[gnome-software] Change the style for update counters



commit 576265f7d10d76bfcbaaabf491f2974df3d4db11
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Nov 15 22:04:07 2013 -0500

    Change the style for update counters
    
    Instead of a throbbing button, we now use a separate label
    with a blue background for the counter.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=710169

 src/gnome-software.ui    |   76 +++++++++++++++++++++++++++++++++++++++++++--
 src/gs-shell-installed.c |   15 ++++-----
 src/gs-shell-updates.c   |   18 ++++-------
 src/gtk-style-hc.css     |    9 +++++
 src/gtk-style.css        |    8 +++++
 5 files changed, 102 insertions(+), 24 deletions(-)
---
diff --git a/src/gnome-software.ui b/src/gnome-software.ui
index c2ac09b..2401e80 100644
--- a/src/gnome-software.ui
+++ b/src/gnome-software.ui
@@ -94,8 +94,42 @@
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
-                        <property name="use_underline">True</property>
-                        <property name="label" translatable="yes" comments="Translators: A label for a 
button to show only software which is already installed.">_Installed</property>
+                        <child>
+                          <object class="GtkBox" id="button_installed_box">
+                            <property name="visible">True</property>
+                            <property name="orientation">horizontal</property>
+                            <property name="halign">fill</property>
+                            <property name="spacing">6</property>
+                            <child>
+                              <object class="GtkLabel" id="button_installed_label">
+                                <property name="visible">True</property>
+                                <property name="use_underline">True</property>
+                                <property name="halign">center</property>
+                                <property name="label" translatable="yes" comments="Translators: A label for 
a button to show only software which is already installed.">_Installed</property>
+                                <property name="mnemonic_widget">button_installed</property>
+                                <style>
+                                  <class name="text-button"/>
+                                </style>
+                              </object>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="button_installed_counter">
+                                <property name="width-chars">2</property>
+                                <style>
+                                  <class name="counter-label"/>
+                                </style>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
                         <style>
                           <class name="toolbar-primary-buttons-software"/>
                         </style>
@@ -111,8 +145,42 @@
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
-                        <property name="use_underline">True</property>
-                        <property name="label" translatable="yes" comments="Translators: A label for a 
button to show only updates which are available to install.">_Updates</property>
+                        <child>
+                          <object class="GtkBox" id="button_updates_box">
+                            <property name="visible">True</property>
+                            <property name="orientation">horizontal</property>
+                            <property name="halign">fill</property>
+                            <property name="spacing">6</property>
+                            <child>
+                              <object class="GtkLabel" id="button_updates_label">
+                                <property name="visible">True</property>
+                                <property name="use_underline">True</property>
+                                <property name="halign">center</property>
+                                <property name="label" translatable="yes" comments="Translators: A label for 
a button to show only updates which are available to install.">_Updates</property>
+                                <property name="mnemonic_widget">button_updates</property>
+                                <style>
+                                  <class name="text-button"/>
+                                </style>
+                              </object>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="button_updates_counter">
+                                <property name="width-chars">2</property>
+                                <style>
+                                  <class name="counter-label"/>
+                                </style>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
                         <style>
                           <class name="toolbar-primary-buttons-software"/>
                         </style>
diff --git a/src/gs-shell-installed.c b/src/gs-shell-installed.c
index bdc3ee4..29d3b89 100644
--- a/src/gs-shell-installed.c
+++ b/src/gs-shell-installed.c
@@ -527,17 +527,14 @@ gs_shell_installed_pending_apps_changed_cb (GsPluginLoader *plugin_loader,
        GsApp *app;
 
        widget = GTK_WIDGET (gtk_builder_get_object (shell_installed->priv->builder,
-                                                    "button_installed"));
+                                                    "button_installed_counter"));
        pending = gs_plugin_loader_get_pending (plugin_loader);
        if (pending->len == 0) {
-               /* TRANSLATORS: this is tab button to show the list of
-                * installed software */
-               label = g_strdup (_("_Installed"));
+               //gtk_widget_hide (widget);
+               label = g_strdup ("0");
        } else {
-               /* TRANSLATORS: this is tab button to show the list of
-                * installed software. The '%d' refers to the number of
-                * applications either installing or erasing */
-               label = g_strdup_printf (_("_Installed (%d)"), pending->len);
+               gtk_widget_show (widget);
+               label = g_strdup_printf ("%d", pending->len);
        }
        for (i = 0; i < pending->len; i++) {
                app = GS_APP (g_ptr_array_index (pending, i));
@@ -558,7 +555,7 @@ gs_shell_installed_pending_apps_changed_cb (GsPluginLoader *plugin_loader,
                }
        }
 
-       gtk_button_set_label (GTK_BUTTON (widget), label);
+       gtk_label_set_label (GTK_LABEL (widget), label);
        g_free (label);
        g_ptr_array_unref (pending);
 }
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index 9d8531c..15f72b3 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -97,21 +97,17 @@ gs_shell_updates_get_updates_cb (GsPluginLoader *plugin_loader,
                gtk_stack_set_visible_child_name (GTK_STACK (widget), "view");
        }
 
-       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_updates"));
+       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_updates_counter"));
        if (list != NULL) {
                gchar *text;
-               /* TRANSLATORS: A label for a button to show only updates
-                * which are available to install. The '%d' refers to the
-                * number of available updates
-                */
-               text = g_strdup_printf (_("_Updates (%d)"), g_list_length (list));
-               gtk_button_set_label (GTK_BUTTON (widget), text);
+               text = g_strdup_printf ("%d", g_list_length (list));
+               gtk_label_set_label (GTK_LABEL (widget), text);
                g_free (text);
+               gtk_widget_show (widget);
        } else {
-               /* TRANSLATORS: A label for a button to show only updates
-                * which are available to install.
-                */
-               gtk_button_set_label (GTK_BUTTON (widget), _("_Updates"));
+               gtk_label_set_label (GTK_LABEL (widget), "0");
+               //gtk_widget_hide (widget);
+               gtk_widget_show (widget);
        }
 
        if (list != NULL &&
diff --git a/src/gtk-style-hc.css b/src/gtk-style-hc.css
index dd54c08..c82d045 100644
--- a/src/gtk-style-hc.css
+++ b/src/gtk-style-hc.css
@@ -35,3 +35,12 @@
        background-color: #ffffff;
        border-color: #000000;
 }
+
+.counter-label {
+    color: @theme_selected_fg_color;
+    background-color: @theme_highlight_color;
+    font-size: smaller;
+    font-weight: bold;
+    border-radius: 4px;
+    padding: 0px 4px;
+}
diff --git a/src/gtk-style.css b/src/gtk-style.css
index 2f4d44f..55ec1e0 100644
--- a/src/gtk-style.css
+++ b/src/gtk-style.css
@@ -110,3 +110,11 @@ GtkNotebook.main-notebook-software > GtkScrolledWindow {
        border-width: 0px;
        padding: 0;
 }
+
+.counter-label {
+    color: @theme_selected_fg_color;
+    background-color: mix(@theme_selected_bg_color, @theme_selected_fg_color, 0.3);
+    font-size: smaller;
+    border-radius: 4px;
+    padding: 0px 4px;
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]