[gnome-software/gnome-3-20] updates page: Move the Install & Restart button below the upgrade banner
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-20] updates page: Move the Install & Restart button below the upgrade banner
- Date: Mon, 14 Mar 2016 10:58:46 +0000 (UTC)
commit 65227355bbc54e9c13978804bae8a9a06c5bca94
Author: Kalev Lember <klember redhat com>
Date: Wed Feb 24 14:52:20 2016 +0100
updates page: Move the Install & Restart button below the upgrade banner
This adds a "fake" header bar under the upgrade banner widget, so that
when the upgrade banner is visible we can show the button down there, as
per mockups.
src/gs-shell-updates.c | 30 ++++++++++++++++++++++++++++--
src/gs-shell-updates.ui | 21 +++++++++++++++++++++
src/gtk-style-hc.css | 6 ++++++
src/gtk-style.css | 6 ++++++
4 files changed, 61 insertions(+), 2 deletions(-)
---
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index 46cf622..ba186c7 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -72,11 +72,13 @@ struct _GsShellUpdates
GtkWidget *button_update_all;
GtkWidget *header_spinner_start;
GtkWidget *header_start_box;
+ GtkWidget *header_end_box;
gboolean has_agreed_to_mobile_data;
gboolean ampm_available;
GtkWidget *button_updates_mobile;
GtkWidget *button_updates_offline;
+ GtkWidget *fake_header_bar;
GtkWidget *label_updates_failed;
GtkWidget *label_updates_last_checked;
GtkWidget *label_updates_spinner;
@@ -209,6 +211,7 @@ gs_shell_updates_get_state_string (GsPluginStatus status)
static void
gs_shell_updates_update_ui_state (GsShellUpdates *self)
{
+ GtkWidget *old_parent;
gboolean allow_mobile_refresh = TRUE;
g_autofree gchar *checked_str = NULL;
g_autofree gchar *spinner_str = NULL;
@@ -383,10 +386,28 @@ gs_shell_updates_update_ui_state (GsShellUpdates *self)
break;
}
- /* upgrade banner */
+ /* are we showing an upgrade banner? */
if (gs_upgrade_banner_get_app (GS_UPGRADE_BANNER (self->upgrade_banner)) != NULL) {
+ /* move header bar buttons to the fake header bar */
+ g_object_ref (self->button_update_all);
+ old_parent = gtk_widget_get_parent (self->button_update_all);
+ if (old_parent != NULL)
+ gtk_container_remove (GTK_CONTAINER (old_parent), self->button_update_all);
+ gtk_header_bar_pack_end (GTK_HEADER_BAR (self->fake_header_bar), self->button_update_all);
+ g_object_unref (self->button_update_all);
+
+ gtk_widget_show (self->fake_header_bar);
gtk_widget_show (self->upgrade_banner);
} else {
+ /* move header bar buttons to the real header bar */
+ g_object_ref (self->button_update_all);
+ old_parent = gtk_widget_get_parent (self->button_update_all);
+ if (old_parent != NULL)
+ gtk_container_remove (GTK_CONTAINER (old_parent), self->button_update_all);
+ gtk_container_add (GTK_CONTAINER (self->header_end_box), self->button_update_all);
+ g_object_unref (self->button_update_all);
+
+ gtk_widget_hide (self->fake_header_bar);
gtk_widget_hide (self->upgrade_banner);
}
@@ -1131,10 +1152,14 @@ gs_shell_updates_setup (GsShellUpdates *self,
g_signal_connect (self->upgrade_banner, "install-button-clicked",
G_CALLBACK (gs_shell_updates_install_upgrade_cb), self);
+ self->header_end_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ gtk_widget_set_visible (self->header_end_box, TRUE);
+ gs_page_set_header_end_widget (GS_PAGE (self), self->header_end_box);
+
self->button_update_all = gtk_button_new_with_mnemonic (_("Restart & _Install"));
gtk_widget_set_visible (self->button_update_all, TRUE);
gtk_style_context_add_class (gtk_widget_get_style_context (self->button_update_all),
"suggested-action");
- gs_page_set_header_end_widget (GS_PAGE (self), self->button_update_all);
+ gtk_container_add (GTK_CONTAINER (self->header_end_box), self->button_update_all);
g_signal_connect (self->button_update_all, "clicked", G_CALLBACK
(gs_shell_updates_button_update_all_cb), self);
self->header_start_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
@@ -1219,6 +1244,7 @@ gs_shell_updates_class_init (GsShellUpdatesClass *klass)
gtk_widget_class_bind_template_child (widget_class, GsShellUpdates, button_updates_mobile);
gtk_widget_class_bind_template_child (widget_class, GsShellUpdates, button_updates_offline);
+ gtk_widget_class_bind_template_child (widget_class, GsShellUpdates, fake_header_bar);
gtk_widget_class_bind_template_child (widget_class, GsShellUpdates, label_updates_failed);
gtk_widget_class_bind_template_child (widget_class, GsShellUpdates, label_updates_last_checked);
gtk_widget_class_bind_template_child (widget_class, GsShellUpdates, label_updates_spinner);
diff --git a/src/gs-shell-updates.ui b/src/gs-shell-updates.ui
index fd652ff..1153466 100644
--- a/src/gs-shell-updates.ui
+++ b/src/gs-shell-updates.ui
@@ -72,6 +72,27 @@
</object>
</child>
<child>
+ <object class="GtkHeaderBar" id="fake_header_bar">
+ <property name="visible">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">False</property>
+ <style>
+ <class name="fake-header-bar"/>
+ </style>
+ <child>
+ <object class="GtkLabel" id="label101">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Other Updates</property>
+ <property name="margin_start">18</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
<object class="GsUpdateList" id="list_box_updates">
<property name="visible">True</property>
<property name="can_focus">True</property>
diff --git a/src/gtk-style-hc.css b/src/gtk-style-hc.css
index 44f3876..a5fe5f2 100644
--- a/src/gtk-style-hc.css
+++ b/src/gtk-style-hc.css
@@ -133,6 +133,12 @@
color: white;
}
+.fake-header-bar {
+ background-color: white;
+ background-image: none;
+ border-radius: 0;
+}
+
.header-label {
font-size: 11px;
padding: 6px;
diff --git a/src/gtk-style.css b/src/gtk-style.css
index 8995089..ed3912c 100644
--- a/src/gtk-style.css
+++ b/src/gtk-style.css
@@ -173,6 +173,12 @@
color: white;
}
+.fake-header-bar {
+ background-color: white;
+ background-image: none;
+ border-radius: 0;
+}
+
.header-label {
font-size: 11px;
padding: 6px;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]