[gnome-control-center] shell/alt: Always activate panel list after view change



commit 8b09079f342303f830c4234fe1c4155d4cb7aabc
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Jul 14 18:11:30 2017 +0200

    shell/alt: Always activate panel list after view change
    
    The displayed panel should always match the selection in the panel
    list. That implies that after swapping out the list (for instance
    by browsing Devices or Details), we need to update the panel rather
    than keeping the old one around until the user manually selects a
    row. The easiest way to achieve that is to activate the panel list
    after a view change when appropriate.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783429

 shell/alt/cc-panel-list.c |   27 +++++++++++++++++++++++++--
 shell/alt/cc-window.c     |    1 -
 2 files changed, 25 insertions(+), 3 deletions(-)
---
diff --git a/shell/alt/cc-panel-list.c b/shell/alt/cc-panel-list.c
index 513d6bd..b984aae 100644
--- a/shell/alt/cc-panel-list.c
+++ b/shell/alt/cc-panel-list.c
@@ -40,6 +40,11 @@ struct _CcPanelList
   GtkWidget          *main_listbox;
   GtkWidget          *search_listbox;
 
+  /* When clicking on Details or Devices row, show it
+   * automatically select the first panel of the list.
+   */
+  gboolean            autoselect_panel : 1;
+
   GtkListBoxRow      *details_row;
   GtkListBoxRow      *devices_row;
 
@@ -410,14 +415,14 @@ row_activated_cb (GtkWidget     *listbox,
   if (row == self->details_row)
     {
       cc_panel_list_set_view (self, CC_PANEL_LIST_DETAILS);
-      return;
+      goto out;
     }
 
   /* Devices */
   if (row == self->devices_row)
     {
       cc_panel_list_set_view (self, CC_PANEL_LIST_DEVICES);
-      return;
+      goto out;
     }
 
   /*
@@ -445,6 +450,13 @@ row_activated_cb (GtkWidget     *listbox,
   data = g_object_get_data (G_OBJECT (row), "data");
 
   g_signal_emit (self, signals[SHOW_PANEL], 0, data->id);
+
+out:
+  /* After selecting the panel and eventually changing the view, reset the
+   * autoselect flag. If necessary, cc_panel_list_set_active_panel() will
+   * set it to FALSE again.
+   */
+  self->autoselect_panel = TRUE;
 }
 
 static void
@@ -768,6 +780,12 @@ cc_panel_list_set_view (CcPanelList     *self,
 
       gtk_stack_set_visible_child (GTK_STACK (self), visible_child);
 
+      /* For non-search views, make sure the displayed panel matches the
+       * newly selected row
+       */
+      if (self->autoselect_panel && view != CC_PANEL_LIST_SEARCH)
+        cc_panel_list_activate (self);
+
       g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_VIEW]);
       g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SEARCH_MODE]);
     }
@@ -838,5 +856,10 @@ cc_panel_list_set_active_panel (CcPanelList *self,
   gtk_list_box_select_row (GTK_LIST_BOX (listbox), GTK_LIST_BOX_ROW (data->row));
   gtk_widget_grab_focus (data->row);
 
+  /* When setting the active panel programatically, prevent from
+   * autoselecting the first panel of the new view.
+   */
+  self->autoselect_panel = FALSE;
+
   g_signal_emit_by_name (data->row, "activate");
 }
diff --git a/shell/alt/cc-window.c b/shell/alt/cc-window.c
index 2333c52..9f29c55 100644
--- a/shell/alt/cc-window.c
+++ b/shell/alt/cc-window.c
@@ -198,7 +198,6 @@ static void
 shell_show_overview_page (CcWindow *self)
 {
   cc_panel_list_set_view (CC_PANEL_LIST (self->panel_list), CC_PANEL_LIST_MAIN);
-  cc_panel_list_activate (CC_PANEL_LIST (self->panel_list));
 
   if (self->current_panel_box)
     gtk_container_remove (GTK_CONTAINER (self->stack), self->current_panel_box);


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