mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-08-24 18:25:50 +00:00
pathbar: Use long press gesture for scrolling
This commit is contained in:
parent
4ff6b8388a
commit
1a37805932
|
@ -103,27 +103,30 @@ typedef struct
|
|||
gboolean drag_slider_timeout_for_up_button;
|
||||
|
||||
GtkPopover *current_view_menu;
|
||||
|
||||
GtkGesture *up_slider_button_long_press_gesture;
|
||||
GtkGesture *down_slider_button_long_press_gesture;
|
||||
} NautilusPathBarPrivate;
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (NautilusPathBar, nautilus_path_bar,
|
||||
GTK_TYPE_CONTAINER);
|
||||
|
||||
static void nautilus_path_bar_scroll_up (NautilusPathBar *self);
|
||||
static void nautilus_path_bar_scroll_down (NautilusPathBar *self);
|
||||
static void nautilus_path_bar_stop_scrolling (NautilusPathBar *self);
|
||||
static gboolean nautilus_path_bar_slider_button_press (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
NautilusPathBar *self);
|
||||
static gboolean nautilus_path_bar_slider_button_release (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
NautilusPathBar *self);
|
||||
static void nautilus_path_bar_check_icon_theme (NautilusPathBar *self);
|
||||
static void nautilus_path_bar_update_button_appearance (ButtonData *button_data);
|
||||
static void nautilus_path_bar_update_button_state (ButtonData *button_data,
|
||||
gboolean current_dir);
|
||||
static void nautilus_path_bar_update_path (NautilusPathBar *self,
|
||||
GFile *file_path);
|
||||
static void nautilus_path_bar_scroll_up (NautilusPathBar *self);
|
||||
static void nautilus_path_bar_scroll_down (NautilusPathBar *self);
|
||||
static void nautilus_path_bar_stop_scrolling (NautilusPathBar *self);
|
||||
static void on_long_press_gesture_pressed (GtkGestureLongPress *gesture,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gpointer user_data);
|
||||
static void on_long_press_gesture_cancelled (GtkGestureLongPress *gesture,
|
||||
gpointer user_data);
|
||||
static void nautilus_path_bar_check_icon_theme (NautilusPathBar *self);
|
||||
static void nautilus_path_bar_update_button_appearance (ButtonData *button_data);
|
||||
static void nautilus_path_bar_update_button_state (ButtonData *button_data,
|
||||
gboolean current_dir);
|
||||
static void nautilus_path_bar_update_path (NautilusPathBar *self,
|
||||
GFile *file_path);
|
||||
|
||||
static GtkWidget *
|
||||
get_slider_button (NautilusPathBar *self,
|
||||
|
@ -248,10 +251,19 @@ nautilus_path_bar_init (NautilusPathBar *self)
|
|||
g_signal_connect_swapped (priv->up_slider_button, "clicked", G_CALLBACK (nautilus_path_bar_scroll_up), self);
|
||||
g_signal_connect_swapped (priv->down_slider_button, "clicked", G_CALLBACK (nautilus_path_bar_scroll_down), self);
|
||||
|
||||
g_signal_connect (priv->up_slider_button, "button-press-event", G_CALLBACK (nautilus_path_bar_slider_button_press), self);
|
||||
g_signal_connect (priv->up_slider_button, "button-release-event", G_CALLBACK (nautilus_path_bar_slider_button_release), self);
|
||||
g_signal_connect (priv->down_slider_button, "button-press-event", G_CALLBACK (nautilus_path_bar_slider_button_press), self);
|
||||
g_signal_connect (priv->down_slider_button, "button-release-event", G_CALLBACK (nautilus_path_bar_slider_button_release), self);
|
||||
priv->up_slider_button_long_press_gesture = gtk_gesture_long_press_new (priv->up_slider_button);
|
||||
|
||||
g_signal_connect (priv->up_slider_button_long_press_gesture, "pressed",
|
||||
G_CALLBACK (on_long_press_gesture_pressed), self);
|
||||
g_signal_connect (priv->up_slider_button_long_press_gesture, "cancelled",
|
||||
G_CALLBACK (on_long_press_gesture_cancelled), self);
|
||||
|
||||
priv->down_slider_button_long_press_gesture = gtk_gesture_long_press_new (priv->down_slider_button);
|
||||
|
||||
g_signal_connect (priv->down_slider_button_long_press_gesture, "pressed",
|
||||
G_CALLBACK (on_long_press_gesture_pressed), self);
|
||||
g_signal_connect (priv->down_slider_button_long_press_gesture, "cancelled",
|
||||
G_CALLBACK (on_long_press_gesture_cancelled), self);
|
||||
|
||||
gtk_drag_dest_set (GTK_WIDGET (priv->up_slider_button),
|
||||
0, NULL, 0, 0);
|
||||
|
@ -328,7 +340,16 @@ remove_settings_signal (NautilusPathBar *self,
|
|||
static void
|
||||
nautilus_path_bar_dispose (GObject *object)
|
||||
{
|
||||
remove_settings_signal (NAUTILUS_PATH_BAR (object), gtk_widget_get_screen (GTK_WIDGET (object)));
|
||||
NautilusPathBar *self;
|
||||
NautilusPathBarPrivate *priv;
|
||||
|
||||
self = NAUTILUS_PATH_BAR (object);
|
||||
priv = nautilus_path_bar_get_instance_private (self);
|
||||
|
||||
remove_settings_signal (self, gtk_widget_get_screen (GTK_WIDGET (object)));
|
||||
|
||||
g_clear_object (&priv->up_slider_button_long_press_gesture);
|
||||
g_clear_object (&priv->down_slider_button_long_press_gesture);
|
||||
|
||||
G_OBJECT_CLASS (nautilus_path_bar_parent_class)->dispose (object);
|
||||
}
|
||||
|
@ -1350,25 +1371,25 @@ nautilus_path_bar_stop_scrolling (NautilusPathBar *self)
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
nautilus_path_bar_slider_button_press (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
NautilusPathBar *self)
|
||||
static void
|
||||
on_long_press_gesture_pressed (GtkGestureLongPress *gesture,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gpointer user_data)
|
||||
{
|
||||
NautilusPathBar *self;
|
||||
NautilusPathBarPrivate *priv;
|
||||
GtkWidget *widget;
|
||||
|
||||
self = NAUTILUS_PATH_BAR (user_data);
|
||||
priv = nautilus_path_bar_get_instance_private (self);
|
||||
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
if (!gtk_widget_has_focus (widget))
|
||||
{
|
||||
gtk_widget_grab_focus (widget);
|
||||
}
|
||||
|
||||
if (event->type != GDK_BUTTON_PRESS || event->button != GDK_BUTTON_PRIMARY)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
priv->ignore_click = FALSE;
|
||||
|
||||
if (widget == priv->up_slider_button)
|
||||
|
@ -1391,28 +1412,20 @@ nautilus_path_bar_slider_button_press (GtkWidget *widget,
|
|||
(GSourceFunc) nautilus_path_bar_scroll_timeout,
|
||||
self);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
nautilus_path_bar_slider_button_release (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
NautilusPathBar *self)
|
||||
static void
|
||||
on_long_press_gesture_cancelled (GtkGestureLongPress *gesture,
|
||||
gpointer user_data)
|
||||
{
|
||||
NautilusPathBar *self;
|
||||
NautilusPathBarPrivate *priv;
|
||||
|
||||
self = NAUTILUS_PATH_BAR (user_data);
|
||||
priv = nautilus_path_bar_get_instance_private (self);
|
||||
|
||||
if (event->type != GDK_BUTTON_RELEASE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
priv->ignore_click = TRUE;
|
||||
nautilus_path_bar_stop_scrolling (self);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue