[gtk] popover: Drop key_press_event handler



commit 824bbf31171669ceb2283b71d484a2eed8950f81
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat May 19 23:20:53 2018 -0400

    popover: Drop key_press_event handler
    
    We can do the same in the generic ::event handler.

 gtk/gtkpopover.c | 63 ++++++++++++++++++++++++++------------------------------
 1 file changed, 29 insertions(+), 34 deletions(-)
---
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index cec113c71d..8d64a6fbe2 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -1377,6 +1377,35 @@ gtk_popover_event (GtkWidget *widget,
   GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
 
   if (gdk_event_get_event_type (event) == GDK_BUTTON_PRESS)
+    {
+      GtkWidget *toplevel, *focus;
+      guint keyval;
+
+      if (!gdk_event_get_keyval ((GdkEvent *) event, &keyval))
+        return GDK_EVENT_PROPAGATE;
+
+      if (keyval == GDK_KEY_Escape)
+        {
+          gtk_popover_popdown (GTK_POPOVER (widget));
+          return GDK_EVENT_STOP;
+        }
+
+      if (!priv->modal)
+       return GDK_EVENT_PROPAGATE;
+
+      toplevel = gtk_widget_get_toplevel (widget);
+
+      if (GTK_IS_WINDOW (toplevel))
+        {
+          focus = gtk_window_get_focus (GTK_WINDOW (toplevel));
+
+          if (focus && gtk_widget_is_ancestor (focus, widget))
+            return gtk_widget_event (focus, (GdkEvent*) event);
+        }
+
+      return GDK_EVENT_PROPAGATE;
+    }
+  else if (gdk_event_get_event_type (event) == GDK_BUTTON_PRESS)
     priv->button_pressed = TRUE;
   else if (gdk_event_get_event_type (event) == GDK_BUTTON_RELEASE)
     {
@@ -1402,39 +1431,6 @@ gtk_popover_event (GtkWidget *widget,
   return GDK_EVENT_PROPAGATE;
 }
 
-static gboolean
-gtk_popover_key_press (GtkWidget   *widget,
-                       GdkEventKey *event)
-{
-  GtkWidget *toplevel, *focus;
-  GtkPopoverPrivate *priv = gtk_popover_get_instance_private (GTK_POPOVER (widget));
-  guint keyval;
-
-  if (!gdk_event_get_keyval ((GdkEvent *) event, &keyval))
-    return GDK_EVENT_PROPAGATE;
-
-  if (keyval == GDK_KEY_Escape)
-    {
-      gtk_popover_popdown (GTK_POPOVER (widget));
-      return GDK_EVENT_STOP;
-    }
-
-  if (!priv->modal)
-    return GDK_EVENT_PROPAGATE;
-
-  toplevel = gtk_widget_get_toplevel (widget);
-
-  if (GTK_IS_WINDOW (toplevel))
-    {
-      focus = gtk_window_get_focus (GTK_WINDOW (toplevel));
-
-      if (focus && gtk_widget_is_ancestor (focus, widget))
-        return gtk_widget_event (focus, (GdkEvent*) event);
-    }
-
-  return GDK_EVENT_PROPAGATE;
-}
-
 static void
 gtk_popover_grab_focus (GtkWidget *widget)
 {
@@ -1578,7 +1574,6 @@ gtk_popover_class_init (GtkPopoverClass *klass)
   widget_class->size_allocate = gtk_popover_size_allocate;
   widget_class->snapshot = gtk_popover_snapshot;
   widget_class->event = gtk_popover_event;
-  widget_class->key_press_event = gtk_popover_key_press;
   widget_class->grab_focus = gtk_popover_grab_focus;
   widget_class->focus = gtk_popover_focus;
   widget_class->show = gtk_popover_show;


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