mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 13:11:13 +00:00
Merge branch 'disable-window-test' into 'master'
Disable window test See merge request GNOME/gtk!1540
This commit is contained in:
commit
3ac4c76b18
@ -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',
|
||||
|
91
demos/gtk-demo/shortcut_triggers.c
Normal file
91
demos/gtk-demo/shortcut_triggers.c
Normal file
@ -0,0 +1,91 @@
|
||||
/* 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);
|
||||
|
||||
gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (widget), button);
|
||||
accel_group = gtk_accel_group_new();
|
||||
gtk_accel_label_set_accel (GTK_ACCEL_LABEL (widget), GDK_KEY_Q, GDK_CONTROL_MASK);
|
||||
|
||||
info = new_widget_info ("accel-label", box, SMALL);
|
||||
|
||||
gtk_widget_add_accelerator (button, "activate", accel_group, GDK_KEY_Q, GDK_CONTROL_MASK,
|
||||
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ const GDK_CROSSING_GRAB = 1;
|
||||
const GDK_CROSSING_UNGRAB = 2;
|
||||
|
||||
// GdkModifierType
|
||||
const GDK_SHIFT_MASK = 1 << 0;
|
||||
const GDK_SHIFT_MASK = 1 << 0;
|
||||
const GDK_LOCK_MASK = 1 << 1;
|
||||
const GDK_CONTROL_MASK = 1 << 2;
|
||||
const GDK_MOD1_MASK = 1 << 3;
|
||||
@ -91,7 +91,6 @@ const GDK_BUTTON5_MASK = 1 << 12;
|
||||
const GDK_SUPER_MASK = 1 << 26;
|
||||
const GDK_HYPER_MASK = 1 << 27;
|
||||
const GDK_META_MASK = 1 << 28;
|
||||
const GDK_RELEASE_MASK = 1 << 30;
|
||||
|
||||
|
||||
var useDataUrls = window.location.search.includes("datauri");
|
||||
|
@ -232,8 +232,7 @@ typedef enum
|
||||
* @GDK_HYPER_MASK: the Hyper modifier
|
||||
* @GDK_META_MASK: the Meta modifier
|
||||
* @GDK_MODIFIER_RESERVED_29_MASK: A reserved bit flag; do not use in your own code
|
||||
* @GDK_RELEASE_MASK: not used in GDK itself. GTK uses it to differentiate
|
||||
* between (keyval, modifiers) pairs from key press and release events.
|
||||
* @GDK_MODIFIER_RESERVED_30_MASK: A reserved bit flag; do not use in your own code
|
||||
* @GDK_MODIFIER_MASK: a mask covering all modifier types.
|
||||
*
|
||||
* A set of bit-flags to indicate the state of modifier keys and mouse buttons
|
||||
@ -294,12 +293,11 @@ typedef enum
|
||||
GDK_META_MASK = 1 << 28,
|
||||
|
||||
GDK_MODIFIER_RESERVED_29_MASK = 1 << 29,
|
||||
|
||||
GDK_RELEASE_MASK = 1 << 30,
|
||||
GDK_MODIFIER_RESERVED_30_MASK = 1 << 30,
|
||||
|
||||
/* Combination of GDK_SHIFT_MASK..GDK_BUTTON5_MASK + GDK_SUPER_MASK
|
||||
+ GDK_HYPER_MASK + GDK_META_MASK + GDK_RELEASE_MASK */
|
||||
GDK_MODIFIER_MASK = 0x5c001fff
|
||||
+ GDK_HYPER_MASK + GDK_META_MASK */
|
||||
GDK_MODIFIER_MASK = 0x1c001fff
|
||||
} GdkModifierType;
|
||||
|
||||
/**
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include <gtk/gtkaboutdialog.h>
|
||||
#include <gtk/gtkaccelgroup.h>
|
||||
#include <gtk/gtkaccellabel.h>
|
||||
#include <gtk/gtkaccelmap.h>
|
||||
#include <gtk/gtkaccessible.h>
|
||||
#include <gtk/gtkactionable.h>
|
||||
#include <gtk/gtkactionbar.h>
|
||||
@ -49,7 +48,6 @@
|
||||
#include <gtk/gtkassistant.h>
|
||||
#include <gtk/gtkbin.h>
|
||||
#include <gtk/gtkbinlayout.h>
|
||||
#include <gtk/gtkbindings.h>
|
||||
#include <gtk/gtkborder.h>
|
||||
#include <gtk/gtkboxlayout.h>
|
||||
#include <gtk/gtkbox.h>
|
||||
@ -198,11 +196,16 @@
|
||||
#include <gtk/gtkselectionmodel.h>
|
||||
#include <gtk/gtkseparator.h>
|
||||
#include <gtk/gtksettings.h>
|
||||
#include <gtk/gtkshortcut.h>
|
||||
#include <gtk/gtkshortcutaction.h>
|
||||
#include <gtk/gtkshortcutcontroller.h>
|
||||
#include <gtk/gtkshortcutlabel.h>
|
||||
#include <gtk/gtkshortcutmanager.h>
|
||||
#include <gtk/gtkshortcutsgroup.h>
|
||||
#include <gtk/gtkshortcutssection.h>
|
||||
#include <gtk/gtkshortcutsshortcut.h>
|
||||
#include <gtk/gtkshortcutswindow.h>
|
||||
#include <gtk/gtkshortcuttrigger.h>
|
||||
#include <gtk/gtkshow.h>
|
||||
#include <gtk/gtksingleselection.h>
|
||||
#include <gtk/gtkslicelistmodel.h>
|
||||
|
1257
gtk/gtkaccelgroup.c
1257
gtk/gtkaccelgroup.c
File diff suppressed because it is too large
Load Diff
@ -36,172 +36,17 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
/* --- type macros --- */
|
||||
#define GTK_TYPE_ACCEL_GROUP (gtk_accel_group_get_type ())
|
||||
#define GTK_ACCEL_GROUP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_ACCEL_GROUP, GtkAccelGroup))
|
||||
#define GTK_ACCEL_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ACCEL_GROUP, GtkAccelGroupClass))
|
||||
#define GTK_IS_ACCEL_GROUP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_ACCEL_GROUP))
|
||||
#define GTK_IS_ACCEL_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ACCEL_GROUP))
|
||||
#define GTK_ACCEL_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ACCEL_GROUP, GtkAccelGroupClass))
|
||||
|
||||
|
||||
/* --- accel flags --- */
|
||||
/**
|
||||
* GtkAccelFlags:
|
||||
* @GTK_ACCEL_VISIBLE: Accelerator is visible
|
||||
* @GTK_ACCEL_LOCKED: Accelerator not removable
|
||||
* @GTK_ACCEL_MASK: Mask
|
||||
*
|
||||
* Accelerator flags used with gtk_accel_group_connect().
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GTK_ACCEL_VISIBLE = 1 << 0,
|
||||
GTK_ACCEL_LOCKED = 1 << 1,
|
||||
GTK_ACCEL_MASK = 0x07
|
||||
} GtkAccelFlags;
|
||||
|
||||
|
||||
/* --- typedefs & structures --- */
|
||||
typedef struct _GtkAccelGroup GtkAccelGroup;
|
||||
typedef struct _GtkAccelGroupClass GtkAccelGroupClass;
|
||||
typedef struct _GtkAccelGroupPrivate GtkAccelGroupPrivate;
|
||||
typedef struct _GtkAccelKey GtkAccelKey;
|
||||
typedef struct _GtkAccelGroupEntry GtkAccelGroupEntry;
|
||||
typedef gboolean (*GtkAccelGroupActivate) (GtkAccelGroup *accel_group,
|
||||
GObject *acceleratable,
|
||||
guint keyval,
|
||||
GdkModifierType modifier);
|
||||
|
||||
/**
|
||||
* GtkAccelGroupFindFunc:
|
||||
* @key:
|
||||
* @closure:
|
||||
* @data: (closure):
|
||||
*/
|
||||
typedef gboolean (*GtkAccelGroupFindFunc) (GtkAccelKey *key,
|
||||
GClosure *closure,
|
||||
gpointer data);
|
||||
|
||||
/**
|
||||
* GtkAccelGroup:
|
||||
*
|
||||
* An object representing and maintaining a group of accelerators.
|
||||
*/
|
||||
struct _GtkAccelGroup
|
||||
{
|
||||
GObject parent;
|
||||
GtkAccelGroupPrivate *priv;
|
||||
};
|
||||
|
||||
/**
|
||||
* GtkAccelGroupClass:
|
||||
* @parent_class: The parent class.
|
||||
* @accel_changed: Signal emitted when an entry is added to or removed
|
||||
* from the accel group.
|
||||
*/
|
||||
struct _GtkAccelGroupClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
/*< public >*/
|
||||
|
||||
void (*accel_changed) (GtkAccelGroup *accel_group,
|
||||
guint keyval,
|
||||
GdkModifierType modifier,
|
||||
GClosure *accel_closure);
|
||||
|
||||
/*< private >*/
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
void (*_gtk_reserved3) (void);
|
||||
void (*_gtk_reserved4) (void);
|
||||
};
|
||||
|
||||
/**
|
||||
* GtkAccelKey:
|
||||
* @accel_key: The accelerator keyval
|
||||
* @accel_mods:The accelerator modifiers
|
||||
* @accel_flags: The accelerator flags
|
||||
*/
|
||||
struct _GtkAccelKey
|
||||
{
|
||||
guint accel_key;
|
||||
GdkModifierType accel_mods;
|
||||
guint accel_flags : 16;
|
||||
};
|
||||
|
||||
|
||||
/* -- Accelerator Groups --- */
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_accel_group_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkAccelGroup* gtk_accel_group_new (void);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_accel_group_get_is_locked (GtkAccelGroup *accel_group);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkModifierType
|
||||
gtk_accel_group_get_modifier_mask (GtkAccelGroup *accel_group);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accel_group_lock (GtkAccelGroup *accel_group);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accel_group_unlock (GtkAccelGroup *accel_group);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accel_group_connect (GtkAccelGroup *accel_group,
|
||||
guint accel_key,
|
||||
GdkModifierType accel_mods,
|
||||
GtkAccelFlags accel_flags,
|
||||
GClosure *closure);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accel_group_connect_by_path (GtkAccelGroup *accel_group,
|
||||
const gchar *accel_path,
|
||||
GClosure *closure);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_accel_group_disconnect (GtkAccelGroup *accel_group,
|
||||
GClosure *closure);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_accel_group_disconnect_key (GtkAccelGroup *accel_group,
|
||||
guint accel_key,
|
||||
GdkModifierType accel_mods);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_accel_group_activate (GtkAccelGroup *accel_group,
|
||||
GQuark accel_quark,
|
||||
GObject *acceleratable,
|
||||
guint accel_key,
|
||||
GdkModifierType accel_mods);
|
||||
|
||||
|
||||
/* --- GtkActivatable glue --- */
|
||||
void _gtk_accel_group_attach (GtkAccelGroup *accel_group,
|
||||
GObject *object);
|
||||
void _gtk_accel_group_detach (GtkAccelGroup *accel_group,
|
||||
GObject *object);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_accel_groups_activate (GObject *object,
|
||||
guint accel_key,
|
||||
GdkModifierType accel_mods);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GSList* gtk_accel_groups_from_object (GObject *object);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkAccelKey* gtk_accel_group_find (GtkAccelGroup *accel_group,
|
||||
GtkAccelGroupFindFunc find_func,
|
||||
gpointer data);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkAccelGroup* gtk_accel_group_from_accel_closure (GClosure *closure);
|
||||
|
||||
|
||||
/* --- Accelerators--- */
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_accelerator_valid (guint keyval,
|
||||
GdkModifierType modifiers) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accelerator_parse (const gchar *accelerator,
|
||||
gboolean gtk_accelerator_parse (const gchar *accelerator,
|
||||
guint *accelerator_key,
|
||||
GdkModifierType *accelerator_mods);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accelerator_parse_with_keycode (const gchar *accelerator,
|
||||
gboolean gtk_accelerator_parse_with_keycode (const gchar *accelerator,
|
||||
GdkDisplay *display,
|
||||
guint *accelerator_key,
|
||||
guint **accelerator_codes,
|
||||
GdkModifierType *accelerator_mods);
|
||||
@ -227,21 +72,6 @@ GDK_AVAILABLE_IN_ALL
|
||||
GdkModifierType
|
||||
gtk_accelerator_get_default_mod_mask (void);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkAccelGroupEntry* gtk_accel_group_query (GtkAccelGroup *accel_group,
|
||||
guint accel_key,
|
||||
GdkModifierType accel_mods,
|
||||
guint *n_entries);
|
||||
|
||||
struct _GtkAccelGroupEntry
|
||||
{
|
||||
GtkAccelKey key;
|
||||
GClosure *closure;
|
||||
GQuark accel_path_quark;
|
||||
};
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkAccelGroup, g_object_unref)
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_ACCEL_GROUP_H__ */
|
||||
|
@ -25,19 +25,9 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
struct _GtkAccelGroupPrivate
|
||||
{
|
||||
guint lock_count;
|
||||
GdkModifierType modifier_mask;
|
||||
GSList *acceleratables;
|
||||
guint n_accels;
|
||||
GtkAccelGroupEntry *priv_accels;
|
||||
};
|
||||
|
||||
void _gtk_accel_group_reconnect (GtkAccelGroup *accel_group,
|
||||
GQuark accel_path_quark);
|
||||
GSList* _gtk_accel_group_get_accelerables (GtkAccelGroup *accel_group);
|
||||
|
||||
void gtk_accelerator_print_label (GString *gstring,
|
||||
guint accelerator_key,
|
||||
GdkModifierType accelerator_mods);
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_ACCEL_GROUP_PRIVATE_H__ */
|
||||
|
@ -29,9 +29,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "gtklabel.h"
|
||||
#include "gtkaccellabel.h"
|
||||
#include "gtkaccellabelprivate.h"
|
||||
#include "gtkaccelmap.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkprivate.h"
|
||||
@ -70,7 +68,6 @@
|
||||
* set (see #GtkAccelFlags).
|
||||
* A #GtkAccelLabel can display multiple accelerators and even signal names,
|
||||
* though it is almost always used to display just one accelerator key.
|
||||
* ]|
|
||||
*
|
||||
* # CSS nodes
|
||||
*
|
||||
@ -86,8 +83,6 @@
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_ACCEL_CLOSURE,
|
||||
PROP_ACCEL_WIDGET,
|
||||
PROP_LABEL,
|
||||
PROP_USE_UNDERLINE,
|
||||
LAST_PROP
|
||||
@ -114,10 +109,6 @@ struct _GtkAccelLabelPrivate
|
||||
GtkWidget *text_label;
|
||||
GtkWidget *accel_label;
|
||||
|
||||
GtkWidget *accel_widget; /* done */
|
||||
GClosure *accel_closure; /* has set function */
|
||||
GtkAccelGroup *accel_group; /* set by set_accel_closure() */
|
||||
|
||||
guint accel_key; /* manual accel key specification if != 0 */
|
||||
GdkModifierType accel_mods;
|
||||
};
|
||||
@ -132,7 +123,6 @@ static void gtk_accel_label_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_accel_label_destroy (GtkWidget *widget);
|
||||
static void gtk_accel_label_finalize (GObject *object);
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkAccelLabel, gtk_accel_label, GTK_TYPE_WIDGET)
|
||||
@ -147,56 +137,8 @@ gtk_accel_label_class_init (GtkAccelLabelClass *class)
|
||||
gobject_class->set_property = gtk_accel_label_set_property;
|
||||
gobject_class->get_property = gtk_accel_label_get_property;
|
||||
|
||||
widget_class->destroy = gtk_accel_label_destroy;
|
||||
|
||||
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_ACCEL_LABEL);
|
||||
|
||||
#ifndef GDK_WINDOWING_QUARTZ
|
||||
/* This is the text that should appear next to menu accelerators
|
||||
* that use the shift key. If the text on this key isn't typically
|
||||
* translated on keyboards used for your language, don't translate
|
||||
* this.
|
||||
*/
|
||||
class->mod_name_shift = g_strdup (C_("keyboard label", "Shift"));
|
||||
/* This is the text that should appear next to menu accelerators
|
||||
* that use the control key. If the text on this key isn't typically
|
||||
* translated on keyboards used for your language, don't translate
|
||||
* this.
|
||||
*/
|
||||
class->mod_name_control = g_strdup (C_("keyboard label", "Ctrl"));
|
||||
/* This is the text that should appear next to menu accelerators
|
||||
* that use the alt key. If the text on this key isn't typically
|
||||
* translated on keyboards used for your language, don't translate
|
||||
* this.
|
||||
*/
|
||||
class->mod_name_alt = g_strdup (C_("keyboard label", "Alt"));
|
||||
class->mod_separator = g_strdup ("+");
|
||||
#else /* GDK_WINDOWING_QUARTZ */
|
||||
|
||||
/* U+21E7 UPWARDS WHITE ARROW */
|
||||
class->mod_name_shift = g_strdup ("\xe2\x87\xa7");
|
||||
/* U+2303 UP ARROWHEAD */
|
||||
class->mod_name_control = g_strdup ("\xe2\x8c\x83");
|
||||
/* U+2325 OPTION KEY */
|
||||
class->mod_name_alt = g_strdup ("\xe2\x8c\xa5");
|
||||
class->mod_separator = g_strdup ("");
|
||||
|
||||
#endif /* GDK_WINDOWING_QUARTZ */
|
||||
|
||||
props[PROP_ACCEL_CLOSURE] =
|
||||
g_param_spec_boxed ("accel-closure",
|
||||
P_("Accelerator Closure"),
|
||||
P_("The closure to be monitored for accelerator changes"),
|
||||
G_TYPE_CLOSURE,
|
||||
GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
props[PROP_ACCEL_WIDGET] =
|
||||
g_param_spec_object ("accel-widget",
|
||||
P_("Accelerator Widget"),
|
||||
P_("The widget to be monitored for accelerator changes"),
|
||||
GTK_TYPE_WIDGET,
|
||||
GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
props[PROP_LABEL] =
|
||||
g_param_spec_string ("label",
|
||||
P_("Label"),
|
||||
@ -229,12 +171,6 @@ gtk_accel_label_set_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ACCEL_CLOSURE:
|
||||
gtk_accel_label_set_accel_closure (accel_label, g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_ACCEL_WIDGET:
|
||||
gtk_accel_label_set_accel_widget (accel_label, g_value_get_object (value));
|
||||
break;
|
||||
case PROP_LABEL:
|
||||
gtk_accel_label_set_label (accel_label, g_value_get_string (value));
|
||||
break;
|
||||
@ -254,16 +190,9 @@ gtk_accel_label_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkAccelLabel *accel_label = GTK_ACCEL_LABEL (object);
|
||||
GtkAccelLabelPrivate *priv = gtk_accel_label_get_instance_private (accel_label);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ACCEL_CLOSURE:
|
||||
g_value_set_boxed (value, priv->accel_closure);
|
||||
break;
|
||||
case PROP_ACCEL_WIDGET:
|
||||
g_value_set_object (value, priv->accel_widget);
|
||||
break;
|
||||
case PROP_LABEL:
|
||||
g_value_set_string (value, gtk_accel_label_get_label (accel_label));
|
||||
break;
|
||||
@ -281,10 +210,6 @@ gtk_accel_label_init (GtkAccelLabel *accel_label)
|
||||
{
|
||||
GtkAccelLabelPrivate *priv = gtk_accel_label_get_instance_private (accel_label);
|
||||
|
||||
priv->accel_widget = NULL;
|
||||
priv->accel_closure = NULL;
|
||||
priv->accel_group = NULL;
|
||||
|
||||
priv->text_label = gtk_label_new ("");
|
||||
gtk_widget_set_hexpand (priv->text_label, TRUE);
|
||||
gtk_label_set_xalign (GTK_LABEL (priv->text_label), 0.0f);
|
||||
@ -317,17 +242,6 @@ gtk_accel_label_new (const gchar *string)
|
||||
return GTK_WIDGET (accel_label);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_accel_label_destroy (GtkWidget *widget)
|
||||
{
|
||||
GtkAccelLabel *accel_label = GTK_ACCEL_LABEL (widget);
|
||||
|
||||
gtk_accel_label_set_accel_widget (accel_label, NULL);
|
||||
gtk_accel_label_set_accel_closure (accel_label, NULL);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_accel_label_parent_class)->destroy (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_accel_label_finalize (GObject *object)
|
||||
{
|
||||
@ -340,26 +254,6 @@ gtk_accel_label_finalize (GObject *object)
|
||||
G_OBJECT_CLASS (gtk_accel_label_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_accel_label_get_accel_widget:
|
||||
* @accel_label: a #GtkAccelLabel
|
||||
*
|
||||
* Fetches the widget monitored by this accelerator label. See
|
||||
* gtk_accel_label_set_accel_widget().
|
||||
*
|
||||
* Returns: (nullable) (transfer none): the widget monitored by @accel_label,
|
||||
* or %NULL if it is not monitoring a widget.
|
||||
**/
|
||||
GtkWidget *
|
||||
gtk_accel_label_get_accel_widget (GtkAccelLabel *accel_label)
|
||||
{
|
||||
GtkAccelLabelPrivate *priv = gtk_accel_label_get_instance_private (accel_label);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_ACCEL_LABEL (accel_label), NULL);
|
||||
|
||||
return priv->accel_widget;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_accel_label_get_accel_width:
|
||||
* @accel_label: a #GtkAccelLabel.
|
||||
@ -384,463 +278,6 @@ gtk_accel_label_get_accel_width (GtkAccelLabel *accel_label)
|
||||
return min;
|
||||
}
|
||||
|
||||
static void
|
||||
refetch_widget_accel_closure (GtkAccelLabel *accel_label)
|
||||
{
|
||||
GtkAccelLabelPrivate *priv = gtk_accel_label_get_instance_private (accel_label);
|
||||
GClosure *closure = NULL;
|
||||
GList *clist, *list;
|
||||
|
||||
g_return_if_fail (GTK_IS_ACCEL_LABEL (accel_label));
|
||||
g_return_if_fail (GTK_IS_WIDGET (priv->accel_widget));
|
||||
|
||||
clist = gtk_widget_list_accel_closures (priv->accel_widget);
|
||||
for (list = clist; list; list = list->next)
|
||||
{
|
||||
/* we just take the first closure used */
|
||||
closure = list->data;
|
||||
break;
|
||||
}
|
||||
|
||||
g_list_free (clist);
|
||||
gtk_accel_label_set_accel_closure (accel_label, closure);
|
||||
}
|
||||
|
||||
static void
|
||||
accel_widget_weak_ref_cb (GtkAccelLabel *accel_label,
|
||||
GtkWidget *old_accel_widget)
|
||||
{
|
||||
GtkAccelLabelPrivate *priv = gtk_accel_label_get_instance_private (accel_label);
|
||||
|
||||
g_return_if_fail (GTK_IS_ACCEL_LABEL (accel_label));
|
||||
g_return_if_fail (GTK_IS_WIDGET (priv->accel_widget));
|
||||
|
||||
g_signal_handlers_disconnect_by_func (priv->accel_widget,
|
||||
refetch_widget_accel_closure,
|
||||
accel_label);
|
||||
priv->accel_widget = NULL;
|
||||
g_object_notify_by_pspec (G_OBJECT (accel_label), props[PROP_ACCEL_WIDGET]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_accel_label_set_accel_widget:
|
||||
* @accel_label: a #GtkAccelLabel
|
||||
* @accel_widget: (nullable): the widget to be monitored, or %NULL
|
||||
*
|
||||
* Sets the widget to be monitored by this accelerator label. Passing %NULL for
|
||||
* @accel_widget will dissociate @accel_label from its current widget, if any.
|
||||
*/
|
||||
void
|
||||
gtk_accel_label_set_accel_widget (GtkAccelLabel *accel_label,
|
||||
GtkWidget *accel_widget)
|
||||
{
|
||||
GtkAccelLabelPrivate *priv = gtk_accel_label_get_instance_private (accel_label);
|
||||
|
||||
g_return_if_fail (GTK_IS_ACCEL_LABEL (accel_label));
|
||||
|
||||
if (accel_widget)
|
||||
g_return_if_fail (GTK_IS_WIDGET (accel_widget));
|
||||
|
||||
if (accel_widget != priv->accel_widget)
|
||||
{
|
||||
if (priv->accel_widget)
|
||||
{
|
||||
gtk_accel_label_set_accel_closure (accel_label, NULL);
|
||||
g_signal_handlers_disconnect_by_func (priv->accel_widget,
|
||||
refetch_widget_accel_closure,
|
||||
accel_label);
|
||||
g_object_weak_unref (G_OBJECT (priv->accel_widget),
|
||||
(GWeakNotify) accel_widget_weak_ref_cb, accel_label);
|
||||
}
|
||||
|
||||
priv->accel_widget = accel_widget;
|
||||
|
||||
if (priv->accel_widget)
|
||||
{
|
||||
g_object_weak_ref (G_OBJECT (priv->accel_widget),
|
||||
(GWeakNotify) accel_widget_weak_ref_cb, accel_label);
|
||||
g_signal_connect_object (priv->accel_widget, "accel-closures-changed",
|
||||
G_CALLBACK (refetch_widget_accel_closure),
|
||||
accel_label, G_CONNECT_SWAPPED);
|
||||
refetch_widget_accel_closure (accel_label);
|
||||
}
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (accel_label), props[PROP_ACCEL_WIDGET]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_accel_label_reset (GtkAccelLabel *accel_label)
|
||||
{
|
||||
gtk_accel_label_refetch (accel_label);
|
||||
}
|
||||
|
||||
static void
|
||||
check_accel_changed (GtkAccelGroup *accel_group,
|
||||
guint keyval,
|
||||
GdkModifierType modifier,
|
||||
GClosure *accel_closure,
|
||||
GtkAccelLabel *accel_label)
|
||||
{
|
||||
GtkAccelLabelPrivate *priv = gtk_accel_label_get_instance_private (accel_label);
|
||||
|
||||
if (accel_closure == priv->accel_closure)
|
||||
gtk_accel_label_reset (accel_label);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_accel_label_set_accel_closure:
|
||||
* @accel_label: a #GtkAccelLabel
|
||||
* @accel_closure: (nullable): the closure to monitor for accelerator changes,
|
||||
* or %NULL
|
||||
*
|
||||
* Sets the closure to be monitored by this accelerator label. The closure
|
||||
* must be connected to an accelerator group; see gtk_accel_group_connect().
|
||||
* Passing %NULL for @accel_closure will dissociate @accel_label from its
|
||||
* current closure, if any.
|
||||
**/
|
||||
void
|
||||
gtk_accel_label_set_accel_closure (GtkAccelLabel *accel_label,
|
||||
GClosure *accel_closure)
|
||||
{
|
||||
GtkAccelLabelPrivate *priv = gtk_accel_label_get_instance_private (accel_label);
|
||||
|
||||
g_return_if_fail (GTK_IS_ACCEL_LABEL (accel_label));
|
||||
|
||||
if (accel_closure)
|
||||
g_return_if_fail (gtk_accel_group_from_accel_closure (accel_closure) != NULL);
|
||||
|
||||
if (accel_closure != priv->accel_closure)
|
||||
{
|
||||
if (priv->accel_closure)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (priv->accel_group,
|
||||
check_accel_changed,
|
||||
accel_label);
|
||||
priv->accel_group = NULL;
|
||||
g_closure_unref (priv->accel_closure);
|
||||
}
|
||||
|
||||
priv->accel_closure = accel_closure;
|
||||
|
||||
if (priv->accel_closure)
|
||||
{
|
||||
g_closure_ref (priv->accel_closure);
|
||||
priv->accel_group = gtk_accel_group_from_accel_closure (accel_closure);
|
||||
g_signal_connect_object (priv->accel_group, "accel-changed", G_CALLBACK (check_accel_changed),
|
||||
accel_label, 0);
|
||||
}
|
||||
|
||||
gtk_accel_label_reset (accel_label);
|
||||
g_object_notify_by_pspec (G_OBJECT (accel_label), props[PROP_ACCEL_CLOSURE]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_accel_label_get_accel_closure:
|
||||
* @accel_label: a #GtkAccelLabel
|
||||
*
|
||||
* Fetches the closure monitored by this accelerator label. See
|
||||
* gtk_accel_label_set_accel_closure().
|
||||
*
|
||||
* Returns: (nullable) (transfer none): the closure monitored by @accel_label,
|
||||
* or %NULL if it is not monitoring a closure.
|
||||
*/
|
||||
GClosure *
|
||||
gtk_accel_label_get_accel_closure (GtkAccelLabel *accel_label)
|
||||
{
|
||||
GtkAccelLabelPrivate *priv = gtk_accel_label_get_instance_private (accel_label);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_ACCEL_LABEL (accel_label), NULL);
|
||||
|
||||
return priv->accel_closure;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
find_accel (GtkAccelKey *key,
|
||||
GClosure *closure,
|
||||
gpointer data)
|
||||
{
|
||||
return data == (gpointer) closure;
|
||||
}
|
||||
|
||||
/* Underscores in key names are better displayed as spaces
|
||||
* E.g., Page_Up should be “Page Up”.
|
||||
*
|
||||
* Some keynames also have prefixes that are not suitable
|
||||
* for display, e.g XF86AudioMute, so strip those out, too.
|
||||
*
|
||||
* This function is only called on untranslated keynames,
|
||||
* so no need to be UTF-8 safe.
|
||||
*/
|
||||
static void
|
||||
append_without_underscores (GString *s,
|
||||
const char *str)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
if (g_str_has_prefix (str, "XF86"))
|
||||
p = str + 4;
|
||||
else if (g_str_has_prefix (str, "ISO_"))
|
||||
p = str + 4;
|
||||
else
|
||||
p = str;
|
||||
|
||||
for ( ; *p; p++)
|
||||
{
|
||||
if (*p == '_')
|
||||
g_string_append_c (s, ' ');
|
||||
else
|
||||
g_string_append_c (s, *p);
|
||||
}
|
||||
}
|
||||
|
||||
/* On Mac, if the key has symbolic representation (e.g. arrow keys),
|
||||
* append it to gstring and return TRUE; otherwise return FALSE.
|
||||
* See http://docs.info.apple.com/article.html?path=Mac/10.5/en/cdb_symbs.html
|
||||
* for the list of special keys. */
|
||||
static gboolean
|
||||
append_keyval_symbol (guint accelerator_key,
|
||||
GString *gstring)
|
||||
{
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
switch (accelerator_key)
|
||||
{
|
||||
case GDK_KEY_Return:
|
||||
/* U+21A9 LEFTWARDS ARROW WITH HOOK */
|
||||
g_string_append (gstring, "\xe2\x86\xa9");
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_ISO_Enter:
|
||||
/* U+2324 UP ARROWHEAD BETWEEN TWO HORIZONTAL BARS */
|
||||
g_string_append (gstring, "\xe2\x8c\xa4");
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_Left:
|
||||
/* U+2190 LEFTWARDS ARROW */
|
||||
g_string_append (gstring, "\xe2\x86\x90");
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_Up:
|
||||
/* U+2191 UPWARDS ARROW */
|
||||
g_string_append (gstring, "\xe2\x86\x91");
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_Right:
|
||||
/* U+2192 RIGHTWARDS ARROW */
|
||||
g_string_append (gstring, "\xe2\x86\x92");
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_Down:
|
||||
/* U+2193 DOWNWARDS ARROW */
|
||||
g_string_append (gstring, "\xe2\x86\x93");
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_Page_Up:
|
||||
/* U+21DE UPWARDS ARROW WITH DOUBLE STROKE */
|
||||
g_string_append (gstring, "\xe2\x87\x9e");
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_Page_Down:
|
||||
/* U+21DF DOWNWARDS ARROW WITH DOUBLE STROKE */
|
||||
g_string_append (gstring, "\xe2\x87\x9f");
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_Home:
|
||||
/* U+2196 NORTH WEST ARROW */
|
||||
g_string_append (gstring, "\xe2\x86\x96");
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_End:
|
||||
/* U+2198 SOUTH EAST ARROW */
|
||||
g_string_append (gstring, "\xe2\x86\x98");
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_Escape:
|
||||
/* U+238B BROKEN CIRCLE WITH NORTHWEST ARROW */
|
||||
g_string_append (gstring, "\xe2\x8e\x8b");
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_BackSpace:
|
||||
/* U+232B ERASE TO THE LEFT */
|
||||
g_string_append (gstring, "\xe2\x8c\xab");
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_Delete:
|
||||
/* U+2326 ERASE TO THE RIGHT */
|
||||
g_string_append (gstring, "\xe2\x8c\xa6");
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
#else /* !GDK_WINDOWING_QUARTZ */
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
gchar *
|
||||
_gtk_accel_label_class_get_accelerator_label (GtkAccelLabelClass *klass,
|
||||
guint accelerator_key,
|
||||
GdkModifierType accelerator_mods)
|
||||
{
|
||||
GString *gstring;
|
||||
gboolean seen_mod = FALSE;
|
||||
gunichar ch;
|
||||
|
||||
gstring = g_string_sized_new (10); /* ~len('backspace') */
|
||||
|
||||
if (accelerator_mods & GDK_SHIFT_MASK)
|
||||
{
|
||||
g_string_append (gstring, klass->mod_name_shift);
|
||||
seen_mod = TRUE;
|
||||
}
|
||||
|
||||
if (accelerator_mods & GDK_CONTROL_MASK)
|
||||
{
|
||||
if (seen_mod)
|
||||
g_string_append (gstring, klass->mod_separator);
|
||||
g_string_append (gstring, klass->mod_name_control);
|
||||
seen_mod = TRUE;
|
||||
}
|
||||
|
||||
if (accelerator_mods & GDK_MOD1_MASK)
|
||||
{
|
||||
if (seen_mod)
|
||||
g_string_append (gstring, klass->mod_separator);
|
||||
g_string_append (gstring, klass->mod_name_alt);
|
||||
seen_mod = TRUE;
|
||||
}
|
||||
|
||||
if (accelerator_mods & GDK_MOD2_MASK)
|
||||
{
|
||||
if (seen_mod)
|
||||
g_string_append (gstring, klass->mod_separator);
|
||||
|
||||
g_string_append (gstring, "Mod2");
|
||||
seen_mod = TRUE;
|
||||
}
|
||||
|
||||
if (accelerator_mods & GDK_MOD3_MASK)
|
||||
{
|
||||
if (seen_mod)
|
||||
g_string_append (gstring, klass->mod_separator);
|
||||
|
||||
g_string_append (gstring, "Mod3");
|
||||
seen_mod = TRUE;
|
||||
}
|
||||
|
||||
if (accelerator_mods & GDK_MOD4_MASK)
|
||||
{
|
||||
if (seen_mod)
|
||||
g_string_append (gstring, klass->mod_separator);
|
||||
|
||||
g_string_append (gstring, "Mod4");
|
||||
seen_mod = TRUE;
|
||||
}
|
||||
|
||||
if (accelerator_mods & GDK_MOD5_MASK)
|
||||
{
|
||||
if (seen_mod)
|
||||
g_string_append (gstring, klass->mod_separator);
|
||||
|
||||
g_string_append (gstring, "Mod5");
|
||||
seen_mod = TRUE;
|
||||
}
|
||||
|
||||
if (accelerator_mods & GDK_SUPER_MASK)
|
||||
{
|
||||
if (seen_mod)
|
||||
g_string_append (gstring, klass->mod_separator);
|
||||
|
||||
/* This is the text that should appear next to menu accelerators
|
||||
* that use the super key. If the text on this key isn't typically
|
||||
* translated on keyboards used for your language, don't translate
|
||||
* this.
|
||||
*/
|
||||
g_string_append (gstring, C_("keyboard label", "Super"));
|
||||
seen_mod = TRUE;
|
||||
}
|
||||
|
||||
if (accelerator_mods & GDK_HYPER_MASK)
|
||||
{
|
||||
if (seen_mod)
|
||||
g_string_append (gstring, klass->mod_separator);
|
||||
|
||||
/* This is the text that should appear next to menu accelerators
|
||||
* that use the hyper key. If the text on this key isn't typically
|
||||
* translated on keyboards used for your language, don't translate
|
||||
* this.
|
||||
*/
|
||||
g_string_append (gstring, C_("keyboard label", "Hyper"));
|
||||
seen_mod = TRUE;
|
||||
}
|
||||
|
||||
if (accelerator_mods & GDK_META_MASK)
|
||||
{
|
||||
if (seen_mod)
|
||||
g_string_append (gstring, klass->mod_separator);
|
||||
|
||||
#ifndef GDK_WINDOWING_QUARTZ
|
||||
/* This is the text that should appear next to menu accelerators
|
||||
* that use the meta key. If the text on this key isn't typically
|
||||
* translated on keyboards used for your language, don't translate
|
||||
* this.
|
||||
*/
|
||||
g_string_append (gstring, C_("keyboard label", "Meta"));
|
||||
#else
|
||||
/* Command key symbol U+2318 PLACE OF INTEREST SIGN */
|
||||
g_string_append (gstring, "\xe2\x8c\x98");
|
||||
#endif
|
||||
seen_mod = TRUE;
|
||||
}
|
||||
|
||||
ch = gdk_keyval_to_unicode (accelerator_key);
|
||||
if (ch && (ch == ' ' || g_unichar_isgraph (ch)))
|
||||
{
|
||||
if (seen_mod)
|
||||
g_string_append (gstring, klass->mod_separator);
|
||||
|
||||
switch (ch)
|
||||
{
|
||||
case ' ':
|
||||
g_string_append (gstring, C_("keyboard label", "Space"));
|
||||
break;
|
||||
case '\\':
|
||||
g_string_append (gstring, C_("keyboard label", "Backslash"));
|
||||
break;
|
||||
default:
|
||||
g_string_append_unichar (gstring, g_unichar_toupper (ch));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (!append_keyval_symbol (accelerator_key, gstring))
|
||||
{
|
||||
const char *tmp;
|
||||
|
||||
tmp = gdk_keyval_name (gdk_keyval_to_lower (accelerator_key));
|
||||
if (tmp != NULL)
|
||||
{
|
||||
if (seen_mod)
|
||||
g_string_append (gstring, klass->mod_separator);
|
||||
|
||||
if (tmp[0] != 0 && tmp[1] == 0)
|
||||
g_string_append_c (gstring, g_ascii_toupper (tmp[0]));
|
||||
else
|
||||
{
|
||||
const gchar *str;
|
||||
str = g_dpgettext2 (GETTEXT_PACKAGE, "keyboard label", tmp);
|
||||
if (str == tmp)
|
||||
append_without_underscores (gstring, tmp);
|
||||
else
|
||||
g_string_append (gstring, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return g_string_free (gstring, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_accel_label_refetch:
|
||||
* @accel_label: a #GtkAccelLabel.
|
||||
@ -864,7 +301,7 @@ gtk_accel_label_refetch (GtkAccelLabel *accel_label)
|
||||
"gtk-enable-accels", &enable_accels,
|
||||
NULL);
|
||||
|
||||
if (enable_accels && (priv->accel_closure || priv->accel_key))
|
||||
if (enable_accels && priv->accel_key)
|
||||
{
|
||||
gboolean have_accel = FALSE;
|
||||
guint accel_key;
|
||||
@ -878,30 +315,9 @@ gtk_accel_label_refetch (GtkAccelLabel *accel_label)
|
||||
have_accel = TRUE;
|
||||
}
|
||||
|
||||
/* If we don't have a hardcoded value, check the accel group */
|
||||
if (!have_accel)
|
||||
{
|
||||
GtkAccelKey *key;
|
||||
|
||||
key = gtk_accel_group_find (priv->accel_group, find_accel, priv->accel_closure);
|
||||
|
||||
if (key && key->accel_flags & GTK_ACCEL_VISIBLE)
|
||||
{
|
||||
accel_key = key->accel_key;
|
||||
accel_mods = key->accel_mods;
|
||||
have_accel = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we found a key using either method, set it */
|
||||
if (have_accel)
|
||||
{
|
||||
GtkAccelLabelClass *klass;
|
||||
|
||||
klass = GTK_ACCEL_LABEL_GET_CLASS (accel_label);
|
||||
accel_string = _gtk_accel_label_class_get_accelerator_label (klass, accel_key, accel_mods);
|
||||
}
|
||||
|
||||
accel_string = gtk_accelerator_get_label (accel_key, accel_mods);
|
||||
else
|
||||
/* Otherwise we have a closure with no key. Show "-/-". */
|
||||
accel_string = g_strdup ("-/-");
|
||||
@ -943,7 +359,7 @@ gtk_accel_label_set_accel (GtkAccelLabel *accel_label,
|
||||
priv->accel_key = accelerator_key;
|
||||
priv->accel_mods = accelerator_mods;
|
||||
|
||||
gtk_accel_label_reset (accel_label);
|
||||
gtk_accel_label_refetch (accel_label);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,18 +46,8 @@ GType gtk_accel_label_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget *gtk_accel_label_new (const gchar *string);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget *gtk_accel_label_get_accel_widget (GtkAccelLabel *accel_label);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
guint gtk_accel_label_get_accel_width (GtkAccelLabel *accel_label);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accel_label_set_accel_widget (GtkAccelLabel *accel_label,
|
||||
GtkWidget *accel_widget);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accel_label_set_accel_closure (GtkAccelLabel *accel_label,
|
||||
GClosure *accel_closure);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GClosure * gtk_accel_label_get_accel_closure (GtkAccelLabel *accel_label);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_accel_label_refetch (GtkAccelLabel *accel_label);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accel_label_set_accel (GtkAccelLabel *accel_label,
|
||||
|
1086
gtk/gtkaccelmap.c
1086
gtk/gtkaccelmap.c
File diff suppressed because it is too large
Load Diff
@ -1,109 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 1998, 2001 Tim Janik
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_ACCEL_MAP_H__
|
||||
#define __GTK_ACCEL_MAP_H__
|
||||
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gtk/gtkaccelgroup.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* --- global GtkAccelMap object --- */
|
||||
#define GTK_TYPE_ACCEL_MAP (gtk_accel_map_get_type ())
|
||||
#define GTK_ACCEL_MAP(accel_map) (G_TYPE_CHECK_INSTANCE_CAST ((accel_map), GTK_TYPE_ACCEL_MAP, GtkAccelMap))
|
||||
#define GTK_ACCEL_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ACCEL_MAP, GtkAccelMapClass))
|
||||
#define GTK_IS_ACCEL_MAP(accel_map) (G_TYPE_CHECK_INSTANCE_TYPE ((accel_map), GTK_TYPE_ACCEL_MAP))
|
||||
#define GTK_IS_ACCEL_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ACCEL_MAP))
|
||||
#define GTK_ACCEL_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ACCEL_MAP, GtkAccelMapClass))
|
||||
|
||||
typedef struct _GtkAccelMap GtkAccelMap;
|
||||
typedef struct _GtkAccelMapClass GtkAccelMapClass;
|
||||
|
||||
/* --- notifier --- */
|
||||
/**
|
||||
* GtkAccelMapForeach:
|
||||
* @data: User data passed to gtk_accel_map_foreach() or
|
||||
* gtk_accel_map_foreach_unfiltered()
|
||||
* @accel_path: Accel path of the current accelerator
|
||||
* @accel_key: Key of the current accelerator
|
||||
* @accel_mods: Modifiers of the current accelerator
|
||||
* @changed: Changed flag of the accelerator (if %TRUE, accelerator has changed
|
||||
* during runtime and would need to be saved during an accelerator dump)
|
||||
*/
|
||||
typedef void (*GtkAccelMapForeach) (gpointer data,
|
||||
const gchar *accel_path,
|
||||
guint accel_key,
|
||||
GdkModifierType accel_mods,
|
||||
gboolean changed);
|
||||
|
||||
|
||||
/* --- public API --- */
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accel_map_add_entry (const gchar *accel_path,
|
||||
guint accel_key,
|
||||
GdkModifierType accel_mods);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_accel_map_lookup_entry (const gchar *accel_path,
|
||||
GtkAccelKey *key);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_accel_map_change_entry (const gchar *accel_path,
|
||||
guint accel_key,
|
||||
GdkModifierType accel_mods,
|
||||
gboolean replace);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accel_map_load (const gchar *file_name);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accel_map_save (const gchar *file_name);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accel_map_foreach (gpointer data,
|
||||
GtkAccelMapForeach foreach_func);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accel_map_load_fd (gint fd);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accel_map_load_scanner (GScanner *scanner);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accel_map_save_fd (gint fd);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accel_map_lock_path (const gchar *accel_path);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accel_map_unlock_path (const gchar *accel_path);
|
||||
|
||||
/* --- filter functions --- */
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accel_map_add_filter (const gchar *filter_pattern);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_accel_map_foreach_unfiltered (gpointer data,
|
||||
GtkAccelMapForeach foreach_func);
|
||||
|
||||
/* --- notification --- */
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_accel_map_get_type (void) G_GNUC_CONST;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkAccelMap *gtk_accel_map_get (void);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkAccelMap, g_object_unref)
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_ACCEL_MAP_H__ */
|
@ -1,39 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 1998, 2001 Tim Janik
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_ACCEL_MAP_PRIVATE_H__
|
||||
#define __GTK_ACCEL_MAP_PRIVATE_H__
|
||||
|
||||
|
||||
#include <gtk/gtkaccelmap.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void _gtk_accel_map_init (void);
|
||||
|
||||
void _gtk_accel_map_add_group (const gchar *accel_path,
|
||||
GtkAccelGroup *accel_group);
|
||||
void _gtk_accel_map_remove_group (const gchar *accel_path,
|
||||
GtkAccelGroup *accel_group);
|
||||
gboolean _gtk_accel_path_is_valid (const gchar *accel_path);
|
||||
|
||||
gchar * _gtk_accel_path_for_action (const gchar *action_name,
|
||||
GVariant *parameter);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_ACCEL_MAP_PRIVATE_H__ */
|
@ -37,7 +37,6 @@
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkrecentmanager.h"
|
||||
#include "gtkaccelmapprivate.h"
|
||||
#include "gtkicontheme.h"
|
||||
#include "gtkbuilder.h"
|
||||
#include "gtkshortcutswindow.h"
|
||||
|
@ -22,134 +22,28 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkapplicationaccelsprivate.h"
|
||||
|
||||
#include "gtkactionmuxerprivate.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
guint key;
|
||||
GdkModifierType modifier;
|
||||
} AccelKey;
|
||||
#include "gtkshortcut.h"
|
||||
#include "gtkshortcutaction.h"
|
||||
#include "gtkshortcuttrigger.h"
|
||||
|
||||
struct _GtkApplicationAccels
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
GHashTable *action_to_accels;
|
||||
GHashTable *accel_to_actions;
|
||||
GListModel *shortcuts;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GtkApplicationAccels, gtk_application_accels, G_TYPE_OBJECT)
|
||||
|
||||
static AccelKey *
|
||||
accel_key_copy (const AccelKey *source)
|
||||
{
|
||||
AccelKey *dest;
|
||||
|
||||
dest = g_slice_new (AccelKey);
|
||||
dest->key = source->key;
|
||||
dest->modifier = source->modifier;
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
static void
|
||||
accel_key_free (gpointer data)
|
||||
{
|
||||
AccelKey *key = data;
|
||||
|
||||
g_slice_free (AccelKey, key);
|
||||
}
|
||||
|
||||
static guint
|
||||
accel_key_hash (gconstpointer data)
|
||||
{
|
||||
const AccelKey *key = data;
|
||||
|
||||
return key->key + (key->modifier << 16);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
accel_key_equal (gconstpointer a,
|
||||
gconstpointer b)
|
||||
{
|
||||
const AccelKey *ak = a;
|
||||
const AccelKey *bk = b;
|
||||
|
||||
return ak->key == bk->key && ak->modifier == bk->modifier;
|
||||
}
|
||||
|
||||
static void
|
||||
add_entry (GtkApplicationAccels *accels,
|
||||
AccelKey *key,
|
||||
const gchar *action_and_target)
|
||||
{
|
||||
const gchar **old;
|
||||
const gchar **new;
|
||||
gint n;
|
||||
|
||||
old = g_hash_table_lookup (accels->accel_to_actions, key);
|
||||
if (old != NULL)
|
||||
for (n = 0; old[n]; n++) /* find the length */
|
||||
;
|
||||
else
|
||||
n = 0;
|
||||
|
||||
new = g_renew (const gchar *, old, n + 1 + 1);
|
||||
new[n] = action_and_target;
|
||||
new[n + 1] = NULL;
|
||||
|
||||
g_hash_table_insert (accels->accel_to_actions, accel_key_copy (key), new);
|
||||
}
|
||||
|
||||
static void
|
||||
remove_entry (GtkApplicationAccels *accels,
|
||||
AccelKey *key,
|
||||
const gchar *action_and_target)
|
||||
{
|
||||
const gchar **old;
|
||||
const gchar **new;
|
||||
gint n, i;
|
||||
|
||||
/* if we can't find the entry then something has gone very wrong... */
|
||||
old = g_hash_table_lookup (accels->accel_to_actions, key);
|
||||
g_assert (old != NULL);
|
||||
|
||||
for (n = 0; old[n]; n++) /* find the length */
|
||||
;
|
||||
g_assert_cmpint (n, >, 0);
|
||||
|
||||
if (n == 1)
|
||||
{
|
||||
/* The simple case of removing the last action for an accel. */
|
||||
g_assert_cmpstr (old[0], ==, action_and_target);
|
||||
g_hash_table_remove (accels->accel_to_actions, key);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
if (g_str_equal (old[i], action_and_target))
|
||||
break;
|
||||
|
||||
/* We must have found it... */
|
||||
g_assert_cmpint (i, <, n);
|
||||
|
||||
new = g_new (const gchar *, n - 1 + 1);
|
||||
memcpy (new, old, i * sizeof (const gchar *));
|
||||
memcpy (new + i, old + i + 1, (n - (i + 1)) * sizeof (const gchar *));
|
||||
new[n - 1] = NULL;
|
||||
|
||||
g_hash_table_insert (accels->accel_to_actions, accel_key_copy (key), new);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_application_accels_finalize (GObject *object)
|
||||
{
|
||||
GtkApplicationAccels *accels = GTK_APPLICATION_ACCELS (object);
|
||||
|
||||
g_hash_table_unref (accels->accel_to_actions);
|
||||
g_hash_table_unref (accels->action_to_accels);
|
||||
g_list_store_remove_all (G_LIST_STORE (accels->shortcuts));
|
||||
g_object_unref (accels->shortcuts);
|
||||
|
||||
G_OBJECT_CLASS (gtk_application_accels_parent_class)->finalize (object);
|
||||
}
|
||||
@ -165,9 +59,7 @@ gtk_application_accels_class_init (GtkApplicationAccelsClass *klass)
|
||||
static void
|
||||
gtk_application_accels_init (GtkApplicationAccels *accels)
|
||||
{
|
||||
accels->accel_to_actions = g_hash_table_new_full (accel_key_hash, accel_key_equal,
|
||||
accel_key_free, g_free);
|
||||
accels->action_to_accels = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||
accels->shortcuts = G_LIST_MODEL (g_list_store_new (GTK_TYPE_SHORTCUT));
|
||||
}
|
||||
|
||||
GtkApplicationAccels *
|
||||
@ -181,54 +73,97 @@ gtk_application_accels_set_accels_for_action (GtkApplicationAccels *accels,
|
||||
const gchar *detailed_action_name,
|
||||
const gchar * const *accelerators)
|
||||
{
|
||||
gchar *action_and_target;
|
||||
AccelKey *keys, *old_keys;
|
||||
gint i, n;
|
||||
gchar *action_name;
|
||||
GVariant *target;
|
||||
GtkShortcut *shortcut;
|
||||
GtkShortcutTrigger *trigger = NULL;
|
||||
GError *error = NULL;
|
||||
guint i;
|
||||
|
||||
action_and_target = gtk_normalise_detailed_action_name (detailed_action_name);
|
||||
|
||||
n = accelerators ? g_strv_length ((gchar **) accelerators) : 0;
|
||||
|
||||
if (n > 0)
|
||||
if (!g_action_parse_detailed_name (detailed_action_name, &action_name, &target, &error))
|
||||
{
|
||||
keys = g_new0 (AccelKey, n + 1);
|
||||
g_critical ("Error parsing action name: %s", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
/* remove the accelerator if it already exists */
|
||||
for (i = 0; i < g_list_model_get_n_items (accels->shortcuts); i++)
|
||||
{
|
||||
GtkShortcut *shortcut_i = g_list_model_get_item (accels->shortcuts, i);
|
||||
GtkShortcutAction *action = gtk_shortcut_get_action (shortcut_i);
|
||||
GVariant *args = gtk_shortcut_get_arguments (shortcut_i);
|
||||
|
||||
if (gtk_shortcut_action_get_action_type (action) != GTK_SHORTCUT_ACTION_ACTION ||
|
||||
!g_str_equal (gtk_action_action_get_name (action), action_name))
|
||||
continue;
|
||||
|
||||
if ((target == NULL && args != NULL) ||
|
||||
(target != NULL && (args == NULL || !g_variant_equal (target, args))))
|
||||
continue;
|
||||
|
||||
g_list_store_remove (G_LIST_STORE (accels->shortcuts), i);
|
||||
break;
|
||||
}
|
||||
|
||||
if (accelerators == NULL)
|
||||
goto out;
|
||||
|
||||
for (i = 0; accelerators[i]; i++)
|
||||
{
|
||||
GtkShortcutTrigger *new_trigger;
|
||||
guint key, modifier;
|
||||
|
||||
if (!gtk_accelerator_parse (accelerators[i], &key, &modifier))
|
||||
{
|
||||
gtk_accelerator_parse (accelerators[i], &keys[i].key, &keys[i].modifier);
|
||||
|
||||
if (keys[i].key == 0)
|
||||
{
|
||||
g_warning ("Unable to parse accelerator '%s': ignored request to install %d accelerators",
|
||||
accelerators[i], n);
|
||||
g_free (action_and_target);
|
||||
g_free (keys);
|
||||
return;
|
||||
}
|
||||
g_critical ("Unable to parse accelerator '%s': ignored request to install accelerators",
|
||||
accelerators[i]);
|
||||
if (trigger)
|
||||
gtk_shortcut_trigger_unref (trigger);
|
||||
goto out;;
|
||||
}
|
||||
new_trigger = gtk_keyval_trigger_new (key, modifier);
|
||||
if (trigger)
|
||||
trigger = gtk_alternative_trigger_new (trigger, new_trigger);
|
||||
else
|
||||
trigger = new_trigger;
|
||||
}
|
||||
else
|
||||
keys = NULL;
|
||||
if (trigger == NULL)
|
||||
goto out;
|
||||
|
||||
old_keys = g_hash_table_lookup (accels->action_to_accels, action_and_target);
|
||||
if (old_keys)
|
||||
{
|
||||
/* We need to remove accel entries from existing keys */
|
||||
for (i = 0; old_keys[i].key; i++)
|
||||
remove_entry (accels, &old_keys[i], action_and_target);
|
||||
}
|
||||
shortcut = gtk_shortcut_new (trigger, gtk_action_action_new (action_name));
|
||||
gtk_shortcut_set_arguments (shortcut, target);
|
||||
g_list_store_append (G_LIST_STORE (accels->shortcuts), shortcut);
|
||||
g_object_unref (shortcut);
|
||||
|
||||
if (keys)
|
||||
{
|
||||
g_hash_table_replace (accels->action_to_accels, action_and_target, keys);
|
||||
out:
|
||||
g_free (action_name);
|
||||
if (target)
|
||||
g_variant_unref (target);
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
add_entry (accels, &keys[i], action_and_target);
|
||||
}
|
||||
else
|
||||
static void
|
||||
append_accelerators (GPtrArray *accels,
|
||||
GtkShortcutTrigger *trigger)
|
||||
{
|
||||
switch (gtk_shortcut_trigger_get_trigger_type (trigger))
|
||||
{
|
||||
g_hash_table_remove (accels->action_to_accels, action_and_target);
|
||||
g_free (action_and_target);
|
||||
case GTK_SHORTCUT_TRIGGER_KEYVAL:
|
||||
g_ptr_array_add (accels,
|
||||
gtk_accelerator_name (gtk_keyval_trigger_get_keyval (trigger),
|
||||
gtk_keyval_trigger_get_modifiers (trigger)));
|
||||
return;
|
||||
|
||||
case GTK_SHORTCUT_TRIGGER_ALTERNATIVE:
|
||||
append_accelerators (accels, gtk_alternative_trigger_get_first (trigger));
|
||||
append_accelerators (accels, gtk_alternative_trigger_get_second (trigger));
|
||||
return;
|
||||
|
||||
case GTK_SHORTCUT_TRIGGER_MNEMONIC:
|
||||
case GTK_SHORTCUT_TRIGGER_NEVER:
|
||||
default:
|
||||
/* not an accelerator */
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -236,223 +171,137 @@ gchar **
|
||||
gtk_application_accels_get_accels_for_action (GtkApplicationAccels *accels,
|
||||
const gchar *detailed_action_name)
|
||||
{
|
||||
gchar *action_and_target;
|
||||
AccelKey *keys;
|
||||
gchar **result;
|
||||
gint n, i = 0;
|
||||
GPtrArray *result;
|
||||
char *action_name;
|
||||
GVariant *target;
|
||||
GError *error = NULL;
|
||||
guint i;
|
||||
|
||||
action_and_target = gtk_normalise_detailed_action_name (detailed_action_name);
|
||||
result = g_ptr_array_new ();
|
||||
|
||||
keys = g_hash_table_lookup (accels->action_to_accels, action_and_target);
|
||||
if (!keys)
|
||||
if (!g_action_parse_detailed_name (detailed_action_name, &action_name, &target, &error))
|
||||
{
|
||||
g_free (action_and_target);
|
||||
return g_new0 (gchar *, 0 + 1);
|
||||
g_critical ("Error parsing action name: %s", error->message);
|
||||
g_error_free (error);
|
||||
g_ptr_array_add (result, NULL);
|
||||
return (gchar **) g_ptr_array_free (result, FALSE);
|
||||
}
|
||||
|
||||
for (n = 0; keys[n].key; n++)
|
||||
;
|
||||
for (i = 0; i < g_list_model_get_n_items (accels->shortcuts); i++)
|
||||
{
|
||||
GtkShortcut *shortcut = g_list_model_get_item (accels->shortcuts, i);
|
||||
GtkShortcutAction *action = gtk_shortcut_get_action (shortcut);
|
||||
GVariant *args = gtk_shortcut_get_arguments (shortcut);
|
||||
|
||||
result = g_new0 (gchar *, n + 1);
|
||||
if (gtk_shortcut_action_get_action_type (action) != GTK_SHORTCUT_ACTION_ACTION ||
|
||||
!g_str_equal (gtk_action_action_get_name (action), action_name))
|
||||
continue;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
result[i] = gtk_accelerator_name (keys[i].key, keys[i].modifier);
|
||||
if ((target == NULL && args != NULL) ||
|
||||
(target != NULL && (args == NULL || !g_variant_equal (target, args))))
|
||||
continue;
|
||||
|
||||
g_free (action_and_target);
|
||||
return result;
|
||||
append_accelerators (result, gtk_shortcut_get_trigger (shortcut));
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (action_name);
|
||||
if (target)
|
||||
g_variant_unref (target);
|
||||
g_ptr_array_add (result, NULL);
|
||||
return (gchar **) g_ptr_array_free (result, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
trigger_matches_accel (GtkShortcutTrigger *trigger,
|
||||
guint keyval,
|
||||
GdkModifierType modifiers)
|
||||
{
|
||||
switch (gtk_shortcut_trigger_get_trigger_type (trigger))
|
||||
{
|
||||
case GTK_SHORTCUT_TRIGGER_KEYVAL:
|
||||
return gtk_keyval_trigger_get_keyval (trigger) == keyval
|
||||
&& gtk_keyval_trigger_get_modifiers (trigger) == modifiers;
|
||||
|
||||
case GTK_SHORTCUT_TRIGGER_ALTERNATIVE:
|
||||
return trigger_matches_accel (gtk_alternative_trigger_get_first (trigger), keyval, modifiers)
|
||||
|| trigger_matches_accel (gtk_alternative_trigger_get_second (trigger), keyval, modifiers);
|
||||
|
||||
case GTK_SHORTCUT_TRIGGER_MNEMONIC:
|
||||
case GTK_SHORTCUT_TRIGGER_NEVER:
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static char *
|
||||
get_detailed_name_for_shortcut (GtkShortcut *shortcut)
|
||||
{
|
||||
GtkShortcutAction *action = gtk_shortcut_get_action (shortcut);
|
||||
|
||||
if (gtk_shortcut_action_get_action_type (action) != GTK_SHORTCUT_ACTION_ACTION)
|
||||
return NULL;
|
||||
|
||||
return g_action_print_detailed_name (gtk_action_action_get_name (action), gtk_shortcut_get_arguments (shortcut));
|
||||
}
|
||||
|
||||
gchar **
|
||||
gtk_application_accels_get_actions_for_accel (GtkApplicationAccels *accels,
|
||||
const gchar *accel)
|
||||
{
|
||||
const gchar * const *actions_and_targets;
|
||||
gchar **detailed_actions;
|
||||
AccelKey accel_key;
|
||||
guint i, n;
|
||||
GPtrArray *result;
|
||||
guint key, modifiers;
|
||||
guint i;
|
||||
|
||||
gtk_accelerator_parse (accel, &accel_key.key, &accel_key.modifier);
|
||||
|
||||
if (accel_key.key == 0)
|
||||
if (!gtk_accelerator_parse (accel, &key, &modifiers))
|
||||
{
|
||||
g_critical ("invalid accelerator string '%s'", accel);
|
||||
g_return_val_if_fail (accel_key.key != 0, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
actions_and_targets = g_hash_table_lookup (accels->accel_to_actions, &accel_key);
|
||||
n = actions_and_targets ? g_strv_length ((gchar **) actions_and_targets) : 0;
|
||||
|
||||
detailed_actions = g_new0 (gchar *, n + 1);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
result = g_ptr_array_new ();
|
||||
|
||||
for (i = 0; i < g_list_model_get_n_items (accels->shortcuts); i++)
|
||||
{
|
||||
const gchar *action_and_target = actions_and_targets[i];
|
||||
const gchar *sep;
|
||||
GVariant *target;
|
||||
GtkShortcut *shortcut = g_list_model_get_item (accels->shortcuts, i);
|
||||
char *detailed_name;
|
||||
|
||||
sep = strrchr (action_and_target, '|');
|
||||
target = g_variant_parse (NULL, action_and_target, sep, NULL, NULL);
|
||||
detailed_actions[i] = g_action_print_detailed_name (sep + 1, target);
|
||||
if (target)
|
||||
g_variant_unref (target);
|
||||
if (!trigger_matches_accel (gtk_shortcut_get_trigger (shortcut), key, modifiers))
|
||||
continue;
|
||||
|
||||
detailed_name = get_detailed_name_for_shortcut (shortcut);
|
||||
if (detailed_name)
|
||||
g_ptr_array_add (result, detailed_name);
|
||||
}
|
||||
|
||||
detailed_actions[n] = NULL;
|
||||
|
||||
return detailed_actions;
|
||||
g_ptr_array_add (result, NULL);
|
||||
return (gchar **) g_ptr_array_free (result, FALSE);
|
||||
}
|
||||
|
||||
gchar **
|
||||
gtk_application_accels_list_action_descriptions (GtkApplicationAccels *accels)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
gchar **result;
|
||||
gint n, i = 0;
|
||||
gpointer key;
|
||||
GPtrArray *result;
|
||||
guint i;
|
||||
|
||||
n = g_hash_table_size (accels->action_to_accels);
|
||||
result = g_new (gchar *, n + 1);
|
||||
|
||||
g_hash_table_iter_init (&iter, accels->action_to_accels);
|
||||
while (g_hash_table_iter_next (&iter, &key, NULL))
|
||||
result = g_ptr_array_new ();
|
||||
|
||||
for (i = 0; i < g_list_model_get_n_items (accels->shortcuts); i++)
|
||||
{
|
||||
const gchar *action_and_target = key;
|
||||
const gchar *sep;
|
||||
GVariant *target;
|
||||
GtkShortcut *shortcut = g_list_model_get_item (accels->shortcuts, i);
|
||||
char *detailed_name;
|
||||
|
||||
sep = strrchr (action_and_target, '|');
|
||||
target = g_variant_parse (NULL, action_and_target, sep, NULL, NULL);
|
||||
result[i++] = g_action_print_detailed_name (sep + 1, target);
|
||||
if (target)
|
||||
g_variant_unref (target);
|
||||
detailed_name = get_detailed_name_for_shortcut (shortcut);
|
||||
if (detailed_name)
|
||||
g_ptr_array_add (result, detailed_name);
|
||||
}
|
||||
g_assert_cmpint (i, ==, n);
|
||||
result[i] = NULL;
|
||||
|
||||
return result;
|
||||
g_ptr_array_add (result, NULL);
|
||||
return (gchar **) g_ptr_array_free (result, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_application_accels_foreach_key (GtkApplicationAccels *accels,
|
||||
GtkWindow *window,
|
||||
GtkWindowKeysForeachFunc callback,
|
||||
gpointer user_data)
|
||||
GListModel *
|
||||
gtk_application_accels_get_shortcuts (GtkApplicationAccels *accels)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
gpointer key;
|
||||
|
||||
g_hash_table_iter_init (&iter, accels->accel_to_actions);
|
||||
while (g_hash_table_iter_next (&iter, &key, NULL))
|
||||
{
|
||||
AccelKey *accel_key = key;
|
||||
|
||||
(* callback) (window, accel_key->key, accel_key->modifier, FALSE, user_data);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_application_accels_activate (GtkApplicationAccels *accels,
|
||||
GActionGroup *action_group,
|
||||
guint key,
|
||||
GdkModifierType modifier)
|
||||
{
|
||||
AccelKey accel_key = { key, modifier };
|
||||
const gchar **actions;
|
||||
gint i;
|
||||
|
||||
actions = g_hash_table_lookup (accels->accel_to_actions, &accel_key);
|
||||
|
||||
if (actions == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* We may have more than one action on a given accel. This could be
|
||||
* the case if we have different types of windows with different
|
||||
* actions in each.
|
||||
*
|
||||
* Find the first one that will successfully activate and use it.
|
||||
*/
|
||||
for (i = 0; actions[i]; i++)
|
||||
{
|
||||
const GVariantType *parameter_type;
|
||||
const gchar *action_name;
|
||||
const gchar *sep;
|
||||
gboolean enabled;
|
||||
GVariant *target;
|
||||
|
||||
sep = strrchr (actions[i], '|');
|
||||
action_name = sep + 1;
|
||||
|
||||
if (!g_action_group_query_action (action_group, action_name, &enabled, ¶meter_type, NULL, NULL, NULL))
|
||||
continue;
|
||||
|
||||
if (!enabled)
|
||||
continue;
|
||||
|
||||
/* We found an action with the correct name and it's enabled.
|
||||
* This is the action that we are going to try to invoke.
|
||||
*
|
||||
* There is still the possibility that the target value doesn't
|
||||
* match the expected parameter type. In that case, we will print
|
||||
* a warning.
|
||||
*
|
||||
* Note: we want to hold a ref on the target while we're invoking
|
||||
* the action to prevent trouble if someone uninstalls the accel
|
||||
* from the handler. That's not a problem since we're parsing it.
|
||||
*/
|
||||
if (actions[i] != sep) /* if it has a target... */
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (parameter_type == NULL)
|
||||
{
|
||||
gchar *accel_str = gtk_accelerator_name (key, modifier);
|
||||
g_warning ("Accelerator '%s' tries to invoke action '%s' with target, but action has no parameter",
|
||||
accel_str, action_name);
|
||||
g_free (accel_str);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
target = g_variant_parse (NULL, actions[i], sep, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (target);
|
||||
|
||||
if (!g_variant_is_of_type (target, parameter_type))
|
||||
{
|
||||
gchar *accel_str = gtk_accelerator_name (key, modifier);
|
||||
gchar *typestr = g_variant_type_dup_string (parameter_type);
|
||||
gchar *targetstr = g_variant_print (target, TRUE);
|
||||
g_warning ("Accelerator '%s' tries to invoke action '%s' with target '%s',"
|
||||
" but action expects parameter with type '%s'", accel_str, action_name, targetstr, typestr);
|
||||
g_variant_unref (target);
|
||||
g_free (targetstr);
|
||||
g_free (accel_str);
|
||||
g_free (typestr);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parameter_type != NULL)
|
||||
{
|
||||
gchar *accel_str = gtk_accelerator_name (key, modifier);
|
||||
gchar *typestr = g_variant_type_dup_string (parameter_type);
|
||||
g_warning ("Accelerator '%s' tries to invoke action '%s' without target,"
|
||||
" but action expects parameter with type '%s'", accel_str, action_name, typestr);
|
||||
g_free (accel_str);
|
||||
g_free (typestr);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
target = NULL;
|
||||
}
|
||||
|
||||
g_action_group_activate_action (action_group, action_name, target);
|
||||
|
||||
if (target)
|
||||
g_variant_unref (target);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return accels->shortcuts;
|
||||
}
|
||||
|
@ -47,15 +47,7 @@ gchar ** gtk_application_accels_get_actions_for_accel (GtkApplicat
|
||||
|
||||
gchar ** gtk_application_accels_list_action_descriptions (GtkApplicationAccels *accels);
|
||||
|
||||
void gtk_application_accels_foreach_key (GtkApplicationAccels *accels,
|
||||
GtkWindow *window,
|
||||
GtkWindowKeysForeachFunc callback,
|
||||
gpointer user_data);
|
||||
|
||||
gboolean gtk_application_accels_activate (GtkApplicationAccels *accels,
|
||||
GActionGroup *action_group,
|
||||
guint key,
|
||||
GdkModifierType modifier);
|
||||
GListModel * gtk_application_accels_get_shortcuts (GtkApplicationAccels *accels);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -65,7 +65,6 @@
|
||||
|
||||
#include "gtkassistant.h"
|
||||
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkbox.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkbutton.h"
|
||||
@ -510,7 +509,6 @@ gtk_assistant_class_init (GtkAssistantClass *class)
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkContainerClass *container_class;
|
||||
GtkWindowClass *window_class;
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
gobject_class = (GObjectClass *) class;
|
||||
widget_class = (GtkWidgetClass *) class;
|
||||
@ -619,8 +617,10 @@ gtk_assistant_class_init (GtkAssistantClass *class)
|
||||
NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
binding_set = gtk_binding_set_by_class (class);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "escape", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Escape, 0,
|
||||
"escape",
|
||||
NULL);
|
||||
|
||||
/**
|
||||
* GtkAssistant:use-header-bar:
|
||||
|
1793
gtk/gtkbindings.c
1793
gtk/gtkbindings.c
File diff suppressed because it is too large
Load Diff
@ -1,124 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* GtkBindingSet: Keybinding manager for GObjects.
|
||||
* Copyright (C) 1998 Tim Janik
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_BINDINGS_H__
|
||||
#define __GTK_BINDINGS_H__
|
||||
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <gtk/gtkenums.h>
|
||||
#include <gtk/gtktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkBindingSet GtkBindingSet;
|
||||
|
||||
/**
|
||||
* GtkBindingCallback:
|
||||
* @widget: The object to invoke the callback on
|
||||
* @args: (allow-none): The arguments or %NULL if none
|
||||
* @user_data: The user data passed when registering the callback
|
||||
*
|
||||
* Prototype of the callback function registered with
|
||||
* gtk_binding_entry_add_callback.
|
||||
*/
|
||||
typedef void (* GtkBindingCallback) (GtkWidget *widget,
|
||||
GVariant *args,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkBindingSet *gtk_binding_set_new (const gchar *set_name);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkBindingSet *gtk_binding_set_by_class (gpointer object_class);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkBindingSet *gtk_binding_set_find (const gchar *set_name);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_bindings_activate (GObject *object,
|
||||
guint keyval,
|
||||
GdkModifierType modifiers);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_bindings_activate_event (GObject *object,
|
||||
GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_binding_set_activate (GtkBindingSet *binding_set,
|
||||
guint keyval,
|
||||
GdkModifierType modifiers,
|
||||
GObject *object);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_binding_entry_skip (GtkBindingSet *binding_set,
|
||||
guint keyval,
|
||||
GdkModifierType modifiers);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_binding_entry_add_signal (GtkBindingSet *binding_set,
|
||||
guint keyval,
|
||||
GdkModifierType modifiers,
|
||||
const gchar *signal_name,
|
||||
guint n_args,
|
||||
...);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GTokenType gtk_binding_entry_add_signal_from_string
|
||||
(GtkBindingSet *binding_set,
|
||||
const gchar *signal_desc);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_binding_entry_add_action_variant
|
||||
(GtkBindingSet *binding_set,
|
||||
guint keyval,
|
||||
GdkModifierType modifiers,
|
||||
const char *action_name,
|
||||
GVariant *args);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_binding_entry_add_action (GtkBindingSet *binding_set,
|
||||
guint keyval,
|
||||
GdkModifierType modifiers,
|
||||
const char *action_name,
|
||||
const char *format_string,
|
||||
...);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_binding_entry_add_callback(GtkBindingSet *binding_set,
|
||||
guint keyval,
|
||||
GdkModifierType modifiers,
|
||||
GtkBindingCallback callback,
|
||||
GVariant *args,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_binding_entry_remove (GtkBindingSet *binding_set,
|
||||
guint keyval,
|
||||
GdkModifierType modifiers);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_BINDINGS_H__ */
|
@ -215,16 +215,20 @@
|
||||
|
||||
#include "gtkbuilderprivate.h"
|
||||
|
||||
#include "gdkpixbufutilsprivate.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkbuilderscopeprivate.h"
|
||||
#include "gtkdebug.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkicontheme.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkshortcutactionprivate.h"
|
||||
#include "gtkshortcuttrigger.h"
|
||||
#include "gtktestutils.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkicontheme.h"
|
||||
#include "gtkiconthemeprivate.h"
|
||||
#include "gdkpixbufutilsprivate.h"
|
||||
|
||||
static void gtk_builder_finalize (GObject *object);
|
||||
static void gtk_builder_set_property (GObject *object,
|
||||
@ -2092,6 +2096,29 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
|
||||
ret = FALSE;
|
||||
}
|
||||
}
|
||||
else if (G_VALUE_HOLDS (value, GTK_TYPE_SHORTCUT_TRIGGER))
|
||||
{
|
||||
GtkShortcutTrigger *trigger = gtk_shortcut_trigger_parse_string (string);
|
||||
|
||||
if (trigger)
|
||||
g_value_take_boxed (value, trigger);
|
||||
else
|
||||
{
|
||||
g_set_error (error,
|
||||
GTK_BUILDER_ERROR,
|
||||
GTK_BUILDER_ERROR_INVALID_VALUE,
|
||||
"Could not parse shortcut trigger '%s'",
|
||||
string);
|
||||
ret = FALSE;
|
||||
}
|
||||
}
|
||||
else if (G_VALUE_HOLDS (value, GTK_TYPE_SHORTCUT_ACTION))
|
||||
{
|
||||
GtkShortcutAction *action = gtk_shortcut_action_parse_builder (builder, string, error);
|
||||
|
||||
/* Works for success and failure (NULL) case */
|
||||
g_value_take_boxed (value, action);
|
||||
}
|
||||
else if (G_VALUE_HOLDS (value, G_TYPE_STRV))
|
||||
{
|
||||
gchar **vector = g_strsplit (string, "\n", 0);
|
||||
|
@ -189,35 +189,44 @@ dismiss_current_popup (GtkColorEditor *editor)
|
||||
}
|
||||
|
||||
static void
|
||||
popup_edit (GtkWidget *widget,
|
||||
GtkColorEditor *editor)
|
||||
popup_edit (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
GVariant *parameters)
|
||||
{
|
||||
GtkColorEditor *editor = GTK_COLOR_EDITOR (widget);
|
||||
GtkWidget *popup = NULL;
|
||||
GtkRoot *root;
|
||||
GtkWidget *focus;
|
||||
gint position;
|
||||
gint s, e;
|
||||
const char *param;
|
||||
|
||||
if (widget == editor->priv->sv_plane)
|
||||
param = g_variant_get_string (parameters, NULL);
|
||||
|
||||
if (strcmp (param, "sv") == 0)
|
||||
{
|
||||
popup = editor->priv->sv_popup;
|
||||
focus = editor->priv->s_entry;
|
||||
position = 0;
|
||||
}
|
||||
else if (widget == editor->priv->h_slider)
|
||||
else if (strcmp (param, "h") == 0)
|
||||
{
|
||||
popup = editor->priv->h_popup;
|
||||
focus = editor->priv->h_entry;
|
||||
gtk_range_get_slider_range (GTK_RANGE (editor->priv->h_slider), &s, &e);
|
||||
position = (s + e) / 2;
|
||||
}
|
||||
else if (widget == editor->priv->a_slider)
|
||||
else if (strcmp (param, "a") == 0)
|
||||
{
|
||||
popup = editor->priv->a_popup;
|
||||
focus = editor->priv->a_entry;
|
||||
gtk_range_get_slider_range (GTK_RANGE (editor->priv->a_slider), &s, &e);
|
||||
position = (s + e) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("unsupported popup_edit parameter %s", param);
|
||||
}
|
||||
|
||||
if (popup == editor->priv->current_popup)
|
||||
dismiss_current_popup (editor);
|
||||
@ -544,8 +553,12 @@ gtk_color_editor_class_init (GtkColorEditorClass *class)
|
||||
gtk_widget_class_bind_template_callback (widget_class, entry_text_changed);
|
||||
gtk_widget_class_bind_template_callback (widget_class, entry_apply);
|
||||
gtk_widget_class_bind_template_callback (widget_class, entry_focus_changed);
|
||||
gtk_widget_class_bind_template_callback (widget_class, popup_edit);
|
||||
gtk_widget_class_bind_template_callback (widget_class, pick_color);
|
||||
|
||||
gtk_widget_class_install_action (widget_class, "color.edit", "s", popup_edit);
|
||||
gtk_widget_class_install_action (widget_class, "color.edit", "s", popup_edit);
|
||||
gtk_widget_class_install_action (widget_class, "color.edit", "s", popup_edit);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -28,6 +28,10 @@
|
||||
#include "gtksnapshot.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
#include "gtkshortcutcontroller.h"
|
||||
#include "gtkshortcuttrigger.h"
|
||||
#include "gtkshortcutaction.h"
|
||||
#include "gtkshortcut.h"
|
||||
|
||||
struct _GtkColorPlanePrivate
|
||||
{
|
||||
@ -244,11 +248,11 @@ static void
|
||||
hold_action (GtkGestureLongPress *gesture,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
GtkColorPlane *plane)
|
||||
GtkWidget *plane)
|
||||
{
|
||||
gboolean handled;
|
||||
|
||||
g_signal_emit_by_name (plane, "popup-menu", &handled);
|
||||
gtk_widget_activate_action (plane,
|
||||
"color.edit",
|
||||
"s", gtk_widget_get_name (plane));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -344,7 +348,7 @@ static void
|
||||
plane_drag_gesture_begin (GtkGestureDrag *gesture,
|
||||
gdouble start_x,
|
||||
gdouble start_y,
|
||||
GtkColorPlane *plane)
|
||||
GtkWidget *plane)
|
||||
{
|
||||
guint button;
|
||||
|
||||
@ -352,9 +356,9 @@ plane_drag_gesture_begin (GtkGestureDrag *gesture,
|
||||
|
||||
if (button == GDK_BUTTON_SECONDARY)
|
||||
{
|
||||
gboolean handled;
|
||||
|
||||
g_signal_emit_by_name (plane, "popup-menu", &handled);
|
||||
gtk_widget_activate_action (plane,
|
||||
"color.edit",
|
||||
"s", gtk_widget_get_name (plane));
|
||||
}
|
||||
|
||||
if (button != GDK_BUTTON_PRIMARY)
|
||||
@ -363,9 +367,9 @@ plane_drag_gesture_begin (GtkGestureDrag *gesture,
|
||||
return;
|
||||
}
|
||||
|
||||
set_cross_cursor (GTK_WIDGET (plane), TRUE);
|
||||
update_color (plane, start_x, start_y);
|
||||
gtk_widget_grab_focus (GTK_WIDGET (plane));
|
||||
set_cross_cursor (plane, TRUE);
|
||||
update_color (GTK_COLOR_PLANE (plane), start_x, start_y);
|
||||
gtk_widget_grab_focus (plane);
|
||||
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
||||
}
|
||||
|
||||
@ -397,6 +401,9 @@ gtk_color_plane_init (GtkColorPlane *plane)
|
||||
GtkEventController *controller;
|
||||
GtkGesture *gesture;
|
||||
AtkObject *atk_obj;
|
||||
GtkShortcutTrigger *trigger;
|
||||
GtkShortcutAction *action;
|
||||
GtkShortcut *shortcut;
|
||||
|
||||
plane->priv = gtk_color_plane_get_instance_private (plane);
|
||||
|
||||
@ -430,6 +437,14 @@ gtk_color_plane_init (GtkColorPlane *plane)
|
||||
g_signal_connect (controller, "key-pressed",
|
||||
G_CALLBACK (key_controller_key_pressed), plane);
|
||||
gtk_widget_add_controller (GTK_WIDGET (plane), controller);
|
||||
|
||||
controller = gtk_shortcut_controller_new ();
|
||||
trigger = gtk_alternative_trigger_new (gtk_keyval_trigger_new (GDK_KEY_F10, GDK_SHIFT_MASK),
|
||||
gtk_keyval_trigger_new (GDK_KEY_Menu, 0));
|
||||
action = gtk_action_action_new ("color.edit");
|
||||
shortcut = gtk_shortcut_new_with_arguments (trigger, action, "s", "sv");
|
||||
gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), shortcut);
|
||||
gtk_widget_add_controller (GTK_WIDGET (plane), controller);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -29,6 +29,10 @@
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtksnapshot.h"
|
||||
#include "gtkshortcutcontroller.h"
|
||||
#include "gtkshortcuttrigger.h"
|
||||
#include "gtkshortcutaction.h"
|
||||
#include "gtkshortcut.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
@ -48,7 +52,7 @@ enum
|
||||
static void hold_action (GtkGestureLongPress *gesture,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
GtkColorScale *scale);
|
||||
GtkWidget *scale);
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkColorScale, gtk_color_scale, GTK_TYPE_SCALE)
|
||||
|
||||
@ -160,6 +164,29 @@ gtk_color_scale_init (GtkColorScale *scale)
|
||||
gtk_widget_add_css_class (GTK_WIDGET (scale), "color");
|
||||
}
|
||||
|
||||
static void
|
||||
scale_constructed (GObject *object)
|
||||
{
|
||||
GtkColorScale *scale = GTK_COLOR_SCALE (object);
|
||||
GtkColorScalePrivate *priv = gtk_color_scale_get_instance_private (scale);
|
||||
GtkEventController *controller;
|
||||
GtkShortcutTrigger *trigger;
|
||||
GtkShortcutAction *action;
|
||||
GtkShortcut *shortcut;
|
||||
|
||||
controller = gtk_shortcut_controller_new ();
|
||||
trigger = gtk_alternative_trigger_new (gtk_keyval_trigger_new (GDK_KEY_F10, GDK_SHIFT_MASK),
|
||||
gtk_keyval_trigger_new (GDK_KEY_Menu, 0));
|
||||
action = gtk_action_action_new ("color.edit");
|
||||
shortcut = gtk_shortcut_new_with_arguments (trigger,
|
||||
action,
|
||||
"s",
|
||||
priv->type == GTK_COLOR_SCALE_ALPHA
|
||||
? "a" : "h");
|
||||
gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), shortcut);
|
||||
gtk_widget_add_controller (GTK_WIDGET (scale), controller);
|
||||
}
|
||||
|
||||
static void
|
||||
scale_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
@ -223,11 +250,11 @@ static void
|
||||
hold_action (GtkGestureLongPress *gesture,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
GtkColorScale *scale)
|
||||
GtkWidget *scale)
|
||||
{
|
||||
gboolean handled;
|
||||
|
||||
g_signal_emit_by_name (scale, "popup-menu", &handled);
|
||||
gtk_widget_activate_action (scale,
|
||||
"color.edit",
|
||||
"s", gtk_widget_get_name (scale));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -245,6 +272,7 @@ gtk_color_scale_class_init (GtkColorScaleClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
|
||||
object_class->constructed = scale_constructed;
|
||||
object_class->finalize = scale_finalize;
|
||||
object_class->get_property = scale_get_property;
|
||||
object_class->set_property = scale_set_property;
|
||||
@ -253,6 +281,7 @@ gtk_color_scale_class_init (GtkColorScaleClass *class)
|
||||
g_param_spec_int ("scale-type", P_("Scale type"), P_("Scale type"),
|
||||
0, 1, 0,
|
||||
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -348,13 +348,12 @@ gtk_color_swatch_measure (GtkWidget *widget,
|
||||
*natural = MAX (*natural, min);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static gboolean
|
||||
swatch_popup_menu (GtkWidget *widget)
|
||||
static void
|
||||
swatch_popup_menu (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
GVariant *parameters)
|
||||
{
|
||||
do_popup (GTK_COLOR_SWATCH (widget));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -480,7 +479,6 @@ gtk_color_swatch_class_init (GtkColorSwatchClass *class)
|
||||
|
||||
widget_class->measure = gtk_color_swatch_measure;
|
||||
widget_class->snapshot = swatch_snapshot;
|
||||
widget_class->popup_menu = swatch_popup_menu;
|
||||
widget_class->size_allocate = swatch_size_allocate;
|
||||
widget_class->state_flags_changed = swatch_state_flags_changed;
|
||||
|
||||
@ -497,6 +495,17 @@ gtk_color_swatch_class_init (GtkColorSwatchClass *class)
|
||||
g_param_spec_boolean ("can-drop", P_("Can Drop"), P_("Whether the swatch should accept drops"),
|
||||
FALSE, GTK_PARAM_READWRITE));
|
||||
|
||||
gtk_widget_class_install_action (widget_class, "menu.popup", NULL, swatch_popup_menu);
|
||||
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
GDK_KEY_F10, GDK_SHIFT_MASK,
|
||||
"menu.popup",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
GDK_KEY_Menu, 0,
|
||||
"menu.popup",
|
||||
NULL);
|
||||
|
||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_COLOR_SWATCH_ACCESSIBLE);
|
||||
gtk_widget_class_set_css_name (widget_class, I_("colorswatch"));
|
||||
}
|
||||
|
@ -19,12 +19,12 @@
|
||||
|
||||
#include "gtkcomboboxprivate.h"
|
||||
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkbox.h"
|
||||
#include "gtkcellareabox.h"
|
||||
#include "gtkcelllayout.h"
|
||||
#include "gtkcellrenderertext.h"
|
||||
#include "gtkcellview.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
#include "gtkeventcontrollerscroll.h"
|
||||
#include "gtkframe.h"
|
||||
#include "gtkbuiltiniconprivate.h"
|
||||
@ -33,10 +33,11 @@
|
||||
#include "gtkmain.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkshortcutcontroller.h"
|
||||
#include "gtktogglebutton.h"
|
||||
#include "gtktreepopoverprivate.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
#include "a11y/gtkcomboboxaccessible.h"
|
||||
|
||||
@ -409,7 +410,6 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
|
||||
GObjectClass *object_class;
|
||||
GtkContainerClass *container_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
container_class = (GtkContainerClass *)klass;
|
||||
container_class->forall = gtk_combo_box_forall;
|
||||
@ -560,57 +560,77 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
|
||||
G_TYPE_STRING, 1, G_TYPE_STRING);
|
||||
|
||||
/* key bindings */
|
||||
binding_set = gtk_binding_set_by_class (widget_class);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Down, GDK_MOD1_MASK,
|
||||
"popup",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Down, GDK_MOD1_MASK,
|
||||
"popup",
|
||||
NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Down, GDK_MOD1_MASK,
|
||||
"popup", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Down, GDK_MOD1_MASK,
|
||||
"popup", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Up, GDK_MOD1_MASK,
|
||||
"popdown",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Up, GDK_MOD1_MASK,
|
||||
"popdown",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Escape, 0,
|
||||
"popdown",
|
||||
NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Up, GDK_MOD1_MASK,
|
||||
"popdown", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Up, GDK_MOD1_MASK,
|
||||
"popdown", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0,
|
||||
"popdown", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Up, 0,
|
||||
"move-active",
|
||||
"(i)", GTK_SCROLL_STEP_UP);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Up, 0,
|
||||
"move-active",
|
||||
"(i)", GTK_SCROLL_STEP_UP);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Page_Up, 0,
|
||||
"move-active",
|
||||
"(i)", GTK_SCROLL_PAGE_UP);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Page_Up, 0,
|
||||
"move-active",
|
||||
"(i)", GTK_SCROLL_PAGE_UP);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Home, 0,
|
||||
"move-active",
|
||||
"(i)", GTK_SCROLL_START);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Home, 0,
|
||||
"move-active",
|
||||
"(i)", GTK_SCROLL_START);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Up, 0,
|
||||
"move-active", 1,
|
||||
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_UP);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Up, 0,
|
||||
"move-active", 1,
|
||||
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_UP);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Page_Up, 0,
|
||||
"move-active", 1,
|
||||
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_UP);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Page_Up, 0,
|
||||
"move-active", 1,
|
||||
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_UP);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Home, 0,
|
||||
"move-active", 1,
|
||||
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_START);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Home, 0,
|
||||
"move-active", 1,
|
||||
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_START);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Down, 0,
|
||||
"move-active", 1,
|
||||
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_DOWN);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Down, 0,
|
||||
"move-active", 1,
|
||||
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_DOWN);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Page_Down, 0,
|
||||
"move-active", 1,
|
||||
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_DOWN);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Page_Down, 0,
|
||||
"move-active", 1,
|
||||
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_DOWN);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_End, 0,
|
||||
"move-active", 1,
|
||||
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_END);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_End, 0,
|
||||
"move-active", 1,
|
||||
GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_END);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Down, 0,
|
||||
"move-active",
|
||||
"(i)", GTK_SCROLL_STEP_DOWN);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Down, 0,
|
||||
"move-active",
|
||||
"(i)", GTK_SCROLL_STEP_DOWN);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Page_Down, 0,
|
||||
"move-active",
|
||||
"(i)", GTK_SCROLL_PAGE_DOWN);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Page_Down, 0,
|
||||
"move-active",
|
||||
"(i)", GTK_SCROLL_PAGE_DOWN);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_End, 0,
|
||||
"move-active",
|
||||
"(i)", GTK_SCROLL_END);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_End, 0,
|
||||
"move-active",
|
||||
"(i)", GTK_SCROLL_END);
|
||||
|
||||
/* properties */
|
||||
g_object_class_override_property (object_class,
|
||||
@ -826,6 +846,7 @@ gtk_combo_box_init (GtkComboBox *combo_box)
|
||||
{
|
||||
GtkComboBoxPrivate *priv = gtk_combo_box_get_instance_private (combo_box);
|
||||
GtkEventController *controller;
|
||||
GList *controllers, *list;
|
||||
|
||||
priv->active = -1;
|
||||
priv->active_row = NULL;
|
||||
@ -860,6 +881,19 @@ gtk_combo_box_init (GtkComboBox *combo_box)
|
||||
G_CALLBACK (gtk_combo_box_scroll_controller_scroll),
|
||||
combo_box);
|
||||
gtk_widget_add_controller (GTK_WIDGET (combo_box), controller);
|
||||
|
||||
controllers = gtk_widget_list_controllers (priv->popup_widget, GTK_PHASE_BUBBLE);
|
||||
for (list = controllers; list; list = list->next)
|
||||
{
|
||||
if (GTK_IS_SHORTCUT_CONTROLLER (list->data))
|
||||
{
|
||||
g_object_ref (list->data);
|
||||
gtk_widget_remove_controller (priv->popup_widget, list->data);
|
||||
gtk_widget_add_controller (priv->popup_widget, list->data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_list_free (controllers);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1789,18 +1823,7 @@ gtk_combo_box_menu_key (GtkEventControllerKey *key,
|
||||
GdkModifierType modifiers,
|
||||
GtkComboBox *combo_box)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GdkEvent *event;
|
||||
|
||||
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (key));
|
||||
event = gtk_get_current_event ();
|
||||
|
||||
if (!gtk_bindings_activate_event (G_OBJECT (widget), event))
|
||||
{
|
||||
gtk_event_controller_key_forward (key, GTK_WIDGET (combo_box));
|
||||
}
|
||||
|
||||
gdk_event_unref (event);
|
||||
gtk_event_controller_key_forward (key, GTK_WIDGET (combo_box));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
254
gtk/gtkconcatmodel.c
Normal file
254
gtk/gtkconcatmodel.c
Normal file
@ -0,0 +1,254 @@
|
||||
/*
|
||||
* Copyright © 2018 Benjamin Otte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* SECTION:gtkconcatmodel
|
||||
* @Short_description: concatenation list model
|
||||
* @Title: GtkConcatModel
|
||||
* @See_also: #GListModel
|
||||
*
|
||||
* #GtkConcatModel is a #GListModel implementation that takes a list of list models
|
||||
* and presents them as one concatenated list.
|
||||
*
|
||||
* Node that all the types of the passed in list models must match the concat model's
|
||||
* type. If they are not, you must use a common ancestor type for the #GtkConcatModel,
|
||||
* %G_TYPE_OBJECT being the ultimate option.
|
||||
**/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkconcatmodelprivate.h"
|
||||
|
||||
struct _GtkConcatModel
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GType item_type;
|
||||
guint n_items;
|
||||
|
||||
GList *models;
|
||||
};
|
||||
|
||||
struct _GtkConcatModelClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
static GType
|
||||
gtk_concat_model_list_model_get_item_type (GListModel *list)
|
||||
{
|
||||
GtkConcatModel *self = GTK_CONCAT_MODEL (list);
|
||||
|
||||
return self->item_type;
|
||||
}
|
||||
|
||||
static guint
|
||||
gtk_concat_model_list_model_get_n_items (GListModel *list)
|
||||
{
|
||||
GtkConcatModel *self = GTK_CONCAT_MODEL (list);
|
||||
|
||||
return self->n_items;
|
||||
}
|
||||
|
||||
static gpointer
|
||||
gtk_concat_model_list_model_get_item (GListModel *list,
|
||||
guint position)
|
||||
{
|
||||
GtkConcatModel *self = GTK_CONCAT_MODEL (list);
|
||||
GList *l;
|
||||
|
||||
/* FIXME: Use an RBTree to make this O(log N) */
|
||||
for (l = self->models; l; l = l->next)
|
||||
{
|
||||
guint n = g_list_model_get_n_items (l->data);
|
||||
|
||||
if (position < n)
|
||||
return g_list_model_get_item (l->data, position);
|
||||
|
||||
position -= n;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_concat_model_list_model_init (GListModelInterface *iface)
|
||||
{
|
||||
iface->get_item_type = gtk_concat_model_list_model_get_item_type;
|
||||
iface->get_n_items = gtk_concat_model_list_model_get_n_items;
|
||||
iface->get_item = gtk_concat_model_list_model_get_item;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkConcatModel, gtk_concat_model,
|
||||
G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, gtk_concat_model_list_model_init))
|
||||
|
||||
static void
|
||||
gtk_concat_model_items_changed (GListModel *model,
|
||||
guint position,
|
||||
guint removed,
|
||||
guint added,
|
||||
GtkConcatModel *self)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
for (l = self->models; l; l = l->next)
|
||||
{
|
||||
if (l->data == model)
|
||||
break;
|
||||
|
||||
position += g_list_model_get_n_items (l->data);
|
||||
}
|
||||
|
||||
self->n_items -= removed;
|
||||
self->n_items += added;
|
||||
|
||||
g_list_model_items_changed (G_LIST_MODEL (self),
|
||||
position,
|
||||
removed,
|
||||
added);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_concat_model_remove_internal (GtkConcatModel *self,
|
||||
GListModel *model,
|
||||
gboolean emit_signals)
|
||||
{
|
||||
guint n_items, position;
|
||||
GList *l;
|
||||
|
||||
position = 0;
|
||||
for (l = self->models; l; l = l->next)
|
||||
{
|
||||
if (l->data == model)
|
||||
break;
|
||||
|
||||
position += g_list_model_get_n_items (l->data);
|
||||
}
|
||||
|
||||
g_return_if_fail (l != NULL);
|
||||
|
||||
self->models = g_list_delete_link (self->models, l);
|
||||
n_items = g_list_model_get_n_items (model);
|
||||
self->n_items -= n_items;
|
||||
g_signal_handlers_disconnect_by_func (model, gtk_concat_model_items_changed, self);
|
||||
g_object_unref (model);
|
||||
|
||||
if (n_items && emit_signals)
|
||||
g_list_model_items_changed (G_LIST_MODEL (self),
|
||||
position,
|
||||
n_items,
|
||||
0);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_concat_model_dispose (GObject *object)
|
||||
{
|
||||
GtkConcatModel *self = GTK_CONCAT_MODEL (object);
|
||||
|
||||
/* FIXME: Make this work without signal emissions */
|
||||
while (self->models)
|
||||
gtk_concat_model_remove_internal (self, self->models->data, FALSE);
|
||||
|
||||
G_OBJECT_CLASS (gtk_concat_model_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_concat_model_class_init (GtkConcatModelClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = gtk_concat_model_dispose;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_concat_model_init (GtkConcatModel *self)
|
||||
{
|
||||
}
|
||||
|
||||
GtkConcatModel *
|
||||
gtk_concat_model_new (GType item_type)
|
||||
{
|
||||
GtkConcatModel *self;
|
||||
|
||||
g_return_val_if_fail (g_type_is_a (item_type, G_TYPE_OBJECT), NULL);
|
||||
|
||||
self = g_object_new (GTK_TYPE_CONCAT_MODEL, NULL);
|
||||
|
||||
self->item_type = item_type;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_concat_model_append (GtkConcatModel *self,
|
||||
GListModel *model)
|
||||
{
|
||||
guint n_items;
|
||||
|
||||
g_return_if_fail (GTK_IS_CONCAT_MODEL (self));
|
||||
g_return_if_fail (G_IS_LIST_MODEL (model));
|
||||
g_return_if_fail (g_type_is_a (g_list_model_get_item_type (model), self->item_type));
|
||||
|
||||
g_object_ref (model);
|
||||
g_signal_connect (model, "items-changed", G_CALLBACK (gtk_concat_model_items_changed), self);
|
||||
self->models = g_list_append (self->models, model);
|
||||
n_items = g_list_model_get_n_items (model);
|
||||
self->n_items += n_items;
|
||||
|
||||
if (n_items)
|
||||
g_list_model_items_changed (G_LIST_MODEL (self),
|
||||
self->n_items - n_items,
|
||||
0,
|
||||
n_items);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_concat_model_remove (GtkConcatModel *self,
|
||||
GListModel *model)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_CONCAT_MODEL (self));
|
||||
g_return_if_fail (G_IS_LIST_MODEL (model));
|
||||
|
||||
gtk_concat_model_remove_internal (self, model, TRUE);
|
||||
}
|
||||
|
||||
GListModel *
|
||||
gtk_concat_model_get_model_for_item (GtkConcatModel *self,
|
||||
guint position)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_CONCAT_MODEL (self), NULL);
|
||||
|
||||
/* FIXME: Use an RBTree to make this O(log N) */
|
||||
for (l = self->models; l; l = l->next)
|
||||
{
|
||||
guint n = g_list_model_get_n_items (l->data);
|
||||
|
||||
if (position < n)
|
||||
return l->data;
|
||||
|
||||
position -= n;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
52
gtk/gtkconcatmodelprivate.h
Normal file
52
gtk/gtkconcatmodelprivate.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright © 2018 Benjamin Otte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __GTK_CONCAT_MODEL_H__
|
||||
#define __GTK_CONCAT_MODEL_H__
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_CONCAT_MODEL (gtk_concat_model_get_type ())
|
||||
#define GTK_CONCAT_MODEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_CONCAT_MODEL, GtkConcatModel))
|
||||
#define GTK_CONCAT_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GTK_TYPE_CONCAT_MODEL, GtkConcatModelClass))
|
||||
#define GTK_IS_CONCAT_MODEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_CONCAT_MODEL))
|
||||
#define GTK_IS_CONCAT_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTK_TYPE_CONCAT_MODEL))
|
||||
#define GTK_CONCAT_MODEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_CONCAT_MODEL, GtkConcatModelClass))
|
||||
|
||||
typedef struct _GtkConcatModel GtkConcatModel;
|
||||
typedef struct _GtkConcatModelClass GtkConcatModelClass;
|
||||
|
||||
GType gtk_concat_model_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkConcatModel * gtk_concat_model_new (GType item_type);
|
||||
|
||||
void gtk_concat_model_append (GtkConcatModel *self,
|
||||
GListModel *model);
|
||||
void gtk_concat_model_remove (GtkConcatModel *self,
|
||||
GListModel *model);
|
||||
|
||||
GListModel * gtk_concat_model_get_model_for_item (GtkConcatModel *self,
|
||||
guint position);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CONCAT_MODEL_H__ */
|
@ -38,7 +38,6 @@
|
||||
#include "gtkcontainerprivate.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkbuilderprivate.h"
|
||||
@ -490,7 +489,6 @@ gtk_dialog_class_init (GtkDialogClass *class)
|
||||
GObjectClass *gobject_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkWindowClass *window_class;
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
gobject_class = G_OBJECT_CLASS (class);
|
||||
widget_class = GTK_WIDGET_CLASS (class);
|
||||
@ -565,8 +563,7 @@ gtk_dialog_class_init (GtkDialogClass *class)
|
||||
-1, 1, -1,
|
||||
GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
binding_set = gtk_binding_set_by_class (class);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "close", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_Escape, 0, "close", NULL);
|
||||
|
||||
/* Bind class to template
|
||||
*/
|
||||
|
@ -119,12 +119,39 @@ gtk_emoji_chooser_child_focus (GtkWidget *widget,
|
||||
return GTK_WIDGET_CLASS (gtk_emoji_chooser_child_parent_class)->focus (widget, direction);
|
||||
}
|
||||
|
||||
static void show_variations (GtkEmojiChooser *chooser,
|
||||
GtkWidget *child);
|
||||
|
||||
static void
|
||||
gtk_emoji_chooser_child_popup_menu (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
GVariant *paramters)
|
||||
{
|
||||
GtkWidget *chooser;
|
||||
|
||||
chooser = gtk_widget_get_ancestor (widget, GTK_TYPE_EMOJI_CHOOSER);
|
||||
|
||||
show_variations (GTK_EMOJI_CHOOSER (chooser), widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_emoji_chooser_child_class_init (GtkEmojiChooserChildClass *class)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
widget_class->size_allocate = gtk_emoji_chooser_child_size_allocate;
|
||||
widget_class->focus = gtk_emoji_chooser_child_focus;
|
||||
|
||||
gtk_widget_class_install_action (widget_class, "menu.popup", NULL, gtk_emoji_chooser_child_popup_menu);
|
||||
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
GDK_KEY_F10, GDK_SHIFT_MASK,
|
||||
"menu.popup",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
GDK_KEY_Menu, 0,
|
||||
"menu.popup",
|
||||
NULL);
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, "emoji");
|
||||
}
|
||||
|
||||
@ -421,16 +448,6 @@ pressed_cb (GtkGesture *gesture,
|
||||
show_variations (chooser, child);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
popup_menu (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GtkEmojiChooser *chooser = data;
|
||||
|
||||
show_variations (chooser, widget);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
add_emoji (GtkWidget *box,
|
||||
gboolean prepend,
|
||||
@ -488,9 +505,6 @@ add_emoji (GtkWidget *box,
|
||||
if (modifier != 0)
|
||||
g_object_set_data (G_OBJECT (child), "modifier", GUINT_TO_POINTER (modifier));
|
||||
|
||||
if (chooser)
|
||||
g_signal_connect (child, "popup-menu", G_CALLBACK (popup_menu), chooser);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (child), label);
|
||||
gtk_flow_box_insert (GTK_FLOW_BOX (box), child, prepend ? 0 : -1);
|
||||
}
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include "gtkentryprivate.h"
|
||||
|
||||
#include "gtkadjustment.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkbox.h"
|
||||
#include "gtkbutton.h"
|
||||
#include "gtkcelleditable.h"
|
||||
|
@ -972,6 +972,25 @@ typedef enum
|
||||
GTK_PAN_DIRECTION_DOWN
|
||||
} GtkPanDirection;
|
||||
|
||||
/**
|
||||
* GtkShortcutScope:
|
||||
* @GTK_SHORTCUT_SCOPE_LOCAL: Shortcuts are handled inside
|
||||
* the widget the controller belongs to.
|
||||
* @GTK_SHORTCUT_SCOPE_MANAGED: Shortcuts are handled by
|
||||
* the first ancestor that is a #GtkShortcutManager
|
||||
* @GTK_SHORTCUT_SCOPE_GLOBAL: Shortcuts are handled by
|
||||
* the root widget.
|
||||
*
|
||||
* Describes where #GtkShortcuts added to a
|
||||
* #GtkShortcutController get handled.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GTK_SHORTCUT_SCOPE_LOCAL,
|
||||
GTK_SHORTCUT_SCOPE_MANAGED,
|
||||
GTK_SHORTCUT_SCOPE_GLOBAL
|
||||
} GtkShortcutScope;
|
||||
|
||||
/**
|
||||
* GtkPopoverConstraint:
|
||||
* @GTK_POPOVER_CONSTRAINT_NONE: Don't constrain the popover position
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkeventcontrollerprivate.h"
|
||||
#include "gtkeventcontrollerfocus.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkenums.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkeventcontrollerprivate.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkenums.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
@ -368,9 +367,6 @@ gtk_event_controller_key_forward (GtkEventControllerKey *controller,
|
||||
GTK_PHASE_BUBBLE))
|
||||
return TRUE;
|
||||
|
||||
if (gtk_bindings_activate_event (G_OBJECT (widget), controller->current_event))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "gtkfilechooserwidgetprivate.h"
|
||||
|
||||
#include "gtkbookmarksmanagerprivate.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkbutton.h"
|
||||
#include "gtkcelllayout.h"
|
||||
#include "gtkcellrendererpixbuf.h"
|
||||
@ -85,6 +84,10 @@
|
||||
#include "gtkbinlayout.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkpopovermenuprivate.h"
|
||||
#include "gtkshortcutcontroller.h"
|
||||
#include "gtkshortcuttrigger.h"
|
||||
#include "gtkshortcutaction.h"
|
||||
#include "gtkshortcut.h"
|
||||
|
||||
#include <cairo-gobject.h>
|
||||
|
||||
@ -1190,125 +1193,22 @@ places_sidebar_show_error_message_cb (GtkPlacesSidebar *sidebar,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
should_trigger_location_entry (GtkFileChooserWidget *impl,
|
||||
guint keyval,
|
||||
GdkModifierType state,
|
||||
const char **string)
|
||||
trigger_location_entry (GtkWidget *widget,
|
||||
GVariant *arguments,
|
||||
gpointer unused)
|
||||
{
|
||||
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (widget);
|
||||
GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl);
|
||||
GdkModifierType no_text_input_mask;
|
||||
|
||||
if (priv->operation_mode == OPERATION_MODE_SEARCH)
|
||||
return FALSE;
|
||||
|
||||
no_text_input_mask =
|
||||
gtk_widget_get_modifier_mask (GTK_WIDGET (impl), GDK_MODIFIER_INTENT_NO_TEXT_INPUT);
|
||||
|
||||
if (state & no_text_input_mask)
|
||||
if (priv->action != GTK_FILE_CHOOSER_ACTION_OPEN &&
|
||||
priv->action != GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
||||
return FALSE;
|
||||
|
||||
switch (keyval)
|
||||
{
|
||||
case GDK_KEY_slash:
|
||||
case GDK_KEY_KP_Divide:
|
||||
*string = "/";
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_period:
|
||||
*string = ".";
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_asciitilde:
|
||||
*string = "~";
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Handles key press events on the file list, so that we can trap Enter to
|
||||
* activate the default button on our own. Also, checks to see if “/” has been
|
||||
* pressed.
|
||||
*/
|
||||
static gboolean
|
||||
treeview_key_press_cb (GtkEventControllerKey *controller,
|
||||
guint keyval,
|
||||
guint keycode,
|
||||
GdkModifierType state,
|
||||
gpointer data)
|
||||
{
|
||||
GtkFileChooserWidget *impl = (GtkFileChooserWidget *) data;
|
||||
GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl);
|
||||
const char *string;
|
||||
|
||||
if (should_trigger_location_entry (impl, keyval, state, &string) &&
|
||||
(priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
||||
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER))
|
||||
{
|
||||
location_popup_handler (impl, string);
|
||||
return GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
if ((keyval == GDK_KEY_Return ||
|
||||
keyval == GDK_KEY_ISO_Enter ||
|
||||
keyval == GDK_KEY_KP_Enter ||
|
||||
keyval == GDK_KEY_space ||
|
||||
keyval == GDK_KEY_KP_Space) &&
|
||||
!(state & gtk_accelerator_get_default_mod_mask ()) &&
|
||||
priv->action != GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
||||
{
|
||||
gtk_widget_activate_default (GTK_WIDGET (impl));
|
||||
return GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
if (keyval == GDK_KEY_Escape &&
|
||||
priv->operation_mode == OPERATION_MODE_SEARCH)
|
||||
{
|
||||
return gtk_event_controller_key_forward (controller,
|
||||
GTK_WIDGET (gtk_search_entry_get_text_widget (GTK_SEARCH_ENTRY (priv->search_entry))));
|
||||
}
|
||||
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
widget_key_press_cb (GtkEventControllerKey *controller,
|
||||
guint keyval,
|
||||
guint keycode,
|
||||
GdkModifierType state,
|
||||
gpointer data)
|
||||
{
|
||||
GtkFileChooserWidget *impl = (GtkFileChooserWidget *) data;
|
||||
GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl);
|
||||
gboolean handled = FALSE;
|
||||
const char *string;
|
||||
|
||||
if (should_trigger_location_entry (impl, keyval, state, &string))
|
||||
{
|
||||
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
||||
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
||||
{
|
||||
location_popup_handler (impl, string);
|
||||
handled = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
priv->starting_search = TRUE;
|
||||
if (gtk_event_controller_key_forward (controller, priv->search_entry))
|
||||
{
|
||||
gtk_widget_grab_focus (priv->search_entry);
|
||||
|
||||
if (priv->operation_mode != OPERATION_MODE_SEARCH &&
|
||||
priv->starting_search)
|
||||
operation_mode_set (impl, OPERATION_MODE_SEARCH);
|
||||
|
||||
handled = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return handled;
|
||||
location_popup_handler (impl, g_variant_get_string (arguments, NULL));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Callback used from gtk_tree_selection_selected_foreach(); adds a bookmark for
|
||||
@ -2132,11 +2032,12 @@ file_list_show_popover (GtkFileChooserWidget *impl,
|
||||
gtk_popover_popup (GTK_POPOVER (priv->browse_files_popover));
|
||||
}
|
||||
|
||||
/* Callback used for the GtkWidget::popup-menu signal of the file list */
|
||||
static gboolean
|
||||
list_popup_menu_cb (GtkWidget *widget,
|
||||
GtkFileChooserWidget *impl)
|
||||
list_popup_menu_cb (GtkWidget *widget,
|
||||
GVariant *args,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (user_data);
|
||||
GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl);
|
||||
graphene_rect_t bounds;
|
||||
|
||||
@ -2151,6 +2052,16 @@ list_popup_menu_cb (GtkWidget *widget,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
files_list_clicked (GtkGesture *gesture,
|
||||
int n_press,
|
||||
double x,
|
||||
double y,
|
||||
GtkFileChooserWidget *impl)
|
||||
{
|
||||
list_popup_menu_cb (NULL, NULL, impl);
|
||||
}
|
||||
|
||||
/* Callback used when a button is pressed on the file list. We trap button 3 to
|
||||
* bring up a popup menu.
|
||||
*/
|
||||
@ -7461,18 +7372,20 @@ show_hidden_handler (GtkFileChooserWidget *impl)
|
||||
}
|
||||
|
||||
static void
|
||||
add_normal_and_shifted_binding (GtkBindingSet *binding_set,
|
||||
add_normal_and_shifted_binding (GtkWidgetClass *widget_class,
|
||||
guint keyval,
|
||||
GdkModifierType modifiers,
|
||||
const gchar *signal_name)
|
||||
{
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
keyval, modifiers,
|
||||
signal_name, 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modifiers,
|
||||
signal_name,
|
||||
NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
keyval, modifiers | GDK_SHIFT_MASK,
|
||||
signal_name, 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modifiers | GDK_SHIFT_MASK,
|
||||
signal_name,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -7483,7 +7396,6 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
|
||||
};
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
GtkBindingSet *binding_set;
|
||||
gint i;
|
||||
|
||||
gobject_class->finalize = gtk_file_chooser_widget_finalize;
|
||||
@ -7764,71 +7676,84 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
|
||||
NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
binding_set = gtk_binding_set_by_class (class);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_l, GDK_CONTROL_MASK,
|
||||
"location-toggle-popup",
|
||||
NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_l, GDK_CONTROL_MASK,
|
||||
"location-toggle-popup",
|
||||
0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_v, GDK_CONTROL_MASK,
|
||||
"location-popup-on-paste",
|
||||
NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_v, GDK_CONTROL_MASK,
|
||||
"location-popup-on-paste",
|
||||
0);
|
||||
|
||||
add_normal_and_shifted_binding (binding_set,
|
||||
add_normal_and_shifted_binding (widget_class,
|
||||
GDK_KEY_Up, GDK_MOD1_MASK,
|
||||
"up-folder");
|
||||
|
||||
add_normal_and_shifted_binding (binding_set,
|
||||
add_normal_and_shifted_binding (widget_class,
|
||||
GDK_KEY_KP_Up, GDK_MOD1_MASK,
|
||||
"up-folder");
|
||||
|
||||
add_normal_and_shifted_binding (binding_set,
|
||||
add_normal_and_shifted_binding (widget_class,
|
||||
GDK_KEY_Down, GDK_MOD1_MASK,
|
||||
"down-folder");
|
||||
add_normal_and_shifted_binding (binding_set,
|
||||
add_normal_and_shifted_binding (widget_class,
|
||||
GDK_KEY_KP_Down, GDK_MOD1_MASK,
|
||||
"down-folder");
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_Home, GDK_MOD1_MASK,
|
||||
"home-folder",
|
||||
0);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_KP_Home, GDK_MOD1_MASK,
|
||||
"home-folder",
|
||||
0);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_d, GDK_MOD1_MASK,
|
||||
"desktop-folder",
|
||||
0);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_h, GDK_CONTROL_MASK,
|
||||
"show-hidden",
|
||||
0);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_s, GDK_MOD1_MASK,
|
||||
"search-shortcut",
|
||||
0);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_f, GDK_CONTROL_MASK,
|
||||
"search-shortcut",
|
||||
0);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_r, GDK_MOD1_MASK,
|
||||
"recent-shortcut",
|
||||
0);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_p, GDK_MOD1_MASK,
|
||||
"places-shortcut",
|
||||
0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Home, GDK_MOD1_MASK,
|
||||
"home-folder",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Home, GDK_MOD1_MASK,
|
||||
"home-folder",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_d, GDK_MOD1_MASK,
|
||||
"desktop-folder",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_h, GDK_CONTROL_MASK,
|
||||
"show-hidden",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_s, GDK_MOD1_MASK,
|
||||
"search-shortcut",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_f, GDK_CONTROL_MASK,
|
||||
"search-shortcut",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_r, GDK_MOD1_MASK,
|
||||
"recent-shortcut",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_p, GDK_MOD1_MASK,
|
||||
"places-shortcut",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding (widget_class,
|
||||
GDK_KEY_slash, 0,
|
||||
trigger_location_entry,
|
||||
"s", "/");
|
||||
gtk_widget_class_add_binding (widget_class,
|
||||
GDK_KEY_KP_Divide, 0,
|
||||
trigger_location_entry,
|
||||
"s", "/");
|
||||
gtk_widget_class_add_binding (widget_class,
|
||||
GDK_KEY_period, 0,
|
||||
trigger_location_entry,
|
||||
"s", ".");
|
||||
gtk_widget_class_add_binding (widget_class,
|
||||
GDK_KEY_asciitilde, 0,
|
||||
trigger_location_entry,
|
||||
"s", "~");
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
quick_bookmark_keyvals[i], GDK_MOD1_MASK,
|
||||
"quick-bookmark",
|
||||
1, G_TYPE_INT, i);
|
||||
for (i = 0; i < G_N_ELEMENTS (quick_bookmark_keyvals); i++)
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
quick_bookmark_keyvals[i], GDK_MOD1_MASK,
|
||||
"quick-bookmark",
|
||||
"(i)", i);
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_SEARCH_MODE,
|
||||
g_param_spec_boolean ("search-mode",
|
||||
@ -7893,7 +7818,6 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, box);
|
||||
|
||||
/* And a *lot* of callbacks to bind ... */
|
||||
gtk_widget_class_bind_template_callback (widget_class, list_popup_menu_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, file_list_query_tooltip_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, list_row_activated);
|
||||
gtk_widget_class_bind_template_callback (widget_class, list_selection_changed);
|
||||
@ -7913,8 +7837,6 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
|
||||
gtk_widget_class_bind_template_callback (widget_class, rename_file_end);
|
||||
gtk_widget_class_bind_template_callback (widget_class, click_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, long_press_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, treeview_key_press_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, widget_key_press_cb);
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, I_("filechooser"));
|
||||
|
||||
@ -7930,6 +7852,11 @@ post_process_ui (GtkFileChooserWidget *impl)
|
||||
GList *cells;
|
||||
GFile *file;
|
||||
GtkDropTarget *target;
|
||||
GtkGesture *gesture;
|
||||
GtkEventController *controller;
|
||||
GtkShortcutTrigger *trigger;
|
||||
GtkShortcutAction *action;
|
||||
GtkShortcut *shortcut;
|
||||
|
||||
/* Setup file list treeview */
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
||||
@ -7988,6 +7915,20 @@ post_process_ui (GtkFileChooserWidget *impl)
|
||||
priv->item_actions);
|
||||
|
||||
gtk_search_entry_set_key_capture_widget (GTK_SEARCH_ENTRY (priv->search_entry), priv->search_entry);
|
||||
|
||||
gesture = gtk_gesture_click_new ();
|
||||
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);
|
||||
g_signal_connect (gesture, "pressed", G_CALLBACK (files_list_clicked), impl);
|
||||
gtk_widget_add_controller (GTK_WIDGET (priv->browse_files_tree_view), GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
controller = gtk_shortcut_controller_new ();
|
||||
trigger = gtk_alternative_trigger_new (gtk_keyval_trigger_new (GDK_KEY_F10, GDK_SHIFT_MASK),
|
||||
gtk_keyval_trigger_new (GDK_KEY_Menu, 0));
|
||||
action = gtk_callback_action_new (list_popup_menu_cb, impl, NULL);
|
||||
shortcut = gtk_shortcut_new (trigger, action);
|
||||
gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), shortcut);
|
||||
gtk_widget_add_controller (GTK_WIDGET (priv->browse_files_tree_view), controller);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -78,7 +78,6 @@
|
||||
#include "gtkflowbox.h"
|
||||
|
||||
#include "gtkadjustment.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkcontainerprivate.h"
|
||||
#include "gtkcsscolorvalueprivate.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
@ -2987,7 +2986,7 @@ gtk_flow_box_focus (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_flow_box_add_move_binding (GtkBindingSet *binding_set,
|
||||
gtk_flow_box_add_move_binding (GtkWidgetClass *widget_class,
|
||||
guint keyval,
|
||||
GdkModifierType modmask,
|
||||
GtkMovementStep step,
|
||||
@ -2998,7 +2997,7 @@ gtk_flow_box_add_move_binding (GtkBindingSet *binding_set,
|
||||
GdkModifierType modify_mod_mask = GDK_CONTROL_MASK;
|
||||
|
||||
display = gdk_display_get_default ();
|
||||
if (display)
|
||||
if (display != NULL)
|
||||
{
|
||||
extend_mod_mask = gdk_keymap_get_modifier_mask (gdk_display_get_keymap (display),
|
||||
GDK_MODIFIER_INTENT_EXTEND_SELECTION);
|
||||
@ -3006,26 +3005,22 @@ gtk_flow_box_add_move_binding (GtkBindingSet *binding_set,
|
||||
GDK_MODIFIER_INTENT_MODIFY_SELECTION);
|
||||
}
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, modmask,
|
||||
"move-cursor", 2,
|
||||
GTK_TYPE_MOVEMENT_STEP, step,
|
||||
G_TYPE_INT, count,
|
||||
NULL);
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, modmask | extend_mod_mask,
|
||||
"move-cursor", 2,
|
||||
GTK_TYPE_MOVEMENT_STEP, step,
|
||||
G_TYPE_INT, count,
|
||||
NULL);
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, modmask | modify_mod_mask,
|
||||
"move-cursor", 2,
|
||||
GTK_TYPE_MOVEMENT_STEP, step,
|
||||
G_TYPE_INT, count,
|
||||
NULL);
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, modmask | extend_mod_mask | modify_mod_mask,
|
||||
"move-cursor", 2,
|
||||
GTK_TYPE_MOVEMENT_STEP, step,
|
||||
G_TYPE_INT, count,
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modmask,
|
||||
"move-cursor",
|
||||
"(ii)", step, count);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modmask | extend_mod_mask,
|
||||
"move-cursor",
|
||||
"(ii)", step, count);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modmask | modify_mod_mask,
|
||||
"move-cursor",
|
||||
"(ii)", step, count);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modmask | extend_mod_mask | modify_mod_mask,
|
||||
"move-cursor",
|
||||
"(ii)", step, count);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -3387,7 +3382,6 @@ gtk_flow_box_class_init (GtkFlowBoxClass *class)
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
object_class->finalize = gtk_flow_box_finalize;
|
||||
object_class->get_property = gtk_flow_box_get_property;
|
||||
@ -3664,50 +3658,57 @@ gtk_flow_box_class_init (GtkFlowBoxClass *class)
|
||||
|
||||
widget_class->activate_signal = signals[ACTIVATE_CURSOR_CHILD];
|
||||
|
||||
binding_set = gtk_binding_set_by_class (class);
|
||||
gtk_flow_box_add_move_binding (binding_set, GDK_KEY_Home, 0,
|
||||
gtk_flow_box_add_move_binding (widget_class, GDK_KEY_Home, 0,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, -1);
|
||||
gtk_flow_box_add_move_binding (binding_set, GDK_KEY_KP_Home, 0,
|
||||
gtk_flow_box_add_move_binding (widget_class, GDK_KEY_KP_Home, 0,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, -1);
|
||||
gtk_flow_box_add_move_binding (binding_set, GDK_KEY_End, 0,
|
||||
gtk_flow_box_add_move_binding (widget_class, GDK_KEY_End, 0,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, 1);
|
||||
gtk_flow_box_add_move_binding (binding_set, GDK_KEY_KP_End, 0,
|
||||
gtk_flow_box_add_move_binding (widget_class, GDK_KEY_KP_End, 0,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, 1);
|
||||
gtk_flow_box_add_move_binding (binding_set, GDK_KEY_Up, 0,
|
||||
gtk_flow_box_add_move_binding (widget_class, GDK_KEY_Up, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, -1);
|
||||
gtk_flow_box_add_move_binding (binding_set, GDK_KEY_KP_Up, 0,
|
||||
gtk_flow_box_add_move_binding (widget_class, GDK_KEY_KP_Up, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, -1);
|
||||
gtk_flow_box_add_move_binding (binding_set, GDK_KEY_Down, 0,
|
||||
gtk_flow_box_add_move_binding (widget_class, GDK_KEY_Down, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, 1);
|
||||
gtk_flow_box_add_move_binding (binding_set, GDK_KEY_KP_Down, 0,
|
||||
gtk_flow_box_add_move_binding (widget_class, GDK_KEY_KP_Down, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, 1);
|
||||
gtk_flow_box_add_move_binding (binding_set, GDK_KEY_Page_Up, 0,
|
||||
gtk_flow_box_add_move_binding (widget_class, GDK_KEY_Page_Up, 0,
|
||||
GTK_MOVEMENT_PAGES, -1);
|
||||
gtk_flow_box_add_move_binding (binding_set, GDK_KEY_KP_Page_Up, 0,
|
||||
gtk_flow_box_add_move_binding (widget_class, GDK_KEY_KP_Page_Up, 0,
|
||||
GTK_MOVEMENT_PAGES, -1);
|
||||
gtk_flow_box_add_move_binding (binding_set, GDK_KEY_Page_Down, 0,
|
||||
gtk_flow_box_add_move_binding (widget_class, GDK_KEY_Page_Down, 0,
|
||||
GTK_MOVEMENT_PAGES, 1);
|
||||
gtk_flow_box_add_move_binding (binding_set, GDK_KEY_KP_Page_Down, 0,
|
||||
gtk_flow_box_add_move_binding (widget_class, GDK_KEY_KP_Page_Down, 0,
|
||||
GTK_MOVEMENT_PAGES, 1);
|
||||
|
||||
gtk_flow_box_add_move_binding (binding_set, GDK_KEY_Right, 0,
|
||||
gtk_flow_box_add_move_binding (widget_class, GDK_KEY_Right, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, 1);
|
||||
gtk_flow_box_add_move_binding (binding_set, GDK_KEY_KP_Right, 0,
|
||||
gtk_flow_box_add_move_binding (widget_class, GDK_KEY_KP_Right, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, 1);
|
||||
gtk_flow_box_add_move_binding (binding_set, GDK_KEY_Left, 0,
|
||||
gtk_flow_box_add_move_binding (widget_class, GDK_KEY_Left, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, -1);
|
||||
gtk_flow_box_add_move_binding (binding_set, GDK_KEY_KP_Left, 0,
|
||||
gtk_flow_box_add_move_binding (widget_class, GDK_KEY_KP_Left, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, -1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_space, GDK_CONTROL_MASK,
|
||||
"toggle-cursor-child", 0, NULL);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Space, GDK_CONTROL_MASK,
|
||||
"toggle-cursor-child", 0, NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_space, GDK_CONTROL_MASK,
|
||||
"toggle-cursor-child",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Space, GDK_CONTROL_MASK,
|
||||
"toggle-cursor-child",
|
||||
NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK,
|
||||
"select-all", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"unselect-all", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_a, GDK_CONTROL_MASK,
|
||||
"select-all",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_a, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"unselect-all",
|
||||
NULL);
|
||||
|
||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_FLOW_BOX_ACCESSIBLE);
|
||||
gtk_widget_class_set_css_name (widget_class, I_("flowbox"));
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include "gtkaccessible.h"
|
||||
#include "gtkadjustmentprivate.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkcellareabox.h"
|
||||
#include "gtkcellareacontext.h"
|
||||
#include "gtkcelllayout.h"
|
||||
@ -235,7 +234,7 @@ static gboolean gtk_icon_view_unselect_all_internal (GtkIco
|
||||
static void gtk_icon_view_update_rubberband (GtkIconView *icon_view);
|
||||
static void gtk_icon_view_item_invalidate_size (GtkIconViewItem *item);
|
||||
static void gtk_icon_view_invalidate_sizes (GtkIconView *icon_view);
|
||||
static void gtk_icon_view_add_move_binding (GtkBindingSet *binding_set,
|
||||
static void gtk_icon_view_add_move_binding (GtkWidgetClass *widget_class,
|
||||
guint keyval,
|
||||
guint modmask,
|
||||
GtkMovementStep step,
|
||||
@ -337,16 +336,9 @@ G_DEFINE_TYPE_WITH_CODE (GtkIconView, gtk_icon_view, GTK_TYPE_CONTAINER,
|
||||
static void
|
||||
gtk_icon_view_class_init (GtkIconViewClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkContainerClass *container_class;
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
binding_set = gtk_binding_set_by_class (klass);
|
||||
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
widget_class = (GtkWidgetClass *) klass;
|
||||
container_class = (GtkContainerClass *) klass;
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
|
||||
|
||||
gobject_class->constructed = gtk_icon_view_constructed;
|
||||
gobject_class->dispose = gtk_icon_view_dispose;
|
||||
@ -813,70 +805,88 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
|
||||
_gtk_marshal_BOOLEAN__ENUM_INTv);
|
||||
|
||||
/* Key bindings */
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK,
|
||||
"select-all", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"unselect-all", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_space, GDK_CONTROL_MASK,
|
||||
"toggle-cursor-item", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Space, GDK_CONTROL_MASK,
|
||||
"toggle-cursor-item", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_a, GDK_CONTROL_MASK,
|
||||
"select-all",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_a, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"unselect-all",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_space, GDK_CONTROL_MASK,
|
||||
"toggle-cursor-item",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Space, GDK_CONTROL_MASK,
|
||||
"toggle-cursor-item",
|
||||
NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_space, 0,
|
||||
"activate-cursor-item", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Space, 0,
|
||||
"activate-cursor-item", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Return, 0,
|
||||
"activate-cursor-item", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_ISO_Enter, 0,
|
||||
"activate-cursor-item", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Enter, 0,
|
||||
"activate-cursor-item", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_space, 0,
|
||||
"activate-cursor-item",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Space, 0,
|
||||
"activate-cursor-item",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Return, 0,
|
||||
"activate-cursor-item",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_ISO_Enter, 0,
|
||||
"activate-cursor-item",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Enter, 0,
|
||||
"activate-cursor-item",
|
||||
NULL);
|
||||
|
||||
gtk_icon_view_add_move_binding (binding_set, GDK_KEY_Up, 0,
|
||||
gtk_icon_view_add_move_binding (widget_class, GDK_KEY_Up, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, -1);
|
||||
gtk_icon_view_add_move_binding (binding_set, GDK_KEY_KP_Up, 0,
|
||||
gtk_icon_view_add_move_binding (widget_class, GDK_KEY_KP_Up, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, -1);
|
||||
|
||||
gtk_icon_view_add_move_binding (binding_set, GDK_KEY_Down, 0,
|
||||
gtk_icon_view_add_move_binding (widget_class, GDK_KEY_Down, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, 1);
|
||||
gtk_icon_view_add_move_binding (binding_set, GDK_KEY_KP_Down, 0,
|
||||
gtk_icon_view_add_move_binding (widget_class, GDK_KEY_KP_Down, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, 1);
|
||||
|
||||
gtk_icon_view_add_move_binding (binding_set, GDK_KEY_p, GDK_CONTROL_MASK,
|
||||
gtk_icon_view_add_move_binding (widget_class, GDK_KEY_p, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, -1);
|
||||
|
||||
gtk_icon_view_add_move_binding (binding_set, GDK_KEY_n, GDK_CONTROL_MASK,
|
||||
gtk_icon_view_add_move_binding (widget_class, GDK_KEY_n, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, 1);
|
||||
|
||||
gtk_icon_view_add_move_binding (binding_set, GDK_KEY_Home, 0,
|
||||
gtk_icon_view_add_move_binding (widget_class, GDK_KEY_Home, 0,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, -1);
|
||||
gtk_icon_view_add_move_binding (binding_set, GDK_KEY_KP_Home, 0,
|
||||
gtk_icon_view_add_move_binding (widget_class, GDK_KEY_KP_Home, 0,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, -1);
|
||||
|
||||
gtk_icon_view_add_move_binding (binding_set, GDK_KEY_End, 0,
|
||||
gtk_icon_view_add_move_binding (widget_class, GDK_KEY_End, 0,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, 1);
|
||||
gtk_icon_view_add_move_binding (binding_set, GDK_KEY_KP_End, 0,
|
||||
gtk_icon_view_add_move_binding (widget_class, GDK_KEY_KP_End, 0,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, 1);
|
||||
|
||||
gtk_icon_view_add_move_binding (binding_set, GDK_KEY_Page_Up, 0,
|
||||
gtk_icon_view_add_move_binding (widget_class, GDK_KEY_Page_Up, 0,
|
||||
GTK_MOVEMENT_PAGES, -1);
|
||||
gtk_icon_view_add_move_binding (binding_set, GDK_KEY_KP_Page_Up, 0,
|
||||
gtk_icon_view_add_move_binding (widget_class, GDK_KEY_KP_Page_Up, 0,
|
||||
GTK_MOVEMENT_PAGES, -1);
|
||||
|
||||
gtk_icon_view_add_move_binding (binding_set, GDK_KEY_Page_Down, 0,
|
||||
gtk_icon_view_add_move_binding (widget_class, GDK_KEY_Page_Down, 0,
|
||||
GTK_MOVEMENT_PAGES, 1);
|
||||
gtk_icon_view_add_move_binding (binding_set, GDK_KEY_KP_Page_Down, 0,
|
||||
gtk_icon_view_add_move_binding (widget_class, GDK_KEY_KP_Page_Down, 0,
|
||||
GTK_MOVEMENT_PAGES, 1);
|
||||
|
||||
gtk_icon_view_add_move_binding (binding_set, GDK_KEY_Right, 0,
|
||||
gtk_icon_view_add_move_binding (widget_class, GDK_KEY_Right, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, 1);
|
||||
gtk_icon_view_add_move_binding (binding_set, GDK_KEY_Left, 0,
|
||||
gtk_icon_view_add_move_binding (widget_class, GDK_KEY_Left, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, -1);
|
||||
|
||||
gtk_icon_view_add_move_binding (binding_set, GDK_KEY_KP_Right, 0,
|
||||
gtk_icon_view_add_move_binding (widget_class, GDK_KEY_KP_Right, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, 1);
|
||||
gtk_icon_view_add_move_binding (binding_set, GDK_KEY_KP_Left, 0,
|
||||
gtk_icon_view_add_move_binding (widget_class, GDK_KEY_KP_Left, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, -1);
|
||||
|
||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_ICON_VIEW_ACCESSIBLE);
|
||||
@ -3405,35 +3415,35 @@ gtk_icon_view_build_items (GtkIconView *icon_view)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_icon_view_add_move_binding (GtkBindingSet *binding_set,
|
||||
gtk_icon_view_add_move_binding (GtkWidgetClass *widget_class,
|
||||
guint keyval,
|
||||
guint modmask,
|
||||
GtkMovementStep step,
|
||||
gint count)
|
||||
{
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, modmask,
|
||||
I_("move-cursor"), 2,
|
||||
G_TYPE_ENUM, step,
|
||||
G_TYPE_INT, count);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modmask,
|
||||
I_("move-cursor"),
|
||||
"(ii)", step, count);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, GDK_SHIFT_MASK,
|
||||
"move-cursor", 2,
|
||||
G_TYPE_ENUM, step,
|
||||
G_TYPE_INT, count);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, GDK_SHIFT_MASK,
|
||||
"move-cursor",
|
||||
"(ii)", step, count);
|
||||
|
||||
if ((modmask & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
|
||||
return;
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"move-cursor", 2,
|
||||
G_TYPE_ENUM, step,
|
||||
G_TYPE_INT, count);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"move-cursor",
|
||||
"(ii)", step, count);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, GDK_CONTROL_MASK,
|
||||
"move-cursor", 2,
|
||||
G_TYPE_ENUM, step,
|
||||
G_TYPE_INT, count);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, GDK_CONTROL_MASK,
|
||||
"move-cursor",
|
||||
"(ii)", step, count);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "gtklabel.h"
|
||||
#include "gtkbutton.h"
|
||||
#include "gtkenums.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkdialog.h"
|
||||
#include "gtkrevealer.h"
|
||||
#include "gtkintl.h"
|
||||
@ -378,14 +377,9 @@ gtk_info_bar_dispose (GObject *object)
|
||||
static void
|
||||
gtk_info_bar_class_init (GtkInfoBarClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkContainerClass *container_class;
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
widget_class = GTK_WIDGET_CLASS (klass);
|
||||
container_class = GTK_CONTAINER_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
|
||||
|
||||
object_class->get_property = gtk_info_bar_get_property;
|
||||
object_class->set_property = gtk_info_bar_set_property;
|
||||
@ -469,9 +463,10 @@ gtk_info_bar_class_init (GtkInfoBarClass *klass)
|
||||
NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
binding_set = gtk_binding_set_by_class (klass);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "close", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Escape, 0,
|
||||
"close",
|
||||
NULL);
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, I_("infobar"));
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||
|
220
gtk/gtklabel.c
220
gtk/gtklabel.c
@ -26,7 +26,6 @@
|
||||
|
||||
#include "gtklabelprivate.h"
|
||||
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkbuilderprivate.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
@ -42,6 +41,9 @@
|
||||
#include "gtknotebook.h"
|
||||
#include "gtkpango.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkshortcut.h"
|
||||
#include "gtkshortcutcontroller.h"
|
||||
#include "gtkshortcuttrigger.h"
|
||||
#include "gtkshow.h"
|
||||
#include "gtksnapshot.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
@ -276,7 +278,7 @@ struct _GtkLabelPrivate
|
||||
{
|
||||
GtkLabelSelectionInfo *select_info;
|
||||
GtkWidget *mnemonic_widget;
|
||||
GtkWindow *mnemonic_window;
|
||||
GtkEventController *mnemonic_controller;
|
||||
|
||||
PangoAttrList *attrs;
|
||||
PangoAttrList *markup_attrs;
|
||||
@ -414,7 +416,6 @@ static GParamSpec *label_props[NUM_PROPERTIES] = { NULL, };
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static GQuark quark_shortcuts_connected;
|
||||
static GQuark quark_mnemonic_menu;
|
||||
static GQuark quark_mnemonics_visible_connected;
|
||||
static GQuark quark_gtk_signal;
|
||||
static GQuark quark_link;
|
||||
@ -479,7 +480,9 @@ static void gtk_label_set_markup_internal (GtkLabel *label,
|
||||
static void gtk_label_recalculate (GtkLabel *label);
|
||||
static void gtk_label_root (GtkWidget *widget);
|
||||
static void gtk_label_unroot (GtkWidget *widget);
|
||||
static gboolean gtk_label_popup_menu (GtkWidget *widget);
|
||||
static void gtk_label_popup_menu (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
GVariant *parameters);
|
||||
static void gtk_label_do_popup (GtkLabel *label,
|
||||
double x,
|
||||
double y);
|
||||
@ -499,9 +502,7 @@ static void gtk_label_update_active_link (GtkWidget *widget,
|
||||
|
||||
static gboolean gtk_label_mnemonic_activate (GtkWidget *widget,
|
||||
gboolean group_cycling);
|
||||
static void gtk_label_setup_mnemonic (GtkLabel *label,
|
||||
GtkWidget *toplevel,
|
||||
guint last_key);
|
||||
static void gtk_label_setup_mnemonic (GtkLabel *label);
|
||||
|
||||
static void gtk_label_buildable_interface_init (GtkBuildableIface *iface);
|
||||
static gboolean gtk_label_buildable_custom_tag_start (GtkBuildable *buildable,
|
||||
@ -606,7 +607,7 @@ G_DEFINE_TYPE_WITH_CODE (GtkLabel, gtk_label, GTK_TYPE_WIDGET,
|
||||
gtk_label_buildable_interface_init))
|
||||
|
||||
static void
|
||||
add_move_binding (GtkBindingSet *binding_set,
|
||||
add_move_binding (GtkWidgetClass *widget_class,
|
||||
guint keyval,
|
||||
guint modmask,
|
||||
GtkMovementStep step,
|
||||
@ -614,18 +615,16 @@ add_move_binding (GtkBindingSet *binding_set,
|
||||
{
|
||||
g_return_if_fail ((modmask & GDK_SHIFT_MASK) == 0);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, modmask,
|
||||
"move-cursor", 3,
|
||||
G_TYPE_ENUM, step,
|
||||
G_TYPE_INT, count,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modmask,
|
||||
"move-cursor",
|
||||
"(iib)", step, count, FALSE);
|
||||
|
||||
/* Selection-extending version */
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, modmask | GDK_SHIFT_MASK,
|
||||
"move-cursor", 3,
|
||||
G_TYPE_ENUM, step,
|
||||
G_TYPE_INT, count,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modmask | GDK_SHIFT_MASK,
|
||||
"move-cursor",
|
||||
"(iib)", step, count, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -633,7 +632,6 @@ gtk_label_class_init (GtkLabelClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
gobject_class->set_property = gtk_label_set_property;
|
||||
gobject_class->get_property = gtk_label_get_property;
|
||||
@ -649,7 +647,6 @@ gtk_label_class_init (GtkLabelClass *class)
|
||||
widget_class->root = gtk_label_root;
|
||||
widget_class->unroot = gtk_label_unroot;
|
||||
widget_class->mnemonic_activate = gtk_label_mnemonic_activate;
|
||||
widget_class->popup_menu = gtk_label_popup_menu;
|
||||
widget_class->grab_focus = gtk_label_grab_focus;
|
||||
widget_class->focus = gtk_label_focus;
|
||||
widget_class->get_request_mode = gtk_label_get_request_mode;
|
||||
@ -1026,127 +1023,127 @@ gtk_label_class_init (GtkLabelClass *class)
|
||||
|
||||
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, label_props);
|
||||
|
||||
gtk_widget_class_install_action (widget_class, "menu.popup", NULL, gtk_label_popup_menu);
|
||||
|
||||
/*
|
||||
* Key bindings
|
||||
*/
|
||||
binding_set = gtk_binding_set_by_class (class);
|
||||
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
GDK_KEY_F10, GDK_SHIFT_MASK,
|
||||
"menu.popup",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
GDK_KEY_Menu, 0,
|
||||
"menu.popup",
|
||||
NULL);
|
||||
|
||||
/* Moving the insertion point */
|
||||
add_move_binding (binding_set, GDK_KEY_Right, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_Right, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Left, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_Left, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Right, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Right, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Left, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Left, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_f, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_f, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_LOGICAL_POSITIONS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_b, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_b, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_LOGICAL_POSITIONS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Right, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_Right, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_WORDS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Left, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_Left, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_WORDS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Right, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Right, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_WORDS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Left, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Left, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_WORDS, -1);
|
||||
|
||||
/* select all */
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK,
|
||||
"move-cursor", 3,
|
||||
G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
|
||||
G_TYPE_INT, -1,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK,
|
||||
"move-cursor", 3,
|
||||
G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
|
||||
G_TYPE_INT, 1,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_slash, GDK_CONTROL_MASK,
|
||||
"move-cursor", 3,
|
||||
G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
|
||||
G_TYPE_INT, -1,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_slash, GDK_CONTROL_MASK,
|
||||
"move-cursor", 3,
|
||||
G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
|
||||
G_TYPE_INT, 1,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_widget_class_add_binding (widget_class,
|
||||
GDK_KEY_a, GDK_CONTROL_MASK,
|
||||
(GtkShortcutFunc) gtk_label_select_all,
|
||||
NULL);
|
||||
gtk_widget_class_add_binding (widget_class,
|
||||
GDK_KEY_slash, GDK_CONTROL_MASK,
|
||||
(GtkShortcutFunc) gtk_label_select_all,
|
||||
NULL);
|
||||
|
||||
/* unselect all */
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
||||
"move-cursor", 3,
|
||||
G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
|
||||
G_TYPE_INT, 0,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_a, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
||||
"move-cursor",
|
||||
"(iib)", GTK_MOVEMENT_PARAGRAPH_ENDS, 0, FALSE);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_backslash, GDK_CONTROL_MASK,
|
||||
"move-cursor", 3,
|
||||
G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
|
||||
G_TYPE_INT, 0,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_backslash, GDK_CONTROL_MASK,
|
||||
"move-cursor",
|
||||
"(iib)", GTK_MOVEMENT_PARAGRAPH_ENDS, 0, FALSE);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_f, GDK_MOD1_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_f, GDK_MOD1_MASK,
|
||||
GTK_MOVEMENT_WORDS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_b, GDK_MOD1_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_b, GDK_MOD1_MASK,
|
||||
GTK_MOVEMENT_WORDS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Home, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_Home, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_End, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_End, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Home, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Home, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_End, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_End, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Home, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_Home, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_End, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_End, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Home, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Home, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_End, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_End, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, 1);
|
||||
|
||||
/* copy */
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_c, GDK_CONTROL_MASK,
|
||||
"copy-clipboard", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_c, GDK_CONTROL_MASK,
|
||||
"copy-clipboard",
|
||||
NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Return, 0,
|
||||
"activate-current-link", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_ISO_Enter, 0,
|
||||
"activate-current-link", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Enter, 0,
|
||||
"activate-current-link", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Return, 0,
|
||||
"activate-current-link",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_ISO_Enter, 0,
|
||||
"activate-current-link",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Enter, 0,
|
||||
"activate-current-link",
|
||||
NULL);
|
||||
|
||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_LABEL_ACCESSIBLE);
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, I_("label"));
|
||||
|
||||
quark_shortcuts_connected = g_quark_from_static_string ("gtk-label-shortcuts-connected");
|
||||
quark_mnemonic_menu = g_quark_from_static_string ("gtk-mnemonic-menu");
|
||||
quark_mnemonics_visible_connected = g_quark_from_static_string ("gtk-label-mnemonics-visible-connected");
|
||||
quark_gtk_signal = g_quark_from_static_string ("gtk-signal");
|
||||
quark_link = g_quark_from_static_string ("link");
|
||||
@ -1349,7 +1346,6 @@ gtk_label_init (GtkLabel *label)
|
||||
priv->attrs = NULL;
|
||||
|
||||
priv->mnemonic_widget = NULL;
|
||||
priv->mnemonic_window = NULL;
|
||||
|
||||
priv->mnemonics_visible = FALSE;
|
||||
}
|
||||
@ -1817,30 +1813,41 @@ gtk_label_mnemonic_activate (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_label_setup_mnemonic (GtkLabel *label,
|
||||
GtkWidget *toplevel,
|
||||
guint last_key)
|
||||
gtk_label_setup_mnemonic (GtkLabel *label)
|
||||
{
|
||||
GtkLabelPrivate *priv = gtk_label_get_instance_private (label);
|
||||
GtkWidget *widget = GTK_WIDGET (label);
|
||||
GtkShortcut *shortcut;
|
||||
|
||||
if (last_key != GDK_KEY_VoidSymbol)
|
||||
if (priv->mnemonic_keyval == GDK_KEY_VoidSymbol)
|
||||
{
|
||||
if (priv->mnemonic_window)
|
||||
{
|
||||
gtk_window_remove_mnemonic (priv->mnemonic_window,
|
||||
last_key,
|
||||
widget);
|
||||
priv->mnemonic_window = NULL;
|
||||
}
|
||||
if (priv->mnemonic_controller)
|
||||
{
|
||||
gtk_widget_remove_controller (widget, priv->mnemonic_controller);
|
||||
priv->mnemonic_controller = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (priv->mnemonic_keyval == GDK_KEY_VoidSymbol)
|
||||
goto done;
|
||||
if (priv->mnemonic_controller == NULL)
|
||||
{
|
||||
priv->mnemonic_controller = gtk_shortcut_controller_new ();
|
||||
gtk_event_controller_set_propagation_phase (priv->mnemonic_controller, GTK_PHASE_CAPTURE);
|
||||
gtk_shortcut_controller_set_scope (GTK_SHORTCUT_CONTROLLER (priv->mnemonic_controller), GTK_SHORTCUT_SCOPE_MANAGED);
|
||||
shortcut = gtk_shortcut_new (gtk_mnemonic_trigger_new (priv->mnemonic_keyval),
|
||||
gtk_mnemonic_action_new ());
|
||||
gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (priv->mnemonic_controller), shortcut);
|
||||
gtk_widget_add_controller (GTK_WIDGET (label), priv->mnemonic_controller);
|
||||
g_object_unref (shortcut);
|
||||
}
|
||||
else
|
||||
{
|
||||
shortcut = g_list_model_get_item (G_LIST_MODEL (priv->mnemonic_controller), 0);
|
||||
gtk_shortcut_set_trigger (shortcut, gtk_mnemonic_trigger_new (priv->mnemonic_keyval));
|
||||
g_object_unref (shortcut);
|
||||
}
|
||||
|
||||
connect_mnemonics_visible_notify (GTK_LABEL (widget));
|
||||
|
||||
done:;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1883,13 +1890,12 @@ static void
|
||||
gtk_label_root (GtkWidget *widget)
|
||||
{
|
||||
GtkLabel *label = GTK_LABEL (widget);
|
||||
GtkLabelPrivate *priv = gtk_label_get_instance_private (label);
|
||||
GtkSettings *settings;
|
||||
gboolean shortcuts_connected;
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_label_parent_class)->root (widget);
|
||||
|
||||
gtk_label_setup_mnemonic (label, GTK_WIDGET (gtk_widget_get_root (widget)), priv->mnemonic_keyval);
|
||||
gtk_label_setup_mnemonic (label);
|
||||
|
||||
/* The PangoContext is replaced when the display changes, so clear the layouts */
|
||||
gtk_label_clear_layout (GTK_LABEL (widget));
|
||||
@ -1916,9 +1922,8 @@ static void
|
||||
gtk_label_unroot (GtkWidget *widget)
|
||||
{
|
||||
GtkLabel *label = GTK_LABEL (widget);
|
||||
GtkLabelPrivate *priv = gtk_label_get_instance_private (label);
|
||||
|
||||
gtk_label_setup_mnemonic (label, NULL, priv->mnemonic_keyval);
|
||||
gtk_label_setup_mnemonic (label);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_label_parent_class)->unroot (widget);
|
||||
}
|
||||
@ -2166,7 +2171,7 @@ gtk_label_recalculate (GtkLabel *label)
|
||||
|
||||
if (keyval != priv->mnemonic_keyval)
|
||||
{
|
||||
gtk_label_setup_mnemonic (label, GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (label))), keyval);
|
||||
gtk_label_setup_mnemonic (label);
|
||||
g_object_notify_by_pspec (G_OBJECT (label), label_props[PROP_MNEMONIC_KEYVAL]);
|
||||
}
|
||||
|
||||
@ -6066,13 +6071,14 @@ gtk_label_do_popup (GtkLabel *label,
|
||||
gtk_popover_popup (GTK_POPOVER (priv->popup_menu));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_label_popup_menu (GtkWidget *widget)
|
||||
static void
|
||||
gtk_label_popup_menu (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
GVariant *parameters)
|
||||
{
|
||||
GtkLabel *label = GTK_LABEL (widget);
|
||||
|
||||
gtk_label_do_popup (label, -1, -1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -123,7 +123,9 @@ static void gtk_link_button_set_property (GObject *object,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_link_button_clicked (GtkButton *button);
|
||||
static gboolean gtk_link_button_popup_menu (GtkWidget *widget);
|
||||
static void gtk_link_button_popup_menu (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
GVariant *parameters);
|
||||
static gboolean gtk_link_button_query_tooltip_cb (GtkWidget *widget,
|
||||
gint x,
|
||||
gint y,
|
||||
@ -169,8 +171,6 @@ gtk_link_button_class_init (GtkLinkButtonClass *klass)
|
||||
gobject_class->get_property = gtk_link_button_get_property;
|
||||
gobject_class->finalize = gtk_link_button_finalize;
|
||||
|
||||
widget_class->popup_menu = gtk_link_button_popup_menu;
|
||||
|
||||
button_class->clicked = gtk_link_button_clicked;
|
||||
|
||||
klass->activate_link = gtk_link_button_activate_link;
|
||||
@ -230,6 +230,17 @@ gtk_link_button_class_init (GtkLinkButtonClass *klass)
|
||||
|
||||
gtk_widget_class_install_action (widget_class, "clipboard.copy", NULL,
|
||||
gtk_link_button_activate_clipboard_copy);
|
||||
|
||||
gtk_widget_class_install_action (widget_class, "menu.popup", NULL, gtk_link_button_popup_menu);
|
||||
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
GDK_KEY_F10, GDK_SHIFT_MASK,
|
||||
"menu.popup",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
GDK_KEY_Menu, 0,
|
||||
"menu.popup",
|
||||
NULL);
|
||||
}
|
||||
|
||||
static GMenuModel *
|
||||
@ -503,11 +514,12 @@ gtk_link_button_clicked (GtkButton *button)
|
||||
g_signal_emit (button, link_signals[ACTIVATE_LINK], 0, &retval);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_link_button_popup_menu (GtkWidget *widget)
|
||||
static void
|
||||
gtk_link_button_popup_menu (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
GVariant *parameters)
|
||||
{
|
||||
gtk_link_button_do_popup (GTK_LINK_BUTTON (widget), -1, -1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include "gtkactionhelperprivate.h"
|
||||
#include "gtkadjustmentprivate.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkcontainerprivate.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
@ -232,7 +231,7 @@ static GSequenceIter * gtk_list_box_get_next_visible (GtkListBo
|
||||
GSequenceIter *iter);
|
||||
static void gtk_list_box_apply_filter (GtkListBox *box,
|
||||
GtkListBoxRow *row);
|
||||
static void gtk_list_box_add_move_binding (GtkBindingSet *binding_set,
|
||||
static void gtk_list_box_add_move_binding (GtkWidgetClass *widget_class,
|
||||
guint keyval,
|
||||
GdkModifierType modmask,
|
||||
GtkMovementStep step,
|
||||
@ -436,9 +435,6 @@ gtk_list_box_class_init (GtkListBoxClass *klass)
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_LIST_BOX_ACCESSIBLE);
|
||||
|
||||
object_class->get_property = gtk_list_box_get_property;
|
||||
object_class->set_property = gtk_list_box_set_property;
|
||||
@ -611,43 +607,52 @@ gtk_list_box_class_init (GtkListBoxClass *klass)
|
||||
|
||||
widget_class->activate_signal = signals[ACTIVATE_CURSOR_ROW];
|
||||
|
||||
binding_set = gtk_binding_set_by_class (klass);
|
||||
gtk_list_box_add_move_binding (binding_set, GDK_KEY_Home, 0,
|
||||
gtk_list_box_add_move_binding (widget_class, GDK_KEY_Home, 0,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, -1);
|
||||
gtk_list_box_add_move_binding (binding_set, GDK_KEY_KP_Home, 0,
|
||||
gtk_list_box_add_move_binding (widget_class, GDK_KEY_KP_Home, 0,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, -1);
|
||||
gtk_list_box_add_move_binding (binding_set, GDK_KEY_End, 0,
|
||||
gtk_list_box_add_move_binding (widget_class, GDK_KEY_End, 0,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, 1);
|
||||
gtk_list_box_add_move_binding (binding_set, GDK_KEY_KP_End, 0,
|
||||
gtk_list_box_add_move_binding (widget_class, GDK_KEY_KP_End, 0,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, 1);
|
||||
gtk_list_box_add_move_binding (binding_set, GDK_KEY_Up, 0,
|
||||
gtk_list_box_add_move_binding (widget_class, GDK_KEY_Up, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, -1);
|
||||
gtk_list_box_add_move_binding (binding_set, GDK_KEY_KP_Up, 0,
|
||||
gtk_list_box_add_move_binding (widget_class, GDK_KEY_KP_Up, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, -1);
|
||||
gtk_list_box_add_move_binding (binding_set, GDK_KEY_Down, 0,
|
||||
gtk_list_box_add_move_binding (widget_class, GDK_KEY_Down, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, 1);
|
||||
gtk_list_box_add_move_binding (binding_set, GDK_KEY_KP_Down, 0,
|
||||
gtk_list_box_add_move_binding (widget_class, GDK_KEY_KP_Down, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, 1);
|
||||
gtk_list_box_add_move_binding (binding_set, GDK_KEY_Page_Up, 0,
|
||||
gtk_list_box_add_move_binding (widget_class, GDK_KEY_Page_Up, 0,
|
||||
GTK_MOVEMENT_PAGES, -1);
|
||||
gtk_list_box_add_move_binding (binding_set, GDK_KEY_KP_Page_Up, 0,
|
||||
gtk_list_box_add_move_binding (widget_class, GDK_KEY_KP_Page_Up, 0,
|
||||
GTK_MOVEMENT_PAGES, -1);
|
||||
gtk_list_box_add_move_binding (binding_set, GDK_KEY_Page_Down, 0,
|
||||
gtk_list_box_add_move_binding (widget_class, GDK_KEY_Page_Down, 0,
|
||||
GTK_MOVEMENT_PAGES, 1);
|
||||
gtk_list_box_add_move_binding (binding_set, GDK_KEY_KP_Page_Down, 0,
|
||||
gtk_list_box_add_move_binding (widget_class, GDK_KEY_KP_Page_Down, 0,
|
||||
GTK_MOVEMENT_PAGES, 1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_space, GDK_CONTROL_MASK,
|
||||
"toggle-cursor-row", 0, NULL);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Space, GDK_CONTROL_MASK,
|
||||
"toggle-cursor-row", 0, NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_space, GDK_CONTROL_MASK,
|
||||
"toggle-cursor-row",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Space, GDK_CONTROL_MASK,
|
||||
"toggle-cursor-row",
|
||||
NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK,
|
||||
"select-all", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"unselect-all", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_a, GDK_CONTROL_MASK,
|
||||
"select-all",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_a, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"unselect-all",
|
||||
NULL);
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, I_("list"));
|
||||
|
||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_LIST_BOX_ACCESSIBLE);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1435,7 +1440,7 @@ gtk_list_box_set_accept_unpaired_release (GtkListBox *box,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_list_box_add_move_binding (GtkBindingSet *binding_set,
|
||||
gtk_list_box_add_move_binding (GtkWidgetClass *widget_class,
|
||||
guint keyval,
|
||||
GdkModifierType modmask,
|
||||
GtkMovementStep step,
|
||||
@ -1454,26 +1459,22 @@ gtk_list_box_add_move_binding (GtkBindingSet *binding_set,
|
||||
GDK_MODIFIER_INTENT_MODIFY_SELECTION);
|
||||
}
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, modmask,
|
||||
"move-cursor", 2,
|
||||
GTK_TYPE_MOVEMENT_STEP, step,
|
||||
G_TYPE_INT, count,
|
||||
NULL);
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, modmask | extend_mod_mask,
|
||||
"move-cursor", 2,
|
||||
GTK_TYPE_MOVEMENT_STEP, step,
|
||||
G_TYPE_INT, count,
|
||||
NULL);
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, modmask | modify_mod_mask,
|
||||
"move-cursor", 2,
|
||||
GTK_TYPE_MOVEMENT_STEP, step,
|
||||
G_TYPE_INT, count,
|
||||
NULL);
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, modmask | extend_mod_mask | modify_mod_mask,
|
||||
"move-cursor", 2,
|
||||
GTK_TYPE_MOVEMENT_STEP, step,
|
||||
G_TYPE_INT, count,
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modmask,
|
||||
"move-cursor",
|
||||
"(ii)", step, count);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modmask | extend_mod_mask,
|
||||
"move-cursor",
|
||||
"(ii)", step, count);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modmask | modify_mod_mask,
|
||||
"move-cursor",
|
||||
"(ii)", step, count);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modmask | extend_mod_mask | modify_mod_mask,
|
||||
"move-cursor",
|
||||
"(ii)", step, count);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -114,7 +114,6 @@
|
||||
|
||||
#include "gtkintl.h"
|
||||
|
||||
#include "gtkaccelmapprivate.h"
|
||||
#include "gtkbox.h"
|
||||
#include "gtkdebug.h"
|
||||
#include "gtkdropprivate.h"
|
||||
@ -663,8 +662,6 @@ do_post_parse_initialization (void)
|
||||
gsk_ensure_resources ();
|
||||
_gtk_ensure_resources ();
|
||||
|
||||
_gtk_accel_map_init ();
|
||||
|
||||
gtk_initialized = TRUE;
|
||||
|
||||
#ifdef G_OS_UNIX
|
||||
@ -1697,14 +1694,11 @@ gtk_main_do_event (GdkEvent *event)
|
||||
current_events = g_list_prepend (current_events, event);
|
||||
|
||||
if (is_pointing_event (event))
|
||||
target_widget = handle_pointing_event (event);
|
||||
{
|
||||
target_widget = handle_pointing_event (event);
|
||||
}
|
||||
else if (is_key_event (event))
|
||||
{
|
||||
if (gdk_event_get_event_type (event) == GDK_KEY_PRESS &&
|
||||
GTK_IS_WINDOW (target_widget) &&
|
||||
gtk_window_activate_key (GTK_WINDOW (target_widget), event))
|
||||
goto cleanup;
|
||||
|
||||
target_widget = handle_key_event (event);
|
||||
}
|
||||
else if (is_focus_event (event))
|
||||
|
@ -1,201 +0,0 @@
|
||||
/* gtkmnemonichash.c: Sets of mnemonics with cycling
|
||||
*
|
||||
* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2002, Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkmnemonichash.h"
|
||||
#include "gtknative.h"
|
||||
|
||||
struct _GtkMnemnonicHash
|
||||
{
|
||||
GHashTable *hash;
|
||||
};
|
||||
|
||||
|
||||
GtkMnemonicHash *
|
||||
_gtk_mnemonic_hash_new (void)
|
||||
{
|
||||
GtkMnemonicHash *mnemonic_hash = g_new (GtkMnemonicHash, 1);
|
||||
|
||||
mnemonic_hash->hash = g_hash_table_new (g_direct_hash, NULL);
|
||||
|
||||
return mnemonic_hash;
|
||||
}
|
||||
|
||||
static void
|
||||
mnemonic_hash_free_foreach (gpointer key,
|
||||
gpointer value,
|
||||
gpointer user)
|
||||
{
|
||||
guint keyval = GPOINTER_TO_UINT (key);
|
||||
GSList *targets = value;
|
||||
|
||||
gchar *name = gtk_accelerator_name (keyval, 0);
|
||||
|
||||
g_warning ("mnemonic \"%s\" wasn't removed for widget (%p)",
|
||||
name, targets->data);
|
||||
g_free (name);
|
||||
|
||||
g_slist_free (targets);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_mnemonic_hash_free (GtkMnemonicHash *mnemonic_hash)
|
||||
{
|
||||
g_hash_table_foreach (mnemonic_hash->hash,
|
||||
mnemonic_hash_free_foreach,
|
||||
NULL);
|
||||
|
||||
g_hash_table_destroy (mnemonic_hash->hash);
|
||||
g_free (mnemonic_hash);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_mnemonic_hash_add (GtkMnemonicHash *mnemonic_hash,
|
||||
guint keyval,
|
||||
GtkWidget *target)
|
||||
{
|
||||
gpointer key = GUINT_TO_POINTER (keyval);
|
||||
GSList *targets, *new_targets;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET (target));
|
||||
|
||||
targets = g_hash_table_lookup (mnemonic_hash->hash, key);
|
||||
g_return_if_fail (g_slist_find (targets, target) == NULL);
|
||||
|
||||
new_targets = g_slist_append (targets, target);
|
||||
if (new_targets != targets)
|
||||
g_hash_table_insert (mnemonic_hash->hash, key, new_targets);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_mnemonic_hash_remove (GtkMnemonicHash *mnemonic_hash,
|
||||
guint keyval,
|
||||
GtkWidget *target)
|
||||
{
|
||||
gpointer key = GUINT_TO_POINTER (keyval);
|
||||
GSList *targets, *new_targets;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET (target));
|
||||
|
||||
targets = g_hash_table_lookup (mnemonic_hash->hash, key);
|
||||
|
||||
g_return_if_fail (targets && g_slist_find (targets, target) != NULL);
|
||||
|
||||
new_targets = g_slist_remove (targets, target);
|
||||
if (new_targets != targets)
|
||||
{
|
||||
if (new_targets == NULL)
|
||||
g_hash_table_remove (mnemonic_hash->hash, key);
|
||||
else
|
||||
g_hash_table_insert (mnemonic_hash->hash, key, new_targets);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_mnemonic_hash_activate (GtkMnemonicHash *mnemonic_hash,
|
||||
guint keyval)
|
||||
{
|
||||
GSList *list, *targets;
|
||||
GtkWidget *widget, *chosen_widget;
|
||||
GdkSurface *surface;
|
||||
gboolean overloaded;
|
||||
|
||||
targets = g_hash_table_lookup (mnemonic_hash->hash,
|
||||
GUINT_TO_POINTER (keyval));
|
||||
if (!targets)
|
||||
return FALSE;
|
||||
|
||||
overloaded = FALSE;
|
||||
chosen_widget = NULL;
|
||||
for (list = targets; list; list = list->next)
|
||||
{
|
||||
widget = GTK_WIDGET (list->data);
|
||||
surface = gtk_native_get_surface (gtk_widget_get_native (widget));
|
||||
|
||||
if (gtk_widget_is_sensitive (widget) &&
|
||||
gtk_widget_get_mapped (widget) &&
|
||||
surface && gdk_surface_is_viewable (surface))
|
||||
{
|
||||
if (chosen_widget)
|
||||
{
|
||||
overloaded = TRUE;
|
||||
break;
|
||||
}
|
||||
else
|
||||
chosen_widget = widget;
|
||||
}
|
||||
}
|
||||
|
||||
if (chosen_widget)
|
||||
{
|
||||
/* For round robin we put the activated entry on
|
||||
* the end of the list after activation
|
||||
*/
|
||||
targets = g_slist_remove (targets, chosen_widget);
|
||||
targets = g_slist_append (targets, chosen_widget);
|
||||
g_hash_table_insert (mnemonic_hash->hash,
|
||||
GUINT_TO_POINTER (keyval),
|
||||
targets);
|
||||
|
||||
return gtk_widget_mnemonic_activate (chosen_widget, overloaded);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GSList *
|
||||
_gtk_mnemonic_hash_lookup (GtkMnemonicHash *mnemonic_hash,
|
||||
guint keyval)
|
||||
{
|
||||
return g_hash_table_lookup (mnemonic_hash->hash, GUINT_TO_POINTER (keyval));
|
||||
}
|
||||
|
||||
static void
|
||||
mnemonic_hash_foreach_func (gpointer key,
|
||||
gpointer value,
|
||||
gpointer data)
|
||||
{
|
||||
struct {
|
||||
GtkMnemonicHashForeach func;
|
||||
gpointer func_data;
|
||||
} *info = data;
|
||||
|
||||
guint keyval = GPOINTER_TO_UINT (key);
|
||||
GSList *targets = value;
|
||||
|
||||
(*info->func) (keyval, targets, info->func_data);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_mnemonic_hash_foreach (GtkMnemonicHash *mnemonic_hash,
|
||||
GtkMnemonicHashForeach func,
|
||||
gpointer func_data)
|
||||
{
|
||||
struct {
|
||||
GtkMnemonicHashForeach func;
|
||||
gpointer func_data;
|
||||
} info;
|
||||
|
||||
info.func = func;
|
||||
info.func_data = func_data;
|
||||
|
||||
g_hash_table_foreach (mnemonic_hash->hash,
|
||||
mnemonic_hash_foreach_func,
|
||||
&info);
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/* gtkmnemonichash.h: Sets of mnemonics with cycling
|
||||
*
|
||||
* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2002, Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_MNEMONIC_HASH_H__
|
||||
#define __GTK_MNEMONIC_HASH_H__
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <gtk/gtkwidget.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkMnemnonicHash GtkMnemonicHash;
|
||||
|
||||
typedef void (*GtkMnemonicHashForeach) (guint keyval,
|
||||
GSList *targets,
|
||||
gpointer data);
|
||||
|
||||
GtkMnemonicHash *_gtk_mnemonic_hash_new (void);
|
||||
void _gtk_mnemonic_hash_free (GtkMnemonicHash *mnemonic_hash);
|
||||
void _gtk_mnemonic_hash_add (GtkMnemonicHash *mnemonic_hash,
|
||||
guint keyval,
|
||||
GtkWidget *target);
|
||||
void _gtk_mnemonic_hash_remove (GtkMnemonicHash *mnemonic_hash,
|
||||
guint keyval,
|
||||
GtkWidget *target);
|
||||
gboolean _gtk_mnemonic_hash_activate (GtkMnemonicHash *mnemonic_hash,
|
||||
guint keyval);
|
||||
GSList * _gtk_mnemonic_hash_lookup (GtkMnemonicHash *mnemonic_hash,
|
||||
guint keyval);
|
||||
void _gtk_mnemonic_hash_foreach (GtkMnemonicHash *mnemonic_hash,
|
||||
GtkMnemonicHashForeach func,
|
||||
gpointer func_data);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_MNEMONIC_HASH_H__ */
|
@ -727,7 +727,6 @@ update_accel (GtkModelButton *self,
|
||||
{
|
||||
guint key;
|
||||
GdkModifierType mods;
|
||||
GtkAccelLabelClass *accel_class;
|
||||
char *str;
|
||||
|
||||
if (!self->accel_label)
|
||||
@ -739,12 +738,9 @@ update_accel (GtkModelButton *self,
|
||||
}
|
||||
|
||||
gtk_accelerator_parse (accel, &key, &mods);
|
||||
|
||||
accel_class = g_type_class_ref (GTK_TYPE_ACCEL_LABEL);
|
||||
str = _gtk_accel_label_class_get_accelerator_label (accel_class, key, mods);
|
||||
str = gtk_accelerator_get_label (key, mods);
|
||||
gtk_label_set_label (GTK_LABEL (self->accel_label), str);
|
||||
g_free (str);
|
||||
g_type_class_unref (accel_class);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -57,6 +57,10 @@
|
||||
#include "gtkpopover.h"
|
||||
#include "gtksnapshot.h"
|
||||
#include "gdktextureprivate.h"
|
||||
#include "gtkshortcutcontroller.h"
|
||||
#include "gtkshortcuttrigger.h"
|
||||
#include "gtkshortcutaction.h"
|
||||
#include "gtkshortcut.h"
|
||||
#include <glib/gprintf.h>
|
||||
|
||||
/**
|
||||
@ -1458,6 +1462,7 @@ do_popup_menu_for_process_tree_view (GtkWidget *widget,
|
||||
|
||||
static gboolean
|
||||
on_popup_menu_for_process_tree_view (GtkWidget *widget,
|
||||
GVariant *args,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkMountOperation *op = GTK_MOUNT_OPERATION (user_data);
|
||||
@ -1503,6 +1508,10 @@ create_show_processes_dialog (GtkMountOperation *op,
|
||||
gchar *s;
|
||||
gboolean use_header;
|
||||
GtkGesture *gesture;
|
||||
GtkEventController *controller;
|
||||
GtkShortcutTrigger *trigger;
|
||||
GtkShortcutAction *action;
|
||||
GtkShortcut *shortcut;
|
||||
|
||||
priv = op->priv;
|
||||
|
||||
@ -1589,9 +1598,15 @@ create_show_processes_dialog (GtkMountOperation *op,
|
||||
gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), scrolled_window);
|
||||
|
||||
g_signal_connect (tree_view, "popup-menu",
|
||||
G_CALLBACK (on_popup_menu_for_process_tree_view),
|
||||
op);
|
||||
controller = gtk_shortcut_controller_new ();
|
||||
trigger = gtk_alternative_trigger_new (gtk_keyval_trigger_new (GDK_KEY_F10, GDK_SHIFT_MASK),
|
||||
gtk_keyval_trigger_new (GDK_KEY_Menu, 0));
|
||||
action = gtk_callback_action_new (on_popup_menu_for_process_tree_view,
|
||||
op,
|
||||
NULL);
|
||||
shortcut = gtk_shortcut_new_with_arguments (trigger, action, "s", "sv");
|
||||
gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), shortcut);
|
||||
gtk_widget_add_controller (GTK_WIDGET (tree_view), controller);
|
||||
|
||||
gesture = gtk_gesture_click_new ();
|
||||
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
#include "gtknotebook.h"
|
||||
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkbox.h"
|
||||
#include "gtkboxlayout.h"
|
||||
#include "gtkbuildable.h"
|
||||
@ -773,7 +772,9 @@ static void gtk_notebook_dispose (GObject *object);
|
||||
/*** GtkWidget Methods ***/
|
||||
static void gtk_notebook_destroy (GtkWidget *widget);
|
||||
static void gtk_notebook_unmap (GtkWidget *widget);
|
||||
static gboolean gtk_notebook_popup_menu (GtkWidget *widget);
|
||||
static void gtk_notebook_popup_menu (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
GVariant *parameters);
|
||||
static void gtk_notebook_motion (GtkEventController *controller,
|
||||
double x,
|
||||
double y,
|
||||
@ -935,49 +936,53 @@ G_DEFINE_TYPE_WITH_CODE (GtkNotebook, gtk_notebook, GTK_TYPE_CONTAINER,
|
||||
gtk_notebook_buildable_init))
|
||||
|
||||
static void
|
||||
add_tab_bindings (GtkBindingSet *binding_set,
|
||||
add_tab_bindings (GtkWidgetClass *widget_class,
|
||||
GdkModifierType modifiers,
|
||||
GtkDirectionType direction)
|
||||
{
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Tab, modifiers,
|
||||
"move_focus_out", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, direction);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Tab, modifiers,
|
||||
"move_focus_out", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, direction);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Tab, modifiers,
|
||||
"move_focus_out",
|
||||
"(i)", direction);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Tab, modifiers,
|
||||
"move_focus_out",
|
||||
"(i)", direction);
|
||||
}
|
||||
|
||||
static void
|
||||
add_arrow_bindings (GtkBindingSet *binding_set,
|
||||
add_arrow_bindings (GtkWidgetClass *widget_class,
|
||||
guint keysym,
|
||||
GtkDirectionType direction)
|
||||
{
|
||||
guint keypad_keysym = keysym - GDK_KEY_Left + GDK_KEY_KP_Left;
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, keysym, GDK_CONTROL_MASK,
|
||||
"move_focus_out", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, direction);
|
||||
gtk_binding_entry_add_signal (binding_set, keypad_keysym, GDK_CONTROL_MASK,
|
||||
"move_focus_out", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, direction);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keysym, GDK_CONTROL_MASK,
|
||||
"move_focus_out",
|
||||
"(i)", direction);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keypad_keysym, GDK_CONTROL_MASK,
|
||||
"move_focus_out",
|
||||
"(i)", direction);
|
||||
}
|
||||
|
||||
static void
|
||||
add_reorder_bindings (GtkBindingSet *binding_set,
|
||||
add_reorder_bindings (GtkWidgetClass *widget_class,
|
||||
guint keysym,
|
||||
GtkDirectionType direction,
|
||||
gboolean move_to_last)
|
||||
{
|
||||
guint keypad_keysym = keysym - GDK_KEY_Left + GDK_KEY_KP_Left;
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, keysym, GDK_MOD1_MASK,
|
||||
"reorder_tab", 2,
|
||||
GTK_TYPE_DIRECTION_TYPE, direction,
|
||||
G_TYPE_BOOLEAN, move_to_last);
|
||||
gtk_binding_entry_add_signal (binding_set, keypad_keysym, GDK_MOD1_MASK,
|
||||
"reorder_tab", 2,
|
||||
GTK_TYPE_DIRECTION_TYPE, direction,
|
||||
G_TYPE_BOOLEAN, move_to_last);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keysym, GDK_MOD1_MASK,
|
||||
"reorder_tab",
|
||||
"(ib)", direction, move_to_last);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keypad_keysym, GDK_MOD1_MASK,
|
||||
"reorder_tab",
|
||||
"(ib)", direction, move_to_last);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -1035,7 +1040,6 @@ gtk_notebook_class_init (GtkNotebookClass *class)
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
gobject_class->set_property = gtk_notebook_set_property;
|
||||
gobject_class->get_property = gtk_notebook_get_property;
|
||||
@ -1044,7 +1048,6 @@ gtk_notebook_class_init (GtkNotebookClass *class)
|
||||
|
||||
widget_class->destroy = gtk_notebook_destroy;
|
||||
widget_class->unmap = gtk_notebook_unmap;
|
||||
widget_class->popup_menu = gtk_notebook_popup_menu;
|
||||
widget_class->grab_notify = gtk_notebook_grab_notify;
|
||||
widget_class->state_flags_changed = gtk_notebook_state_flags_changed;
|
||||
widget_class->direction_changed = gtk_notebook_direction_changed;
|
||||
@ -1308,67 +1311,77 @@ gtk_notebook_class_init (GtkNotebookClass *class)
|
||||
G_TYPE_FROM_CLASS (gobject_class),
|
||||
_gtk_marshal_OBJECT__OBJECTv);
|
||||
|
||||
binding_set = gtk_binding_set_by_class (class);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_space, 0,
|
||||
"select-page", 1,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_KP_Space, 0,
|
||||
"select-page", 1,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
gtk_widget_class_install_action (widget_class, "menu.popup", NULL, gtk_notebook_popup_menu);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_Home, 0,
|
||||
"focus-tab", 1,
|
||||
GTK_TYPE_NOTEBOOK_TAB, GTK_NOTEBOOK_TAB_FIRST);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_KP_Home, 0,
|
||||
"focus-tab", 1,
|
||||
GTK_TYPE_NOTEBOOK_TAB, GTK_NOTEBOOK_TAB_FIRST);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_End, 0,
|
||||
"focus-tab", 1,
|
||||
GTK_TYPE_NOTEBOOK_TAB, GTK_NOTEBOOK_TAB_LAST);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_KP_End, 0,
|
||||
"focus-tab", 1,
|
||||
GTK_TYPE_NOTEBOOK_TAB, GTK_NOTEBOOK_TAB_LAST);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_space, 0,
|
||||
"select-page",
|
||||
"(b)", FALSE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Space, 0,
|
||||
"select-page",
|
||||
"(b)", FALSE);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_Page_Up, GDK_CONTROL_MASK,
|
||||
"change-current-page", 1,
|
||||
G_TYPE_INT, -1);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_Page_Down, GDK_CONTROL_MASK,
|
||||
"change-current-page", 1,
|
||||
G_TYPE_INT, 1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Home, 0,
|
||||
"focus-tab",
|
||||
"(i)", GTK_NOTEBOOK_TAB_FIRST);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Home, 0,
|
||||
"focus-tab",
|
||||
"(i)", GTK_NOTEBOOK_TAB_FIRST);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_End, 0,
|
||||
"focus-tab",
|
||||
"(i)", GTK_NOTEBOOK_TAB_LAST);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_End, 0,
|
||||
"focus-tab",
|
||||
"(i)", GTK_NOTEBOOK_TAB_LAST);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_Page_Up, GDK_CONTROL_MASK | GDK_MOD1_MASK,
|
||||
"change-current-page", 1,
|
||||
G_TYPE_INT, -1);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_Page_Down, GDK_CONTROL_MASK | GDK_MOD1_MASK,
|
||||
"change-current-page", 1,
|
||||
G_TYPE_INT, 1);
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
GDK_KEY_F10, GDK_SHIFT_MASK,
|
||||
"menu.popup",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
GDK_KEY_Menu, 0,
|
||||
"menu.popup",
|
||||
NULL);
|
||||
|
||||
add_arrow_bindings (binding_set, GDK_KEY_Up, GTK_DIR_UP);
|
||||
add_arrow_bindings (binding_set, GDK_KEY_Down, GTK_DIR_DOWN);
|
||||
add_arrow_bindings (binding_set, GDK_KEY_Left, GTK_DIR_LEFT);
|
||||
add_arrow_bindings (binding_set, GDK_KEY_Right, GTK_DIR_RIGHT);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Page_Up, GDK_CONTROL_MASK,
|
||||
"change-current-page",
|
||||
"(i)", -1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Page_Down, GDK_CONTROL_MASK,
|
||||
"change-current-page",
|
||||
"(i)", 1);
|
||||
|
||||
add_reorder_bindings (binding_set, GDK_KEY_Up, GTK_DIR_UP, FALSE);
|
||||
add_reorder_bindings (binding_set, GDK_KEY_Down, GTK_DIR_DOWN, FALSE);
|
||||
add_reorder_bindings (binding_set, GDK_KEY_Left, GTK_DIR_LEFT, FALSE);
|
||||
add_reorder_bindings (binding_set, GDK_KEY_Right, GTK_DIR_RIGHT, FALSE);
|
||||
add_reorder_bindings (binding_set, GDK_KEY_Home, GTK_DIR_LEFT, TRUE);
|
||||
add_reorder_bindings (binding_set, GDK_KEY_Home, GTK_DIR_UP, TRUE);
|
||||
add_reorder_bindings (binding_set, GDK_KEY_End, GTK_DIR_RIGHT, TRUE);
|
||||
add_reorder_bindings (binding_set, GDK_KEY_End, GTK_DIR_DOWN, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Page_Up, GDK_CONTROL_MASK | GDK_MOD1_MASK,
|
||||
"change-current-page",
|
||||
"(i)", -1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Page_Down, GDK_CONTROL_MASK | GDK_MOD1_MASK,
|
||||
"change-current-page",
|
||||
"(i)", 1);
|
||||
|
||||
add_tab_bindings (binding_set, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD);
|
||||
add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
|
||||
add_arrow_bindings (widget_class, GDK_KEY_Up, GTK_DIR_UP);
|
||||
add_arrow_bindings (widget_class, GDK_KEY_Down, GTK_DIR_DOWN);
|
||||
add_arrow_bindings (widget_class, GDK_KEY_Left, GTK_DIR_LEFT);
|
||||
add_arrow_bindings (widget_class, GDK_KEY_Right, GTK_DIR_RIGHT);
|
||||
|
||||
add_reorder_bindings (widget_class, GDK_KEY_Up, GTK_DIR_UP, FALSE);
|
||||
add_reorder_bindings (widget_class, GDK_KEY_Down, GTK_DIR_DOWN, FALSE);
|
||||
add_reorder_bindings (widget_class, GDK_KEY_Left, GTK_DIR_LEFT, FALSE);
|
||||
add_reorder_bindings (widget_class, GDK_KEY_Right, GTK_DIR_RIGHT, FALSE);
|
||||
add_reorder_bindings (widget_class, GDK_KEY_Home, GTK_DIR_LEFT, TRUE);
|
||||
add_reorder_bindings (widget_class, GDK_KEY_Home, GTK_DIR_UP, TRUE);
|
||||
add_reorder_bindings (widget_class, GDK_KEY_End, GTK_DIR_RIGHT, TRUE);
|
||||
add_reorder_bindings (widget_class, GDK_KEY_End, GTK_DIR_DOWN, TRUE);
|
||||
|
||||
add_tab_bindings (widget_class, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD);
|
||||
add_tab_bindings (widget_class, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
|
||||
|
||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_NOTEBOOK_ACCESSIBLE);
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT);
|
||||
@ -2598,20 +2611,16 @@ gtk_notebook_gesture_pressed (GtkGestureClick *gesture,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
gtk_notebook_popup_menu (GtkWidget *widget)
|
||||
static void
|
||||
gtk_notebook_popup_menu (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
GVariant *parameters)
|
||||
{
|
||||
GtkNotebook *notebook = GTK_NOTEBOOK (widget);
|
||||
GtkNotebookPrivate *priv = notebook->priv;
|
||||
|
||||
if (priv->menu)
|
||||
{
|
||||
gtk_popover_popup (GTK_POPOVER (priv->menu));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
gtk_popover_popup (GTK_POPOVER (priv->menu));
|
||||
}
|
||||
|
||||
static void
|
||||
|
184
gtk/gtkpaned.c
184
gtk/gtkpaned.c
@ -26,7 +26,6 @@
|
||||
|
||||
#include "gtkpaned.h"
|
||||
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkcontainerprivate.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
@ -278,24 +277,29 @@ static guint signals[LAST_SIGNAL] = { 0 };
|
||||
static GParamSpec *paned_props[LAST_PROP] = { NULL, };
|
||||
|
||||
static void
|
||||
add_tab_bindings (GtkBindingSet *binding_set,
|
||||
GdkModifierType modifiers)
|
||||
add_tab_bindings (GtkWidgetClass *widget_class,
|
||||
GdkModifierType modifiers)
|
||||
{
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Tab, modifiers,
|
||||
"toggle-handle-focus", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Tab, modifiers,
|
||||
"toggle-handle-focus", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Tab, modifiers,
|
||||
"toggle-handle-focus",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Tab, modifiers,
|
||||
"toggle-handle-focus",
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
add_move_binding (GtkBindingSet *binding_set,
|
||||
add_move_binding (GtkWidgetClass *widget_class,
|
||||
guint keyval,
|
||||
GdkModifierType mask,
|
||||
GtkScrollType scroll)
|
||||
{
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, mask,
|
||||
"move-handle", 1,
|
||||
GTK_TYPE_SCROLL_TYPE, scroll);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, mask,
|
||||
"move-handle",
|
||||
"(i)", scroll);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -337,16 +341,9 @@ gtk_paned_handle_contains (GtkGizmo *handle,
|
||||
static void
|
||||
gtk_paned_class_init (GtkPanedClass *class)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkContainerClass *container_class;
|
||||
GtkPanedClass *paned_class;
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
object_class = (GObjectClass *) class;
|
||||
widget_class = (GtkWidgetClass *) class;
|
||||
container_class = (GtkContainerClass *) class;
|
||||
paned_class = (GtkPanedClass *) class;
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
|
||||
|
||||
object_class->set_property = gtk_paned_set_property;
|
||||
object_class->get_property = gtk_paned_get_property;
|
||||
@ -364,12 +361,12 @@ gtk_paned_class_init (GtkPanedClass *class)
|
||||
container_class->child_type = gtk_paned_child_type;
|
||||
container_class->set_focus_child = gtk_paned_set_focus_child;
|
||||
|
||||
paned_class->cycle_child_focus = gtk_paned_cycle_child_focus;
|
||||
paned_class->toggle_handle_focus = gtk_paned_toggle_handle_focus;
|
||||
paned_class->move_handle = gtk_paned_move_handle;
|
||||
paned_class->cycle_handle_focus = gtk_paned_cycle_handle_focus;
|
||||
paned_class->accept_position = gtk_paned_accept_position;
|
||||
paned_class->cancel_position = gtk_paned_cancel_position;
|
||||
class->cycle_child_focus = gtk_paned_cycle_child_focus;
|
||||
class->toggle_handle_focus = gtk_paned_toggle_handle_focus;
|
||||
class->move_handle = gtk_paned_move_handle;
|
||||
class->cycle_handle_focus = gtk_paned_cycle_handle_focus;
|
||||
class->accept_position = gtk_paned_accept_position;
|
||||
class->cancel_position = gtk_paned_cancel_position;
|
||||
|
||||
|
||||
paned_props[PROP_POSITION] =
|
||||
@ -607,84 +604,87 @@ gtk_paned_class_init (GtkPanedClass *class)
|
||||
_gtk_marshal_BOOLEAN__VOID,
|
||||
G_TYPE_BOOLEAN, 0);
|
||||
|
||||
binding_set = gtk_binding_set_by_class (class);
|
||||
|
||||
/* F6 and friends */
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_F6, 0,
|
||||
"cycle-child-focus", 1,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_F6, GDK_SHIFT_MASK,
|
||||
"cycle-child-focus", 1,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_F6, 0,
|
||||
"cycle-child-focus",
|
||||
"(b)", FALSE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_F6, GDK_SHIFT_MASK,
|
||||
"cycle-child-focus",
|
||||
"(b)", TRUE);
|
||||
|
||||
/* F8 and friends */
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_F8, 0,
|
||||
"cycle-handle-focus", 1,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_F8, 0,
|
||||
"cycle-handle-focus",
|
||||
"(b)", FALSE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_F8, GDK_SHIFT_MASK,
|
||||
"cycle-handle-focus",
|
||||
"(b)", TRUE);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_F8, GDK_SHIFT_MASK,
|
||||
"cycle-handle-focus", 1,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
|
||||
add_tab_bindings (binding_set, 0);
|
||||
add_tab_bindings (binding_set, GDK_CONTROL_MASK);
|
||||
add_tab_bindings (binding_set, GDK_SHIFT_MASK);
|
||||
add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK);
|
||||
add_tab_bindings (widget_class, 0);
|
||||
add_tab_bindings (widget_class, GDK_CONTROL_MASK);
|
||||
add_tab_bindings (widget_class, GDK_SHIFT_MASK);
|
||||
add_tab_bindings (widget_class, GDK_CONTROL_MASK | GDK_SHIFT_MASK);
|
||||
|
||||
/* accept and cancel positions */
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_Escape, 0,
|
||||
"cancel-position", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Escape, 0,
|
||||
"cancel-position",
|
||||
NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_Return, 0,
|
||||
"accept-position", 0);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_ISO_Enter, 0,
|
||||
"accept-position", 0);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_KP_Enter, 0,
|
||||
"accept-position", 0);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_space, 0,
|
||||
"accept-position", 0);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_KP_Space, 0,
|
||||
"accept-position", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Return, 0,
|
||||
"accept-position",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_ISO_Enter, 0,
|
||||
"accept-position",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Enter, 0,
|
||||
"accept-position",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_space, 0,
|
||||
"accept-position",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Space, 0,
|
||||
"accept-position",
|
||||
NULL);
|
||||
|
||||
/* move handle */
|
||||
add_move_binding (binding_set, GDK_KEY_Left, 0, GTK_SCROLL_STEP_LEFT);
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Left, 0, GTK_SCROLL_STEP_LEFT);
|
||||
add_move_binding (binding_set, GDK_KEY_Left, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_LEFT);
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Left, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_LEFT);
|
||||
add_move_binding (widget_class, GDK_KEY_Left, 0, GTK_SCROLL_STEP_LEFT);
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Left, 0, GTK_SCROLL_STEP_LEFT);
|
||||
add_move_binding (widget_class, GDK_KEY_Left, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_LEFT);
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Left, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_LEFT);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Right, 0, GTK_SCROLL_STEP_RIGHT);
|
||||
add_move_binding (binding_set, GDK_KEY_Right, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_RIGHT);
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Right, 0, GTK_SCROLL_STEP_RIGHT);
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Right, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_RIGHT);
|
||||
add_move_binding (widget_class, GDK_KEY_Right, 0, GTK_SCROLL_STEP_RIGHT);
|
||||
add_move_binding (widget_class, GDK_KEY_Right, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_RIGHT);
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Right, 0, GTK_SCROLL_STEP_RIGHT);
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Right, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_RIGHT);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Up, 0, GTK_SCROLL_STEP_UP);
|
||||
add_move_binding (binding_set, GDK_KEY_Up, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_UP);
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Up, 0, GTK_SCROLL_STEP_UP);
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Up, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_UP);
|
||||
add_move_binding (binding_set, GDK_KEY_Page_Up, 0, GTK_SCROLL_PAGE_UP);
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Page_Up, 0, GTK_SCROLL_PAGE_UP);
|
||||
add_move_binding (widget_class, GDK_KEY_Up, 0, GTK_SCROLL_STEP_UP);
|
||||
add_move_binding (widget_class, GDK_KEY_Up, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_UP);
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Up, 0, GTK_SCROLL_STEP_UP);
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Up, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_UP);
|
||||
add_move_binding (widget_class, GDK_KEY_Page_Up, 0, GTK_SCROLL_PAGE_UP);
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Page_Up, 0, GTK_SCROLL_PAGE_UP);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Down, 0, GTK_SCROLL_STEP_DOWN);
|
||||
add_move_binding (binding_set, GDK_KEY_Down, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_DOWN);
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Down, 0, GTK_SCROLL_STEP_DOWN);
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Down, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_DOWN);
|
||||
add_move_binding (binding_set, GDK_KEY_Page_Down, 0, GTK_SCROLL_PAGE_RIGHT);
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Page_Down, 0, GTK_SCROLL_PAGE_RIGHT);
|
||||
add_move_binding (widget_class, GDK_KEY_Down, 0, GTK_SCROLL_STEP_DOWN);
|
||||
add_move_binding (widget_class, GDK_KEY_Down, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_DOWN);
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Down, 0, GTK_SCROLL_STEP_DOWN);
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Down, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_DOWN);
|
||||
add_move_binding (widget_class, GDK_KEY_Page_Down, 0, GTK_SCROLL_PAGE_RIGHT);
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Page_Down, 0, GTK_SCROLL_PAGE_RIGHT);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Home, 0, GTK_SCROLL_START);
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Home, 0, GTK_SCROLL_START);
|
||||
add_move_binding (binding_set, GDK_KEY_End, 0, GTK_SCROLL_END);
|
||||
add_move_binding (binding_set, GDK_KEY_KP_End, 0, GTK_SCROLL_END);
|
||||
add_move_binding (widget_class, GDK_KEY_Home, 0, GTK_SCROLL_START);
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Home, 0, GTK_SCROLL_START);
|
||||
add_move_binding (widget_class, GDK_KEY_End, 0, GTK_SCROLL_END);
|
||||
add_move_binding (widget_class, GDK_KEY_KP_End, 0, GTK_SCROLL_END);
|
||||
|
||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_PANED_ACCESSIBLE);
|
||||
gtk_widget_class_set_css_name (widget_class, I_("paned"));
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "gtkpasswordentry.h"
|
||||
|
||||
#include "gtkaccessible.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtktextprivate.h"
|
||||
#include "gtkeditable.h"
|
||||
#include "gtkgestureclick.h"
|
||||
|
@ -106,7 +106,15 @@ static void mount_volume (GtkPlacesView
|
||||
static void on_eject_button_clicked (GtkWidget *widget,
|
||||
GtkPlacesViewRow *row);
|
||||
|
||||
static gboolean on_row_popup_menu (GtkPlacesViewRow *row);
|
||||
static gboolean on_row_popup_menu (GtkWidget *widget,
|
||||
GVariant *args,
|
||||
gpointer user_data);
|
||||
|
||||
static void click_cb (GtkGesture *gesture,
|
||||
int n_press,
|
||||
double x,
|
||||
double y,
|
||||
gpointer user_data);
|
||||
|
||||
static void populate_servers (GtkPlacesView *view);
|
||||
|
||||
@ -673,12 +681,28 @@ insert_row (GtkPlacesView *view,
|
||||
gboolean is_network)
|
||||
{
|
||||
GtkPlacesViewPrivate *priv;
|
||||
GtkEventController *controller;
|
||||
GtkShortcutTrigger *trigger;
|
||||
GtkShortcutAction *action;
|
||||
GtkShortcut *shortcut;
|
||||
GtkGesture *gesture;
|
||||
|
||||
priv = gtk_places_view_get_instance_private (view);
|
||||
|
||||
g_object_set_data (G_OBJECT (row), "is-network", GINT_TO_POINTER (is_network));
|
||||
|
||||
g_signal_connect (row, "popup-menu", G_CALLBACK (on_row_popup_menu), row);
|
||||
controller = gtk_shortcut_controller_new ();
|
||||
trigger = gtk_alternative_trigger_new (gtk_keyval_trigger_new (GDK_KEY_F10, GDK_SHIFT_MASK),
|
||||
gtk_keyval_trigger_new (GDK_KEY_Menu, 0));
|
||||
action = gtk_callback_action_new (on_row_popup_menu, row, NULL);
|
||||
shortcut = gtk_shortcut_new (trigger, action);
|
||||
gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), shortcut);
|
||||
gtk_widget_add_controller (GTK_WIDGET (row), controller);
|
||||
|
||||
gesture = gtk_gesture_click_new ();
|
||||
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);
|
||||
g_signal_connect (gesture, "pressed", G_CALLBACK (click_cb), row);
|
||||
gtk_widget_add_controller (row, GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
g_signal_connect (gtk_places_view_row_get_eject_button (GTK_PLACES_VIEW_ROW (row)),
|
||||
"clicked",
|
||||
@ -1699,10 +1723,12 @@ get_menu_model (void)
|
||||
return G_MENU_MODEL (menu);
|
||||
}
|
||||
|
||||
static void
|
||||
popup_menu (GtkPlacesViewRow *row,
|
||||
GdkEventButton *event)
|
||||
static gboolean
|
||||
on_row_popup_menu (GtkWidget *widget,
|
||||
GVariant *args,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkPlacesViewRow *row = GTK_PLACES_VIEW_ROW (widget);
|
||||
GtkPlacesViewPrivate *priv;
|
||||
GtkWidget *view;
|
||||
GMount *mount;
|
||||
@ -1730,27 +1756,39 @@ popup_menu (GtkPlacesViewRow *row,
|
||||
GMenuModel *model = get_menu_model ();
|
||||
|
||||
priv->popup_menu = gtk_popover_menu_new_from_model (model);
|
||||
gtk_widget_set_parent (priv->popup_menu, GTK_WIDGET (view));
|
||||
gtk_popover_set_position (GTK_POPOVER (priv->popup_menu), GTK_POS_BOTTOM);
|
||||
|
||||
gtk_popover_set_has_arrow (GTK_POPOVER (priv->popup_menu), FALSE);
|
||||
gtk_widget_set_halign (priv->popup_menu, GTK_ALIGN_START);
|
||||
gtk_widget_set_halign (priv->popup_menu, GTK_ALIGN_CENTER);
|
||||
|
||||
g_object_unref (model);
|
||||
}
|
||||
|
||||
gtk_widget_set_halign (priv->popup_menu, GTK_ALIGN_CENTER);
|
||||
if (priv->row_for_action)
|
||||
g_object_set_data (G_OBJECT (priv->row_for_action), "menu", NULL);
|
||||
|
||||
g_object_ref (priv->popup_menu);
|
||||
gtk_widget_unparent (priv->popup_menu);
|
||||
gtk_widget_set_parent (priv->popup_menu, GTK_WIDGET (row));
|
||||
g_object_unref (priv->popup_menu);
|
||||
|
||||
priv->row_for_action = row;
|
||||
if (priv->row_for_action)
|
||||
g_object_set_data (G_OBJECT (priv->row_for_action), "menu", priv->popup_menu);
|
||||
|
||||
gtk_popover_popup (GTK_POPOVER (priv->popup_menu));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
on_row_popup_menu (GtkPlacesViewRow *row)
|
||||
static void
|
||||
click_cb (GtkGesture *gesture,
|
||||
int n_press,
|
||||
double x,
|
||||
double y,
|
||||
gpointer user_data)
|
||||
{
|
||||
popup_menu (row, NULL);
|
||||
return TRUE;
|
||||
on_row_popup_menu (GTK_WIDGET (user_data), NULL, NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "gtkspinner.h"
|
||||
#include "gtkstack.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtknative.h"
|
||||
#else
|
||||
#include <gtk/gtk.h>
|
||||
#endif
|
||||
@ -193,18 +194,6 @@ measure_available_space (GtkPlacesViewRow *row)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pressed_cb (GtkGesture *gesture,
|
||||
int n_pressed,
|
||||
double x,
|
||||
double y,
|
||||
GtkPlacesViewRow *row)
|
||||
{
|
||||
gboolean menu_activated;
|
||||
|
||||
g_signal_emit_by_name (row, "popup-menu", &menu_activated);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_places_view_row_finalize (GObject *object)
|
||||
{
|
||||
@ -320,6 +309,19 @@ gtk_places_view_row_set_property (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_places_view_row_size_allocate (GtkWidget *widget,
|
||||
int width,
|
||||
int height,
|
||||
int baseline)
|
||||
{
|
||||
GtkWidget *menu = GTK_WIDGET (g_object_get_data (G_OBJECT (widget), "menu"));
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_places_view_row_parent_class)->size_allocate (widget, width, height, baseline);
|
||||
if (menu)
|
||||
gtk_native_check_resize (GTK_NATIVE (menu));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_places_view_row_class_init (GtkPlacesViewRowClass *klass)
|
||||
{
|
||||
@ -330,6 +332,8 @@ gtk_places_view_row_class_init (GtkPlacesViewRowClass *klass)
|
||||
object_class->get_property = gtk_places_view_row_get_property;
|
||||
object_class->set_property = gtk_places_view_row_set_property;
|
||||
|
||||
widget_class->size_allocate = gtk_places_view_row_size_allocate;
|
||||
|
||||
properties[PROP_ICON] =
|
||||
g_param_spec_object ("icon",
|
||||
P_("Icon of the row"),
|
||||
@ -391,8 +395,6 @@ gtk_places_view_row_class_init (GtkPlacesViewRowClass *klass)
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkPlacesViewRow, icon_image);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkPlacesViewRow, name_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkPlacesViewRow, path_label);
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, pressed_cb);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -103,11 +103,9 @@
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkbinlayout.h"
|
||||
#include "gtkenums.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkmnemonichash.h"
|
||||
#include "gtkgizmoprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkprivate.h"
|
||||
@ -121,6 +119,8 @@
|
||||
#include "gtkcsscolorvalueprivate.h"
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtksnapshot.h"
|
||||
#include "gtkshortcut.h"
|
||||
#include "gtkshortcuttrigger.h"
|
||||
|
||||
#include "gtkrender.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
@ -1445,37 +1445,41 @@ gtk_popover_remove (GtkContainer *container,
|
||||
}
|
||||
|
||||
static void
|
||||
add_tab_bindings (GtkBindingSet *binding_set,
|
||||
add_tab_bindings (GtkWidgetClass *widget_class,
|
||||
GdkModifierType modifiers,
|
||||
GtkDirectionType direction)
|
||||
{
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Tab, modifiers,
|
||||
"move-focus", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, direction);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Tab, modifiers,
|
||||
"move-focus", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, direction);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_Tab, modifiers,
|
||||
"move-focus",
|
||||
"(i)", direction);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Tab, modifiers,
|
||||
"move-focus",
|
||||
"(i)", direction);
|
||||
}
|
||||
|
||||
static void
|
||||
add_arrow_bindings (GtkBindingSet *binding_set,
|
||||
add_arrow_bindings (GtkWidgetClass *widget_class,
|
||||
guint keysym,
|
||||
GtkDirectionType direction)
|
||||
{
|
||||
guint keypad_keysym = keysym - GDK_KEY_Left + GDK_KEY_KP_Left;
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, keysym, 0,
|
||||
"move-focus", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, direction);
|
||||
gtk_binding_entry_add_signal (binding_set, keysym, GDK_CONTROL_MASK,
|
||||
"move-focus", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, direction);
|
||||
gtk_binding_entry_add_signal (binding_set, keypad_keysym, 0,
|
||||
"move-focus", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, direction);
|
||||
gtk_binding_entry_add_signal (binding_set, keypad_keysym, GDK_CONTROL_MASK,
|
||||
"move-focus", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, direction);
|
||||
gtk_widget_class_add_binding_signal (widget_class, keysym, 0,
|
||||
"move-focus",
|
||||
"(i)",
|
||||
direction);
|
||||
gtk_widget_class_add_binding_signal (widget_class, keysym, GDK_CONTROL_MASK,
|
||||
"move-focus",
|
||||
"(i)",
|
||||
direction);
|
||||
gtk_widget_class_add_binding_signal (widget_class, keypad_keysym, 0,
|
||||
"move-focus",
|
||||
"(i)",
|
||||
direction);
|
||||
gtk_widget_class_add_binding_signal (widget_class, keypad_keysym, GDK_CONTROL_MASK,
|
||||
"move-focus",
|
||||
"(i)",
|
||||
direction);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1484,7 +1488,6 @@ gtk_popover_class_init (GtkPopoverClass *klass)
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
object_class->dispose = gtk_popover_dispose;
|
||||
object_class->finalize = gtk_popover_finalize;
|
||||
@ -1563,24 +1566,22 @@ gtk_popover_class_init (GtkPopoverClass *klass)
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
|
||||
binding_set = gtk_binding_set_by_class (klass);
|
||||
add_arrow_bindings (widget_class, GDK_KEY_Up, GTK_DIR_UP);
|
||||
add_arrow_bindings (widget_class, GDK_KEY_Down, GTK_DIR_DOWN);
|
||||
add_arrow_bindings (widget_class, GDK_KEY_Left, GTK_DIR_LEFT);
|
||||
add_arrow_bindings (widget_class, GDK_KEY_Right, GTK_DIR_RIGHT);
|
||||
|
||||
add_arrow_bindings (binding_set, GDK_KEY_Up, GTK_DIR_UP);
|
||||
add_arrow_bindings (binding_set, GDK_KEY_Down, GTK_DIR_DOWN);
|
||||
add_arrow_bindings (binding_set, GDK_KEY_Left, GTK_DIR_LEFT);
|
||||
add_arrow_bindings (binding_set, GDK_KEY_Right, GTK_DIR_RIGHT);
|
||||
add_tab_bindings (widget_class, 0, GTK_DIR_TAB_FORWARD);
|
||||
add_tab_bindings (widget_class, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD);
|
||||
add_tab_bindings (widget_class, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
|
||||
add_tab_bindings (widget_class, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
|
||||
|
||||
add_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD);
|
||||
add_tab_bindings (binding_set, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD);
|
||||
add_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
|
||||
add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Return, 0,
|
||||
"activate-default", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_ISO_Enter, 0,
|
||||
"activate-default", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Enter, 0,
|
||||
"activate-default", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_Return, 0,
|
||||
"activate-default", NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_ISO_Enter, 0,
|
||||
"activate-default", NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Enter, 0,
|
||||
"activate-default", NULL);
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, "popover");
|
||||
}
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "gtkeventcontrollermotion.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkmodelbuttonprivate.h"
|
||||
#include "gtkpopovermenubar.h"
|
||||
|
||||
@ -362,37 +361,37 @@ gtk_popover_menu_focus (GtkWidget *widget,
|
||||
|
||||
|
||||
static void
|
||||
add_tab_bindings (GtkBindingSet *binding_set,
|
||||
add_tab_bindings (GtkWidgetClass *widget_class,
|
||||
GdkModifierType modifiers,
|
||||
GtkDirectionType direction)
|
||||
{
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Tab, modifiers,
|
||||
"move-focus", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, direction);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Tab, modifiers,
|
||||
"move-focus", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, direction);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_Tab, modifiers,
|
||||
"move-focus",
|
||||
"(i)", direction);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Tab, modifiers,
|
||||
"move-focus",
|
||||
"(i)", direction);
|
||||
}
|
||||
|
||||
static void
|
||||
add_arrow_bindings (GtkBindingSet *binding_set,
|
||||
add_arrow_bindings (GtkWidgetClass *widget_class,
|
||||
guint keysym,
|
||||
GtkDirectionType direction)
|
||||
{
|
||||
guint keypad_keysym = keysym - GDK_KEY_Left + GDK_KEY_KP_Left;
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, keysym, 0,
|
||||
"move-focus", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, direction);
|
||||
gtk_binding_entry_add_signal (binding_set, keysym, GDK_CONTROL_MASK,
|
||||
"move-focus", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, direction);
|
||||
gtk_binding_entry_add_signal (binding_set, keypad_keysym, 0,
|
||||
"move-focus", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, direction);
|
||||
gtk_binding_entry_add_signal (binding_set, keypad_keysym, GDK_CONTROL_MASK,
|
||||
"move-focus", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, direction);
|
||||
gtk_widget_class_add_binding_signal (widget_class, keysym, 0,
|
||||
"move-focus",
|
||||
"(i)", direction);
|
||||
gtk_widget_class_add_binding_signal (widget_class, keysym, GDK_CONTROL_MASK,
|
||||
"move-focus",
|
||||
"(i)", direction);
|
||||
gtk_widget_class_add_binding_signal (widget_class, keypad_keysym, 0,
|
||||
"move-focus",
|
||||
"(i)", direction);
|
||||
gtk_widget_class_add_binding_signal (widget_class, keypad_keysym, GDK_CONTROL_MASK,
|
||||
"move-focus",
|
||||
"(i)", direction);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -408,7 +407,6 @@ gtk_popover_menu_class_init (GtkPopoverMenuClass *klass)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
object_class->dispose = gtk_popover_menu_dispose;
|
||||
object_class->set_property = gtk_popover_menu_set_property;
|
||||
@ -435,28 +433,26 @@ gtk_popover_menu_class_init (GtkPopoverMenuClass *klass)
|
||||
G_TYPE_MENU_MODEL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
binding_set = gtk_binding_set_by_class (klass);
|
||||
add_arrow_bindings (widget_class, GDK_KEY_Up, GTK_DIR_UP);
|
||||
add_arrow_bindings (widget_class, GDK_KEY_Down, GTK_DIR_DOWN);
|
||||
add_arrow_bindings (widget_class, GDK_KEY_Left, GTK_DIR_LEFT);
|
||||
add_arrow_bindings (widget_class, GDK_KEY_Right, GTK_DIR_RIGHT);
|
||||
|
||||
add_arrow_bindings (binding_set, GDK_KEY_Up, GTK_DIR_UP);
|
||||
add_arrow_bindings (binding_set, GDK_KEY_Down, GTK_DIR_DOWN);
|
||||
add_arrow_bindings (binding_set, GDK_KEY_Left, GTK_DIR_LEFT);
|
||||
add_arrow_bindings (binding_set, GDK_KEY_Right, GTK_DIR_RIGHT);
|
||||
add_tab_bindings (widget_class, 0, GTK_DIR_TAB_FORWARD);
|
||||
add_tab_bindings (widget_class, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD);
|
||||
add_tab_bindings (widget_class, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
|
||||
add_tab_bindings (widget_class, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
|
||||
|
||||
add_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD);
|
||||
add_tab_bindings (binding_set, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD);
|
||||
add_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
|
||||
add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Return, 0,
|
||||
"activate-default", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_ISO_Enter, 0,
|
||||
"activate-default", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Enter, 0,
|
||||
"activate-default", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_space, 0,
|
||||
"activate-default", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Space, 0,
|
||||
"activate-default", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_Return, 0,
|
||||
"activate-default", NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_ISO_Enter, 0,
|
||||
"activate-default", NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Enter, 0,
|
||||
"activate-default", NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_space, 0,
|
||||
"activate-default", NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Space, 0,
|
||||
"activate-default", NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1883,16 +1883,6 @@ gtk_range_click_gesture_pressed (GtkGestureClick *gesture,
|
||||
mouse_location == priv->highlight_widget)
|
||||
mouse_location = priv->trough_widget;
|
||||
|
||||
if (mouse_location == priv->slider_widget &&
|
||||
gdk_event_triggers_context_menu (event))
|
||||
{
|
||||
gboolean handled;
|
||||
|
||||
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
||||
g_signal_emit_by_name (widget, "popup-menu", &handled);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mouse_location == priv->slider_widget)
|
||||
{
|
||||
/* Shift-click in the slider = fine adjustment */
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkintl.h"
|
||||
|
||||
#include "gtkshortcutmanager.h"
|
||||
|
||||
/**
|
||||
* SECTION:gtkroot
|
||||
* @Title: GtkRoot
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "gtkscale.h"
|
||||
|
||||
#include "gtkadjustment.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkbuilderprivate.h"
|
||||
#include "gtkgizmoprivate.h"
|
||||
@ -623,10 +622,11 @@ gtk_scale_size_allocate (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
#define add_slider_binding(binding_set, keyval, mask, scroll) \
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, mask, \
|
||||
I_("move-slider"), 1, \
|
||||
GTK_TYPE_SCROLL_TYPE, scroll)
|
||||
#define add_slider_binding(binding_set, keyval, mask, scroll) \
|
||||
gtk_widget_class_add_binding_signal (widget_class, \
|
||||
keyval, mask, \
|
||||
I_("move-slider"), \
|
||||
"(i)", scroll)
|
||||
|
||||
static void
|
||||
gtk_scale_value_changed (GtkRange *range)
|
||||
@ -650,7 +650,6 @@ gtk_scale_class_init (GtkScaleClass *class)
|
||||
GObjectClass *gobject_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkRangeClass *range_class;
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
gobject_class = G_OBJECT_CLASS (class);
|
||||
range_class = (GtkRangeClass*) class;
|
||||
@ -706,8 +705,6 @@ gtk_scale_class_init (GtkScaleClass *class)
|
||||
* blind users etc. don't care about scale orientation.
|
||||
*/
|
||||
|
||||
binding_set = gtk_binding_set_by_class (class);
|
||||
|
||||
add_slider_binding (binding_set, GDK_KEY_Left, 0,
|
||||
GTK_SCROLL_STEP_LEFT);
|
||||
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "gtkscalebutton.h"
|
||||
|
||||
#include "gtkadjustment.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkbox.h"
|
||||
#include "gtkbuttonprivate.h"
|
||||
#include "gtkimage.h"
|
||||
@ -171,7 +170,6 @@ gtk_scale_button_class_init (GtkScaleButtonClass *klass)
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass);
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
gobject_class->constructed = gtk_scale_button_constructed;
|
||||
gobject_class->finalize = gtk_scale_button_finalize;
|
||||
@ -298,20 +296,30 @@ gtk_scale_button_class_init (GtkScaleButtonClass *klass)
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
/* Key bindings */
|
||||
binding_set = gtk_binding_set_by_class (widget_class);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_space, 0,
|
||||
"popup", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Space, 0,
|
||||
"popup", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Return, 0,
|
||||
"popup", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_ISO_Enter, 0,
|
||||
"popup", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Enter, 0,
|
||||
"popup", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0,
|
||||
"popdown", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_space, 0,
|
||||
"popup",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Space, 0,
|
||||
"popup",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Return, 0,
|
||||
"popup",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_ISO_Enter, 0,
|
||||
"popup",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Enter, 0,
|
||||
"popup",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Escape, 0,
|
||||
"popdown",
|
||||
NULL);
|
||||
|
||||
/* Bind class to template
|
||||
*/
|
||||
|
@ -209,16 +209,6 @@ gtk_scrollbar_class_init (GtkScrollbarClass *class)
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
emit_popup_menu (GtkWidget *self)
|
||||
{
|
||||
gboolean handled;
|
||||
|
||||
g_signal_emit_by_name (self, "popup-menu", &handled);
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_scrollbar_init (GtkScrollbar *self)
|
||||
{
|
||||
@ -227,7 +217,6 @@ gtk_scrollbar_init (GtkScrollbar *self)
|
||||
priv->orientation = GTK_ORIENTATION_HORIZONTAL;
|
||||
|
||||
priv->range = g_object_new (GTK_TYPE_RANGE, NULL);
|
||||
g_signal_connect_swapped (priv->range, "popup-menu", G_CALLBACK (emit_popup_menu), self);
|
||||
gtk_widget_set_hexpand (priv->range, TRUE);
|
||||
gtk_widget_set_vexpand (priv->range, TRUE);
|
||||
gtk_widget_set_parent (priv->range, GTK_WIDGET (self));
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
#include "gtkadjustment.h"
|
||||
#include "gtkadjustmentprivate.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkeventcontrollermotion.h"
|
||||
#include "gtkeventcontrollerscroll.h"
|
||||
#include "gtkgesturedrag.h"
|
||||
@ -413,7 +412,7 @@ static GParamSpec *properties[NUM_PROPERTIES];
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkScrolledWindow, gtk_scrolled_window, GTK_TYPE_BIN)
|
||||
|
||||
static void
|
||||
add_scroll_binding (GtkBindingSet *binding_set,
|
||||
add_scroll_binding (GtkWidgetClass *widget_class,
|
||||
guint keyval,
|
||||
GdkModifierType mask,
|
||||
GtkScrollType scroll,
|
||||
@ -421,27 +420,29 @@ add_scroll_binding (GtkBindingSet *binding_set,
|
||||
{
|
||||
guint keypad_keyval = keyval - GDK_KEY_Left + GDK_KEY_KP_Left;
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, mask,
|
||||
"scroll-child", 2,
|
||||
GTK_TYPE_SCROLL_TYPE, scroll,
|
||||
G_TYPE_BOOLEAN, horizontal);
|
||||
gtk_binding_entry_add_signal (binding_set, keypad_keyval, mask,
|
||||
"scroll-child", 2,
|
||||
GTK_TYPE_SCROLL_TYPE, scroll,
|
||||
G_TYPE_BOOLEAN, horizontal);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, mask,
|
||||
"scroll-child",
|
||||
"(ib)", scroll, horizontal);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keypad_keyval, mask,
|
||||
"scroll-child",
|
||||
"(ib)", scroll, horizontal);
|
||||
}
|
||||
|
||||
static void
|
||||
add_tab_bindings (GtkBindingSet *binding_set,
|
||||
add_tab_bindings (GtkWidgetClass *widget_class,
|
||||
GdkModifierType modifiers,
|
||||
GtkDirectionType direction)
|
||||
{
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Tab, modifiers,
|
||||
"move-focus-out", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, direction);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Tab, modifiers,
|
||||
"move-focus-out", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, direction);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Tab, modifiers,
|
||||
"move-focus-out",
|
||||
"(i)", direction);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Tab, modifiers,
|
||||
"move-focus-out",
|
||||
"(i)", direction);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -517,7 +518,6 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
gobject_class->set_property = gtk_scrolled_window_set_property;
|
||||
gobject_class->get_property = gtk_scrolled_window_get_property;
|
||||
@ -789,25 +789,23 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1, GTK_TYPE_POSITION_TYPE);
|
||||
|
||||
binding_set = gtk_binding_set_by_class (class);
|
||||
add_scroll_binding (widget_class, GDK_KEY_Left, GDK_CONTROL_MASK, GTK_SCROLL_STEP_BACKWARD, TRUE);
|
||||
add_scroll_binding (widget_class, GDK_KEY_Right, GDK_CONTROL_MASK, GTK_SCROLL_STEP_FORWARD, TRUE);
|
||||
add_scroll_binding (widget_class, GDK_KEY_Up, GDK_CONTROL_MASK, GTK_SCROLL_STEP_BACKWARD, FALSE);
|
||||
add_scroll_binding (widget_class, GDK_KEY_Down, GDK_CONTROL_MASK, GTK_SCROLL_STEP_FORWARD, FALSE);
|
||||
|
||||
add_scroll_binding (binding_set, GDK_KEY_Left, GDK_CONTROL_MASK, GTK_SCROLL_STEP_BACKWARD, TRUE);
|
||||
add_scroll_binding (binding_set, GDK_KEY_Right, GDK_CONTROL_MASK, GTK_SCROLL_STEP_FORWARD, TRUE);
|
||||
add_scroll_binding (binding_set, GDK_KEY_Up, GDK_CONTROL_MASK, GTK_SCROLL_STEP_BACKWARD, FALSE);
|
||||
add_scroll_binding (binding_set, GDK_KEY_Down, GDK_CONTROL_MASK, GTK_SCROLL_STEP_FORWARD, FALSE);
|
||||
add_scroll_binding (widget_class, GDK_KEY_Page_Up, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_BACKWARD, TRUE);
|
||||
add_scroll_binding (widget_class, GDK_KEY_Page_Down, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_FORWARD, TRUE);
|
||||
add_scroll_binding (widget_class, GDK_KEY_Page_Up, 0, GTK_SCROLL_PAGE_BACKWARD, FALSE);
|
||||
add_scroll_binding (widget_class, GDK_KEY_Page_Down, 0, GTK_SCROLL_PAGE_FORWARD, FALSE);
|
||||
|
||||
add_scroll_binding (binding_set, GDK_KEY_Page_Up, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_BACKWARD, TRUE);
|
||||
add_scroll_binding (binding_set, GDK_KEY_Page_Down, GDK_CONTROL_MASK, GTK_SCROLL_PAGE_FORWARD, TRUE);
|
||||
add_scroll_binding (binding_set, GDK_KEY_Page_Up, 0, GTK_SCROLL_PAGE_BACKWARD, FALSE);
|
||||
add_scroll_binding (binding_set, GDK_KEY_Page_Down, 0, GTK_SCROLL_PAGE_FORWARD, FALSE);
|
||||
add_scroll_binding (widget_class, GDK_KEY_Home, GDK_CONTROL_MASK, GTK_SCROLL_START, TRUE);
|
||||
add_scroll_binding (widget_class, GDK_KEY_End, GDK_CONTROL_MASK, GTK_SCROLL_END, TRUE);
|
||||
add_scroll_binding (widget_class, GDK_KEY_Home, 0, GTK_SCROLL_START, FALSE);
|
||||
add_scroll_binding (widget_class, GDK_KEY_End, 0, GTK_SCROLL_END, FALSE);
|
||||
|
||||
add_scroll_binding (binding_set, GDK_KEY_Home, GDK_CONTROL_MASK, GTK_SCROLL_START, TRUE);
|
||||
add_scroll_binding (binding_set, GDK_KEY_End, GDK_CONTROL_MASK, GTK_SCROLL_END, TRUE);
|
||||
add_scroll_binding (binding_set, GDK_KEY_Home, 0, GTK_SCROLL_START, FALSE);
|
||||
add_scroll_binding (binding_set, GDK_KEY_End, 0, GTK_SCROLL_END, FALSE);
|
||||
|
||||
add_tab_bindings (binding_set, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD);
|
||||
add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
|
||||
add_tab_bindings (widget_class, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD);
|
||||
add_tab_bindings (widget_class, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
|
||||
|
||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_SCROLLED_WINDOW_ACCESSIBLE);
|
||||
gtk_widget_class_set_css_name (widget_class, I_("scrolledwindow"));
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "gtksearchentryprivate.h"
|
||||
|
||||
#include "gtkaccessible.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkeditable.h"
|
||||
#include "gtkboxlayout.h"
|
||||
#include "gtkgestureclick.h"
|
||||
@ -267,7 +266,6 @@ gtk_search_entry_class_init (GtkSearchEntryClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
object_class->finalize = gtk_search_entry_finalize;
|
||||
object_class->get_property = gtk_search_entry_get_property;
|
||||
@ -401,14 +399,18 @@ gtk_search_entry_class_init (GtkSearchEntryClass *klass)
|
||||
NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
binding_set = gtk_binding_set_by_class (klass);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_g, GDK_CONTROL_MASK,
|
||||
"next-match", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_g, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
||||
"previous-match", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0,
|
||||
"stop-search", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_g, GDK_CONTROL_MASK,
|
||||
"next-match",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_g, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
||||
"previous-match",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Escape, 0,
|
||||
"stop-search",
|
||||
NULL);
|
||||
|
||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_ENTRY_ACCESSIBLE);
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT);
|
||||
|
392
gtk/gtkshortcut.c
Normal file
392
gtk/gtkshortcut.c
Normal file
@ -0,0 +1,392 @@
|
||||
/*
|
||||
* Copyright © 2018 Benjamin Otte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkshortcut.h"
|
||||
|
||||
#include "gtkintl.h"
|
||||
#include "gtkshortcutaction.h"
|
||||
#include "gtkshortcuttrigger.h"
|
||||
#include "gtkwidget.h"
|
||||
|
||||
/**
|
||||
* SECTION:gtkshortcut
|
||||
* @title: GtkShortcut
|
||||
* @short_description: An object describing a keyboard shortcut
|
||||
* @see_also: #GtkShortcutController, #GtkShortcutAction,
|
||||
* #GtkShortcutTrigger
|
||||
*
|
||||
* GtkShortcut is the low level object used for managing keyboard
|
||||
* shortcuts.
|
||||
*
|
||||
* It contains a description of how to trigger the shortcut via a
|
||||
* #GtkShortcutTrigger and a way to activate the shortcut on a widget
|
||||
* via #GtkShortcutAction.
|
||||
*
|
||||
* The actual work is usually done via #GtkShortcutController, which
|
||||
* decides if and when to activate a shortcut. Using that controller
|
||||
* directly however is rarely necessary as various higher level
|
||||
* convenience APIs exist on #GtkWidgets that make it easier to use
|
||||
* shortcuts in GTK.
|
||||
*
|
||||
* #GtkShortcut does provide functionality to make it easy for users
|
||||
* to work with shortcuts, either by providing informational strings
|
||||
* for display purposes or by allowing shortcuts to be configured.
|
||||
*/
|
||||
|
||||
struct _GtkShortcut
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GtkShortcutAction *action;
|
||||
GtkShortcutTrigger *trigger;
|
||||
GVariant *args;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_ACTION,
|
||||
PROP_ARGUMENTS,
|
||||
PROP_TRIGGER,
|
||||
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GtkShortcut, gtk_shortcut, G_TYPE_OBJECT)
|
||||
|
||||
static GParamSpec *properties[N_PROPS] = { NULL, };
|
||||
|
||||
static void
|
||||
gtk_shortcut_dispose (GObject *object)
|
||||
{
|
||||
GtkShortcut *self = GTK_SHORTCUT (object);
|
||||
|
||||
g_clear_pointer (&self->action, gtk_shortcut_action_unref);
|
||||
g_clear_pointer (&self->trigger, gtk_shortcut_trigger_unref);
|
||||
g_clear_pointer (&self->args, g_variant_unref);
|
||||
|
||||
G_OBJECT_CLASS (gtk_shortcut_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_shortcut_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkShortcut *self = GTK_SHORTCUT (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_ACTION:
|
||||
g_value_set_boxed (value, self->action);
|
||||
break;
|
||||
|
||||
case PROP_ARGUMENTS:
|
||||
g_value_set_variant (value, self->args);
|
||||
break;
|
||||
|
||||
case PROP_TRIGGER:
|
||||
g_value_set_boxed (value, self->trigger);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_shortcut_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkShortcut *self = GTK_SHORTCUT (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_ACTION:
|
||||
gtk_shortcut_set_action (self, g_value_dup_boxed (value));
|
||||
break;
|
||||
|
||||
case PROP_ARGUMENTS:
|
||||
gtk_shortcut_set_arguments (self, g_value_get_variant (value));
|
||||
break;
|
||||
|
||||
case PROP_TRIGGER:
|
||||
gtk_shortcut_set_trigger (self, g_value_dup_boxed (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_shortcut_class_init (GtkShortcutClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->dispose = gtk_shortcut_dispose;
|
||||
gobject_class->get_property = gtk_shortcut_get_property;
|
||||
gobject_class->set_property = gtk_shortcut_set_property;
|
||||
|
||||
/**
|
||||
* GtkShortcut:action:
|
||||
*
|
||||
* The action that gets activated by this shortcut.
|
||||
*/
|
||||
properties[PROP_ACTION] =
|
||||
g_param_spec_boxed ("action",
|
||||
P_("Action"),
|
||||
P_("The action activated by this shortcut"),
|
||||
GTK_TYPE_SHORTCUT_ACTION,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GtkShortcut:arguments:
|
||||
*
|
||||
* Arguments passed to activation.
|
||||
*/
|
||||
properties[PROP_ARGUMENTS] =
|
||||
g_param_spec_variant ("arguments",
|
||||
P_("Arguments"),
|
||||
P_("Arguments passed to activation"),
|
||||
G_VARIANT_TYPE_ANY,
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GtkShortcut:trigger:
|
||||
*
|
||||
* The trigger that triggers this shortcut.
|
||||
*/
|
||||
properties[PROP_TRIGGER] =
|
||||
g_param_spec_boxed ("trigger",
|
||||
P_("Trigger"),
|
||||
P_("The trigger for this shortcut"),
|
||||
GTK_TYPE_SHORTCUT_TRIGGER,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_shortcut_init (GtkShortcut *self)
|
||||
{
|
||||
self->action = gtk_nothing_action_new ();
|
||||
self->trigger = gtk_shortcut_trigger_ref (gtk_never_trigger_get ());
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_new:
|
||||
* @trigger: (transfer full) (allow-none): The trigger that will trigger the shortcut
|
||||
* @action: (transfer full) (allow-none): The action that will be activated upon
|
||||
* triggering
|
||||
*
|
||||
* Creates a new #GtkShortcut that is triggered by @trigger and then activates
|
||||
* @action.
|
||||
*
|
||||
* Returns: a new #GtkShortcut
|
||||
**/
|
||||
GtkShortcut *
|
||||
gtk_shortcut_new (GtkShortcutTrigger *trigger,
|
||||
GtkShortcutAction *action)
|
||||
{
|
||||
GtkShortcut *shortcut;
|
||||
|
||||
shortcut = g_object_new (GTK_TYPE_SHORTCUT,
|
||||
"action", action,
|
||||
"trigger", trigger,
|
||||
NULL);
|
||||
|
||||
if (trigger)
|
||||
gtk_shortcut_trigger_unref (trigger);
|
||||
if (action)
|
||||
gtk_shortcut_action_unref (action);
|
||||
|
||||
return shortcut;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_new_with_arguments: (skip)
|
||||
* @trigger: (transfer full) (allow-none): The trigger that will trigger the shortcut
|
||||
* @action: (transfer full) (allow-none): The action that will be activated upon
|
||||
* triggering
|
||||
* @format_string: (allow-none): GVariant format string for arguments or %NULL for
|
||||
* no arguments
|
||||
* @...: arguments, as given by format string.
|
||||
*
|
||||
* Creates a new #GtkShortcut that is triggered by @trigger and then activates
|
||||
* @action with arguments given by @format_string.
|
||||
*
|
||||
* Returns: a new #GtkShortcut
|
||||
**/
|
||||
GtkShortcut *
|
||||
gtk_shortcut_new_with_arguments (GtkShortcutTrigger *trigger,
|
||||
GtkShortcutAction *action,
|
||||
const gchar *format_string,
|
||||
...)
|
||||
{
|
||||
GtkShortcut *shortcut;
|
||||
GVariant *args;
|
||||
|
||||
if (format_string)
|
||||
{
|
||||
va_list valist;
|
||||
va_start (valist, format_string);
|
||||
args = g_variant_new_va (format_string, NULL, &valist);
|
||||
va_end (valist);
|
||||
}
|
||||
else
|
||||
{
|
||||
args = NULL;
|
||||
}
|
||||
|
||||
shortcut = g_object_new (GTK_TYPE_SHORTCUT,
|
||||
"action", action,
|
||||
"arguments", args,
|
||||
"trigger", trigger,
|
||||
NULL);
|
||||
|
||||
if (trigger)
|
||||
gtk_shortcut_trigger_unref (trigger);
|
||||
if (action)
|
||||
gtk_shortcut_action_unref (action);
|
||||
|
||||
return shortcut;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_get_action:
|
||||
* @self: a #GtkShortcut
|
||||
*
|
||||
* Gets the action that is activated by this shortcut.
|
||||
*
|
||||
* Returns: (transfer none): the action
|
||||
**/
|
||||
GtkShortcutAction *
|
||||
gtk_shortcut_get_action (GtkShortcut *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_SHORTCUT (self), NULL);
|
||||
|
||||
return self->action;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_set_action:
|
||||
* @self: a #GtkShortcut
|
||||
* @action: (transfer full) (nullable): The new action.
|
||||
* If the @action is %NULL, the nothing action will be used.
|
||||
*
|
||||
* Sets the new action for @self to be @action.
|
||||
**/
|
||||
void
|
||||
gtk_shortcut_set_action (GtkShortcut *self,
|
||||
GtkShortcutAction *action)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_SHORTCUT (self));
|
||||
|
||||
if (action == NULL)
|
||||
action = gtk_nothing_action_new ();
|
||||
|
||||
if (self->action == action)
|
||||
{
|
||||
gtk_shortcut_action_unref (action);
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_shortcut_action_unref (self->action);
|
||||
self->action = action;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ACTION]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_get_trigger:
|
||||
* @self: a #GtkShortcut
|
||||
*
|
||||
* Gets the trigger used to trigger @self.
|
||||
*
|
||||
* Returns: (transfer none): the trigger used
|
||||
**/
|
||||
GtkShortcutTrigger *
|
||||
gtk_shortcut_get_trigger (GtkShortcut *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_SHORTCUT (self), NULL);
|
||||
|
||||
return self->trigger;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_set_trigger:
|
||||
* @self: a #GtkShortcut
|
||||
* @trigger: (transfer full) (nullable): The new trigger.
|
||||
* If the @trigger is %NULL, the never trigger will be used.
|
||||
*
|
||||
* Sets the new trigger for @self to be @trigger.
|
||||
**/
|
||||
void
|
||||
gtk_shortcut_set_trigger (GtkShortcut *self,
|
||||
GtkShortcutTrigger *trigger)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_SHORTCUT (self));
|
||||
|
||||
if (trigger == NULL)
|
||||
trigger = gtk_shortcut_trigger_ref (gtk_never_trigger_get ());
|
||||
|
||||
if (self->trigger == trigger)
|
||||
{
|
||||
gtk_shortcut_trigger_unref (trigger);
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_shortcut_trigger_unref (self->trigger);
|
||||
self->trigger = trigger;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TRIGGER]);
|
||||
}
|
||||
|
||||
GVariant *
|
||||
gtk_shortcut_get_arguments (GtkShortcut *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_SHORTCUT (self), NULL);
|
||||
|
||||
return self->args;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_shortcut_set_arguments (GtkShortcut *self,
|
||||
GVariant *args)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_SHORTCUT (self));
|
||||
|
||||
if (self->args == args)
|
||||
return;
|
||||
|
||||
g_clear_pointer (&self->args, g_variant_unref);
|
||||
if (args)
|
||||
self->args = g_variant_ref_sink (args);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ARGUMENTS]);
|
||||
}
|
62
gtk/gtkshortcut.h
Normal file
62
gtk/gtkshortcut.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright © 2018 Benjamin Otte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_SHORTCUT_H__
|
||||
#define __GTK_SHORTCUT_H__
|
||||
|
||||
#include <gtk/gtktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_SHORTCUT (gtk_shortcut_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (GtkShortcut, gtk_shortcut, GTK, SHORTCUT, GObject)
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcut * gtk_shortcut_new (GtkShortcutTrigger *trigger,
|
||||
GtkShortcutAction *action);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcut * gtk_shortcut_new_with_arguments (GtkShortcutTrigger *trigger,
|
||||
GtkShortcutAction *action,
|
||||
const gchar *format_string,
|
||||
...);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutTrigger *
|
||||
gtk_shortcut_get_trigger (GtkShortcut *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_shortcut_set_trigger (GtkShortcut *self,
|
||||
GtkShortcutTrigger *trigger);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutAction *
|
||||
gtk_shortcut_get_action (GtkShortcut *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_shortcut_set_action (GtkShortcut *self,
|
||||
GtkShortcutAction *action);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GVariant * gtk_shortcut_get_arguments (GtkShortcut *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_shortcut_set_arguments (GtkShortcut *self,
|
||||
GVariant *args);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_SHORTCUT_H__ */
|
1134
gtk/gtkshortcutaction.c
Normal file
1134
gtk/gtkshortcutaction.c
Normal file
File diff suppressed because it is too large
Load Diff
135
gtk/gtkshortcutaction.h
Normal file
135
gtk/gtkshortcutaction.h
Normal file
@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright © 2018 Benjamin Otte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_SHORTCUT_ACTION_H__
|
||||
#define __GTK_SHORTCUT_ACTION_H__
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gtk/gtktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_SHORTCUT_ACTION (gtk_shortcut_action_get_type ())
|
||||
|
||||
#define GTK_IS_SHORTCUT_ACTION(obj) ((obj) != NULL)
|
||||
|
||||
/**
|
||||
* GtkShortcutFunc:
|
||||
* @widget: The widget passed to the activation
|
||||
* @args: The arguments passed to the activation
|
||||
* @user_data: The user data provided when activating the action
|
||||
*
|
||||
* Prototype for shortcuts based on user callbacks.
|
||||
*/
|
||||
typedef gboolean (* GtkShortcutFunc) (GtkWidget *widget,
|
||||
GVariant *args,
|
||||
gpointer user_data);
|
||||
|
||||
/**
|
||||
* GtkShortcutActionFlags:
|
||||
* @GTK_SHORTCUT_ACTION_EXCLUSIVE: The action is the only
|
||||
* action that can be activated. If this flag is not set,
|
||||
* a future activation may select a different action.
|
||||
*
|
||||
* List of flags that can be passed to action activation.
|
||||
* More flags may be added in the future.
|
||||
**/
|
||||
typedef enum {
|
||||
GTK_SHORTCUT_ACTION_EXCLUSIVE = 1 << 0
|
||||
} GtkShortcutActionFlags;
|
||||
|
||||
/**
|
||||
* GtkShortcutActionType:
|
||||
* @GTK_SHORTCUT_ACTION_NOTHING: Don't ever activate
|
||||
* @GTK_SHORTCUT_ACTION_CALLBACK: Call a custom user-provided callback
|
||||
* @GTK_SHORTCUT_ACTION_ACTIVATE: Call gtk_widget_activate() on the widget
|
||||
* @GTK_SHORTCUT_ACTION_MNEMONIC: Call gtk_widget_mnemonic_activate()
|
||||
* on the widget
|
||||
* @GTK_SHORTCUT_ACTION_SIGNAL: Emit the given action signal on the widget
|
||||
* @GTK_SHORTCUT_ACTION_ACTION: Call the provided action on the widget
|
||||
* @GTK_SHORTCUT_ACTION_GACTION: Activate a GAction
|
||||
*
|
||||
* The type of a action determines what the action does when activated.
|
||||
**/
|
||||
typedef enum {
|
||||
GTK_SHORTCUT_ACTION_NOTHING,
|
||||
GTK_SHORTCUT_ACTION_CALLBACK,
|
||||
GTK_SHORTCUT_ACTION_ACTIVATE,
|
||||
GTK_SHORTCUT_ACTION_MNEMONIC,
|
||||
GTK_SHORTCUT_ACTION_SIGNAL,
|
||||
GTK_SHORTCUT_ACTION_ACTION,
|
||||
GTK_SHORTCUT_ACTION_GACTION
|
||||
} GtkShortcutActionType;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_shortcut_action_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutAction * gtk_shortcut_action_ref (GtkShortcutAction *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_shortcut_action_unref (GtkShortcutAction *self);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutActionType gtk_shortcut_action_get_action_type (GtkShortcutAction *self);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
char * gtk_shortcut_action_to_string (GtkShortcutAction *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_shortcut_action_print (GtkShortcutAction *self,
|
||||
GString *string);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_shortcut_action_activate (GtkShortcutAction *self,
|
||||
GtkShortcutActionFlags flags,
|
||||
GtkWidget *widget,
|
||||
GVariant *args);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutAction * gtk_nothing_action_new (void);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutAction * gtk_callback_action_new (GtkShortcutFunc callback,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutAction * gtk_mnemonic_action_new (void);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutAction * gtk_activate_action_new (void);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutAction * gtk_signal_action_new (const char *signal_name);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const char * gtk_signal_action_get_signal_name (GtkShortcutAction *action);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutAction * gtk_action_action_new (const char *name);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const char * gtk_action_action_get_name (GtkShortcutAction *action);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutAction * gtk_gaction_action_new (GAction *action);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GAction * gtk_gaction_action_get_gaction (GtkShortcutAction *action);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_SHORTCUT_ACTION_H__ */
|
29
gtk/gtkshortcutactionprivate.h
Normal file
29
gtk/gtkshortcutactionprivate.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright © 2018 Benjamin Otte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_SHORTCUT_ACTION_PRIVATE_H__
|
||||
#define __GTK_SHORTCUT_ACTION_PRIVATE_H__
|
||||
|
||||
#include "gtkshortcutaction.h"
|
||||
|
||||
GtkShortcutAction * gtk_shortcut_action_parse_builder (GtkBuilder *builder,
|
||||
const char *string,
|
||||
GError **error);
|
||||
|
||||
#endif /* __GTK_SHORTCUT_ACTION_PRIVATE_H__ */
|
673
gtk/gtkshortcutcontroller.c
Normal file
673
gtk/gtkshortcutcontroller.c
Normal file
@ -0,0 +1,673 @@
|
||||
/*
|
||||
* Copyright © 2018 Benjamin Otte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* SECTION:gtkshortcutcontroller
|
||||
* @Short_description: Event controller for shortcuts
|
||||
* @Title: GtkShortcutController
|
||||
* @See_also: #GtkEventController, #GtkShortcut
|
||||
*
|
||||
* #GtkShortcutController is an event controller that manages shortcuts.
|
||||
*
|
||||
* #GtkShortcutController implements #GListModel for querying the shortcuts that
|
||||
* have been added to it.
|
||||
**/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkshortcutcontrollerprivate.h"
|
||||
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkconcatmodelprivate.h"
|
||||
#include "gtkeventcontrollerprivate.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkshortcut.h"
|
||||
#include "gtkshortcutmanager.h"
|
||||
#include "gtkshortcuttrigger.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
struct _GtkShortcutController
|
||||
{
|
||||
GtkEventController parent_instance;
|
||||
|
||||
GListModel *shortcuts;
|
||||
GtkShortcutScope scope;
|
||||
GdkModifierType mnemonics_modifiers;
|
||||
|
||||
guint custom_shortcuts : 1;
|
||||
};
|
||||
|
||||
struct _GtkShortcutControllerClass
|
||||
{
|
||||
GtkEventControllerClass parent_class;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_MNEMONICS_MODIFIERS,
|
||||
PROP_MODEL,
|
||||
PROP_SCOPE,
|
||||
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
static GParamSpec *properties[N_PROPS] = { NULL, };
|
||||
|
||||
static GType
|
||||
gtk_shortcut_controller_list_model_get_item_type (GListModel *list)
|
||||
{
|
||||
return GTK_TYPE_SHORTCUT;
|
||||
}
|
||||
|
||||
static guint
|
||||
gtk_shortcut_controller_list_model_get_n_items (GListModel *list)
|
||||
{
|
||||
GtkShortcutController *self = GTK_SHORTCUT_CONTROLLER (list);
|
||||
|
||||
return g_list_model_get_n_items (self->shortcuts);
|
||||
}
|
||||
|
||||
static gpointer
|
||||
gtk_shortcut_controller_list_model_get_item (GListModel *list,
|
||||
guint position)
|
||||
{
|
||||
GtkShortcutController *self = GTK_SHORTCUT_CONTROLLER (list);
|
||||
|
||||
return g_list_model_get_item (self->shortcuts, position);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_shortcut_controller_list_model_init (GListModelInterface *iface)
|
||||
{
|
||||
iface->get_item_type = gtk_shortcut_controller_list_model_get_item_type;
|
||||
iface->get_n_items = gtk_shortcut_controller_list_model_get_n_items;
|
||||
iface->get_item = gtk_shortcut_controller_list_model_get_item;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_shortcut_controller_buildable_add_child (GtkBuildable *buildable,
|
||||
GtkBuilder *builder,
|
||||
GObject *child,
|
||||
const gchar *type)
|
||||
{
|
||||
if (type != NULL)
|
||||
{
|
||||
GTK_BUILDER_WARN_INVALID_CHILD_TYPE (buildable, type);
|
||||
}
|
||||
if (GTK_IS_SHORTCUT (child))
|
||||
{
|
||||
gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (buildable), GTK_SHORTCUT (child));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Cannot add an object of type %s to a controller of type %s",
|
||||
g_type_name (G_OBJECT_TYPE (child)), g_type_name (G_OBJECT_TYPE (buildable)));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_shortcut_controller_buildable_init (GtkBuildableIface *iface)
|
||||
{
|
||||
iface->add_child = gtk_shortcut_controller_buildable_add_child;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkShortcutController, gtk_shortcut_controller,
|
||||
GTK_TYPE_EVENT_CONTROLLER,
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, gtk_shortcut_controller_list_model_init)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_shortcut_controller_buildable_init))
|
||||
|
||||
static gboolean
|
||||
gtk_shortcut_controller_is_rooted (GtkShortcutController *self)
|
||||
{
|
||||
GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (self));
|
||||
|
||||
if (widget == NULL)
|
||||
return FALSE;
|
||||
|
||||
return gtk_widget_get_root (widget) != NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_shortcut_controller_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkShortcutController *self = GTK_SHORTCUT_CONTROLLER (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_MNEMONICS_MODIFIERS:
|
||||
gtk_shortcut_controller_set_mnemonics_modifiers (self, g_value_get_flags (value));
|
||||
break;
|
||||
|
||||
case PROP_MODEL:
|
||||
{
|
||||
GListModel *model = g_value_get_object (value);
|
||||
if (model && g_list_model_get_item_type (model) != GTK_TYPE_SHORTCUT)
|
||||
{
|
||||
g_warning ("Setting a model with type '%s' on a shortcut controller that requires 'GtkShortcut'",
|
||||
g_type_name (g_list_model_get_item_type (model)));
|
||||
model = NULL;
|
||||
}
|
||||
if (model == NULL)
|
||||
{
|
||||
self->shortcuts = G_LIST_MODEL (g_list_store_new (GTK_TYPE_SHORTCUT));
|
||||
self->custom_shortcuts = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
self->shortcuts = g_object_ref (model);
|
||||
self->custom_shortcuts = FALSE;
|
||||
}
|
||||
g_signal_connect_swapped (self->shortcuts, "items-changed", G_CALLBACK (g_list_model_items_changed), self);
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_SCOPE:
|
||||
gtk_shortcut_controller_set_scope (self, g_value_get_enum (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_shortcut_controller_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkShortcutController *self = GTK_SHORTCUT_CONTROLLER (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_MNEMONICS_MODIFIERS:
|
||||
g_value_set_flags (value, self->mnemonics_modifiers);
|
||||
break;
|
||||
|
||||
case PROP_SCOPE:
|
||||
g_value_set_enum (value, self->scope);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_shortcut_controller_dispose (GObject *object)
|
||||
{
|
||||
GtkShortcutController *self = GTK_SHORTCUT_CONTROLLER (object);
|
||||
|
||||
if (self->custom_shortcuts)
|
||||
g_list_store_remove_all (G_LIST_STORE (self->shortcuts));
|
||||
|
||||
G_OBJECT_CLASS (gtk_shortcut_controller_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_shortcut_controller_finalize (GObject *object)
|
||||
{
|
||||
GtkShortcutController *self = GTK_SHORTCUT_CONTROLLER (object);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (self->shortcuts, g_list_model_items_changed, self);
|
||||
g_clear_object (&self->shortcuts);
|
||||
|
||||
G_OBJECT_CLASS (gtk_shortcut_controller_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_shortcut_controller_trigger_shortcut (GtkShortcutController *self,
|
||||
GtkShortcut *shortcut,
|
||||
guint position,
|
||||
GdkEvent *event,
|
||||
gboolean enable_mnemonics)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
if (!gtk_shortcut_trigger_trigger (gtk_shortcut_get_trigger (shortcut), event, enable_mnemonics))
|
||||
return FALSE;
|
||||
|
||||
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (self));
|
||||
if (!self->custom_shortcuts &&
|
||||
GTK_IS_CONCAT_MODEL (self->shortcuts))
|
||||
{
|
||||
GListModel *model = gtk_concat_model_get_model_for_item (GTK_CONCAT_MODEL (self->shortcuts), position);
|
||||
if (GTK_IS_SHORTCUT_CONTROLLER (model))
|
||||
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (model));
|
||||
}
|
||||
|
||||
return gtk_shortcut_action_activate (gtk_shortcut_get_action (shortcut),
|
||||
GTK_SHORTCUT_ACTION_EXCLUSIVE, /* FIXME */
|
||||
widget,
|
||||
gtk_shortcut_get_arguments (shortcut));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_shortcut_controller_run_controllers (GtkEventController *controller,
|
||||
GdkEvent *event,
|
||||
double x,
|
||||
double y,
|
||||
gboolean enable_mnemonics)
|
||||
{
|
||||
GtkShortcutController *self = GTK_SHORTCUT_CONTROLLER (controller);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < g_list_model_get_n_items (self->shortcuts); i++)
|
||||
{
|
||||
if (gtk_shortcut_controller_trigger_shortcut (self,
|
||||
g_list_model_get_item (self->shortcuts, i),
|
||||
i,
|
||||
event,
|
||||
enable_mnemonics))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_shortcut_controller_handle_event (GtkEventController *controller,
|
||||
GdkEvent *event,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkShortcutController *self = GTK_SHORTCUT_CONTROLLER (controller);
|
||||
gboolean enable_mnemonics;
|
||||
|
||||
if (self->scope != GTK_SHORTCUT_SCOPE_LOCAL)
|
||||
return FALSE;
|
||||
|
||||
if (gdk_event_get_event_type (event) == GDK_KEY_PRESS)
|
||||
{
|
||||
GdkModifierType modifiers;
|
||||
modifiers = gdk_event_get_modifier_state (event);
|
||||
enable_mnemonics = (modifiers & gtk_accelerator_get_default_mod_mask ()) == self->mnemonics_modifiers;
|
||||
}
|
||||
else
|
||||
{
|
||||
enable_mnemonics = FALSE;
|
||||
}
|
||||
|
||||
return gtk_shortcut_controller_run_controllers (controller, event, x, y, enable_mnemonics);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_shortcut_controller_set_widget (GtkEventController *controller,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkShortcutController *self = GTK_SHORTCUT_CONTROLLER (controller);
|
||||
|
||||
GTK_EVENT_CONTROLLER_CLASS (gtk_shortcut_controller_parent_class)->set_widget (controller, widget);
|
||||
|
||||
if (_gtk_widget_get_root (widget))
|
||||
gtk_shortcut_controller_root (self);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_shortcut_controller_unset_widget (GtkEventController *controller)
|
||||
{
|
||||
GtkShortcutController *self = GTK_SHORTCUT_CONTROLLER (controller);
|
||||
GtkWidget *widget = gtk_event_controller_get_widget (controller);
|
||||
|
||||
if (_gtk_widget_get_root (widget))
|
||||
gtk_shortcut_controller_unroot (self);
|
||||
|
||||
GTK_EVENT_CONTROLLER_CLASS (gtk_shortcut_controller_parent_class)->unset_widget (controller);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_shortcut_controller_class_init (GtkShortcutControllerClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkEventControllerClass *controller_class = GTK_EVENT_CONTROLLER_CLASS (klass);
|
||||
|
||||
object_class->dispose = gtk_shortcut_controller_dispose;
|
||||
object_class->finalize = gtk_shortcut_controller_finalize;
|
||||
object_class->set_property = gtk_shortcut_controller_set_property;
|
||||
object_class->get_property = gtk_shortcut_controller_get_property;
|
||||
|
||||
controller_class->handle_event = gtk_shortcut_controller_handle_event;
|
||||
controller_class->set_widget = gtk_shortcut_controller_set_widget;
|
||||
controller_class->unset_widget = gtk_shortcut_controller_unset_widget;
|
||||
|
||||
/**
|
||||
* GtkShortcutController:mnemonic-modifiers:
|
||||
*
|
||||
* The modifiers that need to be pressed to allow mnemonics activation.
|
||||
*/
|
||||
properties[PROP_MNEMONICS_MODIFIERS] =
|
||||
g_param_spec_flags ("mnemonic-modifiers",
|
||||
P_("Mnemonic modifers"),
|
||||
P_("The modifiers to be pressed to allow mnemonics activation"),
|
||||
GDK_TYPE_MODIFIER_TYPE,
|
||||
GDK_MOD1_MASK,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GtkShortcutController:model:
|
||||
*
|
||||
* A list model to take shortcuts from
|
||||
*/
|
||||
properties[PROP_MODEL] =
|
||||
g_param_spec_object ("model",
|
||||
P_("Model"),
|
||||
P_("A list model to take shortcuts from"),
|
||||
G_TYPE_LIST_MODEL,
|
||||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GtkShortcutController:scope:
|
||||
*
|
||||
* What scope the shortcuts will be handled in.
|
||||
*/
|
||||
properties[PROP_SCOPE] =
|
||||
g_param_spec_enum ("scope",
|
||||
P_("Scope"),
|
||||
P_("What scope the shortcuts will be handled in"),
|
||||
GTK_TYPE_SHORTCUT_SCOPE,
|
||||
GTK_SHORTCUT_SCOPE_LOCAL,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_shortcut_controller_init (GtkShortcutController *self)
|
||||
{
|
||||
self->mnemonics_modifiers = GDK_MOD1_MASK;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_shortcut_controller_root (GtkShortcutController *self)
|
||||
{
|
||||
GtkShortcutManager *manager;
|
||||
|
||||
switch (self->scope)
|
||||
{
|
||||
case GTK_SHORTCUT_SCOPE_LOCAL:
|
||||
return;
|
||||
|
||||
case GTK_SHORTCUT_SCOPE_MANAGED:
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
for (widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (self));
|
||||
!GTK_IS_SHORTCUT_MANAGER (widget);
|
||||
widget = _gtk_widget_get_parent (widget))
|
||||
;
|
||||
|
||||
if (!GTK_IS_SHORTCUT_MANAGER (widget))
|
||||
return;
|
||||
|
||||
manager = GTK_SHORTCUT_MANAGER (widget);
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_SHORTCUT_SCOPE_GLOBAL:
|
||||
{
|
||||
GtkRoot *root = gtk_widget_get_root (gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (self)));
|
||||
|
||||
if (!GTK_IS_SHORTCUT_MANAGER (root))
|
||||
return;
|
||||
|
||||
manager = GTK_SHORTCUT_MANAGER (root);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return;
|
||||
}
|
||||
|
||||
GTK_SHORTCUT_MANAGER_GET_IFACE (manager)->add_controller (manager, self);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_shortcut_controller_unroot (GtkShortcutController *self)
|
||||
{
|
||||
GtkShortcutManager *manager;
|
||||
|
||||
switch (self->scope)
|
||||
{
|
||||
case GTK_SHORTCUT_SCOPE_LOCAL:
|
||||
return;
|
||||
|
||||
case GTK_SHORTCUT_SCOPE_MANAGED:
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
for (widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (self));
|
||||
!GTK_IS_SHORTCUT_MANAGER (widget);
|
||||
widget = _gtk_widget_get_parent (widget))
|
||||
;
|
||||
|
||||
if (!GTK_IS_SHORTCUT_MANAGER (widget))
|
||||
return;
|
||||
|
||||
manager = GTK_SHORTCUT_MANAGER (widget);
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_SHORTCUT_SCOPE_GLOBAL:
|
||||
{
|
||||
GtkRoot *root = gtk_widget_get_root (gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (self)));
|
||||
|
||||
if (!GTK_IS_SHORTCUT_MANAGER (root))
|
||||
return;
|
||||
|
||||
manager = GTK_SHORTCUT_MANAGER (root);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return;
|
||||
}
|
||||
|
||||
GTK_SHORTCUT_MANAGER_GET_IFACE (manager)->remove_controller (manager, self);
|
||||
}
|
||||
|
||||
GtkEventController *
|
||||
gtk_shortcut_controller_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_SHORTCUT_CONTROLLER,
|
||||
NULL);
|
||||
}
|
||||
|
||||
GtkEventController *
|
||||
gtk_shortcut_controller_new_for_model (GListModel *model)
|
||||
{
|
||||
g_return_val_if_fail (G_IS_LIST_MODEL (model), NULL);
|
||||
g_return_val_if_fail (g_list_model_get_item_type (model) == GTK_TYPE_SHORTCUT, NULL);
|
||||
|
||||
return g_object_new (GTK_TYPE_SHORTCUT_CONTROLLER,
|
||||
"model", model,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_controller_add_shortcut:
|
||||
* @self: the controller
|
||||
* @shortcut: a #GtkShortcut
|
||||
*
|
||||
* Adds @shortcut to the list of shortcuts handled by @self.
|
||||
*
|
||||
* If this controller uses an external shortcut list, this function does
|
||||
* nothing.
|
||||
*
|
||||
* The shortcut is added to the list so that it is triggered before
|
||||
* all existing shortcuts.
|
||||
*
|
||||
* FIXME: What's supposed to happen if a shortcut gets added twice?
|
||||
**/
|
||||
void
|
||||
gtk_shortcut_controller_add_shortcut (GtkShortcutController *self,
|
||||
GtkShortcut *shortcut)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_SHORTCUT_CONTROLLER (self));
|
||||
g_return_if_fail (GTK_IS_SHORTCUT (shortcut));
|
||||
|
||||
if (!self->custom_shortcuts)
|
||||
return;
|
||||
|
||||
g_list_store_append (G_LIST_STORE (self->shortcuts), shortcut);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_controller_remove_shortcut:
|
||||
* @self: the controller
|
||||
* @shortcut: a #GtkShortcut
|
||||
*
|
||||
* Removes @shortcut from the list of shortcuts handled by @self.
|
||||
*
|
||||
* If @shortcut had not been added to @controller or this controller
|
||||
* uses an external shortcut list, this function does nothing.
|
||||
**/
|
||||
void
|
||||
gtk_shortcut_controller_remove_shortcut (GtkShortcutController *self,
|
||||
GtkShortcut *shortcut)
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_if_fail (GTK_IS_SHORTCUT_CONTROLLER (self));
|
||||
g_return_if_fail (GTK_IS_SHORTCUT (shortcut));
|
||||
|
||||
if (!self->custom_shortcuts)
|
||||
return;
|
||||
|
||||
for (i = 0; i < g_list_model_get_n_items (self->shortcuts); i++)
|
||||
{
|
||||
GtkShortcut *item = g_list_model_get_item (self->shortcuts, i);
|
||||
|
||||
if (item == shortcut)
|
||||
{
|
||||
g_object_unref (item);
|
||||
g_list_store_remove (G_LIST_STORE (self->shortcuts), i);
|
||||
return;
|
||||
}
|
||||
|
||||
g_object_unref (item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_controller_set_scope:
|
||||
* @self: a #GtkShortcutController
|
||||
* @scope: the new scope to use
|
||||
*
|
||||
* Sets the controller to have the given @scope.
|
||||
*
|
||||
* The scope allows shortcuts to be activated outside of the normal
|
||||
* event propagation. In particular, it allows installing global
|
||||
* keyboard shortcuts that can be activated even when a widget does
|
||||
* not have focus.
|
||||
**/
|
||||
void
|
||||
gtk_shortcut_controller_set_scope (GtkShortcutController *self,
|
||||
GtkShortcutScope scope)
|
||||
{
|
||||
gboolean rooted;
|
||||
|
||||
g_return_if_fail (GTK_IS_SHORTCUT_CONTROLLER (self));
|
||||
|
||||
if (self->scope == scope)
|
||||
return;
|
||||
|
||||
rooted = gtk_shortcut_controller_is_rooted (self);
|
||||
|
||||
if (rooted)
|
||||
gtk_shortcut_controller_unroot (self);
|
||||
|
||||
self->scope = scope;
|
||||
|
||||
if (rooted)
|
||||
gtk_shortcut_controller_root (self);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SCOPE]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_controller_get_scope:
|
||||
* @self: a #GtkShortcutController
|
||||
*
|
||||
* Gets the scope for when this controller activates its shortcuts. See
|
||||
* gtk_shortcut_controller_set_scope() for details.
|
||||
*
|
||||
* Returns: the controller's scope
|
||||
**/
|
||||
GtkShortcutScope
|
||||
gtk_shortcut_controller_get_scope (GtkShortcutController *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_SHORTCUT_CONTROLLER (self), GTK_SHORTCUT_SCOPE_LOCAL);
|
||||
|
||||
return self->scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_controller_set_mnemonics_modifiers:
|
||||
* @self: a #GtkShortcutController
|
||||
* @modifiers: the new mnemonics_modifiers to use
|
||||
*
|
||||
* Sets the controller to have the given @mnemonics_modifiers.
|
||||
*
|
||||
* The mnemonics modifiers determines which modifiers need to be pressed to allow
|
||||
* activation of shortcuts with mnemonics triggers.
|
||||
*
|
||||
* This value is only relevant for local shortcut controllers. Global and managed
|
||||
* shortcut controllers will have their shortcuts activated from other places which
|
||||
* have their own modifiers for activating mnemonics.
|
||||
**/
|
||||
void
|
||||
gtk_shortcut_controller_set_mnemonics_modifiers (GtkShortcutController *self,
|
||||
GdkModifierType modifiers)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_SHORTCUT_CONTROLLER (self));
|
||||
|
||||
if (self->mnemonics_modifiers == modifiers)
|
||||
return;
|
||||
|
||||
self->mnemonics_modifiers = modifiers;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MNEMONICS_MODIFIERS]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_controller_get_mnemonics_modifiers:
|
||||
* @self: a #GtkShortcutController
|
||||
*
|
||||
* Gets the mnemonics modifiers for when this controller activates its shortcuts. See
|
||||
* gtk_shortcut_controller_set_mnemonics_modifiers() for details.
|
||||
*
|
||||
* Returns: the controller's mnemonics modifiers
|
||||
**/
|
||||
GdkModifierType
|
||||
gtk_shortcut_controller_get_mnemonics_modifiers (GtkShortcutController *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_SHORTCUT_CONTROLLER (self), GTK_SHORTCUT_SCOPE_LOCAL);
|
||||
|
||||
return self->mnemonics_modifiers;
|
||||
}
|
||||
|
70
gtk/gtkshortcutcontroller.h
Normal file
70
gtk/gtkshortcutcontroller.h
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright © 2018 Benjamin Otte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __GTK_SHORTCUT_CONTROLLER_H__
|
||||
#define __GTK_SHORTCUT_CONTROLLER_H__
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gtk/gtkeventcontroller.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_SHORTCUT_CONTROLLER (gtk_shortcut_controller_get_type ())
|
||||
#define GTK_SHORTCUT_CONTROLLER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_SHORTCUT_CONTROLLER, GtkShortcutController))
|
||||
#define GTK_SHORTCUT_CONTROLLER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GTK_TYPE_SHORTCUT_CONTROLLER, GtkShortcutControllerClass))
|
||||
#define GTK_IS_SHORTCUT_CONTROLLER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_SHORTCUT_CONTROLLER))
|
||||
#define GTK_IS_SHORTCUT_CONTROLLER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTK_TYPE_SHORTCUT_CONTROLLER))
|
||||
#define GTK_SHORTCUT_CONTROLLER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_SHORTCUT_CONTROLLER, GtkShortcutControllerClass))
|
||||
|
||||
typedef struct _GtkShortcutController GtkShortcutController;
|
||||
typedef struct _GtkShortcutControllerClass GtkShortcutControllerClass;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_shortcut_controller_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkEventController * gtk_shortcut_controller_new (void);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkEventController * gtk_shortcut_controller_new_for_model (GListModel *list);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_shortcut_controller_set_mnemonics_modifiers (GtkShortcutController *self,
|
||||
GdkModifierType modifiers);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkModifierType gtk_shortcut_controller_get_mnemonics_modifiers (GtkShortcutController *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_shortcut_controller_set_scope (GtkShortcutController *self,
|
||||
GtkShortcutScope scope);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutScope gtk_shortcut_controller_get_scope (GtkShortcutController *self);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_shortcut_controller_add_shortcut (GtkShortcutController *self,
|
||||
GtkShortcut *shortcut);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_shortcut_controller_remove_shortcut (GtkShortcutController *self,
|
||||
GtkShortcut *shortcut);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_SHORTCUT_CONTROLLER_H__ */
|
28
gtk/gtkshortcutcontrollerprivate.h
Normal file
28
gtk/gtkshortcutcontrollerprivate.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright © 2018 Benjamin Otte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_SHORTCUT_CONTROLLER_PRIVATE_H__
|
||||
#define __GTK_SHORTCUT_CONTROLLER_PRIVATE_H__
|
||||
|
||||
#include "gtkshortcutcontroller.h"
|
||||
|
||||
void gtk_shortcut_controller_root (GtkShortcutController *controller);
|
||||
void gtk_shortcut_controller_unroot (GtkShortcutController *controller);
|
||||
|
||||
#endif /* __GTK_SHORTCUT_CONTROLLER_H__ */
|
@ -303,8 +303,7 @@ parse_combination (GtkShortcutLabel *self,
|
||||
accels = g_strsplit (str, "&", 0);
|
||||
for (k = 0; accels[k]; k++)
|
||||
{
|
||||
gtk_accelerator_parse (accels[k], &key, &modifier);
|
||||
if (key == 0 && modifier == 0)
|
||||
if (!gtk_accelerator_parse (accels[k], &key, &modifier))
|
||||
{
|
||||
retval = FALSE;
|
||||
break;
|
||||
|
106
gtk/gtkshortcutmanager.c
Normal file
106
gtk/gtkshortcutmanager.c
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright © 2018 Benjamin Otte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkshortcutmanager.h"
|
||||
#include "gtkshortcutmanagerprivate.h"
|
||||
#include "gtkconcatmodelprivate.h"
|
||||
|
||||
/**
|
||||
* SECTION:gtkshortcutmanager
|
||||
* @title: GtkShortcutManager
|
||||
* @short_description: Interface for managing shortcuts
|
||||
*
|
||||
* The GtkShortcutManager interface is used to implement
|
||||
* shortcut scopes.
|
||||
*/
|
||||
|
||||
G_DEFINE_INTERFACE (GtkShortcutManager, gtk_shortcut_manager, G_TYPE_OBJECT)
|
||||
|
||||
void
|
||||
gtk_shortcut_manager_create_controllers (GtkWidget *widget)
|
||||
{
|
||||
GtkConcatModel *model;
|
||||
GtkEventController *controller;
|
||||
|
||||
model = gtk_concat_model_new (GTK_TYPE_SHORTCUT);
|
||||
g_object_set_data_full (G_OBJECT (widget), "gtk-shortcut-manager-bubble", model, g_object_unref);
|
||||
controller = gtk_shortcut_controller_new_for_model (G_LIST_MODEL (model));
|
||||
gtk_event_controller_set_name (controller, "gtk-shortcut-manager-bubble");
|
||||
gtk_widget_add_controller (widget, controller);
|
||||
|
||||
model = gtk_concat_model_new (GTK_TYPE_SHORTCUT);
|
||||
g_object_set_data_full (G_OBJECT (widget), "gtk-shortcut-manager-capture", model, g_object_unref);
|
||||
controller = gtk_shortcut_controller_new_for_model (G_LIST_MODEL (model));
|
||||
gtk_event_controller_set_name (controller, "gtk-shortcut-manager-capture");
|
||||
gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
|
||||
gtk_widget_add_controller (widget, controller);
|
||||
}
|
||||
|
||||
static GtkConcatModel *
|
||||
gtk_shortcut_manager_get_model (GtkShortcutManager *self,
|
||||
GtkPropagationPhase phase)
|
||||
{
|
||||
switch (phase)
|
||||
{
|
||||
case GTK_PHASE_CAPTURE:
|
||||
return g_object_get_data (G_OBJECT (self), "gtk-shortcut-manager-capture");
|
||||
case GTK_PHASE_BUBBLE:
|
||||
return g_object_get_data (G_OBJECT (self), "gtk-shortcut-manager-bubble");
|
||||
case GTK_PHASE_NONE:
|
||||
case GTK_PHASE_TARGET:
|
||||
return NULL;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_shortcut_manager_default_add_controller (GtkShortcutManager *self,
|
||||
GtkShortcutController *controller)
|
||||
{
|
||||
GtkConcatModel *model;
|
||||
|
||||
model = gtk_shortcut_manager_get_model (self,
|
||||
gtk_event_controller_get_propagation_phase (GTK_EVENT_CONTROLLER (controller)));
|
||||
if (model)
|
||||
gtk_concat_model_append (model, G_LIST_MODEL (controller));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_shortcut_manager_default_remove_controller (GtkShortcutManager *self,
|
||||
GtkShortcutController *controller)
|
||||
{
|
||||
GtkConcatModel *model;
|
||||
|
||||
model = gtk_shortcut_manager_get_model (self,
|
||||
gtk_event_controller_get_propagation_phase (GTK_EVENT_CONTROLLER (controller)));
|
||||
if (model)
|
||||
gtk_concat_model_remove (model, G_LIST_MODEL (controller));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_shortcut_manager_default_init (GtkShortcutManagerInterface *iface)
|
||||
{
|
||||
iface->add_controller = gtk_shortcut_manager_default_add_controller;
|
||||
iface->remove_controller = gtk_shortcut_manager_default_remove_controller;
|
||||
}
|
||||
|
71
gtk/gtkshortcutmanager.h
Normal file
71
gtk/gtkshortcutmanager.h
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright © 2018 Benjamin Otte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_SHORTCUT_MANAGER_H__
|
||||
#define __GTK_SHORTCUT_MANAGER_H__
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gtk/gtkshortcutcontroller.h>
|
||||
#include <gtk/gtkwidget.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_SHORTCUT_MANAGER (gtk_shortcut_manager_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_INTERFACE (GtkShortcutManager, gtk_shortcut_manager, GTK, SHORTCUT_MANAGER, GtkWidget)
|
||||
|
||||
/**
|
||||
* GtkShortcutManager:
|
||||
*
|
||||
* This object is used to implement support for #GtkShortcutScopes. Every
|
||||
* widget that implements #GtkShortcutManager will be used as a
|
||||
* %GTK_SHORTCUT_SCOPE_MANAGED.
|
||||
*/
|
||||
|
||||
/**
|
||||
* GtkShortcutManagerInterface:
|
||||
* @add_controller: Add a #GtkShortcutController to be managed.
|
||||
* @remove_controller: Remove a #GtkShortcutController that had previously
|
||||
* been added.
|
||||
*
|
||||
* The list of functions that can be implemented for the #GtkShortcutManager interface.
|
||||
*
|
||||
* Note that no function is mandatory to implement, the default implementation will work
|
||||
* fine.
|
||||
*/
|
||||
struct _GtkShortcutManagerInterface
|
||||
{
|
||||
/*< private >*/
|
||||
GTypeInterface g_iface;
|
||||
|
||||
/*< public >*/
|
||||
void (* add_controller) (GtkShortcutManager *self,
|
||||
GtkShortcutController *controller);
|
||||
void (* remove_controller) (GtkShortcutManager *self,
|
||||
GtkShortcutController *controller);
|
||||
};
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_SHORTCUT_MANAGER_H__ */
|
12
gtk/gtkshortcutmanagerprivate.h
Normal file
12
gtk/gtkshortcutmanagerprivate.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef __GTK_SHORTCUT_MANAGER_PRIVATE_H__
|
||||
#define __GTK_SHORTCUT_MANAGER__PRIVATE_H__
|
||||
|
||||
#include "gtkshortcutmanager.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void gtk_shortcut_manager_create_controllers (GtkWidget *widget);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_SHORTCUT_MANAGER_PRIVATE_H__ */
|
@ -30,7 +30,6 @@
|
||||
#include "gtkorientable.h"
|
||||
#include "gtksizegroup.h"
|
||||
#include "gtkwidget.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkgesturepan.h"
|
||||
@ -307,7 +306,6 @@ gtk_shortcuts_section_class_init (GtkShortcutsSectionClass *klass)
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
object_class->finalize = gtk_shortcuts_section_finalize;
|
||||
object_class->get_property = gtk_shortcuts_section_get_property;
|
||||
@ -388,23 +386,23 @@ gtk_shortcuts_section_class_init (GtkShortcutsSectionClass *klass)
|
||||
G_TYPE_BOOLEAN, 1,
|
||||
G_TYPE_INT);
|
||||
|
||||
binding_set = gtk_binding_set_by_class (klass);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_Page_Up, 0,
|
||||
"change-current-page", 1,
|
||||
G_TYPE_INT, -1);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_Page_Down, 0,
|
||||
"change-current-page", 1,
|
||||
G_TYPE_INT, 1);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_Page_Up, GDK_CONTROL_MASK,
|
||||
"change-current-page", 1,
|
||||
G_TYPE_INT, -1);
|
||||
gtk_binding_entry_add_signal (binding_set,
|
||||
GDK_KEY_Page_Down, GDK_CONTROL_MASK,
|
||||
"change-current-page", 1,
|
||||
G_TYPE_INT, 1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Page_Up, 0,
|
||||
"change-current-page",
|
||||
"(i)", -1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Page_Down, 0,
|
||||
"change-current-page",
|
||||
"(i)", 1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Page_Up, GDK_CONTROL_MASK,
|
||||
"change-current-page",
|
||||
"(i)", -1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Page_Down, GDK_CONTROL_MASK,
|
||||
"change-current-page",
|
||||
"(i)", 1);
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, I_("shortcuts-section"));
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
#include "gtkshortcutswindowprivate.h"
|
||||
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkbox.h"
|
||||
#include "gtkgrid.h"
|
||||
#include "gtkheaderbar.h"
|
||||
@ -774,7 +773,6 @@ gtk_shortcuts_window_class_init (GtkShortcutsWindowClass *klass)
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
|
||||
GtkBindingSet *binding_set = gtk_binding_set_by_class (klass);
|
||||
|
||||
object_class->constructed = gtk_shortcuts_window_constructed;
|
||||
object_class->finalize = gtk_shortcuts_window_finalize;
|
||||
@ -856,8 +854,14 @@ gtk_shortcuts_window_class_init (GtkShortcutsWindowClass *klass)
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "close", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_f, GDK_CONTROL_MASK, "search", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Escape, 0,
|
||||
"close",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_f, GDK_CONTROL_MASK,
|
||||
"search",
|
||||
NULL);
|
||||
|
||||
g_type_ensure (GTK_TYPE_SHORTCUTS_GROUP);
|
||||
g_type_ensure (GTK_TYPE_SHORTCUTS_SHORTCUT);
|
||||
|
976
gtk/gtkshortcuttrigger.c
Normal file
976
gtk/gtkshortcuttrigger.c
Normal file
@ -0,0 +1,976 @@
|
||||
/*
|
||||
* Copyright © 2018 Benjamin Otte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:gtkshortcuttrigger
|
||||
* @Title: GtkShortcutTrigger
|
||||
* @Short_description: Triggers to track if shortcuts should be activated
|
||||
* @See_also: #GtkShortcut
|
||||
*
|
||||
* #GtkShortcutTrigger is the object used to track if a #GtkShortcut should be
|
||||
* activated. For this purpose, gtk_shortcut_trigger_trigger() can be called
|
||||
* on a #GdkEvent.
|
||||
*
|
||||
* #GtkShortcutTriggers contain functions that allow easy presentation to end
|
||||
* users as well as being printed for debugging.
|
||||
*
|
||||
* All #GtkShortcutTriggers are immutable, you can only specify their properties
|
||||
* during construction. If you want to change a trigger, you have to replace it
|
||||
* with a new one.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkshortcuttrigger.h"
|
||||
|
||||
#include "gtkaccelgroupprivate.h"
|
||||
|
||||
typedef struct _GtkShortcutTriggerClass GtkShortcutTriggerClass;
|
||||
|
||||
#define GTK_IS_SHORTCUT_TRIGGER_TYPE(trigger,type) (GTK_IS_SHORTCUT_TRIGGER (trigger) && (trigger)->trigger_class->trigger_type == (type))
|
||||
|
||||
struct _GtkShortcutTrigger
|
||||
{
|
||||
const GtkShortcutTriggerClass *trigger_class;
|
||||
|
||||
gatomicrefcount ref_count;
|
||||
};
|
||||
|
||||
struct _GtkShortcutTriggerClass
|
||||
{
|
||||
GtkShortcutTriggerType trigger_type;
|
||||
gsize struct_size;
|
||||
const char *type_name;
|
||||
|
||||
void (* finalize) (GtkShortcutTrigger *trigger);
|
||||
gboolean (* trigger) (GtkShortcutTrigger *trigger,
|
||||
GdkEvent *event,
|
||||
gboolean enable_mnemonics);
|
||||
guint (* hash) (GtkShortcutTrigger *trigger);
|
||||
int (* compare) (GtkShortcutTrigger *trigger1,
|
||||
GtkShortcutTrigger *trigger2);
|
||||
void (* print) (GtkShortcutTrigger *trigger,
|
||||
GString *string);
|
||||
gboolean (* print_label) (GtkShortcutTrigger *trigger,
|
||||
GdkDisplay *display,
|
||||
GString *string);
|
||||
};
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GtkShortcutTrigger, gtk_shortcut_trigger,
|
||||
gtk_shortcut_trigger_ref,
|
||||
gtk_shortcut_trigger_unref)
|
||||
|
||||
static void
|
||||
gtk_shortcut_trigger_finalize (GtkShortcutTrigger *self)
|
||||
{
|
||||
self->trigger_class->finalize (self);
|
||||
|
||||
g_free (self);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gtk_shortcut_trigger_new:
|
||||
* @trigger_class: class structure for this trigger
|
||||
*
|
||||
* Returns: (transfer full): the newly created #GtkShortcutTrigger
|
||||
*/
|
||||
static GtkShortcutTrigger *
|
||||
gtk_shortcut_trigger_new (const GtkShortcutTriggerClass *trigger_class)
|
||||
{
|
||||
GtkShortcutTrigger *self;
|
||||
|
||||
g_return_val_if_fail (trigger_class != NULL, NULL);
|
||||
|
||||
self = g_malloc0 (trigger_class->struct_size);
|
||||
g_atomic_ref_count_init (&self->ref_count);
|
||||
|
||||
self->trigger_class = trigger_class;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_trigger_ref:
|
||||
* @self: a #GtkShortcutTrigger
|
||||
*
|
||||
* Acquires a reference on the given #GtkShortcutTrigger.
|
||||
*
|
||||
* Returns: (transfer full): the #GtkShortcutTrigger with
|
||||
* an additional reference
|
||||
*/
|
||||
GtkShortcutTrigger *
|
||||
gtk_shortcut_trigger_ref (GtkShortcutTrigger *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_SHORTCUT_TRIGGER (self), NULL);
|
||||
|
||||
g_atomic_ref_count_inc (&self->ref_count);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_trigger_unref:
|
||||
* @self: (transfer full): a #GtkShortcutTrigger
|
||||
*
|
||||
* Releases a reference on the given #GtkShortcutTrigger.
|
||||
*
|
||||
* If the reference was the last, the resources associated
|
||||
* to the trigger are freed.
|
||||
*/
|
||||
void
|
||||
gtk_shortcut_trigger_unref (GtkShortcutTrigger *self)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_SHORTCUT_TRIGGER (self));
|
||||
|
||||
if (g_atomic_ref_count_dec (&self->ref_count))
|
||||
gtk_shortcut_trigger_finalize (self);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_trigger_get_trigger_type:
|
||||
* @self: a #GtkShortcutTrigger
|
||||
*
|
||||
* Returns the type of the @trigger.
|
||||
*
|
||||
* Returns: the type of the #GtkShortcutTrigger
|
||||
*/
|
||||
GtkShortcutTriggerType
|
||||
gtk_shortcut_trigger_get_trigger_type (GtkShortcutTrigger *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_SHORTCUT_TRIGGER (self), GTK_SHORTCUT_TRIGGER_NEVER);
|
||||
|
||||
return self->trigger_class->trigger_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_trigger_trigger:
|
||||
* @self: a #GtkShortcutTrigger
|
||||
* @event: the event to check
|
||||
* @enable_mnemonics: %TRUE if mnemonics should trigger. Usually the
|
||||
* value of this property is determined by checking that the passed
|
||||
* in @event is a Key event and has the right modifiers set.
|
||||
*
|
||||
* Checks if the given @event triggers @self. If so,
|
||||
* returns %TRUE.
|
||||
*
|
||||
* Returns: %TRUE if this event triggered the trigger
|
||||
**/
|
||||
gboolean
|
||||
gtk_shortcut_trigger_trigger (GtkShortcutTrigger *self,
|
||||
GdkEvent *event,
|
||||
gboolean enable_mnemonics)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_SHORTCUT_TRIGGER (self), FALSE);
|
||||
|
||||
return self->trigger_class->trigger (self, event, enable_mnemonics);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_trigger_parse_string:
|
||||
* @string: the string to parse
|
||||
*
|
||||
* Tries to parse the given string into a trigger. On success,
|
||||
* the parsed trigger is returned. When parsing failed, %NULL is
|
||||
* returned.
|
||||
*
|
||||
* FIXME: Document the supported format here once we've figured
|
||||
* it out.
|
||||
* For now, this function only supports gtk_accelerator_parse() and
|
||||
* can only return a trigger of type %GTK_SHORTCUT_TRIGGER_KEYVAL.
|
||||
*
|
||||
* Returns: a new #GtkShortcutTrigger or %NULL on error
|
||||
**/
|
||||
GtkShortcutTrigger *
|
||||
gtk_shortcut_trigger_parse_string (const char *string)
|
||||
{
|
||||
GdkModifierType modifiers;
|
||||
guint keyval;
|
||||
|
||||
g_return_val_if_fail (string != NULL, NULL);
|
||||
|
||||
if (gtk_accelerator_parse (string, &keyval, &modifiers))
|
||||
return gtk_keyval_trigger_new (keyval, modifiers);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_trigger_to_string:
|
||||
* @self: a #GtkShortcutTrigger
|
||||
*
|
||||
* Prints the given trigger into a human-readable string.
|
||||
* This is a small wrapper around gdk_content_formats_print()
|
||||
* to help when debugging.
|
||||
*
|
||||
* Returns: (transfer full): a new string
|
||||
**/
|
||||
char *
|
||||
gtk_shortcut_trigger_to_string (GtkShortcutTrigger *self)
|
||||
{
|
||||
GString *string;
|
||||
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
|
||||
string = g_string_new (NULL);
|
||||
gtk_shortcut_trigger_print (self, string);
|
||||
|
||||
return g_string_free (string, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_trigger_print:
|
||||
* @self: a #GtkShortcutTrigger
|
||||
* @string: a #GString to print into
|
||||
*
|
||||
* Prints the given trigger into a string for the developer.
|
||||
* This is meant for debugging and logging.
|
||||
*
|
||||
* The form of the representation may change at any time
|
||||
* and is not guaranteed to stay identical.
|
||||
**/
|
||||
void
|
||||
gtk_shortcut_trigger_print (GtkShortcutTrigger *self,
|
||||
GString *string)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_SHORTCUT_TRIGGER (self));
|
||||
g_return_if_fail (string != NULL);
|
||||
|
||||
return self->trigger_class->print (self, string);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_trigger_to_label:
|
||||
* @self: a #GtkShortcutTrigger
|
||||
* @display: #GdkDisplay to print for
|
||||
*
|
||||
* Gets textual representation for the given trigger. This
|
||||
* function is returning a translated string for presentation
|
||||
* to end users for example in menu items or in help texts.
|
||||
*
|
||||
* The @display in use may influence the resulting string in
|
||||
* various forms, such as resolving hardware keycodes or by
|
||||
* causing display-specific modifier names.
|
||||
*
|
||||
* The form of the representation may change at any time and is
|
||||
* not guaranteed to stay identical.
|
||||
*
|
||||
* Returns: (transfer full): a new string
|
||||
**/
|
||||
char *
|
||||
gtk_shortcut_trigger_to_label (GtkShortcutTrigger *self,
|
||||
GdkDisplay *display)
|
||||
{
|
||||
GString *string;
|
||||
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
|
||||
string = g_string_new (NULL);
|
||||
gtk_shortcut_trigger_print_label (self, display, string);
|
||||
|
||||
return g_string_free (string, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_trigger_print_label:
|
||||
* @self: a #GtkShortcutTrigger
|
||||
* @display: #GdkDisplay to print for
|
||||
* @string: a #GString to print into
|
||||
*
|
||||
* Prints the given trigger into a string. This function is
|
||||
* returning a translated string for presentation to end users
|
||||
* for example in menu items or in help texts.
|
||||
*
|
||||
* The @display in use may influence the resulting string in
|
||||
* various forms, such as resolving hardware keycodes or by
|
||||
* causing display-specific modifier names.
|
||||
*
|
||||
* The form of the representation may change at any time and is
|
||||
* not guaranteed to stay identical.
|
||||
*
|
||||
* Returns: %TRUE if something was printed or %FALSE if the
|
||||
* trigger did not have a textual representation suitable
|
||||
* for end users.
|
||||
**/
|
||||
gboolean
|
||||
gtk_shortcut_trigger_print_label (GtkShortcutTrigger *self,
|
||||
GdkDisplay *display,
|
||||
GString *string)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_SHORTCUT_TRIGGER (self), FALSE);
|
||||
g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
|
||||
g_return_val_if_fail (string != NULL, FALSE);
|
||||
|
||||
return self->trigger_class->print_label (self, display, string);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_trigger_hash:
|
||||
* @trigger: (type GtkShortcutTrigger): a #GtkShortcutTrigger
|
||||
*
|
||||
* Generates a hash value for a #GtkShortcutTrigger.
|
||||
*
|
||||
* The output of this function is guaranteed to be the same for a given
|
||||
* value only per-process. It may change between different processor
|
||||
* architectures or even different versions of GTK. Do not use this
|
||||
* function as a basis for building protocols or file formats.
|
||||
*
|
||||
* The types of @trigger is #gconstpointer only to allow use of this
|
||||
* function with #GHashTable. They must each be a #GtkShortcutTrigger.
|
||||
*
|
||||
* Returns: a hash value corresponding to @trigger
|
||||
**/
|
||||
guint
|
||||
gtk_shortcut_trigger_hash (gconstpointer trigger)
|
||||
{
|
||||
GtkShortcutTrigger *t = (GtkShortcutTrigger *) trigger;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_SHORTCUT_TRIGGER (trigger), 0);
|
||||
|
||||
return t->trigger_class->hash (t);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_trigger_equal:
|
||||
* @trigger1: (type GtkShortcutTrigger): a #GtkShortcutTrigger
|
||||
* @trigger2: (type GtkShortcutTrigger): a #GtkShortcutTrigger
|
||||
*
|
||||
* Checks if @trigger1 and @trigger2 trigger under the same conditions.
|
||||
*
|
||||
* The types of @one and @two are #gconstpointer only to allow use of this
|
||||
* function with #GHashTable. They must each be a #GtkShortcutTrigger.
|
||||
*
|
||||
* Returns: %TRUE if @trigger1 and @trigger2 are equal
|
||||
**/
|
||||
gboolean
|
||||
gtk_shortcut_trigger_equal (gconstpointer trigger1,
|
||||
gconstpointer trigger2)
|
||||
{
|
||||
return gtk_shortcut_trigger_compare (trigger1, trigger2) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_shortcut_trigger_compare:
|
||||
* @trigger1: (type GtkShortcutTrigger): a #GtkShortcutTrigger
|
||||
* @trigger2: (type GtkShortcutTrigger): a #GtkShortcutTrigger
|
||||
*
|
||||
*
|
||||
* The types of @one and @two are #gconstpointer only to allow use of this
|
||||
* function as a #GCompareFunc. They must each be a #GtkShortcutTrigger.
|
||||
*
|
||||
* Returns: An integer less than, equal to, or greater than zero if
|
||||
* @trigger1 is found, respectively, to be less than, to match,
|
||||
* or be greater than @trigger2.
|
||||
**/
|
||||
gint
|
||||
gtk_shortcut_trigger_compare (gconstpointer trigger1,
|
||||
gconstpointer trigger2)
|
||||
{
|
||||
GtkShortcutTrigger *t1 = (GtkShortcutTrigger *) trigger1;
|
||||
GtkShortcutTrigger *t2 = (GtkShortcutTrigger *) trigger2;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_SHORTCUT_TRIGGER (trigger1), -1);
|
||||
g_return_val_if_fail (GTK_IS_SHORTCUT_TRIGGER (trigger2), 1);
|
||||
|
||||
if (t1->trigger_class != t2->trigger_class)
|
||||
return t1->trigger_class->trigger_type - t2->trigger_class->trigger_type;
|
||||
|
||||
return t1->trigger_class->compare (t1, t2);
|
||||
}
|
||||
|
||||
/*** GTK_SHORTCUT_TRIGGER_NEVER ***/
|
||||
|
||||
typedef struct _GtkNeverTrigger GtkNeverTrigger;
|
||||
|
||||
struct _GtkNeverTrigger
|
||||
{
|
||||
GtkShortcutTrigger trigger;
|
||||
|
||||
guint never;
|
||||
GdkModifierType modifiers;
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_never_trigger_finalize (GtkShortcutTrigger *trigger)
|
||||
{
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_never_trigger_trigger (GtkShortcutTrigger *trigger,
|
||||
GdkEvent *event,
|
||||
gboolean enable_mnemonics)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static guint
|
||||
gtk_never_trigger_hash (GtkShortcutTrigger *trigger)
|
||||
{
|
||||
return GTK_SHORTCUT_TRIGGER_NEVER;
|
||||
}
|
||||
|
||||
static int
|
||||
gtk_never_trigger_compare (GtkShortcutTrigger *trigger1,
|
||||
GtkShortcutTrigger *trigger2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_never_trigger_print (GtkShortcutTrigger *trigger,
|
||||
GString *string)
|
||||
|
||||
{
|
||||
g_string_append (string, "<never>");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_never_trigger_print_label (GtkShortcutTrigger *trigger,
|
||||
GdkDisplay *display,
|
||||
GString *string)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static const GtkShortcutTriggerClass GTK_NEVER_TRIGGER_CLASS = {
|
||||
GTK_SHORTCUT_TRIGGER_NEVER,
|
||||
sizeof (GtkNeverTrigger),
|
||||
"GtkNeverTrigger",
|
||||
gtk_never_trigger_finalize,
|
||||
gtk_never_trigger_trigger,
|
||||
gtk_never_trigger_hash,
|
||||
gtk_never_trigger_compare,
|
||||
gtk_never_trigger_print,
|
||||
gtk_never_trigger_print_label
|
||||
};
|
||||
|
||||
static GtkNeverTrigger never = { { >K_NEVER_TRIGGER_CLASS, 1 } };
|
||||
|
||||
/**
|
||||
* gtk_never_trigger_get:
|
||||
*
|
||||
* Gets the never trigger. This is a singleton for a trigger
|
||||
* that never triggers. Use this trigger instead of %NULL
|
||||
* because it implements all virtual functions.
|
||||
*
|
||||
* Returns: (transfer none): The never trigger
|
||||
*/
|
||||
GtkShortcutTrigger *
|
||||
gtk_never_trigger_get (void)
|
||||
{
|
||||
return &never.trigger;
|
||||
}
|
||||
|
||||
/*** GTK_KEYVAL_TRIGGER ***/
|
||||
|
||||
typedef struct _GtkKeyvalTrigger GtkKeyvalTrigger;
|
||||
|
||||
struct _GtkKeyvalTrigger
|
||||
{
|
||||
GtkShortcutTrigger trigger;
|
||||
|
||||
guint keyval;
|
||||
GdkModifierType modifiers;
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_keyval_trigger_finalize (GtkShortcutTrigger *trigger)
|
||||
{
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_keyval_trigger_trigger (GtkShortcutTrigger *trigger,
|
||||
GdkEvent *event,
|
||||
gboolean enable_mnemonics)
|
||||
{
|
||||
GtkKeyvalTrigger *self = (GtkKeyvalTrigger *) trigger;
|
||||
GdkModifierType modifiers;
|
||||
guint keyval;
|
||||
|
||||
if (gdk_event_get_event_type (event) != GDK_KEY_PRESS)
|
||||
return FALSE;
|
||||
|
||||
/* XXX: This needs to deal with groups */
|
||||
modifiers = gdk_event_get_modifier_state (event);
|
||||
keyval = gdk_key_event_get_keyval (event);
|
||||
|
||||
if (keyval == GDK_KEY_ISO_Left_Tab)
|
||||
keyval = GDK_KEY_Tab;
|
||||
else
|
||||
keyval = gdk_keyval_to_lower (keyval);
|
||||
|
||||
return keyval == self->keyval && modifiers == self->modifiers;
|
||||
}
|
||||
|
||||
static guint
|
||||
gtk_keyval_trigger_hash (GtkShortcutTrigger *trigger)
|
||||
{
|
||||
GtkKeyvalTrigger *self = (GtkKeyvalTrigger *) trigger;
|
||||
|
||||
return (self->modifiers << 24)
|
||||
| (self->modifiers >> 8)
|
||||
| (self->keyval << 16)
|
||||
| GTK_SHORTCUT_TRIGGER_KEYVAL;
|
||||
}
|
||||
|
||||
static int
|
||||
gtk_keyval_trigger_compare (GtkShortcutTrigger *trigger1,
|
||||
GtkShortcutTrigger *trigger2)
|
||||
{
|
||||
GtkKeyvalTrigger *self1 = (GtkKeyvalTrigger *) trigger1;
|
||||
GtkKeyvalTrigger *self2 = (GtkKeyvalTrigger *) trigger2;
|
||||
|
||||
if (self1->modifiers != self2->modifiers)
|
||||
return self2->modifiers - self1->modifiers;
|
||||
|
||||
return self1->keyval - self2->keyval;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_keyval_trigger_print (GtkShortcutTrigger *trigger,
|
||||
GString *string)
|
||||
|
||||
{
|
||||
GtkKeyvalTrigger *self = (GtkKeyvalTrigger *) trigger;
|
||||
char *accelerator_name;
|
||||
|
||||
accelerator_name = gtk_accelerator_name (self->keyval, self->modifiers);
|
||||
g_string_append (string, accelerator_name);
|
||||
g_free (accelerator_name);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_keyval_trigger_print_label (GtkShortcutTrigger *trigger,
|
||||
GdkDisplay *display,
|
||||
GString *string)
|
||||
{
|
||||
GtkKeyvalTrigger *self = (GtkKeyvalTrigger *) trigger;
|
||||
|
||||
gtk_accelerator_print_label (string, self->keyval, self->modifiers);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static const GtkShortcutTriggerClass GTK_KEYVAL_TRIGGER_CLASS = {
|
||||
GTK_SHORTCUT_TRIGGER_KEYVAL,
|
||||
sizeof (GtkKeyvalTrigger),
|
||||
"GtkKeyvalTrigger",
|
||||
gtk_keyval_trigger_finalize,
|
||||
gtk_keyval_trigger_trigger,
|
||||
gtk_keyval_trigger_hash,
|
||||
gtk_keyval_trigger_compare,
|
||||
gtk_keyval_trigger_print,
|
||||
gtk_keyval_trigger_print_label
|
||||
};
|
||||
|
||||
/**
|
||||
* gtk_keyval_trigger_new:
|
||||
* @keyval: The keyval to trigger for
|
||||
* @modifiers: the modifiers that need to be present
|
||||
*
|
||||
* Creates a #GtkShortcutTrigger that will trigger whenever
|
||||
* the key with the given @keyval and @modifiers is pressed.
|
||||
*
|
||||
* Returns: A new #GtkShortcutTrigger
|
||||
*/
|
||||
GtkShortcutTrigger *
|
||||
gtk_keyval_trigger_new (guint keyval,
|
||||
GdkModifierType modifiers)
|
||||
{
|
||||
GtkKeyvalTrigger *self;
|
||||
|
||||
self = (GtkKeyvalTrigger *) gtk_shortcut_trigger_new (>K_KEYVAL_TRIGGER_CLASS);
|
||||
|
||||
/* We store keyvals as lower key */
|
||||
if (keyval == GDK_KEY_ISO_Left_Tab)
|
||||
self->keyval = GDK_KEY_Tab;
|
||||
else
|
||||
self->keyval = gdk_keyval_to_lower (keyval);
|
||||
self->modifiers = modifiers;
|
||||
|
||||
return &self->trigger;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_keyval_trigger_get_modifiers:
|
||||
* @self: a keyval #GtkShortcutTrigger
|
||||
*
|
||||
* Gets the modifiers that must be present to succeed
|
||||
* triggering @self.
|
||||
*
|
||||
* Returns: the modifiers
|
||||
**/
|
||||
GdkModifierType
|
||||
gtk_keyval_trigger_get_modifiers (GtkShortcutTrigger *self)
|
||||
{
|
||||
GtkKeyvalTrigger *trigger = (GtkKeyvalTrigger *) self;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_SHORTCUT_TRIGGER_TYPE (self, GTK_SHORTCUT_TRIGGER_KEYVAL), 0);
|
||||
|
||||
return trigger->modifiers;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_keyval_trigger_get_keyval:
|
||||
* @self: a keyval #GtkShortcutTrigger
|
||||
*
|
||||
* Gets the keyval that must be pressed to succeed
|
||||
* triggering @self.
|
||||
*
|
||||
* Returns: the keyval
|
||||
**/
|
||||
guint
|
||||
gtk_keyval_trigger_get_keyval (GtkShortcutTrigger *self)
|
||||
{
|
||||
GtkKeyvalTrigger *trigger = (GtkKeyvalTrigger *) self;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_SHORTCUT_TRIGGER_TYPE (self, GTK_SHORTCUT_TRIGGER_KEYVAL), 0);
|
||||
|
||||
return trigger->keyval;
|
||||
}
|
||||
|
||||
/*** GTK_MNEMONIC_TRIGGER ***/
|
||||
|
||||
typedef struct _GtkMnemonicTrigger GtkMnemonicTrigger;
|
||||
|
||||
struct _GtkMnemonicTrigger
|
||||
{
|
||||
GtkShortcutTrigger trigger;
|
||||
|
||||
guint keyval;
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_mnemonic_trigger_finalize (GtkShortcutTrigger *trigger)
|
||||
{
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_mnemonic_trigger_trigger (GtkShortcutTrigger *trigger,
|
||||
GdkEvent *event,
|
||||
gboolean enable_mnemonics)
|
||||
{
|
||||
GtkMnemonicTrigger *self = (GtkMnemonicTrigger *) trigger;
|
||||
guint keyval;
|
||||
|
||||
if (!enable_mnemonics)
|
||||
return FALSE;
|
||||
|
||||
if (gdk_event_get_event_type (event) != GDK_KEY_PRESS)
|
||||
return FALSE;
|
||||
|
||||
/* XXX: This needs to deal with groups */
|
||||
keyval = gdk_key_event_get_keyval (event);
|
||||
|
||||
if (keyval == GDK_KEY_ISO_Left_Tab)
|
||||
keyval = GDK_KEY_Tab;
|
||||
else
|
||||
keyval = gdk_keyval_to_lower (keyval);
|
||||
|
||||
return keyval == self->keyval;
|
||||
}
|
||||
|
||||
static guint
|
||||
gtk_mnemonic_trigger_hash (GtkShortcutTrigger *trigger)
|
||||
{
|
||||
GtkMnemonicTrigger *self = (GtkMnemonicTrigger *) trigger;
|
||||
|
||||
return (self->keyval << 8)
|
||||
| GTK_SHORTCUT_TRIGGER_MNEMONIC;
|
||||
}
|
||||
|
||||
static int
|
||||
gtk_mnemonic_trigger_compare (GtkShortcutTrigger *trigger1,
|
||||
GtkShortcutTrigger *trigger2)
|
||||
{
|
||||
GtkMnemonicTrigger *self1 = (GtkMnemonicTrigger *) trigger1;
|
||||
GtkMnemonicTrigger *self2 = (GtkMnemonicTrigger *) trigger2;
|
||||
|
||||
return self1->keyval - self2->keyval;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_mnemonic_trigger_print (GtkShortcutTrigger *trigger,
|
||||
GString *string)
|
||||
{
|
||||
GtkMnemonicTrigger *self = (GtkMnemonicTrigger *) trigger;
|
||||
const char *keyval_str;
|
||||
|
||||
keyval_str = gdk_keyval_name (self->keyval);
|
||||
if (keyval_str == NULL)
|
||||
keyval_str = "???";
|
||||
|
||||
g_string_append (string, "<Mnemonic>");
|
||||
g_string_append (string, keyval_str);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_mnemonic_trigger_print_label (GtkShortcutTrigger *trigger,
|
||||
GdkDisplay *display,
|
||||
GString *string)
|
||||
{
|
||||
GtkMnemonicTrigger *self = (GtkMnemonicTrigger *) trigger;
|
||||
const char *keyval_str;
|
||||
|
||||
keyval_str = gdk_keyval_name (self->keyval);
|
||||
if (keyval_str == NULL)
|
||||
return FALSE;
|
||||
|
||||
g_string_append (string, keyval_str);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static const GtkShortcutTriggerClass GTK_MNEMONIC_TRIGGER_CLASS = {
|
||||
GTK_SHORTCUT_TRIGGER_MNEMONIC,
|
||||
sizeof (GtkMnemonicTrigger),
|
||||
"GtkMnemonicTrigger",
|
||||
gtk_mnemonic_trigger_finalize,
|
||||
gtk_mnemonic_trigger_trigger,
|
||||
gtk_mnemonic_trigger_hash,
|
||||
gtk_mnemonic_trigger_compare,
|
||||
gtk_mnemonic_trigger_print,
|
||||
gtk_mnemonic_trigger_print_label
|
||||
};
|
||||
|
||||
/**
|
||||
* gtk_mnemonic_trigger_new:
|
||||
* @keyval: The keyval to trigger for
|
||||
*
|
||||
* Creates a #GtkShortcutTrigger that will trigger whenever the key with
|
||||
* the given @keyval is pressed and mnemonics have been activated.
|
||||
*
|
||||
* Mnemonics are activated by calling code when a key event with the right
|
||||
* modifiers is detected.
|
||||
*
|
||||
* Returns: A new #GtkShortcutTrigger
|
||||
*/
|
||||
GtkShortcutTrigger *
|
||||
gtk_mnemonic_trigger_new (guint keyval)
|
||||
{
|
||||
GtkMnemonicTrigger *self;
|
||||
|
||||
self = (GtkMnemonicTrigger *) gtk_shortcut_trigger_new (>K_MNEMONIC_TRIGGER_CLASS);
|
||||
|
||||
/* We store keyvals as lower key */
|
||||
if (keyval == GDK_KEY_ISO_Left_Tab)
|
||||
self->keyval = GDK_KEY_Tab;
|
||||
else
|
||||
self->keyval = gdk_keyval_to_lower (keyval);
|
||||
|
||||
return &self->trigger;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_mnemonic_trigger_get_keyval:
|
||||
* @trigger: a mnemonic #GtkShortcutTrigger
|
||||
*
|
||||
* Gets the keyval that must be pressed to succeed triggering @self.
|
||||
*
|
||||
* Returns: the keyval
|
||||
**/
|
||||
guint
|
||||
gtk_mnemonic_trigger_get_keyval (GtkShortcutTrigger *trigger)
|
||||
{
|
||||
GtkMnemonicTrigger *self = (GtkMnemonicTrigger *) trigger;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_SHORTCUT_TRIGGER_TYPE (trigger, GTK_SHORTCUT_TRIGGER_MNEMONIC), 0);
|
||||
|
||||
return self->keyval;
|
||||
}
|
||||
|
||||
/*** GTK_ALTERNATIVE_TRIGGER ***/
|
||||
|
||||
typedef struct _GtkAlternativeTrigger GtkAlternativeTrigger;
|
||||
|
||||
struct _GtkAlternativeTrigger
|
||||
{
|
||||
GtkShortcutTrigger trigger;
|
||||
|
||||
GtkShortcutTrigger *first;
|
||||
GtkShortcutTrigger *second;
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_alternative_trigger_finalize (GtkShortcutTrigger *trigger)
|
||||
{
|
||||
GtkAlternativeTrigger *self = (GtkAlternativeTrigger *) trigger;
|
||||
|
||||
gtk_shortcut_trigger_unref (self->first);
|
||||
gtk_shortcut_trigger_unref (self->second);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_alternative_trigger_trigger (GtkShortcutTrigger *trigger,
|
||||
GdkEvent *event,
|
||||
gboolean enable_mnemonics)
|
||||
{
|
||||
GtkAlternativeTrigger *self = (GtkAlternativeTrigger *) trigger;
|
||||
|
||||
if (gtk_shortcut_trigger_trigger (self->first, event, enable_mnemonics))
|
||||
return TRUE;
|
||||
|
||||
if (gtk_shortcut_trigger_trigger (self->second, event, enable_mnemonics))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static guint
|
||||
gtk_alternative_trigger_hash (GtkShortcutTrigger *trigger)
|
||||
{
|
||||
GtkAlternativeTrigger *self = (GtkAlternativeTrigger *) trigger;
|
||||
guint result;
|
||||
|
||||
result = gtk_shortcut_trigger_hash (self->first);
|
||||
result <<= 5;
|
||||
|
||||
result |= gtk_shortcut_trigger_hash (self->second);
|
||||
result <<= 5;
|
||||
|
||||
return result | GTK_SHORTCUT_TRIGGER_ALTERNATIVE;
|
||||
}
|
||||
|
||||
static int
|
||||
gtk_alternative_trigger_compare (GtkShortcutTrigger *trigger1,
|
||||
GtkShortcutTrigger *trigger2)
|
||||
{
|
||||
GtkAlternativeTrigger *self1 = (GtkAlternativeTrigger *) trigger1;
|
||||
GtkAlternativeTrigger *self2 = (GtkAlternativeTrigger *) trigger2;
|
||||
int cmp;
|
||||
|
||||
cmp = gtk_shortcut_trigger_compare (self1->first, self2->first);
|
||||
if (cmp != 0)
|
||||
return cmp;
|
||||
|
||||
return gtk_shortcut_trigger_compare (self1->second, self2->second);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_alternative_trigger_print (GtkShortcutTrigger *trigger,
|
||||
GString *string)
|
||||
{
|
||||
GtkAlternativeTrigger *self = (GtkAlternativeTrigger *) trigger;
|
||||
|
||||
gtk_shortcut_trigger_print (self->first, string);
|
||||
g_string_append (string, ", ");
|
||||
gtk_shortcut_trigger_print (self->second, string);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_alternative_trigger_print_label (GtkShortcutTrigger *trigger,
|
||||
GdkDisplay *display,
|
||||
GString *string)
|
||||
{
|
||||
GtkAlternativeTrigger *self = (GtkAlternativeTrigger *) trigger;
|
||||
|
||||
if (gtk_shortcut_trigger_print_label (self->first, display, string))
|
||||
{
|
||||
g_string_append (string, ", ");
|
||||
if (!gtk_shortcut_trigger_print_label (self->second, display, string))
|
||||
g_string_truncate (string, string->len - 2);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return gtk_shortcut_trigger_print_label (self->second, display, string);
|
||||
}
|
||||
}
|
||||
|
||||
static const GtkShortcutTriggerClass GTK_ALTERNATIVE_TRIGGER_CLASS = {
|
||||
GTK_SHORTCUT_TRIGGER_ALTERNATIVE,
|
||||
sizeof (GtkAlternativeTrigger),
|
||||
"GtkAlternativeTrigger",
|
||||
gtk_alternative_trigger_finalize,
|
||||
gtk_alternative_trigger_trigger,
|
||||
gtk_alternative_trigger_hash,
|
||||
gtk_alternative_trigger_compare,
|
||||
gtk_alternative_trigger_print,
|
||||
gtk_alternative_trigger_print_label
|
||||
};
|
||||
|
||||
/**
|
||||
* gtk_alternative_trigger_new:
|
||||
* @first: (transfer full): The first trigger that may trigger
|
||||
* @second: (transfer full): The second trigger that may trigger
|
||||
*
|
||||
* Creates a #GtkShortcutTrigger that will trigger whenever
|
||||
* either of the two given triggers gets triggered.
|
||||
*
|
||||
* Note that nesting is allowed, so if you want more than two
|
||||
* alternative, create a new alternative trigger for each option.
|
||||
*
|
||||
* Returns: a new #GtkShortcutTrigger
|
||||
*/
|
||||
GtkShortcutTrigger *
|
||||
gtk_alternative_trigger_new (GtkShortcutTrigger *first,
|
||||
GtkShortcutTrigger *second)
|
||||
{
|
||||
GtkAlternativeTrigger *self;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_SHORTCUT_TRIGGER (first), NULL);
|
||||
g_return_val_if_fail (GTK_IS_SHORTCUT_TRIGGER (second), NULL);
|
||||
|
||||
self = (GtkAlternativeTrigger *) gtk_shortcut_trigger_new (>K_ALTERNATIVE_TRIGGER_CLASS);
|
||||
|
||||
self->first = first;
|
||||
self->second = second;
|
||||
|
||||
return &self->trigger;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_alternative_trigger_get_first:
|
||||
* @self: an alternative #GtkShortcutTrigger
|
||||
*
|
||||
* Gets the first of the two alternative triggers that may
|
||||
* trigger @self. gtk_alternative_trigger_get_second() will
|
||||
* return the other one.
|
||||
*
|
||||
* Returns: (transfer none): the first alternative trigger
|
||||
**/
|
||||
GtkShortcutTrigger *
|
||||
gtk_alternative_trigger_get_first (GtkShortcutTrigger *self)
|
||||
{
|
||||
GtkAlternativeTrigger *trigger = (GtkAlternativeTrigger *) self;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_SHORTCUT_TRIGGER_TYPE (self, GTK_SHORTCUT_TRIGGER_ALTERNATIVE), 0);
|
||||
|
||||
return trigger->first;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_alternative_trigger_get_second:
|
||||
* @self: an alternative #GtkShortcutTrigger
|
||||
*
|
||||
* Gets the second of the two alternative triggers that may
|
||||
* trigger @self. gtk_alternative_trigger_get_first() will
|
||||
* return the other one.
|
||||
*
|
||||
* Returns: (transfer none): the second alternative trigger
|
||||
**/
|
||||
GtkShortcutTrigger *
|
||||
gtk_alternative_trigger_get_second (GtkShortcutTrigger *self)
|
||||
{
|
||||
GtkAlternativeTrigger *trigger = (GtkAlternativeTrigger *) self;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_SHORTCUT_TRIGGER_TYPE (self, GTK_SHORTCUT_TRIGGER_ALTERNATIVE), 0);
|
||||
|
||||
return trigger->second;
|
||||
}
|
121
gtk/gtkshortcuttrigger.h
Normal file
121
gtk/gtkshortcuttrigger.h
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright © 2018 Benjamin Otte
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_SHORTCUT_TRIGGER_H__
|
||||
#define __GTK_SHORTCUT_TRIGGER_H__
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gtk/gtktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_SHORTCUT_TRIGGER (gtk_shortcut_trigger_get_type ())
|
||||
|
||||
#define GTK_IS_SHORTCUT_TRIGGER(obj) ((obj) != NULL)
|
||||
|
||||
/**
|
||||
* GtkShortcutTriggerType:
|
||||
* @GTK_SHORTCUT_TRIGGER_NEVER: Never ever trigger
|
||||
* @GTK_SHORTCUT_TRIGGER_KEYVAL: Trigger if a key event with matching
|
||||
* modifiers and keyval is received.
|
||||
* @GTK_SHORTCUT_TRIGGER_MNEMONIC: Trigger if a key event with matching
|
||||
* keyval is received and mnemonics are enabled for this event.
|
||||
* @GTK_SHORTCUT_TRIGGER_ALTERNAITVE: Trigger if either if two
|
||||
* alternatives triggers
|
||||
*
|
||||
* The type of a trigger determines what the trigger triggers on.
|
||||
**/
|
||||
typedef enum {
|
||||
GTK_SHORTCUT_TRIGGER_NEVER,
|
||||
GTK_SHORTCUT_TRIGGER_KEYVAL,
|
||||
GTK_SHORTCUT_TRIGGER_MNEMONIC,
|
||||
GTK_SHORTCUT_TRIGGER_ALTERNATIVE
|
||||
} GtkShortcutTriggerType;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_shortcut_trigger_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutTrigger * gtk_shortcut_trigger_ref (GtkShortcutTrigger *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_shortcut_trigger_unref (GtkShortcutTrigger *self);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutTriggerType gtk_shortcut_trigger_get_trigger_type (GtkShortcutTrigger *self);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutTrigger * gtk_shortcut_trigger_parse_string (const char *string);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
char * gtk_shortcut_trigger_to_string (GtkShortcutTrigger *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_shortcut_trigger_print (GtkShortcutTrigger *self,
|
||||
GString *string);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
char * gtk_shortcut_trigger_to_label (GtkShortcutTrigger *self,
|
||||
GdkDisplay *display);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_shortcut_trigger_print_label (GtkShortcutTrigger *self,
|
||||
GdkDisplay *display,
|
||||
GString *string);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
guint gtk_shortcut_trigger_hash (gconstpointer trigger);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_shortcut_trigger_equal (gconstpointer trigger1,
|
||||
gconstpointer trigger2);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gint gtk_shortcut_trigger_compare (gconstpointer trigger1,
|
||||
gconstpointer trigger2);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_shortcut_trigger_trigger (GtkShortcutTrigger *self,
|
||||
GdkEvent *event,
|
||||
gboolean enable_mnemonics);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutTrigger * gtk_never_trigger_get (void);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutTrigger * gtk_keyval_trigger_new (guint keyval,
|
||||
GdkModifierType modifiers);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkModifierType gtk_keyval_trigger_get_modifiers (GtkShortcutTrigger *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
guint gtk_keyval_trigger_get_keyval (GtkShortcutTrigger *self);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutTrigger * gtk_mnemonic_trigger_new (guint keyval);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
guint gtk_mnemonic_trigger_get_keyval (GtkShortcutTrigger *self);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutTrigger * gtk_alternative_trigger_new (GtkShortcutTrigger *one,
|
||||
GtkShortcutTrigger *two);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutTrigger * gtk_alternative_trigger_get_first (GtkShortcutTrigger *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkShortcutTrigger * gtk_alternative_trigger_get_second (GtkShortcutTrigger *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_SHORTCUT_TRIGGER_H__ */
|
@ -30,7 +30,6 @@
|
||||
#include "gtkspinbutton.h"
|
||||
|
||||
#include "gtkadjustment.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkbox.h"
|
||||
#include "gtkbutton.h"
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
@ -317,10 +316,10 @@ G_DEFINE_TYPE_WITH_CODE (GtkSpinButton, gtk_spin_button, GTK_TYPE_WIDGET,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_EDITABLE,
|
||||
gtk_spin_button_cell_editable_init))
|
||||
|
||||
#define add_spin_binding(binding_set, keyval, mask, scroll) \
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, mask, \
|
||||
"change-value", 1, \
|
||||
GTK_TYPE_SCROLL_TYPE, scroll)
|
||||
#define add_spin_binding(widget_class, keyval, mask, scroll) \
|
||||
gtk_widget_class_add_binding_signal (widget_class, keyval, mask, \
|
||||
"change-value", \
|
||||
"(i)", scroll)
|
||||
|
||||
|
||||
static gboolean
|
||||
@ -347,7 +346,6 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
gobject_class->finalize = gtk_spin_button_finalize;
|
||||
gobject_class->set_property = gtk_spin_button_set_property;
|
||||
@ -545,18 +543,16 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
|
||||
G_TYPE_NONE, 1,
|
||||
GTK_TYPE_SCROLL_TYPE);
|
||||
|
||||
binding_set = gtk_binding_set_by_class (class);
|
||||
|
||||
add_spin_binding (binding_set, GDK_KEY_Up, 0, GTK_SCROLL_STEP_UP);
|
||||
add_spin_binding (binding_set, GDK_KEY_KP_Up, 0, GTK_SCROLL_STEP_UP);
|
||||
add_spin_binding (binding_set, GDK_KEY_Down, 0, GTK_SCROLL_STEP_DOWN);
|
||||
add_spin_binding (binding_set, GDK_KEY_KP_Down, 0, GTK_SCROLL_STEP_DOWN);
|
||||
add_spin_binding (binding_set, GDK_KEY_Page_Up, 0, GTK_SCROLL_PAGE_UP);
|
||||
add_spin_binding (binding_set, GDK_KEY_Page_Down, 0, GTK_SCROLL_PAGE_DOWN);
|
||||
add_spin_binding (binding_set, GDK_KEY_End, GDK_CONTROL_MASK, GTK_SCROLL_END);
|
||||
add_spin_binding (binding_set, GDK_KEY_Home, GDK_CONTROL_MASK, GTK_SCROLL_START);
|
||||
add_spin_binding (binding_set, GDK_KEY_Page_Up, GDK_CONTROL_MASK, GTK_SCROLL_END);
|
||||
add_spin_binding (binding_set, GDK_KEY_Page_Down, GDK_CONTROL_MASK, GTK_SCROLL_START);
|
||||
add_spin_binding (widget_class, GDK_KEY_Up, 0, GTK_SCROLL_STEP_UP);
|
||||
add_spin_binding (widget_class, GDK_KEY_KP_Up, 0, GTK_SCROLL_STEP_UP);
|
||||
add_spin_binding (widget_class, GDK_KEY_Down, 0, GTK_SCROLL_STEP_DOWN);
|
||||
add_spin_binding (widget_class, GDK_KEY_KP_Down, 0, GTK_SCROLL_STEP_DOWN);
|
||||
add_spin_binding (widget_class, GDK_KEY_Page_Up, 0, GTK_SCROLL_PAGE_UP);
|
||||
add_spin_binding (widget_class, GDK_KEY_Page_Down, 0, GTK_SCROLL_PAGE_DOWN);
|
||||
add_spin_binding (widget_class, GDK_KEY_End, GDK_CONTROL_MASK, GTK_SCROLL_END);
|
||||
add_spin_binding (widget_class, GDK_KEY_Home, GDK_CONTROL_MASK, GTK_SCROLL_START);
|
||||
add_spin_binding (widget_class, GDK_KEY_Page_Up, GDK_CONTROL_MASK, GTK_SCROLL_END);
|
||||
add_spin_binding (widget_class, GDK_KEY_Page_Down, GDK_CONTROL_MASK, GTK_SCROLL_START);
|
||||
|
||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_SPIN_BUTTON_ACCESSIBLE);
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT);
|
||||
|
297
gtk/gtktext.c
297
gtk/gtktext.c
@ -25,7 +25,6 @@
|
||||
|
||||
#include "gtkactionable.h"
|
||||
#include "gtkadjustment.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkbox.h"
|
||||
#include "gtkbutton.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
@ -382,7 +381,9 @@ static void gtk_text_set_alignment (GtkText *self,
|
||||
/* Default signal handlers
|
||||
*/
|
||||
static GMenuModel *gtk_text_get_menu_model (GtkText *self);
|
||||
static gboolean gtk_text_popup_menu (GtkWidget *widget);
|
||||
static void gtk_text_popup_menu (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
GVariant *parameters);
|
||||
static void gtk_text_move_cursor (GtkText *self,
|
||||
GtkMovementStep step,
|
||||
int count,
|
||||
@ -679,7 +680,7 @@ G_DEFINE_TYPE_WITH_CODE (GtkText, gtk_text, GTK_TYPE_WIDGET,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE, gtk_text_editable_init))
|
||||
|
||||
static void
|
||||
add_move_binding (GtkBindingSet *binding_set,
|
||||
add_move_binding (GtkWidgetClass *widget_class,
|
||||
guint keyval,
|
||||
guint modmask,
|
||||
GtkMovementStep step,
|
||||
@ -687,28 +688,22 @@ add_move_binding (GtkBindingSet *binding_set,
|
||||
{
|
||||
g_return_if_fail ((modmask & GDK_SHIFT_MASK) == 0);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, modmask,
|
||||
"move-cursor", 3,
|
||||
G_TYPE_ENUM, step,
|
||||
G_TYPE_INT, count,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modmask,
|
||||
"move-cursor",
|
||||
"(iib)", step, count, FALSE);
|
||||
/* Selection-extending version */
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, modmask | GDK_SHIFT_MASK,
|
||||
"move-cursor", 3,
|
||||
G_TYPE_ENUM, step,
|
||||
G_TYPE_INT, count,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modmask | GDK_SHIFT_MASK,
|
||||
"move-cursor",
|
||||
"(iib)", step, count, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_text_class_init (GtkTextClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
widget_class = (GtkWidgetClass*) class;
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
|
||||
gobject_class->dispose = gtk_text_dispose;
|
||||
gobject_class->finalize = gtk_text_finalize;
|
||||
@ -728,7 +723,6 @@ gtk_text_class_init (GtkTextClass *class)
|
||||
widget_class->state_flags_changed = gtk_text_state_flags_changed;
|
||||
widget_class->root = gtk_text_root;
|
||||
widget_class->mnemonic_activate = gtk_text_mnemonic_activate;
|
||||
widget_class->popup_menu = gtk_text_popup_menu;
|
||||
|
||||
class->move_cursor = gtk_text_move_cursor;
|
||||
class->insert_at_cursor = gtk_text_insert_at_cursor;
|
||||
@ -1196,187 +1190,217 @@ gtk_text_class_init (GtkTextClass *class)
|
||||
|
||||
gtk_widget_class_install_action (widget_class, "text.undo", NULL, gtk_text_real_undo);
|
||||
gtk_widget_class_install_action (widget_class, "text.redo", NULL, gtk_text_real_redo);
|
||||
gtk_widget_class_install_action (widget_class, "menu.popup", NULL, gtk_text_popup_menu);
|
||||
|
||||
/*
|
||||
* Key bindings
|
||||
*/
|
||||
|
||||
binding_set = gtk_binding_set_by_class (class);
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
GDK_KEY_F10, GDK_SHIFT_MASK,
|
||||
"menu.popup",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
GDK_KEY_Menu, 0,
|
||||
"menu.popup",
|
||||
NULL);
|
||||
|
||||
/* Moving the insertion point */
|
||||
add_move_binding (binding_set, GDK_KEY_Right, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_Right, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Left, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_Left, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Right, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Right, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Left, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Left, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Right, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_Right, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_WORDS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Left, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_Left, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_WORDS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Right, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Right, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_WORDS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Left, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Left, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_WORDS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Home, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_Home, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_End, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_End, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Home, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Home, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_End, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_End, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Home, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_Home, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_End, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_End, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Home, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Home, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_End, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_End, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, 1);
|
||||
|
||||
/* Select all
|
||||
*/
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK,
|
||||
"move-cursor", 3,
|
||||
GTK_TYPE_MOVEMENT_STEP, GTK_MOVEMENT_BUFFER_ENDS,
|
||||
G_TYPE_INT, -1,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK,
|
||||
"move-cursor", 3,
|
||||
GTK_TYPE_MOVEMENT_STEP, GTK_MOVEMENT_BUFFER_ENDS,
|
||||
G_TYPE_INT, 1,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_widget_class_add_binding (widget_class,
|
||||
GDK_KEY_a, GDK_CONTROL_MASK,
|
||||
(GtkShortcutFunc) gtk_text_select_all,
|
||||
NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_slash, GDK_CONTROL_MASK,
|
||||
"move-cursor", 3,
|
||||
GTK_TYPE_MOVEMENT_STEP, GTK_MOVEMENT_BUFFER_ENDS,
|
||||
G_TYPE_INT, -1,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_slash, GDK_CONTROL_MASK,
|
||||
"move-cursor", 3,
|
||||
GTK_TYPE_MOVEMENT_STEP, GTK_MOVEMENT_BUFFER_ENDS,
|
||||
G_TYPE_INT, 1,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_widget_class_add_binding (widget_class,
|
||||
GDK_KEY_slash, GDK_CONTROL_MASK,
|
||||
(GtkShortcutFunc) gtk_text_select_all,
|
||||
NULL);
|
||||
/* Unselect all
|
||||
*/
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_backslash, GDK_CONTROL_MASK,
|
||||
"move-cursor", 3,
|
||||
GTK_TYPE_MOVEMENT_STEP, GTK_MOVEMENT_VISUAL_POSITIONS,
|
||||
G_TYPE_INT, 0,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
||||
"move-cursor", 3,
|
||||
GTK_TYPE_MOVEMENT_STEP, GTK_MOVEMENT_VISUAL_POSITIONS,
|
||||
G_TYPE_INT, 0,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_backslash, GDK_CONTROL_MASK,
|
||||
"move-cursor",
|
||||
"(iib)", GTK_MOVEMENT_VISUAL_POSITIONS, 0, FALSE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_a, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
||||
"move-cursor",
|
||||
"(iib)", GTK_MOVEMENT_VISUAL_POSITIONS, 0, FALSE);
|
||||
|
||||
/* Activate
|
||||
*/
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Return, 0,
|
||||
"activate", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_ISO_Enter, 0,
|
||||
"activate", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Enter, 0,
|
||||
"activate", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_Return, 0,
|
||||
"activate",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_ISO_Enter, 0,
|
||||
"activate",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Enter, 0,
|
||||
"activate",
|
||||
NULL);
|
||||
|
||||
/* Deleting text */
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, 0,
|
||||
"delete-from-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_DELETE_CHARS,
|
||||
G_TYPE_INT, 1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Delete, 0,
|
||||
"delete-from-cursor",
|
||||
"(ii)", GTK_DELETE_CHARS, 1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, 0,
|
||||
"delete-from-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_DELETE_CHARS,
|
||||
G_TYPE_INT, 1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Delete, 0,
|
||||
"delete-from-cursor",
|
||||
"(ii)", GTK_DELETE_CHARS, 1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, 0,
|
||||
"backspace", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_BackSpace, 0,
|
||||
"backspace",
|
||||
NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_u, GDK_CONTROL_MASK,
|
||||
"delete-from-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_DELETE_PARAGRAPH_ENDS,
|
||||
G_TYPE_INT, -1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_u, GDK_CONTROL_MASK,
|
||||
"delete-from-cursor",
|
||||
"(ii)", GTK_DELETE_PARAGRAPH_ENDS, -1);
|
||||
|
||||
/* Make this do the same as Backspace, to help with mis-typing */
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, GDK_SHIFT_MASK,
|
||||
"backspace", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_BackSpace, GDK_SHIFT_MASK,
|
||||
"backspace",
|
||||
NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, GDK_CONTROL_MASK,
|
||||
"delete-from-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_DELETE_WORD_ENDS,
|
||||
G_TYPE_INT, 1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Delete, GDK_CONTROL_MASK,
|
||||
"delete-from-cursor",
|
||||
"(ii)", GTK_DELETE_WORD_ENDS, 1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, GDK_CONTROL_MASK,
|
||||
"delete-from-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_DELETE_WORD_ENDS,
|
||||
G_TYPE_INT, 1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Delete, GDK_CONTROL_MASK,
|
||||
"delete-from-cursor",
|
||||
"(ii)", GTK_DELETE_WORD_ENDS, 1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, GDK_CONTROL_MASK,
|
||||
"delete-from-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_DELETE_WORD_ENDS,
|
||||
G_TYPE_INT, -1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_BackSpace, GDK_CONTROL_MASK,
|
||||
"delete-from-cursor",
|
||||
"(ii)", GTK_DELETE_WORD_ENDS, -1);
|
||||
|
||||
/* Cut/copy/paste */
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_x, GDK_CONTROL_MASK,
|
||||
"cut-clipboard",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_c, GDK_CONTROL_MASK,
|
||||
"copy-clipboard",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_v, GDK_CONTROL_MASK,
|
||||
"paste-clipboard",
|
||||
NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_x, GDK_CONTROL_MASK,
|
||||
"cut-clipboard", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_c, GDK_CONTROL_MASK,
|
||||
"copy-clipboard", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_v, GDK_CONTROL_MASK,
|
||||
"paste-clipboard", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Delete, GDK_SHIFT_MASK,
|
||||
"cut-clipboard",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Insert, GDK_CONTROL_MASK,
|
||||
"copy-clipboard",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Insert, GDK_SHIFT_MASK,
|
||||
"paste-clipboard",
|
||||
NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, GDK_SHIFT_MASK,
|
||||
"cut-clipboard", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Insert, GDK_CONTROL_MASK,
|
||||
"copy-clipboard", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Insert, GDK_SHIFT_MASK,
|
||||
"paste-clipboard", 0);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, GDK_SHIFT_MASK,
|
||||
"cut-clipboard", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Insert, GDK_CONTROL_MASK,
|
||||
"copy-clipboard", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Insert, GDK_SHIFT_MASK,
|
||||
"paste-clipboard", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Delete, GDK_SHIFT_MASK,
|
||||
"cut-clipboard",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Insert, GDK_CONTROL_MASK,
|
||||
"copy-clipboard",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Insert, GDK_SHIFT_MASK,
|
||||
"paste-clipboard",
|
||||
NULL);
|
||||
|
||||
/* Overwrite */
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Insert, 0,
|
||||
"toggle-overwrite", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Insert, 0,
|
||||
"toggle-overwrite", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Insert, 0,
|
||||
"toggle-overwrite",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Insert, 0,
|
||||
"toggle-overwrite",
|
||||
NULL);
|
||||
|
||||
/* Emoji */
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_period, GDK_CONTROL_MASK,
|
||||
"insert-emoji", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_semicolon, GDK_CONTROL_MASK,
|
||||
"insert-emoji", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_period, GDK_CONTROL_MASK,
|
||||
"insert-emoji",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_semicolon, GDK_CONTROL_MASK,
|
||||
"insert-emoji",
|
||||
NULL);
|
||||
|
||||
/* Undo/Redo */
|
||||
gtk_binding_entry_add_action (binding_set, GDK_KEY_z, GDK_CONTROL_MASK,
|
||||
"text.undo", NULL);
|
||||
gtk_binding_entry_add_action (binding_set, GDK_KEY_y, GDK_CONTROL_MASK,
|
||||
"text.redo", NULL);
|
||||
gtk_binding_entry_add_action (binding_set, GDK_KEY_z, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"text.redo", NULL);
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
GDK_KEY_z, GDK_CONTROL_MASK,
|
||||
"text.undo", NULL);
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
GDK_KEY_y, GDK_CONTROL_MASK,
|
||||
"text.redo", NULL);
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
GDK_KEY_z, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"text.redo", NULL);
|
||||
|
||||
|
||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_TEXT_ACCESSIBLE);
|
||||
gtk_widget_class_set_css_name (widget_class, I_("text"));
|
||||
@ -5912,11 +5936,12 @@ gtk_text_mnemonic_activate (GtkWidget *widget,
|
||||
return GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_text_popup_menu (GtkWidget *widget)
|
||||
static void
|
||||
gtk_text_popup_menu (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
GVariant *parameters)
|
||||
{
|
||||
gtk_text_do_popup (GTK_TEXT (widget), -1, -1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "gtkadjustmentprivate.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkcsscolorvalueprivate.h"
|
||||
#include "gtkdebug.h"
|
||||
#include "gtkdropcontrollermotion.h"
|
||||
@ -435,7 +434,9 @@ static gboolean gtk_text_view_drag_drop (GtkDropTarget *dest,
|
||||
double y,
|
||||
GtkTextView *text_view);
|
||||
|
||||
static gboolean gtk_text_view_popup_menu (GtkWidget *widget);
|
||||
static void gtk_text_view_popup_menu (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
GVariant *parameters);
|
||||
static void gtk_text_view_move_cursor (GtkTextView *text_view,
|
||||
GtkMovementStep step,
|
||||
gint count,
|
||||
@ -774,7 +775,7 @@ gtk_text_view_drop_scroll_leave (GtkDropControllerMotion *motion,
|
||||
}
|
||||
|
||||
static void
|
||||
add_move_binding (GtkBindingSet *binding_set,
|
||||
add_move_binding (GtkWidgetClass *widget_class,
|
||||
guint keyval,
|
||||
guint modmask,
|
||||
GtkMovementStep step,
|
||||
@ -782,18 +783,16 @@ add_move_binding (GtkBindingSet *binding_set,
|
||||
{
|
||||
g_assert ((modmask & GDK_SHIFT_MASK) == 0);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, modmask,
|
||||
"move-cursor", 3,
|
||||
G_TYPE_ENUM, step,
|
||||
G_TYPE_INT, count,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modmask,
|
||||
"move-cursor",
|
||||
"(iib)", step, count, FALSE);
|
||||
|
||||
/* Selection-extending version */
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, modmask | GDK_SHIFT_MASK,
|
||||
"move-cursor", 3,
|
||||
G_TYPE_ENUM, step,
|
||||
G_TYPE_INT, count,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modmask | GDK_SHIFT_MASK,
|
||||
"move-cursor",
|
||||
"(iib)", step, count, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -802,7 +801,6 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
/* Default handlers and virtual methods
|
||||
*/
|
||||
@ -822,8 +820,6 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
|
||||
widget_class->snapshot = gtk_text_view_snapshot;
|
||||
widget_class->focus = gtk_text_view_focus;
|
||||
|
||||
widget_class->popup_menu = gtk_text_view_popup_menu;
|
||||
|
||||
container_class->add = gtk_text_view_add;
|
||||
container_class->remove = gtk_text_view_remove;
|
||||
container_class->forall = gtk_text_view_forall;
|
||||
@ -1466,237 +1462,288 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
|
||||
|
||||
gtk_widget_class_install_action (widget_class, "text.undo", NULL, gtk_text_view_real_undo);
|
||||
gtk_widget_class_install_action (widget_class, "text.redo", NULL, gtk_text_view_real_redo);
|
||||
gtk_widget_class_install_action (widget_class, "menu.popup", NULL, gtk_text_view_popup_menu);
|
||||
|
||||
/*
|
||||
* Key bindings
|
||||
*/
|
||||
|
||||
binding_set = gtk_binding_set_by_class (klass);
|
||||
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
GDK_KEY_F10, GDK_SHIFT_MASK,
|
||||
"menu.popup",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
GDK_KEY_Menu, 0,
|
||||
"menu.popup",
|
||||
NULL);
|
||||
|
||||
/* Moving the insertion point */
|
||||
add_move_binding (binding_set, GDK_KEY_Right, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_Right, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Right, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Right, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Left, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_Left, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Left, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Left, 0,
|
||||
GTK_MOVEMENT_VISUAL_POSITIONS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Right, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_Right, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_WORDS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Right, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Right, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_WORDS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Left, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_Left, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_WORDS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Left, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Left, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_WORDS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Up, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_Up, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Up, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Up, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Down, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_Down, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Down, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Down, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Up, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_Up, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_PARAGRAPHS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Up, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Up, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_PARAGRAPHS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Down, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_Down, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_PARAGRAPHS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Down, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Down, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_PARAGRAPHS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Home, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_Home, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Home, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Home, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_End, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_End, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_End, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_End, 0,
|
||||
GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Home, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_Home, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Home, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Home, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_End, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_End, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_End, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_End, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Page_Up, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_Page_Up, 0,
|
||||
GTK_MOVEMENT_PAGES, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Page_Up, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Page_Up, 0,
|
||||
GTK_MOVEMENT_PAGES, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Page_Down, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_Page_Down, 0,
|
||||
GTK_MOVEMENT_PAGES, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Page_Down, 0,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Page_Down, 0,
|
||||
GTK_MOVEMENT_PAGES, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Page_Up, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_Page_Up, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_HORIZONTAL_PAGES, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Page_Up, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Page_Up, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_HORIZONTAL_PAGES, -1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_Page_Down, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_Page_Down, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_HORIZONTAL_PAGES, 1);
|
||||
|
||||
add_move_binding (binding_set, GDK_KEY_KP_Page_Down, GDK_CONTROL_MASK,
|
||||
add_move_binding (widget_class, GDK_KEY_KP_Page_Down, GDK_CONTROL_MASK,
|
||||
GTK_MOVEMENT_HORIZONTAL_PAGES, 1);
|
||||
|
||||
/* Select all */
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK,
|
||||
"select-all", 1,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_a, GDK_CONTROL_MASK,
|
||||
"select-all",
|
||||
"(b)", TRUE);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_slash, GDK_CONTROL_MASK,
|
||||
"select-all", 1,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_slash, GDK_CONTROL_MASK,
|
||||
"select-all",
|
||||
"(b)", TRUE);
|
||||
|
||||
/* Unselect all */
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_backslash, GDK_CONTROL_MASK,
|
||||
"select-all", 1,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_backslash, GDK_CONTROL_MASK,
|
||||
"select-all",
|
||||
"(b)", FALSE);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
||||
"select-all", 1,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_a, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
||||
"select-all",
|
||||
"(b)", FALSE);
|
||||
|
||||
/* Deleting text */
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, 0,
|
||||
"delete-from-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_DELETE_CHARS,
|
||||
G_TYPE_INT, 1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Delete, 0,
|
||||
"delete-from-cursor",
|
||||
"(ii)", GTK_DELETE_CHARS, 1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, 0,
|
||||
"delete-from-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_DELETE_CHARS,
|
||||
G_TYPE_INT, 1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Delete, 0,
|
||||
"delete-from-cursor",
|
||||
"(ii)", GTK_DELETE_CHARS, 1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, 0,
|
||||
"backspace", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_BackSpace, 0,
|
||||
"backspace",
|
||||
NULL);
|
||||
|
||||
/* Make this do the same as Backspace, to help with mis-typing */
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, GDK_SHIFT_MASK,
|
||||
"backspace", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_BackSpace, GDK_SHIFT_MASK,
|
||||
"backspace",
|
||||
NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, GDK_CONTROL_MASK,
|
||||
"delete-from-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_DELETE_WORD_ENDS,
|
||||
G_TYPE_INT, 1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Delete, GDK_CONTROL_MASK,
|
||||
"delete-from-cursor",
|
||||
"(ii)", GTK_DELETE_WORD_ENDS, 1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, GDK_CONTROL_MASK,
|
||||
"delete-from-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_DELETE_WORD_ENDS,
|
||||
G_TYPE_INT, 1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Delete, GDK_CONTROL_MASK,
|
||||
"delete-from-cursor",
|
||||
"(ii)", GTK_DELETE_WORD_ENDS, 1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, GDK_CONTROL_MASK,
|
||||
"delete-from-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_DELETE_WORD_ENDS,
|
||||
G_TYPE_INT, -1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_BackSpace, GDK_CONTROL_MASK,
|
||||
"delete-from-cursor",
|
||||
"(ii)", GTK_DELETE_WORD_ENDS, -1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
||||
"delete-from-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_DELETE_PARAGRAPH_ENDS,
|
||||
G_TYPE_INT, 1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Delete, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
||||
"delete-from-cursor",
|
||||
"(ii)", GTK_DELETE_PARAGRAPH_ENDS, 1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
||||
"delete-from-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_DELETE_PARAGRAPH_ENDS,
|
||||
G_TYPE_INT, 1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Delete, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
||||
"delete-from-cursor",
|
||||
"(ii)", GTK_DELETE_PARAGRAPH_ENDS, 1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
||||
"delete-from-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_DELETE_PARAGRAPH_ENDS,
|
||||
G_TYPE_INT, -1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_BackSpace, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
||||
"delete-from-cursor",
|
||||
"(ii)", GTK_DELETE_PARAGRAPH_ENDS, -1);
|
||||
|
||||
/* Cut/copy/paste */
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_x, GDK_CONTROL_MASK,
|
||||
"cut-clipboard", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_c, GDK_CONTROL_MASK,
|
||||
"copy-clipboard", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_v, GDK_CONTROL_MASK,
|
||||
"paste-clipboard", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_x, GDK_CONTROL_MASK,
|
||||
"cut-clipboard",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_c, GDK_CONTROL_MASK,
|
||||
"copy-clipboard",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_v, GDK_CONTROL_MASK,
|
||||
"paste-clipboard",
|
||||
NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, GDK_SHIFT_MASK,
|
||||
"cut-clipboard", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Insert, GDK_CONTROL_MASK,
|
||||
"copy-clipboard", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Insert, GDK_SHIFT_MASK,
|
||||
"paste-clipboard", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Delete, GDK_SHIFT_MASK,
|
||||
"cut-clipboard",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Insert, GDK_CONTROL_MASK,
|
||||
"copy-clipboard",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Insert, GDK_SHIFT_MASK,
|
||||
"paste-clipboard",
|
||||
NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, GDK_SHIFT_MASK,
|
||||
"cut-clipboard", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Insert, GDK_CONTROL_MASK,
|
||||
"copy-clipboard", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Insert, GDK_SHIFT_MASK,
|
||||
"paste-clipboard", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Delete, GDK_SHIFT_MASK,
|
||||
"cut-clipboard",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Insert, GDK_CONTROL_MASK,
|
||||
"copy-clipboard",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Insert, GDK_SHIFT_MASK,
|
||||
"paste-clipboard",
|
||||
NULL);
|
||||
|
||||
/* Undo/Redo */
|
||||
gtk_binding_entry_add_action (binding_set, GDK_KEY_z, GDK_CONTROL_MASK,
|
||||
"text.undo", NULL);
|
||||
gtk_binding_entry_add_action (binding_set, GDK_KEY_y, GDK_CONTROL_MASK,
|
||||
"text.redo", NULL);
|
||||
gtk_binding_entry_add_action (binding_set, GDK_KEY_z, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"text.redo", NULL);
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
GDK_KEY_z, GDK_CONTROL_MASK,
|
||||
"text.undo", NULL);
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
GDK_KEY_y, GDK_CONTROL_MASK,
|
||||
"text.redo", NULL);
|
||||
gtk_widget_class_add_binding_action (widget_class,
|
||||
GDK_KEY_z, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"text.redo", NULL);
|
||||
|
||||
/* Overwrite */
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Insert, 0,
|
||||
"toggle-overwrite", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Insert, 0,
|
||||
"toggle-overwrite", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Insert, 0,
|
||||
"toggle-overwrite",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Insert, 0,
|
||||
"toggle-overwrite",
|
||||
NULL);
|
||||
|
||||
/* Emoji */
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_period, GDK_CONTROL_MASK,
|
||||
"insert-emoji", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_semicolon, GDK_CONTROL_MASK,
|
||||
"insert-emoji", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_period, GDK_CONTROL_MASK,
|
||||
"insert-emoji",
|
||||
NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_semicolon, GDK_CONTROL_MASK,
|
||||
"insert-emoji",
|
||||
NULL);
|
||||
|
||||
/* Caret mode */
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_F7, 0,
|
||||
"toggle-cursor-visible", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_F7, 0,
|
||||
"toggle-cursor-visible",
|
||||
NULL);
|
||||
|
||||
/* Control-tab focus motion */
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Tab, GDK_CONTROL_MASK,
|
||||
"move-focus", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, GTK_DIR_TAB_FORWARD);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Tab, GDK_CONTROL_MASK,
|
||||
"move-focus", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, GTK_DIR_TAB_FORWARD);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Tab, GDK_CONTROL_MASK,
|
||||
"move-focus",
|
||||
"(i)", GTK_DIR_TAB_FORWARD);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Tab, GDK_CONTROL_MASK,
|
||||
"move-focus",
|
||||
"(i)", GTK_DIR_TAB_FORWARD);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Tab, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
||||
"move-focus", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, GTK_DIR_TAB_BACKWARD);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Tab, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
||||
"move-focus", 1,
|
||||
GTK_TYPE_DIRECTION_TYPE, GTK_DIR_TAB_BACKWARD);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Tab, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
||||
"move-focus",
|
||||
"(i)", GTK_DIR_TAB_BACKWARD);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Tab, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
||||
"move-focus",
|
||||
"(i)", GTK_DIR_TAB_BACKWARD);
|
||||
|
||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_TEXT_VIEW_ACCESSIBLE);
|
||||
gtk_widget_class_set_css_name (widget_class, I_("textview"));
|
||||
@ -4428,6 +4475,9 @@ gtk_text_view_size_allocate (GtkWidget *widget,
|
||||
|
||||
if (priv->popup_menu)
|
||||
gtk_native_check_resize (GTK_NATIVE (priv->popup_menu));
|
||||
|
||||
if (priv->selection_bubble)
|
||||
gtk_native_check_resize (GTK_NATIVE (priv->selection_bubble));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -8655,11 +8705,12 @@ gtk_text_view_do_popup (GtkTextView *text_view,
|
||||
gdk_event_unref (trigger_event);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_text_view_popup_menu (GtkWidget *widget)
|
||||
static void
|
||||
gtk_text_view_popup_menu (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
GVariant *parameters)
|
||||
{
|
||||
gtk_text_view_do_popup (GTK_TEXT_VIEW (widget), NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
#include "gtkadjustmentprivate.h"
|
||||
#include "gtkbox.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkbutton.h"
|
||||
#include "gtkcelllayout.h"
|
||||
@ -54,6 +53,7 @@
|
||||
#include "gtkrendericonprivate.h"
|
||||
#include "gtkscrollable.h"
|
||||
#include "gtksettingsprivate.h"
|
||||
#include "gtkshortcutcontroller.h"
|
||||
#include "gtksnapshot.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtktooltip.h"
|
||||
@ -657,6 +657,11 @@ static void gtk_tree_view_size_allocate (GtkWidget *widget,
|
||||
static void gtk_tree_view_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot);
|
||||
|
||||
static gboolean gtk_tree_view_forward_controller_key_pressed (GtkEventControllerKey *key,
|
||||
guint keyval,
|
||||
guint keycode,
|
||||
GdkModifierType state,
|
||||
GtkTreeView *tree_view);
|
||||
static gboolean gtk_tree_view_key_controller_key_pressed (GtkEventControllerKey *key,
|
||||
guint keyval,
|
||||
guint keycode,
|
||||
@ -765,7 +770,7 @@ static void invalidate_empty_focus (GtkTreeView *tree_view);
|
||||
static gboolean gtk_tree_view_is_expander_column (GtkTreeView *tree_view,
|
||||
GtkTreeViewColumn *column);
|
||||
static inline gboolean gtk_tree_view_draw_expanders (GtkTreeView *tree_view);
|
||||
static void gtk_tree_view_add_move_binding (GtkBindingSet *binding_set,
|
||||
static void gtk_tree_view_add_move_binding (GtkWidgetClass *widget_class,
|
||||
guint keyval,
|
||||
guint modmask,
|
||||
gboolean add_shifted_binding,
|
||||
@ -999,16 +1004,9 @@ G_DEFINE_TYPE_WITH_CODE (GtkTreeView, gtk_tree_view, GTK_TYPE_CONTAINER,
|
||||
static void
|
||||
gtk_tree_view_class_init (GtkTreeViewClass *class)
|
||||
{
|
||||
GObjectClass *o_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkContainerClass *container_class;
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
binding_set = gtk_binding_set_by_class (class);
|
||||
|
||||
o_class = (GObjectClass *) class;
|
||||
widget_class = (GtkWidgetClass *) class;
|
||||
container_class = (GtkContainerClass *) class;
|
||||
GObjectClass *o_class = G_OBJECT_CLASS (class);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
|
||||
|
||||
/* GObject signals */
|
||||
o_class->set_property = gtk_tree_view_set_property;
|
||||
@ -1503,217 +1501,198 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
|
||||
_gtk_marshal_BOOLEAN__VOIDv);
|
||||
|
||||
/* Key bindings */
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_KEY_Up, 0, TRUE,
|
||||
gtk_tree_view_add_move_binding (widget_class, GDK_KEY_Up, 0, TRUE,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, -1);
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_KEY_KP_Up, 0, TRUE,
|
||||
gtk_tree_view_add_move_binding (widget_class, GDK_KEY_KP_Up, 0, TRUE,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, -1);
|
||||
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_KEY_Down, 0, TRUE,
|
||||
gtk_tree_view_add_move_binding (widget_class, GDK_KEY_Down, 0, TRUE,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, 1);
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_KEY_KP_Down, 0, TRUE,
|
||||
gtk_tree_view_add_move_binding (widget_class, GDK_KEY_KP_Down, 0, TRUE,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, 1);
|
||||
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_KEY_p, GDK_CONTROL_MASK, FALSE,
|
||||
gtk_tree_view_add_move_binding (widget_class, GDK_KEY_p, GDK_CONTROL_MASK, FALSE,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, -1);
|
||||
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_KEY_n, GDK_CONTROL_MASK, FALSE,
|
||||
gtk_tree_view_add_move_binding (widget_class, GDK_KEY_n, GDK_CONTROL_MASK, FALSE,
|
||||
GTK_MOVEMENT_DISPLAY_LINES, 1);
|
||||
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_KEY_Home, 0, TRUE,
|
||||
gtk_tree_view_add_move_binding (widget_class, GDK_KEY_Home, 0, TRUE,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, -1);
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_KEY_KP_Home, 0, TRUE,
|
||||
gtk_tree_view_add_move_binding (widget_class, GDK_KEY_KP_Home, 0, TRUE,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, -1);
|
||||
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_KEY_End, 0, TRUE,
|
||||
gtk_tree_view_add_move_binding (widget_class, GDK_KEY_End, 0, TRUE,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, 1);
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_KEY_KP_End, 0, TRUE,
|
||||
gtk_tree_view_add_move_binding (widget_class, GDK_KEY_KP_End, 0, TRUE,
|
||||
GTK_MOVEMENT_BUFFER_ENDS, 1);
|
||||
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_KEY_Page_Up, 0, TRUE,
|
||||
gtk_tree_view_add_move_binding (widget_class, GDK_KEY_Page_Up, 0, TRUE,
|
||||
GTK_MOVEMENT_PAGES, -1);
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_KEY_KP_Page_Up, 0, TRUE,
|
||||
gtk_tree_view_add_move_binding (widget_class, GDK_KEY_KP_Page_Up, 0, TRUE,
|
||||
GTK_MOVEMENT_PAGES, -1);
|
||||
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_KEY_Page_Down, 0, TRUE,
|
||||
gtk_tree_view_add_move_binding (widget_class, GDK_KEY_Page_Down, 0, TRUE,
|
||||
GTK_MOVEMENT_PAGES, 1);
|
||||
gtk_tree_view_add_move_binding (binding_set, GDK_KEY_KP_Page_Down, 0, TRUE,
|
||||
gtk_tree_view_add_move_binding (widget_class, GDK_KEY_KP_Page_Down, 0, TRUE,
|
||||
GTK_MOVEMENT_PAGES, 1);
|
||||
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Right, 0, "move-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
|
||||
G_TYPE_INT, 1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Right, 0,
|
||||
"move-cursor",
|
||||
"(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, 1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Left, 0, "move-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
|
||||
G_TYPE_INT, -1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Left, 0,
|
||||
"move-cursor",
|
||||
"(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, -1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Right, 0, "move-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
|
||||
G_TYPE_INT, 1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Right, 0,
|
||||
"move-cursor",
|
||||
"(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, 1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Left, 0, "move-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
|
||||
G_TYPE_INT, -1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Left, 0,
|
||||
"move-cursor",
|
||||
"(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, -1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Right, GDK_CONTROL_MASK,
|
||||
"move-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
|
||||
G_TYPE_INT, 1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Right, GDK_CONTROL_MASK,
|
||||
"move-cursor",
|
||||
"(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, 1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Left, GDK_CONTROL_MASK,
|
||||
"move-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
|
||||
G_TYPE_INT, -1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Left, GDK_CONTROL_MASK,
|
||||
"move-cursor",
|
||||
"(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, -1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Right, GDK_CONTROL_MASK,
|
||||
"move-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
|
||||
G_TYPE_INT, 1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Right, GDK_CONTROL_MASK,
|
||||
"move-cursor",
|
||||
"(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, 1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Left, GDK_CONTROL_MASK,
|
||||
"move-cursor", 2,
|
||||
G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
|
||||
G_TYPE_INT, -1);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Left, GDK_CONTROL_MASK,
|
||||
"move-cursor",
|
||||
"(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, -1);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_space, GDK_CONTROL_MASK, "toggle-cursor-row", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Space, GDK_CONTROL_MASK, "toggle-cursor-row", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_space, GDK_CONTROL_MASK, "toggle-cursor-row", NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Space, GDK_CONTROL_MASK, "toggle-cursor-row", NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK, "select-all", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_slash, GDK_CONTROL_MASK, "select-all", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_a, GDK_CONTROL_MASK, "select-all", NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_slash, GDK_CONTROL_MASK, "select-all", NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_A, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "unselect-all", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_backslash, GDK_CONTROL_MASK, "unselect-all", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_A, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "unselect-all", NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_backslash, GDK_CONTROL_MASK, "unselect-all", NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_space, GDK_SHIFT_MASK, "select-cursor-row", 1,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Space, GDK_SHIFT_MASK, "select-cursor-row", 1,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_space, GDK_SHIFT_MASK, "select-cursor-row", "(b)", TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Space, GDK_SHIFT_MASK, "select-cursor-row", "(b)", TRUE);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_space, 0, "select-cursor-row", 1,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Space, 0, "select-cursor-row", 1,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Return, 0, "select-cursor-row", 1,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_ISO_Enter, 0, "select-cursor-row", 1,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Enter, 0, "select-cursor-row", 1,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_space, 0, "select-cursor-row", "(b)", TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Space, 0, "select-cursor-row", "(b)", TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_Return, 0, "select-cursor-row", "(b)", TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_ISO_Enter, 0, "select-cursor-row", "(b)", TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Enter, 0, "select-cursor-row", "(b)", TRUE);
|
||||
|
||||
/* expand and collapse rows */
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_plus, 0, "expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_plus, 0,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", TRUE, TRUE, FALSE);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_asterisk, 0,
|
||||
"expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Multiply, 0,
|
||||
"expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_asterisk, 0,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", TRUE, TRUE, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Multiply, 0,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", TRUE, TRUE, TRUE);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_slash, 0,
|
||||
"expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, FALSE,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Divide, 0,
|
||||
"expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, FALSE,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_slash, 0,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", TRUE, FALSE, FALSE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Divide, 0,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", TRUE, FALSE, FALSE);
|
||||
|
||||
/* Not doable on US keyboards */
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_plus, GDK_SHIFT_MASK, "expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Add, 0, "expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Add, GDK_SHIFT_MASK, "expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Add, GDK_SHIFT_MASK, "expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Right, GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, FALSE,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Right, GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, FALSE,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Right,
|
||||
GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, FALSE,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Right,
|
||||
GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, FALSE,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_plus, GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", TRUE, TRUE, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Add, 0,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", TRUE, TRUE, FALSE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Add, GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", TRUE, TRUE, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Add, GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", TRUE, TRUE, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Right, GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", FALSE, TRUE, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Right, GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", FALSE, TRUE, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Right, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", FALSE, TRUE, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Right, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", FALSE, TRUE, TRUE);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_minus, 0, "expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, FALSE,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_minus, GDK_SHIFT_MASK, "expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, FALSE,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Subtract, 0, "expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, FALSE,
|
||||
G_TYPE_BOOLEAN, FALSE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Subtract, GDK_SHIFT_MASK, "expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, TRUE,
|
||||
G_TYPE_BOOLEAN, FALSE,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Left, GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, FALSE,
|
||||
G_TYPE_BOOLEAN, FALSE,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Left, GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, FALSE,
|
||||
G_TYPE_BOOLEAN, FALSE,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Left,
|
||||
GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, FALSE,
|
||||
G_TYPE_BOOLEAN, FALSE,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Left,
|
||||
GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row", 3,
|
||||
G_TYPE_BOOLEAN, FALSE,
|
||||
G_TYPE_BOOLEAN, FALSE,
|
||||
G_TYPE_BOOLEAN, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_minus, 0,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", TRUE, FALSE, FALSE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_minus, GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", TRUE, FALSE, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Subtract, 0,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", TRUE, FALSE, FALSE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Subtract, GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", TRUE, FALSE, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Left, GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", FALSE, FALSE, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Left, GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", FALSE, FALSE, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_Left, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", FALSE, FALSE, TRUE);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
GDK_KEY_KP_Left, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"expand-collapse-cursor-row",
|
||||
"(bbb)", FALSE, FALSE, TRUE);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, 0, "select-cursor-parent", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, GDK_CONTROL_MASK, "select-cursor-parent", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_BackSpace, 0, "select-cursor-parent", NULL);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_BackSpace, GDK_CONTROL_MASK, "select-cursor-parent", NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_f, GDK_CONTROL_MASK, "start-interactive-search", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_f, GDK_CONTROL_MASK, "start-interactive-search", NULL);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_F, GDK_CONTROL_MASK, "start-interactive-search", 0);
|
||||
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_F, GDK_CONTROL_MASK, "start-interactive-search", NULL);
|
||||
|
||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_TREE_VIEW_ACCESSIBLE);
|
||||
gtk_widget_class_set_css_name (widget_class, I_("treeview"));
|
||||
@ -1725,6 +1704,7 @@ gtk_tree_view_init (GtkTreeView *tree_view)
|
||||
GtkCssNode *widget_node;
|
||||
GtkGesture *gesture;
|
||||
GtkEventController *controller;
|
||||
GList *list, *controllers;
|
||||
|
||||
gtk_widget_set_can_focus (GTK_WIDGET (tree_view), TRUE);
|
||||
gtk_widget_set_overflow (GTK_WIDGET (tree_view), GTK_OVERFLOW_HIDDEN);
|
||||
@ -1786,6 +1766,24 @@ gtk_tree_view_init (GtkTreeView *tree_view)
|
||||
gtk_css_node_set_state (tree_view->header_node, gtk_css_node_get_state (widget_node));
|
||||
g_object_unref (tree_view->header_node);
|
||||
|
||||
controller = gtk_event_controller_key_new ();
|
||||
g_signal_connect (controller, "key-pressed",
|
||||
G_CALLBACK (gtk_tree_view_forward_controller_key_pressed), tree_view);
|
||||
gtk_widget_add_controller (GTK_WIDGET (tree_view), controller);
|
||||
|
||||
controllers = gtk_widget_list_controllers (GTK_WIDGET (tree_view), GTK_PHASE_BUBBLE);
|
||||
for (list = controllers; list; list = list->next)
|
||||
{
|
||||
if (GTK_IS_SHORTCUT_CONTROLLER (list->data))
|
||||
{
|
||||
g_object_ref (list->data);
|
||||
gtk_widget_remove_controller (GTK_WIDGET (tree_view), list->data);
|
||||
gtk_widget_add_controller (GTK_WIDGET (tree_view), list->data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_list_free (controllers);
|
||||
|
||||
tree_view->click_gesture = gtk_gesture_click_new ();
|
||||
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (tree_view->click_gesture), 0);
|
||||
g_signal_connect (tree_view->click_gesture, "pressed",
|
||||
@ -5312,7 +5310,6 @@ gtk_tree_view_key_controller_key_pressed (GtkEventControllerKey *key,
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (tree_view);
|
||||
GtkWidget *button;
|
||||
GdkEvent *event;
|
||||
|
||||
if (tree_view->rubber_band_status)
|
||||
{
|
||||
@ -5432,16 +5429,16 @@ gtk_tree_view_key_controller_key_pressed (GtkEventControllerKey *key,
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle the keybindings. */
|
||||
event = gtk_get_current_event ();
|
||||
if (gtk_bindings_activate_event (G_OBJECT (widget), event))
|
||||
{
|
||||
gdk_event_unref (event);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gdk_event_unref (event);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_tree_view_forward_controller_key_pressed (GtkEventControllerKey *key,
|
||||
guint keyval,
|
||||
guint keycode,
|
||||
GdkModifierType state,
|
||||
GtkTreeView *tree_view)
|
||||
{
|
||||
if (tree_view->search_entry_avoid_unhandled_binding)
|
||||
{
|
||||
tree_view->search_entry_avoid_unhandled_binding = FALSE;
|
||||
@ -5487,15 +5484,6 @@ gtk_tree_view_key_controller_key_released (GtkEventControllerKey *key,
|
||||
GdkModifierType state,
|
||||
GtkTreeView *tree_view)
|
||||
{
|
||||
GdkEvent *event;
|
||||
|
||||
if (tree_view->rubber_band_status)
|
||||
return;
|
||||
|
||||
/* Handle the keybindings. */
|
||||
event = gtk_get_current_event ();
|
||||
gtk_bindings_activate_event (G_OBJECT (tree_view), event);
|
||||
gdk_event_unref (event);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -8914,7 +8902,7 @@ gtk_tree_view_draw_expanders (GtkTreeView *tree_view)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tree_view_add_move_binding (GtkBindingSet *binding_set,
|
||||
gtk_tree_view_add_move_binding (GtkWidgetClass *widget_class,
|
||||
guint keyval,
|
||||
guint modmask,
|
||||
gboolean add_shifted_binding,
|
||||
@ -8922,29 +8910,29 @@ gtk_tree_view_add_move_binding (GtkBindingSet *binding_set,
|
||||
gint count)
|
||||
{
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, modmask,
|
||||
"move-cursor", 2,
|
||||
G_TYPE_ENUM, step,
|
||||
G_TYPE_INT, count);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, modmask,
|
||||
"move-cursor",
|
||||
"(ii)", step, count);
|
||||
|
||||
if (add_shifted_binding)
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, GDK_SHIFT_MASK,
|
||||
"move-cursor", 2,
|
||||
G_TYPE_ENUM, step,
|
||||
G_TYPE_INT, count);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, GDK_SHIFT_MASK,
|
||||
"move-cursor",
|
||||
"(ii)", step, count);
|
||||
|
||||
if ((modmask & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
|
||||
return;
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"move-cursor", 2,
|
||||
G_TYPE_ENUM, step,
|
||||
G_TYPE_INT, count);
|
||||
gtk_widget_class_add_binding_signal (widget_class, keyval,
|
||||
GDK_CONTROL_MASK | GDK_SHIFT_MASK,
|
||||
"move-cursor",
|
||||
"(ii)", step, count);
|
||||
|
||||
gtk_binding_entry_add_signal (binding_set, keyval, GDK_CONTROL_MASK,
|
||||
"move-cursor", 2,
|
||||
G_TYPE_ENUM, step,
|
||||
G_TYPE_INT, count);
|
||||
gtk_widget_class_add_binding_signal (widget_class,
|
||||
keyval, GDK_CONTROL_MASK,
|
||||
"move-cursor",
|
||||
"(ii)", step, count);
|
||||
}
|
||||
|
||||
static gint
|
||||
|
@ -45,6 +45,9 @@ typedef struct _GtkNative GtkNative;
|
||||
typedef struct _GtkRequisition GtkRequisition;
|
||||
typedef struct _GtkRoot GtkRoot;
|
||||
typedef struct _GtkSettings GtkSettings;
|
||||
typedef struct _GtkShortcut GtkShortcut;
|
||||
typedef struct _GtkShortcutAction GtkShortcutAction;
|
||||
typedef struct _GtkShortcutTrigger GtkShortcutTrigger;
|
||||
typedef GdkSnapshot GtkSnapshot;
|
||||
typedef struct _GtkStyleContext GtkStyleContext;
|
||||
typedef struct _GtkTooltip GtkTooltip;
|
||||
|
760
gtk/gtkwidget.c
760
gtk/gtkwidget.c
@ -26,13 +26,12 @@
|
||||
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
#include "gtkaccelmapprivate.h"
|
||||
#include "gtkaccelgroupprivate.h"
|
||||
#include "gtkaccessible.h"
|
||||
#include "gtkapplicationprivate.h"
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkbuilderprivate.h"
|
||||
#include "gtkconcatmodelprivate.h"
|
||||
#include "gtkcontainerprivate.h"
|
||||
#include "gtkcssboxesprivate.h"
|
||||
#include "gtkcssfiltervalueprivate.h"
|
||||
@ -59,6 +58,11 @@
|
||||
#include "gtknativeprivate.h"
|
||||
#include "gtkscrollable.h"
|
||||
#include "gtksettingsprivate.h"
|
||||
#include "gtkshortcut.h"
|
||||
#include "gtkshortcutcontrollerprivate.h"
|
||||
#include "gtkshortcutmanager.h"
|
||||
#include "gtkshortcutmanagerprivate.h"
|
||||
#include "gtkshortcuttrigger.h"
|
||||
#include "gtksizegroup-private.h"
|
||||
#include "gtksnapshotprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
@ -493,6 +497,7 @@ typedef struct {
|
||||
struct _GtkWidgetClassPrivate
|
||||
{
|
||||
GtkWidgetTemplate *template;
|
||||
GListStore *shortcuts;
|
||||
GType accessible_type;
|
||||
AtkRole accessible_role;
|
||||
GQuark css_name;
|
||||
@ -515,7 +520,6 @@ enum {
|
||||
MNEMONIC_ACTIVATE,
|
||||
MOVE_FOCUS,
|
||||
KEYNAV_FAILED,
|
||||
POPUP_MENU,
|
||||
ACCEL_CLOSURES_CHANGED,
|
||||
CAN_ACTIVATE_ACCEL,
|
||||
QUERY_TOOLTIP,
|
||||
@ -701,8 +705,6 @@ static gpointer gtk_widget_parent_class = NULL;
|
||||
static guint widget_signals[LAST_SIGNAL] = { 0 };
|
||||
GtkTextDirection gtk_default_direction = GTK_TEXT_DIR_LTR;
|
||||
|
||||
static GQuark quark_accel_path = 0;
|
||||
static GQuark quark_accel_closures = 0;
|
||||
static GQuark quark_pango_context = 0;
|
||||
static GQuark quark_mnemonic_labels = 0;
|
||||
static GQuark quark_tooltip_markup = 0;
|
||||
@ -784,9 +786,29 @@ static void
|
||||
gtk_widget_base_class_init (gpointer g_class)
|
||||
{
|
||||
GtkWidgetClass *klass = g_class;
|
||||
GtkWidgetClassPrivate *priv;
|
||||
|
||||
klass->priv = G_TYPE_CLASS_GET_PRIVATE (g_class, GTK_TYPE_WIDGET, GtkWidgetClassPrivate);
|
||||
klass->priv->template = NULL;
|
||||
priv = klass->priv = G_TYPE_CLASS_GET_PRIVATE (g_class, GTK_TYPE_WIDGET, GtkWidgetClassPrivate);
|
||||
|
||||
priv->template = NULL;
|
||||
|
||||
if (priv->shortcuts == NULL)
|
||||
{
|
||||
priv->shortcuts = g_list_store_new (GTK_TYPE_SHORTCUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
GListModel *parent_shortcuts = G_LIST_MODEL (priv->shortcuts);
|
||||
guint i;
|
||||
|
||||
priv->shortcuts = g_list_store_new (GTK_TYPE_SHORTCUT);
|
||||
for (i = 0; i < g_list_model_get_n_items (parent_shortcuts); i++)
|
||||
{
|
||||
GtkShortcut *shortcut = g_list_model_get_item (parent_shortcuts, i);
|
||||
g_list_store_append (priv->shortcuts, shortcut);
|
||||
g_object_unref (shortcut);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -839,12 +861,30 @@ gtk_widget_real_grab_notify (GtkWidget *widget,
|
||||
static void
|
||||
gtk_widget_real_root (GtkWidget *widget)
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
GList *l;
|
||||
|
||||
gtk_widget_forall (widget, (GtkCallback) gtk_widget_root, NULL);
|
||||
|
||||
for (l = priv->event_controllers; l; l = l->next)
|
||||
{
|
||||
if (GTK_IS_SHORTCUT_CONTROLLER (l->data))
|
||||
gtk_shortcut_controller_root (GTK_SHORTCUT_CONTROLLER (l->data));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_widget_real_unroot (GtkWidget *widget)
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
GList *l;
|
||||
|
||||
for (l = priv->event_controllers; l; l = l->next)
|
||||
{
|
||||
if (GTK_IS_SHORTCUT_CONTROLLER (l->data))
|
||||
gtk_shortcut_controller_unroot (GTK_SHORTCUT_CONTROLLER (l->data));
|
||||
}
|
||||
|
||||
gtk_widget_forall (widget, (GtkCallback) gtk_widget_unroot, NULL);
|
||||
}
|
||||
|
||||
@ -852,13 +892,10 @@ static void
|
||||
gtk_widget_class_init (GtkWidgetClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
g_type_class_adjust_private_offset (klass, &GtkWidget_private_offset);
|
||||
gtk_widget_parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
quark_accel_path = g_quark_from_static_string ("gtk-accel-path");
|
||||
quark_accel_closures = g_quark_from_static_string ("gtk-accel-closures");
|
||||
quark_pango_context = g_quark_from_static_string ("gtk-pango-context");
|
||||
quark_mnemonic_labels = g_quark_from_static_string ("gtk-mnemonic-labels");
|
||||
quark_tooltip_markup = g_quark_from_static_string ("gtk-tooltip-markup");
|
||||
@ -1637,32 +1674,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
_gtk_marshal_BOOLEAN__INT_INT_BOOLEAN_OBJECTv);
|
||||
|
||||
/**
|
||||
* GtkWidget::popup-menu:
|
||||
* @widget: the object which received the signal
|
||||
*
|
||||
* This signal gets emitted whenever a widget should pop up a context
|
||||
* menu. This usually happens through the standard key binding mechanism;
|
||||
* by pressing a certain key while a widget is focused, the user can cause
|
||||
* the widget to pop up a menu. For example, the #GtkEntry widget creates
|
||||
* a menu with clipboard commands. See the
|
||||
* [Popup Menu Migration Checklist][checklist-popup-menu]
|
||||
* for an example of how to use this signal.
|
||||
*
|
||||
* Returns: %TRUE if a menu was activated
|
||||
*/
|
||||
widget_signals[POPUP_MENU] =
|
||||
g_signal_new (I_("popup-menu"),
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
||||
G_STRUCT_OFFSET (GtkWidgetClass, popup_menu),
|
||||
_gtk_boolean_handled_accumulator, NULL,
|
||||
_gtk_marshal_BOOLEAN__VOID,
|
||||
G_TYPE_BOOLEAN, 0);
|
||||
g_signal_set_va_marshaller (widget_signals[POPUP_MENU],
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
_gtk_marshal_BOOLEAN__VOIDv);
|
||||
|
||||
/**
|
||||
* GtkWidget::accel-closures-changed:
|
||||
* @widget: the object which received the signal.
|
||||
@ -1704,12 +1715,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
_gtk_marshal_BOOLEAN__UINTv);
|
||||
|
||||
binding_set = gtk_binding_set_by_class (klass);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_F10, GDK_SHIFT_MASK,
|
||||
"popup-menu", 0);
|
||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Menu, 0,
|
||||
"popup-menu", 0);
|
||||
|
||||
gtk_widget_class_set_accessible_type (klass, GTK_TYPE_WIDGET_ACCESSIBLE);
|
||||
gtk_widget_class_set_css_name (klass, I_("widget"));
|
||||
}
|
||||
@ -1717,7 +1722,9 @@ gtk_widget_class_init (GtkWidgetClass *klass)
|
||||
static void
|
||||
gtk_widget_base_class_finalize (GtkWidgetClass *klass)
|
||||
{
|
||||
|
||||
template_data_free (klass->priv->template);
|
||||
g_object_unref (klass->priv->shortcuts);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2348,6 +2355,7 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
|
||||
GtkWidget *widget = GTK_WIDGET (instance);
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
GType layout_manager_type;
|
||||
GtkEventController *controller;
|
||||
|
||||
widget->priv = priv;
|
||||
|
||||
@ -2416,9 +2424,19 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
|
||||
if (g_type_is_a (G_TYPE_FROM_CLASS (g_class), GTK_TYPE_ROOT))
|
||||
priv->root = (GtkRoot *) widget;
|
||||
|
||||
if (g_type_is_a (G_TYPE_FROM_CLASS (g_class), GTK_TYPE_SHORTCUT_MANAGER))
|
||||
gtk_shortcut_manager_create_controllers (widget);
|
||||
|
||||
layout_manager_type = gtk_widget_class_get_layout_manager_type (g_class);
|
||||
if (layout_manager_type != G_TYPE_INVALID)
|
||||
gtk_widget_set_layout_manager (widget, g_object_new (layout_manager_type, NULL));
|
||||
|
||||
if (g_list_model_get_n_items (G_LIST_MODEL (GTK_WIDGET_CLASS (g_class)->priv->shortcuts)) > 0)
|
||||
{
|
||||
controller = gtk_shortcut_controller_new_for_model (G_LIST_MODEL (GTK_WIDGET_CLASS (g_class)->priv->shortcuts));
|
||||
gtk_event_controller_set_name (controller, "gtk-widget-class-shortcuts");
|
||||
gtk_widget_add_controller (widget, controller);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4311,6 +4329,181 @@ gtk_widget_real_size_allocate (GtkWidget *widget,
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_class_add_binding: (skip)
|
||||
* @widget_class: the class to add the binding to
|
||||
* @keyval: key value of binding to install
|
||||
* @mods: key modifier of binding to install
|
||||
* @callback: the callback to call upon activation
|
||||
* @format_string: GVariant format string for arguments or %NULL for
|
||||
* no arguments
|
||||
* @...: arguments, as given by format string.
|
||||
*
|
||||
* Creates a new shortcut for @widget_class that calls the given @callback
|
||||
* with arguments read according to @format_string.
|
||||
* The arguments and format string must be provided in the same way as
|
||||
* with g_variant_new().
|
||||
*
|
||||
* This function is a convenience wrapper around
|
||||
* gtk_widget_class_add_shortcut() and must be called during class
|
||||
* initialization. It does not provide for user_data, if you need that,
|
||||
* you will have to use gtk_widget_class_add_shortcut() with a custom
|
||||
* shortcut.
|
||||
**/
|
||||
void
|
||||
gtk_widget_class_add_binding (GtkWidgetClass *widget_class,
|
||||
guint keyval,
|
||||
GdkModifierType mods,
|
||||
GtkShortcutFunc func,
|
||||
const gchar *format_string,
|
||||
...)
|
||||
{
|
||||
GtkShortcut *shortcut;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET_CLASS (widget_class));
|
||||
|
||||
shortcut = gtk_shortcut_new (gtk_keyval_trigger_new (keyval, mods),
|
||||
gtk_callback_action_new (func, NULL, NULL));
|
||||
if (format_string)
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, format_string);
|
||||
gtk_shortcut_set_arguments (shortcut,
|
||||
g_variant_new_va (format_string, NULL, &args));
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
gtk_widget_class_add_shortcut (widget_class, shortcut);
|
||||
|
||||
g_object_unref (shortcut);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_class_add_binding_signal: (skip)
|
||||
* @widget_class: the class to add the binding to
|
||||
* @keyval: key value of binding to install
|
||||
* @mods: key modifier of binding to install
|
||||
* @signal: the signal to execute
|
||||
* @format_string: GVariant format string for arguments or %NULL for
|
||||
* no arguments
|
||||
* @...: arguments, as given by format string.
|
||||
*
|
||||
* Creates a new shortcut for @widget_class that emits the given action
|
||||
* @signal with arguments read according to @format_string.
|
||||
* The arguments and format string must be provided in the same way as
|
||||
* with g_variant_new().
|
||||
*
|
||||
* This function is a convenience wrapper around
|
||||
* gtk_widget_class_add_shortcut() and must be called during class
|
||||
* initialization.
|
||||
*/
|
||||
void
|
||||
gtk_widget_class_add_binding_signal (GtkWidgetClass *widget_class,
|
||||
guint keyval,
|
||||
GdkModifierType mods,
|
||||
const gchar *signal,
|
||||
const gchar *format_string,
|
||||
...)
|
||||
{
|
||||
GtkShortcut *shortcut;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET_CLASS (widget_class));
|
||||
g_return_if_fail (g_signal_lookup (signal, G_TYPE_FROM_CLASS (widget_class)));
|
||||
/* XXX: validate variant format for signal */
|
||||
|
||||
shortcut = gtk_shortcut_new (gtk_keyval_trigger_new (keyval, mods),
|
||||
gtk_signal_action_new (signal));
|
||||
if (format_string)
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, format_string);
|
||||
gtk_shortcut_set_arguments (shortcut,
|
||||
g_variant_new_va (format_string, NULL, &args));
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
gtk_widget_class_add_shortcut (widget_class, shortcut);
|
||||
|
||||
g_object_unref (shortcut);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_class_add_binding_action: (skip)
|
||||
* @widget_class: the class to add the binding to
|
||||
* @keyval: key value of binding to install
|
||||
* @mods: key modifier of binding to install
|
||||
* @action_name: the action to activate
|
||||
* @format_string: GVariant format string for arguments or %NULL for
|
||||
* no arguments
|
||||
* @...: arguments, as given by format string.
|
||||
*
|
||||
* Creates a new shortcut for @widget_class that activates the given
|
||||
* @action_name with arguments read according to @format_string.
|
||||
* The arguments and format string must be provided in the same way as
|
||||
* with g_variant_new().
|
||||
*
|
||||
* This function is a convenience wrapper around
|
||||
* gtk_widget_class_add_shortcut() and must be called during class
|
||||
* initialization.
|
||||
*/
|
||||
void
|
||||
gtk_widget_class_add_binding_action (GtkWidgetClass *widget_class,
|
||||
guint keyval,
|
||||
GdkModifierType mods,
|
||||
const gchar *action_name,
|
||||
const gchar *format_string,
|
||||
...)
|
||||
{
|
||||
GtkShortcut *shortcut;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET_CLASS (widget_class));
|
||||
/* XXX: validate variant format for action */
|
||||
|
||||
shortcut = gtk_shortcut_new (gtk_keyval_trigger_new (keyval, mods),
|
||||
gtk_action_action_new (action_name));
|
||||
if (format_string)
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, format_string);
|
||||
gtk_shortcut_set_arguments (shortcut,
|
||||
g_variant_new_va (format_string, NULL, &args));
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
gtk_widget_class_add_shortcut (widget_class, shortcut);
|
||||
|
||||
g_object_unref (shortcut);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_class_add_shortcut:
|
||||
* @widget_class: the class to add the shortcut to
|
||||
* @shortcut: (transfer none): the #GtkShortcut to add
|
||||
*
|
||||
* Installs a shortcut in @widget_class. Every instance created for
|
||||
* @widget_class or its subclasses will inherit this shortcut and
|
||||
* trigger it.
|
||||
*
|
||||
* Shortcuts added this way will be triggered in the @GTK_PHASE_BUBBLE
|
||||
* phase, which means they may also trigger if child widgets have focus.
|
||||
*
|
||||
* This function must only be used in class initialization functions
|
||||
* otherwise it is not guaranteed that the shortcut will be installed.
|
||||
**/
|
||||
void
|
||||
gtk_widget_class_add_shortcut (GtkWidgetClass *widget_class,
|
||||
GtkShortcut *shortcut)
|
||||
{
|
||||
GtkWidgetClassPrivate *priv;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET_CLASS (widget_class));
|
||||
g_return_if_fail (GTK_IS_SHORTCUT (shortcut));
|
||||
|
||||
priv = widget_class->priv;
|
||||
|
||||
g_list_store_append (priv->shortcuts, shortcut);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_widget_real_can_activate_accel (GtkWidget *widget,
|
||||
guint signal_id)
|
||||
@ -4352,311 +4545,6 @@ gtk_widget_can_activate_accel (GtkWidget *widget,
|
||||
return can_activate;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
GClosure closure;
|
||||
guint signal_id;
|
||||
} AccelClosure;
|
||||
|
||||
static void
|
||||
closure_accel_activate (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data)
|
||||
{
|
||||
AccelClosure *aclosure = (AccelClosure*) closure;
|
||||
gboolean can_activate = gtk_widget_can_activate_accel (closure->data, aclosure->signal_id);
|
||||
|
||||
if (can_activate)
|
||||
g_signal_emit (closure->data, aclosure->signal_id, 0);
|
||||
|
||||
/* whether accelerator was handled */
|
||||
g_value_set_boolean (return_value, can_activate);
|
||||
}
|
||||
|
||||
static void
|
||||
closures_destroy (gpointer data)
|
||||
{
|
||||
GSList *slist, *closures = data;
|
||||
|
||||
for (slist = closures; slist; slist = slist->next)
|
||||
{
|
||||
g_closure_invalidate (slist->data);
|
||||
g_closure_unref (slist->data);
|
||||
}
|
||||
g_slist_free (closures);
|
||||
}
|
||||
|
||||
static GClosure*
|
||||
widget_new_accel_closure (GtkWidget *widget,
|
||||
guint signal_id)
|
||||
{
|
||||
AccelClosure *aclosure;
|
||||
GClosure *closure = NULL;
|
||||
GSList *slist, *closures;
|
||||
|
||||
closures = g_object_steal_qdata (G_OBJECT (widget), quark_accel_closures);
|
||||
for (slist = closures; slist; slist = slist->next)
|
||||
if (!gtk_accel_group_from_accel_closure (slist->data))
|
||||
{
|
||||
/* reuse this closure */
|
||||
closure = slist->data;
|
||||
break;
|
||||
}
|
||||
if (!closure)
|
||||
{
|
||||
closure = g_closure_new_object (sizeof (AccelClosure), G_OBJECT (widget));
|
||||
closures = g_slist_prepend (closures, g_closure_ref (closure));
|
||||
g_closure_sink (closure);
|
||||
g_closure_set_marshal (closure, closure_accel_activate);
|
||||
}
|
||||
g_object_set_qdata_full (G_OBJECT (widget), quark_accel_closures, closures, closures_destroy);
|
||||
|
||||
aclosure = (AccelClosure*) closure;
|
||||
g_assert (closure->data == widget);
|
||||
g_assert (closure->marshal == closure_accel_activate);
|
||||
aclosure->signal_id = signal_id;
|
||||
|
||||
return closure;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_add_accelerator:
|
||||
* @widget: widget to install an accelerator on
|
||||
* @accel_signal: widget signal to emit on accelerator activation
|
||||
* @accel_group: accel group for this widget, added to its toplevel
|
||||
* @accel_key: GDK keyval of the accelerator
|
||||
* @accel_mods: modifier key combination of the accelerator
|
||||
* @accel_flags: flag accelerators, e.g. %GTK_ACCEL_VISIBLE
|
||||
*
|
||||
* Installs an accelerator for this @widget in @accel_group that causes
|
||||
* @accel_signal to be emitted if the accelerator is activated.
|
||||
* The @accel_group needs to be added to the widget’s toplevel via
|
||||
* gtk_window_add_accel_group(), and the signal must be of type %G_SIGNAL_ACTION.
|
||||
* Accelerators added through this function are not user changeable during
|
||||
* runtime. If you want to support accelerators that can be changed by the
|
||||
* user, use gtk_accel_map_add_entry() and gtk_widget_set_accel_path() or
|
||||
* gtk_menu_item_set_accel_path() instead.
|
||||
*/
|
||||
void
|
||||
gtk_widget_add_accelerator (GtkWidget *widget,
|
||||
const gchar *accel_signal,
|
||||
GtkAccelGroup *accel_group,
|
||||
guint accel_key,
|
||||
GdkModifierType accel_mods,
|
||||
GtkAccelFlags accel_flags)
|
||||
{
|
||||
GClosure *closure;
|
||||
GSignalQuery query;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
g_return_if_fail (accel_signal != NULL);
|
||||
g_return_if_fail (GTK_IS_ACCEL_GROUP (accel_group));
|
||||
|
||||
g_signal_query (g_signal_lookup (accel_signal, G_OBJECT_TYPE (widget)), &query);
|
||||
if (!query.signal_id ||
|
||||
!(query.signal_flags & G_SIGNAL_ACTION) ||
|
||||
query.return_type != G_TYPE_NONE ||
|
||||
query.n_params)
|
||||
{
|
||||
/* hmm, should be elaborate enough */
|
||||
g_warning (G_STRLOC ": widget '%s' has no activatable signal \"%s\" without arguments",
|
||||
G_OBJECT_TYPE_NAME (widget), accel_signal);
|
||||
return;
|
||||
}
|
||||
|
||||
closure = widget_new_accel_closure (widget, query.signal_id);
|
||||
|
||||
g_object_ref (widget);
|
||||
|
||||
/* install the accelerator. since we don't map this onto an accel_path,
|
||||
* the accelerator will automatically be locked.
|
||||
*/
|
||||
gtk_accel_group_connect (accel_group,
|
||||
accel_key,
|
||||
accel_mods,
|
||||
accel_flags | GTK_ACCEL_LOCKED,
|
||||
closure);
|
||||
|
||||
g_signal_emit (widget, widget_signals[ACCEL_CLOSURES_CHANGED], 0);
|
||||
|
||||
g_object_unref (widget);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_remove_accelerator:
|
||||
* @widget: widget to install an accelerator on
|
||||
* @accel_group: accel group for this widget
|
||||
* @accel_key: GDK keyval of the accelerator
|
||||
* @accel_mods: modifier key combination of the accelerator
|
||||
*
|
||||
* Removes an accelerator from @widget, previously installed with
|
||||
* gtk_widget_add_accelerator().
|
||||
*
|
||||
* Returns: whether an accelerator was installed and could be removed
|
||||
*/
|
||||
gboolean
|
||||
gtk_widget_remove_accelerator (GtkWidget *widget,
|
||||
GtkAccelGroup *accel_group,
|
||||
guint accel_key,
|
||||
GdkModifierType accel_mods)
|
||||
{
|
||||
GtkAccelGroupEntry *ag_entry;
|
||||
GList *slist, *clist;
|
||||
guint n;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
|
||||
g_return_val_if_fail (GTK_IS_ACCEL_GROUP (accel_group), FALSE);
|
||||
|
||||
ag_entry = gtk_accel_group_query (accel_group, accel_key, accel_mods, &n);
|
||||
clist = gtk_widget_list_accel_closures (widget);
|
||||
for (slist = clist; slist; slist = slist->next)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
if (slist->data == (gpointer) ag_entry[i].closure)
|
||||
{
|
||||
gboolean is_removed = gtk_accel_group_disconnect (accel_group, slist->data);
|
||||
|
||||
g_signal_emit (widget, widget_signals[ACCEL_CLOSURES_CHANGED], 0);
|
||||
|
||||
g_list_free (clist);
|
||||
|
||||
return is_removed;
|
||||
}
|
||||
}
|
||||
g_list_free (clist);
|
||||
|
||||
g_warning (G_STRLOC ": no accelerator (%u,%u) installed in accel group (%p) for %s (%p)",
|
||||
accel_key, accel_mods, accel_group,
|
||||
G_OBJECT_TYPE_NAME (widget), widget);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_list_accel_closures:
|
||||
* @widget: widget to list accelerator closures for
|
||||
*
|
||||
* Lists the closures used by @widget for accelerator group connections
|
||||
* with gtk_accel_group_connect_by_path() or gtk_accel_group_connect().
|
||||
* The closures can be used to monitor accelerator changes on @widget,
|
||||
* by connecting to the @GtkAccelGroup::accel-changed signal of the
|
||||
* #GtkAccelGroup of a closure which can be found out with
|
||||
* gtk_accel_group_from_accel_closure().
|
||||
*
|
||||
* Returns: (transfer container) (element-type GClosure):
|
||||
* a newly allocated #GList of closures
|
||||
*/
|
||||
GList*
|
||||
gtk_widget_list_accel_closures (GtkWidget *widget)
|
||||
{
|
||||
GSList *slist;
|
||||
GList *clist = NULL;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
|
||||
for (slist = g_object_get_qdata (G_OBJECT (widget), quark_accel_closures); slist; slist = slist->next)
|
||||
if (gtk_accel_group_from_accel_closure (slist->data))
|
||||
clist = g_list_prepend (clist, slist->data);
|
||||
return clist;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
GQuark path_quark;
|
||||
GtkAccelGroup *accel_group;
|
||||
GClosure *closure;
|
||||
} AccelPath;
|
||||
|
||||
static void
|
||||
destroy_accel_path (gpointer data)
|
||||
{
|
||||
AccelPath *apath = data;
|
||||
|
||||
gtk_accel_group_disconnect (apath->accel_group, apath->closure);
|
||||
|
||||
/* closures_destroy takes care of unrefing the closure */
|
||||
g_object_unref (apath->accel_group);
|
||||
|
||||
g_slice_free (AccelPath, apath);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gtk_widget_set_accel_path:
|
||||
* @widget: a #GtkWidget
|
||||
* @accel_path: (allow-none): path used to look up the accelerator
|
||||
* @accel_group: (allow-none): a #GtkAccelGroup.
|
||||
*
|
||||
* Given an accelerator group, @accel_group, and an accelerator path,
|
||||
* @accel_path, sets up an accelerator in @accel_group so whenever the
|
||||
* key binding that is defined for @accel_path is pressed, @widget
|
||||
* will be activated. This removes any accelerators (for any
|
||||
* accelerator group) installed by previous calls to
|
||||
* gtk_widget_set_accel_path(). Associating accelerators with
|
||||
* paths allows them to be modified by the user and the modifications
|
||||
* to be saved for future use. (See gtk_accel_map_save().)
|
||||
*
|
||||
* This function is a low level function that would most likely
|
||||
* be used by a menu creation system.
|
||||
*
|
||||
* If you only want to
|
||||
* set up accelerators on menu items gtk_menu_item_set_accel_path()
|
||||
* provides a somewhat more convenient interface.
|
||||
*
|
||||
* Note that @accel_path string will be stored in a #GQuark. Therefore, if you
|
||||
* pass a static string, you can save some memory by interning it first with
|
||||
* g_intern_static_string().
|
||||
**/
|
||||
void
|
||||
gtk_widget_set_accel_path (GtkWidget *widget,
|
||||
const gchar *accel_path,
|
||||
GtkAccelGroup *accel_group)
|
||||
{
|
||||
AccelPath *apath;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
g_return_if_fail (GTK_WIDGET_GET_CLASS (widget)->activate_signal != 0);
|
||||
|
||||
if (accel_path)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_ACCEL_GROUP (accel_group));
|
||||
g_return_if_fail (_gtk_accel_path_is_valid (accel_path));
|
||||
|
||||
gtk_accel_map_add_entry (accel_path, 0, 0);
|
||||
apath = g_slice_new (AccelPath);
|
||||
apath->accel_group = g_object_ref (accel_group);
|
||||
apath->path_quark = g_quark_from_string (accel_path);
|
||||
apath->closure = widget_new_accel_closure (widget, GTK_WIDGET_GET_CLASS (widget)->activate_signal);
|
||||
}
|
||||
else
|
||||
apath = NULL;
|
||||
|
||||
/* also removes possible old settings */
|
||||
g_object_set_qdata_full (G_OBJECT (widget), quark_accel_path, apath, destroy_accel_path);
|
||||
|
||||
if (apath)
|
||||
gtk_accel_group_connect_by_path (apath->accel_group, g_quark_to_string (apath->path_quark), apath->closure);
|
||||
|
||||
g_signal_emit (widget, widget_signals[ACCEL_CLOSURES_CHANGED], 0);
|
||||
}
|
||||
|
||||
const gchar*
|
||||
_gtk_widget_get_accel_path (GtkWidget *widget,
|
||||
gboolean *locked)
|
||||
{
|
||||
AccelPath *apath;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
|
||||
apath = g_object_get_qdata (G_OBJECT (widget), quark_accel_path);
|
||||
if (locked)
|
||||
*locked = apath ? gtk_accel_group_get_is_locked (apath->accel_group) : TRUE;
|
||||
return apath ? g_quark_to_string (apath->path_quark) : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_mnemonic_activate:
|
||||
* @widget: a #GtkWidget
|
||||
@ -4910,11 +4798,6 @@ gtk_widget_event (GtkWidget *widget,
|
||||
if (return_val == FALSE)
|
||||
return_val |= gtk_widget_run_controllers (widget, event, target, x, y, GTK_PHASE_BUBBLE);
|
||||
|
||||
if (return_val == FALSE &&
|
||||
(gdk_event_get_event_type (event) == GDK_KEY_PRESS ||
|
||||
gdk_event_get_event_type (event) == GDK_KEY_RELEASE))
|
||||
return_val |= gtk_bindings_activate_event (G_OBJECT (widget), event);
|
||||
|
||||
return return_val;
|
||||
}
|
||||
|
||||
@ -7557,10 +7440,6 @@ gtk_widget_real_destroy (GtkWidget *object)
|
||||
priv->accessible = NULL;
|
||||
}
|
||||
|
||||
/* wipe accelerator closures (keep order) */
|
||||
g_object_set_qdata (G_OBJECT (widget), quark_accel_path, NULL);
|
||||
g_object_set_qdata (G_OBJECT (widget), quark_accel_closures, NULL);
|
||||
|
||||
/* Callers of add_mnemonic_label() should disconnect on ::destroy */
|
||||
g_object_set_qdata (G_OBJECT (widget), quark_mnemonic_labels, NULL);
|
||||
|
||||
@ -8996,90 +8875,6 @@ static const GtkBuildableParser accessibility_parser =
|
||||
accessibility_text,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GObject *object;
|
||||
GtkBuilder *builder;
|
||||
guint key;
|
||||
guint modifiers;
|
||||
gchar *signal;
|
||||
} AccelGroupParserData;
|
||||
|
||||
static void
|
||||
accel_group_start_element (GtkBuildableParseContext *context,
|
||||
const gchar *element_name,
|
||||
const gchar **names,
|
||||
const gchar **values,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
{
|
||||
AccelGroupParserData *data = (AccelGroupParserData*)user_data;
|
||||
|
||||
if (strcmp (element_name, "accelerator") == 0)
|
||||
{
|
||||
const gchar *key_str = NULL;
|
||||
const gchar *signal = NULL;
|
||||
const gchar *modifiers_str = NULL;
|
||||
guint key = 0;
|
||||
guint modifiers = 0;
|
||||
|
||||
if (!_gtk_builder_check_parent (data->builder, context, "object", error))
|
||||
return;
|
||||
|
||||
if (!g_markup_collect_attributes (element_name, names, values, error,
|
||||
G_MARKUP_COLLECT_STRING, "key", &key_str,
|
||||
G_MARKUP_COLLECT_STRING, "signal", &signal,
|
||||
G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "modifiers", &modifiers_str,
|
||||
G_MARKUP_COLLECT_INVALID))
|
||||
{
|
||||
_gtk_builder_prefix_error (data->builder, context, error);
|
||||
return;
|
||||
}
|
||||
|
||||
key = gdk_keyval_from_name (key_str);
|
||||
if (key == 0)
|
||||
{
|
||||
g_set_error (error,
|
||||
GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_INVALID_VALUE,
|
||||
"Could not parse key '%s'", key_str);
|
||||
_gtk_builder_prefix_error (data->builder, context, error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (modifiers_str != NULL)
|
||||
{
|
||||
GFlagsValue aliases[2] = {
|
||||
{ 0, "primary", "primary" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
aliases[0].value = _gtk_get_primary_accel_mod ();
|
||||
|
||||
if (!_gtk_builder_flags_from_string (GDK_TYPE_MODIFIER_TYPE, aliases,
|
||||
modifiers_str, &modifiers, error))
|
||||
{
|
||||
_gtk_builder_prefix_error (data->builder, context, error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
data->key = key;
|
||||
data->modifiers = modifiers;
|
||||
data->signal = g_strdup (signal);
|
||||
}
|
||||
else
|
||||
{
|
||||
_gtk_builder_error_unhandled_tag (data->builder, context,
|
||||
"GtkWidget", element_name,
|
||||
error);
|
||||
}
|
||||
}
|
||||
|
||||
static const GtkBuildableParser accel_group_parser =
|
||||
{
|
||||
accel_group_start_element,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
@ -9283,20 +9078,6 @@ gtk_widget_buildable_custom_tag_start (GtkBuildable *buildable,
|
||||
GtkBuildableParser *parser,
|
||||
gpointer *parser_data)
|
||||
{
|
||||
if (strcmp (tagname, "accelerator") == 0)
|
||||
{
|
||||
AccelGroupParserData *data;
|
||||
|
||||
data = g_slice_new0 (AccelGroupParserData);
|
||||
data->object = (GObject *)g_object_ref (buildable);
|
||||
data->builder = builder;
|
||||
|
||||
*parser = accel_group_parser;
|
||||
*parser_data = data;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (strcmp (tagname, "accessibility") == 0)
|
||||
{
|
||||
AccessibilitySubParserData *data;
|
||||
@ -9349,45 +9130,6 @@ gtk_widget_buildable_custom_tag_end (GtkBuildable *buildable,
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_widget_buildable_finish_accelerator (GtkWidget *widget,
|
||||
GtkWidget *toplevel,
|
||||
gpointer user_data)
|
||||
{
|
||||
AccelGroupParserData *accel_data;
|
||||
GSList *accel_groups;
|
||||
GtkAccelGroup *accel_group;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
g_return_if_fail (GTK_IS_WIDGET (toplevel));
|
||||
g_return_if_fail (user_data != NULL);
|
||||
|
||||
accel_data = (AccelGroupParserData*)user_data;
|
||||
accel_groups = gtk_accel_groups_from_object (G_OBJECT (toplevel));
|
||||
if (g_slist_length (accel_groups) == 0)
|
||||
{
|
||||
accel_group = gtk_accel_group_new ();
|
||||
if (GTK_IS_WINDOW (toplevel))
|
||||
gtk_window_add_accel_group (GTK_WINDOW (toplevel), accel_group);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_assert (g_slist_length (accel_groups) == 1);
|
||||
accel_group = g_slist_nth_data (accel_groups, 0);
|
||||
}
|
||||
|
||||
gtk_widget_add_accelerator (GTK_WIDGET (accel_data->object),
|
||||
accel_data->signal,
|
||||
accel_group,
|
||||
accel_data->key,
|
||||
accel_data->modifiers,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
|
||||
g_object_unref (accel_data->object);
|
||||
g_free (accel_data->signal);
|
||||
g_slice_free (AccelGroupParserData, accel_data);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_widget_buildable_finish_layout_properties (GtkWidget *widget,
|
||||
GtkWidget *parent,
|
||||
@ -9461,19 +9203,7 @@ gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
|
||||
const gchar *tagname,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (strcmp (tagname, "accelerator") == 0)
|
||||
{
|
||||
AccelGroupParserData *accel_data;
|
||||
GtkRoot *root;
|
||||
|
||||
accel_data = (AccelGroupParserData*)user_data;
|
||||
g_assert (accel_data->object);
|
||||
|
||||
root = _gtk_widget_get_root (GTK_WIDGET (accel_data->object));
|
||||
|
||||
_gtk_widget_buildable_finish_accelerator (GTK_WIDGET (buildable), GTK_WIDGET (root), user_data);
|
||||
}
|
||||
else if (strcmp (tagname, "accessibility") == 0)
|
||||
if (strcmp (tagname, "accessibility") == 0)
|
||||
{
|
||||
AccessibilitySubParserData *a11y_data;
|
||||
|
||||
@ -11853,6 +11583,24 @@ gtk_widget_reset_controllers (GtkWidget *widget)
|
||||
}
|
||||
}
|
||||
|
||||
GList *
|
||||
gtk_widget_list_controllers (GtkWidget *widget,
|
||||
GtkPropagationPhase phase)
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
GList *res = NULL, *l;
|
||||
|
||||
for (l = priv->event_controllers; l; l = l->next)
|
||||
{
|
||||
GtkEventController *controller = l->data;
|
||||
|
||||
if (gtk_event_controller_get_propagation_phase (controller) == phase)
|
||||
res = g_list_prepend (res, controller);
|
||||
}
|
||||
|
||||
return g_list_reverse (res);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gtk_widget_maybe_add_debug_render_nodes (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
|
@ -33,6 +33,8 @@
|
||||
#include <gsk/gsk.h>
|
||||
#include <gtk/gtkaccelgroup.h>
|
||||
#include <gtk/gtkborder.h>
|
||||
#include <gtk/gtkshortcut.h>
|
||||
#include <gtk/gtkshortcutaction.h>
|
||||
#include <gtk/gtktypes.h>
|
||||
#include <atk/atk.h>
|
||||
|
||||
@ -374,23 +376,32 @@ GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_widget_class_get_layout_manager_type (GtkWidgetClass *widget_class);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_widget_add_accelerator (GtkWidget *widget,
|
||||
const gchar *accel_signal,
|
||||
GtkAccelGroup *accel_group,
|
||||
guint accel_key,
|
||||
GdkModifierType accel_mods,
|
||||
GtkAccelFlags accel_flags);
|
||||
void gtk_widget_class_add_binding (GtkWidgetClass *widget_class,
|
||||
guint keyval,
|
||||
GdkModifierType mods,
|
||||
GtkShortcutFunc callback,
|
||||
const gchar *format_string,
|
||||
...);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_widget_remove_accelerator (GtkWidget *widget,
|
||||
GtkAccelGroup *accel_group,
|
||||
guint accel_key,
|
||||
GdkModifierType accel_mods);
|
||||
void gtk_widget_class_add_binding_signal
|
||||
(GtkWidgetClass *widget_class,
|
||||
GdkModifierType mods,
|
||||
guint keyval,
|
||||
const gchar *signal,
|
||||
const gchar *format_string,
|
||||
...);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_widget_set_accel_path (GtkWidget *widget,
|
||||
const gchar *accel_path,
|
||||
GtkAccelGroup *accel_group);
|
||||
void gtk_widget_class_add_binding_action
|
||||
(GtkWidgetClass *widget_class,
|
||||
GdkModifierType mods,
|
||||
guint keyval,
|
||||
const gchar *action_name,
|
||||
const gchar *format_string,
|
||||
...);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GList* gtk_widget_list_accel_closures (GtkWidget *widget);
|
||||
void gtk_widget_class_add_shortcut (GtkWidgetClass *widget_class,
|
||||
GtkShortcut *shortcut);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_widget_can_activate_accel (GtkWidget *widget,
|
||||
guint signal_id);
|
||||
|
@ -230,9 +230,6 @@ void _gtk_widget_add_attached_window (GtkWidget *widget,
|
||||
void _gtk_widget_remove_attached_window (GtkWidget *widget,
|
||||
GtkWindow *window);
|
||||
|
||||
const gchar* _gtk_widget_get_accel_path (GtkWidget *widget,
|
||||
gboolean *locked);
|
||||
|
||||
AtkObject * _gtk_widget_peek_accessible (GtkWidget *widget);
|
||||
|
||||
void _gtk_widget_set_has_default (GtkWidget *widget,
|
||||
@ -258,9 +255,6 @@ void _gtk_widget_synthesize_crossing (GtkWidget *fro
|
||||
GdkDevice *device,
|
||||
GdkCrossingMode mode);
|
||||
|
||||
void _gtk_widget_buildable_finish_accelerator (GtkWidget *widget,
|
||||
GtkWidget *toplevel,
|
||||
gpointer user_data);
|
||||
GtkStyleContext * _gtk_widget_peek_style_context (GtkWidget *widget);
|
||||
|
||||
gboolean _gtk_widget_captured_event (GtkWidget *widget,
|
||||
@ -283,6 +277,9 @@ gboolean gtk_widget_has_size_request (GtkWidget *widget);
|
||||
|
||||
void gtk_widget_reset_controllers (GtkWidget *widget);
|
||||
|
||||
GList * gtk_widget_list_controllers (GtkWidget *widget,
|
||||
GtkPropagationPhase phase);
|
||||
|
||||
gboolean gtk_widget_query_tooltip (GtkWidget *widget,
|
||||
gint x,
|
||||
gint y,
|
||||
|
853
gtk/gtkwindow.c
853
gtk/gtkwindow.c
File diff suppressed because it is too large
Load Diff
@ -97,12 +97,6 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gtk_window_set_startup_id (GtkWindow *window,
|
||||
const gchar *startup_id);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_window_add_accel_group (GtkWindow *window,
|
||||
GtkAccelGroup *accel_group);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_window_remove_accel_group (GtkWindow *window,
|
||||
GtkAccelGroup *accel_group);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_window_set_focus (GtkWindow *window,
|
||||
GtkWidget *focus);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
@ -190,31 +184,6 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gtk_window_set_has_user_ref_count (GtkWindow *window,
|
||||
gboolean setting);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_window_add_mnemonic (GtkWindow *window,
|
||||
guint keyval,
|
||||
GtkWidget *target);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_window_remove_mnemonic (GtkWindow *window,
|
||||
guint keyval,
|
||||
GtkWidget *target);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_window_mnemonic_activate (GtkWindow *window,
|
||||
guint keyval,
|
||||
GdkModifierType modifier);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_window_set_mnemonic_modifier (GtkWindow *window,
|
||||
GdkModifierType modifier);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkModifierType gtk_window_get_mnemonic_modifier (GtkWindow *window);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_window_activate_key (GtkWindow *window,
|
||||
GdkEvent *event);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_window_propagate_key_event (GtkWindow *window,
|
||||
GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_window_present (GtkWindow *window);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@ -56,7 +56,6 @@ void gtk_window_check_resize (GtkWindow *self);
|
||||
typedef void (*GtkWindowKeysForeachFunc) (GtkWindow *window,
|
||||
guint keyval,
|
||||
GdkModifierType modifiers,
|
||||
gboolean is_mnemonic,
|
||||
gpointer data);
|
||||
|
||||
gboolean gtk_window_emit_close_request (GtkWindow *window);
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "prop-list.h"
|
||||
#include "recorder.h"
|
||||
#include "resource-list.h"
|
||||
#include "shortcuts.h"
|
||||
#include "size-groups.h"
|
||||
#include "statistics.h"
|
||||
#include "visual.h"
|
||||
@ -74,6 +75,7 @@ gtk_inspector_init (void)
|
||||
g_type_ensure (GTK_TYPE_INSPECTOR_PROP_LIST);
|
||||
g_type_ensure (GTK_TYPE_INSPECTOR_RECORDER);
|
||||
g_type_ensure (GTK_TYPE_INSPECTOR_RESOURCE_LIST);
|
||||
g_type_ensure (GTK_TYPE_INSPECTOR_SHORTCUTS);
|
||||
g_type_ensure (GTK_TYPE_INSPECTOR_SIZE_GROUPS);
|
||||
g_type_ensure (GTK_TYPE_INSPECTOR_STATISTICS);
|
||||
g_type_ensure (GTK_TYPE_INSPECTOR_VISUAL);
|
||||
|
@ -28,6 +28,7 @@ inspector_sources = files(
|
||||
'recording.c',
|
||||
'renderrecording.c',
|
||||
'resource-list.c',
|
||||
'shortcuts.c',
|
||||
'size-groups.c',
|
||||
'startrecording.c',
|
||||
'statistics.c',
|
||||
|
158
gtk/inspector/shortcuts.c
Normal file
158
gtk/inspector/shortcuts.c
Normal file
@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
#include "shortcuts.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtklistbox.h"
|
||||
#include "gtksizegroup.h"
|
||||
#include "gtkstack.h"
|
||||
#include "gtkshortcut.h"
|
||||
#include "gtkshortcuttrigger.h"
|
||||
#include "gtkshortcutcontroller.h"
|
||||
|
||||
struct _GtkInspectorShortcuts
|
||||
{
|
||||
GtkWidget parent;
|
||||
|
||||
GtkWidget *box;
|
||||
GtkWidget *list;
|
||||
|
||||
GtkSizeGroup *trigger;
|
||||
GtkSizeGroup *action;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GtkInspectorShortcuts, gtk_inspector_shortcuts, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
gtk_inspector_shortcuts_init (GtkInspectorShortcuts *sl)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (sl));
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
create_row (gpointer item,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkShortcut *shortcut = GTK_SHORTCUT (item);
|
||||
GtkInspectorShortcuts *sl = GTK_INSPECTOR_SHORTCUTS (user_data);
|
||||
GtkShortcutTrigger *trigger;
|
||||
GtkShortcutAction *action;
|
||||
char *s;
|
||||
GtkWidget *row;
|
||||
GtkWidget *label;
|
||||
|
||||
trigger = gtk_shortcut_get_trigger (shortcut);
|
||||
action = gtk_shortcut_get_action (shortcut);
|
||||
|
||||
row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
|
||||
s = gtk_shortcut_trigger_to_string (trigger);
|
||||
label = gtk_label_new (s);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||
g_free (s);
|
||||
gtk_container_add (GTK_CONTAINER (row), label);
|
||||
gtk_size_group_add_widget (sl->trigger, label);
|
||||
|
||||
s = gtk_shortcut_action_to_string (action);
|
||||
label = gtk_label_new (s);
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||
g_free (s);
|
||||
gtk_container_add (GTK_CONTAINER (row), label);
|
||||
gtk_size_group_add_widget (sl->action, label);
|
||||
|
||||
return row;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_inspector_shortcuts_set_object (GtkInspectorShortcuts *sl,
|
||||
GObject *object)
|
||||
{
|
||||
GtkWidget *stack;
|
||||
GtkStackPage *page;
|
||||
|
||||
stack = gtk_widget_get_parent (GTK_WIDGET (sl));
|
||||
page = gtk_stack_get_page (GTK_STACK (stack), GTK_WIDGET (sl));
|
||||
|
||||
if (GTK_IS_SHORTCUT_CONTROLLER (object))
|
||||
{
|
||||
g_object_set (page, "visible", TRUE, NULL);
|
||||
gtk_list_box_bind_model (GTK_LIST_BOX (sl->list),
|
||||
G_LIST_MODEL (object),
|
||||
create_row,
|
||||
sl,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_object_set (page, "visible", FALSE, NULL);
|
||||
gtk_list_box_bind_model (GTK_LIST_BOX (sl->list),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_inspector_shortcuts_measure (GtkWidget *widget,
|
||||
GtkOrientation orientation,
|
||||
int for_size,
|
||||
int *minimum,
|
||||
int *natural,
|
||||
int *minimum_baseline,
|
||||
int *natural_baseline)
|
||||
{
|
||||
GtkInspectorShortcuts *shortcuts = GTK_INSPECTOR_SHORTCUTS (widget);
|
||||
|
||||
gtk_widget_measure (shortcuts->box,
|
||||
orientation,
|
||||
for_size,
|
||||
minimum, natural,
|
||||
minimum_baseline, natural_baseline);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_inspector_shortcuts_size_allocate (GtkWidget *widget,
|
||||
int width,
|
||||
int height,
|
||||
int baseline)
|
||||
{
|
||||
GtkInspectorShortcuts *shortcuts = GTK_INSPECTOR_SHORTCUTS (widget);
|
||||
|
||||
gtk_widget_size_allocate (shortcuts->box,
|
||||
&(GtkAllocation) { 0, 0, width, height },
|
||||
baseline);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gtk_inspector_shortcuts_class_init (GtkInspectorShortcutsClass *klass)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
widget_class->measure = gtk_inspector_shortcuts_measure;
|
||||
widget_class->size_allocate = gtk_inspector_shortcuts_size_allocate;
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/shortcuts.ui");
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorShortcuts, box);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorShortcuts, list);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorShortcuts, trigger);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorShortcuts, action);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
/*
|
||||
* Copyright (c) 2020 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -15,16 +15,17 @@
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_BINDINGS_PRIVATE_H__
|
||||
#define __GTK_BINDINGS_PRIVATE_H__
|
||||
#ifndef _GTK_INSPECTOR_SHORTCUTS_H_
|
||||
#define _GTK_INSPECTOR_SHORTCUTS_H_
|
||||
|
||||
#include "gtkbindings.h"
|
||||
#include <gtk/gtkbox.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
#define GTK_TYPE_INSPECTOR_SHORTCUTS (gtk_inspector_shortcuts_get_type ())
|
||||
|
||||
guint _gtk_binding_parse_binding (GScanner *scanner);
|
||||
void _gtk_binding_reset_parsed (void);
|
||||
G_DECLARE_FINAL_TYPE (GtkInspectorShortcuts, gtk_inspector_shortcuts, GTK, INSPECTOR_SHORTCUTS, GtkWidget)
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_BINDINGS_PRIVATE_H__ */
|
||||
void gtk_inspector_shortcuts_set_object (GtkInspectorShortcuts *sl,
|
||||
GObject *object);
|
||||
|
||||
#endif
|
59
gtk/inspector/shortcuts.ui
Normal file
59
gtk/inspector/shortcuts.ui
Normal file
@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface domain="gtk40">
|
||||
<template class="GtkInspectorShortcuts" parent="GtkWidget">
|
||||
<style>
|
||||
<class name="view"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkBox" id="box">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<style>
|
||||
<class name="header"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkLabel" id="trigger_heading">
|
||||
<property name="label" translatable="yes">Trigger</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="action_heading">
|
||||
<property name="label" translatable="yes">Action</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="vexpand">1</property>
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<child>
|
||||
<object class="GtkListBox" id="list">
|
||||
<style>
|
||||
<class name="list"/>
|
||||
</style>
|
||||
<property name="selection-mode">none</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
<object class="GtkSizeGroup" id="trigger">
|
||||
<property name="mode">horizontal</property>
|
||||
<widgets>
|
||||
<widget name="trigger_heading"/>
|
||||
</widgets>
|
||||
</object>
|
||||
<object class="GtkSizeGroup" id="action">
|
||||
<property name="mode">horizontal</property>
|
||||
<widgets>
|
||||
<widget name="action_heading"/>
|
||||
</widgets>
|
||||
</object>
|
||||
</interface>
|
@ -37,6 +37,7 @@
|
||||
#include "size-groups.h"
|
||||
#include "data-list.h"
|
||||
#include "actions.h"
|
||||
#include "shortcuts.h"
|
||||
#include "menu.h"
|
||||
#include "misc-info.h"
|
||||
#include "magnifier.h"
|
||||
@ -91,6 +92,7 @@ set_selected_object (GtkInspectorWindow *iw,
|
||||
gtk_inspector_size_groups_set_object (GTK_INSPECTOR_SIZE_GROUPS (iw->size_groups), selected);
|
||||
gtk_inspector_data_list_set_object (GTK_INSPECTOR_DATA_LIST (iw->data_list), selected);
|
||||
gtk_inspector_actions_set_object (GTK_INSPECTOR_ACTIONS (iw->actions), selected);
|
||||
gtk_inspector_shortcuts_set_object (GTK_INSPECTOR_SHORTCUTS (iw->shortcuts), selected);
|
||||
gtk_inspector_menu_set_object (GTK_INSPECTOR_MENU (iw->menu), selected);
|
||||
gtk_inspector_controllers_set_object (GTK_INSPECTOR_CONTROLLERS (iw->controllers), selected);
|
||||
gtk_inspector_magnifier_set_object (GTK_INSPECTOR_MAGNIFIER (iw->magnifier), selected);
|
||||
@ -421,6 +423,7 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, size_groups);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, data_list);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, actions);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, shortcuts);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, menu);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, misc_info);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, controllers);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user