[epiphany] prefs: Fix setting the default search engine



commit 132270a88806f29749cec214882efb44e2b0f12b
Author: vanadiae <vanadiae35 gmail com>
Date:   Wed Feb 3 15:22:13 2021 +0100

    prefs: Fix setting the default search engine
    
    Currently when setting an engine as the default one, it isn't always
    kept once the preferences are reopened.
    
    This is because when creating each row in the UI, the "active" property
    of each radio button is default-initialized to NULL when constructing
    it, but since we're already connected to the "clicked" signal it somehow
    sends it for this FALSE state even though it didn't go to TRUE first.
    
    So this commit makes sure that the clicked signal is a real click, by
    checking for active state TRUE.
    
    Fixes #1430

 src/preferences/ephy-search-engine-row.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/preferences/ephy-search-engine-row.c b/src/preferences/ephy-search-engine-row.c
index d3bb9f769..f4432bbce 100644
--- a/src/preferences/ephy-search-engine-row.c
+++ b/src/preferences/ephy-search-engine-row.c
@@ -444,7 +444,12 @@ static void
 on_radio_button_clicked_cb (EphySearchEngineRow *row,
                             GtkButton           *button)
 {
-  ephy_search_engine_manager_set_default_engine (row->manager, row->saved_name);
+  /* This avoids having some random engines being set as default when adding a new row,
+   * since when it default initialize the "active" property to %FALSE on object construction,
+   * it records a "clicked" signal
+   */
+  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
+    ephy_search_engine_manager_set_default_engine (row->manager, row->saved_name);
 }
 
 static void
@@ -537,7 +542,7 @@ on_ephy_search_engine_row_constructed (GObject *object)
 
   /* Tick the radio button if it's the default search engine. */
   if (g_strcmp0 (self->saved_name, default_search_engine_name) == 0)
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->radio_button), TRUE);
+    ephy_search_engine_row_set_as_default (self);
 
   g_signal_connect_object (self->name_entry, "notify::text", G_CALLBACK (on_name_entry_text_changed_cb), 
self, G_CONNECT_SWAPPED);
   g_signal_connect_object (self->address_entry, "notify::text", G_CALLBACK 
(on_address_entry_text_changed_cb), self, G_CONNECT_SWAPPED);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]