/** * gtk_test_widget_click: * @widget: Widget to generate a button click on. * @button: Number of the pointer button for the event, usually 1, 2 or 3. * @modifiers: Keyboard modifiers the event is setup with. * * This function will generate a @button click (button press and button * release event) in the middle of the first GdkWindow found that belongs * to @widget. * For %GTK_NO_WINDOW widgets like GtkButton, this will often be an * input-only event window. For other widgets, this is usually widget->window. * Certain caveats should be considered when using this function, in * particular because the mouse pointer is warped to the button click * location, see gdk_test_simulate_button() for details. * * Returns: wether all actions neccessary for the button click simulation were carried out successfully. * * Since: 2.14 **/ gboolean gtk_test_widget_click (GtkWidget *widget, guint button, GdkModifierType modifiers) { gboolean b1res, b2res; GSList *iwindows = test_find_widget_input_windows (widget, FALSE); if (!iwindows) iwindows = test_find_widget_input_windows (widget, TRUE); if (!iwindows) return FALSE; b1res = gdk_test_simulate_button (iwindows->data, -1, -1, button, modifiers, GDK_BUTTON_PRESS); b2res = gdk_test_simulate_button (iwindows->data, -1, -1, button, modifiers, GDK_BUTTON_RELEASE); g_slist_free (iwindows); return b1res && b2res; }
/** * gtk_test_spin_button_click * @spinner: valid GtkSpinButton widget. * @button: Number of the pointer button for the event, usually 1, 2 or 3. * @upwards: %TRUE for upwards arrow click, %FALSE for downwards arrow click. * * This function will generate a @button click in the upwards or downwards * spin button arrow areas, usually leading to an increase or decrease of * spin button's value. * * Returns: wether all actions neccessary for the button click simulation were carried out successfully. * * Since: 2.14 **/ gboolean gtk_test_spin_button_click (GtkSpinButton *spinner, guint button, gboolean upwards) { gboolean b1res = FALSE, b2res = FALSE; if (spinner->panel) { gint width, height, pos; gdk_drawable_get_size (spinner->panel, &width, &height); pos = upwards ? 0 : height - 1; b1res = gdk_test_simulate_button (spinner->panel, width - 1, pos, button, 0, GDK_BUTTON_PRESS); b2res = gdk_test_simulate_button (spinner->panel, width - 1, pos, button, 0, GDK_BUTTON_RELEASE); } return b1res && b2res; }
/** * gtk_test_spin_button_click: * @spinner: valid GtkSpinButton widget. * @button: Number of the pointer button for the event, usually 1, 2 or 3. * @upwards: %TRUE for upwards arrow click, %FALSE for downwards arrow click. * * This function will generate a @button click in the upwards or downwards * spin button arrow areas, usually leading to an increase or decrease of * spin button's value. * * Returns: wether all actions neccessary for the button click simulation were carried out successfully. * * Since: 2.14 **/ gboolean gtk_test_spin_button_click (GtkSpinButton *spinner, guint button, gboolean upwards) { GdkWindow *down_panel = NULL, *up_panel = NULL, *panel; gboolean b1res = FALSE, b2res = FALSE; _gtk_spin_button_get_panels (spinner, &down_panel, &up_panel); panel = (upwards) ? up_panel : down_panel; if (panel) { gint width = gdk_window_get_width (panel); b1res = gdk_test_simulate_button (panel, width - 1, 1, button, 0, GDK_BUTTON_PRESS); b2res = gdk_test_simulate_button (panel, width - 1, 1, button, 0, GDK_BUTTON_RELEASE); } return b1res && b2res; }