diff options
author | Andy Hertzfeld <andy@src.gnome.org> | 2001-02-08 21:16:35 +0000 |
---|---|---|
committer | Andy Hertzfeld <andy@src.gnome.org> | 2001-02-08 21:16:35 +0000 |
commit | 13414e32b4a6d80a40f8b272cf510759151c89ed (patch) | |
tree | c428ca0c6d18a42fe74fbbd1d7fd1acfdf198964 | |
parent | 3e8345a80037b3f009c62ed8b704424aff320f50 (diff) | |
download | nautilus-13414e32b4a6d80a40f8b272cf510759151c89ed.tar.gz |
fixed bugs 6437 and 6438 by testing for a directory selected instead of a
* libnautilus-extensions/nautilus-gnome-extensions.c:
(icon_selected_callback), (nautilus_gnome_icon_selector_new):
fixed bugs 6437 and 6438 by testing for a directory selected
instead of a file in the icon selector, and putting up an error
dialog in that case instead of invoking the callback with the
directory path.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-gnome-extensions.c | 24 | ||||
-rw-r--r-- | libnautilus-private/nautilus-gnome-extensions.c | 24 |
3 files changed, 49 insertions, 8 deletions
@@ -1,3 +1,12 @@ +2001-02-08 Andy Hertzfeld <andy@eazel.com> + + * libnautilus-extensions/nautilus-gnome-extensions.c: + (icon_selected_callback), (nautilus_gnome_icon_selector_new): + fixed bugs 6437 and 6438 by testing for a directory selected + instead of a file in the icon selector, and putting up an error + dialog in that case instead of invoking the callback with the + directory path. + 2001-02-08 Pavel Cisler <pavel@eazel.com> Fix 6401 (Create Link yields "You cannot link a file to itself" diff --git a/libnautilus-extensions/nautilus-gnome-extensions.c b/libnautilus-extensions/nautilus-gnome-extensions.c index f8be31ad4..cb39245c7 100644 --- a/libnautilus-extensions/nautilus-gnome-extensions.c +++ b/libnautilus-extensions/nautilus-gnome-extensions.c @@ -34,6 +34,8 @@ #include <libart_lgpl/art_rgb.h> #include <libart_lgpl/art_rect.h> #include "nautilus-gdk-extensions.h" +#include "nautilus-stock-dialogs.h" +#include <libgnome/gnome-i18n.h> #include <libgnome/gnome-util.h> #include <libgnomeui/gnome-file-entry.h> #include <libgnomeui/gnome-icon-list.h> @@ -51,6 +53,7 @@ struct IconSelectionData { GtkWidget *icon_selection; GtkWidget *file_entry; + GtkWindow *owning_window; NautilusIconSelectionFunction selection_function; gpointer callback_data; }; @@ -618,15 +621,27 @@ icon_selected_callback (GtkWidget *button, IconSelectionData *selection_data) { const gchar *icon_path; GtkWidget *entry; + struct stat buf; gnome_icon_selection_stop_loading ( GNOME_ICON_SELECTION (selection_data->icon_selection)); entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (selection_data->file_entry)); icon_path = gtk_entry_get_text (GTK_ENTRY (entry)); - /* invoke the callback to inform it of the file path */ - selection_data->selection_function (icon_path, selection_data->callback_data); - + /* if a specific file wasn't selected, put up a dialog to tell the + * user to pick something, and leave the picker up + */ + stat (icon_path, &buf); + if (S_ISDIR (buf.st_mode)) { + nautilus_show_error_dialog (_("No image was selected. You must click on an image to select it."), + _("No selection made"), + selection_data->owning_window); + + } else { + /* invoke the callback to inform it of the file path */ + selection_data->selection_function (icon_path, selection_data->callback_data); + } + /* we have to get rid of the icon selection dialog, but we can't do it now, since the * file entry might still need it. Do it when the next idle rolls around */ @@ -718,7 +733,8 @@ nautilus_gnome_icon_selector_new (const char *title, selection_data = g_new0 (IconSelectionData, 1); selection_data->icon_selection = icon_selection; selection_data->file_entry = file_entry; - selection_data->selection_function = selected; + selection_data->owning_window = owner; + selection_data->selection_function = selected; selection_data->callback_data = callback_data; gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(dialog)->vbox), diff --git a/libnautilus-private/nautilus-gnome-extensions.c b/libnautilus-private/nautilus-gnome-extensions.c index f8be31ad4..cb39245c7 100644 --- a/libnautilus-private/nautilus-gnome-extensions.c +++ b/libnautilus-private/nautilus-gnome-extensions.c @@ -34,6 +34,8 @@ #include <libart_lgpl/art_rgb.h> #include <libart_lgpl/art_rect.h> #include "nautilus-gdk-extensions.h" +#include "nautilus-stock-dialogs.h" +#include <libgnome/gnome-i18n.h> #include <libgnome/gnome-util.h> #include <libgnomeui/gnome-file-entry.h> #include <libgnomeui/gnome-icon-list.h> @@ -51,6 +53,7 @@ struct IconSelectionData { GtkWidget *icon_selection; GtkWidget *file_entry; + GtkWindow *owning_window; NautilusIconSelectionFunction selection_function; gpointer callback_data; }; @@ -618,15 +621,27 @@ icon_selected_callback (GtkWidget *button, IconSelectionData *selection_data) { const gchar *icon_path; GtkWidget *entry; + struct stat buf; gnome_icon_selection_stop_loading ( GNOME_ICON_SELECTION (selection_data->icon_selection)); entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (selection_data->file_entry)); icon_path = gtk_entry_get_text (GTK_ENTRY (entry)); - /* invoke the callback to inform it of the file path */ - selection_data->selection_function (icon_path, selection_data->callback_data); - + /* if a specific file wasn't selected, put up a dialog to tell the + * user to pick something, and leave the picker up + */ + stat (icon_path, &buf); + if (S_ISDIR (buf.st_mode)) { + nautilus_show_error_dialog (_("No image was selected. You must click on an image to select it."), + _("No selection made"), + selection_data->owning_window); + + } else { + /* invoke the callback to inform it of the file path */ + selection_data->selection_function (icon_path, selection_data->callback_data); + } + /* we have to get rid of the icon selection dialog, but we can't do it now, since the * file entry might still need it. Do it when the next idle rolls around */ @@ -718,7 +733,8 @@ nautilus_gnome_icon_selector_new (const char *title, selection_data = g_new0 (IconSelectionData, 1); selection_data->icon_selection = icon_selection; selection_data->file_entry = file_entry; - selection_data->selection_function = selected; + selection_data->owning_window = owner; + selection_data->selection_function = selected; selection_data->callback_data = callback_data; gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(dialog)->vbox), |