mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-14 20:51:07 +00:00
label: Port bindings to use shortcuts
This commit is contained in:
parent
e430e0e2ff
commit
cb09211ace
136
gtk/gtklabel.c
136
gtk/gtklabel.c
@ -26,7 +26,6 @@
|
||||
|
||||
#include "gtklabelprivate.h"
|
||||
|
||||
#include "gtkbindings.h"
|
||||
#include "gtkbuildable.h"
|
||||
#include "gtkbuilderprivate.h"
|
||||
#include "gtkcssnodeprivate.h"
|
||||
@ -606,7 +605,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 +613,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 +630,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;
|
||||
@ -1029,117 +1025,107 @@ gtk_label_class_init (GtkLabelClass *class)
|
||||
/*
|
||||
* Key bindings
|
||||
*/
|
||||
binding_set = gtk_binding_set_by_class (class);
|
||||
|
||||
/* 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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user