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.
This commit is contained in:
parent
c6d5df7d27
commit
661df1b683
4 changed files with 43 additions and 0 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -536,6 +536,21 @@ notify_fold_cb (HdyLeaflet *leaflet,
|
|||
update_fold_state (shell);
|
||||
}
|
||||
|
||||
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,
|
||||
|
@ -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);
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue