From 9335fda65695dd4796f419c2db122c03ccb4b308 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Thu, 6 Jan 2005 02:05:48 +0000 Subject: [PATCH] Merged from HEAD: 2005-01-05 Federico Mena Quintero Merged from HEAD: * gtk/gtkpathbar.c (_gtk_path_bar_set_path): Don't call button_data_free() explicitly; the button is weak-reffed and the callback will free the button data. Fixes #163010. (_gtk_path_bar_set_path): Don't ref/sink the button. And for the failure case, call gtk_widget_destroy() on it. * gtk/gtkfilechooserdefault.c (check_is_folder): Use gtk_file_system_get_folder() again (see the ChangeLog entry from 2004-08-25). We can't first get the parent folder and then request the info for the path in question, as the parent folder may not be readable. See bug #162617. (gtk_file_chooser_default_set_current_folder): Assert that the passed-in path is not null. (shortcuts_find_current_folder): Likewise. (shortcuts_add_current_folder): Likewise. (set_list_model): Likewise. (gtk_file_chooser_default_map): Only reload the current folder if it exists. (bookmarks_check_add_sensitivity): Check for the current folder being NULL. (browse_files_select_first_row): Don't set the cursor if there is no model loaded. --- ChangeLog | 27 +++++++++++++++++++++++ ChangeLog.pre-2-10 | 27 +++++++++++++++++++++++ ChangeLog.pre-2-6 | 27 +++++++++++++++++++++++ ChangeLog.pre-2-8 | 27 +++++++++++++++++++++++ gtk/gtkfilechooserdefault.c | 44 ++++++++++++++++--------------------- gtk/gtkpathbar.c | 7 +----- 6 files changed, 128 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2394b82486..ba5560429b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2005-01-05 Federico Mena Quintero + + Merged from HEAD: + + * gtk/gtkpathbar.c (_gtk_path_bar_set_path): Don't call + button_data_free() explicitly; the button is weak-reffed and the + callback will free the button data. Fixes #163010. + (_gtk_path_bar_set_path): Don't ref/sink the button. And for the + failure case, call gtk_widget_destroy() on it. + + * gtk/gtkfilechooserdefault.c (check_is_folder): Use + gtk_file_system_get_folder() again (see the ChangeLog entry from + 2004-08-25). We can't first get the parent folder and then + request the info for the path in question, as the parent folder + may not be readable. See bug #162617. + (gtk_file_chooser_default_set_current_folder): Assert that the + passed-in path is not null. + (shortcuts_find_current_folder): Likewise. + (shortcuts_add_current_folder): Likewise. + (set_list_model): Likewise. + (gtk_file_chooser_default_map): Only reload the current folder if + it exists. + (bookmarks_check_add_sensitivity): Check for the current folder + being NULL. + (browse_files_select_first_row): Don't set the cursor if there is + no model loaded. + 2005-01-05 Federico Mena Quintero Merged from HEAD: diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 2394b82486..ba5560429b 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,30 @@ +2005-01-05 Federico Mena Quintero + + Merged from HEAD: + + * gtk/gtkpathbar.c (_gtk_path_bar_set_path): Don't call + button_data_free() explicitly; the button is weak-reffed and the + callback will free the button data. Fixes #163010. + (_gtk_path_bar_set_path): Don't ref/sink the button. And for the + failure case, call gtk_widget_destroy() on it. + + * gtk/gtkfilechooserdefault.c (check_is_folder): Use + gtk_file_system_get_folder() again (see the ChangeLog entry from + 2004-08-25). We can't first get the parent folder and then + request the info for the path in question, as the parent folder + may not be readable. See bug #162617. + (gtk_file_chooser_default_set_current_folder): Assert that the + passed-in path is not null. + (shortcuts_find_current_folder): Likewise. + (shortcuts_add_current_folder): Likewise. + (set_list_model): Likewise. + (gtk_file_chooser_default_map): Only reload the current folder if + it exists. + (bookmarks_check_add_sensitivity): Check for the current folder + being NULL. + (browse_files_select_first_row): Don't set the cursor if there is + no model loaded. + 2005-01-05 Federico Mena Quintero Merged from HEAD: diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 2394b82486..ba5560429b 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,30 @@ +2005-01-05 Federico Mena Quintero + + Merged from HEAD: + + * gtk/gtkpathbar.c (_gtk_path_bar_set_path): Don't call + button_data_free() explicitly; the button is weak-reffed and the + callback will free the button data. Fixes #163010. + (_gtk_path_bar_set_path): Don't ref/sink the button. And for the + failure case, call gtk_widget_destroy() on it. + + * gtk/gtkfilechooserdefault.c (check_is_folder): Use + gtk_file_system_get_folder() again (see the ChangeLog entry from + 2004-08-25). We can't first get the parent folder and then + request the info for the path in question, as the parent folder + may not be readable. See bug #162617. + (gtk_file_chooser_default_set_current_folder): Assert that the + passed-in path is not null. + (shortcuts_find_current_folder): Likewise. + (shortcuts_add_current_folder): Likewise. + (set_list_model): Likewise. + (gtk_file_chooser_default_map): Only reload the current folder if + it exists. + (bookmarks_check_add_sensitivity): Check for the current folder + being NULL. + (browse_files_select_first_row): Don't set the cursor if there is + no model loaded. + 2005-01-05 Federico Mena Quintero Merged from HEAD: diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 2394b82486..ba5560429b 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,30 @@ +2005-01-05 Federico Mena Quintero + + Merged from HEAD: + + * gtk/gtkpathbar.c (_gtk_path_bar_set_path): Don't call + button_data_free() explicitly; the button is weak-reffed and the + callback will free the button data. Fixes #163010. + (_gtk_path_bar_set_path): Don't ref/sink the button. And for the + failure case, call gtk_widget_destroy() on it. + + * gtk/gtkfilechooserdefault.c (check_is_folder): Use + gtk_file_system_get_folder() again (see the ChangeLog entry from + 2004-08-25). We can't first get the parent folder and then + request the info for the path in question, as the parent folder + may not be readable. See bug #162617. + (gtk_file_chooser_default_set_current_folder): Assert that the + passed-in path is not null. + (shortcuts_find_current_folder): Likewise. + (shortcuts_add_current_folder): Likewise. + (set_list_model): Likewise. + (gtk_file_chooser_default_map): Only reload the current folder if + it exists. + (bookmarks_check_add_sensitivity): Check for the current folder + being NULL. + (browse_files_select_first_row): Don't set the cursor if there is + no model loaded. + 2005-01-05 Federico Mena Quintero Merged from HEAD: diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index 0fe71bf96f..3d9d1577cd 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -1016,6 +1016,7 @@ shortcuts_find_current_folder (GtkFileChooserDefault *impl) selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view)); + g_assert (impl->current_folder != NULL); pos = shortcut_find_position (impl, impl->current_folder); if (pos == -1) { @@ -1061,32 +1062,14 @@ get_file_info (GtkFileSystem *file_system, const GtkFilePath *path, gboolean nam static gboolean check_is_folder (GtkFileSystem *file_system, const GtkFilePath *path, GError **error) { - GtkFileInfo *info; - gboolean is_folder; + GtkFileFolder *folder; - /* Use get_file_info() rather than trying get_folder() and checking - * for an error directly because older versions of the gnome-vfs - * backend don't return an error immediately. This way is also - * more efficient if we already have the parent folder. - */ - info = get_file_info (file_system, path, FALSE, error); - - if (!info) + folder = gtk_file_system_get_folder (file_system, path, 0, error); + if (!folder) return FALSE; - is_folder = gtk_file_info_get_is_folder (info); - - if (!is_folder) - g_set_error (error, - GTK_FILE_SYSTEM_ERROR, - GTK_FILE_SYSTEM_ERROR_NOT_FOLDER, - "%s: %s", - gtk_file_info_get_display_name (info), - g_strerror (ENOTDIR)); - - gtk_file_info_free (info); - - return is_folder; + g_object_unref (folder); + return TRUE; } /* Inserts a path in the shortcuts tree, making a copy of it; alternatively, @@ -1430,6 +1413,8 @@ shortcuts_add_current_folder (GtkFileChooserDefault *impl) success = TRUE; + g_assert (impl->current_folder != NULL); + pos = shortcut_find_position (impl, impl->current_folder); if (pos == -1) { @@ -2003,7 +1988,7 @@ bookmarks_check_add_sensitivity (GtkFileChooserDefault *impl) selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view)); if (gtk_tree_selection_count_selected_rows (selection) == 0) - active = (shortcut_find_position (impl, impl->current_folder) == -1); + active = (impl->current_folder != NULL) && (shortcut_find_position (impl, impl->current_folder) == -1); else { gboolean all_folders; @@ -3797,7 +3782,9 @@ gtk_file_chooser_default_map (GtkWidget *widget) GTK_WIDGET_CLASS (parent_class)->map (widget); - change_folder_and_display_error (impl, impl->current_folder); + if (impl->current_folder) + change_folder_and_display_error (impl, impl->current_folder); + bookmarks_changed_cb (impl->file_system, impl); } @@ -4068,6 +4055,9 @@ browse_files_select_first_row (GtkFileChooserDefault *impl) { GtkTreePath *path; + 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); gtk_tree_path_free (path); @@ -4152,6 +4142,8 @@ static gboolean set_list_model (GtkFileChooserDefault *impl, GError **error) { + g_assert (impl->current_folder != NULL); + load_remove_timer (impl); if (impl->browse_files_model) @@ -4239,6 +4231,8 @@ gtk_file_chooser_default_set_current_folder (GtkFileChooser *chooser, GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser); gboolean result; + g_assert (path != NULL); + if (impl->local_only && !gtk_file_system_path_is_local (impl->file_system, path)) { diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c index eb0645fbf9..a22fc42445 100644 --- a/gtk/gtkpathbar.c +++ b/gtk/gtkpathbar.c @@ -1293,9 +1293,6 @@ _gtk_path_bar_set_path (GtkPathBar *path_bar, gtk_file_info_free (file_info); gtk_file_path_free (path); - g_object_ref (button_data->button); - gtk_object_sink (GTK_OBJECT (button_data->button)); - new_buttons = g_list_prepend (new_buttons, button_data); if (button_data->type != NORMAL_BUTTON) @@ -1330,9 +1327,7 @@ _gtk_path_bar_set_path (GtkPathBar *path_bar, ButtonData *button_data; button_data = BUTTON_DATA (l->data); - - gtk_widget_unref (button_data->button); - button_data_free (button_data); + gtk_widget_destroy (button_data->button); } g_list_free (new_buttons);