[gnome-control-center] common: Move CcLanguageChooser signal handlers into GtkBuilder



commit d7c8ecee601228365312ebb242eb82ee5d23b980
Author: Robert Ancell <robert ancell canonical com>
Date:   Tue Dec 1 10:41:44 2020 +1300

    common: Move CcLanguageChooser signal handlers into GtkBuilder

 panels/common/cc-language-chooser.c  | 20 +++++++-------------
 panels/common/cc-language-chooser.ui |  3 +++
 2 files changed, 10 insertions(+), 13 deletions(-)
---
diff --git a/panels/common/cc-language-chooser.c b/panels/common/cc-language-chooser.c
index 08cd71bce..0e6125c7c 100644
--- a/panels/common/cc-language-chooser.c
+++ b/panels/common/cc-language-chooser.c
@@ -158,7 +158,7 @@ sort_languages (GtkListBoxRow *a,
 }
 
 static void
-filter_changed (CcLanguageChooser *chooser)
+language_filter_entry_search_changed_cb (CcLanguageChooser *chooser)
 {
         g_autofree gchar *filter_contents = NULL;
 
@@ -225,8 +225,7 @@ set_locale_id (CcLanguageChooser *chooser,
 }
 
 static void
-row_activated (CcLanguageChooser *chooser,
-               GtkListBoxRow     *row)
+language_listbox_row_activated_cb (CcLanguageChooser *chooser, GtkListBoxRow *row)
 {
         const gchar *new_locale_id;
 
@@ -249,7 +248,7 @@ row_activated (CcLanguageChooser *chooser,
 }
 
 static void
-activate_default (CcLanguageChooser *chooser)
+activate_default_cb (CcLanguageChooser *chooser)
 {
         GtkWidget *focus;
 
@@ -281,16 +280,7 @@ cc_language_chooser_init (CcLanguageChooser *chooser)
                                       cc_list_box_update_header_func, NULL, NULL);
         add_all_languages (chooser);
 
-        g_signal_connect_object (chooser->language_filter_entry, "search-changed",
-                                 G_CALLBACK (filter_changed), chooser, G_CONNECT_SWAPPED);
-
-        g_signal_connect_object (chooser->language_listbox, "row-activated",
-                                 G_CALLBACK (row_activated), chooser, G_CONNECT_SWAPPED);
-
         gtk_list_box_invalidate_filter (chooser->language_listbox);
-
-        g_signal_connect (chooser, "activate-default",
-                          G_CALLBACK (activate_default), NULL);
 }
 
 static void
@@ -319,6 +309,10 @@ cc_language_chooser_class_init (CcLanguageChooserClass *klass)
         gtk_widget_class_bind_template_child (widget_class, CcLanguageChooser, more_row);
         gtk_widget_class_bind_template_child (widget_class, CcLanguageChooser, search_bar);
         gtk_widget_class_bind_template_child (widget_class, CcLanguageChooser, select_button);
+
+        gtk_widget_class_bind_template_callback (widget_class, activate_default_cb);
+        gtk_widget_class_bind_template_callback (widget_class, language_filter_entry_search_changed_cb);
+        gtk_widget_class_bind_template_callback (widget_class, language_listbox_row_activated_cb);
 }
 
 CcLanguageChooser *
diff --git a/panels/common/cc-language-chooser.ui b/panels/common/cc-language-chooser.ui
index 85b344467..5449fb3dd 100644
--- a/panels/common/cc-language-chooser.ui
+++ b/panels/common/cc-language-chooser.ui
@@ -7,6 +7,7 @@
     <property name="destroy_with_parent">True</property>
     <property name="default_width">340</property>
     <property name="default_height">475</property>
+    <signal name="activate-default" handler="activate_default_cb"/>
     <child type="action">
       <object class="GtkButton" id="select_button">
         <property name="label" translatable="yes">_Select</property>
@@ -42,6 +43,7 @@
               <object class="GtkSearchEntry" id="language_filter_entry">
                 <property name="visible">True</property>
                 <property name="width_chars">30</property>
+                <signal name="search-changed" handler="language_filter_entry_search_changed_cb" 
object="CcLanguageChooser" swapped="yes"/>
               </object>
             </child>
           </object>
@@ -60,6 +62,7 @@
                 <property name="vexpand">True</property>
                 <property name="halign">fill</property>
                 <property name="valign">fill</property>
+                <signal name="row-activated" handler="language_listbox_row_activated_cb" 
object="CcLanguageChooser" swapped="yes"/>
                 <child type="placeholder">
                   <object class="GtkLabel">
                     <property name="visible">True</property>


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