[gnome-software] Fix up visibility of the search bar



commit 32387cf82bba03fc27743c5d16e49c38011de30b
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Aug 29 22:02:49 2013 -0400

    Fix up visibility of the search bar
    
    At application start, we are calling refresh functions without
    making the corresponding page current. To avoid unintended effects,
    the refresh functions and their async callbacks must not change
    the visibility of any shared ui elements unless the page is still
    current.

 src/gs-shell-category.c  |    3 ---
 src/gs-shell-details.c   |    3 ---
 src/gs-shell-installed.c |   18 ++++++++++++------
 src/gs-shell-installed.h |    1 +
 src/gs-shell-updates.c   |    9 ++++-----
 src/gs-shell.c           |    1 +
 6 files changed, 18 insertions(+), 17 deletions(-)
---
diff --git a/src/gs-shell-category.c b/src/gs-shell-category.c
index feaead4..8c7c1a3 100644
--- a/src/gs-shell-category.c
+++ b/src/gs-shell-category.c
@@ -50,9 +50,6 @@ gs_shell_category_refresh (GsShellCategory *shell)
         widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "application_details_header"));
         gtk_widget_show (widget);
         gtk_label_set_label (GTK_LABEL (widget), gs_category_get_name (priv->category));
-
-       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "search_bar"));
-       gtk_widget_hide (widget);
 }
 
 static void
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 7214c0a..9a08b24 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -70,9 +70,6 @@ gs_shell_details_refresh (GsShellDetails *shell_details)
         widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_back"));
         gtk_widget_show (widget);
 
-       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "search_bar"));
-       gtk_widget_hide (widget);
-
        kind = gs_app_get_kind (priv->app);
        state = gs_app_get_state (priv->app);
 
diff --git a/src/gs-shell-installed.c b/src/gs-shell-installed.c
index 744db22..b471522 100644
--- a/src/gs-shell-installed.c
+++ b/src/gs-shell-installed.c
@@ -24,6 +24,7 @@
 #include <string.h>
 #include <glib/gi18n.h>
 
+#include "gs-shell.h"
 #include "gs-shell-installed.h"
 #include "gs-app.h"
 #include "gs-utils.h"
@@ -43,6 +44,7 @@ struct GsShellInstalledPrivate
        GtkSizeGroup            *sizegroup_name;
        gboolean                 cache_valid;
        gboolean                 waiting;
+        GsShell                 *shell;
 };
 
 G_DEFINE_TYPE (GsShellInstalled, gs_shell_installed, G_TYPE_OBJECT)
@@ -337,12 +339,14 @@ gs_shell_installed_refresh (GsShellInstalled *shell_installed)
         GtkSpinner *spinner;
         GtkAdjustment *adj;
 
-        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 (gs_shell_get_mode (priv->shell) == GS_SHELL_MODE_INSTALLED) {
+                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), "");
+        }
 
         resort_list (shell_installed);
 
@@ -453,6 +457,7 @@ gs_shell_installed_pending_apps_changed_cb (GsPluginLoader *plugin_loader,
  */
 void
 gs_shell_installed_setup (GsShellInstalled *shell_installed,
+                          GsShell *shell,
                          GsPluginLoader *plugin_loader,
                          GtkBuilder *builder,
                          GCancellable *cancellable)
@@ -462,6 +467,7 @@ gs_shell_installed_setup (GsShellInstalled *shell_installed,
 
        g_return_if_fail (GS_IS_SHELL_INSTALLED (shell_installed));
 
+        priv->shell = shell;
        priv->plugin_loader = g_object_ref (plugin_loader);
        g_signal_connect (priv->plugin_loader, "pending-apps-changed",
                          G_CALLBACK (gs_shell_installed_pending_apps_changed_cb),
diff --git a/src/gs-shell-installed.h b/src/gs-shell-installed.h
index ede2e78..75cb9ac 100644
--- a/src/gs-shell-installed.h
+++ b/src/gs-shell-installed.h
@@ -55,6 +55,7 @@ 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_setup       (GsShellInstalled       *shell_installed,
+                                                 GsShell                *shell,
                                                 GsPluginLoader         *plugin_loader,
                                                 GtkBuilder             *builder,
                                                 GCancellable           *cancellable);
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index 6b33068..5f3b11c 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -156,8 +156,10 @@ gs_shell_updates_refresh (GsShellUpdates *shell_updates)
         GtkSpinner *spinner;
         GList *list;
 
-        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "buttonbox_main"));
-        gtk_widget_show (widget);
+        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);
+        }
 
        /* no need to refresh */
        if (priv->cache_valid) {
@@ -178,9 +180,6 @@ gs_shell_updates_refresh (GsShellUpdates *shell_updates)
        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "scrolledwindow_updates"));
        gtk_widget_show (widget);
 
-       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "search_bar"));
-       gtk_widget_hide (widget);
-
         if (priv->waiting)
                 return;
 
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 13c0a6e..e856b66 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -365,6 +365,7 @@ gs_shell_setup (GsShell *shell, GsPluginLoader *plugin_loader, GCancellable *can
                                priv->builder,
                                priv->cancellable);
        gs_shell_installed_setup (priv->shell_installed,
+                                  shell,
                                  priv->plugin_loader,
                                  priv->builder,
                                  priv->cancellable);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]