diff options
author | specter <specter92@live.com> | 2017-07-12 20:58:06 -0400 |
---|---|---|
committer | Michael Catanzaro <mcatanzaro@igalia.com> | 2017-07-12 20:39:54 -0500 |
commit | 13c147b026fb6c902118f598201b4157a5210ead (patch) | |
tree | 525bd07748d313ee81d977cf524b13a110aca8c5 | |
parent | 638a8051cd970f231126ebed7cb02bcd289cae50 (diff) | |
download | epiphany-13c147b026fb6c902118f598201b4157a5210ead.tar.gz |
prefs-dialog: Clear "custom" dialog automatically when another radio option is selected
Also fixed bug where the "custom" dialog becomes unsensitive if one
highlights it fully and then types on top of it.
https://bugzilla.gnome.org/show_bug.cgi?id=783290
-rw-r--r-- | src/prefs-dialog.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c index b74beb8d7..571bf8c72 100644 --- a/src/prefs-dialog.c +++ b/src/prefs-dialog.c @@ -1315,10 +1315,17 @@ new_tab_homepage_get_mapping (GValue *value, static GVariant * new_tab_homepage_set_mapping (const GValue *value, const GVariantType *expected_type, - gpointer user_data) + gpointer user_data) { + PrefsDialog *dialog = EPHY_PREFS_DIALOG (user_data); + if (!g_value_get_boolean (value)) return NULL; + + /* In case the new tab button is pressed while there's text in the custom homepage entry */ + gtk_entry_set_text (GTK_ENTRY (dialog->custom_homepage_entry), ""); + gtk_widget_set_sensitive (dialog->custom_homepage_entry, FALSE); + return g_variant_new_string (""); } @@ -1339,10 +1346,15 @@ blank_homepage_get_mapping (GValue *value, static GVariant * blank_homepage_set_mapping (const GValue *value, const GVariantType *expected_type, - gpointer user_data) + gpointer user_data) { + PrefsDialog *dialog = EPHY_PREFS_DIALOG (user_data); + if (!g_value_get_boolean (value)) return NULL; + + gtk_entry_set_text (GTK_ENTRY (dialog->custom_homepage_entry), ""); + return g_variant_new_string ("about:blank"); } @@ -1364,11 +1376,12 @@ custom_homepage_set_mapping (const GValue *value, const GVariantType *expected_type, gpointer user_data) { - PrefsDialog *dialog = user_data; + PrefsDialog *dialog = EPHY_PREFS_DIALOG (user_data); const char *setting; if (!g_value_get_boolean (value)) { gtk_widget_set_sensitive (dialog->custom_homepage_entry, FALSE); + gtk_entry_set_text (GTK_ENTRY (dialog->custom_homepage_entry), ""); return NULL; } @@ -1379,6 +1392,7 @@ custom_homepage_set_mapping (const GValue *value, return NULL; gtk_entry_set_text (GTK_ENTRY (dialog->custom_homepage_entry), setting); + return g_variant_new_string (setting); } @@ -1386,8 +1400,15 @@ static void custom_homepage_entry_changed (GtkEntry *entry, PrefsDialog *dialog) { - g_settings_set_string (EPHY_SETTINGS_MAIN, EPHY_PREFS_HOMEPAGE_URL, - gtk_entry_get_text (entry)); + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->custom_homepage_radiobutton))) { + g_settings_set_string (EPHY_SETTINGS_MAIN, EPHY_PREFS_HOMEPAGE_URL, + gtk_entry_get_text (entry)); + } else if ((gtk_entry_get_text (entry) != NULL) && + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->new_tab_homepage_radiobutton))) { + g_settings_set_string (EPHY_SETTINGS_MAIN, EPHY_PREFS_HOMEPAGE_URL, gtk_entry_get_text (entry)); + gtk_widget_set_sensitive (dialog->custom_homepage_entry, TRUE); + gtk_widget_grab_focus (dialog->custom_homepage_entry); + } } static void @@ -1436,7 +1457,7 @@ setup_general_page (PrefsDialog *dialog) G_SETTINGS_BIND_DEFAULT, new_tab_homepage_get_mapping, new_tab_homepage_set_mapping, - NULL, + dialog, NULL); g_settings_bind_with_mapping (settings, EPHY_PREFS_HOMEPAGE_URL, @@ -1445,7 +1466,7 @@ setup_general_page (PrefsDialog *dialog) G_SETTINGS_BIND_DEFAULT, blank_homepage_get_mapping, blank_homepage_set_mapping, - NULL, + dialog, NULL); g_settings_bind_with_mapping (settings, EPHY_PREFS_HOMEPAGE_URL, |