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:
Carlos Garnacho 2014-05-26 11:58:18 +02:00
parent 68c1e83cf0
commit ef61c9c58b
4 changed files with 32 additions and 46 deletions

View File

@ -331,11 +331,12 @@ typedef enum
/**
* GtkOrientation:
* @GTK_ORIENTATION_HORIZONTAL: The widget is in horizontal orientation.
* @GTK_ORIENTATION_VERTICAL: The widget is in vertical orientation.
* @GTK_ORIENTATION_HORIZONTAL: The element is in horizontal orientation.
* @GTK_ORIENTATION_VERTICAL: The element is in vertical orientation.
*
* Represents the orientation of widgets which can be switched between horizontal
* and vertical orientation on the fly, like #GtkToolbar.
* Represents the orientation of widgets and other objects which can be switched
* between horizontal and vertical orientation on the fly, like #GtkToolbar or
* #GtkGesturePan.
*/
typedef enum
{
@ -1117,19 +1118,4 @@ typedef enum
GTK_PAN_DIRECTION_DOWN
} 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__ */

View File

@ -104,19 +104,19 @@ gtk_gesture_pan_set_property (GObject *object,
}
static void
direction_from_offset (gdouble offset_x,
gdouble offset_y,
GtkPanOrientation orientation,
GtkPanDirection *direction)
direction_from_offset (gdouble offset_x,
gdouble offset_y,
GtkOrientation orientation,
GtkPanDirection *direction)
{
if (orientation == GTK_PAN_ORIENTATION_HORIZONTAL)
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
if (offset_x > 0)
*direction = GTK_PAN_DIRECTION_RIGHT;
else
*direction = GTK_PAN_DIRECTION_LEFT;
}
else if (orientation == GTK_PAN_ORIENTATION_VERTICAL)
else if (orientation == GTK_ORIENTATION_VERTICAL)
{
if (offset_y > 0)
*direction = GTK_PAN_DIRECTION_DOWN;
@ -141,10 +141,10 @@ guess_direction (GtkGesturePan *gesture,
#define FACTOR 2
if (abs_x > abs_y * FACTOR)
direction_from_offset (offset_x, offset_y,
GTK_PAN_ORIENTATION_HORIZONTAL, direction);
GTK_ORIENTATION_HORIZONTAL, direction);
else if (abs_y > abs_x * FACTOR)
direction_from_offset (offset_x, offset_y,
GTK_PAN_ORIENTATION_VERTICAL, direction);
GTK_ORIENTATION_VERTICAL, direction);
else
return FALSE;
@ -160,10 +160,10 @@ check_orientation_matches (GtkGesturePan *gesture,
return (((direction == GTK_PAN_DIRECTION_LEFT ||
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_DOWN) &&
priv->orientation == GTK_PAN_ORIENTATION_VERTICAL));
priv->orientation == GTK_ORIENTATION_VERTICAL));
}
static void
@ -196,7 +196,7 @@ gtk_gesture_pan_drag_update (GtkGestureDrag *gesture,
else
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);
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",
P_("Orientation"),
P_("Allowed orientations"),
GTK_TYPE_PAN_ORIENTATION,
GTK_PAN_ORIENTATION_HORIZONTAL,
GTK_TYPE_ORIENTATION,
GTK_ORIENTATION_HORIZONTAL,
GTK_PARAM_READWRITE));
/**
* GtkGesturePan::pan:
@ -266,7 +266,7 @@ gtk_gesture_pan_init (GtkGesturePan *gesture)
GtkGesturePanPrivate *priv;
priv = gtk_gesture_pan_get_instance_private (gesture);
priv->orientation = GTK_PAN_ORIENTATION_HORIZONTAL;
priv->orientation = GTK_ORIENTATION_HORIZONTAL;
}
/**
@ -281,8 +281,8 @@ gtk_gesture_pan_init (GtkGesturePan *gesture)
* Since: 3.14
**/
GtkGesture *
gtk_gesture_pan_new (GtkWidget *widget,
GtkPanOrientation orientation)
gtk_gesture_pan_new (GtkWidget *widget,
GtkOrientation orientation)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
@ -302,7 +302,7 @@ gtk_gesture_pan_new (GtkWidget *widget,
*
* Since: 3.14
*/
GtkPanOrientation
GtkOrientation
gtk_gesture_pan_get_orientation (GtkGesturePan *gesture)
{
GtkGesturePanPrivate *priv;
@ -324,14 +324,14 @@ gtk_gesture_pan_get_orientation (GtkGesturePan *gesture)
* Since: 3.14
*/
void
gtk_gesture_pan_set_orientation (GtkGesturePan *gesture,
GtkPanOrientation orientation)
gtk_gesture_pan_set_orientation (GtkGesturePan *gesture,
GtkOrientation orientation)
{
GtkGesturePanPrivate *priv;
g_return_if_fail (GTK_IS_GESTURE_PAN (gesture));
g_return_if_fail (orientation == GTK_PAN_ORIENTATION_HORIZONTAL ||
orientation == GTK_PAN_ORIENTATION_VERTICAL);
g_return_if_fail (orientation == GTK_ORIENTATION_HORIZONTAL ||
orientation == GTK_ORIENTATION_VERTICAL);
priv = gtk_gesture_pan_get_instance_private (gesture);

View File

@ -42,15 +42,15 @@ GDK_AVAILABLE_IN_3_14
GType gtk_gesture_pan_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_3_14
GtkGesture * gtk_gesture_pan_new (GtkWidget *widget,
GtkPanOrientation orientation);
GtkGesture * gtk_gesture_pan_new (GtkWidget *widget,
GtkOrientation orientation);
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
void gtk_gesture_pan_set_orientation (GtkGesturePan *gesture,
GtkPanOrientation orientation);
void gtk_gesture_pan_set_orientation (GtkGesturePan *gesture,
GtkOrientation orientation);
G_END_DECLS

View File

@ -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)))
{
GtkPanOrientation orientation;
GtkOrientation orientation;
if (priv->hscrollbar_visible)
orientation = GTK_PAN_ORIENTATION_HORIZONTAL;