diff options
author | Alexander Larsson <alexl@redhat.com> | 2006-12-04 17:39:52 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2006-12-04 17:39:52 +0000 |
commit | daba3077c4042a6dee471778f3d09c1b175bfd88 (patch) | |
tree | bd8ac248ee8d7b81ef124541801d8490570b2d12 /src | |
parent | 9afc81b817441776a6c46f1272019430a845d978 (diff) | |
download | nautilus-daba3077c4042a6dee471778f3d09c1b175bfd88.tar.gz |
Reveal selection on sort-order change.(#332667) Patch from Gene Z. Ragan
2006-12-04 Alexander Larsson <alexl@redhat.com>
* src/file-manager/fm-list-view.c:
Reveal selection on sort-order change.(#332667)
Patch from Gene Z. Ragan
Diffstat (limited to 'src')
-rw-r--r-- | src/file-manager/fm-list-view.c | 65 |
1 files changed, 34 insertions, 31 deletions
diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c index 518260bc9..f81fd481c 100644 --- a/src/file-manager/fm-list-view.c +++ b/src/file-manager/fm-list-view.c @@ -969,6 +969,36 @@ key_press_callback (GtkWidget *widget, GdkEventKey *event, gpointer callback_dat } static void +fm_list_view_reveal_selection (FMDirectoryView *view) +{ + GList *selection; + + g_return_if_fail (FM_IS_LIST_VIEW (view)); + + selection = fm_directory_view_get_selection (view); + + /* Make sure at least one of the selected items is scrolled into view */ + if (selection != NULL) { + FMListView *list_view; + NautilusFile *file; + GtkTreeIter iter; + GtkTreePath *path; + + list_view = FM_LIST_VIEW (view); + file = selection->data; + if (fm_list_model_get_first_iter_for_file (list_view->details->model, file, &iter)) { + path = gtk_tree_model_get_path (GTK_TREE_MODEL (list_view->details->model), &iter); + + gtk_tree_view_scroll_to_cell (list_view->details->tree_view, path, NULL, FALSE, 0.0, 0.0); + + gtk_tree_path_free (path); + } + } + + nautilus_file_list_free (selection); +} + +static void sort_column_changed_callback (GtkTreeSortable *sortable, FMListView *view) { @@ -994,6 +1024,9 @@ sort_column_changed_callback (GtkTreeSortable *sortable, reversed_attr = (reversed ? "true" : "false"); nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_REVERSED, default_reversed_attr, reversed_attr); + + /* Make sure selected item(s) is visible after sort */ + fm_list_view_reveal_selection (FM_DIRECTORY_VIEW (view)); } static void @@ -1482,7 +1515,7 @@ set_sort_order_from_metadata_and_preferences (FMListView *list_view) gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_view->details->model), sort_column_id, - sort_reversed ? GTK_SORT_DESCENDING : GTK_SORT_ASCENDING); + sort_reversed ? GTK_SORT_DESCENDING : GTK_SORT_ASCENDING); } static gboolean @@ -1837,36 +1870,6 @@ fm_list_view_select_all (FMDirectoryView *view) } static void -fm_list_view_reveal_selection (FMDirectoryView *view) -{ - GList *selection; - - g_return_if_fail (FM_IS_LIST_VIEW (view)); - - selection = fm_directory_view_get_selection (view); - - /* Make sure at least one of the selected items is scrolled into view */ - if (selection != NULL) { - FMListView *list_view; - NautilusFile *file; - GtkTreeIter iter; - GtkTreePath *path; - - list_view = FM_LIST_VIEW (view); - file = selection->data; - if (fm_list_model_get_first_iter_for_file (list_view->details->model, file, &iter)) { - path = gtk_tree_model_get_path (GTK_TREE_MODEL (list_view->details->model), &iter); - - gtk_tree_view_scroll_to_cell (list_view->details->tree_view, path, NULL, FALSE, 0.0, 0.0); - - gtk_tree_path_free (path); - } - } - - nautilus_file_list_free (selection); -} - -static void column_editor_response_callback (GtkWidget *dialog, int response_id, gpointer user_data) |