nautilus r14555 - in trunk: . libnautilus-private src src/file-manager test



Author: cneumair
Date: Mon Sep  1 10:24:12 2008
New Revision: 14555
URL: http://svn.gnome.org/viewvc/nautilus?rev=14555&view=rev

Log:
2008-09-01  Christian Neumair  <cneumair gnome org>

	* libnautilus-private/nautilus-customization-data.c
	(format_name_for_display), (load_name_map_hash_table):
	* src/file-manager/fm-directory-view.c
	(add_template_to_templates_menus):
	* src/nautilus-property-browser.c
	(nautilus_property_browser_drag_data_get),
	(make_properties_from_directories):
	* test/test-nautilus-wrap-table.c (main):
	Strip extensions using eel_filename_strip_extension(). Fixes #309510.
	Thanks to Paolo Borelli <pborelli katamail com> and Jared Moore
	<jaredm gmx com>.


Modified:
   trunk/ChangeLog
   trunk/libnautilus-private/nautilus-customization-data.c
   trunk/src/file-manager/fm-directory-view.c
   trunk/src/nautilus-property-browser.c
   trunk/test/test-nautilus-wrap-table.c

Modified: trunk/libnautilus-private/nautilus-customization-data.c
==============================================================================
--- trunk/libnautilus-private/nautilus-customization-data.c	(original)
+++ trunk/libnautilus-private/nautilus-customization-data.c	Mon Sep  1 10:24:12 2008
@@ -35,6 +35,7 @@
 #include <eel/eel-gdk-pixbuf-extensions.h>
 #include <eel/eel-glib-extensions.h>
 #include <eel/eel-gtk-extensions.h>
+#include <eel/eel-vfs-extensions.h>
 #include <eel/eel-string.h>
 #include <eel/eel-xml-extensions.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
@@ -77,7 +78,6 @@
 static char *            get_file_path_for_mode              (const NautilusCustomizationData *data,
 							      const char *file_name);
 static char*             format_name_for_display             (NautilusCustomizationData *data, const char *name);
-static char*             strip_extension                     (const char* string_to_strip);
 static void		 load_name_map_hash_table	     (NautilusCustomizationData *data);
 
 
@@ -412,7 +412,7 @@
 
 	/* map file names to display names using the mappings defined in the hash table */
 	
-	formatted_str = strip_extension (name);
+	formatted_str = eel_filename_strip_extension (name);
 	if (data->name_map_hash != NULL) {
 		mapped_name = g_hash_table_lookup (data->name_map_hash, formatted_str);
 		if (mapped_name) {
@@ -467,18 +467,3 @@
 		}		
 	}	
 }
-
-/* utility routine to strip the extension from the passed in string */
-static char*
-strip_extension (const char* string_to_strip)
-{
-	char *result_str, *temp_str;
-	if (string_to_strip == NULL)
-		return NULL;
-	
-	result_str = g_strdup(string_to_strip);
-	temp_str = strrchr(result_str, '.');
-	if (temp_str)
-		*temp_str = '\0';
-	return result_str;
-}

Modified: trunk/src/file-manager/fm-directory-view.c
==============================================================================
--- trunk/src/file-manager/fm-directory-view.c	(original)
+++ trunk/src/file-manager/fm-directory-view.c	Mon Sep  1 10:24:12 2008
@@ -5251,25 +5251,21 @@
 				 const char *menu_path,
 				 const char *popup_bg_path)
 {
-	char *tip, *uri, *name;
-	char *dot, *escaped_label;
+	char *tmp, *tip, *uri, *name;
+	char *escaped_label;
 	GdkPixbuf *pixbuf;
 	char *action_name;
 	CreateTemplateParameters *parameters;
 	GtkUIManager *ui_manager;
 	GtkAction *action;
 
+	tmp = nautilus_file_get_display_name (file);
+	name = eel_filename_strip_extension (tmp);
+	g_free (tmp);
 
-	name = nautilus_file_get_display_name (file);
 	uri = nautilus_file_get_uri (file);
 	tip = g_strdup_printf (_("Create Document from template \"%s\""), name);
 
-	/* Remove extension */
-	dot = strrchr (name, '.');
-	if (dot != NULL) {
-		*dot = 0;
-	}
-
 	action_name = escape_action_name (uri, "template_");
 	escaped_label = eel_str_double_underscores (name);
 	

Modified: trunk/src/nautilus-property-browser.c
==============================================================================
--- trunk/src/nautilus-property-browser.c	(original)
+++ trunk/src/nautilus-property-browser.c	Mon Sep  1 10:24:12 2008
@@ -42,6 +42,7 @@
 #include <eel/eel-labeled-image.h>
 #include <eel/eel-stock-dialogs.h>
 #include <eel/eel-string.h>
+#include <eel/eel-vfs-extensions.h>
 #include <eel/eel-xml-extensions.h>
 #include <librsvg/rsvg.h>
 #include <libxml/parser.h>
@@ -165,7 +166,6 @@
 								 NautilusPropertyBrowser       *property_browser);
 
 /* misc utilities */
-static char *   strip_extension                                 (const char                    *string_to_strip);
 static void     element_clicked_callback                        (GtkWidget                     *image_table,
 								 GtkWidget                     *child,
 								 const EelImageTableEvent *event,
@@ -605,7 +605,7 @@
 		is_reset = FALSE;
 		if (strcmp (property_browser->details->drag_type,
 			    "property/keyword") == 0) {
-			char* keyword_str = strip_extension(property_browser->details->dragged_file);
+			char *keyword_str = eel_filename_strip_extension(property_browser->details->dragged_file);
 		        gtk_selection_data_set(selection_data, selection_data->target, 8, keyword_str, strlen(keyword_str));
 			g_free(keyword_str);
 			return;	
@@ -1609,22 +1609,6 @@
 	}
 }
 
-
-/* utility routine to strip the extension from the passed in string */
-static char*
-strip_extension (const char* string_to_strip)
-{
-	char *result_str, *temp_str;
-	if (string_to_strip == NULL)
-		return NULL;
-	
-	result_str = g_strdup(string_to_strip);
-	temp_str = strrchr(result_str, '.');
-	if (temp_str)
-		*temp_str = '\0';
-	return result_str;
-}
-
 static void
 labeled_image_configure (EelLabeledImage *labeled_image)
 {
@@ -1667,7 +1651,6 @@
 	GList *icons, *l;
 	char *icon_name;
 	char *keyword;
-	char *extension;
 	GtkWidget *property_image;
 	GtkWidget *blank;
 	guint num_images;
@@ -1706,11 +1689,7 @@
 			property_image = labeled_image_new (object_label, object_pixbuf, object_name, PANGO_SCALE_LARGE);
 			eel_labeled_image_set_fixed_image_height (EEL_LABELED_IMAGE (property_image), MAX_EMBLEM_HEIGHT);
 
-			keyword = g_strdup (object_name);
-			extension = strchr (keyword, '.');
-			if (extension) {
-				*extension = '\0';
-			}
+			keyword = eel_filename_strip_extension (object_name);
 			property_browser->details->keywords = g_list_prepend (property_browser->details->keywords,
 									      keyword);
 

Modified: trunk/test/test-nautilus-wrap-table.c
==============================================================================
--- trunk/test/test-nautilus-wrap-table.c	(original)
+++ trunk/test/test-nautilus-wrap-table.c	Mon Sep  1 10:24:12 2008
@@ -2,6 +2,7 @@
 
 #include <eel/eel-wrap-table.h>
 #include <eel/eel-labeled-image.h>
+#include <eel/eel-vfs-extensions.h>
 #include <libnautilus-private/nautilus-customization-data.h>
 #include <libnautilus-private/nautilus-icon-info.h>
 
@@ -11,7 +12,7 @@
 	NautilusCustomizationData *customization_data;
 	GtkWidget *window;
 	GtkWidget *emblems_table, *button, *scroller;
-	char *emblem_name, *dot_pos;
+	char *emblem_name, *stripped_name;
 	GdkPixbuf *pixbuf;
 	char *label;
 
@@ -62,19 +63,16 @@
 									 &pixbuf,
 									 &label) == GNOME_VFS_OK) {	
 
-		/* strip the suffix, if any */
-		dot_pos = strrchr(emblem_name, '.');
-		if (dot_pos) {
-			*dot_pos = '\0';
-		}
+		stripped_name = eel_filename_strip_extension (emblem_name);
+		g_free (emblem_name);
 		
-		if (strcmp (emblem_name, "erase") == 0) {
+		if (strcmp (stripped_name, "erase") == 0) {
 			g_object_unref (pixbuf);
 			g_free (label);
-			g_free (emblem_name);
+			g_free (stripped_name);
 			continue;
 		}
-		
+
 		button = eel_labeled_image_check_button_new (label, pixbuf);
 		g_free (label);
 		g_object_unref (pixbuf);
@@ -82,7 +80,7 @@
 		/* Attach parameters and signal handler. */
 		g_object_set_data_full (G_OBJECT (button),
 					"nautilus_property_name",
-					emblem_name,
+					stripped_name,
 					(GDestroyNotify) g_free);
 				     
 		gtk_container_add (GTK_CONTAINER (emblems_table), button);



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