mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-01 16:30:15 +00:00
emoji chooser: handle right-click
Whereever we handle long-press for touch, it makes sense to handle right-click as a faster alternative for mouse-based interaction. This commit makes right-click work to bring up the variation selector for Emojis.
This commit is contained in:
parent
4d0a57fe0b
commit
5e748ce940
@ -28,6 +28,7 @@
|
|||||||
#include "gtkstack.h"
|
#include "gtkstack.h"
|
||||||
#include "gtklabel.h"
|
#include "gtklabel.h"
|
||||||
#include "gtkgesturelongpress.h"
|
#include "gtkgesturelongpress.h"
|
||||||
|
#include "gtkgesturemultipress.h"
|
||||||
#include "gtkpopover.h"
|
#include "gtkpopover.h"
|
||||||
#include "gtkscrolledwindow.h"
|
#include "gtkscrolledwindow.h"
|
||||||
#include "gtkintl.h"
|
#include "gtkintl.h"
|
||||||
@ -61,9 +62,12 @@ struct _GtkEmojiChooser
|
|||||||
EmojiSection symbols;
|
EmojiSection symbols;
|
||||||
EmojiSection flags;
|
EmojiSection flags;
|
||||||
|
|
||||||
GtkGesture *recent_press;
|
GtkGesture *recent_long_press;
|
||||||
GtkGesture *people_press;
|
GtkGesture *recent_multi_press;
|
||||||
GtkGesture *body_press;
|
GtkGesture *people_long_press;
|
||||||
|
GtkGesture *people_multi_press;
|
||||||
|
GtkGesture *body_long_press;
|
||||||
|
GtkGesture *body_multi_press;
|
||||||
|
|
||||||
GVariant *data;
|
GVariant *data;
|
||||||
|
|
||||||
@ -91,9 +95,12 @@ gtk_emoji_chooser_finalize (GObject *object)
|
|||||||
g_variant_unref (chooser->data);
|
g_variant_unref (chooser->data);
|
||||||
g_object_unref (chooser->settings);
|
g_object_unref (chooser->settings);
|
||||||
|
|
||||||
g_clear_object (&chooser->recent_press);
|
g_clear_object (&chooser->recent_long_press);
|
||||||
g_clear_object (&chooser->people_press);
|
g_clear_object (&chooser->recent_multi_press);
|
||||||
g_clear_object (&chooser->body_press);
|
g_clear_object (&chooser->people_long_press);
|
||||||
|
g_clear_object (&chooser->people_multi_press);
|
||||||
|
g_clear_object (&chooser->body_long_press);
|
||||||
|
g_clear_object (&chooser->body_multi_press);
|
||||||
|
|
||||||
G_OBJECT_CLASS (gtk_emoji_chooser_parent_class)->finalize (object);
|
G_OBJECT_CLASS (gtk_emoji_chooser_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
@ -214,12 +221,9 @@ emoji_activated (GtkFlowBox *box,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
long_pressed_cb (GtkGesture *gesture,
|
show_variations (GtkEmojiChooser *chooser,
|
||||||
double x,
|
GtkWidget *child)
|
||||||
double y,
|
|
||||||
gpointer data)
|
|
||||||
{
|
{
|
||||||
GtkWidget *child;
|
|
||||||
GtkWidget *popover;
|
GtkWidget *popover;
|
||||||
GtkWidget *view;
|
GtkWidget *view;
|
||||||
GtkWidget *box;
|
GtkWidget *box;
|
||||||
@ -230,8 +234,6 @@ long_pressed_cb (GtkGesture *gesture,
|
|||||||
gboolean has_variations;
|
gboolean has_variations;
|
||||||
gunichar modifier;
|
gunichar modifier;
|
||||||
|
|
||||||
box = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
|
|
||||||
child = GTK_WIDGET (gtk_flow_box_get_child_at_pos (GTK_FLOW_BOX (box), x, y));
|
|
||||||
if (!child)
|
if (!child)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -277,6 +279,37 @@ long_pressed_cb (GtkGesture *gesture,
|
|||||||
gtk_popover_popup (GTK_POPOVER (popover));
|
gtk_popover_popup (GTK_POPOVER (popover));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
long_pressed_cb (GtkGesture *gesture,
|
||||||
|
double x,
|
||||||
|
double y,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GtkEmojiChooser *chooser = data;
|
||||||
|
GtkWidget *box;
|
||||||
|
GtkWidget *child;
|
||||||
|
|
||||||
|
box = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
|
||||||
|
child = GTK_WIDGET (gtk_flow_box_get_child_at_pos (GTK_FLOW_BOX (box), x, y));
|
||||||
|
show_variations (chooser, child);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pressed_cb (GtkGesture *gesture,
|
||||||
|
int n_press,
|
||||||
|
double x,
|
||||||
|
double y,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GtkEmojiChooser *chooser = data;
|
||||||
|
GtkWidget *box;
|
||||||
|
GtkWidget *child;
|
||||||
|
|
||||||
|
box = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
|
||||||
|
child = GTK_WIDGET (gtk_flow_box_get_child_at_pos (GTK_FLOW_BOX (box), x, y));
|
||||||
|
show_variations (chooser, child);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_emoji (GtkWidget *box,
|
add_emoji (GtkWidget *box,
|
||||||
gboolean prepend,
|
gboolean prepend,
|
||||||
@ -542,14 +575,23 @@ gtk_emoji_chooser_init (GtkEmojiChooser *chooser)
|
|||||||
|
|
||||||
gtk_widget_init_template (GTK_WIDGET (chooser));
|
gtk_widget_init_template (GTK_WIDGET (chooser));
|
||||||
|
|
||||||
chooser->recent_press = gtk_gesture_long_press_new (chooser->recent.box);
|
chooser->recent_long_press = gtk_gesture_long_press_new (chooser->recent.box);
|
||||||
g_signal_connect (chooser->recent_press, "pressed", G_CALLBACK (long_pressed_cb), chooser);
|
g_signal_connect (chooser->recent_long_press, "pressed", G_CALLBACK (long_pressed_cb), chooser);
|
||||||
|
chooser->recent_multi_press = gtk_gesture_multi_press_new (chooser->recent.box);
|
||||||
|
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (chooser->recent_multi_press), GDK_BUTTON_SECONDARY);
|
||||||
|
g_signal_connect (chooser->recent_multi_press, "pressed", G_CALLBACK (pressed_cb), chooser);
|
||||||
|
|
||||||
chooser->people_press = gtk_gesture_long_press_new (chooser->people.box);
|
chooser->people_long_press = gtk_gesture_long_press_new (chooser->people.box);
|
||||||
g_signal_connect (chooser->people_press, "pressed", G_CALLBACK (long_pressed_cb), chooser);
|
g_signal_connect (chooser->people_long_press, "pressed", G_CALLBACK (long_pressed_cb), chooser);
|
||||||
|
chooser->people_multi_press = gtk_gesture_multi_press_new (chooser->people.box);
|
||||||
|
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (chooser->people_multi_press), GDK_BUTTON_SECONDARY);
|
||||||
|
g_signal_connect (chooser->people_multi_press, "pressed", G_CALLBACK (pressed_cb), chooser);
|
||||||
|
|
||||||
chooser->body_press = gtk_gesture_long_press_new (chooser->body.box);
|
chooser->body_long_press = gtk_gesture_long_press_new (chooser->body.box);
|
||||||
g_signal_connect (chooser->body_press, "pressed", G_CALLBACK (long_pressed_cb), chooser);
|
g_signal_connect (chooser->body_long_press, "pressed", G_CALLBACK (long_pressed_cb), chooser);
|
||||||
|
chooser->body_multi_press = gtk_gesture_multi_press_new (chooser->body.box);
|
||||||
|
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (chooser->body_multi_press), GDK_BUTTON_SECONDARY);
|
||||||
|
g_signal_connect (chooser->body_multi_press, "pressed", G_CALLBACK (pressed_cb), chooser);
|
||||||
|
|
||||||
adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (chooser->scrolled_window));
|
adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (chooser->scrolled_window));
|
||||||
g_signal_connect (adj, "value-changed", G_CALLBACK (adj_value_changed), chooser);
|
g_signal_connect (adj, "value-changed", G_CALLBACK (adj_value_changed), chooser);
|
||||||
|
Loading…
Reference in New Issue
Block a user