diff --git a/ChangeLog b/ChangeLog index 729569c74..1c19ef772 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,46 @@ +2001-02-13 Arik Devens + + reviewed by: Maciej Stachowiak + + Fixed bug 5837, 'Home Location' preference should accept ~. + Fixed bug 6463, GNOME-VFS spews critical errors as you type an + incomplete path in the location bar. + Fixed bug 6478, nautilus crashes on ~somedir/ if that dir + doesn't exist. + Fixed bug 6506, Entering "~" in Add New Background Dialogue box + causes Nautilus to crash. + + * libnautilus-extensions/nautilus-entry.c: + (nautilus_entry_initialize), (nautilus_entry_key_press): Added + setting of expand_tilde to FALSE. Added a slash case so that ~/ + gets expanded to $(HOMEDIR). + * libnautilus-extensions/nautilus-entry.h: Added gboolean + expand_tilde to the NautilusEntry struct. + * libnautilus-extensions/nautilus-file-utilities.c: + (nautilus_make_uri_from_input): Added falling into default case + on ~'s if the dir doesn't exist so they end up at http://'s. + * libnautilus-extensions/nautilus-preferences-item.c: + (preferences_item_create_editable_string): Added special case + setting of expand_tilde to TRUE on the home dir preference box. + As well as a FIXME saying this should be dealt with later on. + * libnautilus-extensions/nautilus-text-caption.c: + (nautilus_text_caption_initialize), (entry_changed_callback), + (nautilus_text_caption_set_editable), + (nautilus_text_caption_set_expand_tilde): Changed + NautilusTextCaption to use NautilusEntry instead of GtkEntry. + Added function to set expand tilde on NautilusText Caption. + Updated set_editable to work with NautilusEntry. + * libnautilus-extensions/nautilus-text-caption.h: Added + nautilus_text_caption_set_expand_tilde function prototype. + * src/nautilus-location-bar.c: (try_to_expand_path), + (nautilus_location_bar_initialize): Added expanding of ~'s at + the beginning of the location to full path. Added setting of + expand_tilde to TRUE. + * src/nautilus-property-browser.c: (add_pattern_to_browser): + Added if statement to not attempt to do anything if the dir + chosen uses ~ do to gtk brokenness. Also added error dialog + that explains what happened to the user. + 2001-02-13 Andy Hertzfeld * src/nautilus-theme-selector.c: diff --git a/libnautilus-extensions/nautilus-entry.c b/libnautilus-extensions/nautilus-entry.c index 97e16d3b6..b7c227be7 100644 --- a/libnautilus-extensions/nautilus-entry.c +++ b/libnautilus-extensions/nautilus-entry.c @@ -124,6 +124,7 @@ nautilus_entry_initialize (NautilusEntry *entry) entry->user_edit = TRUE; entry->special_tab_handling = FALSE; entry->cursor_obscured = FALSE; + entry->expand_tilde = FALSE; /* Allow pointer motion events so we can expose an obscured cursor if necessary */ gtk_widget_set_events (widget, gtk_widget_get_events (widget) | GDK_POINTER_MOTION_MASK); @@ -159,7 +160,6 @@ nautilus_entry_destroy (GtkObject *object) NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object)); } - static void obscure_cursor (NautilusEntry *entry) { @@ -210,6 +210,14 @@ nautilus_entry_key_press (GtkWidget *widget, GdkEventKey *event) */ gtk_widget_activate (widget); return TRUE; + + case GDK_slash: + if (entry->expand_tilde) { + if (g_strcasecmp (gtk_entry_get_text (GTK_ENTRY (entry)), "~") == 0) { + gtk_entry_set_text (GTK_ENTRY (entry), g_get_home_dir ()); + } + } + break; default: break; diff --git a/libnautilus-extensions/nautilus-entry.h b/libnautilus-extensions/nautilus-entry.h index d9fa23eb4..03d572a4d 100644 --- a/libnautilus-extensions/nautilus-entry.h +++ b/libnautilus-extensions/nautilus-entry.h @@ -52,6 +52,7 @@ struct NautilusEntry { gboolean user_edit; gboolean special_tab_handling; gboolean cursor_obscured; + gboolean expand_tilde; }; struct NautilusEntryClass { diff --git a/libnautilus-extensions/nautilus-file-utilities.c b/libnautilus-extensions/nautilus-file-utilities.c index 2ac9caefe..98d2da8d6 100644 --- a/libnautilus-extensions/nautilus-file-utilities.c +++ b/libnautilus-extensions/nautilus-file-utilities.c @@ -154,9 +154,14 @@ nautilus_make_uri_from_input (const char *location) break; case '~': path = gnome_vfs_expand_initial_tilde (stripped); - uri = gnome_vfs_get_uri_from_local_path (path); - g_free (path); - break; + /* deliberately falling into default case on fail */ + if (*path == '/') { + uri = gnome_vfs_get_uri_from_local_path (path); + g_free (path); + break; + } + g_free (path); + /* don't insert break here, read above comment */ default: if (has_valid_scheme (stripped)) { uri = g_strdup (stripped); diff --git a/libnautilus-extensions/nautilus-preferences-item.c b/libnautilus-extensions/nautilus-preferences-item.c index 97d1a1104..d03425541 100644 --- a/libnautilus-extensions/nautilus-preferences-item.c +++ b/libnautilus-extensions/nautilus-preferences-item.c @@ -431,6 +431,13 @@ preferences_item_create_editable_string (NautilusPreferencesItem *item, item->details->child = nautilus_text_caption_new (); + /* FIXME This is a special case for the home uri preference, + in the future this should be generalized. */ + if (g_strcasecmp (preference_name, "preferences/home_uri") == 0) + { + nautilus_text_caption_set_expand_tilde (NAUTILUS_TEXT_CAPTION (item->details->child), TRUE); + } + nautilus_caption_set_title_label (NAUTILUS_CAPTION (item->details->child), description); g_free (description); diff --git a/libnautilus-extensions/nautilus-text-caption.c b/libnautilus-extensions/nautilus-text-caption.c index 29e6b1aa1..6c8409606 100644 --- a/libnautilus-extensions/nautilus-text-caption.c +++ b/libnautilus-extensions/nautilus-text-caption.c @@ -27,6 +27,7 @@ #include "nautilus-text-caption.h" #include "nautilus-gtk-macros.h" #include "nautilus-glib-extensions.h" +#include "nautilus-entry.h" #include #include @@ -99,7 +100,7 @@ nautilus_text_caption_initialize (NautilusTextCaption *text_caption) gtk_box_set_homogeneous (GTK_BOX (text_caption), FALSE); gtk_box_set_spacing (GTK_BOX (text_caption), TEXT_CAPTION_SPACING); - text_caption->detail->text = gtk_entry_new (); + text_caption->detail->text = nautilus_entry_new (); gtk_entry_set_editable (GTK_ENTRY (text_caption->detail->text), TRUE); @@ -199,3 +200,12 @@ nautilus_text_caption_set_editable (NautilusTextCaption *text_caption, gtk_entry_set_editable (GTK_ENTRY (text_caption->detail->text), editable); } + +void +nautilus_text_caption_set_expand_tilde (NautilusTextCaption *text_caption, + gboolean expand_tilde) +{ + g_return_if_fail (NAUTILUS_IS_TEXT_CAPTION (text_caption)); + + NAUTILUS_ENTRY (text_caption->detail->text)->expand_tilde = TRUE; +} diff --git a/libnautilus-extensions/nautilus-text-caption.h b/libnautilus-extensions/nautilus-text-caption.h index 762c70111..d157e041e 100644 --- a/libnautilus-extensions/nautilus-text-caption.h +++ b/libnautilus-extensions/nautilus-text-caption.h @@ -71,6 +71,9 @@ void nautilus_text_caption_set_text (NautilusTextCaption *text_caption, void nautilus_text_caption_set_editable (NautilusTextCaption *text_caption, gboolean editable); +void nautilus_text_caption_set_expand_tilde (NautilusTextCaption *text_caption, + gboolean expand_tilde); + END_GNOME_DECLS #endif /* NAUTILUS_TEXT_CAPTION_H */ diff --git a/libnautilus-private/nautilus-entry.c b/libnautilus-private/nautilus-entry.c index 97e16d3b6..b7c227be7 100644 --- a/libnautilus-private/nautilus-entry.c +++ b/libnautilus-private/nautilus-entry.c @@ -124,6 +124,7 @@ nautilus_entry_initialize (NautilusEntry *entry) entry->user_edit = TRUE; entry->special_tab_handling = FALSE; entry->cursor_obscured = FALSE; + entry->expand_tilde = FALSE; /* Allow pointer motion events so we can expose an obscured cursor if necessary */ gtk_widget_set_events (widget, gtk_widget_get_events (widget) | GDK_POINTER_MOTION_MASK); @@ -159,7 +160,6 @@ nautilus_entry_destroy (GtkObject *object) NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object)); } - static void obscure_cursor (NautilusEntry *entry) { @@ -210,6 +210,14 @@ nautilus_entry_key_press (GtkWidget *widget, GdkEventKey *event) */ gtk_widget_activate (widget); return TRUE; + + case GDK_slash: + if (entry->expand_tilde) { + if (g_strcasecmp (gtk_entry_get_text (GTK_ENTRY (entry)), "~") == 0) { + gtk_entry_set_text (GTK_ENTRY (entry), g_get_home_dir ()); + } + } + break; default: break; diff --git a/libnautilus-private/nautilus-entry.h b/libnautilus-private/nautilus-entry.h index d9fa23eb4..03d572a4d 100644 --- a/libnautilus-private/nautilus-entry.h +++ b/libnautilus-private/nautilus-entry.h @@ -52,6 +52,7 @@ struct NautilusEntry { gboolean user_edit; gboolean special_tab_handling; gboolean cursor_obscured; + gboolean expand_tilde; }; struct NautilusEntryClass { diff --git a/libnautilus-private/nautilus-file-utilities.c b/libnautilus-private/nautilus-file-utilities.c index 2ac9caefe..98d2da8d6 100644 --- a/libnautilus-private/nautilus-file-utilities.c +++ b/libnautilus-private/nautilus-file-utilities.c @@ -154,9 +154,14 @@ nautilus_make_uri_from_input (const char *location) break; case '~': path = gnome_vfs_expand_initial_tilde (stripped); - uri = gnome_vfs_get_uri_from_local_path (path); - g_free (path); - break; + /* deliberately falling into default case on fail */ + if (*path == '/') { + uri = gnome_vfs_get_uri_from_local_path (path); + g_free (path); + break; + } + g_free (path); + /* don't insert break here, read above comment */ default: if (has_valid_scheme (stripped)) { uri = g_strdup (stripped); diff --git a/libnautilus-private/nautilus-preferences-item.c b/libnautilus-private/nautilus-preferences-item.c index 97d1a1104..d03425541 100644 --- a/libnautilus-private/nautilus-preferences-item.c +++ b/libnautilus-private/nautilus-preferences-item.c @@ -431,6 +431,13 @@ preferences_item_create_editable_string (NautilusPreferencesItem *item, item->details->child = nautilus_text_caption_new (); + /* FIXME This is a special case for the home uri preference, + in the future this should be generalized. */ + if (g_strcasecmp (preference_name, "preferences/home_uri") == 0) + { + nautilus_text_caption_set_expand_tilde (NAUTILUS_TEXT_CAPTION (item->details->child), TRUE); + } + nautilus_caption_set_title_label (NAUTILUS_CAPTION (item->details->child), description); g_free (description); diff --git a/libnautilus-private/nautilus-text-caption.c b/libnautilus-private/nautilus-text-caption.c index 29e6b1aa1..6c8409606 100644 --- a/libnautilus-private/nautilus-text-caption.c +++ b/libnautilus-private/nautilus-text-caption.c @@ -27,6 +27,7 @@ #include "nautilus-text-caption.h" #include "nautilus-gtk-macros.h" #include "nautilus-glib-extensions.h" +#include "nautilus-entry.h" #include #include @@ -99,7 +100,7 @@ nautilus_text_caption_initialize (NautilusTextCaption *text_caption) gtk_box_set_homogeneous (GTK_BOX (text_caption), FALSE); gtk_box_set_spacing (GTK_BOX (text_caption), TEXT_CAPTION_SPACING); - text_caption->detail->text = gtk_entry_new (); + text_caption->detail->text = nautilus_entry_new (); gtk_entry_set_editable (GTK_ENTRY (text_caption->detail->text), TRUE); @@ -199,3 +200,12 @@ nautilus_text_caption_set_editable (NautilusTextCaption *text_caption, gtk_entry_set_editable (GTK_ENTRY (text_caption->detail->text), editable); } + +void +nautilus_text_caption_set_expand_tilde (NautilusTextCaption *text_caption, + gboolean expand_tilde) +{ + g_return_if_fail (NAUTILUS_IS_TEXT_CAPTION (text_caption)); + + NAUTILUS_ENTRY (text_caption->detail->text)->expand_tilde = TRUE; +} diff --git a/libnautilus-private/nautilus-text-caption.h b/libnautilus-private/nautilus-text-caption.h index 762c70111..d157e041e 100644 --- a/libnautilus-private/nautilus-text-caption.h +++ b/libnautilus-private/nautilus-text-caption.h @@ -71,6 +71,9 @@ void nautilus_text_caption_set_text (NautilusTextCaption *text_caption, void nautilus_text_caption_set_editable (NautilusTextCaption *text_caption, gboolean editable); +void nautilus_text_caption_set_expand_tilde (NautilusTextCaption *text_caption, + gboolean expand_tilde); + END_GNOME_DECLS #endif /* NAUTILUS_TEXT_CAPTION_H */ diff --git a/src/nautilus-location-bar.c b/src/nautilus-location-bar.c index 9a70f8bdf..85d8e10e3 100644 --- a/src/nautilus-location-bar.c +++ b/src/nautilus-location-bar.c @@ -1,3 +1,4 @@ + /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ /* @@ -305,7 +306,8 @@ try_to_expand_path (NautilusLocationBar *bar) char *dir_name; char *expand_text; char *expand_name; - + char *tilde_expand_name; + editable = GTK_EDITABLE (bar->details->entry); user_location = gtk_editable_get_chars (editable, 0, -1); bar->details->idle_id = 0; @@ -339,7 +341,7 @@ try_to_expand_path (NautilusLocationBar *bar) g_free (current_path); return FALSE; } - + base_length = strlen (base_name); dir_name = gnome_vfs_uri_extract_dirname (uri); @@ -372,11 +374,17 @@ try_to_expand_path (NautilusLocationBar *bar) /* if we've got something, add it to the entry */ if (expand_text && !nautilus_str_has_suffix (current_path, expand_text)) { - gtk_entry_append_text (GTK_ENTRY (editable), expand_text + base_length); - gtk_entry_select_region (GTK_ENTRY (editable), current_path_length - offset, + gtk_entry_append_text (GTK_ENTRY (editable), expand_text + base_length); + gtk_entry_select_region (GTK_ENTRY (editable), current_path_length - offset, current_path_length + strlen (expand_text) - base_length - offset); g_free (expand_text); } + + tilde_expand_name = gtk_entry_get_text (GTK_ENTRY (editable)); + if (*tilde_expand_name == '~') { + gtk_entry_set_text (GTK_ENTRY (editable), gnome_vfs_expand_initial_tilde (tilde_expand_name)); + } + g_free (tilde_expand_name); g_free (dir_name); g_free (base_name); @@ -540,6 +548,7 @@ nautilus_location_bar_initialize (NautilusLocationBar *bar) entry = nautilus_entry_new (); NAUTILUS_ENTRY (entry)->special_tab_handling = TRUE; + NAUTILUS_ENTRY (entry)->expand_tilde = TRUE; gtk_signal_connect_object (GTK_OBJECT (entry), "activate", nautilus_navigation_bar_location_changed, GTK_OBJECT (bar)); diff --git a/src/nautilus-property-browser.c b/src/nautilus-property-browser.c index 734f79e8d..3b22d9fe8 100644 --- a/src/nautilus-property-browser.c +++ b/src/nautilus-property-browser.c @@ -1031,52 +1031,61 @@ add_pattern_to_browser (const char *path_name, gpointer *data) NautilusPropertyBrowser *property_browser = NAUTILUS_PROPERTY_BROWSER(data); - /* fetch the mime type and make sure that the file is an image */ - path_uri = gnome_vfs_get_uri_from_local_path (path_name); + /* FIXME this is not a problem in nautilus but rather in the + gtk widget that selects the tiles. that would have to be fixed to + support tilde's. at the moment this is the best we can do. */ + if (*path_name != '~') { + /* fetch the mime type and make sure that the file is an image */ + path_uri = gnome_vfs_get_uri_from_local_path (path_name); - /* don't allow the user to change the reset image */ - basename = nautilus_uri_get_basename (path_uri); - if (basename && nautilus_strcmp (basename, RESET_IMAGE_NAME) == 0) { - nautilus_show_error_dialog (_("Sorry, but you can't replace the reset image."), _("Not an Image"), NULL); - g_free (path_uri); - g_free (basename); - return; - } + /* don't allow the user to change the reset image */ + basename = nautilus_uri_get_basename (path_uri); + if (basename && nautilus_strcmp (basename, RESET_IMAGE_NAME) == 0) { + nautilus_show_error_dialog (_("Sorry, but you can't replace the reset image."), _("Not an Image"), NULL); + g_free (path_uri); + g_free (basename); + return; + } - g_free(path_uri); - g_free (basename); - - user_directory = nautilus_get_user_directory (); + g_free (path_uri); + g_free (basename); + + user_directory = nautilus_get_user_directory (); + + /* copy the image file to the patterns directory */ + directory_path = nautilus_make_path (user_directory, property_browser->details->category); + g_free (user_directory); + source_file_name = strrchr (path_name, '/'); + destination_name = nautilus_make_path (directory_path, source_file_name + 1); - /* copy the image file to the patterns directory */ - directory_path = nautilus_make_path (user_directory, property_browser->details->category); - g_free (user_directory); - source_file_name = strrchr (path_name, '/'); - destination_name = nautilus_make_path (directory_path, source_file_name + 1); - - /* make the directory if it doesn't exist */ - if (!g_file_exists(directory_path)) { - directory_uri = gnome_vfs_get_uri_from_local_path (directory_path); - gnome_vfs_make_directory (directory_uri, - GNOME_VFS_PERM_USER_ALL - | GNOME_VFS_PERM_GROUP_ALL - | GNOME_VFS_PERM_OTHER_READ); - g_free (directory_uri); - } - - g_free(directory_path); - - result = nautilus_copy_uri_simple (path_name, destination_name); - if (result != GNOME_VFS_OK) { - char *message = g_strdup_printf (_("Sorry, but the pattern %s couldn't be installed."), path_name); + /* make the directory if it doesn't exist */ + if (!g_file_exists(directory_path)) { + directory_uri = gnome_vfs_get_uri_from_local_path (directory_path); + gnome_vfs_make_directory (directory_uri, + GNOME_VFS_PERM_USER_ALL + | GNOME_VFS_PERM_GROUP_ALL + | GNOME_VFS_PERM_OTHER_READ); + g_free (directory_uri); + } + + g_free (directory_path); + + result = nautilus_copy_uri_simple (path_name, destination_name); + if (result != GNOME_VFS_OK) { + char *message = g_strdup_printf (_("Sorry, but the pattern %s couldn't be installed."), path_name); + nautilus_show_error_dialog (message, _("Couldn't install pattern"), GTK_WINDOW (property_browser)); + g_free (message); + } + + g_free (destination_name); + + /* update the property browser's contents to show the new one */ + nautilus_property_browser_update_contents (property_browser); + } else { + char *message = g_strdup_printf (_("Sorry, but ~ as a directory is not currently supported.\n Please Type the full path.")); nautilus_show_error_dialog (message, _("Couldn't install pattern"), GTK_WINDOW (property_browser)); g_free (message); } - - g_free(destination_name); - - /* update the property browser's contents to show the new one */ - nautilus_property_browser_update_contents(property_browser); } /* here's where we initiate adding a new pattern by putting up a file selector */