mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 14:31:10 +00:00
Merge branch 'emoji-insert-fix' into 'master'
textview: Make insert-emoji replace the selection Closes #2996 See merge request GNOME/gtk!2350
This commit is contained in:
commit
89c10e092a
@ -9616,6 +9616,21 @@ gtk_text_view_get_monospace (GtkTextView *text_view)
|
||||
return gtk_widget_has_css_class (GTK_WIDGET (text_view), GTK_STYLE_CLASS_MONOSPACE);
|
||||
}
|
||||
|
||||
static void
|
||||
emoji_picked (GtkEmojiChooser *chooser,
|
||||
const char *text,
|
||||
GtkTextView *self)
|
||||
{
|
||||
GtkTextBuffer *buffer;
|
||||
|
||||
buffer = get_buffer (self);
|
||||
|
||||
gtk_text_buffer_begin_user_action (buffer);
|
||||
gtk_text_buffer_delete_selection (buffer, TRUE, TRUE);
|
||||
gtk_text_buffer_insert_at_cursor (buffer, text, -1);
|
||||
gtk_text_buffer_end_user_action (buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_text_view_insert_emoji (GtkTextView *text_view)
|
||||
{
|
||||
@ -9634,8 +9649,7 @@ gtk_text_view_insert_emoji (GtkTextView *text_view)
|
||||
g_object_set_data (G_OBJECT (text_view), "gtk-emoji-chooser", chooser);
|
||||
|
||||
gtk_widget_set_parent (chooser, GTK_WIDGET (text_view));
|
||||
g_signal_connect_swapped (chooser, "emoji-picked",
|
||||
G_CALLBACK (gtk_text_view_insert_at_cursor), text_view);
|
||||
g_signal_connect (chooser, "emoji-picked", G_CALLBACK (emoji_picked), text_view);
|
||||
}
|
||||
|
||||
buffer = get_buffer (text_view);
|
||||
|
Loading…
Reference in New Issue
Block a user