[gtk/shortcuts-rebased-again: 130/171] text: Add more actions
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/shortcuts-rebased-again: 130/171] text: Add more actions
- Date: Mon, 24 Jun 2019 23:15:25 +0000 (UTC)
commit 9039d0b0c1fd9ab5d5bda65f77c656ad3fd6349b
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jun 21 20:24:13 2019 +0000
text: Add more actions
These will let us port more bindings to actions.
gtk/gtktext.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 95 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index d5767210fc..f694e44b11 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -544,6 +544,9 @@ static void emit_changed (GtkText *self);
static void gtk_text_update_clipboard_actions (GtkText *self);
static void gtk_text_update_emoji_action (GtkText *self);
+static void gtk_text_activate_default_activate (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameter);
static void gtk_text_activate_clipboard_cut (GtkWidget *widget,
const char *action_name,
GVariant *parameter);
@@ -559,6 +562,18 @@ static void gtk_text_activate_selection_delete (GtkWidget *widget,
static void gtk_text_activate_selection_select_all (GtkWidget *widget,
const char *action_name,
GVariant *parameter);
+static void gtk_text_activate_edit_move_cursor (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameter);
+static void gtk_text_activate_edit_insert_at_cursor (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameter);
+static void gtk_text_activate_edit_delete_from_cursor (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameter);
+static void gtk_text_activate_edit_backspace (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameter);
static void gtk_text_activate_misc_insert_emoji (GtkWidget *widget,
const char *action_name,
GVariant *parameter);
@@ -1175,6 +1190,8 @@ gtk_text_class_init (GtkTextClass *class)
/* Actions */
+ gtk_widget_class_install_action (widget_class, "default.activate",
+ gtk_text_activate_default_activate);
gtk_widget_class_install_action (widget_class, "clipboard.cut", NULL,
gtk_text_activate_clipboard_cut);
gtk_widget_class_install_action (widget_class, "clipboard.copy", NULL,
@@ -1190,6 +1207,17 @@ gtk_text_class_init (GtkTextClass *class)
gtk_widget_class_install_property_action (widget_class,
"misc.toggle-visibility",
"visibility");
+ gtk_widget_class_install_property_action (widget_class,
+ "misc.toggle-overwrite",
+ "overwrite-mode");
+ gtk_widget_class_install_action (widget_class, "edit.move-cursor", "(iib)",
+ gtk_text_activate_edit_move_cursor);
+ gtk_widget_class_install_action (widget_class, "edit.insert-at-cursor", "s",
+ gtk_text_activate_edit_insert_at_cursor);
+ gtk_widget_class_install_action (widget_class, "edit.delete-from-cursor", "(ii)",
+ gtk_text_activate_edit_delete_from_cursor);
+ gtk_widget_class_install_action (widget_class, "edit.backspace", NULL,
+ gtk_text_activate_edit_backspace);
/* Key bindings */
@@ -1252,7 +1280,7 @@ gtk_text_class_init (GtkTextClass *class)
"selection.select-all",
NULL);
- /* Unselect all
+ /* Unselect all
*/
gtk_widget_class_add_binding_signal (widget_class,
GDK_KEY_backslash, GDK_CONTROL_MASK,
@@ -1285,7 +1313,7 @@ gtk_text_class_init (GtkTextClass *class)
GDK_KEY_KP_Delete, 0,
"delete-from-cursor",
"(ii)", GTK_DELETE_CHARS, 1);
-
+
gtk_widget_class_add_binding_signal (widget_class,
GDK_KEY_BackSpace, 0,
"backspace",
@@ -5656,6 +5684,18 @@ hide_selection_bubble (GtkText *self)
gtk_widget_hide (priv->selection_bubble);
}
+static void
+gtk_text_activate_default_activate (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameter)
+{
+ GtkText *self = GTK_TEXT (widget);
+ GtkTextPrivate *priv = gtk_text_get_instance_private (self);
+
+ if (priv->activates_default)
+ gtk_widget_activate_default (gtk_widget_get_parent (widget));
+}
+
static void
gtk_text_activate_clipboard_cut (GtkWidget *widget,
const char *action_name,
@@ -5701,8 +5741,59 @@ gtk_text_activate_selection_select_all (GtkWidget *widget,
const char *action_name,
GVariant *parameter)
{
- GtkText *self = GTK_TEXT (widget);
- gtk_text_select_all (self);
+ gtk_text_select_all (GTK_TEXT (widget));
+}
+
+static void
+gtk_text_activate_edit_move_cursor (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameter)
+{
+ GtkMovementStep step;
+ int count;
+ gboolean extend;
+
+ g_variant_get (parameter, "(iib)", &step, &count, &extend);
+
+ step = CLAMP (step, GTK_MOVEMENT_LOGICAL_POSITIONS,
+ GTK_MOVEMENT_HORIZONTAL_PAGES);
+
+ gtk_text_move_cursor (GTK_TEXT (widget), step, count, extend);
+}
+
+static void
+gtk_text_activate_edit_insert_at_cursor (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameter)
+{
+ const char *str;
+
+ g_variant_get (parameter, "(&s)", &str);
+ gtk_text_insert_at_cursor (GTK_TEXT (widget), str);
+}
+
+static void
+gtk_text_activate_edit_delete_from_cursor (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameter)
+{
+ GtkDeleteType type;
+ int count;
+
+ g_variant_get (parameter, "(ii)", &type, &count);
+
+ type = CLAMP (type, GTK_DELETE_CHARS,
+ GTK_DELETE_WHITESPACE);
+
+ gtk_text_delete_from_cursor (GTK_TEXT (widget), type, count);
+}
+
+static void
+gtk_text_activate_edit_backspace (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameter)
+{
+ gtk_text_backspace (GTK_TEXT (widget));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]