From 81c03e738fd933702738264c75b0a4a0a72495b9 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 1d370484..251f4a93 100644 --- a/src/file-manager/fm-list-view.c +++ b/src/file-manager/fm-list-view.c @@ -1544,27 +1544,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; @@ -1646,7 +1641,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. */ @@ -1760,7 +1755,7 @@ create_and_set_up_tree_view (FMListView *view) gtk_style_context_get_font (context, GTK_STATE_FLAG_NORMAL))); 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, @@ -1804,14 +1799,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