Always prefill language entries with default values

This commit is contained in:
Christian Dywan 2010-10-10 22:41:15 +02:00
parent 4d2968a0cc
commit 9d8c819521
2 changed files with 16 additions and 4 deletions

View file

@ -474,6 +474,9 @@ g_icon_to_string (GIcon *icon)
* "custom-PROPERTY": the last value of an enumeration will be the "custom" * "custom-PROPERTY": the last value of an enumeration will be the "custom"
* value, where the user may enter text freely, which then updates * value, where the user may enter text freely, which then updates
* the property PROPERTY instead. This applies only to enumerations. * 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. * Any other values for @hint are silently ignored.
* *
@ -740,6 +743,17 @@ katze_property_proxy (gpointer object,
g_object_get (object, property, &string, NULL); g_object_get (object, property, &string, NULL);
if (!string) if (!string)
string = g_strdup (G_PARAM_SPEC_STRING (pspec)->default_value); 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 : ""); gtk_entry_set_text (GTK_ENTRY (widget), string ? string : "");
g_signal_connect (widget, "activate", g_signal_connect (widget, "activate",
G_CALLBACK (proxy_entry_activate_cb), object); G_CALLBACK (proxy_entry_activate_cb), object);

View file

@ -452,9 +452,7 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
gtk_button_set_label (GTK_BUTTON (button), _("Enable Spell Checking")); gtk_button_set_label (GTK_BUTTON (button), _("Enable Spell Checking"));
gtk_widget_set_tooltip_text (button, _("Enable spell checking while typing")); gtk_widget_set_tooltip_text (button, _("Enable spell checking while typing"));
INDENTED_ADD (button); INDENTED_ADD (button);
button = gtk_label_new (_("Spelling dictionaries:")); entry = katze_property_proxy (settings, "spell-checking-languages", "languages");
INDENTED_ADD (button);
entry = katze_property_proxy (settings, "spell-checking-languages", NULL);
/* i18n: The example should be adjusted to contain a good local default */ /* i18n: The example should be adjusted to contain a good local default */
gtk_widget_set_tooltip_text (entry, _("A comma separated list of " gtk_widget_set_tooltip_text (entry, _("A comma separated list of "
"languages to be used for spell checking, for example \"en_GB,de_DE\"")); "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); SPANNED_ADD (button);
label = katze_property_label (settings, "preferred-languages"); label = katze_property_label (settings, "preferred-languages");
INDENTED_ADD (label); INDENTED_ADD (label);
entry = katze_property_proxy (settings, "preferred-languages", NULL); entry = katze_property_proxy (settings, "preferred-languages", "languages");
SPANNED_ADD (entry); SPANNED_ADD (entry);
/* Page "Privacy" */ /* Page "Privacy" */