summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Mikhaylenko <alexm@gnome.org>2022-02-16 13:56:50 +0500
committerMarge Bot <marge-bot@gnome.org>2022-02-18 15:47:03 +0000
commit0b51d2cd7a1f43a2f13d4714079f84d6a22aba97 (patch)
treef8f098091be6fe594b7eb1eefc538866ebab24ec
parent9464fe084317f8648261b081bd2b494636422ec2 (diff)
downloadepiphany-0b51d2cd7a1f43a2f13d4714079f84d6a22aba97.tar.gz
search-engine-listbox: Don't subclass GtkListBox
Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/1072>
-rw-r--r--src/preferences/ephy-search-engine-listbox.c14
-rw-r--r--src/preferences/ephy-search-engine-listbox.h2
-rw-r--r--src/resources/gtk/search-engine-listbox.ui17
3 files changed, 20 insertions, 13 deletions
diff --git a/src/preferences/ephy-search-engine-listbox.c b/src/preferences/ephy-search-engine-listbox.c
index 32a81b3be..2e5cb2184 100644
--- a/src/preferences/ephy-search-engine-listbox.c
+++ b/src/preferences/ephy-search-engine-listbox.c
@@ -168,7 +168,9 @@ ephy_add_engine_button_merged_model_init (EphyAddEngineButtonMergedModel *self)
}
struct _EphySearchEngineListBox {
- GtkListBox parent_instance;
+ GtkBin parent_instance;
+
+ GtkWidget *list;
/* This widget isn't actually showed anywhere. It is just a stable place where we can add more radio buttons without having to bother if the primary radio button gets removed. */
GtkWidget *radio_buttons_group;
@@ -187,7 +189,7 @@ struct _EphySearchEngineListBox {
gboolean is_model_initially_loaded;
};
-G_DEFINE_TYPE (EphySearchEngineListBox, ephy_search_engine_list_box, GTK_TYPE_LIST_BOX)
+G_DEFINE_TYPE (EphySearchEngineListBox, ephy_search_engine_list_box, GTK_TYPE_BIN)
GtkWidget *
ephy_search_engine_list_box_new (void)
@@ -262,7 +264,7 @@ on_row_expand_state_changed_cb (EphySearchEngineRow *expanded_row,
if (!hdy_expander_row_get_expanded (HDY_EXPANDER_ROW (expanded_row)))
return;
- while ((row = gtk_list_box_get_row_at_index (GTK_LIST_BOX (self), i++))) {
+ while ((row = gtk_list_box_get_row_at_index (GTK_LIST_BOX (self->list), i++))) {
/* Ignore this row if not a search engine row ("add search engine" row). */
if (!EPHY_IS_SEARCH_ENGINE_ROW (row))
continue;
@@ -277,8 +279,7 @@ on_row_expand_state_changed_cb (EphySearchEngineRow *expanded_row,
static void
on_add_search_engine_row_clicked_cb (EphySearchEngineListBox *self,
- GtkListBoxRow *clicked_row,
- gpointer user_data)
+ GtkListBoxRow *clicked_row)
{
g_autoptr (EphySearchEngine) empty_engine = NULL;
@@ -380,6 +381,7 @@ ephy_search_engine_list_box_class_init (EphySearchEngineListBoxClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/epiphany/gtk/search-engine-listbox.ui");
+ gtk_widget_class_bind_template_child (widget_class, EphySearchEngineListBox, list);
gtk_widget_class_bind_template_callback (widget_class, on_add_search_engine_row_clicked_cb);
}
@@ -399,7 +401,7 @@ ephy_search_engine_list_box_init (EphySearchEngineListBox *self)
self->wrapper_model = g_object_new (EPHY_TYPE_ADD_ENGINE_BUTTON_MERGED_MODEL, NULL);
self->is_model_initially_loaded = FALSE;
- gtk_list_box_bind_model (GTK_LIST_BOX (self),
+ gtk_list_box_bind_model (GTK_LIST_BOX (self->list),
G_LIST_MODEL (self->wrapper_model),
(GtkListBoxCreateWidgetFunc)list_box_create_row_func,
self, NULL);
diff --git a/src/preferences/ephy-search-engine-listbox.h b/src/preferences/ephy-search-engine-listbox.h
index 624901f31..6750972ac 100644
--- a/src/preferences/ephy-search-engine-listbox.h
+++ b/src/preferences/ephy-search-engine-listbox.h
@@ -27,7 +27,7 @@ G_BEGIN_DECLS
#define EPHY_TYPE_SEARCH_ENGINE_LIST_BOX (ephy_search_engine_list_box_get_type())
-G_DECLARE_FINAL_TYPE (EphySearchEngineListBox, ephy_search_engine_list_box, EPHY, SEARCH_ENGINE_LIST_BOX, GtkListBox)
+G_DECLARE_FINAL_TYPE (EphySearchEngineListBox, ephy_search_engine_list_box, EPHY, SEARCH_ENGINE_LIST_BOX, GtkBin)
GtkWidget *ephy_search_engine_list_box_new (void);
diff --git a/src/resources/gtk/search-engine-listbox.ui b/src/resources/gtk/search-engine-listbox.ui
index 89091aea3..50a82fd47 100644
--- a/src/resources/gtk/search-engine-listbox.ui
+++ b/src/resources/gtk/search-engine-listbox.ui
@@ -1,12 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.20"/>
- <template class="EphySearchEngineListBox" parent="GtkListBox">
+ <template class="EphySearchEngineListBox" parent="GtkBin">
<property name="visible">True</property>
- <property name="selection-mode">none</property>
- <signal name="row-activated" handler="on_add_search_engine_row_clicked_cb"/>
- <style>
- <class name="content"/>
- </style>
+ <child>
+ <object class="GtkListBox" id="list">
+ <property name="visible">True</property>
+ <property name="selection-mode">none</property>
+ <signal name="row-activated" handler="on_add_search_engine_row_clicked_cb" swapped="yes"/>
+ <style>
+ <class name="content"/>
+ </style>
+ </object>
+ </child>
</template>
</interface>