[gnome-software] Make installing apps appear on the installed list
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Make installing apps appear on the installed list
- Date: Fri, 30 Aug 2013 04:15:07 +0000 (UTC)
commit 600d55f640999aecc93d964e5916bdf8277ff24b
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Aug 30 00:09:39 2013 -0400
Make installing apps appear on the installed list
Also try to remove apps from the list after there removal
is complete.
src/gs-shell-installed.c | 62 +++++++++++++++++++++++++++++++++++++--------
src/gs-shell-search.c | 27 --------------------
2 files changed, 51 insertions(+), 38 deletions(-)
---
diff --git a/src/gs-shell-installed.c b/src/gs-shell-installed.c
index e96a4df..4e02615 100644
--- a/src/gs-shell-installed.c
+++ b/src/gs-shell-installed.c
@@ -31,6 +31,8 @@
#include "gs-app-widget.h"
static void gs_shell_installed_finalize (GObject *object);
+static void remove_row (GtkListBox *list_box,
+ GtkWidget *child);
#define GS_SHELL_INSTALLED_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GS_TYPE_SHELL_INSTALLED,
GsShellInstalledPrivate))
@@ -235,6 +237,38 @@ gs_shell_installed_app_remove_cb (GsAppWidget *app_widget,
gtk_widget_destroy (dialog);
}
+static void
+app_state_changed (GsApp *app, GtkWidget *widget)
+{
+ GtkWidget *row, *list;
+
+ if (gs_app_get_state (app) == GS_APP_STATE_AVAILABLE) {
+ row = gtk_widget_get_parent (widget);
+ list = gtk_widget_get_parent (row);
+ remove_row (GTK_LIST_BOX (list), widget);
+ }
+}
+
+static void
+gs_shell_installed_add_app (GsShellInstalled *shell, GsApp *app)
+{
+ GsShellInstalledPrivate *priv = shell->priv;
+ GtkWidget *widget;
+
+ g_debug ("adding to installed list: %s", gs_app_get_id (app));
+ widget = gs_app_widget_new ();
+ g_signal_connect (widget, "button-clicked",
+ G_CALLBACK (gs_shell_installed_app_remove_cb), shell);
+ g_signal_connect_object (app, "state-changed",
+ G_CALLBACK (app_state_changed), widget, 0);
+ gs_app_widget_set_app (GS_APP_WIDGET (widget), app);
+ gtk_container_add (GTK_CONTAINER (priv->list_box_installed), widget);
+ gs_app_widget_set_size_groups (GS_APP_WIDGET (widget),
+ priv->sizegroup_image,
+ priv->sizegroup_name);
+ gtk_widget_show (widget);
+}
+
/**
* gs_shell_installed_get_installed_cb:
**/
@@ -268,17 +302,7 @@ gs_shell_installed_get_installed_cb (GObject *source_object,
}
for (l = list; l != NULL; l = l->next) {
app = GS_APP (l->data);
- g_debug ("adding installed %s", gs_app_get_id (app));
- widget = gs_app_widget_new ();
- g_signal_connect (widget, "button-clicked",
- G_CALLBACK (gs_shell_installed_app_remove_cb),
- shell_installed);
- gs_app_widget_set_app (GS_APP_WIDGET (widget), app);
- gtk_container_add (GTK_CONTAINER (priv->list_box_installed), widget);
- gs_app_widget_set_size_groups (GS_APP_WIDGET (widget),
- priv->sizegroup_image,
- priv->sizegroup_name);
- gtk_widget_show (widget);
+ gs_shell_installed_add_app (shell_installed, app);
}
out: ;
}
@@ -293,6 +317,9 @@ reset_date (GtkWidget *row, gpointer data)
app = gs_app_widget_get_app (GS_APP_WIDGET (child));
if (gs_app_get_state (app) == GS_APP_STATE_REMOVING) {
+ /* sort removing apps above installed apps,
+ * below installing apps
+ */
gs_app_set_install_date (app, G_MAXUINT - 2);
gtk_list_box_row_changed (GTK_LIST_BOX_ROW (row));
}
@@ -418,6 +445,8 @@ gs_shell_installed_pending_apps_changed_cb (GsPluginLoader *plugin_loader,
gchar *label;
GPtrArray *pending;
GtkWidget *widget;
+ guint i;
+ GsApp *app;
widget = GTK_WIDGET (gtk_builder_get_object (shell_installed->priv->builder,
"label_button_installed"));
@@ -426,6 +455,17 @@ gs_shell_installed_pending_apps_changed_cb (GsPluginLoader *plugin_loader,
label = g_strdup (_("Installed"));
else
label = g_strdup_printf (_("Installed (%d)"), pending->len);
+ for (i = 0; i < pending->len; i++) {
+ app = GS_APP (g_ptr_array_index (pending, i));
+ if (gs_app_get_state (app) == GS_APP_STATE_INSTALLING) {
+ /* sort installing apps above removing and
+ * installed apps
+ */
+ gs_app_set_install_date (app, G_MAXUINT - 1);
+ gs_shell_installed_add_app (shell_installed, app);
+ }
+ }
+
gtk_label_set_label (GTK_LABEL (widget), label);
g_free (label);
g_ptr_array_unref (pending);
diff --git a/src/gs-shell-search.c b/src/gs-shell-search.c
index e68aa9d..fa81fba 100644
--- a/src/gs-shell-search.c
+++ b/src/gs-shell-search.c
@@ -405,29 +405,6 @@ gs_shell_search_list_header_func (GtkListBoxRow *row,
}
/**
- * gs_shell_search_pending_apps_changed_cb:
- */
-static void
-gs_shell_search_pending_apps_changed_cb (GsPluginLoader *plugin_loader,
- GsShellSearch *shell_search)
-{
- gchar *label;
- GPtrArray *pending;
- GtkWidget *widget;
-
- widget = GTK_WIDGET (gtk_builder_get_object (shell_search->priv->builder,
- "label_button_search"));
- pending = gs_plugin_loader_get_pending (plugin_loader);
- if (pending->len == 0)
- label = g_strdup (_("Search"));
- else
- label = g_strdup_printf (_("Search (%d)"), pending->len);
- gtk_label_set_label (GTK_LABEL (widget), label);
- g_free (label);
- g_ptr_array_unref (pending);
-}
-
-/**
* gs_shell_search_setup:
*/
void
@@ -442,10 +419,6 @@ gs_shell_search_setup (GsShellSearch *shell_search,
g_return_if_fail (GS_IS_SHELL_SEARCH (shell_search));
priv->plugin_loader = g_object_ref (plugin_loader);
- g_signal_connect (priv->plugin_loader, "pending-apps-changed",
- G_CALLBACK (gs_shell_search_pending_apps_changed_cb),
- shell_search);
-
priv->builder = g_object_ref (builder);
priv->cancellable = g_object_ref (cancellable);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]