[gtk/wip/matthiasc/context-menu: 1051/1062] text: Add a context action for visibility
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/context-menu: 1051/1062] text: Add a context action for visibility
- Date: Mon, 10 Jun 2019 15:32:06 +0000 (UTC)
commit d9457dc842d5e69b152418239da5f2d8261fdfe1
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Apr 11 14:47:20 2019 -0400
text: Add a context action for visibility
This will be used by GtkPasswordEntry for amending
the context menu.
gtk/gtktext.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
---
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 682dda29b9..532f2f91ff 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -5212,10 +5212,15 @@ gtk_text_set_visibility (GtkText *self,
if (priv->visible != visible)
{
+ GAction *action;
+
priv->visible = visible;
g_object_notify (G_OBJECT (self), "visibility");
gtk_text_recompute (self);
+
+ action = g_action_map_lookup_action (priv->context_actions, "toggle-visibility");
+ g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_boolean (visible));
}
}
@@ -5613,6 +5618,15 @@ insert_emoji_activated (GSimpleAction *action,
hide_selection_bubble (GTK_TEXT (user_data));
}
+static void
+toggle_visibility (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GtkText *text = GTK_TEXT (user_data);
+ gtk_text_set_visibility (text, !gtk_text_get_visibility (text));
+}
+
static void
gtk_text_add_context_actions (GtkText *self)
{
@@ -5625,6 +5639,7 @@ gtk_text_add_context_actions (GtkText *self)
{ "delete-selection", delete_selection_activated, NULL, NULL, NULL },
{ "select-all", select_all_activated, NULL, NULL, NULL },
{ "insert-emoji", insert_emoji_activated, NULL, NULL, NULL },
+ { "toggle-visibility", toggle_visibility, NULL, "true", NULL },
};
GSimpleActionGroup *actions = g_simple_action_group_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]