[gtk/matthiasc/for-master: 2/2] emojichooser: Allow inserting multiple Emoji
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 2/2] emojichooser: Allow inserting multiple Emoji
- Date: Fri, 2 Oct 2020 03:45:19 +0000 (UTC)
commit da8ee53e2de2d0891f37b72fe434f659ed1b8f33
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Oct 1 23:35:06 2020 -0400
emojichooser: Allow inserting multiple Emoji
Don't close the Emoji chooser when the Control
key is held while clicking. So you can insert
multiple Emoji without having to reopen the
chooser every time.
Fixes: #1002
gtk/gtkemojichooser.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkemojichooser.c b/gtk/gtkemojichooser.c
index 55c8f328ad..e660e6c5aa 100644
--- a/gtk/gtkemojichooser.c
+++ b/gtk/gtkemojichooser.c
@@ -378,6 +378,22 @@ add_recent_item (GtkEmojiChooser *chooser,
g_variant_unref (item);
}
+static gboolean
+should_close (GtkEmojiChooser *chooser)
+{
+ GdkDisplay *display;
+ GdkSeat *seat;
+ GdkDevice *device;
+ GdkModifierType state;
+
+ display = gtk_widget_get_display (GTK_WIDGET (chooser));
+ seat = gdk_display_get_default_seat (display);
+ device = gdk_seat_get_keyboard (seat);
+ state = gdk_device_get_modifier_state (device);
+
+ return (state & GDK_CONTROL_MASK) == 0;
+}
+
static void
emoji_activated (GtkFlowBox *box,
GtkFlowBoxChild *child,
@@ -389,7 +405,16 @@ emoji_activated (GtkFlowBox *box,
GVariant *item;
gunichar modifier;
- gtk_popover_popdown (GTK_POPOVER (chooser));
+ if (should_close (chooser))
+ gtk_popover_popdown (GTK_POPOVER (chooser));
+ else
+ {
+ GtkWidget *popover;
+
+ popover = gtk_widget_get_ancestor (GTK_WIDGET (box), GTK_TYPE_POPOVER);
+ if (popover != GTK_WIDGET (chooser))
+ gtk_popover_popdown (GTK_POPOVER (popover));
+ }
label = gtk_flow_box_child_get_child (child);
text = g_strdup (gtk_label_get_label (GTK_LABEL (label)));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]