]> Pileus Git - ~andy/gtk/blob - gtk/gtkorientable.c
gtk/: fully remove gtkalias hacks
[~andy/gtk] / gtk / gtkorientable.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * gtkorientable.c
5  * Copyright (C) 2008 Imendio AB
6  * Contact: Michael Natterer <mitch@imendio.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23
24 #include "config.h"
25
26 #include "gtkorientable.h"
27 #include "gtkprivate.h"
28 #include "gtkintl.h"
29
30
31 /**
32  * SECTION:gtkorientable
33  * @Short_description: An interface for flippable widgets
34  * @Title: GtkOrientable
35  *
36  * The #GtkOrientable interface is implemented by all widgets that can be
37  * oriented horizontally or vertically. Historically, such widgets have been
38  * realized as subclasses of a common base class (e.g #GtkBox/#GtkHBox/#GtkVBox
39  * or #GtkScale/#GtkHScale/#GtkVScale). #GtkOrientable is more flexible in that
40  * it allows the orientation to be changed at runtime, allowing the widgets
41  * to 'flip'.
42  *
43  * #GtkOrientable was introduced in GTK+ 2.16.
44  */
45
46
47 typedef GtkOrientableIface GtkOrientableInterface;
48 G_DEFINE_INTERFACE (GtkOrientable, gtk_orientable, G_TYPE_OBJECT)
49
50 static void
51 gtk_orientable_default_init (GtkOrientableInterface *iface)
52 {
53   /**
54    * GtkOrientable:orientation:
55    *
56    * The orientation of the orientable.
57    *
58    * Since: 2.16
59    **/
60   g_object_interface_install_property (iface,
61                                        g_param_spec_enum ("orientation",
62                                                           P_("Orientation"),
63                                                           P_("The orientation of the orientable"),
64                                                           GTK_TYPE_ORIENTATION,
65                                                           GTK_ORIENTATION_HORIZONTAL,
66                                                           GTK_PARAM_READWRITE));
67 }
68
69 /**
70  * gtk_orientable_set_orientation:
71  * @orientable: a #GtkOrientable
72  * @orientation: the orientable's new orientation.
73  *
74  * Sets the orientation of the @orientable.
75  *
76  * Since: 2.16
77  **/
78 void
79 gtk_orientable_set_orientation (GtkOrientable  *orientable,
80                                 GtkOrientation  orientation)
81 {
82   g_return_if_fail (GTK_IS_ORIENTABLE (orientable));
83
84   g_object_set (orientable,
85                 "orientation", orientation,
86                 NULL);
87 }
88
89 /**
90  * gtk_orientable_get_orientation:
91  * @orientable: a #GtkOrientable
92  *
93  * Retrieves the orientation of the @orientable.
94  *
95  * Return value: the orientation of the @orientable.
96  *
97  * Since: 2.16
98  **/
99 GtkOrientation
100 gtk_orientable_get_orientation (GtkOrientable *orientable)
101 {
102   GtkOrientation orientation;
103
104   g_return_val_if_fail (GTK_IS_ORIENTABLE (orientable),
105                         GTK_ORIENTATION_HORIZONTAL);
106
107   g_object_get (orientable,
108                 "orientation", &orientation,
109                 NULL);
110
111   return orientation;
112 }