fix for emblem sidebar



Hi,

Here's a fix for #104169.  Ok to commit?

Thanks,
James
? nautilus_jwillcox_emblem_fix_v1.diff
? nautilus_jwillcox_schema_fix_v1.diff
? components/emblem/.nautilus-emblem-view.c.swp
? libnautilus-private/.nautilus-emblem-utils.c.swp
? libnautilus-private/apps_nautilus_preferences.schemas
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.5896
diff -u -r1.5896 ChangeLog
--- ChangeLog	30 Jul 2003 07:34:12 -0000	1.5896
+++ ChangeLog	1 Aug 2003 16:16:09 -0000
@@ -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 
Index: components/emblem/nautilus-emblem-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/components/emblem/nautilus-emblem-view.c,v
retrieving revision 1.6
diff -u -r1.6 nautilus-emblem-view.c
--- components/emblem/nautilus-emblem-view.c	5 Dec 2002 01:14:14 -0000	1.6
+++ components/emblem/nautilus-emblem-view.c	1 Aug 2003 16:16:09 -0000
@@ -106,6 +106,7 @@
 	GdkPixbuf *pixbuf;
 	char *uri;
 	char *name;
+	char *keyword;
 } Emblem;
 
 BONOBO_CLASS_BOILERPLATE (NautilusEmblemView, nautilus_emblem_view,
@@ -471,6 +472,11 @@
 		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 @@
 {
 	Emblem *emblem;
 	GSList *emblems;
-	char *keyword;
+	GSList *l;
 
 	switch (response) {
 	case GTK_RESPONSE_CANCEL:
@@ -613,18 +619,32 @@
 		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)) {
+				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);
Index: libnautilus-private/apps_nautilus_preferences.schemas.in
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/apps_nautilus_preferences.schemas.in,v
retrieving revision 1.8
diff -u -r1.8 apps_nautilus_preferences.schemas.in
--- libnautilus-private/apps_nautilus_preferences.schemas.in	5 Jul 2003 16:20:18 -0000	1.8
+++ libnautilus-private/apps_nautilus_preferences.schemas.in	1 Aug 2003 16:16:09 -0000
@@ -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>
Index: libnautilus-private/nautilus-emblem-utils.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-emblem-utils.c,v
retrieving revision 1.6
diff -u -r1.6 nautilus-emblem-utils.c
--- libnautilus-private/nautilus-emblem-utils.c	16 May 2003 18:32:14 -0000	1.6
+++ libnautilus-private/nautilus-emblem-utils.c	1 Aug 2003 16:16:09 -0000
@@ -188,31 +188,22 @@
 	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,8 +212,29 @@
 		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 ());
Index: libnautilus-private/nautilus-emblem-utils.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-emblem-utils.h,v
retrieving revision 1.2
diff -u -r1.2 nautilus-emblem-utils.h
--- libnautilus-private/nautilus-emblem-utils.h	21 Oct 2002 16:39:01 -0000	1.2
+++ libnautilus-private/nautilus-emblem-utils.h	1 Aug 2003 16:16:09 -0000
@@ -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,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]