diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c index 3281a09794..2451f114dd 100644 --- a/gtk/gtkplacesview.c +++ b/gtk/gtkplacesview.c @@ -99,9 +99,6 @@ struct _GtkPlacesViewPrivate static void mount_volume (GtkPlacesView *view, GVolume *volume); -static gboolean on_button_press_event (GtkPlacesViewRow *row, - GdkEventButton *event); - static void on_eject_button_clicked (GtkWidget *widget, GtkPlacesViewRow *row); @@ -662,15 +659,7 @@ insert_row (GtkPlacesView *view, g_object_set_data (G_OBJECT (row), "is-network", GINT_TO_POINTER (is_network)); - g_signal_connect_swapped (GTK_PLACES_VIEW_ROW (row), - "button-press-event", - G_CALLBACK (on_button_press_event), - row); - - g_signal_connect (row, - "popup-menu", - G_CALLBACK (on_row_popup_menu), - row); + g_signal_connect (row, "popup-menu", G_CALLBACK (on_row_popup_menu), row); g_signal_connect (gtk_places_view_row_get_eject_button (GTK_PLACES_VIEW_ROW (row)), "clicked", @@ -1697,22 +1686,6 @@ on_row_popup_menu (GtkPlacesViewRow *row) return TRUE; } -static gboolean -on_button_press_event (GtkPlacesViewRow *row, - GdkEventButton *event) -{ - if (row && - gdk_event_triggers_context_menu ((GdkEvent*) event) && - gdk_event_get_event_type ((GdkEvent *)event) == GDK_BUTTON_PRESS) - { - popup_menu (row, event); - - return TRUE; - } - - return FALSE; -} - static gboolean on_key_press_event (GtkWidget *widget, GdkEventKey *event, diff --git a/gtk/gtkplacesviewrow.c b/gtk/gtkplacesviewrow.c index c7236afd1b..c64c063523 100644 --- a/gtk/gtkplacesviewrow.c +++ b/gtk/gtkplacesviewrow.c @@ -34,6 +34,7 @@ #include "gtkspinner.h" #include "gtkstack.h" #include "gtktypebuiltins.h" +#include "gtkgesturemultipress.h" #else #include #endif @@ -55,6 +56,8 @@ struct _GtkPlacesViewRow GMount *mount; GFile *file; + GtkGesture *gesture; + GCancellable *cancellable; gint is_network : 1; @@ -192,6 +195,16 @@ measure_available_space (GtkPlacesViewRow *row) } } +static void +pressed_cb (GtkGesture *gesture, + int n_pressed, + double x, + double y, + GtkPlacesViewRow *row) +{ + g_signal_emit_by_name (row, "popup-menu", 0); +} + static void gtk_places_view_row_finalize (GObject *object) { @@ -203,6 +216,7 @@ gtk_places_view_row_finalize (GObject *object) g_clear_object (&self->mount); g_clear_object (&self->file); g_clear_object (&self->cancellable); + g_clear_object (&self->gesture); G_OBJECT_CLASS (gtk_places_view_row_parent_class)->finalize (object); } @@ -384,6 +398,10 @@ static void gtk_places_view_row_init (GtkPlacesViewRow *self) { gtk_widget_init_template (GTK_WIDGET (self)); + + self->gesture = gtk_gesture_multi_press_new (GTK_WIDGET (self)); + gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (self->gesture), GDK_BUTTON_SECONDARY); + g_signal_connect (self->gesture, "pressed", G_CALLBACK (pressed_cb), self); } GtkWidget*