[gimp/soc-2010-cage] app/tests: Remove gimp_ui_synthesize_plus_key_event() crack



commit 5f6f534dbab3706b374351d77c77d552f95e82e2
Author: Martin Nordholts <martinn src gnome org>
Date:   Mon Jun 21 20:59:38 2010 +0200

    app/tests: Remove gimp_ui_synthesize_plus_key_event() crack
    
    Make gimp_ui_synthesize_plus_key_event() generic and implement it with
    gdk_test_simulate_key(). We can't use gtk_test_widget_send_key()
    because its input window logic doesn't seem to work very well.

 app/tests/test-ui.c |   51 +++++++++++++++------------------------------------
 1 files changed, 15 insertions(+), 36 deletions(-)
---
diff --git a/app/tests/test-ui.c b/app/tests/test-ui.c
index 2233298..36f076b 100644
--- a/app/tests/test-ui.c
+++ b/app/tests/test-ui.c
@@ -79,7 +79,8 @@ typedef struct
 
 static GimpUIManager * gimp_ui_get_ui_manager                   (Gimp              *gimp);
 static void            gimp_ui_synthesize_delete_event          (GtkWidget         *widget);
-static void            gimp_ui_synthesize_plus_key_event        (GtkWidget         *widget);
+static void            gimp_ui_synthesize_key_event             (GtkWidget         *widget,
+                                                                 guint              keyval);
 static GtkWidget     * gimp_ui_find_dock_window                 (GimpDialogFactory *dialog_factory,
                                                                  GimpUiTestFunc     predicate);
 static gboolean        gimp_ui_not_toolbox_window               (GObject           *object);
@@ -296,7 +297,7 @@ keyboard_zoom_focus (GimpTestFixture *fixture,
   factor_before_zoom = gimp_zoom_model_get_factor (shell->zoom);
 
   /* Do the zoom */
-  gimp_ui_synthesize_plus_key_event (GTK_WIDGET (window));
+  gimp_ui_synthesize_key_event (GTK_WIDGET (window), GDK_plus);
   gimp_test_run_mainloop_until_idle ();
 
   /* Make sure the zoom focus point remained fixed */
@@ -575,41 +576,19 @@ gimp_ui_synthesize_delete_event (GtkWidget *widget)
 }
 
 static void
-gimp_ui_synthesize_plus_key_event (GtkWidget *widget)
+gimp_ui_synthesize_key_event (GtkWidget *widget,
+                              guint      keyval)
 {
-  GdkWindow *window           = NULL;
-  GdkEvent  *event            = NULL;
-  guint      keyval           = GDK_plus;
-  guint      hardware_keycode = 20;
-
-  /* FIXME: How do we figure out hardware_keycode, especially in a
-   * platform independent way? 20 is the hardware keycode on my
-   * machine for GDK_plus when using a X11 backend... I hope it will
-   * be the same on others running at least the X11 build of GTK+
-   */
-
-  window = gtk_widget_get_window (widget);
-  g_assert (window);
-
-  event = gdk_event_new (GDK_KEY_PRESS);
-  event->any.window           = g_object_ref (window);
-  event->any.send_event       = TRUE;
-  event->key.keyval           = keyval;
-  event->key.time             = GDK_CURRENT_TIME;
-  event->key.state            = 0;
-  event->key.hardware_keycode = hardware_keycode;
-  gdk_event_put (event);
-  gdk_event_free (event);
-
-  event = gdk_event_new (GDK_KEY_RELEASE);
-  event->any.window           = g_object_ref (window);
-  event->any.send_event       = TRUE;
-  event->key.keyval           = keyval;
-  event->key.time             = GDK_CURRENT_TIME;
-  event->key.state            = 0;
-  event->key.hardware_keycode = hardware_keycode;
-  gdk_event_put (event);
-  gdk_event_free (event);
+  gdk_test_simulate_key (gtk_widget_get_window (widget),
+                         -1, -1, /*x, y*/
+                         keyval,
+                         0 /*modifiers*/,
+                         GDK_KEY_PRESS);
+  gdk_test_simulate_key (gtk_widget_get_window (widget),
+                         -1, -1, /*x, y*/
+                         keyval,
+                         0 /*modifiers*/,
+                         GDK_KEY_RELEASE);
 }
 
 static GtkWidget *



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