Commit 4ddc94b2 authored by Benjamin Otte's avatar Benjamin Otte Committed by Carlos Garnacho

multipressgesture: Port to new API model

parent 71991270
......@@ -321,10 +321,10 @@ do_clipboard (GtkWidget *do_widget)
G_CALLBACK (drag_data_received), image);
/* context menu on image */
gesture = gtk_gesture_multi_press_new (image);
gesture = gtk_gesture_multi_press_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);
g_object_set_data_full (G_OBJECT (image), "gesture", gesture, g_object_unref);
g_signal_connect (gesture, "pressed", G_CALLBACK (pressed_cb), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (gesture));
/* Create the second image */
image = gtk_image_new_from_icon_name ("process-stop");
......@@ -346,10 +346,10 @@ do_clipboard (GtkWidget *do_widget)
G_CALLBACK (drag_data_received), image);
/* context menu on image */
gesture = gtk_gesture_multi_press_new (image);
gesture = gtk_gesture_multi_press_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);
g_object_set_data_full (G_OBJECT (image), "gesture", gesture, g_object_unref);
g_signal_connect (gesture, "pressed", G_CALLBACK (pressed_cb), image);
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (gesture));
}
if (!gtk_widget_get_visible (window))
......
......@@ -356,10 +356,11 @@ do_dnd (GtkWidget *do_widget)
gtk_widget_set_hexpand (fixed, TRUE);
gtk_widget_set_vexpand (fixed, TRUE);
multipress = gtk_gesture_multi_press_new (fixed);
multipress = gtk_gesture_multi_press_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (multipress), 0);
g_signal_connect (multipress, "pressed", G_CALLBACK (pressed_cb), NULL);
g_signal_connect (multipress, "released", G_CALLBACK (released_cb), NULL);
gtk_widget_add_controller (fixed, GTK_EVENT_CONTROLLER (multipress));
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/dnd/dnd.css");
......
......@@ -165,9 +165,9 @@ activate (GtkApplication *app,
g_signal_connect (drag, "drag-update", G_CALLBACK (drag_update), drawing_area);
g_signal_connect (drag, "drag-end", G_CALLBACK (drag_end), drawing_area);
press = gtk_gesture_multi_press_new (drawing_area);
press = gtk_gesture_multi_press_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (press), GDK_BUTTON_SECONDARY);
g_object_set_data_full (G_OBJECT (drawing_area), "press", press, g_object_unref);
gtk_widget_add_controller (drawing_area, GTK_EVENT_CONTROLLER (press));
g_signal_connect (press, "pressed", G_CALLBACK (pressed), drawing_area);
......
......@@ -97,7 +97,6 @@ struct _GtkAppChooserWidgetPrivate {
GAppInfoMonitor *monitor;
GtkWidget *popup_menu;
GtkGesture *multipress_gesture;
};
enum {
......@@ -886,7 +885,6 @@ gtk_app_chooser_widget_finalize (GObject *object)
g_free (self->priv->default_text);
g_signal_handlers_disconnect_by_func (self->priv->monitor, app_info_changed, self);
g_object_unref (self->priv->monitor);
g_object_unref (self->priv->multipress_gesture);
G_OBJECT_CLASS (gtk_app_chooser_widget_parent_class)->finalize (object);
}
......@@ -1139,6 +1137,7 @@ gtk_app_chooser_widget_init (GtkAppChooserWidget *self)
{
GtkTreeSelection *selection;
GtkTreeModel *sort;
GtkGesture *gesture;
self->priv = gtk_app_chooser_widget_get_instance_private (self);
......@@ -1176,10 +1175,11 @@ gtk_app_chooser_widget_init (GtkAppChooserWidget *self)
g_signal_connect (self->priv->monitor, "changed",
G_CALLBACK (app_info_changed), self);
self->priv->multipress_gesture = gtk_gesture_multi_press_new (self->priv->program_list);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (self->priv->multipress_gesture), GDK_BUTTON_SECONDARY);
g_signal_connect (self->priv->multipress_gesture, "pressed",
gesture = gtk_gesture_multi_press_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);
g_signal_connect (gesture, "pressed",
G_CALLBACK (gtk_app_chooser_row_pressed_cb), self);
gtk_widget_add_controller (self->priv->program_list, GTK_EVENT_CONTROLLER (gesture));
}
static GAppInfo *
......
......@@ -124,7 +124,6 @@ enum {
};
static void gtk_button_finalize (GObject *object);
static void gtk_button_dispose (GObject *object);
static void gtk_button_set_property (GObject *object,
guint prop_id,
......@@ -215,7 +214,6 @@ gtk_button_class_init (GtkButtonClass *klass)
container_class = GTK_CONTAINER_CLASS (klass);
gobject_class->dispose = gtk_button_dispose;
gobject_class->finalize = gtk_button_finalize;
gobject_class->set_property = gtk_button_set_property;
gobject_class->get_property = gtk_button_get_property;
......@@ -442,7 +440,7 @@ gtk_button_init (GtkButton *button)
priv->use_underline = FALSE;
priv->child_type = WIDGET_CHILD;
priv->gesture = gtk_gesture_multi_press_new (GTK_WIDGET (button));
priv->gesture = gtk_gesture_multi_press_new ();
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->gesture), FALSE);
gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (priv->gesture), TRUE);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->gesture), GDK_BUTTON_PRIMARY);
......@@ -451,18 +449,7 @@ gtk_button_init (GtkButton *button)
g_signal_connect (priv->gesture, "update", G_CALLBACK (multipress_gesture_update_cb), button);
g_signal_connect (priv->gesture, "cancel", G_CALLBACK (multipress_gesture_cancel_cb), button);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->gesture), GTK_PHASE_CAPTURE);
}
static void
gtk_button_finalize (GObject *object)
{
GtkButton *button = GTK_BUTTON (object);
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
g_clear_object (&priv->gesture);
G_OBJECT_CLASS (gtk_button_parent_class)->finalize (object);
gtk_widget_add_controller (GTK_WIDGET (button), GTK_EVENT_CONTROLLER (priv->gesture));
}
static void
......
......@@ -249,7 +249,6 @@ struct _GtkCalendarPrivate
gint detail_width_chars;
gint detail_overflow[6];
GtkGesture *press_gesture;
GtkGesture *drag_gesture;
GtkEventController *scroll_controller;
GtkEventController *key_controller;
......@@ -643,6 +642,7 @@ static void
gtk_calendar_init (GtkCalendar *calendar)
{
GtkWidget *widget = GTK_WIDGET (calendar);
GtkGesture *gesture;
time_t secs;
struct tm *tm;
gint i;
......@@ -672,9 +672,10 @@ gtk_calendar_init (GtkCalendar *calendar)
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (calendar)),
GTK_STYLE_CLASS_VIEW);
priv->press_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (calendar));
g_signal_connect (priv->press_gesture, "pressed", G_CALLBACK (gtk_calendar_button_press), calendar);
g_signal_connect (priv->press_gesture, "released", G_CALLBACK (gtk_calendar_button_release), calendar);
gesture = gtk_gesture_multi_press_new ();
g_signal_connect (gesture, "pressed", G_CALLBACK (gtk_calendar_button_press), calendar);
g_signal_connect (gesture, "released", G_CALLBACK (gtk_calendar_button_release), calendar);
gtk_widget_add_controller (GTK_WIDGET (calendar), GTK_EVENT_CONTROLLER (gesture));
priv->drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (calendar));
g_signal_connect (priv->drag_gesture, "drag-begin", G_CALLBACK (gtk_calendar_drag_begin), calendar);
......@@ -1332,7 +1333,6 @@ gtk_calendar_finalize (GObject *object)
{
GtkCalendarPrivate *priv = GTK_CALENDAR (object)->priv;
g_object_unref (priv->press_gesture);
g_object_unref (priv->drag_gesture);
g_object_unref (priv->scroll_controller);
g_object_unref (priv->key_controller);
......
......@@ -66,7 +66,6 @@ struct _GtkColorSwatchPrivate
guint has_menu : 1;
GtkGesture *long_press_gesture;
GtkGesture *multipress_gesture;
GtkEventController *key_controller;
GtkWidget *overlay_widget;
......@@ -505,7 +504,6 @@ swatch_dispose (GObject *object)
}
g_clear_object (&swatch->priv->long_press_gesture);
g_clear_object (&swatch->priv->multipress_gesture);
g_clear_object (&swatch->priv->key_controller);
G_OBJECT_CLASS (gtk_color_swatch_parent_class)->dispose (object);
......@@ -562,6 +560,8 @@ gtk_color_swatch_class_init (GtkColorSwatchClass *class)
static void
gtk_color_swatch_init (GtkColorSwatch *swatch)
{
GtkGesture *gesture;
swatch->priv = gtk_color_swatch_get_instance_private (swatch);
swatch->priv->use_alpha = TRUE;
swatch->priv->selectable = TRUE;
......@@ -576,10 +576,11 @@ gtk_color_swatch_init (GtkColorSwatch *swatch)
g_signal_connect (swatch->priv->long_press_gesture, "pressed",
G_CALLBACK (hold_action), swatch);
swatch->priv->multipress_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (swatch));
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (swatch->priv->multipress_gesture), 0);
g_signal_connect (swatch->priv->multipress_gesture, "pressed",
gesture = gtk_gesture_multi_press_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
g_signal_connect (gesture, "pressed",
G_CALLBACK (tap_action), swatch);
gtk_widget_add_controller (GTK_WIDGET (swatch), GTK_EVENT_CONTROLLER (gesture));
swatch->priv->key_controller = gtk_event_controller_key_new (GTK_WIDGET (swatch));
g_signal_connect (swatch->priv->key_controller, "key-pressed",
......
......@@ -213,7 +213,6 @@ struct _GtkEntryPrivate
GtkWidget *magnifier;
GtkGesture *drag_gesture;
GtkGesture *multipress_gesture;
GtkEventController *motion_controller;
GtkEventController *key_controller;
......@@ -2517,6 +2516,7 @@ gtk_entry_init (GtkEntry *entry)
{
GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
GtkCssNode *widget_node;
GtkGesture *gesture;
gint i;
gtk_widget_set_can_focus (GTK_WIDGET (entry), TRUE);
......@@ -2565,11 +2565,12 @@ gtk_entry_init (GtkEntry *entry)
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->drag_gesture), 0);
gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (priv->drag_gesture), TRUE);
priv->multipress_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (entry));
g_signal_connect (priv->multipress_gesture, "pressed",
gesture = gtk_gesture_multi_press_new ();
g_signal_connect (gesture, "pressed",
G_CALLBACK (gtk_entry_multipress_gesture_pressed), entry);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->multipress_gesture), 0);
gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (priv->multipress_gesture), TRUE);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (gesture), TRUE);
gtk_widget_add_controller (GTK_WIDGET (entry), GTK_EVENT_CONTROLLER (gesture));
priv->motion_controller = gtk_event_controller_motion_new (GTK_WIDGET (entry));
g_signal_connect (priv->motion_controller, "motion",
......@@ -2796,7 +2797,6 @@ gtk_entry_finalize (GObject *object)
g_free (priv->im_module);
g_clear_object (&priv->drag_gesture);
g_clear_object (&priv->multipress_gesture);
g_clear_object (&priv->motion_controller);
if (priv->tabs)
......
......@@ -155,8 +155,6 @@ struct _GtkExpanderPrivate
GtkWidget *arrow_widget;
GtkWidget *child;
GtkGesture *multipress_gesture;
guint expand_timer;
guint expanded : 1;
......@@ -338,6 +336,7 @@ static void
gtk_expander_init (GtkExpander *expander)
{
GtkExpanderPrivate *priv = gtk_expander_get_instance_private (expander);
GtkGesture *gesture;
gtk_widget_set_can_focus (GTK_WIDGET (expander), TRUE);
gtk_widget_set_has_surface (GTK_WIDGET (expander), FALSE);
......@@ -367,15 +366,16 @@ gtk_expander_init (GtkExpander *expander)
gtk_drag_dest_set (GTK_WIDGET (expander), 0, NULL, 0);
gtk_drag_dest_set_track_motion (GTK_WIDGET (expander), TRUE);
priv->multipress_gesture = gtk_gesture_multi_press_new (priv->title_widget);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->multipress_gesture),
gesture = gtk_gesture_multi_press_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture),
GDK_BUTTON_PRIMARY);
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->multipress_gesture),
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture),
FALSE);
g_signal_connect (priv->multipress_gesture, "released",
g_signal_connect (gesture, "released",
G_CALLBACK (gesture_multipress_released_cb), expander);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->multipress_gesture),
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
GTK_PHASE_BUBBLE);
gtk_widget_add_controller (GTK_WIDGET (priv->title_widget), GTK_EVENT_CONTROLLER (gesture));
}
static GtkBuildableIface *parent_buildable_iface;
......@@ -491,8 +491,6 @@ gtk_expander_destroy (GtkWidget *widget)
priv->arrow_widget = NULL;
}
g_clear_object (&priv->multipress_gesture);
GTK_WIDGET_CLASS (gtk_expander_parent_class)->destroy (widget);
}
......
......@@ -665,7 +665,6 @@ struct _GtkFlowBoxPrivate {
gpointer sort_data;
GDestroyNotify sort_destroy;
GtkGesture *multipress_gesture;
GtkGesture *drag_gesture;
GtkEventController *key_controller;
......@@ -3379,7 +3378,6 @@ gtk_flow_box_finalize (GObject *obj)
g_clear_object (&priv->vadjustment);
g_object_unref (priv->drag_gesture);
g_object_unref (priv->multipress_gesture);
g_object_unref (priv->key_controller);
if (priv->bound_model)
......@@ -3727,6 +3725,7 @@ static void
gtk_flow_box_init (GtkFlowBox *box)
{
GtkFlowBoxPrivate *priv = BOX_PRIV (box);
GtkGesture *gesture;
gtk_widget_set_has_surface (GTK_WIDGET (box), FALSE);
......@@ -3741,21 +3740,22 @@ gtk_flow_box_init (GtkFlowBox *box)
priv->children = g_sequence_new (NULL);
priv->multipress_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (box));
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->multipress_gesture),
gesture = gtk_gesture_multi_press_new ();
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture),
FALSE);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->multipress_gesture),
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture),
GDK_BUTTON_PRIMARY);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->multipress_gesture),
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
GTK_PHASE_BUBBLE);
g_signal_connect (priv->multipress_gesture, "pressed",
g_signal_connect (gesture, "pressed",
G_CALLBACK (gtk_flow_box_multipress_gesture_pressed), box);
g_signal_connect (priv->multipress_gesture, "released",
g_signal_connect (gesture, "released",
G_CALLBACK (gtk_flow_box_multipress_gesture_released), box);
g_signal_connect (priv->multipress_gesture, "stopped",
g_signal_connect (gesture, "stopped",
G_CALLBACK (gtk_flow_box_multipress_gesture_stopped), box);
g_signal_connect (priv->multipress_gesture, "unpaired-release",
g_signal_connect (gesture, "unpaired-release",
G_CALLBACK (gtk_flow_box_multipress_unpaired_release), box);
gtk_widget_add_controller (GTK_WIDGET (box), GTK_EVENT_CONTROLLER (gesture));
priv->drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (box));
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->drag_gesture),
......
......@@ -2026,11 +2026,10 @@ add_check_group (GtkFontChooserWidget *fontchooser,
g_signal_connect_swapped (feat, "notify::inconsistent", G_CALLBACK (update_font_features), fontchooser);
g_signal_connect (feat, "clicked", G_CALLBACK (feat_clicked), NULL);
gesture = gtk_gesture_multi_press_new (feat);
g_object_set_data_full (G_OBJECT (feat), "press", gesture, g_object_unref);
gesture = gtk_gesture_multi_press_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);
g_signal_connect (gesture, "pressed", G_CALLBACK (feat_pressed), feat);
gtk_widget_add_controller (feat, GTK_EVENT_CONTROLLER (gesture));
example = gtk_label_new ("");
gtk_label_set_selectable (GTK_LABEL (example), TRUE);
......
......@@ -432,7 +432,6 @@ gtk_gesture_multi_press_init (GtkGestureMultiPress *gesture)
/**
* gtk_gesture_multi_press_new:
* @widget: a #GtkWidget
*
* Returns a newly created #GtkGesture that recognizes single and multiple
* presses.
......@@ -440,12 +439,9 @@ gtk_gesture_multi_press_init (GtkGestureMultiPress *gesture)
* Returns: a newly created #GtkGestureMultiPress
**/
GtkGesture *
gtk_gesture_multi_press_new (GtkWidget *widget)
gtk_gesture_multi_press_new (void)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
return g_object_new (GTK_TYPE_GESTURE_MULTI_PRESS,
"widget", widget,
NULL);
}
......
......@@ -42,7 +42,7 @@ GDK_AVAILABLE_IN_ALL
GType gtk_gesture_multi_press_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkGesture * gtk_gesture_multi_press_new (GtkWidget *widget);
GtkGesture * gtk_gesture_multi_press_new (void);
GDK_AVAILABLE_IN_ALL
void gtk_gesture_multi_press_set_area (GtkGestureMultiPress *gesture,
......
......@@ -918,6 +918,8 @@ gtk_icon_view_cell_layout_init (GtkCellLayoutIface *iface)
static void
gtk_icon_view_init (GtkIconView *icon_view)
{
GtkGesture *gesture;
icon_view->priv = gtk_icon_view_get_instance_private (icon_view);
icon_view->priv->width = 0;
......@@ -957,11 +959,12 @@ gtk_icon_view_init (GtkIconView *icon_view)
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (icon_view)),
GTK_STYLE_CLASS_VIEW);
icon_view->priv->press_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (icon_view));
g_signal_connect (icon_view->priv->press_gesture, "pressed", G_CALLBACK (gtk_icon_view_button_press),
gesture = gtk_gesture_multi_press_new ();
g_signal_connect (gesture, "pressed", G_CALLBACK (gtk_icon_view_button_press),
icon_view);
g_signal_connect (icon_view->priv->press_gesture, "released", G_CALLBACK (gtk_icon_view_button_release),
g_signal_connect (gesture, "released", G_CALLBACK (gtk_icon_view_button_release),
icon_view);
gtk_widget_add_controller (GTK_WIDGET (icon_view), GTK_EVENT_CONTROLLER (gesture));
icon_view->priv->motion_controller = gtk_event_controller_motion_new (GTK_WIDGET (icon_view));
g_signal_connect (icon_view->priv->motion_controller, "leave", G_CALLBACK (gtk_icon_view_leave),
......@@ -1020,7 +1023,6 @@ gtk_icon_view_dispose (GObject *object)
priv->cell_area = NULL;
}
g_clear_object (&priv->press_gesture);
g_clear_object (&priv->motion_controller);
g_clear_object (&priv->key_controller);
......
......@@ -60,7 +60,6 @@ struct _GtkIconViewPrivate
GList *items;
GtkGesture *press_gesture;
GtkEventController *motion_controller;
GtkEventController *key_controller;
......
......@@ -436,8 +436,11 @@ gtk_im_context_wayland_set_client_widget (GtkIMContext *context,
if (widget == context_wayland->widget)
return;
if (context_wayland->widget && context_wayland->widget != widget)
g_clear_object (&context_wayland->gesture);
if (context_wayland->widget)
{
gtk_widget_remove_controller (context_wayland->widget, GTK_EVENT_CONTROLLER (context_wayland->gesture));
context_wayland->gesture = NULL;
}
g_set_object (&context_wayland->widget, widget);
......@@ -445,13 +448,14 @@ gtk_im_context_wayland_set_client_widget (GtkIMContext *context,
{
GtkGesture *gesture;
gesture = gtk_gesture_multi_press_new (widget);
gesture = gtk_gesture_multi_press_new ();
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
GTK_PHASE_CAPTURE);
g_signal_connect (gesture, "pressed",
G_CALLBACK (pressed_cb), context);
g_signal_connect (gesture, "released",
G_CALLBACK (released_cb), context);
gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (gesture));
context_wayland->gesture = gesture;
}
}
......
......@@ -3178,7 +3178,6 @@ gtk_label_finalize (GObject *object)
if (priv->select_info)
{
g_object_unref (priv->select_info->drag_gesture);
g_object_unref (priv->select_info->multipress_gesture);
g_object_unref (priv->select_info->motion_controller);
g_object_unref (priv->select_info->provider);
}
......@@ -5024,13 +5023,14 @@ gtk_label_ensure_select_info (GtkLabel *label)
G_CALLBACK (gtk_label_drag_gesture_update), label);
gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (priv->select_info->drag_gesture), TRUE);
priv->select_info->multipress_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (label));
priv->select_info->multipress_gesture = gtk_gesture_multi_press_new ();
g_signal_connect (priv->select_info->multipress_gesture, "pressed",
G_CALLBACK (gtk_label_multipress_gesture_pressed), label);
g_signal_connect (priv->select_info->multipress_gesture, "released",
G_CALLBACK (gtk_label_multipress_gesture_released), label);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->select_info->multipress_gesture), 0);
gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (priv->select_info->multipress_gesture), TRUE);
gtk_widget_add_controller (GTK_WIDGET (label), GTK_EVENT_CONTROLLER (priv->select_info->multipress_gesture));
priv->select_info->motion_controller = gtk_event_controller_motion_new (GTK_WIDGET (label));
g_signal_connect (priv->select_info->motion_controller, "motion",
......@@ -5054,7 +5054,7 @@ gtk_label_clear_select_info (GtkLabel *label)
if (!priv->select_info->selectable && !priv->select_info->links)
{
g_object_unref (priv->select_info->drag_gesture);
g_object_unref (priv->select_info->multipress_gesture);
gtk_widget_remove_controller (GTK_WIDGET (label), GTK_EVENT_CONTROLLER (priv->select_info->multipress_gesture));
g_object_unref (priv->select_info->motion_controller);
GTK_LABEL_CONTENT (priv->select_info->provider)->label = NULL;
g_object_unref (priv->select_info->provider);
......
......@@ -79,7 +79,6 @@ struct _GtkLinkButtonPrivate
gboolean visited;
GtkWidget *popup_menu;
GtkGesture *click_gesture;
};
enum
......@@ -209,9 +208,9 @@ gtk_link_button_class_init (GtkLinkButtonClass *klass)
static void
gtk_link_button_init (GtkLinkButton *link_button)
{
GtkLinkButtonPrivate *priv = gtk_link_button_get_instance_private (link_button);
GtkStyleContext *context;
GdkContentFormats *targets;
GtkGesture *gesture;
gtk_button_set_relief (GTK_BUTTON (link_button), GTK_RELIEF_NONE);
gtk_widget_set_state_flags (GTK_WIDGET (link_button), GTK_STATE_FLAG_LINK, FALSE);
......@@ -232,12 +231,13 @@ gtk_link_button_init (GtkLinkButton *link_button)
gdk_content_formats_unref (targets);
gtk_drag_source_set_icon_name (GTK_WIDGET (link_button), "text-x-generic");
priv->click_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (link_button));
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->click_gesture), FALSE);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->click_gesture), 0);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->click_gesture), GTK_PHASE_BUBBLE);
g_signal_connect (priv->click_gesture, "pressed", G_CALLBACK (gtk_link_button_pressed_cb),
gesture = gtk_gesture_multi_press_new ();
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), FALSE);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture), GTK_PHASE_BUBBLE);
g_signal_connect (gesture, "pressed", G_CALLBACK (gtk_link_button_pressed_cb),
link_button);
gtk_widget_add_controller (GTK_WIDGET (link_button), GTK_EVENT_CONTROLLER (gesture));
context = gtk_widget_get_style_context (GTK_WIDGET (link_button));
gtk_style_context_add_class (context, "link");
......@@ -252,8 +252,7 @@ gtk_link_button_finalize (GObject *object)
GtkLinkButtonPrivate *priv = gtk_link_button_get_instance_private (link_button);
g_free (priv->uri);
g_object_unref (priv->click_gesture);
G_OBJECT_CLASS (gtk_link_button_parent_class)->finalize (object);
}
......
......@@ -114,8 +114,6 @@ typedef struct
gboolean activate_single_click;
gboolean accept_unpaired_release;
GtkGesture *multipress_gesture;
/* DnD */
GtkListBoxRow *drag_highlighted_row;
......@@ -379,7 +377,6 @@ gtk_list_box_finalize (GObject *obj)
g_clear_object (&priv->adjustment);
g_clear_object (&priv->drag_highlighted_row);
g_clear_object (&priv->multipress_gesture);
g_sequence_free (priv->children);
g_hash_table_unref (priv->header_hash);
......@@ -612,6 +609,7 @@ gtk_list_box_init (GtkListBox *box)
{
GtkListBoxPrivate *priv = BOX_PRIV (box);
GtkWidget *widget = GTK_WIDGET (box);
GtkGesture *gesture;
gtk_widget_set_has_surface (widget, FALSE);
priv->selection_mode = GTK_SELECTION_SINGLE;
......@@ -620,21 +618,22 @@ gtk_list_box_init (GtkListBox *box)
priv->children = g_sequence_new (NULL);
priv->header_hash = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL);
priv->multipress_gesture = gtk_gesture_multi_press_new (widget);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->multipress_gesture),
gesture = gtk_gesture_multi_press_new ();
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
GTK_PHASE_BUBBLE);
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->multipress_gesture),
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture),
FALSE);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->multipress_gesture),
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture),
GDK_BUTTON_PRIMARY);
g_signal_connect (priv->multipress_gesture, "pressed",
g_signal_connect (gesture, "pressed",
G_CALLBACK (gtk_list_box_multipress_gesture_pressed), box);
g_signal_connect (priv->multipress_gesture, "released",
g_signal_connect (gesture, "released",
G_CALLBACK (gtk_list_box_multipress_gesture_released), box);
g_signal_connect (priv->multipress_gesture, "stopped",
g_signal_connect (gesture, "stopped",
G_CALLBACK (gtk_list_box_multipress_gesture_stopped), box);
g_signal_connect (priv->multipress_gesture, "unpaired-release",
g_signal_connect (gesture, "unpaired-release",
G_CALLBACK (gtk_list_box_multipress_unpaired_release), box);
gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (gesture));
g_signal_connect (box, "notify::parent", G_CALLBACK (gtk_list_box_parent_cb), NULL);
}
......
......@@ -1085,6 +1085,7 @@ static void
gtk_menu_init (GtkMenu *menu)
{
GtkMenuPrivate *priv;
GtkGesture *gesture;
priv = gtk_menu_get_instance_private (menu);
......@@ -1129,12 +1130,13 @@ gtk_menu_init (GtkMenu *menu)
gtk_widget_set_parent (priv->bottom_arrow_widget, GTK_WIDGET (menu));
gtk_widget_hide (priv->bottom_arrow_widget);
priv->click_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (menu));
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->click_gesture), FALSE);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->click_gesture), 0);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->click_gesture), GTK_PHASE_BUBBLE);
g_signal_connect (priv->click_gesture, "pressed", G_CALLBACK (gtk_menu_pressed_cb), menu);
g_signal_connect (priv->click_gesture, "released", G_CALLBACK (gtk_menu_released_cb), menu);
gesture = gtk_gesture_multi_press_new ();
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), FALSE);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture), GTK_PHASE_BUBBLE);
g_signal_connect (gesture, "pressed", G_CALLBACK (gtk_menu_pressed_cb), menu);
g_signal_connect (gesture, "released", G_CALLBACK (gtk_menu_released_cb), menu);
gtk_widget_add_controller (GTK_WIDGET (menu), GTK_EVENT_CONTROLLER (gesture));
priv->scroll_controller =
gtk_event_controller_scroll_new (GTK_WIDGET (menu),
......@@ -1223,7 +1225,6 @@ gtk_menu_finalize (GObject *object)
gtk_widget_unparent (priv->top_arrow_widget);
gtk_widget_unparent (priv->bottom_arrow_widget);
g_clear_object (&priv->click_gesture);
g_clear_object (&priv->scroll_controller);
g_clear_object (&priv->motion_controller);
g_clear_object (&priv->key_controller);
......
......@@ -75,7 +75,6 @@ struct _GtkMenuPrivate
GtkWidget *top_arrow_widget;
GtkWidget *bottom_arrow_widget;
GtkGesture *click_gesture;
GtkEventController *scroll_controller;
GtkEventController *motion_controller;
GtkEventController *key_controller;
......
......@@ -132,8 +132,6 @@ struct _GtkMountOperationPrivate {
/* for the show-processes dialog */
GtkWidget *process_tree_view;
GtkListStore *process_list_store;
GtkGesture *multipress_gesture;
};
enum {
......@@ -231,9 +229,6 @@ gtk_mount_operation_finalize (GObject *object)
if (priv->handler)
g_object_unref (priv->handler);
if (priv->multipress_gesture)
g_object_unref (priv->multipress_gesture);
G_OBJECT_CLASS (gtk_mount_operation_parent_class)->finalize (object);
}
......@@ -1384,6 +1379,7 @@ create_show_processes_dialog (GtkMountOperation *op,
GtkListStore *list_store;
gchar *s;
gboolean use_header;
GtkGesture *gesture;
priv = op->priv;
......@@ -1474,10 +1470,11 @@ create_show_processes_dialog (GtkMountOperation *op,
G_CALLBACK (on_popup_menu_for_process_tree_view),
op);
priv->multipress_gesture = gtk_gesture_multi_press_new (tree_view);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->multipress_gesture), GDK_BUTTON_SECONDARY);
g_signal_connect (priv->multipress_gesture, "pressed",
gesture = gtk_gesture_multi_press_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);
g_signal_connect (gesture, "pressed",
G_CALLBACK (multi_press_cb), op);
gtk_widget_add_controller (tree_view, GTK_EVENT_CONTROLLER (gesture));
list_store = gtk_list_store_new (3,
GDK_TYPE_TEXTURE,
......
......@@ -207,7 +207,6 @@ struct _GtkNotebookPrivate
guint switch_tab_timer;
GList *switch_tab;
GtkGesture *press_gesture;
GtkEventController *motion_controller;
guint32 timer;
......@@ -1042,6 +1041,7 @@ gtk_notebook_init (GtkNotebook *notebook)
{
GtkNotebookPrivate *priv;
GdkContentFormats *targets;
GtkGesture *gesture;
gtk_widget_set_can_focus (GTK_WIDGET (notebook), TRUE);
gtk_widget_set_has_surface (GTK_WIDGET (notebook), FALSE);
......@@ -1111,11 +1111,12 @@ gtk_notebook_init (GtkNotebook *notebook)
gtk_widget_set_vexpand (priv->stack_widget, TRUE);
gtk_container_add (GTK_CONTAINER (priv->box), priv->stack_widget);
priv->press_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (notebook));
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->press_gesture), 0);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->press_gesture), GTK_PHASE_CAPTURE);
g_signal_connect (priv->press_gesture, "pressed", G_CALLBACK (gtk_notebook_gesture_pressed), notebook);
g_signal_connect (priv->press_gesture, "released", G_CALLBACK (gtk_notebook_gesture_released), notebook);
gesture = gtk_gesture_multi_press_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);