From d443ee5ad388cacc96ce7d523af5216e266daf01 Mon Sep 17 00:00:00 2001 From: monsta Date: Fri, 6 Jan 2017 13:39:44 +0300 Subject: show/hide columns instead of appending/removing them fixes https://github.com/mate-desktop/caja/issues/649 adapted from: https://git.gnome.org/browse/nautilus/commit/?id=e19f7cb3fec1e6c884d1741c3c00916c65ab035f --- src/file-manager/fm-list-view.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c index 46f6c143..163f1be8 100644 --- a/src/file-manager/fm-list-view.c +++ b/src/file-manager/fm-list-view.c @@ -1541,27 +1541,22 @@ apply_columns_settings (FMListView *list_view, view_columns = g_list_reverse (view_columns); - /* remove columns that are not present in the configuration */ + /* hide columns that are not present in the configuration */ old_view_columns = gtk_tree_view_get_columns (list_view->details->tree_view); for (l = old_view_columns; l != NULL; l = l->next) { if (g_list_find (view_columns, l->data) == NULL) { - gtk_tree_view_remove_column (list_view->details->tree_view, l->data); + gtk_tree_view_column_set_visible (l->data, FALSE); } } g_list_free (old_view_columns); - /* append new columns from the configuration */ - old_view_columns = gtk_tree_view_get_columns (list_view->details->tree_view); + /* show new columns from the configuration */ for (l = view_columns; l != NULL; l = l->next) { - if (g_list_find (old_view_columns, l->data) == NULL) - { - gtk_tree_view_append_column (list_view->details->tree_view, l->data); - } + gtk_tree_view_column_set_visible (l->data, TRUE); } - g_list_free (old_view_columns); /* place columns in the correct order */ prev_view_column = NULL; @@ -1643,7 +1638,7 @@ create_and_set_up_tree_view (FMListView *view) view->details->columns = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify)g_free, - (GDestroyNotify) g_object_unref); + NULL); gtk_tree_view_set_enable_search (view->details->tree_view, TRUE); /* Don't handle backspace key. It's used to open the parent folder. */ @@ -1762,7 +1757,7 @@ create_and_set_up_tree_view (FMListView *view) font_size = PANGO_PIXELS (pango_font_description_get_size (gtk_widget_get_style (GTK_WIDGET(view))->font_desc)); #endif gtk_tree_view_column_set_min_width (view->details->file_name_column, 20*font_size); - g_object_ref_sink (view->details->file_name_column); + gtk_tree_view_append_column (view->details->tree_view, view->details->file_name_column); view->details->file_name_column_num = column_num; g_hash_table_insert (view->details->columns, @@ -1806,14 +1801,13 @@ create_and_set_up_tree_view (FMListView *view) cell, "text", column_num, NULL); - g_object_ref_sink (column); + gtk_tree_view_append_column (view->details->tree_view, column); gtk_tree_view_column_set_sort_column_id (column, column_num); g_hash_table_insert (view->details->columns, g_strdup (name), column); gtk_tree_view_column_set_resizable (column, TRUE); - gtk_tree_view_column_set_visible (column, TRUE); } g_free (name); g_free (label); -- cgit v1.2.1