[nautilus/wip/antoniof/switch-to-gtk4: 15/36] general: Adapt to EventController API changes
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/switch-to-gtk4: 15/36] general: Adapt to EventController API changes
- Date: Fri, 7 Jan 2022 08:00:53 +0000 (UTC)
commit c75fc872628f606f4bed55ebfae1987ffd9bd9e3
Author: António Fernandes <antoniof gnome org>
Date: Mon Dec 20 20:49:41 2021 +0000
general: Adapt to EventController API changes
We no longer have to keep a reference and manage their lifecycle,
because gtk_widget_add_controller() takes ownership of the controller.
src/nautilus-batch-rename-dialog.c | 9 +---
src/nautilus-files-view.c | 7 ---
src/nautilus-floating-bar.c | 18 ++++++-
src/nautilus-list-view-private.h | 6 ---
src/nautilus-list-view.c | 58 ++++++++-------------
src/nautilus-location-entry.c | 15 +++---
src/nautilus-pathbar.c | 14 ++---
src/nautilus-rename-file-popover-controller.c | 14 ++---
src/nautilus-toolbar.c | 37 ++++++--------
src/nautilus-view-icon-controller.c | 33 +++++-------
src/nautilus-window.c | 73 +++++++++------------------
11 files changed, 109 insertions(+), 175 deletions(-)
---
diff --git a/src/nautilus-batch-rename-dialog.c b/src/nautilus-batch-rename-dialog.c
index 21e47eede..fe8b75017 100644
--- a/src/nautilus-batch-rename-dialog.c
+++ b/src/nautilus-batch-rename-dialog.c
@@ -63,8 +63,6 @@ struct _NautilusBatchRenameDialog
GList *listbox_icons;
GtkSizeGroup *size_group;
- GList *motion_controllers;
-
GList *selection;
GList *new_names;
NautilusBatchRenameDialogMode mode;
@@ -1859,7 +1857,6 @@ nautilus_batch_rename_dialog_finalize (GObject *object)
nautilus_directory_list_free (dialog->distinct_parent_directories);
g_object_unref (dialog->size_group);
- g_clear_list (&dialog->motion_controllers, g_object_unref);
g_hash_table_destroy (dialog->tag_info_table);
@@ -2007,15 +2004,13 @@ connect_to_pointer_motion_events (NautilusBatchRenameDialog *self,
{
GtkEventController *controller;
- controller = gtk_event_controller_motion_new (listbox);
+ controller = gtk_event_controller_motion_new ();
+ gtk_widget_add_controller (listbox, controller);
gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
g_signal_connect (controller, "leave",
G_CALLBACK (on_event_controller_motion_leave), self);
g_signal_connect (controller, "motion",
G_CALLBACK (on_event_controller_motion_motion), self);
-
- self->motion_controllers = g_list_prepend (self->motion_controllers,
- controller);
}
static void
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 78474a747..76fb7cf26 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -9563,13 +9563,6 @@ nautilus_files_view_init (NautilusFilesView *view)
gtk_grid_attach_next_to (GTK_GRID (view), priv->overlay, NULL, GTK_POS_BOTTOM, 1, 1);
gtk_widget_show (priv->overlay);
- /* NautilusFloatingBar listen to its parent's 'event' signal
- * and GtkOverlay doesn't have it enabled by default, so we have to add them
- * here.
- */
- gtk_widget_add_events (GTK_WIDGET (priv->overlay),
- GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
-
/* Scrolled Window */
priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
diff --git a/src/nautilus-floating-bar.c b/src/nautilus-floating-bar.c
index 430d7ca9d..55a35f744 100644
--- a/src/nautilus-floating-bar.c
+++ b/src/nautilus-floating-bar.c
@@ -309,11 +309,25 @@ on_parent_changed (GObject *object,
parent = gtk_widget_get_parent (GTK_WIDGET (object));
- g_clear_object (&self->motion_controller);
+ if (self->motion_controller != NULL)
+ {
+ GtkWidget *old_parent;
+
+ old_parent = gtk_event_controller_get_widget (self->motion_controller);
+ g_warn_if_fail (old_parent != NULL);
+ if (old_parent != NULL)
+ {
+ gtk_widget_remove_controller (old_parent, self->motion_controller);
+ }
+
+ g_object_unref (self->motion_controller);
+ self->motion_controller = NULL;
+ }
if (parent != NULL)
{
- self->motion_controller = gtk_event_controller_motion_new (parent);
+ self->motion_controller = g_object_ref (gtk_event_controller_motion_new ());
+ gtk_widget_add_controller (parent, self->motion_controller);
gtk_event_controller_set_propagation_phase (self->motion_controller,
GTK_PHASE_CAPTURE);
diff --git a/src/nautilus-list-view-private.h b/src/nautilus-list-view-private.h
index cd95c868e..2c83860cc 100644
--- a/src/nautilus-list-view-private.h
+++ b/src/nautilus-list-view-private.h
@@ -77,11 +77,5 @@ struct NautilusListViewDetails {
NautilusTagManager *tag_manager;
GCancellable *starred_cancellable;
-
- GtkGesture *tree_view_drag_gesture;
- GtkGesture *tree_view_click_gesture;
- GtkEventController *motion_controller;
- GtkEventController *key_controller;
- GtkGesture *long_press_gesture;
};
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 4333854ae..ae486a326 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -1989,7 +1989,6 @@ create_and_set_up_tree_view (NautilusListView *view)
GList *l;
gchar **default_column_order, **default_visible_columns;
GtkWidget *content_widget;
- GtkGesture *gesture;
GtkEventController *controller;
content_widget = nautilus_files_view_get_content_widget (NAUTILUS_FILES_VIEW (view));
@@ -2039,33 +2038,29 @@ create_and_set_up_tree_view (NautilusListView *view)
"changed",
G_CALLBACK (list_selection_changed_callback), view, 0);
- gesture = gtk_gesture_drag_new (GTK_WIDGET (view->details->tree_view));
- view->details->tree_view_drag_gesture = gesture;
-
- gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
- GTK_PHASE_CAPTURE);
- gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
+ controller = GTK_EVENT_CONTROLLER (gtk_gesture_drag_new ());
+ gtk_widget_add_controller (GTK_WIDGET (view->details->tree_view), controller);
+ gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
+ gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), 0);
- g_signal_connect (gesture, "drag-begin",
+ g_signal_connect (controller, "drag-begin",
G_CALLBACK (on_tree_view_drag_gesture_drag_begin), view);
- g_signal_connect (gesture, "drag-update",
+ g_signal_connect (controller, "drag-update",
G_CALLBACK (on_tree_view_drag_gesture_drag_update), view);
- gesture = gtk_gesture_click_new (GTK_WIDGET (view->details->tree_view));
- view->details->tree_view_click_gesture = gesture;
+ controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ());
+ gtk_widget_add_controller (GTK_WIDGET (view->details->tree_view), controller);
- gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
- GTK_PHASE_CAPTURE);
- gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
+ gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
+ gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), 0);
- g_signal_connect (gesture, "pressed",
+ g_signal_connect (controller, "pressed",
G_CALLBACK (on_tree_view_click_gesture_pressed), view);
- g_signal_connect (gesture, "released",
+ g_signal_connect (controller, "released",
G_CALLBACK (on_tree_view_click_gesture_released), view);
- controller = gtk_event_controller_motion_new (GTK_WIDGET (view->details->tree_view));
- view->details->motion_controller = controller;
-
+ controller = gtk_event_controller_motion_new ();
+ gtk_widget_add_controller (GTK_WIDGET (view->details->tree_view), controller);
gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
g_signal_connect (controller, "enter",
@@ -2075,8 +2070,8 @@ create_and_set_up_tree_view (NautilusListView *view)
g_signal_connect (controller, "motion",
G_CALLBACK (on_event_controller_motion_motion), view);
- controller = gtk_event_controller_key_new (GTK_WIDGET (view->details->tree_view));
- view->details->key_controller = controller;
+ controller = gtk_event_controller_key_new ();
+ gtk_widget_add_controller (GTK_WIDGET (view->details->tree_view), controller);
gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_BUBBLE);
@@ -2113,16 +2108,12 @@ create_and_set_up_tree_view (NautilusListView *view)
g_signal_connect_object (view->details->model, "get-icon-scale",
G_CALLBACK (get_icon_scale_callback), view, 0);
- gesture = gtk_gesture_long_press_new (GTK_WIDGET (content_widget));
- view->details->long_press_gesture = gesture;
-
- gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
- GTK_PHASE_CAPTURE);
- gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), TRUE);
- g_signal_connect (gesture,
- "pressed",
- (GCallback) on_longpress_gesture_pressed_event,
- view);
+ controller = GTK_EVENT_CONTROLLER (gtk_gesture_long_press_new ());
+ gtk_widget_add_controller (GTK_WIDGET (content_widget), controller);
+ gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
+ gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (controller), TRUE);
+ g_signal_connect (controller, "pressed",
+ (GCallback) on_longpress_gesture_pressed_event, view);
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (view->details->tree_view),
GTK_SELECTION_MULTIPLE);
@@ -3576,11 +3567,6 @@ nautilus_list_view_dispose (GObject *object)
default_column_order_changed_callback,
list_view);
- g_clear_object (&list_view->details->tree_view_drag_gesture);
- g_clear_object (&list_view->details->tree_view_click_gesture);
- g_clear_object (&list_view->details->motion_controller);
- g_clear_object (&list_view->details->key_controller);
- g_clear_object (&list_view->details->long_press_gesture);
g_clear_pointer (&list_view->details->columns_popover, gtk_widget_unparent);
G_OBJECT_CLASS (nautilus_list_view_parent_class)->dispose (object);
diff --git a/src/nautilus-location-entry.c b/src/nautilus-location-entry.c
index 62e588b2f..0333b4ab4 100644
--- a/src/nautilus-location-entry.c
+++ b/src/nautilus-location-entry.c
@@ -578,8 +578,6 @@ finalize (GObject *object)
g_clear_object (&priv->completions_store);
g_free (priv->current_directory);
- g_clear_object (&priv->controller);
-
G_OBJECT_CLASS (nautilus_location_entry_parent_class)->finalize (object);
}
@@ -924,6 +922,7 @@ static void
nautilus_location_entry_init (NautilusLocationEntry *entry)
{
NautilusLocationEntryPrivate *priv;
+ GtkEventController *controller;
priv = nautilus_location_entry_get_instance_private (entry);
@@ -964,15 +963,15 @@ nautilus_location_entry_init (NautilusLocationEntry *entry)
g_signal_connect_object (entry, "changed",
G_CALLBACK (editable_changed_callback), entry, 0);
- priv->controller = gtk_event_controller_key_new (GTK_WIDGET (entry));
+ controller = gtk_event_controller_key_new ();
+ gtk_widget_add_controller (GTK_WIDGET (entry), controller);
/* In GTK3, the Tab key binding (for focus change) happens in the bubble
* phase, and we want to stop that from happening. After porting to GTK4
* we need to check whether this is still correct. */
- gtk_event_controller_set_propagation_phase (priv->controller, GTK_PHASE_BUBBLE);
- g_signal_connect (priv->controller,
- "key-pressed",
- G_CALLBACK (nautilus_location_entry_key_pressed),
- NULL);
+ gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_BUBBLE);
+ g_signal_connect (controller, "key-pressed",
+ G_CALLBACK (nautilus_location_entry_key_pressed), NULL);
+
g_signal_connect_after (entry,
"insert-text",
G_CALLBACK (on_after_insert_text),
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index 9ed162530..2a5002fab 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -77,8 +77,6 @@ typedef struct
NautilusPathBar *path_bar;
- GtkGesture *click_gesture;
-
guint ignore_changes : 1;
guint is_root : 1;
} ButtonData;
@@ -376,8 +374,6 @@ button_data_free (ButtonData *button_data)
nautilus_file_unref (button_data->file);
}
- g_clear_object (&button_data->click_gesture);
-
g_free (button_data);
}
@@ -981,6 +977,7 @@ make_button_data (NautilusPathBar *self,
{
GFile *path;
GtkWidget *child = NULL;
+ GtkEventController *controller;
ButtonData *button_data;
path = nautilus_file_get_location (file);
@@ -1093,11 +1090,10 @@ make_button_data (NautilusPathBar *self,
/* A gesture is needed here, because GtkButton doesn’t react to middle- or
* secondary-clicking.
*/
- button_data->click_gesture = gtk_gesture_click_new (button_data->button);
-
- gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (button_data->click_gesture), 0);
-
- g_signal_connect (button_data->click_gesture, "pressed",
+ controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ());
+ gtk_widget_add_controller (button_data->button, controller);
+ gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), 0);
+ g_signal_connect (controller, "pressed",
G_CALLBACK (on_click_gesture_pressed), button_data);
#if 0 && NAUTILUS_DND_NEEDS_GTK4_REIMPLEMENTATION
diff --git a/src/nautilus-rename-file-popover-controller.c b/src/nautilus-rename-file-popover-controller.c
index 471b65e0e..b5fdbc48c 100644
--- a/src/nautilus-rename-file-popover-controller.c
+++ b/src/nautilus-rename-file-popover-controller.c
@@ -44,8 +44,6 @@ struct _NautilusRenameFilePopoverController
gulong closed_handler_id;
gulong file_changed_handler_id;
gulong key_press_event_handler_id;
-
- GtkEventController *key_controller;
};
G_DEFINE_TYPE (NautilusRenameFilePopoverController, nautilus_rename_file_popover_controller,
NAUTILUS_TYPE_FILE_NAME_WIDGET_CONTROLLER)
@@ -324,6 +322,7 @@ nautilus_rename_file_popover_controller_show_for_file (NautilusRenameFilePopov
GtkWidget *relative_to)
{
g_autoptr (NautilusDirectory) containing_directory = NULL;
+ GtkEventController *controller;
g_autofree gchar *edit_name = NULL;
gint n_chars;
@@ -361,11 +360,10 @@ nautilus_rename_file_popover_controller_show_for_file (NautilusRenameFilePopov
G_CALLBACK (target_file_on_changed),
self);
- self->key_controller = gtk_event_controller_key_new (self->name_entry);
- g_signal_connect (self->key_controller,
- "key-pressed",
- G_CALLBACK (on_event_controller_key_key_pressed),
- self);
+ controller = gtk_event_controller_key_new ();
+ gtk_widget_add_controller (self->name_entry, controller);
+ g_signal_connect (controller, "key-pressed",
+ G_CALLBACK (on_event_controller_key_key_pressed), self);
gtk_label_set_text (GTK_LABEL (self->title_label),
self->target_is_folder ? _("Rename Folder") :
@@ -425,8 +423,6 @@ nautilus_rename_file_popover_controller_finalize (GObject *object)
g_clear_pointer (&self->rename_file_popover, gtk_widget_unparent);
- g_clear_object (&self->key_controller);
-
G_OBJECT_CLASS (nautilus_rename_file_popover_controller_parent_class)->finalize (object);
}
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 83d511b63..de9e53a75 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -88,13 +88,9 @@ struct _NautilusToolbar
GtkWidget *forward_button;
GtkWidget *forward_menu;
- GtkGesture *forward_button_longpress_gesture;
- GtkGesture *forward_button_click_gesture;
GtkWidget *back_button;
GtkWidget *back_menu;
- GtkGesture *back_button_longpress_gesture;
- GtkGesture *back_button_click_gesture;
GtkWidget *search_button;
@@ -796,6 +792,7 @@ static void
nautilus_toolbar_constructed (GObject *object)
{
NautilusToolbar *self = NAUTILUS_TOOLBAR (object);
+ GtkEventController *controller;
self->path_bar = GTK_WIDGET (g_object_new (NAUTILUS_TYPE_PATH_BAR, NULL));
gtk_box_append (GTK_BOX (self->path_bar_container),
@@ -825,12 +822,14 @@ nautilus_toolbar_constructed (GObject *object)
NULL);
update_operations (self);
- self->back_button_longpress_gesture = gtk_gesture_long_press_new (self->back_button);
- g_signal_connect (self->back_button_longpress_gesture, "pressed",
+ controller = GTK_EVENT_CONTROLLER (gtk_gesture_long_press_new ());
+ gtk_widget_add_controller (self->back_button, controller);
+ g_signal_connect (controller, "pressed",
G_CALLBACK (back_button_longpress_cb), self);
- self->forward_button_longpress_gesture = gtk_gesture_long_press_new (self->forward_button);
- g_signal_connect (self->forward_button_longpress_gesture, "pressed",
+ controller = GTK_EVENT_CONTROLLER (gtk_gesture_long_press_new ());
+ gtk_widget_add_controller (self->forward_button, controller);
+ g_signal_connect (controller, "pressed",
G_CALLBACK (forward_button_longpress_cb), self);
g_object_set_data (G_OBJECT (self->back_button), "nav-direction",
@@ -838,17 +837,16 @@ nautilus_toolbar_constructed (GObject *object)
g_object_set_data (G_OBJECT (self->forward_button), "nav-direction",
GUINT_TO_POINTER (NAUTILUS_NAVIGATION_DIRECTION_FORWARD));
-
- self->back_button_click_gesture = gtk_gesture_click_new (self->back_button);
- gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (self->back_button_click_gesture),
- GDK_BUTTON_SECONDARY);
- g_signal_connect (self->back_button_click_gesture, "pressed",
+ controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ());
+ gtk_widget_add_controller (self->back_button, controller);
+ gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), GDK_BUTTON_SECONDARY);
+ g_signal_connect (controller, "pressed",
G_CALLBACK (navigation_button_press_cb), self);
- self->forward_button_click_gesture = gtk_gesture_click_new (self->forward_button);
- gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (self->forward_button_click_gesture),
- GDK_BUTTON_SECONDARY);
- g_signal_connect (self->forward_button_click_gesture, "pressed",
+ controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ());
+ gtk_widget_add_controller (self->forward_button, controller);
+ gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), GDK_BUTTON_SECONDARY);
+ g_signal_connect (controller, "pressed",
G_CALLBACK (navigation_button_press_cb), self);
g_signal_connect (self->operations_popover, "show",
@@ -1035,8 +1033,6 @@ nautilus_toolbar_dispose (GObject *object)
self = NAUTILUS_TOOLBAR (object);
- g_clear_object (&self->forward_button_click_gesture);
- g_clear_object (&self->back_button_click_gesture);
g_clear_pointer (&self->icon_binding, g_binding_unbind);
g_clear_pointer (&self->search_binding, g_binding_unbind);
g_clear_pointer (&self->back_menu, gtk_widget_unparent);
@@ -1072,9 +1068,6 @@ nautilus_toolbar_finalize (GObject *obj)
g_signal_handlers_disconnect_by_func (self->window,
on_window_focus_changed, self);
- g_clear_object (&self->back_button_longpress_gesture);
- g_clear_object (&self->forward_button_longpress_gesture);
-
G_OBJECT_CLASS (nautilus_toolbar_parent_class)->finalize (obj);
}
diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-view-icon-controller.c
index 867301026..ac90d95cb 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -24,7 +24,6 @@ struct _NautilusViewIconController
gboolean single_click_mode;
gboolean activate_on_release;
- GtkGesture *click_gesture;
guint scroll_to_file_handle_id;
guint prioritize_thumbnailing_handle_id;
@@ -1190,7 +1189,6 @@ dispose (GObject *object)
self = NAUTILUS_VIEW_ICON_CONTROLLER (object);
- g_clear_object (&self->click_gesture);
g_clear_handle_id (&self->scroll_to_file_handle_id, g_source_remove);
g_clear_handle_id (&self->prioritize_thumbnailing_handle_id, g_source_remove);
@@ -1364,7 +1362,7 @@ constructed (GObject *object)
GtkAdjustment *hadjustment;
GtkAdjustment *vadjustment;
GActionGroup *view_action_group;
- GtkGesture *longpress_gesture;
+ GtkEventController *controller;
content_widget = nautilus_files_view_get_content_widget (NAUTILUS_FILES_VIEW (self));
hadjustment = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (content_widget));
@@ -1390,26 +1388,23 @@ constructed (GObject *object)
self->view_icon = g_themed_icon_new ("view-grid-symbolic");
/* Compensating for the lack of event boxen to allow clicks outside the flow box. */
- self->click_gesture = gtk_gesture_click_new (GTK_WIDGET (content_widget));
- gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (self->click_gesture),
- GTK_PHASE_CAPTURE);
- gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (self->click_gesture),
- 0);
- g_signal_connect (self->click_gesture, "pressed",
+ controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ());
+ gtk_widget_add_controller (GTK_WIDGET (content_widget), controller);
+ gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
+ gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), 0);
+ g_signal_connect (controller, "pressed",
G_CALLBACK (on_button_press_event), self);
- g_signal_connect (self->click_gesture, "stopped",
+ g_signal_connect (controller, "stopped",
G_CALLBACK (on_click_stopped), self);
- g_signal_connect (self->click_gesture, "released",
+ g_signal_connect (controller, "released",
G_CALLBACK (on_click_released), self);
- longpress_gesture = gtk_gesture_long_press_new (GTK_WIDGET (self->view_ui));
- gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (longpress_gesture),
- GTK_PHASE_CAPTURE);
- gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (longpress_gesture),
- TRUE);
- g_signal_connect (longpress_gesture, "pressed",
- (GCallback) on_longpress_gesture_pressed_callback,
- self);
+ controller = GTK_EVENT_CONTROLLER (gtk_gesture_long_press_new ());
+ gtk_widget_add_controller (GTK_WIDGET (self->view_ui), controller);
+ gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
+ gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (controller), TRUE);
+ g_signal_connect (controller, "pressed",
+ (GCallback) on_longpress_gesture_pressed_callback, self);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (content_widget),
GTK_WIDGET (self->view_ui));
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 6d2a8ffc5..6b1ade67e 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -150,13 +150,6 @@ struct _NautilusWindow
GMenuModel *tab_menu_model;
GQueue *tab_data_queue;
-
- GtkPadController *pad_controller;
-
- GtkGesture *click_gesture;
- GtkGesture *notebook_click_gesture;
- GtkEventController *key_capture_controller;
- GtkEventController *key_bubble_controller;
};
enum
@@ -1955,10 +1948,6 @@ setup_notebook (NautilusWindow *window)
g_signal_connect (window->notebook, "page-removed",
G_CALLBACK (notebook_page_removed_cb),
window);
-
- g_signal_connect (window->notebook_click_gesture, "pressed",
- G_CALLBACK (notebook_button_press_cb),
- window);
}
const GActionEntry win_entries[] =
@@ -2171,11 +2160,6 @@ nautilus_window_dispose (GObject *object)
nautilus_window_unexport_handle (window);
- g_clear_object (&window->notebook_click_gesture);
-
- g_clear_object (&window->key_capture_controller);
- g_clear_object (&window->key_bubble_controller);
-
G_OBJECT_CLASS (nautilus_window_parent_class)->dispose (object);
}
@@ -2213,8 +2197,6 @@ nautilus_window_finalize (GObject *object)
g_queue_free_full (window->tab_data_queue, free_navigation_state);
- g_object_unref (window->pad_controller);
-
/* nautilus_window_close() should have run */
g_assert (window->slots == NULL);
@@ -2605,6 +2587,8 @@ static void
nautilus_window_init (NautilusWindow *window)
{
GtkWindowGroup *window_group;
+ GtkPadController *pad_controller;
+ GtkEventController *controller;
g_type_ensure (NAUTILUS_TYPE_TOOLBAR);
gtk_widget_init_template (GTK_WIDGET (window));
@@ -2654,41 +2638,30 @@ nautilus_window_init (NautilusWindow *window)
window->tab_data_queue = g_queue_new ();
- window->pad_controller = gtk_pad_controller_new (GTK_WINDOW (window),
- G_ACTION_GROUP (window),
- NULL);
- gtk_pad_controller_set_action_entries (window->pad_controller,
+ pad_controller = gtk_pad_controller_new (G_ACTION_GROUP (window), NULL);
+ gtk_pad_controller_set_action_entries (pad_controller,
pad_actions, G_N_ELEMENTS (pad_actions));
-
- window->click_gesture = gtk_gesture_click_new (GTK_WIDGET (window));
-
- gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (window->click_gesture),
- GTK_PHASE_CAPTURE);
- gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (window->click_gesture), 0);
-
- g_signal_connect (window->click_gesture, "pressed",
+ gtk_widget_add_controller (GTK_WIDGET (window),
+ GTK_EVENT_CONTROLLER (pad_controller));
+
+ controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ());
+ gtk_widget_add_controller (GTK_WIDGET (window), controller);
+ gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
+ gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), 0);
+ g_signal_connect (controller, "pressed",
G_CALLBACK (on_click_gesture_pressed), NULL);
- window->notebook_click_gesture = gtk_gesture_click_new (window->notebook);
-
- gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (window->notebook_click_gesture),
- GTK_PHASE_CAPTURE);
- gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (window->notebook_click_gesture),
- 0);
-
- window->key_capture_controller = gtk_event_controller_key_new (GTK_WIDGET (window));
- gtk_event_controller_set_propagation_phase (window->key_capture_controller,
- GTK_PHASE_CAPTURE);
- g_signal_connect (window->key_capture_controller,
- "key-pressed", G_CALLBACK (nautilus_window_key_capture),
- NULL);
-
- window->key_bubble_controller = gtk_event_controller_key_new (GTK_WIDGET (window));
- gtk_event_controller_set_propagation_phase (window->key_bubble_controller,
- GTK_PHASE_BUBBLE);
- g_signal_connect (window->key_bubble_controller,
- "key-pressed", G_CALLBACK (nautilus_window_key_bubble),
- NULL);
+ controller = gtk_event_controller_key_new ();
+ gtk_widget_add_controller (GTK_WIDGET (window), controller);
+ gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE);
+ g_signal_connect (controller, "key-pressed",
+ G_CALLBACK (nautilus_window_key_capture), NULL);
+
+ controller = gtk_event_controller_key_new ();
+ gtk_widget_add_controller (GTK_WIDGET (window), controller);
+ gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_BUBBLE);
+ g_signal_connect (controller, "key-pressed",
+ G_CALLBACK (nautilus_window_key_bubble), NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]