mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 05:50:10 +00:00
eventcontrollermotion: Port to new API model
This commit is contained in:
parent
74dbb057ed
commit
4f3058f195
@ -213,7 +213,6 @@ struct _GtkEntryPrivate
|
||||
GtkWidget *magnifier;
|
||||
|
||||
GtkGesture *drag_gesture;
|
||||
GtkEventController *motion_controller;
|
||||
GtkEventController *key_controller;
|
||||
|
||||
GtkWidget *progress_widget;
|
||||
@ -2517,6 +2516,7 @@ gtk_entry_init (GtkEntry *entry)
|
||||
GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
|
||||
GtkCssNode *widget_node;
|
||||
GtkGesture *gesture;
|
||||
GtkEventController *controller;
|
||||
gint i;
|
||||
|
||||
gtk_widget_set_can_focus (GTK_WIDGET (entry), TRUE);
|
||||
@ -2573,9 +2573,10 @@ gtk_entry_init (GtkEntry *entry)
|
||||
gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (gesture), TRUE);
|
||||
gtk_widget_add_controller (GTK_WIDGET (entry), GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
priv->motion_controller = gtk_event_controller_motion_new (GTK_WIDGET (entry));
|
||||
g_signal_connect (priv->motion_controller, "motion",
|
||||
controller = gtk_event_controller_motion_new ();
|
||||
g_signal_connect (controller, "motion",
|
||||
G_CALLBACK (entry_motion_cb), entry);
|
||||
gtk_widget_add_controller (GTK_WIDGET (entry), controller);
|
||||
|
||||
priv->key_controller = gtk_event_controller_key_new (GTK_WIDGET (entry));
|
||||
g_signal_connect (priv->key_controller, "key-pressed",
|
||||
@ -2797,8 +2798,6 @@ gtk_entry_finalize (GObject *object)
|
||||
g_free (priv->placeholder_text);
|
||||
g_free (priv->im_module);
|
||||
|
||||
g_clear_object (&priv->motion_controller);
|
||||
|
||||
if (priv->tabs)
|
||||
pango_tab_array_free (priv->tabs);
|
||||
|
||||
|
@ -149,19 +149,14 @@ gtk_event_controller_motion_init (GtkEventControllerMotion *motion)
|
||||
|
||||
/**
|
||||
* gtk_event_controller_motion_new:
|
||||
* @widget: a #GtkWidget
|
||||
*
|
||||
* Creates a new event controller that will handle motion events
|
||||
* for the given @widget.
|
||||
* Creates a new event controller that will handle motion events.
|
||||
*
|
||||
* Returns: a new #GtkEventControllerMotion
|
||||
**/
|
||||
GtkEventController *
|
||||
gtk_event_controller_motion_new (GtkWidget *widget)
|
||||
gtk_event_controller_motion_new (void)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
|
||||
return g_object_new (GTK_TYPE_EVENT_CONTROLLER_MOTION,
|
||||
"widget", widget,
|
||||
NULL);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_event_controller_motion_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkEventController *gtk_event_controller_motion_new (GtkWidget *widget);
|
||||
GtkEventController *gtk_event_controller_motion_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -918,6 +918,7 @@ gtk_icon_view_cell_layout_init (GtkCellLayoutIface *iface)
|
||||
static void
|
||||
gtk_icon_view_init (GtkIconView *icon_view)
|
||||
{
|
||||
GtkEventController *controller;
|
||||
GtkGesture *gesture;
|
||||
|
||||
icon_view->priv = gtk_icon_view_get_instance_private (icon_view);
|
||||
@ -966,11 +967,12 @@ gtk_icon_view_init (GtkIconView *icon_view)
|
||||
icon_view);
|
||||
gtk_widget_add_controller (GTK_WIDGET (icon_view), GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
icon_view->priv->motion_controller = gtk_event_controller_motion_new (GTK_WIDGET (icon_view));
|
||||
g_signal_connect (icon_view->priv->motion_controller, "leave", G_CALLBACK (gtk_icon_view_leave),
|
||||
controller = gtk_event_controller_motion_new ();
|
||||
g_signal_connect (controller, "leave", G_CALLBACK (gtk_icon_view_leave),
|
||||
icon_view);
|
||||
g_signal_connect (icon_view->priv->motion_controller, "motion", G_CALLBACK (gtk_icon_view_motion),
|
||||
g_signal_connect (controller, "motion", G_CALLBACK (gtk_icon_view_motion),
|
||||
icon_view);
|
||||
gtk_widget_add_controller (GTK_WIDGET (icon_view), controller);
|
||||
|
||||
icon_view->priv->key_controller = gtk_event_controller_key_new (GTK_WIDGET (icon_view));
|
||||
g_signal_connect (icon_view->priv->key_controller, "key-pressed", G_CALLBACK (gtk_icon_view_key_pressed),
|
||||
@ -1023,7 +1025,6 @@ gtk_icon_view_dispose (GObject *object)
|
||||
priv->cell_area = NULL;
|
||||
}
|
||||
|
||||
g_clear_object (&priv->motion_controller);
|
||||
g_clear_object (&priv->key_controller);
|
||||
|
||||
G_OBJECT_CLASS (gtk_icon_view_parent_class)->dispose (object);
|
||||
|
@ -60,7 +60,6 @@ struct _GtkIconViewPrivate
|
||||
|
||||
GList *items;
|
||||
|
||||
GtkEventController *motion_controller;
|
||||
GtkEventController *key_controller;
|
||||
|
||||
GtkAdjustment *hadjustment;
|
||||
|
@ -3177,7 +3177,6 @@ gtk_label_finalize (GObject *object)
|
||||
|
||||
if (priv->select_info)
|
||||
{
|
||||
g_object_unref (priv->select_info->motion_controller);
|
||||
g_object_unref (priv->select_info->provider);
|
||||
}
|
||||
|
||||
@ -5032,11 +5031,12 @@ gtk_label_ensure_select_info (GtkLabel *label)
|
||||
gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (priv->select_info->multipress_gesture), TRUE);
|
||||
gtk_widget_add_controller (GTK_WIDGET (label), GTK_EVENT_CONTROLLER (priv->select_info->multipress_gesture));
|
||||
|
||||
priv->select_info->motion_controller = gtk_event_controller_motion_new (GTK_WIDGET (label));
|
||||
priv->select_info->motion_controller = gtk_event_controller_motion_new ();
|
||||
g_signal_connect (priv->select_info->motion_controller, "motion",
|
||||
G_CALLBACK (gtk_label_motion), label);
|
||||
g_signal_connect (priv->select_info->motion_controller, "leave",
|
||||
G_CALLBACK (gtk_label_leave), label);
|
||||
gtk_widget_add_controller (GTK_WIDGET (label), priv->select_info->motion_controller);
|
||||
|
||||
priv->select_info->provider = g_object_new (GTK_TYPE_LABEL_CONTENT, NULL);
|
||||
GTK_LABEL_CONTENT (priv->select_info->provider)->label = label;
|
||||
@ -5055,7 +5055,7 @@ gtk_label_clear_select_info (GtkLabel *label)
|
||||
{
|
||||
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_widget_remove_controller (GTK_WIDGET (label), priv->select_info->motion_controller);
|
||||
GTK_LABEL_CONTENT (priv->select_info->provider)->label = NULL;
|
||||
g_object_unref (priv->select_info->provider);
|
||||
|
||||
|
@ -1144,11 +1144,11 @@ gtk_menu_init (GtkMenu *menu)
|
||||
G_CALLBACK (gtk_menu_scroll_controller_scroll), menu);
|
||||
gtk_widget_add_controller (GTK_WIDGET (menu), controller);
|
||||
|
||||
priv->motion_controller =
|
||||
gtk_event_controller_motion_new (GTK_WIDGET (menu));
|
||||
g_signal_connect (priv->motion_controller, "enter", G_CALLBACK (gtk_menu_enter), menu);
|
||||
g_signal_connect (priv->motion_controller, "motion", G_CALLBACK (gtk_menu_motion), menu);
|
||||
g_signal_connect (priv->motion_controller, "leave", G_CALLBACK (gtk_menu_leave), menu);
|
||||
controller = gtk_event_controller_motion_new ();
|
||||
g_signal_connect (controller, "enter", G_CALLBACK (gtk_menu_enter), menu);
|
||||
g_signal_connect (controller, "motion", G_CALLBACK (gtk_menu_motion), menu);
|
||||
g_signal_connect (controller, "leave", G_CALLBACK (gtk_menu_leave), menu);
|
||||
gtk_widget_add_controller (GTK_WIDGET (menu), controller);
|
||||
|
||||
priv->key_controller =
|
||||
gtk_event_controller_key_new (GTK_WIDGET (menu));
|
||||
@ -1225,7 +1225,6 @@ gtk_menu_finalize (GObject *object)
|
||||
|
||||
gtk_widget_unparent (priv->top_arrow_widget);
|
||||
gtk_widget_unparent (priv->bottom_arrow_widget);
|
||||
g_clear_object (&priv->motion_controller);
|
||||
g_clear_object (&priv->key_controller);
|
||||
|
||||
G_OBJECT_CLASS (gtk_menu_parent_class)->finalize (object);
|
||||
|
@ -661,6 +661,7 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass)
|
||||
static void
|
||||
gtk_menu_item_init (GtkMenuItem *menu_item)
|
||||
{
|
||||
GtkEventController *controller;
|
||||
GtkMenuItemPrivate *priv;
|
||||
|
||||
priv = gtk_menu_item_get_instance_private (menu_item);
|
||||
@ -680,9 +681,10 @@ gtk_menu_item_init (GtkMenuItem *menu_item)
|
||||
priv->submenu_placement = GTK_TOP_BOTTOM;
|
||||
priv->timer = 0;
|
||||
|
||||
priv->motion_controller = gtk_event_controller_motion_new (GTK_WIDGET (menu_item));
|
||||
g_signal_connect (priv->motion_controller, "enter", G_CALLBACK (gtk_menu_item_enter), menu_item);
|
||||
g_signal_connect (priv->motion_controller, "leave", G_CALLBACK (gtk_menu_item_leave), menu_item);
|
||||
controller = gtk_event_controller_motion_new ();
|
||||
g_signal_connect (controller, "enter", G_CALLBACK (gtk_menu_item_enter), menu_item);
|
||||
g_signal_connect (controller, "leave", G_CALLBACK (gtk_menu_item_leave), menu_item);
|
||||
gtk_widget_add_controller (GTK_WIDGET (menu_item), controller);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,7 +75,6 @@ struct _GtkMenuPrivate
|
||||
GtkWidget *top_arrow_widget;
|
||||
GtkWidget *bottom_arrow_widget;
|
||||
|
||||
GtkEventController *motion_controller;
|
||||
GtkEventController *key_controller;
|
||||
|
||||
gint scroll_offset;
|
||||
|
@ -207,8 +207,6 @@ struct _GtkNotebookPrivate
|
||||
guint switch_tab_timer;
|
||||
GList *switch_tab;
|
||||
|
||||
GtkEventController *motion_controller;
|
||||
|
||||
guint32 timer;
|
||||
|
||||
guint child_has_focus : 1;
|
||||
@ -1041,6 +1039,7 @@ gtk_notebook_init (GtkNotebook *notebook)
|
||||
{
|
||||
GtkNotebookPrivate *priv;
|
||||
GdkContentFormats *targets;
|
||||
GtkEventController *controller;
|
||||
GtkGesture *gesture;
|
||||
|
||||
gtk_widget_set_can_focus (GTK_WIDGET (notebook), TRUE);
|
||||
@ -1118,8 +1117,9 @@ gtk_notebook_init (GtkNotebook *notebook)
|
||||
g_signal_connect (gesture, "released", G_CALLBACK (gtk_notebook_gesture_released), notebook);
|
||||
gtk_widget_add_controller (GTK_WIDGET (notebook), GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
priv->motion_controller = gtk_event_controller_motion_new (GTK_WIDGET (notebook));
|
||||
g_signal_connect (priv->motion_controller, "motion", G_CALLBACK (gtk_notebook_motion), notebook);
|
||||
controller = gtk_event_controller_motion_new ();
|
||||
g_signal_connect (controller, "motion", G_CALLBACK (gtk_notebook_motion), notebook);
|
||||
gtk_widget_add_controller (GTK_WIDGET (notebook), controller);
|
||||
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (notebook)),
|
||||
GTK_STYLE_CLASS_FRAME);
|
||||
@ -1609,7 +1609,6 @@ gtk_notebook_finalize (GObject *object)
|
||||
GtkNotebook *notebook = GTK_NOTEBOOK (object);
|
||||
GtkNotebookPrivate *priv = notebook->priv;
|
||||
|
||||
g_clear_object (&priv->motion_controller);
|
||||
gtk_widget_unparent (priv->box);
|
||||
|
||||
G_OBJECT_CLASS (gtk_notebook_parent_class)->finalize (object);
|
||||
|
@ -145,7 +145,6 @@ struct _GtkPanedPrivate
|
||||
|
||||
GtkGesture *pan_gesture; /* Used for touch */
|
||||
GtkGesture *drag_gesture; /* Used for mice */
|
||||
GtkEventController *motion_controller;
|
||||
|
||||
gint child1_size;
|
||||
gint drag_pos;
|
||||
@ -993,8 +992,6 @@ gtk_paned_finalize (GObject *object)
|
||||
gtk_paned_set_saved_focus (paned, NULL);
|
||||
gtk_paned_set_first_paned (paned, NULL);
|
||||
|
||||
g_clear_object (&priv->motion_controller);
|
||||
|
||||
gtk_widget_unparent (priv->handle_widget);
|
||||
|
||||
G_OBJECT_CLASS (gtk_paned_parent_class)->finalize (object);
|
||||
@ -1453,6 +1450,7 @@ static void
|
||||
gtk_paned_init (GtkPaned *paned)
|
||||
{
|
||||
GtkPanedPrivate *priv = gtk_paned_get_instance_private (paned);
|
||||
GtkEventController *controller;
|
||||
GtkGesture *gesture;
|
||||
|
||||
gtk_widget_set_has_surface (GTK_WIDGET (paned), FALSE);
|
||||
@ -1496,8 +1494,9 @@ gtk_paned_init (GtkPaned *paned)
|
||||
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));
|
||||
g_signal_connect (priv->motion_controller, "motion", G_CALLBACK (gtk_paned_motion), paned);
|
||||
controller = gtk_event_controller_motion_new ();
|
||||
g_signal_connect (controller, "motion", G_CALLBACK (gtk_paned_motion), paned);
|
||||
gtk_widget_add_controller (GTK_WIDGET (paned), controller);
|
||||
|
||||
priv->handle_widget = gtk_gizmo_new ("separator",
|
||||
NULL,
|
||||
|
@ -259,8 +259,6 @@ struct _GtkScrolledWindowPrivate
|
||||
GtkGesture *drag_gesture;
|
||||
GtkGesture *pan_gesture;
|
||||
|
||||
GtkEventController *motion_controller;
|
||||
|
||||
gdouble drag_start_x;
|
||||
gdouble drag_start_y;
|
||||
|
||||
@ -1989,9 +1987,10 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
|
||||
G_CALLBACK (scroll_controller_decelerate), scrolled_window);
|
||||
gtk_widget_add_controller (widget, controller);
|
||||
|
||||
priv->motion_controller = gtk_event_controller_motion_new (widget);
|
||||
g_signal_connect (priv->motion_controller, "leave",
|
||||
controller = gtk_event_controller_motion_new ();
|
||||
g_signal_connect (controller, "leave",
|
||||
G_CALLBACK (motion_controller_leave), scrolled_window);
|
||||
gtk_widget_add_controller (widget, controller);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -225,7 +225,6 @@ struct _GtkTextViewPrivate
|
||||
GtkTextPendingScroll *pending_scroll;
|
||||
|
||||
GtkGesture *drag_gesture;
|
||||
GtkEventController *motion_controller;
|
||||
GtkEventController *key_controller;
|
||||
|
||||
GtkCssNode *selection_node;
|
||||
@ -1616,6 +1615,7 @@ gtk_text_view_init (GtkTextView *text_view)
|
||||
GdkContentFormats *target_list;
|
||||
GtkTextViewPrivate *priv;
|
||||
GtkStyleContext *context;
|
||||
GtkEventController *controller;
|
||||
GtkGesture *gesture;
|
||||
|
||||
text_view->priv = gtk_text_view_get_instance_private (text_view);
|
||||
@ -1687,8 +1687,9 @@ gtk_text_view_init (GtkTextView *text_view)
|
||||
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);
|
||||
controller = gtk_event_controller_motion_new ();
|
||||
g_signal_connect (controller, "motion", G_CALLBACK (gtk_text_view_motion), widget);
|
||||
gtk_widget_add_controller (widget, controller);
|
||||
|
||||
priv->key_controller = gtk_event_controller_key_new (widget);
|
||||
g_signal_connect (priv->key_controller, "key-pressed",
|
||||
@ -3601,7 +3602,6 @@ gtk_text_view_finalize (GObject *object)
|
||||
|
||||
cancel_pending_scroll (text_view);
|
||||
|
||||
g_object_unref (priv->motion_controller);
|
||||
g_object_unref (priv->key_controller);
|
||||
|
||||
if (priv->tabs)
|
||||
|
@ -461,7 +461,6 @@ struct _GtkTreeViewPrivate
|
||||
GtkGesture *multipress_gesture;
|
||||
GtkGesture *drag_gesture; /* Rubberbanding, row DnD */
|
||||
GtkGesture *column_drag_gesture; /* Column reordering, resizing */
|
||||
GtkEventController *motion_controller;
|
||||
|
||||
/* Tooltip support */
|
||||
gint tooltip_column;
|
||||
@ -1648,6 +1647,7 @@ gtk_tree_view_init (GtkTreeView *tree_view)
|
||||
GtkTreeViewPrivate *priv;
|
||||
GtkCssNode *widget_node;
|
||||
GtkGesture *gesture;
|
||||
GtkEventController *controller;
|
||||
|
||||
priv = tree_view->priv = gtk_tree_view_get_instance_private (tree_view);
|
||||
|
||||
@ -1750,13 +1750,14 @@ gtk_tree_view_init (GtkTreeView *tree_view)
|
||||
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",
|
||||
controller = gtk_event_controller_motion_new ();
|
||||
g_signal_connect (controller, "enter",
|
||||
G_CALLBACK (gtk_tree_view_motion_controller_enter), tree_view);
|
||||
g_signal_connect (priv->motion_controller, "leave",
|
||||
g_signal_connect (controller, "leave",
|
||||
G_CALLBACK (gtk_tree_view_motion_controller_leave), tree_view);
|
||||
g_signal_connect (priv->motion_controller, "motion",
|
||||
g_signal_connect (controller, "motion",
|
||||
G_CALLBACK (gtk_tree_view_motion_controller_motion), tree_view);
|
||||
gtk_widget_add_controller (GTK_WIDGET (tree_view), controller);
|
||||
}
|
||||
|
||||
|
||||
@ -2140,8 +2141,6 @@ gtk_tree_view_destroy (GtkWidget *widget)
|
||||
tree_view->priv->vadjustment = NULL;
|
||||
}
|
||||
|
||||
g_clear_object (&tree_view->priv->motion_controller);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->destroy (widget);
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,6 @@ struct _GtkVideo
|
||||
GFile *file;
|
||||
GtkMediaStream *media_stream;
|
||||
|
||||
GtkEventController *motion_controller;
|
||||
|
||||
GtkWidget *box;
|
||||
GtkWidget *video_image;
|
||||
GtkWidget *overlay_icon;
|
||||
@ -71,6 +69,32 @@ G_DEFINE_TYPE (GtkVideo, gtk_video, GTK_TYPE_WIDGET)
|
||||
|
||||
static GParamSpec *properties[N_PROPS] = { NULL, };
|
||||
|
||||
static gboolean
|
||||
gtk_video_hide_controls (gpointer data)
|
||||
{
|
||||
GtkVideo *self = data;
|
||||
|
||||
gtk_revealer_set_reveal_child (GTK_REVEALER (self->controls_revealer), FALSE);
|
||||
|
||||
self->controls_hide_source = 0;
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_video_motion (GtkEventControllerMotion *motion,
|
||||
double x,
|
||||
double y,
|
||||
GtkVideo *self)
|
||||
{
|
||||
gtk_revealer_set_reveal_child (GTK_REVEALER (self->controls_revealer), TRUE);
|
||||
if (self->controls_hide_source)
|
||||
g_source_remove (self->controls_hide_source);
|
||||
self->controls_hide_source = g_timeout_add (5 * 1000,
|
||||
gtk_video_hide_controls,
|
||||
self);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_video_measure (GtkWidget *widget,
|
||||
GtkOrientation orientation,
|
||||
@ -159,7 +183,6 @@ gtk_video_dispose (GObject *object)
|
||||
|
||||
gtk_video_set_media_stream (self, NULL);
|
||||
|
||||
g_clear_object (&self->motion_controller);
|
||||
g_clear_pointer (&self->box, gtk_widget_unparent);
|
||||
|
||||
G_OBJECT_CLASS (gtk_video_parent_class)->dispose (object);
|
||||
@ -302,44 +325,16 @@ gtk_video_class_init (GtkVideoClass *klass)
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkVideo, overlay_icon);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkVideo, controls);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkVideo, controls_revealer);
|
||||
gtk_widget_class_bind_template_callback (widget_class, gtk_video_motion);
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, I_("video"));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_video_hide_controls (gpointer data)
|
||||
{
|
||||
GtkVideo *self = data;
|
||||
|
||||
gtk_revealer_set_reveal_child (GTK_REVEALER (self->controls_revealer), FALSE);
|
||||
|
||||
self->controls_hide_source = 0;
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_video_motion (GtkEventControllerMotion *motion,
|
||||
double x,
|
||||
double y,
|
||||
GtkVideo *self)
|
||||
{
|
||||
gtk_revealer_set_reveal_child (GTK_REVEALER (self->controls_revealer), TRUE);
|
||||
if (self->controls_hide_source)
|
||||
g_source_remove (self->controls_hide_source);
|
||||
self->controls_hide_source = g_timeout_add (5 * 1000,
|
||||
gtk_video_hide_controls,
|
||||
self);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_video_init (GtkVideo *self)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
gtk_widget_set_has_surface (GTK_WIDGET (self), FALSE);
|
||||
|
||||
self->motion_controller = gtk_event_controller_motion_new (GTK_WIDGET (self));
|
||||
g_signal_connect (self->motion_controller, "motion", G_CALLBACK (gtk_video_motion), self);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,5 +43,10 @@
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEventControllerMotion">
|
||||
<signal name="motion" handler="gtk_video_motion" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
||||
|
@ -375,9 +375,9 @@ test_chase (void)
|
||||
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), child);
|
||||
g_object_set (child, "margin", 4, NULL);
|
||||
|
||||
controller = gtk_event_controller_motion_new (child);
|
||||
g_object_set_data_full (G_OBJECT (child), "motion", controller, g_object_unref);
|
||||
controller = gtk_event_controller_motion_new ();
|
||||
g_signal_connect (controller, "enter", G_CALLBACK (on_enter), overlay);
|
||||
gtk_widget_add_controller (child, controller);
|
||||
|
||||
return win;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user