forked from AuroraMiddleware/gtk
text: Treat Emoji insertion like clipboard
Enter the Emoji inseration in the undo history. Also, stop stashing away the selection when we pop up the Emoji chooser, and use the selection as-is when we insert the Emoji.
This commit is contained in:
parent
410dbdf671
commit
a838a54dca
@ -6779,20 +6779,23 @@ emoji_picked (GtkEmojiChooser *chooser,
|
|||||||
const char *text,
|
const char *text,
|
||||||
GtkText *self)
|
GtkText *self)
|
||||||
{
|
{
|
||||||
int current_pos;
|
int pos;
|
||||||
int selection_bound;
|
|
||||||
|
|
||||||
current_pos = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (chooser), "current-pos"));
|
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
||||||
selection_bound = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (chooser), "selection-bound"));
|
|
||||||
|
|
||||||
gtk_text_set_positions (self, current_pos, selection_bound);
|
begin_change (self);
|
||||||
gtk_text_enter_text (self, text);
|
if (priv->selection_bound != priv->current_pos)
|
||||||
|
gtk_text_delete_selection (self);
|
||||||
|
|
||||||
|
pos = priv->current_pos;
|
||||||
|
gtk_text_insert_text (self, text, -1, &pos);
|
||||||
|
gtk_text_set_selection_bounds (self, pos, pos);
|
||||||
|
end_change (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_text_insert_emoji (GtkText *self)
|
gtk_text_insert_emoji (GtkText *self)
|
||||||
{
|
{
|
||||||
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
|
||||||
GtkWidget *chooser;
|
GtkWidget *chooser;
|
||||||
|
|
||||||
if (gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_TYPE_EMOJI_CHOOSER) != NULL)
|
if (gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_TYPE_EMOJI_CHOOSER) != NULL)
|
||||||
@ -6808,9 +6811,6 @@ gtk_text_insert_emoji (GtkText *self)
|
|||||||
g_signal_connect (chooser, "emoji-picked", G_CALLBACK (emoji_picked), self);
|
g_signal_connect (chooser, "emoji-picked", G_CALLBACK (emoji_picked), self);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (chooser), "current-pos", GINT_TO_POINTER (priv->current_pos));
|
|
||||||
g_object_set_data (G_OBJECT (chooser), "selection-bound", GINT_TO_POINTER (priv->selection_bound));
|
|
||||||
|
|
||||||
gtk_popover_popup (GTK_POPOVER (chooser));
|
gtk_popover_popup (GTK_POPOVER (chooser));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user