[gtk+] gtk: Replace GtkPanOrientation with GtkOrientation
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gtk: Replace GtkPanOrientation with GtkOrientation
- Date: Tue, 27 May 2014 15:48:17 +0000 (UTC)
commit ef61c9c58b6e4c6c364d4df72f10d877aee24e33
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon May 26 11:58:18 2014 +0200
gtk: Replace GtkPanOrientation with GtkOrientation
And document GtkOrientation to be more generic. There's little added
value in a separate enum for this.
gtk/gtkenums.h | 24 +++++-------------------
gtk/gtkgesturepan.c | 42 +++++++++++++++++++++---------------------
gtk/gtkgesturepan.h | 10 +++++-----
gtk/gtkscrolledwindow.c | 2 +-
4 files changed, 32 insertions(+), 46 deletions(-)
---
diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h
index e6c7e0f..9bd617f 100644
--- a/gtk/gtkenums.h
+++ b/gtk/gtkenums.h
@@ -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__ */
diff --git a/gtk/gtkgesturepan.c b/gtk/gtkgesturepan.c
index a7c2936..d7d9fa1 100644
--- a/gtk/gtkgesturepan.c
+++ b/gtk/gtkgesturepan.c
@@ -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);
diff --git a/gtk/gtkgesturepan.h b/gtk/gtkgesturepan.h
index 6cd3856..410d704 100644
--- a/gtk/gtkgesturepan.h
+++ b/gtk/gtkgesturepan.h
@@ -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
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index e5fe575..6880b84 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]