[gnome-software] Reload pages in the software center when the updates cache is changed
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Reload pages in the software center when the updates cache is changed
- Date: Mon, 1 Sep 2014 14:23:45 +0000 (UTC)
commit 3a246ef1835a4af6f9670c5fad2d6a7f9bb0631d
Author: Richard Hughes <richard hughsie com>
Date: Mon Sep 1 12:14:39 2014 +0100
Reload pages in the software center when the updates cache is changed
This also makes the different actions more explicit:
_setup: Sets up any state for the shell panel; shows no UI
_load: Does any action and displays the result
_reload: Invalidates caches, then does _load()
_switch_to: Sets up headerbar and then does _load()
Resolves: https://bugzilla.gnome.org/show_bug.cgi?id=734437
src/gs-shell-category.c | 10 +++++-
src/gs-shell-category.h | 3 +-
src/gs-shell-details.c | 74 +++++++++++++++++++++++----------------
src/gs-shell-details.h | 3 +-
src/gs-shell-installed.c | 81 ++++++++++++++++++++++++++++---------------
src/gs-shell-installed.h | 3 +-
src/gs-shell-overview.c | 86 +++++++++++++++++++++++++++++-----------------
src/gs-shell-overview.h | 3 +-
src/gs-shell-search.c | 84 ++++++++++++++++++++++++++++++--------------
src/gs-shell-search.h | 3 +-
src/gs-shell-updates.c | 86 +++++++++++++++++++++++++--------------------
src/gs-shell-updates.h | 3 +-
src/gs-shell.c | 46 +++++++++++++++++++------
src/gs-shell.h | 1 +
14 files changed, 312 insertions(+), 174 deletions(-)
---
diff --git a/src/gs-shell-category.c b/src/gs-shell-category.c
index 27ee0bf..02425f1 100644
--- a/src/gs-shell-category.c
+++ b/src/gs-shell-category.c
@@ -46,8 +46,16 @@ struct GsShellCategoryPrivate {
G_DEFINE_TYPE_WITH_PRIVATE (GsShellCategory, gs_shell_category, GTK_TYPE_BIN)
+/**
+ * gs_shell_category_reload:
+ */
+void
+gs_shell_category_reload (GsShellCategory *shell_category)
+{
+}
+
void
-gs_shell_category_refresh (GsShellCategory *shell)
+gs_shell_category_switch_to (GsShellCategory *shell)
{
GsShellCategoryPrivate *priv = shell->priv;
GtkWidget *widget;
diff --git a/src/gs-shell-category.h b/src/gs-shell-category.h
index b88e77b..abf3f91 100644
--- a/src/gs-shell-category.h
+++ b/src/gs-shell-category.h
@@ -57,7 +57,8 @@ GsShellCategory *gs_shell_category_new (void);
void gs_shell_category_set_category (GsShellCategory *shell_category,
GsCategory *category);
GsCategory *gs_shell_category_get_category (GsShellCategory *shell_category);
-void gs_shell_category_refresh (GsShellCategory *shell_category);
+void gs_shell_category_switch_to (GsShellCategory *shell_category);
+void gs_shell_category_reload (GsShellCategory *shell_category);
void gs_shell_category_setup (GsShellCategory *shell_category,
GsShell *shell,
GsPluginLoader *plugin_loader,
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 0900f8e..0f3c996 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -47,7 +47,6 @@ struct GsShellDetailsPrivate
GsPluginLoader *plugin_loader;
GtkBuilder *builder;
GCancellable *cancellable;
- gboolean cache_valid;
GsApp *app;
GsShell *shell;
GtkWidget *history_dialog;
@@ -95,15 +94,6 @@ struct GsShellDetailsPrivate
G_DEFINE_TYPE_WITH_PRIVATE (GsShellDetails, gs_shell_details, GTK_TYPE_BIN)
/**
- * gs_shell_details_invalidate:
- **/
-void
-gs_shell_details_invalidate (GsShellDetails *shell_details)
-{
- shell_details->priv->cache_valid = FALSE;
-}
-
-/**
* gs_shell_details_set_state:
**/
static void
@@ -140,10 +130,10 @@ gs_shell_details_set_state (GsShellDetails *shell_details,
}
/**
- * gs_shell_details_refresh:
+ * gs_shell_details_switch_to:
**/
void
-gs_shell_details_refresh (GsShellDetails *shell_details)
+gs_shell_details_switch_to (GsShellDetails *shell_details)
{
GsShellDetailsPrivate *priv = shell_details->priv;
GsAppKind kind;
@@ -151,8 +141,11 @@ gs_shell_details_refresh (GsShellDetails *shell_details)
GtkWidget *widget;
GtkAdjustment *adj;
- if (gs_shell_get_mode (priv->shell) != GS_SHELL_MODE_DETAILS)
+ if (gs_shell_get_mode (priv->shell) != GS_SHELL_MODE_DETAILS) {
+ g_warning ("Called switch_to(details) when in mode %s",
+ gs_shell_get_mode_string (priv->shell));
return;
+ }
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "application_details_header"));
gtk_widget_show (widget);
@@ -287,7 +280,7 @@ gs_shell_details_notify_state_changed_cb (GsApp *app,
GParamSpec *pspec,
GsShellDetails *shell_details)
{
- gs_shell_details_refresh (shell_details);
+ gs_shell_details_switch_to (shell_details);
}
static void
@@ -921,7 +914,7 @@ gs_shell_details_filename_to_app_cb (GObject *source,
g_free (tmp);
/* change widgets */
- gs_shell_details_refresh (shell_details);
+ gs_shell_details_switch_to (shell_details);
gs_shell_details_refresh_screenshots (shell_details);
gs_shell_details_refresh_addons (shell_details);
gs_shell_details_refresh_all (shell_details);
@@ -946,22 +939,13 @@ gs_shell_details_set_filename (GsShellDetails *shell_details, const gchar *filen
}
/**
- * gs_shell_details_set_app:
+ * gs_shell_details_load:
**/
-void
-gs_shell_details_set_app (GsShellDetails *shell_details, GsApp *app)
+static void
+gs_shell_details_load (GsShellDetails *shell_details)
{
GsShellDetailsPrivate *priv = shell_details->priv;
- gchar *app_dump;
-
- /* show some debugging */
- app_dump = gs_app_to_string (app);
- g_debug ("%s", app_dump);
- g_free (app_dump);
-
- /* get extra details about the app */
- gs_shell_details_set_state (shell_details, GS_SHELL_DETAILS_STATE_LOADING);
- gs_plugin_loader_app_refine_async (priv->plugin_loader, app,
+ gs_plugin_loader_app_refine_async (priv->plugin_loader, priv->app,
GS_PLUGIN_REFINE_FLAGS_REQUIRE_LICENCE |
GS_PLUGIN_REFINE_FLAGS_REQUIRE_SIZE |
GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING |
@@ -975,6 +959,35 @@ gs_shell_details_set_app (GsShellDetails *shell_details, GsApp *app)
priv->cancellable,
gs_shell_details_app_refine_cb,
shell_details);
+}
+
+/**
+ * gs_shell_details_reload:
+ **/
+void
+gs_shell_details_reload (GsShellDetails *shell_details)
+{
+ GsShellDetailsPrivate *priv = shell_details->priv;
+ if (priv->app != NULL)
+ gs_shell_details_load (shell_details);
+}
+
+/**
+ * gs_shell_details_set_app:
+ **/
+void
+gs_shell_details_set_app (GsShellDetails *shell_details, GsApp *app)
+{
+ GsShellDetailsPrivate *priv = shell_details->priv;
+ gchar *app_dump;
+
+ /* show some debugging */
+ app_dump = gs_app_to_string (app);
+ g_debug ("%s", app_dump);
+ g_free (app_dump);
+
+ /* get extra details about the app */
+ gs_shell_details_set_state (shell_details, GS_SHELL_DETAILS_STATE_LOADING);
/* save app */
if (priv->app != NULL)
@@ -989,6 +1002,7 @@ gs_shell_details_set_app (GsShellDetails *shell_details, GsApp *app)
g_signal_connect_object (priv->app, "notify::licence",
G_CALLBACK (gs_shell_details_notify_state_changed_cb),
shell_details, 0);
+ gs_shell_details_load (shell_details);
/* set screenshots */
gs_shell_details_refresh_screenshots (shell_details);
@@ -1040,7 +1054,7 @@ gs_shell_details_app_installed_cb (GObject *source,
if (gs_app_get_state (helper->app) != AS_APP_STATE_QUEUED_FOR_INSTALL &&
!gs_shell_is_active (helper->shell_details->priv->shell))
gs_app_notify_installed (helper->app);
- gs_shell_details_refresh_all (helper->shell_details);
+ gs_shell_details_reload (helper->shell_details);
g_object_unref (helper->shell_details);
g_object_unref (helper->app);
g_free (helper);
@@ -1074,7 +1088,7 @@ gs_shell_details_app_removed_cb (GObject *source,
return;
}
- gs_shell_details_refresh_all (helper->shell_details);
+ gs_shell_details_reload (helper->shell_details);
g_object_unref (helper->shell_details);
g_object_unref (helper->app);
g_free (helper);
diff --git a/src/gs-shell-details.h b/src/gs-shell-details.h
index 000961f..e293f29 100644
--- a/src/gs-shell-details.h
+++ b/src/gs-shell-details.h
@@ -60,7 +60,8 @@ void gs_shell_details_set_app (GsShellDetails *shell_details,
void gs_shell_details_set_filename (GsShellDetails *shell_details,
const gchar *filename);
GsApp *gs_shell_details_get_app (GsShellDetails *shell_details);
-void gs_shell_details_refresh (GsShellDetails *shell_details);
+void gs_shell_details_switch_to (GsShellDetails *shell_details);
+void gs_shell_details_reload (GsShellDetails *shell_details);
void gs_shell_details_setup (GsShellDetails *shell_details,
GsShell *shell,
GsPluginLoader *plugin_loader,
diff --git a/src/gs-shell-installed.c b/src/gs-shell-installed.c
index 3847ce9..0695993 100644
--- a/src/gs-shell-installed.c
+++ b/src/gs-shell-installed.c
@@ -280,23 +280,65 @@ out:
}
/**
- * gs_shell_installed_refresh:
+ * gs_shell_installed_load:
+ */
+static void
+gs_shell_installed_load (GsShellInstalled *shell_installed)
+{
+ GsShellInstalledPrivate *priv = shell_installed->priv;
+
+ /* remove old entries */
+ gs_container_remove_all (GTK_CONTAINER (priv->list_box_install));
+
+ /* get popular apps */
+ gs_plugin_loader_get_installed_async (priv->plugin_loader,
+ GS_PLUGIN_REFINE_FLAGS_DEFAULT |
+ GS_PLUGIN_REFINE_FLAGS_REQUIRE_HISTORY |
+ GS_PLUGIN_REFINE_FLAGS_REQUIRE_SETUP_ACTION |
+ GS_PLUGIN_REFINE_FLAGS_REQUIRE_VERSION |
+ GS_PLUGIN_REFINE_FLAGS_REQUIRE_DESCRIPTION |
+ GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING,
+ priv->cancellable,
+ gs_shell_installed_get_installed_cb,
+ shell_installed);
+ gs_start_spinner (GTK_SPINNER (priv->spinner_install));
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->stack_install), "spinner");
+
+ priv->waiting = TRUE;
+}
+
+/**
+ * gs_shell_installed_reload:
+ */
+void
+gs_shell_installed_reload (GsShellInstalled *shell_installed)
+{
+ gs_shell_installed_invalidate (shell_installed);
+ gs_shell_installed_load (shell_installed);
+}
+
+/**
+ * gs_shell_installed_switch_to:
**/
void
-gs_shell_installed_refresh (GsShellInstalled *shell_installed, gboolean scroll_up)
+gs_shell_installed_switch_to (GsShellInstalled *shell_installed, gboolean scroll_up)
{
GsShellInstalledPrivate *priv = shell_installed->priv;
GtkWidget *widget;
- if (gs_shell_get_mode (priv->shell) == GS_SHELL_MODE_INSTALLED) {
- set_selection_mode (shell_installed, FALSE);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "buttonbox_main"));
- gtk_widget_show (widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_select"));
- gtk_widget_show (widget);
+ if (gs_shell_get_mode (priv->shell) != GS_SHELL_MODE_INSTALLED) {
+ g_warning ("Called switch_to(installed) when in mode %s",
+ gs_shell_get_mode_string (priv->shell));
+ return;
}
+ set_selection_mode (shell_installed, FALSE);
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "buttonbox_main"));
+ gtk_widget_show (widget);
+
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_select"));
+ gtk_widget_show (widget);
+
gtk_list_box_invalidate_sort (GTK_LIST_BOX (priv->list_box_install));
if (scroll_up) {
@@ -314,26 +356,7 @@ gs_shell_installed_refresh (GsShellInstalled *shell_installed, gboolean scroll_u
if (priv->waiting)
return;
-
- /* remove old entries */
- gs_container_remove_all (GTK_CONTAINER (priv->list_box_install));
-
- /* get popular apps */
- gs_plugin_loader_get_installed_async (priv->plugin_loader,
- GS_PLUGIN_REFINE_FLAGS_DEFAULT |
- GS_PLUGIN_REFINE_FLAGS_REQUIRE_HISTORY |
- GS_PLUGIN_REFINE_FLAGS_REQUIRE_SETUP_ACTION |
- GS_PLUGIN_REFINE_FLAGS_REQUIRE_VERSION |
- GS_PLUGIN_REFINE_FLAGS_REQUIRE_DESCRIPTION |
- GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING,
- priv->cancellable,
- gs_shell_installed_get_installed_cb,
- shell_installed);
-
- gs_start_spinner (GTK_SPINNER (priv->spinner_install));
- gtk_stack_set_visible_child_name (GTK_STACK (priv->stack_install), "spinner");
-
- priv->waiting = TRUE;
+ gs_shell_installed_load (shell_installed);
}
/**
diff --git a/src/gs-shell-installed.h b/src/gs-shell-installed.h
index fec31bc..0552779 100644
--- a/src/gs-shell-installed.h
+++ b/src/gs-shell-installed.h
@@ -53,8 +53,9 @@ GType gs_shell_installed_get_type (void);
GsShellInstalled *gs_shell_installed_new (void);
void gs_shell_installed_invalidate (GsShellInstalled *shell_installed);
-void gs_shell_installed_refresh (GsShellInstalled *shell_installed,
+void gs_shell_installed_switch_to (GsShellInstalled *shell_installed,
gboolean scroll_up);
+void gs_shell_installed_reload (GsShellInstalled *shell_installed);
void gs_shell_installed_setup (GsShellInstalled *shell_installed,
GsShell *shell,
GsPluginLoader *plugin_loader,
diff --git a/src/gs-shell-overview.c b/src/gs-shell-overview.c
index a57175d..bcbce72 100644
--- a/src/gs-shell-overview.c
+++ b/src/gs-shell-overview.c
@@ -295,38 +295,15 @@ out:
}
/**
- * gs_shell_overview_refresh:
- **/
-void
-gs_shell_overview_refresh (GsShellOverview *shell, gboolean scroll_up)
+ * gs_shell_overview_load:
+ */
+static void
+gs_shell_overview_load (GsShellOverview *shell_overview)
{
GDateTime *date;
- GsShellOverviewPrivate *priv = shell->priv;
- GtkWidget *widget;
- GtkAdjustment *adj;
+ GsShellOverviewPrivate *priv = shell_overview->priv;
const gchar *category_of_day;
- if (gs_shell_get_mode (priv->shell) == GS_SHELL_MODE_OVERVIEW) {
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "buttonbox_main"));
- gtk_widget_show (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "search_bar"));
- gtk_widget_show (widget);
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "entry_search"));
- gtk_entry_set_text (GTK_ENTRY (widget), "");
- }
-
- if (scroll_up) {
- adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW
(priv->scrolledwindow_overview));
- gtk_adjustment_set_value (adj, gtk_adjustment_get_lower (adj));
- }
-
- if (gs_shell_get_mode (priv->shell) == GS_SHELL_MODE_OVERVIEW) {
- gs_grab_focus_when_mapped (priv->scrolledwindow_overview);
- }
-
- if (priv->cache_valid || priv->refresh_count > 0)
- return;
-
priv->empty = TRUE;
priv->refresh_count = 4;
@@ -362,7 +339,7 @@ gs_shell_overview_refresh (GsShellOverview *shell, gboolean scroll_up)
GS_PLUGIN_REFINE_FLAGS_DEFAULT,
priv->cancellable,
gs_shell_overview_get_featured_cb,
- shell);
+ shell_overview);
gs_plugin_loader_get_popular_async (priv->plugin_loader,
GS_PLUGIN_REFINE_FLAGS_DEFAULT,
@@ -370,7 +347,7 @@ gs_shell_overview_refresh (GsShellOverview *shell, gboolean scroll_up)
category_of_day,
priv->cancellable,
gs_shell_overview_get_popular_cb,
- shell);
+ shell_overview);
gs_plugin_loader_get_popular_async (priv->plugin_loader,
GS_PLUGIN_REFINE_FLAGS_DEFAULT,
@@ -378,13 +355,58 @@ gs_shell_overview_refresh (GsShellOverview *shell, gboolean scroll_up)
NULL,
priv->cancellable,
gs_shell_overview_get_popular_rotating_cb,
- shell);
+ shell_overview);
gs_plugin_loader_get_categories_async (priv->plugin_loader,
GS_PLUGIN_REFINE_FLAGS_DEFAULT,
priv->cancellable,
gs_shell_overview_get_categories_cb,
- shell);
+ shell_overview);
+}
+
+/**
+ * gs_shell_overview_reload:
+ */
+void
+gs_shell_overview_reload (GsShellOverview *shell_overview)
+{
+ gs_shell_overview_invalidate (shell_overview);
+ gs_shell_overview_load (shell_overview);
+}
+
+/**
+ * gs_shell_overview_switch_to:
+ **/
+void
+gs_shell_overview_switch_to (GsShellOverview *shell, gboolean scroll_up)
+{
+ GsShellOverviewPrivate *priv = shell->priv;
+ GtkWidget *widget;
+ GtkAdjustment *adj;
+
+ if (gs_shell_get_mode (priv->shell) != GS_SHELL_MODE_OVERVIEW) {
+ g_warning ("Called switch_to(overview) when in mode %s",
+ gs_shell_get_mode_string (priv->shell));
+ return;
+ }
+
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "buttonbox_main"));
+ gtk_widget_show (widget);
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "search_bar"));
+ gtk_widget_show (widget);
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "entry_search"));
+ gtk_entry_set_text (GTK_ENTRY (widget), "");
+
+ if (scroll_up) {
+ adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW
(priv->scrolledwindow_overview));
+ gtk_adjustment_set_value (adj, gtk_adjustment_get_lower (adj));
+ }
+
+ gs_grab_focus_when_mapped (priv->scrolledwindow_overview);
+
+ if (priv->cache_valid || priv->refresh_count > 0)
+ return;
+ gs_shell_overview_load (shell);
}
void
diff --git a/src/gs-shell-overview.h b/src/gs-shell-overview.h
index 8774357..0efbe1a 100644
--- a/src/gs-shell-overview.h
+++ b/src/gs-shell-overview.h
@@ -57,8 +57,9 @@ GType gs_shell_overview_get_type (void);
GsShellOverview *gs_shell_overview_new (void);
void gs_shell_overview_invalidate (GsShellOverview *shell_overview);
-void gs_shell_overview_refresh (GsShellOverview *shell_overview,
+void gs_shell_overview_switch_to (GsShellOverview *shell_overview,
gboolean scroll_up);
+void gs_shell_overview_reload (GsShellOverview *shell_overview);
void gs_shell_overview_setup (GsShellOverview *shell_overview,
GsShell *shell,
GsPluginLoader *plugin_loader,
diff --git a/src/gs-shell-search.c b/src/gs-shell-search.c
index 8af85d7..f8df235 100644
--- a/src/gs-shell-search.c
+++ b/src/gs-shell-search.c
@@ -94,6 +94,7 @@ gs_shell_search_app_installed_cb (GObject *source,
if (!gs_shell_is_active (helper->shell_search->priv->shell))
gs_app_notify_installed (helper->app);
}
+ gs_shell_search_reload (helper->shell_search);
g_object_unref (helper->app);
g_object_unref (helper->shell_search);
g_free (helper);
@@ -124,6 +125,7 @@ gs_shell_search_app_removed_cb (GObject *source,
error);
g_error_free (error);
}
+ gs_shell_search_reload (helper->shell_search);
g_object_unref (helper->app);
g_object_unref (helper->shell_search);
g_free (helper);
@@ -284,34 +286,12 @@ out: ;
}
/**
- * gs_shell_search_refresh:
- **/
-void
-gs_shell_search_refresh (GsShellSearch *shell_search, const gchar *value, gboolean scroll_up)
+ * gs_shell_search_load:
+ */
+static void
+gs_shell_search_load (GsShellSearch *shell_search)
{
GsShellSearchPrivate *priv = shell_search->priv;
- GtkWidget *widget;
-
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "buttonbox_main"));
- gtk_widget_show (widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "search_bar"));
- gtk_widget_show (widget);
-
- if (scroll_up) {
- GtkAdjustment *adj;
- adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW
(priv->scrolledwindow_search));
- gtk_adjustment_set_value (adj, gtk_adjustment_get_lower (adj));
- }
- if (gs_shell_get_mode (priv->shell) == GS_SHELL_MODE_SEARCH) {
- gs_grab_focus_when_mapped (priv->scrolledwindow_search);
- }
-
- if (g_strcmp0 (value, priv->value) == 0)
- return;
-
- g_free (priv->value);
- priv->value = g_strdup (value);
/* remove old entries */
gs_container_remove_all (GTK_CONTAINER (priv->list_box_search));
@@ -325,7 +305,7 @@ gs_shell_search_refresh (GsShellSearch *shell_search, const gchar *value, gboole
/* search for apps */
gs_plugin_loader_search_async (priv->plugin_loader,
- value,
+ priv->value,
GS_PLUGIN_REFINE_FLAGS_DEFAULT |
GS_PLUGIN_REFINE_FLAGS_REQUIRE_VERSION |
GS_PLUGIN_REFINE_FLAGS_REQUIRE_HISTORY |
@@ -341,6 +321,56 @@ gs_shell_search_refresh (GsShellSearch *shell_search, const gchar *value, gboole
}
/**
+ * gs_shell_search_reload:
+ */
+void
+gs_shell_search_reload (GsShellSearch *shell_search)
+{
+ GsShellSearchPrivate *priv = shell_search->priv;
+ if (priv->value != NULL)
+ gs_shell_search_load (shell_search);
+}
+
+/**
+ * gs_shell_search_switch_to:
+ **/
+void
+gs_shell_search_switch_to (GsShellSearch *shell_search, const gchar *value, gboolean scroll_up)
+{
+ GsShellSearchPrivate *priv = shell_search->priv;
+ GtkWidget *widget;
+
+ if (gs_shell_get_mode (priv->shell) != GS_SHELL_MODE_SEARCH) {
+ g_warning ("Called switch_to(search) when in mode %s",
+ gs_shell_get_mode_string (priv->shell));
+ return;
+ }
+
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "buttonbox_main"));
+ gtk_widget_show (widget);
+
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "search_bar"));
+ gtk_widget_show (widget);
+
+ if (scroll_up) {
+ GtkAdjustment *adj;
+ adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW
(priv->scrolledwindow_search));
+ gtk_adjustment_set_value (adj, gtk_adjustment_get_lower (adj));
+ }
+ if (gs_shell_get_mode (priv->shell) == GS_SHELL_MODE_SEARCH) {
+ gs_grab_focus_when_mapped (priv->scrolledwindow_search);
+ }
+
+ if (g_strcmp0 (value, priv->value) == 0)
+ return;
+
+ g_free (priv->value);
+ priv->value = g_strdup (value);
+
+ gs_shell_search_load (shell_search);
+}
+
+/**
* gs_shell_installed_sort_func:
*
* Get a sort key to achive this:
diff --git a/src/gs-shell-search.h b/src/gs-shell-search.h
index b7faea8..9538020 100644
--- a/src/gs-shell-search.h
+++ b/src/gs-shell-search.h
@@ -53,9 +53,10 @@ typedef struct
GType gs_shell_search_get_type (void);
GsShellSearch *gs_shell_search_new (void);
-void gs_shell_search_refresh (GsShellSearch *shell_search,
+void gs_shell_search_switch_to (GsShellSearch *shell_search,
const gchar *text,
gboolean scroll_up);
+void gs_shell_search_reload (GsShellSearch *shell_search);
void gs_shell_search_setup (GsShellSearch *shell_search,
GsShell *shell,
GsPluginLoader *plugin_loader,
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index 9b2336b..34b0d89 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -495,24 +495,60 @@ gs_shell_updates_get_updates_cb (GsPluginLoader *plugin_loader,
}
/**
- * gs_shell_updates_refresh:
+ * gs_shell_updates_load:
+ */
+static void
+gs_shell_updates_load (GsShellUpdates *shell_updates)
+{
+ GsShellUpdatesPrivate *priv = shell_updates->priv;
+ guint64 refine_flags;
+
+ gs_container_remove_all (GTK_CONTAINER (priv->list_box_updates));
+
+ refine_flags = GS_PLUGIN_REFINE_FLAGS_DEFAULT |
+ GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_DETAILS |
+ GS_PLUGIN_REFINE_FLAGS_REQUIRE_VERSION;
+ gs_shell_updates_set_state (shell_updates,
+ GS_SHELL_UPDATES_STATE_ACTION_GET_UPDATES);
+ gs_plugin_loader_get_updates_async (priv->plugin_loader,
+ refine_flags,
+ priv->cancellable,
+ (GAsyncReadyCallback) gs_shell_updates_get_updates_cb,
+ shell_updates);
+}
+
+/**
+ * gs_shell_updates_reload:
+ */
+void
+gs_shell_updates_reload (GsShellUpdates *shell_updates)
+{
+ gs_shell_updates_invalidate (shell_updates);
+ gs_shell_updates_load (shell_updates);
+}
+
+/**
+ * gs_shell_updates_switch_to:
**/
void
-gs_shell_updates_refresh (GsShellUpdates *shell_updates,
- gboolean scroll_up)
+gs_shell_updates_switch_to (GsShellUpdates *shell_updates,
+ gboolean scroll_up)
{
GsShellUpdatesPrivate *priv = shell_updates->priv;
GtkWidget *widget;
- guint64 refine_flags;
- if (gs_shell_get_mode (priv->shell) == GS_SHELL_MODE_UPDATES) {
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "buttonbox_main"));
- gtk_widget_show (widget);
-
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_refresh"));
- gtk_widget_set_visible (widget, TRUE);
+ if (gs_shell_get_mode (priv->shell) != GS_SHELL_MODE_UPDATES) {
+ g_warning ("Called switch_to(updates) when in mode %s",
+ gs_shell_get_mode_string (priv->shell));
+ return;
}
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "buttonbox_main"));
+ gtk_widget_show (widget);
+
+ widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_refresh"));
+ gtk_widget_set_visible (widget, TRUE);
+
if (scroll_up) {
GtkAdjustment *adj;
adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW
(priv->scrolledwindow_updates));
@@ -529,19 +565,7 @@ gs_shell_updates_refresh (GsShellUpdates *shell_updates,
gs_shell_updates_update_ui_state (shell_updates);
return;
}
-
- gs_container_remove_all (GTK_CONTAINER (priv->list_box_updates));
-
- refine_flags = GS_PLUGIN_REFINE_FLAGS_DEFAULT |
- GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_DETAILS |
- GS_PLUGIN_REFINE_FLAGS_REQUIRE_VERSION;
- gs_shell_updates_set_state (shell_updates,
- GS_SHELL_UPDATES_STATE_ACTION_GET_UPDATES);
- gs_plugin_loader_get_updates_async (priv->plugin_loader,
- refine_flags,
- priv->cancellable,
- (GAsyncReadyCallback) gs_shell_updates_get_updates_cb,
- shell_updates);
+ gs_shell_updates_load (shell_updates);
}
static void
@@ -624,7 +648,7 @@ gs_shell_updates_refresh_cb (GsPluginLoader *plugin_loader,
/* get the new list */
gs_shell_updates_invalidate (shell_updates);
- gs_shell_updates_refresh (shell_updates, TRUE);
+ gs_shell_updates_switch_to (shell_updates, TRUE);
}
/**
@@ -798,17 +822,6 @@ gs_shell_updates_button_refresh_cb (GtkWidget *widget,
}
/**
- * gs_shell_updates_changed_cb:
- */
-static void
-gs_shell_updates_changed_cb (GsPluginLoader *plugin_loader,
- GsShellUpdates *shell_updates)
-{
- gs_shell_updates_invalidate (shell_updates);
- gs_shell_updates_refresh (shell_updates, TRUE);
-}
-
-/**
* gs_shell_updates_pending_apps_changed_cb:
*/
static void
@@ -885,9 +898,6 @@ gs_shell_updates_setup (GsShellUpdates *shell_updates,
g_signal_connect (priv->plugin_loader, "pending-apps-changed",
G_CALLBACK (gs_shell_updates_pending_apps_changed_cb),
shell_updates);
- g_signal_connect (priv->plugin_loader, "updates-changed",
- G_CALLBACK (gs_shell_updates_changed_cb),
- shell_updates);
g_signal_connect (priv->plugin_loader, "status-changed",
G_CALLBACK (gs_shell_updates_status_changed_cb),
shell_updates);
diff --git a/src/gs-shell-updates.h b/src/gs-shell-updates.h
index 4600e92..14afb32 100644
--- a/src/gs-shell-updates.h
+++ b/src/gs-shell-updates.h
@@ -54,8 +54,9 @@ GType gs_shell_updates_get_type (void);
GsShellUpdates *gs_shell_updates_new (void);
void gs_shell_updates_invalidate (GsShellUpdates *shell_updates);
-void gs_shell_updates_refresh (GsShellUpdates *shell_updates,
+void gs_shell_updates_switch_to (GsShellUpdates *shell_updates,
gboolean scroll_up);
+void gs_shell_updates_reload (GsShellUpdates *shell_updates);
void gs_shell_updates_setup (GsShellUpdates *shell_updates,
GsShell *shell,
GsPluginLoader *plugin_loader,
diff --git a/src/gs-shell.c b/src/gs-shell.c
index c6daab0..36fe874 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -179,23 +179,23 @@ gs_shell_change_mode (GsShell *shell,
priv->mode = mode;
switch (mode) {
case GS_SHELL_MODE_OVERVIEW:
- gs_shell_overview_refresh (priv->shell_overview, scroll_up);
+ gs_shell_overview_switch_to (priv->shell_overview, scroll_up);
break;
case GS_SHELL_MODE_INSTALLED:
- gs_shell_installed_refresh (priv->shell_installed, scroll_up);
+ gs_shell_installed_switch_to (priv->shell_installed, scroll_up);
break;
case GS_SHELL_MODE_SEARCH:
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "entry_search"));
text = gtk_entry_get_text (GTK_ENTRY (widget));
- gs_shell_search_refresh (priv->shell_search, text, scroll_up);
+ gs_shell_search_switch_to (priv->shell_search, text, scroll_up);
break;
case GS_SHELL_MODE_UPDATES:
- gs_shell_updates_refresh (priv->shell_updates, scroll_up);
+ gs_shell_updates_switch_to (priv->shell_updates, scroll_up);
break;
case GS_SHELL_MODE_DETAILS:
if (app != NULL) {
gs_shell_details_set_app (priv->shell_details, app);
- gs_shell_details_refresh (priv->shell_details);
+ gs_shell_details_switch_to (priv->shell_details);
}
if (data != NULL)
gs_shell_details_set_filename (priv->shell_details, data);
@@ -203,7 +203,7 @@ gs_shell_change_mode (GsShell *shell,
case GS_SHELL_MODE_CATEGORY:
gs_shell_category_set_category (priv->shell_category,
GS_CATEGORY (data));
- gs_shell_category_refresh (priv->shell_category);
+ gs_shell_category_switch_to (priv->shell_category);
break;
default:
g_assert_not_reached ();
@@ -279,8 +279,8 @@ initial_overview_load_done (GsShellOverview *shell_overview, gpointer data)
g_signal_handlers_disconnect_by_func (shell_overview, initial_overview_load_done, data);
- gs_shell_updates_refresh (shell->priv->shell_updates, TRUE);
- gs_shell_installed_refresh (shell->priv->shell_installed, TRUE);
+ gs_shell_updates_reload (shell->priv->shell_updates);
+ gs_shell_installed_reload (shell->priv->shell_installed);
g_signal_emit (shell, signals[SIGNAL_LOADED], 0);
}
@@ -296,7 +296,7 @@ gs_shell_search_activated_cb (GtkEntry *entry, GsShell *shell)
return;
if (gs_shell_get_mode (shell) == GS_SHELL_MODE_SEARCH) {
- gs_shell_search_refresh (priv->shell_search, text, TRUE);
+ gs_shell_search_switch_to (priv->shell_search, text, TRUE);
} else {
gs_shell_change_mode (shell, GS_SHELL_MODE_SEARCH, NULL, NULL, TRUE);
}
@@ -414,7 +414,7 @@ search_changed_handler (GObject *entry, GsShell *shell) {
if (gs_shell_get_mode (shell) != GS_SHELL_MODE_SEARCH)
gs_shell_change_mode (shell, GS_SHELL_MODE_SEARCH, NULL, NULL, TRUE);
else
- gs_shell_search_refresh (shell->priv->shell_search, text, TRUE);
+ gs_shell_search_switch_to (shell->priv->shell_search, text, TRUE);
}
}
@@ -463,6 +463,21 @@ main_window_closed_cb (GtkWidget *dialog, GdkEvent *event, gpointer user_data)
}
/**
+ * gs_shell_updates_changed_cb:
+ */
+static void
+gs_shell_updates_changed_cb (GsPluginLoader *plugin_loader, GsShell *shell)
+{
+ GsShellPrivate *priv = shell->priv;
+ gs_shell_category_reload (priv->shell_category);
+ gs_shell_details_reload (priv->shell_details);
+ gs_shell_installed_reload (priv->shell_installed);
+ gs_shell_overview_reload (priv->shell_overview);
+ gs_shell_search_reload (priv->shell_search);
+ gs_shell_updates_reload (priv->shell_updates);
+}
+
+/**
* gs_shell_setup:
*/
void
@@ -474,6 +489,8 @@ gs_shell_setup (GsShell *shell, GsPluginLoader *plugin_loader, GCancellable *can
g_return_if_fail (GS_IS_SHELL (shell));
priv->plugin_loader = g_object_ref (plugin_loader);
+ g_signal_connect (priv->plugin_loader, "updates-changed",
+ G_CALLBACK (gs_shell_updates_changed_cb), shell);
priv->cancellable = g_object_ref (cancellable);
/* get UI */
@@ -603,6 +620,13 @@ gs_shell_get_mode (GsShell *shell)
return priv->mode;
}
+const gchar *
+gs_shell_get_mode_string (GsShell *shell)
+{
+ GsShellPrivate *priv = shell->priv;
+ return page_name[priv->mode];
+}
+
static void
gs_shell_get_installed_updates_cb (GsPluginLoader *plugin_loader,
GAsyncResult *res,
@@ -740,7 +764,7 @@ gs_shell_show_search_result (GsShell *shell, const gchar *id, const gchar *searc
if (search != NULL && search[0] != '\0') {
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "entry_search"));
gtk_entry_set_text (GTK_ENTRY (widget), search);
- gs_shell_search_refresh (priv->shell_search, search, TRUE);
+ gs_shell_search_switch_to (priv->shell_search, search, TRUE);
gs_shell_change_mode (shell, GS_SHELL_MODE_SEARCH, NULL, NULL, TRUE);
}
diff --git a/src/gs-shell.h b/src/gs-shell.h
index 035d60b..d051c58 100644
--- a/src/gs-shell.h
+++ b/src/gs-shell.h
@@ -72,6 +72,7 @@ void gs_shell_refresh (GsShell *shell,
void gs_shell_set_mode (GsShell *shell,
GsShellMode mode);
GsShellMode gs_shell_get_mode (GsShell *shell);
+const gchar *gs_shell_get_mode_string (GsShell *shell);
void gs_shell_show_installed_updates(GsShell *shell);
void gs_shell_show_sources (GsShell *shell);
void gs_shell_show_app (GsShell *shell,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]