mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-30 15:31:34 +00:00
label: Port bindings to use shortcuts
This commit is contained in:
parent
051f7e4118
commit
83dc9dabed
136
gtk/gtklabel.c
136
gtk/gtklabel.c
@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
#include "gtklabelprivate.h"
|
#include "gtklabelprivate.h"
|
||||||
|
|
||||||
#include "gtkbindings.h"
|
|
||||||
#include "gtkbuildable.h"
|
#include "gtkbuildable.h"
|
||||||
#include "gtkbuilderprivate.h"
|
#include "gtkbuilderprivate.h"
|
||||||
#include "gtkcssnodeprivate.h"
|
#include "gtkcssnodeprivate.h"
|
||||||
@ -606,7 +605,7 @@ G_DEFINE_TYPE_WITH_CODE (GtkLabel, gtk_label, GTK_TYPE_WIDGET,
|
|||||||
gtk_label_buildable_interface_init))
|
gtk_label_buildable_interface_init))
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_move_binding (GtkBindingSet *binding_set,
|
add_move_binding (GtkWidgetClass *widget_class,
|
||||||
guint keyval,
|
guint keyval,
|
||||||
guint modmask,
|
guint modmask,
|
||||||
GtkMovementStep step,
|
GtkMovementStep step,
|
||||||
@ -614,18 +613,16 @@ add_move_binding (GtkBindingSet *binding_set,
|
|||||||
{
|
{
|
||||||
g_return_if_fail ((modmask & GDK_SHIFT_MASK) == 0);
|
g_return_if_fail ((modmask & GDK_SHIFT_MASK) == 0);
|
||||||
|
|
||||||
gtk_binding_entry_add_signal (binding_set, keyval, modmask,
|
gtk_widget_class_add_binding_signal (widget_class,
|
||||||
"move-cursor", 3,
|
keyval, modmask,
|
||||||
G_TYPE_ENUM, step,
|
"move-cursor",
|
||||||
G_TYPE_INT, count,
|
"(iib)", step, count, FALSE);
|
||||||
G_TYPE_BOOLEAN, FALSE);
|
|
||||||
|
|
||||||
/* Selection-extending version */
|
/* Selection-extending version */
|
||||||
gtk_binding_entry_add_signal (binding_set, keyval, modmask | GDK_SHIFT_MASK,
|
gtk_widget_class_add_binding_signal (widget_class,
|
||||||
"move-cursor", 3,
|
keyval, modmask | GDK_SHIFT_MASK,
|
||||||
G_TYPE_ENUM, step,
|
"move-cursor",
|
||||||
G_TYPE_INT, count,
|
"(iib)", step, count, TRUE);
|
||||||
G_TYPE_BOOLEAN, TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -633,7 +630,6 @@ gtk_label_class_init (GtkLabelClass *class)
|
|||||||
{
|
{
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
||||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||||
GtkBindingSet *binding_set;
|
|
||||||
|
|
||||||
gobject_class->set_property = gtk_label_set_property;
|
gobject_class->set_property = gtk_label_set_property;
|
||||||
gobject_class->get_property = gtk_label_get_property;
|
gobject_class->get_property = gtk_label_get_property;
|
||||||
@ -1029,117 +1025,107 @@ gtk_label_class_init (GtkLabelClass *class)
|
|||||||
/*
|
/*
|
||||||
* Key bindings
|
* Key bindings
|
||||||
*/
|
*/
|
||||||
binding_set = gtk_binding_set_by_class (class);
|
|
||||||
|
|
||||||
/* Moving the insertion point */
|
/* 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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
GTK_MOVEMENT_WORDS, -1);
|
||||||
|
|
||||||
/* select all */
|
/* select all */
|
||||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK,
|
gtk_widget_class_add_binding (widget_class,
|
||||||
"move-cursor", 3,
|
GDK_KEY_a, GDK_CONTROL_MASK,
|
||||||
G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
|
(GtkShortcutFunc) gtk_label_select_all,
|
||||||
G_TYPE_INT, -1,
|
NULL);
|
||||||
G_TYPE_BOOLEAN, FALSE);
|
gtk_widget_class_add_binding (widget_class,
|
||||||
|
GDK_KEY_slash, GDK_CONTROL_MASK,
|
||||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK,
|
(GtkShortcutFunc) gtk_label_select_all,
|
||||||
"move-cursor", 3,
|
NULL);
|
||||||
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);
|
|
||||||
|
|
||||||
/* unselect all */
|
/* unselect all */
|
||||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
gtk_widget_class_add_binding_signal (widget_class,
|
||||||
"move-cursor", 3,
|
GDK_KEY_a, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
|
||||||
G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
|
"move-cursor",
|
||||||
G_TYPE_INT, 0,
|
"(iib)", GTK_MOVEMENT_PARAGRAPH_ENDS, 0, FALSE);
|
||||||
G_TYPE_BOOLEAN, FALSE);
|
|
||||||
|
|
||||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_backslash, GDK_CONTROL_MASK,
|
gtk_widget_class_add_binding_signal (widget_class,
|
||||||
"move-cursor", 3,
|
GDK_KEY_backslash, GDK_CONTROL_MASK,
|
||||||
G_TYPE_ENUM, GTK_MOVEMENT_PARAGRAPH_ENDS,
|
"move-cursor",
|
||||||
G_TYPE_INT, 0,
|
"(iib)", GTK_MOVEMENT_PARAGRAPH_ENDS, 0, FALSE);
|
||||||
G_TYPE_BOOLEAN, 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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
GTK_MOVEMENT_BUFFER_ENDS, 1);
|
||||||
|
|
||||||
/* copy */
|
/* copy */
|
||||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_c, GDK_CONTROL_MASK,
|
gtk_widget_class_add_binding_signal (widget_class,
|
||||||
"copy-clipboard", 0);
|
GDK_KEY_c, GDK_CONTROL_MASK,
|
||||||
|
"copy-clipboard",
|
||||||
|
NULL);
|
||||||
|
|
||||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Return, 0,
|
gtk_widget_class_add_binding_signal (widget_class,
|
||||||
"activate-current-link", 0);
|
GDK_KEY_Return, 0,
|
||||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_ISO_Enter, 0,
|
"activate-current-link",
|
||||||
"activate-current-link", 0);
|
NULL);
|
||||||
gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Enter, 0,
|
gtk_widget_class_add_binding_signal (widget_class,
|
||||||
"activate-current-link", 0);
|
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_accessible_type (widget_class, GTK_TYPE_LABEL_ACCESSIBLE);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user