From 9d8c8195212312a275efdf8b87b253568b3681aa Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sun, 10 Oct 2010 22:41:15 +0200 Subject: [PATCH] Always prefill language entries with default values --- katze/katze-utils.c | 14 ++++++++++++++ midori/midori-preferences.c | 6 ++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/katze/katze-utils.c b/katze/katze-utils.c index 7a506820..feb970cd 100644 --- a/katze/katze-utils.c +++ b/katze/katze-utils.c @@ -474,6 +474,9 @@ g_icon_to_string (GIcon *icon) * "custom-PROPERTY": the last value of an enumeration will be the "custom" * value, where the user may enter text freely, which then updates * the property PROPERTY instead. This applies only to enumerations. + * Since 0.2.9 the following hints are also supported: + * "languages": the widget will be particularly suitable for choosing + * multiple language codes, ie. "de,en_GB". * * Any other values for @hint are silently ignored. * @@ -740,6 +743,17 @@ katze_property_proxy (gpointer object, g_object_get (object, property, &string, NULL); if (!string) string = g_strdup (G_PARAM_SPEC_STRING (pspec)->default_value); + if (!(string && *string) && _hint == I_("languages")) + { + gchar* lang = g_strjoinv (",", (gchar**)g_get_language_names ()); + if (g_str_has_suffix (lang, ",C")) + { + string = g_strndup (lang, strlen (lang) - 2); + g_free (lang); + } + else + string = lang; + } gtk_entry_set_text (GTK_ENTRY (widget), string ? string : ""); g_signal_connect (widget, "activate", G_CALLBACK (proxy_entry_activate_cb), object); diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c index d6201255..5f591ac8 100644 --- a/midori/midori-preferences.c +++ b/midori/midori-preferences.c @@ -452,9 +452,7 @@ midori_preferences_set_settings (MidoriPreferences* preferences, gtk_button_set_label (GTK_BUTTON (button), _("Enable Spell Checking")); gtk_widget_set_tooltip_text (button, _("Enable spell checking while typing")); INDENTED_ADD (button); - button = gtk_label_new (_("Spelling dictionaries:")); - INDENTED_ADD (button); - entry = katze_property_proxy (settings, "spell-checking-languages", NULL); + entry = katze_property_proxy (settings, "spell-checking-languages", "languages"); /* i18n: The example should be adjusted to contain a good local default */ gtk_widget_set_tooltip_text (entry, _("A comma separated list of " "languages to be used for spell checking, for example \"en_GB,de_DE\"")); @@ -529,7 +527,7 @@ midori_preferences_set_settings (MidoriPreferences* preferences, SPANNED_ADD (button); label = katze_property_label (settings, "preferred-languages"); INDENTED_ADD (label); - entry = katze_property_proxy (settings, "preferred-languages", NULL); + entry = katze_property_proxy (settings, "preferred-languages", "languages"); SPANNED_ADD (entry); /* Page "Privacy" */