[gtk/matthiasc/for-master: 4/4] text: Update action enabled state correctly



commit c20a966f06256b1e8b8cc7663151a0a9760a0265
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jun 26 22:13:12 2020 -0400

    text: Update action enabled state correctly
    
    Take the editable property into account when updating
    the emoji.insert action state, and update the action
    when it changes.
    
    Fixes: #2897

 gtk/gtktext.c | 7 +++++++
 1 file changed, 7 insertions(+)
---
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index ff6fde8e5b..1ba21144c1 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -2627,6 +2627,7 @@ gtk_text_do_popup (GtkText *self,
   GtkTextPrivate *priv = gtk_text_get_instance_private (self);
 
   gtk_text_update_clipboard_actions (self);
+  gtk_text_update_emoji_action (self);
 
   if (!priv->popup_menu)
     {
@@ -5397,6 +5398,9 @@ gtk_text_set_editable (GtkText  *self,
       gtk_event_controller_key_set_im_context (GTK_EVENT_CONTROLLER_KEY (priv->key_controller),
                                                is_editable ? priv->im_context : NULL);
 
+      gtk_text_update_clipboard_actions (self);
+      gtk_text_update_emoji_action (self);
+
       g_object_notify (G_OBJECT (self), "editable");
     }
 }
@@ -5909,7 +5913,10 @@ gtk_text_update_clipboard_actions (GtkText *self)
 static void
 gtk_text_update_emoji_action (GtkText *self)
 {
+  GtkTextPrivate *priv = gtk_text_get_instance_private (self);
+
   gtk_widget_action_set_enabled (GTK_WIDGET (self), "misc.insert-emoji",
+                                 priv->editable &&
                                  (gtk_text_get_input_hints (self) & GTK_INPUT_HINT_NO_EMOJI) == 0);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]