[epiphany] prefs-dialog: Clear "custom" dialog automatically when another radio option is selected
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] prefs-dialog: Clear "custom" dialog automatically when another radio option is selected
- Date: Thu, 13 Jul 2017 01:39:24 +0000 (UTC)
commit 13124d9c427e40fe77917a87183e05317deb863c
Author: specter <specter92 live com>
Date: Wed Jul 12 20:58:06 2017 -0400
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
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 4b4761f..7052b2f 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -1330,10 +1330,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 ("");
}
@@ -1354,10 +1361,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");
}
@@ -1379,11 +1391,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;
}
@@ -1394,6 +1407,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);
}
@@ -1401,8 +1415,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
@@ -1451,7 +1472,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,
@@ -1460,7 +1481,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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]