[gnome-software] app tile: Use GtkStack for switching between states



commit 15b352c93d464ba2d85efcd5ef06873ac33a7dab
Author: Kalev Lember <kalevlember gmail com>
Date:   Tue Sep 2 20:33:11 2014 +0200

    app tile: Use GtkStack for switching between states

 src/app-tile.ui   |  180 ++++++++++++++++++++++++++++-------------------------
 src/gs-app-tile.c |    6 +-
 2 files changed, 99 insertions(+), 87 deletions(-)
---
diff --git a/src/app-tile.ui b/src/app-tile.ui
index 0e4caed..5d12195 100644
--- a/src/app-tile.ui
+++ b/src/app-tile.ui
@@ -9,11 +9,10 @@
       <class name="tile"/>
     </style>
     <child>
-      <object class="GtkOverlay" id="overlay">
+      <object class="GtkStack" id="stack">
         <property name="visible">True</property>
-        <property name="halign">fill</property>
-        <property name="valign">fill</property>
-        <child type="overlay">
+        <property name="can_focus">False</property>
+        <child>
           <object class="GtkImage" id="waiting">
             <property name="visible">True</property>
             <property name="halign">center</property>
@@ -24,98 +23,111 @@
               <class name="dim-label"/>
             </style>
           </object>
-        </child>
-        <child type="overlay">
-          <object class="GtkEventBox" id="eventbox">
-            <property name="no_show_all">True</property>
-            <property name="visible_window">True</property>
-            <property name="halign">start</property>
-            <property name="valign">start</property>
-            <property name="margin-top">53</property>
-            <property name="margin-start">4</property>
-            <style>
-              <class name="installed-overlay-box"/>
-            </style>
-            <child>
-              <object class="GtkLabel" id="installed-label">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">Installed</property>
-                <property name="margin-start">16</property>
-                <property name="margin-end">16</property>
-                <property name="margin-top">4</property>
-                <property name="margin-bottom">4</property>
-              </object>
-            </child>
-          </object>
+          <packing>
+            <property name="name">waiting</property>
+          </packing>
         </child>
         <child>
-          <object class="GtkGrid" id="grid">
+          <object class="GtkOverlay" id="overlay">
             <property name="visible">True</property>
-            <property name="margin">9</property>
-            <property name="row-spacing">3</property>
-            <property name="column-spacing">12</property>
-            <child>
-              <object class="GtkImage" id="image">
-                <property name="visible">True</property>
-              </object>
-              <packing>
-                <property name="left-attach">0</property>
-                <property name="top-attach">0</property>
-                <property name="width">1</property>
-                <property name="height">3</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="name">
-                <property name="visible">True</property>
-                <property name="ellipsize">end</property>
-                <property name="xalign">0.0</property>
-                <attributes>
-                  <attribute name="weight" value="bold"/>
-                </attributes>
+            <property name="halign">fill</property>
+            <property name="valign">fill</property>
+            <child type="overlay">
+              <object class="GtkEventBox" id="eventbox">
+                <property name="no_show_all">True</property>
+                <property name="visible_window">True</property>
+                <property name="halign">start</property>
+                <property name="valign">start</property>
+                <property name="margin-top">53</property>
+                <property name="margin-start">4</property>
                 <style>
-                  <class name="app-tile-label"/>
+                  <class name="installed-overlay-box"/>
                 </style>
+                <child>
+                  <object class="GtkLabel" id="installed-label">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Installed</property>
+                    <property name="margin-start">16</property>
+                    <property name="margin-end">16</property>
+                    <property name="margin-top">4</property>
+                    <property name="margin-bottom">4</property>
+                  </object>
+                </child>
               </object>
-              <packing>
-                <property name="left-attach">1</property>
-                <property name="top-attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
             </child>
             <child>
-              <object class="GsStarWidget" id="stars">
-                <property name="visible">False</property>
-                <property name="halign">start</property>
-              </object>
-              <packing>
-                <property name="left-attach">1</property>
-                <property name="top-attach">1</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="summary">
+              <object class="GtkGrid" id="grid">
                 <property name="visible">True</property>
-                <property name="ellipsize">end</property>
-                <property name="xalign">0.0</property>
-                <property name="yalign">0.0</property>
-                <property name="lines">2</property>
-                <property name="vexpand">True</property>
-                <style>
-                  <class name="app-tile-label"/>
-                </style>
+                <property name="margin">9</property>
+                <property name="row-spacing">3</property>
+                <property name="column-spacing">12</property>
+                <child>
+                  <object class="GtkImage" id="image">
+                    <property name="visible">True</property>
+                  </object>
+                  <packing>
+                    <property name="left-attach">0</property>
+                    <property name="top-attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="name">
+                    <property name="visible">True</property>
+                    <property name="ellipsize">end</property>
+                    <property name="xalign">0.0</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
+                    <style>
+                      <class name="app-tile-label"/>
+                    </style>
+                  </object>
+                  <packing>
+                    <property name="left-attach">1</property>
+                    <property name="top-attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GsStarWidget" id="stars">
+                    <property name="visible">False</property>
+                    <property name="halign">start</property>
+                  </object>
+                  <packing>
+                    <property name="left-attach">1</property>
+                    <property name="top-attach">1</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="summary">
+                    <property name="visible">True</property>
+                    <property name="ellipsize">end</property>
+                    <property name="xalign">0.0</property>
+                    <property name="yalign">0.0</property>
+                    <property name="lines">2</property>
+                    <property name="vexpand">True</property>
+                    <style>
+                      <class name="app-tile-label"/>
+                    </style>
+                  </object>
+                  <packing>
+                    <property name="left-attach">1</property>
+                    <property name="top-attach">2</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
               </object>
-              <packing>
-                <property name="left-attach">1</property>
-                <property name="top-attach">2</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
             </child>
           </object>
+          <packing>
+            <property name="name">content</property>
+          </packing>
         </child>
       </object>
     </child>
diff --git a/src/gs-app-tile.c b/src/gs-app-tile.c
index 0236643..eef6882 100644
--- a/src/gs-app-tile.c
+++ b/src/gs-app-tile.c
@@ -34,7 +34,7 @@ struct _GsAppTilePrivate
        GtkWidget       *name;
        GtkWidget       *summary;
        GtkWidget       *eventbox;
-       GtkWidget       *waiting;
+       GtkWidget       *stack;
        GtkWidget       *stars;
 };
 
@@ -150,7 +150,7 @@ gs_app_tile_set_app (GsAppTile *tile, GsApp *app)
                                           gs_app_get_kudos_percentage (priv->app));
        }
 
-       gtk_widget_hide (priv->waiting);
+       gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "content");
 
         g_signal_connect (priv->app, "notify::state",
                           G_CALLBACK (app_state_changed), tile);
@@ -202,7 +202,7 @@ gs_app_tile_class_init (GsAppTileClass *klass)
        gtk_widget_class_bind_template_child_private (widget_class, GsAppTile, name);
        gtk_widget_class_bind_template_child_private (widget_class, GsAppTile, summary);
         gtk_widget_class_bind_template_child_private (widget_class, GsAppTile, eventbox);
-        gtk_widget_class_bind_template_child_private (widget_class, GsAppTile, waiting);
+        gtk_widget_class_bind_template_child_private (widget_class, GsAppTile, stack);
         gtk_widget_class_bind_template_child_private (widget_class, GsAppTile, stars);
 }
 


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