diff options
-rw-r--r-- | ChangeLog | 23 | ||||
-rw-r--r-- | data/patterns/reset.png | bin | 759 -> 441 bytes | |||
-rw-r--r-- | libnautilus-private/nautilus-customization-data.c | 56 | ||||
-rw-r--r-- | libnautilus-private/nautilus-customization-data.h | 3 | ||||
-rw-r--r-- | src/nautilus-property-browser.c | 11 |
5 files changed, 84 insertions, 9 deletions
@@ -1,5 +1,28 @@ 2001-07-20 Andy Hertzfeld <andy@differnet.com> + fixed problem that the reset property was not localizable, since + it used an image that contained text. Fixed, by removing the + text from the image and compositing it on the fly, from a localizable + string. + + * data/patterns/reset.png: + new version of reset tile without text. + + * libnautilus-private/nautilus-customization-data.c: + (nautilus_customization_data_get_next_element_for_display), + (add_reset_text), (nautilus_customization_make_pattern_chit): + composite the reset text on the fly when necessary + + * libnautilus-private/nautilus-customization-data.h: + added a parameter to make_pattern_chit to tell it to draw + the reset text when necessary + + * src/nautilus-property-browser.c: (make_drag_image), + (make_color_drag_image), (add_reset_property): + set the reset parameter properly when calling make_pattern_chit. + +2001-07-20 Andy Hertzfeld <andy@differnet.com> + removed the bad hack of attributing special meaning to the "reset.png" filename; instead, use a newly defined drop type of "x-special/gnome-reset-background". diff --git a/data/patterns/reset.png b/data/patterns/reset.png Binary files differindex bf1892e38..34674fbd4 100644 --- a/data/patterns/reset.png +++ b/data/patterns/reset.png diff --git a/libnautilus-private/nautilus-customization-data.c b/libnautilus-private/nautilus-customization-data.c index 3bac9e537..251c3b825 100644 --- a/libnautilus-private/nautilus-customization-data.c +++ b/libnautilus-private/nautilus-customization-data.c @@ -28,6 +28,10 @@ #include <config.h> #include <ctype.h> +#include <libgnome/gnome-defs.h> +#include <libgnome/gnome-util.h> +#include <libgnome/gnome-i18n.h> + #include <gnome-xml/parser.h> #include <gnome-xml/xmlmemory.h> @@ -46,6 +50,7 @@ #include "nautilus-file-utilities.h" #include <eel/eel-gdk-extensions.h> #include <eel/eel-gtk-extensions.h> +#include <eel/eel-scalable-font.h> #include <eel/eel-xml-extensions.h> #include <eel/eel-string.h> @@ -152,7 +157,6 @@ nautilus_customization_data_new (const char *customization_name, return data; } - GnomeVFSResult nautilus_customization_data_get_next_element_for_display (NautilusCustomizationData *data, char **emblem_name, @@ -164,6 +168,7 @@ nautilus_customization_data_get_next_element_for_display (NautilusCustomizationD char *image_file_name, *filtered_name; GdkPixbuf *pixbuf; GdkPixbuf *orig_pixbuf; + gboolean is_reset_image; g_return_val_if_fail (data != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS); g_return_val_if_fail (emblem_name != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS); @@ -203,13 +208,15 @@ nautilus_customization_data_get_next_element_for_display (NautilusCustomizationD image_file_name = get_file_path_for_mode (data, current_file_info->name); - orig_pixbuf = gdk_pixbuf_new_from_file (image_file_name); + orig_pixbuf = gdk_pixbuf_new_from_file (image_file_name); g_free (image_file_name); + is_reset_image = eel_strcmp(current_file_info->name, RESET_IMAGE_NAME) == 0; + *emblem_name = g_strdup (current_file_info->name); if (!strcmp(data->customization_name, "patterns")) { - pixbuf = nautilus_customization_make_pattern_chit (orig_pixbuf, data->pattern_frame, FALSE); + pixbuf = nautilus_customization_make_pattern_chit (orig_pixbuf, data->pattern_frame, FALSE, is_reset_image); } else { pixbuf = eel_gdk_pixbuf_scale_down_to_fit (orig_pixbuf, data->maximum_icon_width, @@ -334,9 +341,45 @@ get_file_path_for_mode (const NautilusCustomizationData *data, return directory_name; } +/* utility to composite localizable text onto the reset pixbuf */ +static void +add_reset_text (GdkPixbuf *pixbuf) +{ + char *reset_text; + EelScalableFont *font; + EelDimensions title_dimensions; + int width, height; + int font_size, text_len; + int h_offset, v_offset; + + font = eel_scalable_font_get_default_font (); + reset_text = _("reset"); + text_len = strlen (reset_text); + + width = gdk_pixbuf_get_width (pixbuf); + height = gdk_pixbuf_get_height (pixbuf); + + font_size = eel_scalable_font_largest_fitting_font_size (font, reset_text, width - 12, 12, 36); + title_dimensions = eel_scalable_font_measure_text (font, font_size, reset_text, text_len); + + /* compute text position, correcting for the imbalanced shadow, etc. */ + h_offset = ((width - title_dimensions.width) / 2) - 2; + v_offset = (((height - 8)/ 2) - title_dimensions.height) / 2; + + eel_scalable_font_draw_text (font, pixbuf, + h_offset, v_offset, + eel_gdk_pixbuf_whole_pixbuf, + font_size, + reset_text, text_len, + EEL_RGBA_COLOR_OPAQUE_WHITE, + EEL_OPACITY_FULLY_OPAQUE); + + gtk_object_unref (GTK_OBJECT (font)); +} + /* utility to make an attractive pattern image by compositing with a frame */ GdkPixbuf* -nautilus_customization_make_pattern_chit (GdkPixbuf *pattern_tile, GdkPixbuf *frame, gboolean dragging) +nautilus_customization_make_pattern_chit (GdkPixbuf *pattern_tile, GdkPixbuf *frame, gboolean dragging, gboolean is_reset) { GdkPixbuf *pixbuf, *temp_pixbuf; int frame_width, frame_height; @@ -361,6 +404,11 @@ nautilus_customization_make_pattern_chit (GdkPixbuf *pattern_tile, GdkPixbuf *fr } gdk_pixbuf_unref (pattern_tile); + + if (is_reset) { + add_reset_text (pixbuf); + } + return pixbuf; } diff --git a/libnautilus-private/nautilus-customization-data.h b/libnautilus-private/nautilus-customization-data.h index a7fc56579..6d51ad400 100644 --- a/libnautilus-private/nautilus-customization-data.h +++ b/libnautilus-private/nautilus-customization-data.h @@ -66,6 +66,7 @@ void nautilus_customization_data_destroy GdkPixbuf* nautilus_customization_make_pattern_chit (GdkPixbuf *pattern_tile, GdkPixbuf *frame, - gboolean dragging); + gboolean dragging, + gboolean is_reset); #endif /* NAUTILUS_CUSTOMIZATION_DATA_H */ diff --git a/src/nautilus-property-browser.c b/src/nautilus-property-browser.c index 6b9ecc832..fe538407e 100644 --- a/src/nautilus-property-browser.c +++ b/src/nautilus-property-browser.c @@ -642,7 +642,8 @@ make_drag_image (NautilusPropertyBrowser *property_browser, const char* file_nam { GdkPixbuf *pixbuf, *orig_pixbuf; char *image_file_name; - + gboolean is_reset; + image_file_name = g_strdup_printf ("%s/%s/%s", NAUTILUS_DATADIR, property_browser->details->category, @@ -664,8 +665,10 @@ make_drag_image (NautilusPropertyBrowser *property_browser, const char* file_nam orig_pixbuf = gdk_pixbuf_new_from_file (image_file_name); + is_reset = eel_strcmp (file_name, RESET_IMAGE_NAME) == 0; + if (!strcmp(property_browser->details->category, "patterns")) { - pixbuf = nautilus_customization_make_pattern_chit (orig_pixbuf, property_browser->details->property_chit, TRUE); + pixbuf = nautilus_customization_make_pattern_chit (orig_pixbuf, property_browser->details->property_chit, TRUE, is_reset); } else { pixbuf = eel_gdk_pixbuf_scale_down_to_fit (orig_pixbuf, MAX_ICON_WIDTH, MAX_ICON_HEIGHT); gdk_pixbuf_unref (orig_pixbuf); @@ -710,7 +713,7 @@ make_color_drag_image (NautilusPropertyBrowser *property_browser, const char *co return nautilus_customization_make_pattern_chit (color_square, property_browser->details->property_chit, - trim_edges); + trim_edges, FALSE); } /* this callback handles button presses on the category widget. It maintains the active state */ @@ -1747,7 +1750,7 @@ add_reset_property (NautilusPropertyBrowser *property_browser) reset_image_file_name = g_strdup_printf ("%s/%s/%s", NAUTILUS_DATADIR, "patterns", RESET_IMAGE_NAME); reset_pixbuf = gdk_pixbuf_new_from_file (reset_image_file_name); - reset_chit = nautilus_customization_make_pattern_chit (reset_pixbuf, property_browser->details->property_chit, FALSE); + reset_chit = nautilus_customization_make_pattern_chit (reset_pixbuf, property_browser->details->property_chit, FALSE, TRUE); g_free (reset_image_file_name); |