diff options
author | Benjamin Otte <otte@redhat.com> | 2018-03-10 18:05:57 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2018-04-26 17:59:42 +0200 |
commit | 1e6eb1f8b94ad10f30678285860dc24877bbbac3 (patch) | |
tree | eef4b5f579a657072967e7f7dd047494af5add1d /gtk | |
parent | bf82149271b4f6bf6379b22eeea191dffe6823dd (diff) | |
download | gtk+-1e6eb1f8b94ad10f30678285860dc24877bbbac3.tar.gz |
draggesture: Port to new API model
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkcalendar.c | 9 | ||||
-rw-r--r-- | gtk/gtkcolorplane.c | 13 | ||||
-rw-r--r-- | gtk/gtkdragsource.c | 6 | ||||
-rw-r--r-- | gtk/gtkentry.c | 4 | ||||
-rw-r--r-- | gtk/gtkflowbox.c | 4 | ||||
-rw-r--r-- | gtk/gtkgesturedrag.c | 6 | ||||
-rw-r--r-- | gtk/gtkgesturedrag.h | 2 | ||||
-rw-r--r-- | gtk/gtklabel.c | 6 | ||||
-rw-r--r-- | gtk/gtkpaned.c | 4 | ||||
-rw-r--r-- | gtk/gtkrange.c | 4 | ||||
-rw-r--r-- | gtk/gtkscrolledwindow.c | 4 | ||||
-rw-r--r-- | gtk/gtktextview.c | 4 | ||||
-rw-r--r-- | gtk/gtktreeview.c | 8 | ||||
-rw-r--r-- | gtk/gtkwindow.c | 6 |
14 files changed, 37 insertions, 43 deletions
diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c index 704ce1808d..a4d3b930ca 100644 --- a/gtk/gtkcalendar.c +++ b/gtk/gtkcalendar.c @@ -249,7 +249,6 @@ struct _GtkCalendarPrivate gint detail_width_chars; gint detail_overflow[6]; - GtkGesture *drag_gesture; GtkEventController *scroll_controller; GtkEventController *key_controller; }; @@ -677,9 +676,10 @@ gtk_calendar_init (GtkCalendar *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); - g_signal_connect (priv->drag_gesture, "drag-update", G_CALLBACK (gtk_calendar_drag_update), calendar); + gesture = gtk_gesture_drag_new (); + g_signal_connect (gesture, "drag-begin", G_CALLBACK (gtk_calendar_drag_begin), calendar); + g_signal_connect (gesture, "drag-update", G_CALLBACK (gtk_calendar_drag_update), calendar); + gtk_widget_add_controller (GTK_WIDGET (calendar), GTK_EVENT_CONTROLLER (gesture)); priv->scroll_controller = gtk_event_controller_scroll_new (GTK_WIDGET (calendar), @@ -1333,7 +1333,6 @@ gtk_calendar_finalize (GObject *object) { GtkCalendarPrivate *priv = GTK_CALENDAR (object)->priv; - g_object_unref (priv->drag_gesture); g_object_unref (priv->scroll_controller); g_object_unref (priv->key_controller); diff --git a/gtk/gtkcolorplane.c b/gtk/gtkcolorplane.c index 30d0a80056..0d2ea83d38 100644 --- a/gtk/gtkcolorplane.c +++ b/gtk/gtkcolorplane.c @@ -37,7 +37,6 @@ struct _GtkColorPlanePrivate GdkTexture *texture; - GtkGesture *drag_gesture; GtkEventController *key_controller; }; @@ -408,14 +407,15 @@ gtk_color_plane_init (GtkColorPlane *plane) atk_object_set_role (atk_obj, ATK_ROLE_COLOR_CHOOSER); } - plane->priv->drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (plane)); - g_signal_connect (plane->priv->drag_gesture, "drag-begin", + gesture = gtk_gesture_drag_new (); + g_signal_connect (gesture, "drag-begin", G_CALLBACK (plane_drag_gesture_begin), plane); - g_signal_connect (plane->priv->drag_gesture, "drag-update", + g_signal_connect (gesture, "drag-update", G_CALLBACK (plane_drag_gesture_update), plane); - g_signal_connect (plane->priv->drag_gesture, "drag-end", + g_signal_connect (gesture, "drag-end", G_CALLBACK (plane_drag_gesture_end), plane); - gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (plane->priv->drag_gesture), 0); + gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0); + gtk_widget_add_controller (GTK_WIDGET (plane), GTK_EVENT_CONTROLLER (gesture)); gesture = gtk_gesture_long_press_new (); g_signal_connect (gesture, "pressed", @@ -440,7 +440,6 @@ plane_finalize (GObject *object) g_clear_object (&plane->priv->s_adj); g_clear_object (&plane->priv->v_adj); - g_clear_object (&plane->priv->drag_gesture); g_clear_object (&plane->priv->key_controller); G_OBJECT_CLASS (gtk_color_plane_parent_class)->finalize (object); diff --git a/gtk/gtkdragsource.c b/gtk/gtkdragsource.c index b74c12ee03..b13be2e367 100644 --- a/gtk/gtkdragsource.c +++ b/gtk/gtkdragsource.c @@ -108,7 +108,8 @@ gtk_drag_source_site_destroy (gpointer data) gdk_content_formats_unref (site->target_list); gtk_image_definition_unref (site->image_def); - g_clear_object (&site->drag_gesture); + /* This gets called only during widget finalization. + * And widget finalization takes care of gestures. */ g_slice_free (GtkDragSourceSite, site); } @@ -144,7 +145,7 @@ gtk_drag_source_set (GtkWidget *widget, { site = g_slice_new0 (GtkDragSourceSite); site->image_def = gtk_image_definition_new_empty (); - site->drag_gesture = gtk_gesture_drag_new (widget); + site->drag_gesture = gtk_gesture_drag_new (); gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (site->drag_gesture), GTK_PHASE_BUBBLE); gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (site->drag_gesture), 0); @@ -154,6 +155,7 @@ gtk_drag_source_set (GtkWidget *widget, g_signal_connect (site->drag_gesture, "update", G_CALLBACK (gtk_drag_source_gesture_update), site); + gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (site->drag_gesture)); g_object_set_data_full (G_OBJECT (widget), I_("gtk-site-data"), diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 804cf13b57..51863a4573 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -2557,13 +2557,14 @@ gtk_entry_init (GtkEntry *entry) gtk_entry_update_cached_style_values (entry); - priv->drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (entry)); + priv->drag_gesture = gtk_gesture_drag_new (); g_signal_connect (priv->drag_gesture, "drag-update", G_CALLBACK (gtk_entry_drag_gesture_update), entry); g_signal_connect (priv->drag_gesture, "drag-end", G_CALLBACK (gtk_entry_drag_gesture_end), 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); + gtk_widget_add_controller (GTK_WIDGET (entry), GTK_EVENT_CONTROLLER (priv->drag_gesture)); gesture = gtk_gesture_multi_press_new (); g_signal_connect (gesture, "pressed", @@ -2796,7 +2797,6 @@ gtk_entry_finalize (GObject *object) g_free (priv->placeholder_text); g_free (priv->im_module); - g_clear_object (&priv->drag_gesture); g_clear_object (&priv->motion_controller); if (priv->tabs) diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c index 1c4ed8db98..f294e4b572 100644 --- a/gtk/gtkflowbox.c +++ b/gtk/gtkflowbox.c @@ -3377,7 +3377,6 @@ gtk_flow_box_finalize (GObject *obj) g_clear_object (&priv->hadjustment); g_clear_object (&priv->vadjustment); - g_object_unref (priv->drag_gesture); g_object_unref (priv->key_controller); if (priv->bound_model) @@ -3757,7 +3756,7 @@ gtk_flow_box_init (GtkFlowBox *box) 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)); + priv->drag_gesture = gtk_gesture_drag_new (); gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->drag_gesture), FALSE); gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->drag_gesture), @@ -3770,6 +3769,7 @@ gtk_flow_box_init (GtkFlowBox *box) G_CALLBACK (gtk_flow_box_drag_gesture_update), box); g_signal_connect (priv->drag_gesture, "drag-end", G_CALLBACK (gtk_flow_box_drag_gesture_end), box); + gtk_widget_add_controller (GTK_WIDGET (box), GTK_EVENT_CONTROLLER (priv->drag_gesture)); priv->key_controller = gtk_event_controller_key_new (GTK_WIDGET (box)); g_signal_connect (priv->key_controller, "key-pressed", diff --git a/gtk/gtkgesturedrag.c b/gtk/gtkgesturedrag.c index 11d7752056..baccf2f2df 100644 --- a/gtk/gtkgesturedrag.c +++ b/gtk/gtkgesturedrag.c @@ -195,19 +195,15 @@ gtk_gesture_drag_init (GtkGestureDrag *gesture) /** * gtk_gesture_drag_new: - * @widget: a #GtkWidget * * Returns a newly created #GtkGesture that recognizes drags. * * Returns: a newly created #GtkGestureDrag **/ GtkGesture * -gtk_gesture_drag_new (GtkWidget *widget) +gtk_gesture_drag_new (void) { - g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); - return g_object_new (GTK_TYPE_GESTURE_DRAG, - "widget", widget, NULL); } diff --git a/gtk/gtkgesturedrag.h b/gtk/gtkgesturedrag.h index ab0cba773c..2493e65de4 100644 --- a/gtk/gtkgesturedrag.h +++ b/gtk/gtkgesturedrag.h @@ -42,7 +42,7 @@ GDK_AVAILABLE_IN_ALL GType gtk_gesture_drag_get_type (void) G_GNUC_CONST; GDK_AVAILABLE_IN_ALL -GtkGesture * gtk_gesture_drag_new (GtkWidget *widget); +GtkGesture * gtk_gesture_drag_new (void); GDK_AVAILABLE_IN_ALL gboolean gtk_gesture_drag_get_start_point (GtkGestureDrag *gesture, diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index c15cd69459..5cce92f33b 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -3177,7 +3177,6 @@ gtk_label_finalize (GObject *object) if (priv->select_info) { - g_object_unref (priv->select_info->drag_gesture); g_object_unref (priv->select_info->motion_controller); g_object_unref (priv->select_info->provider); } @@ -5016,12 +5015,13 @@ gtk_label_ensure_select_info (GtkLabel *label) if (gtk_widget_get_realized (GTK_WIDGET (label))) gtk_label_set_selectable_hint (label); - priv->select_info->drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (label)); + priv->select_info->drag_gesture = gtk_gesture_drag_new (); g_signal_connect (priv->select_info->drag_gesture, "drag-begin", G_CALLBACK (gtk_label_drag_gesture_begin), label); g_signal_connect (priv->select_info->drag_gesture, "drag-update", G_CALLBACK (gtk_label_drag_gesture_update), label); gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (priv->select_info->drag_gesture), TRUE); + gtk_widget_add_controller (GTK_WIDGET (label), GTK_EVENT_CONTROLLER (priv->select_info->drag_gesture)); priv->select_info->multipress_gesture = gtk_gesture_multi_press_new (); g_signal_connect (priv->select_info->multipress_gesture, "pressed", @@ -5053,7 +5053,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); + gtk_widget_remove_controller (GTK_WIDGET (label), GTK_EVENT_CONTROLLER (priv->select_info->drag_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; diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c index 5f44775ad5..d53c9e6497 100644 --- a/gtk/gtkpaned.c +++ b/gtk/gtkpaned.c @@ -993,7 +993,6 @@ gtk_paned_finalize (GObject *object) gtk_paned_set_saved_focus (paned, NULL); gtk_paned_set_first_paned (paned, NULL); - g_clear_object (&priv->drag_gesture); g_clear_object (&priv->motion_controller); gtk_widget_unparent (priv->handle_widget); @@ -1490,10 +1489,11 @@ gtk_paned_init (GtkPaned *paned) priv->pan_gesture = gesture; /* Pointer gesture */ - gesture = gtk_gesture_drag_new (GTK_WIDGET (paned)); + gesture = gtk_gesture_drag_new (); gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture), GTK_PHASE_CAPTURE); connect_drag_gesture_signals (paned, gesture); + gtk_widget_add_controller (GTK_WIDGET (paned), GTK_EVENT_CONTROLLER (gesture)); priv->drag_gesture = gesture; priv->motion_controller = gtk_event_controller_motion_new (GTK_WIDGET (paned)); diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index f79e60beb6..61efac09d9 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -567,12 +567,13 @@ gtk_range_init (GtkRange *range) * in the oppposite order in which they are added to their * widget. */ - priv->drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (range)); + priv->drag_gesture = gtk_gesture_drag_new (); gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->drag_gesture), 0); g_signal_connect (priv->drag_gesture, "drag-begin", G_CALLBACK (gtk_range_drag_gesture_begin), range); g_signal_connect (priv->drag_gesture, "drag-update", G_CALLBACK (gtk_range_drag_gesture_update), range); + gtk_widget_add_controller (GTK_WIDGET (range), GTK_EVENT_CONTROLLER (priv->drag_gesture)); priv->multipress_gesture = gtk_gesture_multi_press_new (); gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->multipress_gesture), 0); @@ -1293,7 +1294,6 @@ gtk_range_finalize (GObject *object) GtkRange *range = GTK_RANGE (object); GtkRangePrivate *priv = gtk_range_get_instance_private (range); - g_clear_object (&priv->drag_gesture); g_clear_object (&priv->scroll_controller); g_clear_object (&priv->key_controller); diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index 65eedc4dff..a6f8e19a75 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -1919,7 +1919,7 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window) priv->overlay_scrolling = TRUE; - priv->drag_gesture = gtk_gesture_drag_new (widget); + priv->drag_gesture = gtk_gesture_drag_new (); gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->drag_gesture), TRUE); g_signal_connect_swapped (priv->drag_gesture, "drag-begin", G_CALLBACK (scrolled_window_drag_begin_cb), @@ -1930,6 +1930,7 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window) g_signal_connect_swapped (priv->drag_gesture, "end", G_CALLBACK (scrolled_window_drag_end_cb), scrolled_window); + gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (priv->drag_gesture)); priv->pan_gesture = gtk_gesture_pan_new (GTK_ORIENTATION_VERTICAL); gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->pan_gesture), TRUE); @@ -2616,7 +2617,6 @@ gtk_scrolled_window_finalize (GObject *object) GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (object); GtkScrolledWindowPrivate *priv = scrolled_window->priv; - g_clear_object (&priv->drag_gesture); g_clear_object (&priv->scroll_controller); diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index c50fe411f7..49b47a38e6 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -1678,13 +1678,14 @@ gtk_text_view_init (GtkTextView *text_view) widget); gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (gesture)); - priv->drag_gesture = gtk_gesture_drag_new (widget); + priv->drag_gesture = gtk_gesture_drag_new (); g_signal_connect (priv->drag_gesture, "drag-update", G_CALLBACK (gtk_text_view_drag_gesture_update), widget); g_signal_connect (priv->drag_gesture, "drag-end", G_CALLBACK (gtk_text_view_drag_gesture_end), widget); + gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (priv->drag_gesture)); priv->motion_controller = gtk_event_controller_motion_new (widget); g_signal_connect (priv->motion_controller, "motion", G_CALLBACK (gtk_text_view_motion), widget); @@ -3600,7 +3601,6 @@ gtk_text_view_finalize (GObject *object) cancel_pending_scroll (text_view); - g_object_unref (priv->drag_gesture); g_object_unref (priv->motion_controller); g_object_unref (priv->key_controller); diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index 6e928d2a79..02e4038b18 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -1730,15 +1730,16 @@ gtk_tree_view_init (GtkTreeView *tree_view) GTK_PHASE_CAPTURE); gtk_widget_add_controller (GTK_WIDGET (tree_view), GTK_EVENT_CONTROLLER (gesture)); - priv->drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (tree_view)); + priv->drag_gesture = gtk_gesture_drag_new (); g_signal_connect (priv->drag_gesture, "drag-begin", G_CALLBACK (gtk_tree_view_drag_gesture_begin), tree_view); g_signal_connect (priv->drag_gesture, "drag-update", G_CALLBACK (gtk_tree_view_drag_gesture_update), tree_view); g_signal_connect (priv->drag_gesture, "drag-end", G_CALLBACK (gtk_tree_view_drag_gesture_end), tree_view); + gtk_widget_add_controller (GTK_WIDGET (tree_view), GTK_EVENT_CONTROLLER (priv->drag_gesture)); - priv->column_drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (tree_view)); + priv->column_drag_gesture = gtk_gesture_drag_new (); g_signal_connect (priv->column_drag_gesture, "drag-begin", G_CALLBACK (gtk_tree_view_column_drag_gesture_begin), tree_view); g_signal_connect (priv->column_drag_gesture, "drag-update", @@ -1747,6 +1748,7 @@ gtk_tree_view_init (GtkTreeView *tree_view) G_CALLBACK (gtk_tree_view_column_drag_gesture_end), tree_view); gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->column_drag_gesture), GTK_PHASE_CAPTURE); + gtk_widget_add_controller (GTK_WIDGET (tree_view), GTK_EVENT_CONTROLLER (priv->column_drag_gesture)); priv->motion_controller = gtk_event_controller_motion_new (GTK_WIDGET (tree_view)); g_signal_connect (priv->motion_controller, "enter", @@ -2138,8 +2140,6 @@ gtk_tree_view_destroy (GtkWidget *widget) tree_view->priv->vadjustment = NULL; } - g_clear_object (&tree_view->priv->drag_gesture); - g_clear_object (&tree_view->priv->column_drag_gesture); g_clear_object (&tree_view->priv->motion_controller); GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->destroy (widget); diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 2e39cb0e2b..b8be885df7 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -1971,13 +1971,14 @@ gtk_window_constructed (GObject *object) G_CALLBACK (multipress_gesture_pressed_cb), object); gtk_widget_add_controller (GTK_WIDGET (object), GTK_EVENT_CONTROLLER (priv->multipress_gesture)); - priv->drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (object)); + priv->drag_gesture = gtk_gesture_drag_new (); gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (priv->drag_gesture), GTK_PHASE_CAPTURE); g_signal_connect (priv->drag_gesture, "drag-begin", G_CALLBACK (drag_gesture_begin_cb), object); g_signal_connect (priv->drag_gesture, "drag-update", G_CALLBACK (drag_gesture_update_cb), object); + gtk_widget_add_controller (GTK_WIDGET (object), GTK_EVENT_CONTROLLER (priv->drag_gesture)); } } @@ -5953,9 +5954,6 @@ gtk_window_finalize (GObject *object) priv->mnemonics_display_timeout_id = 0; } - if (priv->drag_gesture) - g_object_unref (priv->drag_gesture); - g_clear_object (&priv->renderer); G_OBJECT_CLASS (gtk_window_parent_class)->finalize (object); |