From 4a4994f4dbed64784058cb437705d4a5ba22c196 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Fri, 5 Nov 2010 16:30:23 +0100 Subject: [PATCH] libgimpwidgets: bring back unit format strings in GimpSizeEntry Use the user-provided format string as long-format and try to create a short-format by replacing "%s" and "%p" by "%a" for the popup. Works nicely for all cases I've seen so far. --- libgimpwidgets/gimpsizeentry.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libgimpwidgets/gimpsizeentry.c b/libgimpwidgets/gimpsizeentry.c index fe207d60a0..04dc33364e 100644 --- a/libgimpwidgets/gimpsizeentry.c +++ b/libgimpwidgets/gimpsizeentry.c @@ -379,6 +379,27 @@ gimp_size_entry_new (gint number_of_fields, gimp_unit_store_set_has_pixels (store, gse->menu_show_pixels); gimp_unit_store_set_has_percent (store, gse->menu_show_percent); + if (unit_format) + { + gchar *short_format = g_strdup (unit_format); + gchar *p; + + p = strstr (short_format, "%s"); + if (p) + strcpy (p, "%a"); + + p = strstr (short_format, "%p"); + if (p) + strcpy (p, "%a"); + + g_object_set (store, + "short-format", short_format, + "long-format", unit_format, + NULL); + + g_free (short_format); + } + gse->unitmenu = gimp_unit_combo_box_new_with_model (store); g_object_unref (store);