gtk: Replace GtkPanOrientation with GtkOrientation
And document GtkOrientation to be more generic. There's little added value in a separate enum for this.
This commit is contained in:
parent
68c1e83cf0
commit
ef61c9c58b
@ -331,11 +331,12 @@ typedef enum
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* GtkOrientation:
|
* GtkOrientation:
|
||||||
* @GTK_ORIENTATION_HORIZONTAL: The widget is in horizontal orientation.
|
* @GTK_ORIENTATION_HORIZONTAL: The element is in horizontal orientation.
|
||||||
* @GTK_ORIENTATION_VERTICAL: The widget is in vertical orientation.
|
* @GTK_ORIENTATION_VERTICAL: The element is in vertical orientation.
|
||||||
*
|
*
|
||||||
* Represents the orientation of widgets which can be switched between horizontal
|
* Represents the orientation of widgets and other objects which can be switched
|
||||||
* and vertical orientation on the fly, like #GtkToolbar.
|
* between horizontal and vertical orientation on the fly, like #GtkToolbar or
|
||||||
|
* #GtkGesturePan.
|
||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@ -1117,19 +1118,4 @@ typedef enum
|
|||||||
GTK_PAN_DIRECTION_DOWN
|
GTK_PAN_DIRECTION_DOWN
|
||||||
} GtkPanDirection;
|
} GtkPanDirection;
|
||||||
|
|
||||||
/**
|
|
||||||
* GtkPanOrientation:
|
|
||||||
* @GTK_PAN_ORIENTATION_VERTICAL: vertical panning allowed
|
|
||||||
* @GTK_PAN_ORIENTATION_HORIZONTAL: horizontal panning allowed
|
|
||||||
*
|
|
||||||
* Describes the panning axis of a #GtkGesturePan
|
|
||||||
*
|
|
||||||
* Since: 3.14
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
GTK_PAN_ORIENTATION_VERTICAL,
|
|
||||||
GTK_PAN_ORIENTATION_HORIZONTAL
|
|
||||||
} GtkPanOrientation;
|
|
||||||
|
|
||||||
#endif /* __GTK_ENUMS_H__ */
|
#endif /* __GTK_ENUMS_H__ */
|
||||||
|
@ -106,17 +106,17 @@ gtk_gesture_pan_set_property (GObject *object,
|
|||||||
static void
|
static void
|
||||||
direction_from_offset (gdouble offset_x,
|
direction_from_offset (gdouble offset_x,
|
||||||
gdouble offset_y,
|
gdouble offset_y,
|
||||||
GtkPanOrientation orientation,
|
GtkOrientation orientation,
|
||||||
GtkPanDirection *direction)
|
GtkPanDirection *direction)
|
||||||
{
|
{
|
||||||
if (orientation == GTK_PAN_ORIENTATION_HORIZONTAL)
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||||
{
|
{
|
||||||
if (offset_x > 0)
|
if (offset_x > 0)
|
||||||
*direction = GTK_PAN_DIRECTION_RIGHT;
|
*direction = GTK_PAN_DIRECTION_RIGHT;
|
||||||
else
|
else
|
||||||
*direction = GTK_PAN_DIRECTION_LEFT;
|
*direction = GTK_PAN_DIRECTION_LEFT;
|
||||||
}
|
}
|
||||||
else if (orientation == GTK_PAN_ORIENTATION_VERTICAL)
|
else if (orientation == GTK_ORIENTATION_VERTICAL)
|
||||||
{
|
{
|
||||||
if (offset_y > 0)
|
if (offset_y > 0)
|
||||||
*direction = GTK_PAN_DIRECTION_DOWN;
|
*direction = GTK_PAN_DIRECTION_DOWN;
|
||||||
@ -141,10 +141,10 @@ guess_direction (GtkGesturePan *gesture,
|
|||||||
#define FACTOR 2
|
#define FACTOR 2
|
||||||
if (abs_x > abs_y * FACTOR)
|
if (abs_x > abs_y * FACTOR)
|
||||||
direction_from_offset (offset_x, offset_y,
|
direction_from_offset (offset_x, offset_y,
|
||||||
GTK_PAN_ORIENTATION_HORIZONTAL, direction);
|
GTK_ORIENTATION_HORIZONTAL, direction);
|
||||||
else if (abs_y > abs_x * FACTOR)
|
else if (abs_y > abs_x * FACTOR)
|
||||||
direction_from_offset (offset_x, offset_y,
|
direction_from_offset (offset_x, offset_y,
|
||||||
GTK_PAN_ORIENTATION_VERTICAL, direction);
|
GTK_ORIENTATION_VERTICAL, direction);
|
||||||
else
|
else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -160,10 +160,10 @@ check_orientation_matches (GtkGesturePan *gesture,
|
|||||||
|
|
||||||
return (((direction == GTK_PAN_DIRECTION_LEFT ||
|
return (((direction == GTK_PAN_DIRECTION_LEFT ||
|
||||||
direction == GTK_PAN_DIRECTION_RIGHT) &&
|
direction == GTK_PAN_DIRECTION_RIGHT) &&
|
||||||
priv->orientation == GTK_PAN_ORIENTATION_HORIZONTAL) ||
|
priv->orientation == GTK_ORIENTATION_HORIZONTAL) ||
|
||||||
((direction == GTK_PAN_DIRECTION_UP ||
|
((direction == GTK_PAN_DIRECTION_UP ||
|
||||||
direction == GTK_PAN_DIRECTION_DOWN) &&
|
direction == GTK_PAN_DIRECTION_DOWN) &&
|
||||||
priv->orientation == GTK_PAN_ORIENTATION_VERTICAL));
|
priv->orientation == GTK_ORIENTATION_VERTICAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -196,7 +196,7 @@ gtk_gesture_pan_drag_update (GtkGestureDrag *gesture,
|
|||||||
else
|
else
|
||||||
direction_from_offset (offset_x, offset_y, priv->orientation, &direction);
|
direction_from_offset (offset_x, offset_y, priv->orientation, &direction);
|
||||||
|
|
||||||
offset = (priv->orientation == GTK_PAN_ORIENTATION_VERTICAL) ?
|
offset = (priv->orientation == GTK_ORIENTATION_VERTICAL) ?
|
||||||
ABS (offset_y) : ABS (offset_x);
|
ABS (offset_y) : ABS (offset_x);
|
||||||
g_signal_emit (gesture, signals[PAN], 0, direction, offset);
|
g_signal_emit (gesture, signals[PAN], 0, direction, offset);
|
||||||
}
|
}
|
||||||
@ -236,8 +236,8 @@ gtk_gesture_pan_class_init (GtkGesturePanClass *klass)
|
|||||||
g_param_spec_enum ("orientation",
|
g_param_spec_enum ("orientation",
|
||||||
P_("Orientation"),
|
P_("Orientation"),
|
||||||
P_("Allowed orientations"),
|
P_("Allowed orientations"),
|
||||||
GTK_TYPE_PAN_ORIENTATION,
|
GTK_TYPE_ORIENTATION,
|
||||||
GTK_PAN_ORIENTATION_HORIZONTAL,
|
GTK_ORIENTATION_HORIZONTAL,
|
||||||
GTK_PARAM_READWRITE));
|
GTK_PARAM_READWRITE));
|
||||||
/**
|
/**
|
||||||
* GtkGesturePan::pan:
|
* GtkGesturePan::pan:
|
||||||
@ -266,7 +266,7 @@ gtk_gesture_pan_init (GtkGesturePan *gesture)
|
|||||||
GtkGesturePanPrivate *priv;
|
GtkGesturePanPrivate *priv;
|
||||||
|
|
||||||
priv = gtk_gesture_pan_get_instance_private (gesture);
|
priv = gtk_gesture_pan_get_instance_private (gesture);
|
||||||
priv->orientation = GTK_PAN_ORIENTATION_HORIZONTAL;
|
priv->orientation = GTK_ORIENTATION_HORIZONTAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -282,7 +282,7 @@ gtk_gesture_pan_init (GtkGesturePan *gesture)
|
|||||||
**/
|
**/
|
||||||
GtkGesture *
|
GtkGesture *
|
||||||
gtk_gesture_pan_new (GtkWidget *widget,
|
gtk_gesture_pan_new (GtkWidget *widget,
|
||||||
GtkPanOrientation orientation)
|
GtkOrientation orientation)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ gtk_gesture_pan_new (GtkWidget *widget,
|
|||||||
*
|
*
|
||||||
* Since: 3.14
|
* Since: 3.14
|
||||||
*/
|
*/
|
||||||
GtkPanOrientation
|
GtkOrientation
|
||||||
gtk_gesture_pan_get_orientation (GtkGesturePan *gesture)
|
gtk_gesture_pan_get_orientation (GtkGesturePan *gesture)
|
||||||
{
|
{
|
||||||
GtkGesturePanPrivate *priv;
|
GtkGesturePanPrivate *priv;
|
||||||
@ -325,13 +325,13 @@ gtk_gesture_pan_get_orientation (GtkGesturePan *gesture)
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gtk_gesture_pan_set_orientation (GtkGesturePan *gesture,
|
gtk_gesture_pan_set_orientation (GtkGesturePan *gesture,
|
||||||
GtkPanOrientation orientation)
|
GtkOrientation orientation)
|
||||||
{
|
{
|
||||||
GtkGesturePanPrivate *priv;
|
GtkGesturePanPrivate *priv;
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_GESTURE_PAN (gesture));
|
g_return_if_fail (GTK_IS_GESTURE_PAN (gesture));
|
||||||
g_return_if_fail (orientation == GTK_PAN_ORIENTATION_HORIZONTAL ||
|
g_return_if_fail (orientation == GTK_ORIENTATION_HORIZONTAL ||
|
||||||
orientation == GTK_PAN_ORIENTATION_VERTICAL);
|
orientation == GTK_ORIENTATION_VERTICAL);
|
||||||
|
|
||||||
priv = gtk_gesture_pan_get_instance_private (gesture);
|
priv = gtk_gesture_pan_get_instance_private (gesture);
|
||||||
|
|
||||||
|
@ -43,14 +43,14 @@ GType gtk_gesture_pan_get_type (void) G_GNUC_CONST;
|
|||||||
|
|
||||||
GDK_AVAILABLE_IN_3_14
|
GDK_AVAILABLE_IN_3_14
|
||||||
GtkGesture * gtk_gesture_pan_new (GtkWidget *widget,
|
GtkGesture * gtk_gesture_pan_new (GtkWidget *widget,
|
||||||
GtkPanOrientation orientation);
|
GtkOrientation orientation);
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_3_14
|
GDK_AVAILABLE_IN_3_14
|
||||||
GtkPanOrientation gtk_gesture_pan_get_orientation (GtkGesturePan *gesture);
|
GtkOrientation gtk_gesture_pan_get_orientation (GtkGesturePan *gesture);
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_3_14
|
GDK_AVAILABLE_IN_3_14
|
||||||
void gtk_gesture_pan_set_orientation (GtkGesturePan *gesture,
|
void gtk_gesture_pan_set_orientation (GtkGesturePan *gesture,
|
||||||
GtkPanOrientation orientation);
|
GtkOrientation orientation);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
@ -730,7 +730,7 @@ gtk_scrolled_window_check_attach_pan_gesture (GtkScrolledWindow *sw)
|
|||||||
((priv->hscrollbar_visible && !priv->vscrollbar_visible) ||
|
((priv->hscrollbar_visible && !priv->vscrollbar_visible) ||
|
||||||
(!priv->hscrollbar_visible && priv->vscrollbar_visible)))
|
(!priv->hscrollbar_visible && priv->vscrollbar_visible)))
|
||||||
{
|
{
|
||||||
GtkPanOrientation orientation;
|
GtkOrientation orientation;
|
||||||
|
|
||||||
if (priv->hscrollbar_visible)
|
if (priv->hscrollbar_visible)
|
||||||
orientation = GTK_PAN_ORIENTATION_HORIZONTAL;
|
orientation = GTK_PAN_ORIENTATION_HORIZONTAL;
|
||||||
|
Loading…
Reference in New Issue
Block a user