From 2f1ef69fb759bdf99b9b0198b51b7ec21c718380 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 3 Jul 2008 22:40:33 +0000 Subject: [PATCH] Don't select the first row if the folder is empty. Patch by Olle * gtk/gtkfilechooserdefault.c (browse_files_select_first_row): Don't select the first row if the folder is empty. Patch by Olle Bergkvist. svn path=/trunk/; revision=20751 --- ChangeLog | 8 ++++++++ gtk/gtkfilechooserdefault.c | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 997a173a4e..2b9cb36956 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,14 @@ * gdk/win32/gdkinput-win32.c: Fetch the device and cursor names in Unicode, and convert to UTF-8 for the GdkDevice's name field. +2008-07-03 Matthias Clasen + + Bug 538863 – Fixes assertion on entering empty folder + + * gtk/gtkfilechooserdefault.c (browse_files_select_first_row): Don't + select the first row if the folder is empty. + Patch by Olle Bergkvist. + 2008-07-03 Matthias Clasen Bug 540915 – GtkBuilder sets properties in reverse order diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index ce575eae6c..458bdee71a 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -6285,12 +6285,19 @@ static void browse_files_select_first_row (GtkFileChooserDefault *impl) { GtkTreePath *path; + GtkTreeIter dummy_iter; + GtkTreeModel *tree_model; if (!impl->sort_model) return; path = gtk_tree_path_new_from_indices (0, -1); - gtk_tree_view_set_cursor (GTK_TREE_VIEW (impl->browse_files_tree_view), path, NULL, FALSE); + tree_model = gtk_tree_view_get_model (GTK_TREE_VIEW (impl->browse_files_tree_view)); + + /* If the list is empty, do nothing. */ + if (gtk_tree_model_get_iter (tree_model, &dummy_iter, path)) + gtk_tree_view_set_cursor (GTK_TREE_VIEW (impl->browse_files_tree_view), path, NULL, FALSE); + gtk_tree_path_free (path); }