diff options
author | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2016-07-15 00:12:49 -0300 |
---|---|---|
committer | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2016-07-26 11:22:28 -0300 |
commit | 42a360eed682990b00c0b2d8d13c27c7496eb9ee (patch) | |
tree | a612b9690673b051d484d15642d49763176991e2 | |
parent | 1345cf36c5de360260e62109db84affdec6db079 (diff) | |
download | gnome-control-center-42a360eed682990b00c0b2d8d13c27c7496eb9ee.tar.gz |
shell: update sidebar when active panel is set externally
When the active panel is not changed through sidebar navigation,
e.g. by calling the Control Center through command line and asking
to open a specific panel, the panel is correctly opened but the
sidebar is not updated to reflect that.
Fix that by selecting the externally set panel row, and eventually
moving to the correct list.
https://bugzilla.gnome.org/show_bug.cgi?id=769063
-rw-r--r-- | shell/alt/cc-panel-list.c | 30 | ||||
-rw-r--r-- | shell/alt/cc-panel-list.h | 3 | ||||
-rw-r--r-- | shell/alt/cc-window.c | 2 |
3 files changed, 35 insertions, 0 deletions
diff --git a/shell/alt/cc-panel-list.c b/shell/alt/cc-panel-list.c index 1c26dd2de..393e6b72e 100644 --- a/shell/alt/cc-panel-list.c +++ b/shell/alt/cc-panel-list.c @@ -49,6 +49,7 @@ struct _CcPanelList CcPanelListView previous_view; CcPanelListView view; + GHashTable *id_to_data; }; G_DEFINE_TYPE (CcPanelList, cc_panel_list, GTK_TYPE_STACK) @@ -503,6 +504,7 @@ cc_panel_list_finalize (GObject *object) CcPanelList *self = (CcPanelList *)object; g_clear_pointer (&self->search_query, g_free); + g_clear_pointer (&self->id_to_data, g_hash_table_destroy); G_OBJECT_CLASS (cc_panel_list_parent_class)->finalize (object); } @@ -640,6 +642,7 @@ cc_panel_list_init (CcPanelList *self) { gtk_widget_init_template (GTK_WIDGET (self)); + self->id_to_data = g_hash_table_new (g_str_hash, g_str_equal); self->view = CC_PANEL_LIST_MAIN; gtk_list_box_set_sort_func (GTK_LIST_BOX (self->main_listbox), @@ -805,4 +808,31 @@ cc_panel_list_add_panel (CcPanelList *self, /* And add to the search listbox too */ search_data = row_data_new (category, id, title, description, icon); gtk_container_add (GTK_CONTAINER (self->search_listbox), search_data->row); + + g_hash_table_insert (self->id_to_data, data->id, data); +} + +/** + * cc_panel_list_set_active_panel: + * @self: a #CcPanelList + * @id: the id of the panel to be activated + * + * Sets the current active panel. + */ +void +cc_panel_list_set_active_panel (CcPanelList *self, + const gchar *id) +{ + GtkWidget *listbox; + RowData *data; + + g_return_if_fail (CC_IS_PANEL_LIST (self)); + + data = g_hash_table_lookup (self->id_to_data, id); + listbox = gtk_widget_get_parent (data->row); + + gtk_list_box_select_row (GTK_LIST_BOX (listbox), GTK_LIST_BOX_ROW (data->row)); + gtk_widget_grab_focus (data->row); + + g_signal_emit_by_name (data->row, "activate"); } diff --git a/shell/alt/cc-panel-list.h b/shell/alt/cc-panel-list.h index 0cd1880c8..bf50a8c39 100644 --- a/shell/alt/cc-panel-list.h +++ b/shell/alt/cc-panel-list.h @@ -61,6 +61,9 @@ void cc_panel_list_add_panel (CcPanelList const gchar *description, const gchar *icon); +void cc_panel_list_set_active_panel (CcPanelList *self, + const gchar *id); + G_END_DECLS #endif /* CC_PANEL_LIST_H */ diff --git a/shell/alt/cc-window.c b/shell/alt/cc-window.c index dbc6e5a8e..2fd20dd83 100644 --- a/shell/alt/cc-window.c +++ b/shell/alt/cc-window.c @@ -475,6 +475,8 @@ cc_window_set_active_panel_from_id (CcShell *shell, if (old_panel) gtk_container_remove (GTK_CONTAINER (self->stack), old_panel); + + cc_panel_list_set_active_panel (CC_PANEL_LIST (self->panel_list), start_id); } g_free (name); |