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
This commit is contained in:
Matthias Clasen 2020-06-26 22:13:12 -04:00
parent 64db05d3dd
commit c20a966f06

View File

@ -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);
}