mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
Rename things
Rename the can-pick property to can-target, and redo the pick flags with more descriptive names.
This commit is contained in:
parent
1b362d1f01
commit
ef982b7d46
@ -243,7 +243,7 @@ pressed_cb (GtkGesture *gesture,
|
||||
GtkWidget *child;
|
||||
|
||||
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
|
||||
child = gtk_widget_pick (widget, x, y, 0);
|
||||
child = gtk_widget_pick (widget, x, y, GTK_PICK_DEFAULT);
|
||||
|
||||
if (gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)) == GDK_BUTTON_SECONDARY)
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ do_overlay (GtkWidget *do_widget)
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
|
||||
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), vbox);
|
||||
gtk_widget_set_can_pick (vbox, FALSE);
|
||||
gtk_widget_set_can_target (vbox, FALSE);
|
||||
gtk_widget_set_halign (vbox, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (vbox, GTK_ALIGN_CENTER);
|
||||
|
||||
|
@ -66,13 +66,13 @@ do_overlay2 (GtkWidget *do_widget)
|
||||
|
||||
image = gtk_picture_new_for_resource ("/overlay2/decor1.png");
|
||||
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), image);
|
||||
gtk_widget_set_can_pick (image, FALSE);
|
||||
gtk_widget_set_can_target (image, FALSE);
|
||||
gtk_widget_set_halign (image, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (image, GTK_ALIGN_START);
|
||||
|
||||
image = gtk_picture_new_for_resource ("/overlay2/decor2.png");
|
||||
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), image);
|
||||
gtk_widget_set_can_pick (image, FALSE);
|
||||
gtk_widget_set_can_target (image, FALSE);
|
||||
gtk_widget_set_halign (image, GTK_ALIGN_END);
|
||||
gtk_widget_set_valign (image, GTK_ALIGN_END);
|
||||
|
||||
|
@ -228,7 +228,7 @@ puzzle_button_pressed (GtkGestureMultiPress *gesture,
|
||||
int l, t, i;
|
||||
int pos;
|
||||
|
||||
child = gtk_widget_pick (grid, x, y, 0);
|
||||
child = gtk_widget_pick (grid, x, y, GTK_PICK_DEFAULT);
|
||||
|
||||
if (!child)
|
||||
{
|
||||
|
@ -4516,8 +4516,8 @@ gtk_widget_set_can_focus
|
||||
gtk_widget_get_focus_on_click
|
||||
gtk_widget_set_focus_on_click
|
||||
gtk_widget_set_focus_child
|
||||
gtk_widget_get_can_pick
|
||||
gtk_widget_set_can_pick
|
||||
gtk_widget_get_can_target
|
||||
gtk_widget_set_can_target
|
||||
gtk_widget_get_has_surface
|
||||
gtk_widget_set_has_surface
|
||||
gtk_widget_get_sensitive
|
||||
|
@ -3117,7 +3117,7 @@ gtk_entry_ensure_progress_widget (GtkEntry *entry)
|
||||
priv->progress_widget = g_object_new (GTK_TYPE_PROGRESS_BAR,
|
||||
"css-name", "progress",
|
||||
NULL);
|
||||
gtk_widget_set_can_pick (priv->progress_widget, FALSE);
|
||||
gtk_widget_set_can_target (priv->progress_widget, FALSE);
|
||||
|
||||
gtk_widget_set_parent (priv->progress_widget, GTK_WIDGET (entry));
|
||||
|
||||
|
@ -1042,12 +1042,16 @@ typedef enum {
|
||||
|
||||
/**
|
||||
* GtkPickFlags:
|
||||
* @GTK_PICK_ALL: Include insensitive widgets and widgets marked as "can't pick"
|
||||
* @GTK_PICK_DEFAULT: The default behavior, include widgets that are receiving events
|
||||
* @GTK_PICK_INSENSITIVE: Include widgets that are insensitive
|
||||
* @GTK_PICK_NON_TARGETABLE: Include widgets that are marked as non-targetable. See #GtkWidget::can-target
|
||||
*
|
||||
* Flags that influence the behavior of gtk_widget_pick()
|
||||
*/
|
||||
typedef enum {
|
||||
GTK_PICK_ALL = 1 << 0
|
||||
GTK_PICK_DEFAULT = 0,
|
||||
GTK_PICK_INSENSITIVE = 1 << 0,
|
||||
GTK_PICK_NON_TARGETABLE = 1 << 1
|
||||
} GtkPickFlags;
|
||||
|
||||
#endif /* __GTK_ENUMS_H__ */
|
||||
|
@ -3928,7 +3928,7 @@ gtk_flow_box_get_child_at_pos (GtkFlowBox *box,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
GtkWidget *child = gtk_widget_pick (GTK_WIDGET (box), x, y, 0);
|
||||
GtkWidget *child = gtk_widget_pick (GTK_WIDGET (box), x, y, GTK_PICK_DEFAULT);
|
||||
|
||||
if (!child)
|
||||
return NULL;
|
||||
|
@ -1703,7 +1703,7 @@ handle_pointing_event (GdkEvent *event)
|
||||
target = gtk_window_lookup_pointer_focus_implicit_grab (toplevel, device, sequence);
|
||||
|
||||
if (!target)
|
||||
target = gtk_widget_pick (toplevel_widget, x, y, 0);
|
||||
target = gtk_widget_pick (toplevel_widget, x, y, GTK_PICK_DEFAULT);
|
||||
|
||||
if (!target)
|
||||
target = toplevel_widget;
|
||||
@ -1742,7 +1742,7 @@ handle_pointing_event (GdkEvent *event)
|
||||
if (event->any.type == GDK_BUTTON_RELEASE)
|
||||
{
|
||||
GtkWidget *new_target;
|
||||
new_target = gtk_widget_pick (GTK_WIDGET (toplevel), x, y, 0);
|
||||
new_target = gtk_widget_pick (GTK_WIDGET (toplevel), x, y, GTK_PICK_DEFAULT);
|
||||
if (new_target == NULL)
|
||||
new_target = GTK_WIDGET (toplevel);
|
||||
gtk_synthesize_crossing_events (GTK_ROOT (toplevel), target, new_target, event,
|
||||
|
@ -135,7 +135,7 @@ gtk_pointer_focus_repick_target (GtkPointerFocus *focus)
|
||||
{
|
||||
GtkWidget *target;
|
||||
|
||||
target = gtk_widget_pick (GTK_WIDGET (focus->toplevel), focus->x, focus->y, 0);
|
||||
target = gtk_widget_pick (GTK_WIDGET (focus->toplevel), focus->x, focus->y, GTK_PICK_DEFAULT);
|
||||
if (target == NULL)
|
||||
target = GTK_WIDGET (focus->toplevel);
|
||||
gtk_pointer_focus_set_target (focus, target);
|
||||
|
@ -1865,7 +1865,7 @@ gtk_range_long_press_gesture_pressed (GtkGestureLongPress *gesture,
|
||||
GtkRangePrivate *priv = gtk_range_get_instance_private (range);
|
||||
GtkWidget *mouse_location;
|
||||
|
||||
mouse_location = gtk_widget_pick (GTK_WIDGET (range), x, y, 0);
|
||||
mouse_location = gtk_widget_pick (GTK_WIDGET (range), x, y, GTK_PICK_DEFAULT);
|
||||
|
||||
if (mouse_location == priv->slider_widget && !priv->zoom)
|
||||
{
|
||||
|
@ -434,7 +434,7 @@ _gtk_widget_find_at_coords (GdkSurface *surface,
|
||||
if (!event_widget)
|
||||
return NULL;
|
||||
|
||||
picked_widget = gtk_widget_pick (event_widget, surface_x, surface_y, GTK_PICK_ALL);
|
||||
picked_widget = gtk_widget_pick (event_widget, surface_x, surface_y, GTK_PICK_INSENSITIVE);
|
||||
|
||||
if (picked_widget != NULL)
|
||||
gtk_widget_translate_coordinates (event_widget, picked_widget, surface_x, surface_y, widget_x, widget_y);
|
||||
|
@ -546,7 +546,7 @@ enum {
|
||||
PROP_CAN_FOCUS,
|
||||
PROP_HAS_FOCUS,
|
||||
PROP_IS_FOCUS,
|
||||
PROP_CAN_PICK,
|
||||
PROP_CAN_TARGET,
|
||||
PROP_FOCUS_ON_CLICK,
|
||||
PROP_CAN_DEFAULT,
|
||||
PROP_HAS_DEFAULT,
|
||||
@ -1012,9 +1012,9 @@ gtk_widget_class_init (GtkWidgetClass *klass)
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE);
|
||||
|
||||
widget_props[PROP_CAN_PICK] =
|
||||
g_param_spec_boolean ("can-pick",
|
||||
P_("Can pick"),
|
||||
widget_props[PROP_CAN_TARGET] =
|
||||
g_param_spec_boolean ("can-target",
|
||||
P_("Can target"),
|
||||
P_("Whether the widget can receive pointer events"),
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
||||
@ -2187,8 +2187,8 @@ gtk_widget_set_property (GObject *object,
|
||||
if (g_value_get_boolean (value))
|
||||
gtk_widget_grab_focus (widget);
|
||||
break;
|
||||
case PROP_CAN_PICK:
|
||||
gtk_widget_set_can_pick (widget, g_value_get_boolean (value));
|
||||
case PROP_CAN_TARGET:
|
||||
gtk_widget_set_can_target (widget, g_value_get_boolean (value));
|
||||
break;
|
||||
case PROP_FOCUS_ON_CLICK:
|
||||
gtk_widget_set_focus_on_click (widget, g_value_get_boolean (value));
|
||||
@ -2368,8 +2368,8 @@ gtk_widget_get_property (GObject *object,
|
||||
case PROP_IS_FOCUS:
|
||||
g_value_set_boolean (value, gtk_widget_is_focus (widget));
|
||||
break;
|
||||
case PROP_CAN_PICK:
|
||||
g_value_set_boolean (value, gtk_widget_get_can_pick (widget));
|
||||
case PROP_CAN_TARGET:
|
||||
g_value_set_boolean (value, gtk_widget_get_can_target (widget));
|
||||
break;
|
||||
case PROP_FOCUS_ON_CLICK:
|
||||
g_value_set_boolean (value, gtk_widget_get_focus_on_click (widget));
|
||||
@ -2808,7 +2808,7 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
priv->highlight_resize = FALSE;
|
||||
#endif
|
||||
priv->can_pick = TRUE;
|
||||
priv->can_target = TRUE;
|
||||
|
||||
switch (_gtk_widget_get_direction (widget))
|
||||
{
|
||||
@ -11041,12 +11041,13 @@ gtk_widget_pick (GtkWidget *widget,
|
||||
if (!_gtk_widget_is_drawable (widget))
|
||||
return NULL;
|
||||
|
||||
if ((flags & GTK_PICK_ALL) == 0)
|
||||
{
|
||||
if (!gtk_widget_get_can_pick (widget) ||
|
||||
!_gtk_widget_is_sensitive (widget))
|
||||
return NULL;
|
||||
}
|
||||
if (!(flags & GTK_PICK_NON_TARGETABLE) &&
|
||||
!gtk_widget_get_can_target (widget))
|
||||
return NULL;
|
||||
|
||||
if (!(flags & GTK_PICK_INSENSITIVE) &&
|
||||
!_gtk_widget_is_sensitive (widget))
|
||||
return NULL;
|
||||
|
||||
switch (priv->overflow)
|
||||
{
|
||||
@ -13462,31 +13463,30 @@ gtk_widget_get_cursor (GtkWidget *widget)
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_set_can_pick:
|
||||
* gtk_widget_set_can_target:
|
||||
* @widget: a #GtkWidget
|
||||
* @can_pick: whether this widget should be able to receive pointer events
|
||||
* @can_target: whether this widget should be able to receive pointer events
|
||||
*
|
||||
* Sets whether @widget can be the target of pointer events and
|
||||
* can be returned by gtk_widget_pick().
|
||||
* Sets whether @widget can be the target of pointer events.
|
||||
*/
|
||||
void
|
||||
gtk_widget_set_can_pick (GtkWidget *widget,
|
||||
gboolean can_pick)
|
||||
gtk_widget_set_can_target (GtkWidget *widget,
|
||||
gboolean can_target)
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
|
||||
can_pick = !!can_pick;
|
||||
can_target = !!can_target;
|
||||
|
||||
if (priv->can_pick == can_pick)
|
||||
if (priv->can_target == can_target)
|
||||
return;
|
||||
|
||||
priv->can_pick = can_pick;
|
||||
priv->can_target = can_target;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_CAN_PICK]);
|
||||
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_CAN_TARGET]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_get_can_pick:
|
||||
* gtk_widget_get_can_target:
|
||||
* @widget: a #GtkWidget
|
||||
*
|
||||
* Queries whether @widget can be the target of pointer events.
|
||||
@ -13494,11 +13494,11 @@ gtk_widget_set_can_pick (GtkWidget *widget,
|
||||
* Returns: %TRUE if @widget can receive pointer events
|
||||
*/
|
||||
gboolean
|
||||
gtk_widget_get_can_pick (GtkWidget *widget)
|
||||
gtk_widget_get_can_target (GtkWidget *widget)
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
|
||||
return priv->can_pick;
|
||||
return priv->can_target;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -469,10 +469,10 @@ GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_widget_get_focus_on_click (GtkWidget *widget);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_widget_set_can_pick (GtkWidget *widget,
|
||||
gboolean can_pick);
|
||||
void gtk_widget_set_can_target (GtkWidget *widget,
|
||||
gboolean can_target);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_widget_get_can_pick (GtkWidget *widget);
|
||||
gboolean gtk_widget_get_can_target (GtkWidget *widget);
|
||||
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@ -73,7 +73,7 @@ struct _GtkWidgetPrivate
|
||||
guint shadowed : 1;
|
||||
guint child_visible : 1;
|
||||
guint multidevice : 1;
|
||||
guint can_pick : 1;
|
||||
guint can_target : 1;
|
||||
|
||||
/* Queue-resize related flags */
|
||||
guint resize_needed : 1; /* queue_resize() has been called but no get_preferred_size() yet */
|
||||
|
@ -55,7 +55,7 @@ find_widget_at_pointer (GdkDevice *device)
|
||||
gdk_surface_get_device_position (gtk_widget_get_surface (widget),
|
||||
device, &x, &y, NULL);
|
||||
|
||||
widget = gtk_widget_pick (widget, x, y, GTK_PICK_ALL);
|
||||
widget = gtk_widget_pick (widget, x, y, GTK_PICK_INSENSITIVE|GTK_PICK_NON_TARGETABLE);
|
||||
}
|
||||
|
||||
return widget;
|
||||
|
@ -459,7 +459,7 @@ test_input_stacking (void)
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
|
||||
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), vbox);
|
||||
gtk_widget_set_can_pick (vbox, FALSE);
|
||||
gtk_widget_set_can_target (vbox, FALSE);
|
||||
gtk_widget_set_halign (vbox, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (vbox, GTK_ALIGN_CENTER);
|
||||
|
||||
|
@ -187,12 +187,12 @@ gtk_transform_tester_snapshot (GtkWidget *widget,
|
||||
const float py = y;
|
||||
GtkWidget *picked;
|
||||
#if 1
|
||||
picked = gtk_widget_pick (widget, px, py, 0);
|
||||
picked = gtk_widget_pick (widget, px, py, GTK_PICK_DEFAULT);
|
||||
#else
|
||||
{
|
||||
int dx, dy;
|
||||
gtk_widget_translate_coordinates (widget, self->test_widget, px, py, &dx, &dy);
|
||||
picked = gtk_widget_pick (self->test_widget, dx, dy);
|
||||
picked = gtk_widget_pick (self->test_widget, dx, dy, GTK_PICK_DEFAULT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user