[gtk+] emoji chooser: Make menu key work as expected



commit 1cd5df9404720fbd2600901ad9393942c0aa9709
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Nov 19 18:03:07 2017 -0500

    emoji chooser: Make menu key work as expected
    
    Whenever we have a right-click action, we should make
    the menu key work as a keyboard-accessible alternative.

 gtk/gtkemojichooser.c |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkemojichooser.c b/gtk/gtkemojichooser.c
index eff0bb6..ce9708f 100644
--- a/gtk/gtkemojichooser.c
+++ b/gtk/gtkemojichooser.c
@@ -126,7 +126,8 @@ static void
 add_emoji (GtkWidget    *box,
            gboolean      prepend,
            GVariant     *item,
-           gunichar      modifier);
+           gunichar      modifier,
+           GtkEmojiChooser *chooser);
 
 #define MAX_RECENT (7*3)
 
@@ -146,7 +147,7 @@ populate_recent_section (GtkEmojiChooser *chooser)
 
       emoji_data = g_variant_get_child_value (item, 0);
       g_variant_get_child (item, 1, "u", &modifier);
-      add_emoji (chooser->recent.box, FALSE, emoji_data, modifier);
+      add_emoji (chooser->recent.box, FALSE, emoji_data, modifier, chooser);
       g_variant_unref (emoji_data);
       g_variant_unref (item);
     }
@@ -189,7 +190,7 @@ add_recent_item (GtkEmojiChooser *chooser,
     }
   g_list_free (children);
 
-  add_emoji (chooser->recent.box, TRUE, item, modifier);
+  add_emoji (chooser->recent.box, TRUE, item, modifier, chooser);
 
   g_settings_set_value (chooser->settings, "recent-emoji", g_variant_builder_end (&builder));
 
@@ -272,9 +273,9 @@ show_variations (GtkEmojiChooser *chooser,
 
   g_signal_connect (box, "child-activated", G_CALLBACK (emoji_activated), parent_popover);
 
-  add_emoji (box, FALSE, emoji_data, 0);
+  add_emoji (box, FALSE, emoji_data, 0, NULL);
   for (modifier = 0x1f3fb; modifier <= 0x1f3ff; modifier++)
-    add_emoji (box, FALSE, emoji_data, modifier);
+    add_emoji (box, FALSE, emoji_data, modifier, NULL);
 
   gtk_popover_popup (GTK_POPOVER (popover));
 }
@@ -310,11 +311,22 @@ pressed_cb (GtkGesture *gesture,
   show_variations (chooser, child);
 }
 
+static gboolean
+popup_menu (GtkWidget *widget,
+            gpointer   data)
+{
+  GtkEmojiChooser *chooser = data;
+
+  show_variations (chooser, widget);
+  return TRUE;
+}
+
 static void
 add_emoji (GtkWidget    *box,
            gboolean      prepend,
            GVariant     *item,
-           gunichar      modifier)
+           gunichar      modifier,
+           GtkEmojiChooser *chooser)
 {
   GtkWidget *child;
   GtkWidget *label;
@@ -352,6 +364,9 @@ add_emoji (GtkWidget    *box,
   if (modifier != 0)
     g_object_set_data (G_OBJECT (child), "modifier", GUINT_TO_POINTER (modifier));
 
+  if (chooser)
+    g_signal_connect (child, "popup-menu", G_CALLBACK (popup_menu), chooser);
+
   gtk_container_add (GTK_CONTAINER (child), label);
   gtk_flow_box_insert (GTK_FLOW_BOX (box), child, prepend ? 0 : -1);
 }
@@ -392,7 +407,7 @@ populate_emoji_chooser (GtkEmojiChooser *chooser)
       else if (strcmp (name, chooser->flags.first) == 0)
         box = chooser->flags.box;
 
-      add_emoji (box, FALSE, item, 0);
+      add_emoji (box, FALSE, item, 0, chooser);
       g_variant_unref (item);
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]