forked from AuroraMiddleware/gtk
textview: Make insert-emoji replace the selection
This is the expected behavior, and matches what GtkText does. Fixes: #2996
This commit is contained in:
parent
0d98bab82b
commit
348a38a876
@ -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);
|
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
|
static void
|
||||||
gtk_text_view_insert_emoji (GtkTextView *text_view)
|
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);
|
g_object_set_data (G_OBJECT (text_view), "gtk-emoji-chooser", chooser);
|
||||||
|
|
||||||
gtk_widget_set_parent (chooser, GTK_WIDGET (text_view));
|
gtk_widget_set_parent (chooser, GTK_WIDGET (text_view));
|
||||||
g_signal_connect_swapped (chooser, "emoji-picked",
|
g_signal_connect (chooser, "emoji-picked", G_CALLBACK (emoji_picked), text_view);
|
||||||
G_CALLBACK (gtk_text_view_insert_at_cursor), text_view);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = get_buffer (text_view);
|
buffer = get_buffer (text_view);
|
||||||
|
Loading…
Reference in New Issue
Block a user