[gnome-software] Redo spinners



commit 4cbe92ef5a0a529a3d726482dc722fdffdd7214b
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Sep 1 02:08:18 2013 -0400

    Redo spinners
    
    Manage spinner visibility using a stack instead of an overlay.
    At the same time, add a 'No results found' text to the search
    page.

 src/gnome-software.ui    |  169 ++++++++++++++++++++++++++++++----------------
 src/gs-shell-installed.c |    4 +
 src/gs-shell-search.c    |    9 ++-
 src/gs-shell-updates.c   |   23 +++----
 src/gs-utils.c           |    2 -
 5 files changed, 131 insertions(+), 76 deletions(-)
---
diff --git a/src/gnome-software.ui b/src/gnome-software.ui
index b93cab2..facb20d 100644
--- a/src/gnome-software.ui
+++ b/src/gnome-software.ui
@@ -456,15 +456,21 @@
               </packing>
             </child>
             <child>
-              <object class="GtkOverlay" id="overlay_install">
+              <object class="GtkStack" id="stack_install">
                 <property name="visible">True</property>
-                <child type="overlay">
+                <child>
                   <object class="GtkSpinner" id="spinner_install">
+                    <property name="visible">True</property>
                     <property name="width_request">128</property>
                     <property name="height_request">128</property>
                     <property name="halign">center</property>
                     <property name="valign">center</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
                   </object>
+                  <packing>
+                    <property name="name">spinner</property>
+                  </packing>
                 </child>
                 <child>
                   <object class="GtkScrolledWindow" id="scrolledwindow_install">
@@ -480,6 +486,9 @@
                       <placeholder/>
                     </child>
                   </object>
+                  <packing>
+                    <property name="name">view</property>
+                  </packing>
                 </child>
               </object>
             </child>
@@ -491,15 +500,65 @@
               </object>
             </child>
             <child>
-              <object class="GtkOverlay" id="overlay_search">
+              <object class="GtkStack" id="stack_search">
                 <property name="visible">True</property>
-                <child type="overlay">
+                <child>
                   <object class="GtkSpinner" id="spinner_search">
+                    <property name="visible">True</property>
                     <property name="width_request">128</property>
                     <property name="height_request">128</property>
                     <property name="halign">center</property>
                     <property name="valign">center</property>
                   </object>
+                  <packing>
+                    <property name="name">spinner</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkGrid" id="noresults_grid_search">
+                    <property name="visible">True</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                    <property name="halign">center</property>
+                    <property name="valign">center</property>
+                    <property name="row-spacing">12</property>
+                    <property name="column-spacing">12</property>
+                    <child>
+                      <object class="GtkImage" id="noresults_icon">
+                        <property name="visible">True</property>
+                        <property name="icon-name">emblem-documents-symbolic</property>
+                        <property name="pixel-size">64</property>
+                        <style>
+                          <class name="dim-label"/>
+                        </style>
+                      </object>
+                      <packing>
+                        <property name="left-attach">0</property>
+                        <property name="top-attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="noresults_label">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">No Application Found</property>
+                        <property name="halign">start</property>
+                        <property name="valign">center</property>
+                        <style>
+                          <class name="dim-label"/>
+                        </style>
+                        <attributes>
+                          <attribute name="scale" value="1.4"/>
+                        </attributes>
+                      </object>
+                      <packing>
+                        <property name="left-attach">1</property>
+                        <property name="top-attach">0</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="name">no-results</property>
+                  </packing>
                 </child>
                 <child>
                   <object class="GtkScrolledWindow" id="scrolledwindow_search">
@@ -515,6 +574,9 @@
                       <placeholder/>
                     </child>
                   </object>
+                  <packing>
+                    <property name="name">results</property>
+                  </packing>
                 </child>
               </object>
             </child>
@@ -526,83 +588,74 @@
               </object>
             </child>
             <child>
-              <object class="GtkOverlay" id="overlay_updates">
+              <object class="GtkStack" id="stack_updates">
                 <property name="visible">True</property>
-                <child type="overlay">
+                <child>
                   <object class="GtkSpinner" id="spinner_updates">
+                    <property name="visible">True</property>
                     <property name="width_request">128</property>
                     <property name="height_request">128</property>
                     <property name="halign">center</property>
                     <property name="valign">center</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
                   </object>
+                  <packing>
+                    <property name="name">spinner</property>
+                  </packing>
                 </child>
                 <child>
-                  <object class="GtkBox" id="box6">
+                  <object class="GtkScrolledWindow" id="scrolledwindow_updates">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="hscrollbar_policy">never</property>
+                    <property name="vscrollbar_policy">automatic</property>
+                    <property name="shadow_type">none</property>
+                    <style>
+                      <class name="main-scrolled-software"/>
+                    </style>
+                    <child>
+                      <placeholder/>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="name">view</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkBox" id="updates_uptodate_box">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
                     <property name="orientation">vertical</property>
+                    <property name="spacing">12</property>
+                    <property name="halign">center</property>
+                    <property name="valign">center</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
                     <child>
-                      <object class="GtkScrolledWindow" id="scrolledwindow_updates">
+                      <object class="GtkImage" id="image_updates">
                         <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="hscrollbar_policy">never</property>
-                        <property name="vscrollbar_policy">automatic</property>
-                        <property name="shadow_type">none</property>
+                        <property name="can_focus">False</property>
+                        <property name="pixel_size">128</property>
+                        <property name="icon_name">object-select-symbolic</property>
                         <style>
-                          <class name="main-scrolled-software"/>
+                          <class name="dim-label"/>
                         </style>
-                        <child>
-                          <placeholder/>
-                        </child>
                       </object>
-                      <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
-                      </packing>
                     </child>
                     <child>
-                      <object class="GtkBox" id="box_updates_up_to_date">
+                      <object class="GtkLabel" id="label10">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="orientation">vertical</property>
-                        <child>
-                          <object class="GtkImage" id="image_updates">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="yalign">1</property>
-                            <property name="pixel_size">196</property>
-                            <property name="icon_name">object-select-symbolic</property>
-                            <style>
-                              <class name="dim-label"/>
-                            </style>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">True</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label10">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="label" translatable="yes">Software is up to date</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">True</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
+                        <property name="label" translatable="yes">Software is up to date</property>
+                        <attributes>
+                          <attribute name="scale" value="1.4"/>
+                        </attributes>
                       </object>
-                      <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">False</property>
-                        <property name="position">1</property>
-                      </packing>
                     </child>
                   </object>
+                  <packing>
+                    <property name="name">uptodate</property>
+                  </packing>
                 </child>
               </object>
             </child>
diff --git a/src/gs-shell-installed.c b/src/gs-shell-installed.c
index 027bdc1..75ad14c 100644
--- a/src/gs-shell-installed.c
+++ b/src/gs-shell-installed.c
@@ -226,6 +226,8 @@ gs_shell_installed_get_installed_cb (GObject *source_object,
 
         widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "spinner_install"));
         gs_stop_spinner (GTK_SPINNER (widget));
+        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "stack_install"));
+        gtk_stack_set_visible_child_name (GTK_STACK (widget), "view");
 
         priv->waiting = FALSE;
         priv->cache_valid = TRUE;
@@ -320,6 +322,8 @@ gs_shell_installed_refresh (GsShellInstalled *shell_installed, gboolean scroll_u
 
         spinner = GTK_SPINNER (gtk_builder_get_object (shell_installed->priv->builder, "spinner_install"));
         gs_start_spinner (spinner);
+        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "stack_install"));
+        gtk_stack_set_visible_child_name (GTK_STACK (widget), "spinner");
 
        priv->waiting = TRUE;
 }
diff --git a/src/gs-shell-search.c b/src/gs-shell-search.c
index d120fea..9602250 100644
--- a/src/gs-shell-search.c
+++ b/src/gs-shell-search.c
@@ -220,17 +220,18 @@ gs_shell_search_get_search_cb (GObject *source_object,
 
         widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "spinner_search"));
         gs_stop_spinner (GTK_SPINNER (widget));
+        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "stack_search"));
 
         priv->waiting = FALSE;
 
-       list = gs_plugin_loader_search_finish (plugin_loader,
-                                                     res,
-                                                     &error);
+       list = gs_plugin_loader_search_finish (plugin_loader, res, &error);
        if (list == NULL) {
                g_warning ("failed to get search apps: %s", error->message);
                g_error_free (error);
+                gtk_stack_set_visible_child_name (GTK_STACK (widget), "no-results");
                goto out;
        }
+        gtk_stack_set_visible_child_name (GTK_STACK (widget), "results");
        for (l = list; l != NULL; l = l->next) {
                app = GS_APP (l->data);
                g_debug ("adding search %s", gs_app_get_id (app));
@@ -278,6 +279,8 @@ gs_shell_search_refresh (GsShellSearch *shell_search, const gchar *value)
                                       gs_shell_search_get_search_cb,
                                       shell_search);
 
+        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "stack_search"));
+        gtk_stack_set_visible_child_name (GTK_STACK (widget), "spinner");
         spinner = GTK_SPINNER (gtk_builder_get_object (priv->builder, "spinner_search"));
         gs_start_spinner (spinner);
        priv->waiting = TRUE;
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index d5376a6..eaa1473 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -87,10 +87,13 @@ gs_shell_updates_get_updates_cb (GsPluginLoader *plugin_loader,
        /* get the results */
        list = gs_plugin_loader_get_updates_finish (plugin_loader, res, &error);
 
-       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "box_updates_up_to_date"));
-       gtk_widget_set_visible (widget, list == NULL);
-       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "scrolledwindow_updates"));
-       gtk_widget_set_visible (widget, list != NULL);
+               widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "stack_updates"));
+        if (list == NULL) {
+                gtk_stack_set_visible_child_name (GTK_STACK (widget), "uptodate");
+        }
+        else {
+                gtk_stack_set_visible_child_name (GTK_STACK (widget), "view");
+        }
 
         widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_updates"));
         if (list != NULL && gs_shell_get_mode (priv->shell) != GS_SHELL_MODE_UPDATES)
@@ -137,7 +140,7 @@ gs_shell_updates_refresh (GsShellUpdates *shell_updates, gboolean scroll_up)
                 gtk_widget_show (widget);
         }
 
-        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "scrolledwindow_install"));
+        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "scrolledwindow_updates"));
         if (scroll_up) {
                 GtkAdjustment *adj;
                 adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (widget));
@@ -155,14 +158,6 @@ gs_shell_updates_refresh (GsShellUpdates *shell_updates, gboolean scroll_up)
                return;
         }
 
-        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "spinner_updates"));
-        gtk_widget_show (widget);
-
-       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "box_updates_up_to_date"));
-       gtk_widget_hide (widget);
-       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "scrolledwindow_updates"));
-       gtk_widget_show (widget);
-
         if (priv->waiting)
                 return;
 
@@ -175,6 +170,8 @@ gs_shell_updates_refresh (GsShellUpdates *shell_updates, gboolean scroll_up)
 
         spinner = GTK_SPINNER (gtk_builder_get_object (priv->builder, "spinner_updates"));
         gs_start_spinner (spinner);
+       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "stack_updates"));
+        gtk_stack_set_visible_child_name (GTK_STACK (widget), "spinner");
 
        priv->waiting = TRUE;
 }
diff --git a/src/gs-utils.c b/src/gs-utils.c
index 052bce4..07e8d68 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -55,7 +55,6 @@ start_spinning (gpointer data)
 
         gtk_widget_set_opacity (spinner, 0);
         gtk_spinner_start (GTK_SPINNER (spinner));
-        gtk_widget_show (spinner);
         id = g_timeout_add (100, fade_in, spinner);
         g_object_set_data_full (G_OBJECT (spinner), "fade-timeout",
                                 GUINT_TO_POINTER (id), remove_source);
@@ -66,7 +65,6 @@ start_spinning (gpointer data)
 void
 gs_stop_spinner (GtkSpinner *spinner)
 {
-        gtk_widget_hide (GTK_WIDGET (spinner));
         gtk_spinner_stop (spinner);
 }
 


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