Commit 3ac4c76b authored by Matthias Clasen's avatar Matthias Clasen
Browse files

Merge branch 'disable-window-test' into 'master'

Disable window test

See merge request !1540
parents 6ec96d2e 89b537bd
Pipeline #162107 failed with stages
in 18 minutes and 36 seconds
......@@ -210,6 +210,7 @@
<file>search_entry.c</file>
<file>search_entry2.c</file>
<file>shortcuts.c</file>
<file>shortcut_triggers.c</file>
<file>sizegroup.c</file>
<file>sidebar.c</file>
<file>sliding_puzzle.c</file>
......
......@@ -140,17 +140,6 @@ update_value (GtkFontPlane *plane,
gtk_widget_queue_draw (widget);
}
static void
hold_action (GtkGestureLongPress *gesture,
gdouble x,
gdouble y,
GtkFontPlane *plane)
{
gboolean handled;
g_signal_emit_by_name (plane, "popup-menu", &handled);
}
static void
plane_drag_gesture_begin (GtkGestureDrag *gesture,
gdouble start_x,
......@@ -161,13 +150,6 @@ plane_drag_gesture_begin (GtkGestureDrag *gesture,
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
if (button == GDK_BUTTON_SECONDARY)
{
gboolean handled;
g_signal_emit_by_name (plane, "popup-menu", &handled);
}
if (button != GDK_BUTTON_PRIMARY)
{
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
......@@ -218,13 +200,6 @@ gtk_font_plane_init (GtkFontPlane *plane)
G_CALLBACK (plane_drag_gesture_end), plane);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
gtk_widget_add_controller (GTK_WIDGET (plane), GTK_EVENT_CONTROLLER (gesture));
gesture = gtk_gesture_long_press_new ();
g_signal_connect (gesture, "pressed",
G_CALLBACK (hold_action), plane);
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture),
TRUE);
gtk_widget_add_controller (GTK_WIDGET (plane), GTK_EVENT_CONTROLLER (gesture));
}
static void
......
......@@ -310,7 +310,6 @@ static const char *types[] =
"GtkIconView ",
"GtkCellRendererText ",
"GtkContainer ",
"GtkAccelGroup ",
"GtkPaned ",
"GtkPrintOperation ",
"GtkPrintContext ",
......
......@@ -62,6 +62,7 @@ demos = files([
'search_entry.c',
'search_entry2.c',
'shortcuts.c',
'shortcut_triggers.c',
'sidebar.c',
'sizegroup.c',
'sliding_puzzle.c',
......
/* Shortcuts
*
* GtkShortcut is the abstraction used by GTK to handle shortcuts from
* keyboard or other input devices.
*
* Shortcut triggers can be used to weave complex sequences of key
* presses into sophisticated mechanisms to activate shortcuts.
*
* This demo code shows creative ways to do that.
*/
#include <gtk/gtk.h>
static GtkWidget *window = NULL;
static gboolean
shortcut_activated (GtkWidget *widget,
GVariant *unused,
gpointer row)
{
g_print ("activated %s\n", gtk_label_get_label (row));
return TRUE;
}
static GtkShortcutTrigger *
create_ctrl_g (void)
{
return gtk_keyval_trigger_new (GDK_KEY_g, GDK_CONTROL_MASK);
}
static GtkShortcutTrigger *
create_x (void)
{
return gtk_keyval_trigger_new (GDK_KEY_x, 0);
}
struct {
const char *description;
GtkShortcutTrigger * (* create_trigger_func) (void);
} shortcuts[] = {
{ "Press Ctrl-G", create_ctrl_g },
{ "Press X", create_x },
};
GtkWidget *
do_shortcut_triggers (GtkWidget *do_widget)
{
guint i;
if (!window)
{
GtkWidget *list;
GtkEventController *controller;
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Shortcuts");
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
list = gtk_list_box_new ();
g_object_set (list, "margin", 6, NULL);
gtk_container_add (GTK_CONTAINER (window), list);
for (i = 0; i < G_N_ELEMENTS (shortcuts); i++)
{
GtkShortcut *shortcut;
GtkWidget *row;
row = gtk_label_new (shortcuts[i].description);
gtk_container_add (GTK_CONTAINER (list), row);
controller = gtk_shortcut_controller_new ();
gtk_shortcut_controller_set_scope (GTK_SHORTCUT_CONTROLLER (controller), GTK_SHORTCUT_SCOPE_GLOBAL);
gtk_widget_add_controller (row, controller);
shortcut = gtk_shortcut_new (shortcuts[i].create_trigger_func(),
gtk_callback_action_new (shortcut_activated, row, NULL));
gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), shortcut);
}
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
return window;
}
......@@ -160,47 +160,13 @@ check_solved (GtkWidget *grid)
}
static gboolean
puzzle_key_pressed (GtkEventControllerKey *controller,
guint keyval,
guint keycode,
GdkModifierType state,
GtkWidget *grid)
puzzle_key_pressed (GtkWidget *grid,
GVariant *args,
gpointer unused)
{
int dx, dy;
dx = 0;
dy = 0;
switch (keyval)
{
case GDK_KEY_KP_Left:
case GDK_KEY_Left:
/* left */
dx = -1;
break;
case GDK_KEY_KP_Up:
case GDK_KEY_Up:
/* up */
dy = -1;
break;
case GDK_KEY_KP_Right:
case GDK_KEY_Right:
/* right */
dx = 1;
break;
case GDK_KEY_KP_Down:
case GDK_KEY_Down:
/* down */
dy = 1;
break;
default:
/* We return FALSE here because we didn't handle the key that was pressed */
return FALSE;
}
g_variant_get (args, "(ii)", &dx, &dy);
if (!move_puzzle (grid, dx, dy))
{
......@@ -276,6 +242,24 @@ puzzle_button_pressed (GtkGestureClick *gesture,
}
}
static void
add_move_binding (GtkShortcutController *controller,
guint keyval,
guint kp_keyval,
int dx,
int dy)
{
GtkShortcut *shortcut;
shortcut = gtk_shortcut_new_with_arguments (
gtk_alternative_trigger_new (gtk_keyval_trigger_new (keyval, 0),
gtk_keyval_trigger_new (kp_keyval, 0)),
gtk_callback_action_new (puzzle_key_pressed, NULL, NULL),
"(ii)", dx, dy);
gtk_shortcut_controller_add_shortcut (controller, shortcut);
g_object_unref (shortcut);
}
static void
start_puzzle (GdkPaintable *paintable)
{
......@@ -298,12 +282,21 @@ start_puzzle (GdkPaintable *paintable)
aspect_ratio = 1.0;
gtk_aspect_frame_set (GTK_ASPECT_FRAME (frame), 0.5, 0.5, aspect_ratio, FALSE);
/* Add a key event controller so people can use the arrow
/* Add shortcuts so people can use the arrow
* keys to move the puzzle */
controller = gtk_event_controller_key_new ();
g_signal_connect (controller, "key-pressed",
G_CALLBACK (puzzle_key_pressed),
grid);
controller = gtk_shortcut_controller_new ();
add_move_binding (GTK_SHORTCUT_CONTROLLER (controller),
GDK_KEY_Left, GDK_KEY_KP_Left,
-1, 0);
add_move_binding (GTK_SHORTCUT_CONTROLLER (controller),
GDK_KEY_Right, GDK_KEY_KP_Right,
1, 0);
add_move_binding (GTK_SHORTCUT_CONTROLLER (controller),
GDK_KEY_Up, GDK_KEY_KP_Up,
0, -1);
add_move_binding (GTK_SHORTCUT_CONTROLLER (controller),
GDK_KEY_Down, GDK_KEY_KP_Down,
0, 1);
gtk_widget_add_controller (GTK_WIDGET (grid), controller);
controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ());
......
......@@ -336,6 +336,15 @@
<xi:include href="xml/gtkgesturezoom.xml" />
<xi:include href="xml/gtkgesturestylus.xml" />
<xi:include href="xml/gtkpadcontroller.xml" />
<xi:include href="xml/gtkshortcutcontroller.xml" />
</chapter>
<chapter>
<title>Keyboard shortcuts</title>
<xi:include href="xml/gtkshortcut.xml" />
<xi:include href="xml/gtkshortcuttrigger.xml" />
<xi:include href="xml/gtkshortcutaction.xml" />
<xi:include href="xml/gtkshortcutmanager.xml" />
</chapter>
<chapter>
......
......@@ -53,26 +53,6 @@ gtk_about_dialog_get_type
<SECTION>
<FILE>gtkaccelgroup</FILE>
<TITLE>Keyboard Accelerators</TITLE>
GtkAccelGroup
GtkAccelGroupClass
gtk_accel_group_new
GtkAccelFlags
gtk_accel_group_connect
gtk_accel_group_connect_by_path
GtkAccelGroupActivate
GtkAccelGroupFindFunc
gtk_accel_group_disconnect
gtk_accel_group_disconnect_key
gtk_accel_group_activate
gtk_accel_group_lock
gtk_accel_group_unlock
gtk_accel_group_get_is_locked
gtk_accel_group_from_accel_closure
gtk_accel_group_get_modifier_mask
gtk_accel_groups_activate
gtk_accel_groups_from_object
gtk_accel_group_find
GtkAccelKey
gtk_accelerator_valid
gtk_accelerator_parse
gtk_accelerator_name
......@@ -82,52 +62,6 @@ gtk_accelerator_name_with_keycode
gtk_accelerator_get_label_with_keycode
gtk_accelerator_set_default_mod_mask
gtk_accelerator_get_default_mod_mask
<SUBSECTION Standard>
GTK_TYPE_ACCEL_GROUP
GTK_ACCEL_GROUP
GTK_IS_ACCEL_GROUP
GTK_ACCEL_GROUP_CLASS
GTK_IS_ACCEL_GROUP_CLASS
GTK_ACCEL_GROUP_GET_CLASS
<SUBSECTION Private>
GTK_ACCEL_GROUP_GET_PRIVATE
GtkAccelGroupPrivate
GtkAccelGroupEntry
gtk_accel_group_query
gtk_accel_group_get_type
</SECTION>
<SECTION>
<FILE>gtkaccelmap</FILE>
<TITLE>Accelerator Maps</TITLE>
GtkAccelMap
GtkAccelMapForeach
gtk_accel_map_add_entry
gtk_accel_map_lookup_entry
gtk_accel_map_change_entry
gtk_accel_map_load
gtk_accel_map_save
gtk_accel_map_foreach
gtk_accel_map_load_fd
gtk_accel_map_save_fd
gtk_accel_map_load_scanner
gtk_accel_map_add_filter
gtk_accel_map_foreach_unfiltered
gtk_accel_map_get
gtk_accel_map_lock_path
gtk_accel_map_unlock_path
<SUBSECTION Standard>
GTK_ACCEL_MAP
GTK_TYPE_ACCEL_MAP
GTK_IS_ACCEL_MAP
GTK_ACCEL_MAP_CLASS
GTK_IS_ACCEL_MAP_CLASS
GTK_ACCEL_MAP_GET_CLASS
GtkAccelMapClass
<SUBSECTION Private>
gtk_accel_map_get_type
</SECTION>
<SECTION>
......@@ -135,10 +69,6 @@ gtk_accel_map_get_type
<TITLE>GtkAccelLabel</TITLE>
GtkAccelLabel
gtk_accel_label_new
gtk_accel_label_set_accel_closure
gtk_accel_label_get_accel_closure
gtk_accel_label_get_accel_widget
gtk_accel_label_set_accel_widget
gtk_accel_label_get_accel_width
gtk_accel_label_set_accel
gtk_accel_label_get_accel
......@@ -4034,10 +3964,9 @@ gtk_widget_add_tick_callback
gtk_widget_remove_tick_callback
gtk_widget_size_allocate
gtk_widget_allocate
gtk_widget_add_accelerator
gtk_widget_remove_accelerator
gtk_widget_set_accel_path
gtk_widget_list_accel_closures
gtk_widget_class_add_shortcut
gtk_widget_class_add_binding
gtk_widget_class_add_binding_signal
gtk_widget_can_activate_accel
gtk_widget_activate
gtk_widget_is_focus
......@@ -4253,8 +4182,6 @@ gtk_window_new
gtk_window_set_title
gtk_window_set_resizable
gtk_window_get_resizable
gtk_window_add_accel_group
gtk_window_remove_accel_group
gtk_window_set_modal
gtk_window_set_default_size
gtk_window_set_hide_on_close
......@@ -4266,11 +4193,6 @@ gtk_window_is_active
gtk_window_is_maximized
gtk_window_get_toplevels
gtk_window_list_toplevels
gtk_window_add_mnemonic
gtk_window_remove_mnemonic
gtk_window_mnemonic_activate
gtk_window_activate_key
gtk_window_propagate_key_event
gtk_window_get_focus
gtk_window_set_focus
gtk_window_get_default_widget
......@@ -4291,7 +4213,6 @@ gtk_window_set_keep_above
gtk_window_set_keep_below
gtk_window_set_decorated
gtk_window_set_deletable
gtk_window_set_mnemonic_modifier
gtk_window_set_accept_focus
gtk_window_set_focus_on_map
gtk_window_set_startup_id
......@@ -4301,7 +4222,6 @@ gtk_window_get_default_icon_name
gtk_window_get_default_size
gtk_window_get_destroy_with_parent
gtk_window_get_icon_name
gtk_window_get_mnemonic_modifier
gtk_window_get_modal
gtk_window_get_size
gtk_window_get_title
......@@ -4617,26 +4537,6 @@ gtk_css_provider_error_quark
gtk_css_section_get_type
</SECTION>
<SECTION>
<FILE>gtkbindings</FILE>
<TITLE>Bindings</TITLE>
GtkBindingSet
gtk_binding_set_new
gtk_binding_set_by_class
gtk_binding_set_find
gtk_bindings_activate
gtk_bindings_activate_event
gtk_binding_set_activate
gtk_binding_entry_add_action
gtk_binding_entry_add_action_variant
GtkBindingCallback
gtk_binding_entry_add_callback
gtk_binding_entry_add_signal
gtk_binding_entry_add_signal_from_string
gtk_binding_entry_skip
gtk_binding_entry_remove
</SECTION>
<SECTION>
<FILE>gtkenums</FILE>
<TITLE>Standard Enumerations</TITLE>
......@@ -6061,6 +5961,144 @@ GTK_EVENT_CONTROLLER_MOTION_GET_CLASS
gtk_event_controller_motion_get_type
</SECTION>
<SECTION>
<FILE>gtkshortcuttrigger</FILE>
<TITLE>GtkShortcutTrigger</TITLE>
GtkShortcutTrigger
gtk_shortcut_trigger_ref
gtk_shortcut_trigger_unref
GtkShortcutTriggerType
gtk_shortcut_trigger_get_trigger_type
gtk_shortcut_trigger_parse_string
gtk_shortcut_trigger_trigger
gtk_shortcut_trigger_hash
gtk_shortcut_trigger_equal
gtk_shortcut_trigger_compare
gtk_shortcut_trigger_to_string
gtk_shortcut_trigger_print
gtk_shortcut_trigger_to_label
gtk_shortcut_trigger_print_label
<SUBSECTION>
gtk_keyval_trigger_new
gtk_keyval_trigger_get_modifiers
gtk_keyval_trigger_get_keyval
<SUBSECTION>
gtk_mnemonic_trigger_new
gtk_mnemonic_trigger_get_keyval
<SUBSECTION Private>
gtk_shortcut_trigger_get_type
</SECTION>
<SECTION>
<FILE>gtkshortcutaction</FILE>
<TITLE>GtkShortcutAction</TITLE>
GtkShortcutAction
gtk_shortcut_action_ref
gtk_shortcut_action_unref
GtkShortcutActionType
gtk_shortcut_action_get_action_type
gtk_shortcut_action_to_string
gtk_shortcut_action_print
gtk_shortcut_action_activate
<SUBSECTION>
gtk_nothing_action_new
<SUBSECTION>
gtk_callback_action_new
<SUBSECTION>
gtk_mnemonic_action_new
<SUBSECTION>
gtk_activate_action_new
<SUBSECTION>
gtk_signal_action_new
gtk_signal_action_get_signal_name
<SUBSECTION>
gtk_action_action_new
gtk_action_action_get_name
<SUBSECTION>
gtk_gaction_action_new
gtk_gaction_action_get_gaction
<SUBSECTION Private>
gtk_shortcut_action_get_type
</SECTION>
<SECTION>
<FILE>gtkshortcut</FILE>
<TITLE>GtkShortcut</TITLE>
GtkShortcut
gtk_shortcut_new
gtk_shortcut_new_with_arguments
gtk_shortcut_get_trigger
gtk_shortcut_set_trigger
gtk_shortcut_get_action
gtk_shortcut_set_action
gtk_shortcut_get_arguments
gtk_shortcut_set_arguments
<SUBSECTION Standard>
GTK_TYPE_SHORTCUT
GTK_SHORTCUT
GTK_SHORTCUT_CLASS
GTK_IS_SHORTCUT
GTK_IS_SHORTCUT_CLASS
GTK_SHORTCUT_GET_CLASS
<SUBSECTION Private>
gtk_shortcut_get_type
</SECTION>
<SECTION>
<FILE>gtkshortcutmanager</FILE>
<TITLE>GtkShortcutManager</TITLE>
GtkShortcutManager
GtkShortcutManagerInterface
</SECTION>
<SECTION>
<FILE>gtkshortcutcontroller</FILE>
<TITLE>GtkShortcutController</TITLE>
GtkShortcutController
gtk_shortcut_controller_new
gtk_shortcut_controller_new_with_model
GtkShortcutScope
GtkShortcutManager
GtkShortcutManagerInterface
gtk_shortcut_controller_set_mnemonics_modifiers
gtk_shortcut_controller_get_mnemonics_modifiers
gtk_shortcut_controller_set_scope
gtk_shortcut_controller_get_scope
gtk_shortcut_controller_add_shortcut
gtk_shortcut_controller_remove_shortcut
<SUBSECTION Standard>
GTK_TYPE_SHORTCUT_CONTROLLER
GTK_SHORTCUT_CONTROLLER
GTK_SHORTCUT_CONTROLLER_CLASS
GTK_IS_SHORTCUT_CONTROLLER
GTK_IS_SHORTCUT_CONTROLLER_CLASS
GTK_SHORTCUT_CONTROLLER_GET_CLASS
GTK_TYPE_SHORTCUT_MANAGER
GTK_SHORTCUT_MANAGER
GTK_SHORTCUT_MANAGER_CLASS
GTK_IS_SHORTCUT_MANAGER
GTK_IS_SHORTCUT_MANAGER_CLASS
GTK_SHORTCUT_MANAGER_GET_CLASS
<SUBSECTION Private>
gtk_shortcut_controller_get_type
gtk_shortcut_manager_get_type
</SECTION>
<SECTION>
<FILE>gtkeventcontrollerkey</FILE>
<TITLE>GtkEventControllerKey</TITLE>
......
......@@ -2,9 +2,7 @@
#include <gtk/gtkunixprint.h>
gtk_about_dialog_get_type
gtk_accel_group_get_type
gtk_accel_label_get_type
gtk_accel_map_get_type
gtk_accessible_get_type
gtk_actionable_get_type
gtk_action_bar_get_type
......@@ -165,7 +163,10 @@ gtk_search_entry_get_type
gtk_selection_model_get_type
gtk_separator_get_type
gtk_settings_get_type
gtk_shortcut_get_type
gtk_shortcut_controller_get_type
gtk_shortcut_label_get_type
gtk_shortcut_manager_get_type
gtk_shortcuts_window_get_type
gtk_shortcuts_section_get_type
gtk_shortcuts_group_get_type
......
......@@ -281,26 +281,20 @@ create_accel_label (void)
{
WidgetInfo *info;
GtkWidget *widget, *button, *box;
GtkAccelGroup *accel_group;
widget = gtk_accel_label_new ("Accel Label");
button = gtk_button_new_with_label ("Quit");
gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (widget), button);
gtk_widget_hide (button);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (box), widget);
gtk_container_add (GTK_CONTAINER (box), button);