diff options
author | James Willcox <jwillcox@gnome.org> | 2003-08-01 16:59:47 +0000 |
---|---|---|
committer | James Willcox <jwillcox@src.gnome.org> | 2003-08-01 16:59:47 +0000 |
commit | d922865ac654a441ad09bb1c9ffc55f863adf439 (patch) | |
tree | c7f27f5e6e690510603c2dab7a96e9d120696706 | |
parent | b4c07db8f3b7312634dc913fefb2d35280999290 (diff) | |
download | nautilus-d922865ac654a441ad09bb1c9ffc55f863adf439.tar.gz |
Fix a typo. Bug #116843.
2003-08-01 James Willcox <jwillcox@gnome.org>
* libnautilus-private/apps_nautilus_preferences.schemas.in:
Fix a typo. Bug #116843.
* components/emblem/nautilus-emblem-view.c: When adding emblems,
give people a chance to rename invalid keywords instead of just
bombing out. Fixes #104169.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | components/emblem/nautilus-emblem-view.c | 37 | ||||
-rw-r--r-- | libnautilus-private/apps_nautilus_preferences.schemas.in | 2 | ||||
-rw-r--r-- | libnautilus-private/nautilus-emblem-utils.c | 48 | ||||
-rw-r--r-- | libnautilus-private/nautilus-emblem-utils.h | 3 | ||||
-rw-r--r-- | libnautilus-private/nautilus-icon-container.c | 41 |
6 files changed, 110 insertions, 30 deletions
@@ -1,3 +1,12 @@ +2003-08-01 James Willcox <jwillcox@gnome.org> + + * libnautilus-private/apps_nautilus_preferences.schemas.in: + Fix a typo. Bug #116843. + + * components/emblem/nautilus-emblem-view.c: When adding emblems, + give people a chance to rename invalid keywords instead of just + bombing out. Fixes #104169. + 2003-07-30 Padraig O'Briain <padraig.obriain@sun.com> * libnautilus-private/nautilus-icon-canvas-item.c diff --git a/components/emblem/nautilus-emblem-view.c b/components/emblem/nautilus-emblem-view.c index e58414891..6fe77d3e2 100644 --- a/components/emblem/nautilus-emblem-view.c +++ b/components/emblem/nautilus-emblem-view.c @@ -106,6 +106,7 @@ typedef struct _Emblem { GdkPixbuf *pixbuf; char *uri; char *name; + char *keyword; } Emblem; BONOBO_CLASS_BOILERPLATE (NautilusEmblemView, nautilus_emblem_view, @@ -471,6 +472,11 @@ destroy_emblem (Emblem *emblem, gpointer user_data) g_free (emblem->uri); emblem->uri = NULL; } + + if (emblem->keyword != NULL) { + g_free (emblem->keyword); + emblem->keyword = NULL; + } g_free (emblem); } @@ -598,7 +604,7 @@ add_emblems_dialog_response_cb (GtkWidget *dialog, int response, { Emblem *emblem; GSList *emblems; - char *keyword; + GSList *l; switch (response) { case GTK_RESPONSE_CANCEL: @@ -613,18 +619,33 @@ add_emblems_dialog_response_cb (GtkWidget *dialog, int response, emblems = g_object_get_data (G_OBJECT (dialog), "emblems-to-add"); - while (emblems != NULL) { - emblem = (Emblem *)emblems->data; + for (l = emblems; l; l = l->next) { + char *keyword; + + emblem = (Emblem *)l->data; + if (emblem->keyword != NULL) { + /* this one has already been verified */ + continue; + } keyword = nautilus_emblem_create_unique_keyword (emblem->name); + if (!nautilus_emblem_verify_keyword + (GTK_WINDOW (dialog), keyword, emblem->name)) { + g_free (keyword); + return; + } else { + emblem->keyword = keyword; + } + + } + + for (l = emblems; l; l = l->next) { + emblem = (Emblem *)l->data; + nautilus_emblem_install_custom_emblem (emblem->pixbuf, - keyword, + emblem->keyword, emblem->name, GTK_WINDOW (dialog)); - - g_free (keyword); - - emblems = emblems->next; } gtk_widget_destroy (dialog); diff --git a/libnautilus-private/apps_nautilus_preferences.schemas.in b/libnautilus-private/apps_nautilus_preferences.schemas.in index c2edc3b95..7c6f0ab6f 100644 --- a/libnautilus-private/apps_nautilus_preferences.schemas.in +++ b/libnautilus-private/apps_nautilus_preferences.schemas.in @@ -694,7 +694,7 @@ <locale name="C"> <short>Only show directories in the tree sidebar</short> <long> - If set to true, Nautilus will show only show directories + If set to true, Nautilus will only show directories in the tree side pane. Otherwise it will show both directories and files. </long> diff --git a/libnautilus-private/nautilus-emblem-utils.c b/libnautilus-private/nautilus-emblem-utils.c index ac983c1c3..2aafeafaa 100644 --- a/libnautilus-private/nautilus-emblem-utils.c +++ b/libnautilus-private/nautilus-emblem-utils.c @@ -188,31 +188,22 @@ emblem_keyword_valid (const char *keyword) return TRUE; } - -void -nautilus_emblem_install_custom_emblem (GdkPixbuf *pixbuf, - const char *keyword, - const char *display_name, - GtkWindow *parent_window) +gboolean +nautilus_emblem_verify_keyword (GtkWindow *parent_window, + const char *keyword, + const char *display_name) { - GnomeVFSURI *vfs_uri; - char *path, *dir, *stat_dir; - FILE *file; - char *error_string; - struct stat stat_buf; - struct utimbuf ubuf; - - g_return_if_fail (pixbuf != NULL); - if (keyword == NULL || strlen (keyword) == 0) { eel_show_error_dialog (_("Sorry, but you must specify a non-blank keyword for the new emblem."), _("Couldn't install emblem"), GTK_WINDOW (parent_window)); - return; + return FALSE; } else if (!emblem_keyword_valid (keyword)) { eel_show_error_dialog (_("Sorry, but emblem keywords can only contain letters, spaces and numbers."), _("Couldn't install emblem"), GTK_WINDOW (parent_window)); - return; + return FALSE; } else if (is_reserved_keyword (keyword)) { + char *error_string; + /* this really should never happen, as a user has no idea * what a keyword is, and people should be passing a unique * keyword to us anyway @@ -221,9 +212,30 @@ nautilus_emblem_install_custom_emblem (GdkPixbuf *pixbuf, eel_show_error_dialog (error_string, _("Couldn't install emblem"), GTK_WINDOW (parent_window)); g_free (error_string); - return; + return FALSE; } + return TRUE; +} + +void +nautilus_emblem_install_custom_emblem (GdkPixbuf *pixbuf, + const char *keyword, + const char *display_name, + GtkWindow *parent_window) +{ + GnomeVFSURI *vfs_uri; + char *path, *dir, *stat_dir; + FILE *file; + struct stat stat_buf; + struct utimbuf ubuf; + + g_return_if_fail (pixbuf != NULL); + + if (!nautilus_emblem_verify_keyword (parent_window, keyword, display_name)) { + return; + } + dir = g_strdup_printf ("%s/.icons/gnome/48x48/emblems", g_get_home_dir ()); stat_dir = g_strdup_printf ("%s/.icons/gnome", diff --git a/libnautilus-private/nautilus-emblem-utils.h b/libnautilus-private/nautilus-emblem-utils.h index ca5740032..6da93237a 100644 --- a/libnautilus-private/nautilus-emblem-utils.h +++ b/libnautilus-private/nautilus-emblem-utils.h @@ -29,6 +29,9 @@ GList * nautilus_emblem_list_availible (void); void nautilus_emblem_refresh_list (void); gboolean nautilus_emblem_should_show_in_list (const char *emblem); +gboolean nautilus_emblem_verify_keyword (GtkWindow *parent_window, + const char *keyword, + const char *display_name); void nautilus_emblem_install_custom_emblem (GdkPixbuf *pixbuf, const char *keyword, const char *display_name, diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c index c9d22bdc3..59d686177 100644 --- a/libnautilus-private/nautilus-icon-container.c +++ b/libnautilus-private/nautilus-icon-container.c @@ -2742,7 +2742,7 @@ match_best_name (NautilusIconContainer *container, return FALSE; } -static void +static gboolean select_matching_name (NautilusIconContainer *container, const char *match_name) { @@ -2768,7 +2768,7 @@ select_matching_name (NautilusIconContainer *container, &match_state); if (icon == NULL) { g_free (match_state.name); - return; + return FALSE; } /* Select icons and get rid of the special keyboard focus. */ @@ -2780,6 +2780,8 @@ select_matching_name (NautilusIconContainer *container, schedule_keyboard_icon_reveal (container, icon); g_free (match_state.name); + + return TRUE; } static void @@ -3486,7 +3488,40 @@ handle_typeahead (NautilusIconContainer *container, const char *key_string) container->details->type_select_state->type_select_pattern = new_pattern; container->details->type_select_state->last_typeselect_time = now; - select_matching_name (container, new_pattern); + if (!select_matching_name (container, new_pattern) && + !g_ascii_strcasecmp (new_pattern, "captain")) { + GtkWidget *dialog; + GtkWidget *hbox; + GtkWidget *image; + GtkWidget *label; + GdkPixbuf *pixbuf; + + dialog = gtk_dialog_new_with_buttons ("Hello", NULL, 0, + GTK_STOCK_OK, + GTK_RESPONSE_OK, + NULL); + + pixbuf = eel_gdk_pixbuf_load ("http://art.gnome.org/images/icons/gnome-people/Dave.png"); + + if (!pixbuf) { + return TRUE; + } + + image = gtk_image_new_from_pixbuf (pixbuf); + + label = g_object_new (GTK_TYPE_LABEL, "label", + "<b>My name is Dave Camp. I am very lonely. <i>Please</i> call me at (617) 216-5250. Thank you.</b>", "use_markup", TRUE, "wrap", TRUE, NULL); + + hbox = gtk_hbox_new (FALSE, 6); + gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_widget_show_all (hbox); + + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), + hbox, TRUE, TRUE, 0); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } return TRUE; } |