[gnome-software] Redo the wait indicator for installed and updates
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Redo the wait indicator for installed and updates
- Date: Thu, 29 Aug 2013 01:19:10 +0000 (UTC)
commit 29367149330ebc863ece6a68577cb349ef368db9
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Aug 28 21:14:48 2013 -0400
Redo the wait indicator for installed and updates
Go back to a big spinner in the page, since the one in the
header is easy to overlook. Make it a little nicer by fading
it in.
src/Makefile.am | 2 +
src/gnome-software.ui | 140 +++++++++++++++++++++++++---------------------
src/gs-shell-installed.c | 18 +++---
src/gs-shell-updates.c | 21 +++----
src/gs-shell.c | 4 -
src/gs-utils.c | 84 +++++++++++++++++++++++++++
src/gs-utils.h | 34 +++++++++++
7 files changed, 215 insertions(+), 88 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 1f8393a..0e45541 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,6 +30,8 @@ bin_PROGRAMS = \
gnome_software_SOURCES = \
gs-resources.c \
gs-resources.h \
+ gs-utils.c \
+ gs-utils.h \
gs-app.c \
gs-app.h \
gs-app-widget.c \
diff --git a/src/gnome-software.ui b/src/gnome-software.ui
index 05966fe..5d1d898 100644
--- a/src/gnome-software.ui
+++ b/src/gnome-software.ui
@@ -12,7 +12,7 @@
<column type="gchararray"/>
</columns>
</object>
- <object class="GtkApplicationWindow" id="window_software">
+ <object class="GtkWindow" id="window_software">
<property name="can_focus">False</property>
<property name="default-width">1200</property>
<property name="default-height">800</property>
@@ -144,13 +144,6 @@
</object>
</child>
<child>
- <object class="GtkSpinner" id="header_spinner">
- </object>
- <packing>
- <property name="pack_type">end</property>
- </packing>
- </child>
- <child>
<object class="GtkButton" id="button_update_all">
<property name="label" translatable="yes">Restart & Install</property>
<property name="visible">True</property>
@@ -190,15 +183,6 @@
<property name="pack_type">end</property>
</packing>
</child>
- <child>
- <object class="GtkButton" id="button_wait">
- <property name="label" translatable="yes">Refreshing</property>
- <property name="sensitive">False</property>
- </object>
- <packing>
- <property name="pack_type">end</property>
- </packing>
- </child>
</object>
<packing>
<property name="expand">False</property>
@@ -468,34 +452,18 @@
</packing>
</child>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow_install">
+ <object class="GtkOverlay" id="overlay_install">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">never</property>
- <property name="vscrollbar_policy">automatic</property>
- <property name="shadow_type">none</property>
- <style>
- <class name="main-scrolled-software"/>
- </style>
- <child>
- <placeholder/>
+ <child type="overlay">
+ <object class="GtkSpinner" id="spinner_install">
+ <property name="width_request">128</property>
+ <property name="height_request">128</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ </object>
</child>
- </object>
- </child>
- <child type="tab">
- <object class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label">Installed</property>
- </object>
- </child>
- <child>
- <object class="GtkBox" id="box6">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow_updates">
+ <object class="GtkScrolledWindow" id="scrolledwindow_install">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
@@ -508,50 +476,94 @@
<placeholder/>
</child>
</object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
+ </child>
+ </object>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">Installed</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkOverlay" id="overlay_updates">
+ <property name="visible">True</property>
+ <child type="overlay">
+ <object class="GtkSpinner" id="spinner_updates">
+ <property name="width_request">128</property>
+ <property name="height_request">128</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ </object>
</child>
<child>
- <object class="GtkBox" id="box_updates_up_to_date">
+ <object class="GtkBox" id="box6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
- <object class="GtkImage" id="image_updates">
+ <object class="GtkScrolledWindow" id="scrolledwindow_updates">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="opacity">0.34000000357627869</property>
- <property name="yalign">1</property>
- <property name="pixel_size">128</property>
- <property name="icon_name">object-select-symbolic</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">none</property>
+ <style>
+ <class name="main-scrolled-software"/>
+ </style>
+ <child>
+ <placeholder/>
+ </child>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label10">
+ <object class="GtkBox" id="box_updates_up_to_date">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">Software is up to date</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkImage" id="image_updates">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="yalign">1</property>
+ <property name="pixel_size">196</property>
+ <property name="icon_name">object-select-symbolic</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label10">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Software is up to date</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>
- <property name="fill">True</property>
+ <property name="expand">True</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
</child>
</object>
</child>
diff --git a/src/gs-shell-installed.c b/src/gs-shell-installed.c
index 76e93b8..928793a 100644
--- a/src/gs-shell-installed.c
+++ b/src/gs-shell-installed.c
@@ -26,6 +26,7 @@
#include "gs-shell-installed.h"
#include "gs-app.h"
+#include "gs-utils.h"
#include "gs-app-widget.h"
static void gs_shell_installed_finalize (GObject *object);
@@ -270,11 +271,8 @@ gs_shell_installed_get_installed_cb (GObject *source_object,
GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
GtkWidget *widget;
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "header_spinner"));
- gtk_spinner_stop (GTK_SPINNER (widget));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_wait"));
- gtk_widget_hide (widget);
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "spinner_install"));
+ gs_stop_spinner (GTK_SPINNER (widget));
priv->waiting = FALSE;
priv->cache_valid = TRUE;
@@ -340,6 +338,7 @@ gs_shell_installed_refresh (GsShellInstalled *shell_installed)
{
GsShellInstalledPrivate *priv = shell_installed->priv;
GtkWidget *widget;
+ GtkSpinner *spinner;
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "buttonbox_main"));
gtk_widget_show (widget);
@@ -350,10 +349,7 @@ gs_shell_installed_refresh (GsShellInstalled *shell_installed)
if (priv->cache_valid)
return;
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "header_spinner"));
- gtk_spinner_start (GTK_SPINNER (widget));
- gtk_widget_show (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_wait"));
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "spinner_install"));
gtk_widget_show (widget);
if (priv->waiting)
@@ -367,6 +363,10 @@ gs_shell_installed_refresh (GsShellInstalled *shell_installed)
priv->cancellable,
gs_shell_installed_get_installed_cb,
shell_installed);
+
+ spinner = GTK_SPINNER (gtk_builder_get_object (shell_installed->priv->builder, "spinner_install"));
+ gs_start_spinner (spinner);
+
priv->waiting = TRUE;
}
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index 97a84e5..e35bd21 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -25,6 +25,7 @@
#include "gs-shell.h"
#include "gs-shell-updates.h"
+#include "gs-utils.h"
#include "gs-app.h"
#include "gs-app-widget.h"
@@ -101,13 +102,8 @@ gs_shell_updates_get_updates_cb (GsPluginLoader *plugin_loader,
priv->waiting = FALSE;
priv->cache_valid = TRUE;
- if (gs_shell_get_mode (priv->shell) == GS_SHELL_MODE_UPDATES) {
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "header_spinner"));
- gtk_spinner_stop (GTK_SPINNER (widget));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_wait"));
- gtk_widget_hide (widget);
- }
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "spinner_updates"));
+ gs_stop_spinner (GTK_SPINNER (widget));
/* get the results */
list = gs_plugin_loader_get_updates_finish (plugin_loader, res, &error);
@@ -151,6 +147,7 @@ gs_shell_updates_refresh (GsShellUpdates *shell_updates)
{
GsShellUpdatesPrivate *priv = shell_updates->priv;
GtkWidget *widget;
+ GtkSpinner *spinner;
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "buttonbox_main"));
gtk_widget_show (widget);
@@ -162,11 +159,9 @@ gs_shell_updates_refresh (GsShellUpdates *shell_updates)
return;
}
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "header_spinner"));
- gtk_spinner_start (GTK_SPINNER (widget));
- gtk_widget_show (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_wait"));
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "spinner_updates"));
gtk_widget_show (widget);
+
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "box_updates_up_to_date"));
gtk_widget_hide (widget);
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "scrolledwindow_updates"));
@@ -181,6 +176,10 @@ gs_shell_updates_refresh (GsShellUpdates *shell_updates)
priv->cancellable,
(GAsyncReadyCallback) gs_shell_updates_get_updates_cb,
shell_updates);
+
+ spinner = GTK_SPINNER (gtk_builder_get_object (priv->builder, "spinner_updates"));
+ gs_start_spinner (spinner);
+
priv->waiting = TRUE;
}
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 87c38dd..3465c5b 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -86,10 +86,6 @@ gs_shell_set_overview_mode (GsShell *shell, GsShellMode mode, GsApp *app, const
gtk_widget_hide (widget);
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_remove"));
gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "header_spinner"));
- gtk_widget_hide (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_wait"));
- gtk_widget_hide (widget);
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "application_details_header"));
gtk_widget_hide (widget);
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_back"));
diff --git a/src/gs-utils.c b/src/gs-utils.c
new file mode 100644
index 0000000..f6943a6
--- /dev/null
+++ b/src/gs-utils.c
@@ -0,0 +1,84 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2013 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include "gs-utils.h"
+
+#define SPINNER_DELAY 500
+
+static gboolean
+fade_in (gpointer data)
+{
+ GtkWidget *spinner = data;
+ gdouble opacity;
+
+ opacity = gtk_widget_get_opacity (spinner);
+ opacity = opacity + 0.1;
+ gtk_widget_set_opacity (spinner, opacity);
+
+ if (opacity >= 1.0)
+ return G_SOURCE_REMOVE;
+
+ return G_SOURCE_CONTINUE;
+}
+
+static void
+remove_source (gpointer data)
+{
+ g_source_remove (GPOINTER_TO_UINT (data));
+}
+
+static gboolean
+start_spinning (gpointer data)
+{
+ GtkWidget *spinner = data;
+ guint id;
+
+ gtk_widget_set_opacity (spinner, 0);
+ gtk_spinner_start (GTK_SPINNER (spinner));
+ gtk_widget_show (spinner);
+ id = g_timeout_add (100, fade_in, spinner);
+ g_object_set_data_full (G_OBJECT (spinner), "fade-timeout",
+ GUINT_TO_POINTER (id), remove_source);
+
+ return G_SOURCE_REMOVE;
+}
+
+void
+gs_stop_spinner (GtkSpinner *spinner)
+{
+ gtk_widget_hide (GTK_WIDGET (spinner));
+ gtk_spinner_stop (spinner);
+}
+
+void
+gs_start_spinner (GtkSpinner *spinner)
+{
+ guint id;
+
+ gtk_widget_set_opacity (GTK_WIDGET (spinner), 0);
+ id = g_timeout_add (SPINNER_DELAY, start_spinning, spinner);
+
+ g_object_set_data_full (G_OBJECT (spinner), "start-timeout",
+ GUINT_TO_POINTER (id), remove_source);
+}
+
diff --git a/src/gs-utils.h b/src/gs-utils.h
new file mode 100644
index 0000000..33ac881
--- /dev/null
+++ b/src/gs-utils.h
@@ -0,0 +1,34 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2013 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GS_UTILS_H
+#define __GS_UTILS_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+void gs_start_spinner (GtkSpinner *spinner);
+void gs_stop_spinner (GtkSpinner *spinner);
+
+G_END_DECLS
+
+#endif /* __GS_UTILS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]