[gnome-software/wip/installed_updates: 6/16] update dialog: Use a GtkStack instead of manually hiding widgets
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/installed_updates: 6/16] update dialog: Use a GtkStack instead of manually hiding widgets
- Date: Mon, 12 May 2014 12:48:26 +0000 (UTC)
commit e3b72f66b02b802905cae3165138cb79372a2f5f
Author: Kalev Lember <kalevlember gmail com>
Date: Mon Apr 28 16:23:42 2014 +0200
update dialog: Use a GtkStack instead of manually hiding widgets
This paves the way for extending the dialog with additional modes.
src/gs-update-dialog.c | 13 ++--
src/gs-update-dialog.ui | 141 ++++++++++++++++++++++++----------------------
2 files changed, 81 insertions(+), 73 deletions(-)
---
diff --git a/src/gs-update-dialog.c b/src/gs-update-dialog.c
index 099a306..f439bb0 100644
--- a/src/gs-update-dialog.c
+++ b/src/gs-update-dialog.c
@@ -40,6 +40,7 @@ struct _GsUpdateDialogPrivate
GtkWidget *list_box;
GtkWidget *scrolledwindow;
GtkWidget *scrolledwindow_details;
+ GtkWidget *stack;
};
G_DEFINE_TYPE_WITH_PRIVATE (GsUpdateDialog, gs_update_dialog, GTK_TYPE_DIALOG)
@@ -80,8 +81,6 @@ set_updates_description_ui (GsUpdateDialog *dialog, GsApp *app)
/* set update header */
gtk_widget_set_visible (priv->box_header, kind == GS_APP_KIND_NORMAL || kind == GS_APP_KIND_SYSTEM);
- gtk_widget_set_visible (priv->scrolledwindow_details, kind != GS_APP_KIND_OS_UPDATE);
- gtk_widget_set_visible (priv->scrolledwindow, kind == GS_APP_KIND_OS_UPDATE);
gtk_label_set_markup (GTK_LABEL (priv->label_details), update_desc);
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image_icon), gs_app_get_pixbuf (app));
gtk_label_set_label (GTK_LABEL (priv->label_name), gs_app_get_name (app));
@@ -99,7 +98,7 @@ row_activated_cb (GtkListBox *list_box,
app = GS_APP (g_object_get_data (G_OBJECT (gtk_bin_get_child (GTK_BIN (row))), "app"));
/* setup package view */
- gtk_widget_hide (priv->scrolledwindow);
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "package-details");
set_updates_description_ui (dialog, app);
gtk_widget_show (priv->button_back);
}
@@ -168,6 +167,9 @@ gs_update_dialog_set_app (GsUpdateDialog *dialog, GsApp *app)
gtk_widget_show_all (row);
gtk_list_box_insert (GTK_LIST_BOX (priv->list_box), row, -1);
}
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "os-update-list");
+ } else {
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "package-details");
}
}
@@ -191,9 +193,7 @@ button_back_cb (GtkWidget *widget, GsUpdateDialog *dialog)
/* return to the list view */
gtk_widget_hide (priv->button_back);
- gtk_widget_hide (priv->box_header);
- gtk_widget_hide (priv->scrolledwindow_details);
- gtk_widget_show (priv->scrolledwindow);
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "os-update-list");
gtk_window_set_title (GTK_WINDOW (dialog), gs_app_get_name (priv->app));
}
@@ -273,6 +273,7 @@ gs_update_dialog_class_init (GsUpdateDialogClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GsUpdateDialog, list_box);
gtk_widget_class_bind_template_child_private (widget_class, GsUpdateDialog, scrolledwindow);
gtk_widget_class_bind_template_child_private (widget_class, GsUpdateDialog, scrolledwindow_details);
+ gtk_widget_class_bind_template_child_private (widget_class, GsUpdateDialog, stack);
}
GtkWidget *
diff --git a/src/gs-update-dialog.ui b/src/gs-update-dialog.ui
index 8628ec3..9076ceb 100644
--- a/src/gs-update-dialog.ui
+++ b/src/gs-update-dialog.ui
@@ -49,49 +49,29 @@
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
- <object class="GtkBox" id="box7">
+ <object class="GtkStack" id="stack">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="margin_bottom">3</property>
- <property name="border_width">3</property>
- <property name="orientation">vertical</property>
- <property name="spacing">9</property>
<child>
- <object class="GtkBox" id="box_header">
+ <object class="GtkBox" id="box7">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="margin_bottom">3</property>
+ <property name="border_width">3</property>
+ <property name="orientation">vertical</property>
<property name="spacing">9</property>
<child>
- <object class="GtkImage" id="image_icon">
+ <object class="GtkBox" id="box_header">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="pixel_size">96</property>
- <property name="icon_name">accessories-calculator</property>
- <property name="icon_size">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="box9">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">3</property>
+ <property name="spacing">9</property>
<child>
- <object class="GtkLabel" id="label_name">
+ <object class="GtkImage" id="image_icon">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label">Inkscape</property>
- <property name="angle">0.41999998688697815</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- <attribute name="scale" value="1.3999999999999999"/>
- </attributes>
+ <property name="pixel_size">96</property>
+ <property name="icon_name">accessories-calculator</property>
+ <property name="icon_size">0</property>
</object>
<packing>
<property name="expand">False</property>
@@ -100,12 +80,43 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_summary">
+ <object class="GtkBox" id="box9">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label">Vector based drawing program</property>
- <property name="selectable">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">3</property>
+ <child>
+ <object class="GtkLabel" id="label_name">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label">Inkscape</property>
+ <property name="angle">0.41999998688697815</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ <attribute name="scale" value="1.3999999999999999"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_summary">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label">Vector based drawing program</property>
+ <property name="selectable">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -117,44 +128,42 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow_details">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="vexpand">True</property>
- <property name="hscrollbar_policy">never</property>
- <property name="vscrollbar_policy">automatic</property>
- <property name="shadow_type">none</property>
- <property name="kinetic_scrolling">False</property>
<child>
- <object class="GtkLabel" id="label_details">
+ <object class="GtkScrolledWindow" id="scrolledwindow_details">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="margin">6</property>
- <property name="label">New in kmod 14-1
+ <property name="can_focus">True</property>
+ <property name="vexpand">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">none</property>
+ <property name="kinetic_scrolling">False</property>
+ <child>
+ <object class="GtkLabel" id="label_details">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="margin">6</property>
+ <property name="label">New in kmod 14-1
* Moo
* bar</property>
- <property name="wrap">True</property>
- <property name="selectable">True</property>
+ <property name="wrap">True</property>
+ <property name="selectable">True</property>
+ </object>
+ </child>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
+ <property name="name">package-details</property>
</packing>
</child>
<child>
@@ -186,16 +195,14 @@
</child>
</object>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
+ <property name="name">os-update-list</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]