diff --git a/ChangeLog b/ChangeLog index d7249e38a..f3b23aef1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2008-09-01 Christian Neumair + + * 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 and Jared Moore + . + 2008-09-01 Christian Neumair * configure.in: diff --git a/libnautilus-private/nautilus-customization-data.c b/libnautilus-private/nautilus-customization-data.c index 65c45f790..c6ebcc710 100644 --- a/libnautilus-private/nautilus-customization-data.c +++ b/libnautilus-private/nautilus-customization-data.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -77,7 +78,6 @@ static char * get_private_customization_path (const char *custom 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 @@ format_name_for_display (NautilusCustomizationData *data, const char* name) /* 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 @@ load_name_map_hash_table (NautilusCustomizationData *data) } } } - -/* 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; -} diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index d473ac0a1..844eb2250 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -5251,25 +5251,21 @@ add_template_to_templates_menus (FMDirectoryView *directory_view, 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); diff --git a/src/nautilus-property-browser.c b/src/nautilus-property-browser.c index acaef77a4..0bdd41fb0 100644 --- a/src/nautilus-property-browser.c +++ b/src/nautilus-property-browser.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -165,7 +166,6 @@ static void emblems_changed_callback (GObject 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 @@ nautilus_property_browser_drag_data_get (GtkWidget *widget, 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 @@ element_clicked_callback (GtkWidget *image_table, } } - -/* 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 @@ make_properties_from_directories (NautilusPropertyBrowser *property_browser) GList *icons, *l; char *icon_name; char *keyword; - char *extension; GtkWidget *property_image; GtkWidget *blank; guint num_images; @@ -1706,11 +1689,7 @@ make_properties_from_directories (NautilusPropertyBrowser *property_browser) 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); diff --git a/test/test-nautilus-wrap-table.c b/test/test-nautilus-wrap-table.c index 258bde9a9..55147d2a9 100644 --- a/test/test-nautilus-wrap-table.c +++ b/test/test-nautilus-wrap-table.c @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -11,7 +12,7 @@ main (int argc, char* argv[]) 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 @@ main (int argc, char* argv[]) &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 @@ main (int argc, char* argv[]) /* 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);