[gnome-software] Make the distro upgrades dialog match the new mockup
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Make the distro upgrades dialog match the new mockup
- Date: Tue, 12 Apr 2016 18:38:25 +0000 (UTC)
commit fe39ed50897121beff7e352061a767b4393f86d6
Author: Richard Hughes <richard hughsie com>
Date: Tue Apr 12 15:15:01 2016 +0100
Make the distro upgrades dialog match the new mockup
src/gs-shell-updates.c | 49 +++++++++++++++++++---
src/gs-shell-updates.ui | 12 +-----
src/gs-upgrade-banner.c | 73 +++++++++++++++++++++++----------
src/gs-upgrade-banner.h | 7 ++-
src/gs-upgrade-banner.ui | 103 ++++++++++++++++++++++++++++++++-------------
src/gtk-style.css | 6 +-
6 files changed, 174 insertions(+), 76 deletions(-)
---
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index 08a49eb..75c91bd 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -58,6 +58,7 @@ struct _GsShellUpdates
GtkBuilder *builder;
GCancellable *cancellable;
GCancellable *cancellable_refresh;
+ GCancellable *cancellable_upgrade_download;
GSettings *settings;
GSettings *desktop_settings;
gboolean cache_valid;
@@ -1016,7 +1017,7 @@ upgrade_download_finished_cb (GObject *source,
}
static void
-gs_shell_updates_download_upgrade_cb (GsUpgradeBanner *upgrade_banner,
+gs_shell_updates_upgrade_download_cb (GsUpgradeBanner *upgrade_banner,
GsShellUpdates *self)
{
GsApp *app;
@@ -1027,10 +1028,13 @@ gs_shell_updates_download_upgrade_cb (GsUpgradeBanner *upgrade_banner,
return;
}
+ if (self->cancellable_upgrade_download != NULL)
+ g_object_unref (self->cancellable_upgrade_download);
+ self->cancellable_upgrade_download = g_cancellable_new ();
gs_plugin_loader_app_action_async (self->plugin_loader,
app,
GS_PLUGIN_LOADER_ACTION_UPGRADE_DOWNLOAD,
- self->cancellable,
+ self->cancellable_upgrade_download,
upgrade_download_finished_cb,
self);
}
@@ -1094,7 +1098,7 @@ upgrade_trigger_finished_cb (GObject *source,
}
static void
-gs_shell_updates_install_upgrade_cb (GsUpgradeBanner *upgrade_banner,
+gs_shell_updates_upgrade_install_cb (GsUpgradeBanner *upgrade_banner,
GsShellUpdates *self)
{
GsApp *app;
@@ -1113,6 +1117,26 @@ gs_shell_updates_install_upgrade_cb (GsUpgradeBanner *upgrade_banner,
self);
}
+static void
+gs_shell_updates_upgrade_help_cb (GsUpgradeBanner *upgrade_banner,
+ GsShellUpdates *self)
+{
+ GsApp *app;
+ const gchar *uri;
+ g_autoptr(GError) error = NULL;
+
+ app = gs_upgrade_banner_get_app (upgrade_banner);
+ if (app == NULL) {
+ g_warning ("no upgrade available to launch");
+ return;
+ }
+
+ /* open the link */
+ uri = gs_app_get_url (app, AS_URL_KIND_HOMEPAGE);
+ if (!gtk_show_uri (NULL, uri, GDK_CURRENT_TIME, &error))
+ g_warning ("failed to open %s: %s", uri, error->message);
+}
+
/**
* gs_shell_updates_status_changed_cb:
**/
@@ -1152,6 +1176,13 @@ gs_shell_updates_monitor_permission (GsShellUpdates *self)
G_CALLBACK (on_permission_changed), self);
}
+static void
+gs_shell_updates_upgrade_cancel_cb (GsUpgradeBanner *upgrade_banner,
+ GsShellUpdates *self)
+{
+ g_cancellable_cancel (self->cancellable_upgrade_download);
+}
+
void
gs_shell_updates_setup (GsShellUpdates *self,
GsShell *shell,
@@ -1182,10 +1213,14 @@ gs_shell_updates_setup (GsShellUpdates *self,
G_CALLBACK (gs_shell_updates_button_clicked_cb), self);
/* setup system upgrades */
- g_signal_connect (self->upgrade_banner, "download-button-clicked",
- G_CALLBACK (gs_shell_updates_download_upgrade_cb), self);
- g_signal_connect (self->upgrade_banner, "install-button-clicked",
- G_CALLBACK (gs_shell_updates_install_upgrade_cb), self);
+ g_signal_connect (self->upgrade_banner, "download-clicked",
+ G_CALLBACK (gs_shell_updates_upgrade_download_cb), self);
+ g_signal_connect (self->upgrade_banner, "install-clicked",
+ G_CALLBACK (gs_shell_updates_upgrade_install_cb), self);
+ g_signal_connect (self->upgrade_banner, "cancel-clicked",
+ G_CALLBACK (gs_shell_updates_upgrade_cancel_cb), self);
+ g_signal_connect (self->upgrade_banner, "help-clicked",
+ G_CALLBACK (gs_shell_updates_upgrade_help_cb), self);
self->header_end_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_widget_set_visible (self->header_end_box, TRUE);
diff --git a/src/gs-shell-updates.ui b/src/gs-shell-updates.ui
index 1153466..c88716c 100644
--- a/src/gs-shell-updates.ui
+++ b/src/gs-shell-updates.ui
@@ -76,20 +76,10 @@
<property name="visible">True</property>
<property name="hexpand">True</property>
<property name="vexpand">False</property>
+ <property name="title" translatable="yes">Other Updates</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>
diff --git a/src/gs-upgrade-banner.c b/src/gs-upgrade-banner.c
index 45a18db..c991f3e 100644
--- a/src/gs-upgrade-banner.c
+++ b/src/gs-upgrade-banner.c
@@ -33,9 +33,11 @@ typedef struct
GtkWidget *button_upgrades_download;
GtkWidget *button_upgrades_install;
- GtkWidget *button_upgrades_learn_more;
+ GtkWidget *button_upgrades_help;
+ GtkWidget *button_upgrades_cancel;
GtkWidget *label_upgrades_summary;
GtkWidget *label_upgrades_title;
+ GtkWidget *label_upgrades_warning;
GtkWidget *progressbar;
} GsUpgradeBannerPrivate;
@@ -44,7 +46,8 @@ G_DEFINE_TYPE_WITH_PRIVATE (GsUpgradeBanner, gs_upgrade_banner, GTK_TYPE_BIN)
enum {
SIGNAL_DOWNLOAD_BUTTON_CLICKED,
SIGNAL_INSTALL_BUTTON_CLICKED,
- SIGNAL_LEARN_MORE_BUTTON_CLICKED,
+ SIGNAL_HELP_BUTTON_CLICKED,
+ SIGNAL_CANCEL_BUTTON_CLICKED,
SIGNAL_LAST
};
@@ -54,6 +57,7 @@ static void
gs_upgrade_banner_refresh (GsUpgradeBanner *self)
{
GsUpgradeBannerPrivate *priv = gs_upgrade_banner_get_instance_private (self);
+ const gchar *uri;
if (priv->app == NULL)
return;
@@ -72,10 +76,12 @@ gs_upgrade_banner_refresh (GsUpgradeBanner *self)
/* TRANSLATORS: This is the text displayed when a distro
* upgrade is available. First %s is the distro name and the
* 2nd %s is the version, e.g. "Fedora 23 Now Available" */
- str = g_strdup_printf (_("%s %s Now Available"),
+ str = g_strdup_printf (_("<b>%s %s</b> Now Available"),
gs_app_get_name (priv->app),
gs_app_get_version (priv->app));
- gtk_label_set_text (GTK_LABEL (priv->label_upgrades_title), str);
+ gtk_label_set_markup (GTK_LABEL (priv->label_upgrades_title), str);
+ gtk_widget_set_visible (priv->label_upgrades_warning, FALSE);
+ gtk_widget_set_visible (priv->button_upgrades_cancel, FALSE);
break;
}
case AS_APP_STATE_INSTALLING:
@@ -85,10 +91,12 @@ gs_upgrade_banner_refresh (GsUpgradeBanner *self)
/* TRANSLATORS: This is the text displayed while downloading a
* distro upgrade. First %s is the distro name and the 2nd %s
* is the version, e.g. "Downloading Fedora 23" */
- str = g_strdup_printf (_("Downloading %s %s"),
+ str = g_strdup_printf (_("Downloading <b>%s %s</b>"),
gs_app_get_name (priv->app),
gs_app_get_version (priv->app));
- gtk_label_set_text (GTK_LABEL (priv->label_upgrades_title), str);
+ gtk_label_set_markup (GTK_LABEL (priv->label_upgrades_title), str);
+ gtk_widget_set_visible (priv->label_upgrades_warning, FALSE);
+ gtk_widget_set_visible (priv->button_upgrades_cancel, TRUE);
break;
}
case AS_APP_STATE_UPDATABLE:
@@ -99,10 +107,12 @@ gs_upgrade_banner_refresh (GsUpgradeBanner *self)
* upgrade has been downloaded and is ready to be installed.
* First %s is the distro name and the 2nd %s is the version,
* e.g. "Fedora 23 Ready to be Installed" */
- str = g_strdup_printf (_("%s %s Ready to be Installed"),
+ str = g_strdup_printf (_("<b>%s %s</b> Ready to be Installed"),
gs_app_get_name (priv->app),
gs_app_get_version (priv->app));
- gtk_label_set_text (GTK_LABEL (priv->label_upgrades_title), str);
+ gtk_label_set_markup (GTK_LABEL (priv->label_upgrades_title), str);
+ gtk_widget_set_visible (priv->label_upgrades_warning, TRUE);
+ gtk_widget_set_visible (priv->button_upgrades_cancel, FALSE);
break;
}
default:
@@ -118,17 +128,14 @@ gs_upgrade_banner_refresh (GsUpgradeBanner *self)
/* Show the right buttons for the current state */
switch (gs_app_get_state (priv->app)) {
case AS_APP_STATE_AVAILABLE:
- gtk_widget_show (priv->button_upgrades_learn_more);
gtk_widget_show (priv->button_upgrades_download);
gtk_widget_hide (priv->button_upgrades_install);
break;
case AS_APP_STATE_INSTALLING:
- gtk_widget_show (priv->button_upgrades_learn_more);
gtk_widget_hide (priv->button_upgrades_download);
gtk_widget_hide (priv->button_upgrades_install);
break;
case AS_APP_STATE_UPDATABLE:
- gtk_widget_show (priv->button_upgrades_learn_more);
gtk_widget_hide (priv->button_upgrades_download);
gtk_widget_show (priv->button_upgrades_install);
break;
@@ -137,11 +144,15 @@ gs_upgrade_banner_refresh (GsUpgradeBanner *self)
break;
}
+ /* only show help when we have a URL */
+ uri = gs_app_get_url (priv->app, AS_URL_KIND_HOMEPAGE);
+ gtk_widget_set_visible (priv->button_upgrades_help, uri != NULL);
+
/* do a fill bar for the current progress */
switch (gs_app_get_state (priv->app)) {
case AS_APP_STATE_INSTALLING:
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->progressbar),
- gs_app_get_progress (priv->app));
+ (gdouble) gs_app_get_progress (priv->app) / 100.0f);
gtk_widget_show (priv->progressbar);
break;
default:
@@ -188,7 +199,13 @@ install_button_cb (GtkWidget *widget, GsUpgradeBanner *self)
static void
learn_more_button_cb (GtkWidget *widget, GsUpgradeBanner *self)
{
- g_signal_emit (self, signals[SIGNAL_LEARN_MORE_BUTTON_CLICKED], 0);
+ g_signal_emit (self, signals[SIGNAL_HELP_BUTTON_CLICKED], 0);
+}
+
+static void
+cancel_button_cb (GtkWidget *widget, GsUpgradeBanner *self)
+{
+ g_signal_emit (self, signals[SIGNAL_CANCEL_BUTTON_CLICKED], 0);
}
void
@@ -255,9 +272,12 @@ gs_upgrade_banner_init (GsUpgradeBanner *self)
g_signal_connect (priv->button_upgrades_install, "clicked",
G_CALLBACK (install_button_cb),
self);
- g_signal_connect (priv->button_upgrades_learn_more, "clicked",
+ g_signal_connect (priv->button_upgrades_help, "clicked",
G_CALLBACK (learn_more_button_cb),
self);
+ g_signal_connect (priv->button_upgrades_cancel, "clicked",
+ G_CALLBACK (cancel_button_cb),
+ self);
}
static void
@@ -269,23 +289,30 @@ gs_upgrade_banner_class_init (GsUpgradeBannerClass *klass)
widget_class->destroy = gs_upgrade_banner_destroy;
signals [SIGNAL_DOWNLOAD_BUTTON_CLICKED] =
- g_signal_new ("download-button-clicked",
+ g_signal_new ("download-clicked",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GsUpgradeBannerClass, download_button_clicked),
+ G_STRUCT_OFFSET (GsUpgradeBannerClass, download_clicked),
NULL, NULL, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals [SIGNAL_INSTALL_BUTTON_CLICKED] =
- g_signal_new ("install-button-clicked",
+ g_signal_new ("install-clicked",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GsUpgradeBannerClass, install_clicked),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals [SIGNAL_CANCEL_BUTTON_CLICKED] =
+ g_signal_new ("cancel-clicked",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GsUpgradeBannerClass, install_button_clicked),
+ G_STRUCT_OFFSET (GsUpgradeBannerClass, cancel_clicked),
NULL, NULL, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- signals [SIGNAL_LEARN_MORE_BUTTON_CLICKED] =
- g_signal_new ("learn-more-button-clicked",
+ signals [SIGNAL_HELP_BUTTON_CLICKED] =
+ g_signal_new ("help-clicked",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GsUpgradeBannerClass, learn_more_button_clicked),
+ G_STRUCT_OFFSET (GsUpgradeBannerClass, help_clicked),
NULL, NULL, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
@@ -293,10 +320,12 @@ gs_upgrade_banner_class_init (GsUpgradeBannerClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GsUpgradeBanner,
button_upgrades_download);
gtk_widget_class_bind_template_child_private (widget_class, GsUpgradeBanner, button_upgrades_install);
- gtk_widget_class_bind_template_child_private (widget_class, GsUpgradeBanner,
button_upgrades_learn_more);
+ gtk_widget_class_bind_template_child_private (widget_class, GsUpgradeBanner, button_upgrades_cancel);
+ gtk_widget_class_bind_template_child_private (widget_class, GsUpgradeBanner, button_upgrades_help);
gtk_widget_class_bind_template_child_private (widget_class, GsUpgradeBanner, label_upgrades_summary);
gtk_widget_class_bind_template_child_private (widget_class, GsUpgradeBanner, label_upgrades_title);
gtk_widget_class_bind_template_child_private (widget_class, GsUpgradeBanner, progressbar);
+ gtk_widget_class_bind_template_child_private (widget_class, GsUpgradeBanner, label_upgrades_warning);
}
GtkWidget *
diff --git a/src/gs-upgrade-banner.h b/src/gs-upgrade-banner.h
index 8e01884..afd727d 100644
--- a/src/gs-upgrade-banner.h
+++ b/src/gs-upgrade-banner.h
@@ -36,9 +36,10 @@ struct _GsUpgradeBannerClass
{
GtkBinClass parent_class;
- void (*download_button_clicked) (GsUpgradeBanner *self);
- void (*install_button_clicked) (GsUpgradeBanner *self);
- void (*learn_more_button_clicked) (GsUpgradeBanner *self);
+ void (*download_clicked) (GsUpgradeBanner *self);
+ void (*install_clicked) (GsUpgradeBanner *self);
+ void (*cancel_clicked) (GsUpgradeBanner *self);
+ void (*help_clicked) (GsUpgradeBanner *self);
};
GtkWidget *gs_upgrade_banner_new (void);
diff --git a/src/gs-upgrade-banner.ui b/src/gs-upgrade-banner.ui
index 0ee10db..d1ce4f5 100644
--- a/src/gs-upgrade-banner.ui
+++ b/src/gs-upgrade-banner.ui
@@ -8,6 +8,10 @@
<property name="orientation">vertical</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
+ <property name="margin-top">48</property>
+ <property name="margin-bottom">76</property>
+ <property name="height-request">300</property>
+ <property name="valign">center</property>
<style>
<class name="upgrade-banner"/>
</style>
@@ -15,8 +19,8 @@
<object class="GtkLabel" id="label_upgrades_title">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="margin_top">42</property>
- <property name="margin_bottom">8</property>
+ <property name="margin-top">66</property>
+ <property name="margin_bottom">26</property>
<!-- Just a placeholder; actual label text is set in code -->
<property name="label">GNOME 3.20 Now Available</property>
<attributes>
@@ -29,38 +33,32 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">A major upgrade, with new features and added
polish.</property>
- <property name="margin_bottom">12</property>
<attributes>
<attribute name="scale" value="1.2"/>
</attributes>
</object>
</child>
<child>
- <object class="GtkProgressBar" id="progressbar">
+ <object class="GtkLabel" id="label_upgrades_warning">
<property name="visible">True</property>
- <property name="width_request">480</property>
- <property name="halign">center</property>
- <property name="fraction">0.3</property>
- <property name="margin_top">8</property>
- <style>
- <class name="upgrade-progressbar"/>
- </style>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">It is recommended that you back up your data and files
before upgrading.</property>
+ <property name="margin_top">32</property>
+ <attributes>
+ <attribute name="scale" value="0.9"/>
+ </attributes>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- </packing>
</child>
<child>
<object class="GtkBox" id="box_upgrades_buttons">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
- <property name="halign">center</property>
+ <property name="halign">fill</property>
+ <property name="valign">end</property>
<property name="spacing">12</property>
<property name="margin_top">16</property>
- <property name="margin_bottom">28</property>
<child>
- <object class="GtkButton" id="button_upgrades_learn_more">
+ <object class="GtkButton" id="button_upgrades_help">
<property name="label" translatable="yes">_Learn More</property>
<property name="width_request">150</property>
<property name="visible">True</property>
@@ -77,6 +75,45 @@
<property name="fill">False</property>
</packing>
</child>
+
+ <child>
+ <object class="GtkLabel" id="label_dummy1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label"></property>
+ <property name="vexpand">True</property>
+ <property name="hexpand">True</property>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkProgressBar" id="progressbar">
+ <property name="visible">True</property>
+ <property name="width_request">400</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="fraction">0.3</property>
+ <property name="margin_top">8</property>
+ <style>
+ <class name="upgrade-progressbar"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkLabel" id="label_dummy2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label"></property>
+ <property name="vexpand">True</property>
+ <property name="hexpand">True</property>
+ </object>
+ </child>
+
<child>
<object class="GtkButton" id="button_upgrades_download">
<property name="label" translatable="yes">_Download</property>
@@ -96,6 +133,24 @@
</packing>
</child>
<child>
+ <object class="GtkButton" id="button_upgrades_cancel">
+ <property name="label" translatable="yes">_Cancel</property>
+ <property name="width_request">150</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="relief">none</property>
+ <style>
+ <class name="upgrade-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkButton" id="button_upgrades_install">
<property name="label" translatable="yes">_Install</property>
<property name="width_request">150</property>
@@ -115,18 +170,6 @@
</child>
</object>
</child>
- <child>
- <object class="GtkLabel" id="label_upgrades_warning">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">It is recommended that you back up your data and files
before upgrading.</property>
- <property name="margin_top">8</property>
- <property name="margin_bottom">24</property>
- <attributes>
- <attribute name="scale" value="0.9"/>
- </attributes>
- </object>
- </child>
</object>
</child>
</template>
diff --git a/src/gtk-style.css b/src/gtk-style.css
index be67204..bb26b8e 100644
--- a/src/gtk-style.css
+++ b/src/gtk-style.css
@@ -184,9 +184,7 @@
}
.fake-header-bar {
- background-color: white;
- background-image: none;
- border-radius: 0;
+ all: unset;
}
.header-label {
@@ -280,6 +278,8 @@ button.star, .button.star {
.upgrade-banner {
background-color: #1c5288;
+ border-radius: 14px;
+ padding: 16px;
color: @theme_selected_fg_color;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]