[tepl] LanguageChooserWidget: handle GtkEntry::activate



commit eea1d91c39ec84fa3f3e12b8f40b3b97a89af051
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Tue Nov 3 18:08:23 2020 +0100

    LanguageChooserWidget: handle GtkEntry::activate

 tepl/tepl-language-chooser-widget.c | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/tepl/tepl-language-chooser-widget.c b/tepl/tepl-language-chooser-widget.c
index 7711075..fdec737 100644
--- a/tepl/tepl-language-chooser-widget.c
+++ b/tepl/tepl-language-chooser-widget.c
@@ -263,9 +263,8 @@ search_changed_cb (GtkSearchEntry            *search_entry,
 }
 
 static void
-list_box_row_activated_cb (GtkListBox                *list_box,
-                          GtkListBoxRow             *list_box_row,
-                          TeplLanguageChooserWidget *chooser_widget)
+emit_language_activated_for_row (TeplLanguageChooserWidget *chooser_widget,
+                                GtkListBoxRow             *list_box_row)
 {
        GtkSourceLanguage *language;
 
@@ -284,6 +283,27 @@ list_box_row_activated_cb (GtkListBox                *list_box,
        }
 }
 
+static void
+search_entry_activate_cb (GtkEntry                  *entry,
+                         TeplLanguageChooserWidget *chooser_widget)
+{
+       GtkListBoxRow *selected_row;
+
+       selected_row = gtk_list_box_get_selected_row (chooser_widget->priv->list_box);
+       if (selected_row != NULL)
+       {
+               emit_language_activated_for_row (chooser_widget, selected_row);
+       }
+}
+
+static void
+list_box_row_activated_cb (GtkListBox                *list_box,
+                          GtkListBoxRow             *list_box_row,
+                          TeplLanguageChooserWidget *chooser_widget)
+{
+       emit_language_activated_for_row (chooser_widget, list_box_row);
+}
+
 static void
 tepl_language_chooser_widget_init (TeplLanguageChooserWidget *chooser_widget)
 {
@@ -324,6 +344,11 @@ tepl_language_chooser_widget_init (TeplLanguageChooserWidget *chooser_widget)
                          G_CALLBACK (search_changed_cb),
                          chooser_widget);
 
+       g_signal_connect (chooser_widget->priv->search_entry,
+                         "activate",
+                         G_CALLBACK (search_entry_activate_cb),
+                         chooser_widget);
+
        g_signal_connect (chooser_widget->priv->list_box,
                          "row-activated",
                          G_CALLBACK (list_box_row_activated_cb),


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