[gtk/shortcuts-rebased-again: 54/171] label: Port bindings to use shortcuts
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/shortcuts-rebased-again: 54/171] label: Port bindings to use shortcuts
- Date: Mon, 24 Jun 2019 23:09:03 +0000 (UTC)
commit e623561d943e161b7dd70de59e87ba7222530393
Author: Benjamin Otte <otte redhat com>
Date: Sun Aug 12 16:55:43 2018 +0200
label: Port bindings to use shortcuts
gtk/gtklabel.c | 142 ++++++++++++++++++++++++++-------------------------------
1 file changed, 64 insertions(+), 78 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 6c867eed71..d1743d53a9 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -26,7 +26,6 @@
#include "gtklabelprivate.h"
-#include "gtkbindings.h"
#include "gtkbuildable.h"
#include "gtkbuilderprivate.h"
#include "gtkcssnodeprivate.h"
@@ -613,7 +612,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,
@@ -621,18 +620,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
@@ -640,7 +637,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;
@@ -1038,117 +1034,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_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);
-
- add_move_binding (binding_set, GDK_KEY_f, GDK_MOD1_MASK,
+ 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_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 (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_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_c, GDK_CONTROL_MASK,
+ "copy-clipboard",
+ NULL);
+
+ 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]