[gnome-software] popular tile: Use GtkStack for switching between states
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] popular tile: Use GtkStack for switching between states
- Date: Tue, 2 Sep 2014 15:00:52 +0000 (UTC)
commit 276c6d3a2e5c920cd258b4261778c6da9bbf565d
Author: Kalev Lember <kalevlember gmail com>
Date: Tue Sep 2 16:34:41 2014 +0200
popular tile: Use GtkStack for switching between states
Instead of manually hiding and showing widgets to switch between the
loading indicator and the actual app tile, use a GtkStack.
This avoids the resizing of the tile when the stars widget gets shown.
src/gs-popular-tile.c | 8 +--
src/popular-tile.ui | 132 +++++++++++++++++++++++++++----------------------
2 files changed, 75 insertions(+), 65 deletions(-)
---
diff --git a/src/gs-popular-tile.c b/src/gs-popular-tile.c
index 305a614..bbabb02 100644
--- a/src/gs-popular-tile.c
+++ b/src/gs-popular-tile.c
@@ -33,8 +33,8 @@ struct _GsPopularTilePrivate
GtkWidget *label;
GtkWidget *image;
GtkWidget *eventbox;
+ GtkWidget *stack;
GtkWidget *stars;
- GtkWidget *waiting;
};
G_DEFINE_TYPE_WITH_PRIVATE (GsPopularTile, gs_popular_tile, GTK_TYPE_BUTTON)
@@ -125,9 +125,7 @@ gs_popular_tile_set_app (GsPopularTile *tile, GsApp *app)
GS_APP_RATING_KIND_KUDOS,
gs_app_get_kudos_percentage (priv->app));
}
- gtk_widget_show (priv->stars);
-
- 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);
@@ -175,8 +173,8 @@ gs_popular_tile_class_init (GsPopularTileClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GsPopularTile, label);
gtk_widget_class_bind_template_child_private (widget_class, GsPopularTile, image);
gtk_widget_class_bind_template_child_private (widget_class, GsPopularTile, eventbox);
+ gtk_widget_class_bind_template_child_private (widget_class, GsPopularTile, stack);
gtk_widget_class_bind_template_child_private (widget_class, GsPopularTile, stars);
- gtk_widget_class_bind_template_child_private (widget_class, GsPopularTile, waiting);
}
GtkWidget *
diff --git a/src/popular-tile.ui b/src/popular-tile.ui
index e1c2efc..8714f7f 100644
--- a/src/popular-tile.ui
+++ b/src/popular-tile.ui
@@ -8,11 +8,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>
@@ -23,76 +22,89 @@
<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">end</property>
- <property name="valign">end</property>
- <property name="margin-bottom">35</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="GtkEventBox" id="eboxbox">
+ <object class="GtkOverlay" id="overlay">
<property name="visible">True</property>
- <child>
- <object class="GtkBox" id="box">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="halign">fill</property>
- <property name="valign">fill</property>
- <property name="margin">10</property>
+ <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">end</property>
+ <property name="valign">end</property>
+ <property name="margin-bottom">35</property>
+ <style>
+ <class name="installed-overlay-box"/>
+ </style>
<child>
- <object class="GtkImage" id="image">
+ <object class="GtkLabel" id="installed-label">
<property name="visible">True</property>
- <property name="valign">center</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>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkEventBox" id="eboxbox">
+ <property name="visible">True</property>
<child>
- <object class="GtkLabel" id="label">
+ <object class="GtkBox" id="box">
<property name="visible">True</property>
- <property name="valign">end</property>
- <property name="margin">6</property>
- <property name="ellipsize">end</property>
- <property name="width_chars">12</property>
- <property name="max_width_chars">12</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- </packing>
- </child>
- <child>
- <object class="GsStarWidget" id="stars">
- <property name="visible">False</property>
- <property name="halign">center</property>
+ <property name="orientation">vertical</property>
+ <property name="halign">fill</property>
+ <property name="valign">fill</property>
+ <property name="margin">10</property>
+ <child>
+ <object class="GtkImage" id="image">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label">
+ <property name="visible">True</property>
+ <property name="valign">end</property>
+ <property name="margin">6</property>
+ <property name="ellipsize">end</property>
+ <property name="width_chars">12</property>
+ <property name="max_width_chars">12</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GsStarWidget" id="stars">
+ <property name="visible">True</property>
+ <property name="halign">center</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- </packing>
</child>
</object>
</child>
</object>
+ <packing>
+ <property name="name">content</property>
+ </packing>
</child>
</object>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]