mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-10-03 22:45:26 +00:00
files-view: Add gestures to open background menu in empty view
Commit c653f88090
("list-base: Don't inherit from NautilusFilesView")
broke our ability to right click on an empty view to open the background
context menu because the list-base is no longer a child of files-view.
We could move the gestures from list-base to files-view, but that's
problematic not only because of the weird hack we use (to deny
background click after clicking on a view item, but also because we
might want to not allow background click (for example in the network
view), and claiming the background click in such a view would
interrupt the gesture for the underlying view (i.e. GtkListView).
So let's take the path of least resistance and just add the gesture
on the empty state itself.
Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/3281
This commit is contained in:
parent
ec6cd1dfd9
commit
95f3db44c8
|
@ -3230,15 +3230,14 @@ nautilus_files_view_set_selection (NautilusView *nautilus_files_view,
|
|||
}
|
||||
|
||||
static void
|
||||
on_popup_background_context_menu (NautilusListBase *list_base,
|
||||
double x,
|
||||
double y,
|
||||
gpointer user_data)
|
||||
real_popup_background_context_menu (NautilusFilesView *self,
|
||||
GtkWidget *widget,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
NautilusFilesView *self = NAUTILUS_FILES_VIEW (user_data);
|
||||
graphene_point_t view_point;
|
||||
|
||||
if (!gtk_widget_compute_point (GTK_WIDGET (list_base), GTK_WIDGET (self),
|
||||
if (!gtk_widget_compute_point (widget, GTK_WIDGET (self),
|
||||
&GRAPHENE_POINT_INIT (x, y),
|
||||
&view_point))
|
||||
{
|
||||
|
@ -3248,6 +3247,31 @@ on_popup_background_context_menu (NautilusListBase *list_base,
|
|||
nautilus_files_view_pop_up_background_context_menu (self, &view_point);
|
||||
}
|
||||
|
||||
static void
|
||||
on_popup_background_context_menu (NautilusListBase *list_base,
|
||||
double x,
|
||||
double y,
|
||||
gpointer user_data)
|
||||
{
|
||||
NautilusFilesView *self = user_data;
|
||||
|
||||
real_popup_background_context_menu (self, GTK_WIDGET (list_base), x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
on_empty_view_pressed (GtkGesture *gesture,
|
||||
gint n_press,
|
||||
double x,
|
||||
double y,
|
||||
gpointer user_data)
|
||||
{
|
||||
NautilusFilesView *self = user_data;
|
||||
GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
real_popup_background_context_menu (self, widget, x, y);
|
||||
gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_CLAIMED);
|
||||
}
|
||||
|
||||
static void
|
||||
on_popup_selection_context_menu (NautilusListBase *list_base,
|
||||
double x,
|
||||
|
@ -9757,6 +9781,16 @@ nautilus_files_view_init (NautilusFilesView *view)
|
|||
gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
|
||||
gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), shortcut);
|
||||
|
||||
controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ());
|
||||
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), GDK_BUTTON_SECONDARY);
|
||||
gtk_widget_add_controller (GTK_WIDGET (priv->empty_view_page), controller);
|
||||
g_signal_connect (controller, "pressed", G_CALLBACK (on_empty_view_pressed), view);
|
||||
|
||||
controller = GTK_EVENT_CONTROLLER (gtk_gesture_long_press_new ());
|
||||
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (controller), TRUE);
|
||||
gtk_widget_add_controller (GTK_WIDGET (priv->empty_view_page), controller);
|
||||
g_signal_connect (controller, "pressed", G_CALLBACK (on_empty_view_pressed), view);
|
||||
|
||||
priv->starred_cancellable = g_cancellable_new ();
|
||||
priv->clipboard_cancellable = g_cancellable_new ();
|
||||
|
||||
|
|
Loading…
Reference in a new issue