summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorMorten Welinder <terra@gnome.org>2004-03-10 17:55:16 +0000
committerMorten Welinder <mortenw@src.gnome.org>2004-03-10 17:55:16 +0000
commit3f5ec9fe02d2e985be599317ede82adaf78441ee (patch)
tree5e80cb01b4ecd5187e86f1d94ce4196c6b443a76 /gtk
parent2e49ab24f467361df37365da2ddb89bd2d6a0269 (diff)
downloadgtk+-3f5ec9fe02d2e985be599317ede82adaf78441ee.tar.gz
Test validity of path here. (shortcuts_insert_path): Don't check here.
2004-03-10 Morten Welinder <terra@gnome.org> * gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_add_shortcut_folder): Test validity of path here. (shortcuts_insert_path): Don't check here. (get_file_info): Barf if name-only fails.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkfilechooserdefault.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index ab6645f718..74a9feb884 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -822,8 +822,6 @@ get_file_info (GtkFileSystem *file_system, const GtkFilePath *path, gboolean nam
GtkFileFolder *parent_folder;
GtkFileInfo *info;
- info = NULL;
-
if (!gtk_file_system_get_parent (file_system, path, &parent_path, error))
return NULL;
@@ -836,11 +834,17 @@ get_file_info (GtkFileSystem *file_system, const GtkFilePath *path, gboolean nam
error);
gtk_file_path_free (parent_path);
- if (!parent_folder)
- return NULL;
-
- info = gtk_file_folder_get_info (parent_folder, path, error);
- g_object_unref (parent_folder);
+ if (parent_folder)
+ {
+ info = gtk_file_folder_get_info (parent_folder, path, error);
+ g_object_unref (parent_folder);
+ }
+ else
+ {
+ info = NULL;
+ /* Name-only should not fail. */
+ g_return_val_if_fail (!name_only, NULL);
+ }
return info;
}
@@ -872,17 +876,14 @@ shortcuts_insert_path (GtkFileChooserDefault *impl,
}
else
{
- /* Always check to make sure that the directory exists. */
- GtkFileInfo *info = get_file_info (impl->file_system, path, FALSE, error);
- if (info == NULL)
- return FALSE;
-
if (label)
label_copy = g_strdup (label);
else
- label_copy = g_strdup (gtk_file_info_get_display_name (info));
-
- gtk_file_info_free (info);
+ {
+ GtkFileInfo *info = get_file_info (impl->file_system, path, TRUE, error);
+ label_copy = g_strdup (gtk_file_info_get_display_name (info));
+ gtk_file_info_free (info);
+ }
data = gtk_file_path_copy (path);
pixbuf = gtk_file_system_render_icon (impl->file_system, path, GTK_WIDGET (impl),
@@ -3402,8 +3403,15 @@ gtk_file_chooser_default_add_shortcut_folder (GtkFileChooser *chooser,
{
GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
gboolean result;
+ GtkFileInfo *info;
int pos;
+ /* Test validity of path here. */
+ info = get_file_info (impl->file_system, path, FALSE, error);
+ if (!info)
+ return FALSE;
+ gtk_file_info_free (info);
+
pos = shortcuts_get_pos_for_shortcut_folder (impl, impl->num_shortcuts);
result = shortcuts_insert_path (impl, pos, FALSE, NULL, path, NULL, FALSE, error);