From 9e1b0cc6de363ac75d9a656a10b0562e0ebeb61d Mon Sep 17 00:00:00 2001 From: DarkTrick Date: Tue, 27 Oct 2020 20:18:06 +0100 Subject: xfwm4-settings: Keyboard: Enable column sorting Initial issue: Columns were not sortable by the user. --- settings-dialogs/xfwm4-settings.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'settings-dialogs') diff --git a/settings-dialogs/xfwm4-settings.c b/settings-dialogs/xfwm4-settings.c index e8fe5c974..0a0b0c0c3 100644 --- a/settings-dialogs/xfwm4-settings.c +++ b/settings-dialogs/xfwm4-settings.c @@ -489,6 +489,7 @@ xfwm_settings_constructed (GObject *object) /* Keyboard tab: Shortcuts tree view */ { + GtkTreeViewColumn * column = NULL; gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (shortcuts_treeview)), GTK_SELECTION_MULTIPLE); @@ -497,14 +498,21 @@ xfwm_settings_constructed (GObject *object) g_object_unref (G_OBJECT (list_store)); renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (shortcuts_treeview), - 0, _("Action"), renderer, - "text", SHORTCUTS_NAME_COLUMN, NULL); + column = gtk_tree_view_column_new_with_attributes (_("Action"), renderer, + "text", SHORTCUTS_NAME_COLUMN, + NULL); + gtk_tree_view_insert_column (GTK_TREE_VIEW (shortcuts_treeview), column, 0); + gtk_tree_view_column_set_sort_column_id (column, SHORTCUTS_NAME_COLUMN); renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (shortcuts_treeview), - 1, _("Shortcut"), renderer, - "text", SHORTCUTS_SHORTCUT_LABEL_COLUMN, NULL); + column = gtk_tree_view_column_new_with_attributes (_("Shortcut"), renderer, + "text", SHORTCUTS_SHORTCUT_LABEL_COLUMN, + NULL); + gtk_tree_view_insert_column (GTK_TREE_VIEW (shortcuts_treeview), column, 1); + gtk_tree_view_column_set_sort_column_id (column, SHORTCUTS_SHORTCUT_LABEL_COLUMN); + + // set initial sorting + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_store), SHORTCUTS_NAME_COLUMN, GTK_SORT_ASCENDING); g_signal_connect (shortcuts_treeview, "row-activated", G_CALLBACK (xfwm_settings_shortcut_row_activated), settings); -- cgit v1.2.1