[recipes] Clean up key handling code in gr-window.c



commit afd4df928dfc5714f95384331e7f2ef100832210
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Mar 12 22:11:20 2017 -0400

    Clean up key handling code in gr-window.c
    
    There was some dead code here that we don't need anymore.

 src/gr-window.c  |   37 ++++++++++++-------------------------
 src/gr-window.ui |    2 +-
 2 files changed, 13 insertions(+), 26 deletions(-)
---
diff --git a/src/gr-window.c b/src/gr-window.c
index ca1e14c..98ca2fd 100644
--- a/src/gr-window.c
+++ b/src/gr-window.c
@@ -410,48 +410,35 @@ gr_window_timer_expired (GrWindow *window,
 }
 
 static gboolean
-window_keypress_handler (GtkWidget *widget,
-                         GdkEvent  *event,
-                         gpointer   data)
+window_keypress_handler_before (GtkWidget *widget,
+                                GdkEvent  *event,
+                                gpointer   data)
 {
         GrWindow *window = GR_WINDOW (widget);
-//        GdkEventKey *e = (GdkEventKey *) event;
         const char *visible;
 
         visible = gtk_stack_get_visible_child_name (GTK_STACK (window->main_stack));
 
-#if 0
-        if (strcmp (visible, "image") == 0) {
-                if (e->keyval == GDK_KEY_Escape) {
-                        gr_window_show_image (window, NULL, -1);
-                        return GDK_EVENT_STOP;
-                }
-        }
-#endif
-
         if (strcmp (visible, "cooking") == 0)
                 return gr_cooking_page_handle_event (GR_COOKING_PAGE (window->cooking_page), event);
 
-        if (strcmp (visible, "recipes") != 0 &&
-            strcmp (visible, "cuisines") != 0 &&
-            strcmp (visible, "search") != 0)
-                return GDK_EVENT_PROPAGATE;
-
-        return gr_query_editor_handle_event (GR_QUERY_EDITOR (window->search_bar), event);
+        return GDK_EVENT_PROPAGATE;
 }
 
 static gboolean
-window_keypress_handler_before (GtkWidget *widget,
-                                GdkEvent  *event,
-                                gpointer   data)
+window_keypress_handler_after (GtkWidget *widget,
+                               GdkEvent  *event,
+                               gpointer   data)
 {
         GrWindow *window = GR_WINDOW (widget);
         const char *visible;
 
         visible = gtk_stack_get_visible_child_name (GTK_STACK (window->main_stack));
 
-        if (strcmp (visible, "cooking") == 0)
-                return gr_cooking_page_handle_event (GR_COOKING_PAGE (window->cooking_page), event);
+        if (strcmp (visible, "recipes") == 0 ||
+            strcmp (visible, "cuisines") == 0 ||
+            strcmp (visible, "search") == 0)
+                return gr_query_editor_handle_event (GR_QUERY_EDITOR (window->search_bar), event);
 
         return GDK_EVENT_PROPAGATE;
 }
@@ -853,8 +840,8 @@ gr_window_class_init (GrWindowClass *klass)
         gtk_widget_class_bind_template_callback (widget_class, search_changed);
         gtk_widget_class_bind_template_callback (widget_class, stop_search);
         gtk_widget_class_bind_template_callback (widget_class, search_mode_changed);
-        gtk_widget_class_bind_template_callback (widget_class, window_keypress_handler);
         gtk_widget_class_bind_template_callback (widget_class, window_keypress_handler_before);
+        gtk_widget_class_bind_template_callback (widget_class, window_keypress_handler_after);
         gtk_widget_class_bind_template_callback (widget_class, window_buttonpress_handler);
         gtk_widget_class_bind_template_callback (widget_class, window_mapped_handler);
         gtk_widget_class_bind_template_callback (widget_class, window_delete_handler);
diff --git a/src/gr-window.ui b/src/gr-window.ui
index 8f4bfca..46b07be 100644
--- a/src/gr-window.ui
+++ b/src/gr-window.ui
@@ -4,7 +4,7 @@
   <template class="GrWindow" parent="GtkApplicationWindow">
     <property name="resizable">1</property>
     <signal name="key-press-event" handler="window_keypress_handler_before"/>
-    <signal name="key-press-event" handler="window_keypress_handler" after="yes"/>
+    <signal name="key-press-event" handler="window_keypress_handler_after" after="yes"/>
     <signal name="button-press-event" handler="window_buttonpress_handler" after="yes"/>
     <signal name="delete-event" handler="window_delete_handler"/>
     <signal name="map" handler="window_mapped_handler" after="yes"/>


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