[gnome-control-center] shell: update sidebar when active panel is set externally
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] shell: update sidebar when active panel is set externally
- Date: Tue, 26 Jul 2016 14:25:13 +0000 (UTC)
commit 42a360eed682990b00c0b2d8d13c27c7496eb9ee
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Jul 15 00:12:49 2016 -0300
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
shell/alt/cc-panel-list.c | 30 ++++++++++++++++++++++++++++++
shell/alt/cc-panel-list.h | 3 +++
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 1c26dd2..393e6b7 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 0cd1880..bf50a8c 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 dbc6e5a..2fd20dd 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]