diff options
author | Mohammed Sadiq <sadiq@sadiqpk.org> | 2019-07-25 21:48:35 +0530 |
---|---|---|
committer | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2019-08-27 13:26:21 +0000 |
commit | 661df1b6830dea73f267334b5f5bc102e411ebd5 (patch) | |
tree | fd32ca809d94beea8be0212864d945cdc7372866 /shell | |
parent | c6d5df7d2768586d2bfad845622964c9ee67614d (diff) | |
download | gnome-control-center-661df1b6830dea73f267334b5f5bc102e411ebd5.tar.gz |
window: Disable selection when panel list is folded
When the panel list is folded, either the panel items list or the
panel itself is shown, not both. And when the list is shown it
doesn’t mean anything for an item to be marked as selected.
Diffstat (limited to 'shell')
-rw-r--r-- | shell/cc-panel-list.c | 23 | ||||
-rw-r--r-- | shell/cc-panel-list.h | 3 | ||||
-rw-r--r-- | shell/cc-window.c | 16 | ||||
-rw-r--r-- | shell/cc-window.ui | 1 |
4 files changed, 43 insertions, 0 deletions
diff --git a/shell/cc-panel-list.c b/shell/cc-panel-list.c index 67a0ac77f..e5134ac6b 100644 --- a/shell/cc-panel-list.c +++ b/shell/cc-panel-list.c @@ -1137,3 +1137,26 @@ cc_panel_list_add_sidebar_widget (CcPanelList *self, gtk_container_remove (GTK_CONTAINER (self), widget); } } + +void +cc_panel_list_set_selection_mode (CcPanelList *self, + GtkSelectionMode selection_mode) +{ + g_return_if_fail (CC_IS_PANEL_LIST (self)); + + gtk_list_box_set_selection_mode (GTK_LIST_BOX (self->main_listbox), selection_mode); + gtk_list_box_set_selection_mode (GTK_LIST_BOX (self->devices_listbox), selection_mode); + gtk_list_box_set_selection_mode (GTK_LIST_BOX (self->details_listbox), selection_mode); + + /* When selection mode changed, selection will be lost. So reselect */ + if (selection_mode == GTK_SELECTION_SINGLE && self->current_panel_id) + { + GtkWidget *listbox; + RowData *data; + + data = g_hash_table_lookup (self->id_to_data, self->current_panel_id); + listbox = gtk_widget_get_parent (data->row); + gtk_list_box_select_row (GTK_LIST_BOX (listbox), GTK_LIST_BOX_ROW (data->row)); + } +} + diff --git a/shell/cc-panel-list.h b/shell/cc-panel-list.h index 525734ea5..76995c2b8 100644 --- a/shell/cc-panel-list.h +++ b/shell/cc-panel-list.h @@ -73,6 +73,9 @@ void cc_panel_list_set_panel_visibility (CcPanelList void cc_panel_list_add_sidebar_widget (CcPanelList *self, GtkWidget *widget); +void cc_panel_list_set_selection_mode (CcPanelList *self, + GtkSelectionMode selection_mode); + G_END_DECLS #endif /* CC_PANEL_LIST_H */ diff --git a/shell/cc-window.c b/shell/cc-window.c index 6cbe22c71..8a6c6eeeb 100644 --- a/shell/cc-window.c +++ b/shell/cc-window.c @@ -537,6 +537,21 @@ notify_fold_cb (HdyLeaflet *leaflet, } static void +on_main_leaflet_fold_changed_cb (CcWindow *self) +{ + GtkSelectionMode selection_mode; + + g_assert (CC_IS_WINDOW (self)); + + selection_mode = GTK_SELECTION_SINGLE; + + if (hdy_leaflet_get_fold (HDY_LEAFLET (self->main_leaflet)) == HDY_FOLD_FOLDED) + selection_mode = GTK_SELECTION_NONE; + + cc_panel_list_set_selection_mode (CC_PANEL_LIST (self->panel_list), selection_mode); +} + +static void show_panel_cb (CcPanelList *panel_list, const gchar *panel_id, CcWindow *self) @@ -917,6 +932,7 @@ cc_window_class_init (CcWindowClass *klass) gtk_widget_class_bind_template_callback (widget_class, gdk_window_set_cb); gtk_widget_class_bind_template_callback (widget_class, notify_header_visible_child_cb); gtk_widget_class_bind_template_callback (widget_class, notify_fold_cb); + gtk_widget_class_bind_template_callback (widget_class, on_main_leaflet_fold_changed_cb); gtk_widget_class_bind_template_callback (widget_class, on_development_warning_dialog_responded_cb); gtk_widget_class_bind_template_callback (widget_class, previous_button_clicked_cb); gtk_widget_class_bind_template_callback (widget_class, search_entry_activate_cb); diff --git a/shell/cc-window.ui b/shell/cc-window.ui index 45f9182f1..e7b2a5d89 100644 --- a/shell/cc-window.ui +++ b/shell/cc-window.ui @@ -15,6 +15,7 @@ <property name="can_focus">False</property> <property name="mode-transition-type">slide</property> <property name="child-transition-type">slide</property> + <signal name="notify::fold" handler="on_main_leaflet_fold_changed_cb" object="CcWindow" swapped="yes" /> <child> <object class="GtkBox" id="sidebar_box"> <property name="visible">True</property> |