1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
5 * Copyright (C) 2008 Imendio AB
6 * Contact: Michael Natterer <mitch@imendio.com>
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.
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.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
24 #include "gtkorientableprivate.h"
25 #include "gtkprivate.h"
26 #include "gtktypebuiltins.h"
31 * SECTION:gtkorientable
32 * @Short_description: An interface for flippable widgets
33 * @Title: GtkOrientable
35 * The #GtkOrientable interface is implemented by all widgets that can be
36 * oriented horizontally or vertically. Historically, such widgets have been
37 * realized as subclasses of a common base class (e.g #GtkBox/#GtkHBox/#GtkVBox
38 * or #GtkScale/#GtkHScale/#GtkVScale). #GtkOrientable is more flexible in that
39 * it allows the orientation to be changed at runtime, allowing the widgets
42 * #GtkOrientable was introduced in GTK+ 2.16.
46 typedef GtkOrientableIface GtkOrientableInterface;
47 G_DEFINE_INTERFACE (GtkOrientable, gtk_orientable, G_TYPE_OBJECT)
50 gtk_orientable_default_init (GtkOrientableInterface *iface)
53 * GtkOrientable:orientation:
55 * The orientation of the orientable.
59 g_object_interface_install_property (iface,
60 g_param_spec_enum ("orientation",
62 P_("The orientation of the orientable"),
64 GTK_ORIENTATION_HORIZONTAL,
65 GTK_PARAM_READWRITE));
69 * gtk_orientable_set_orientation:
70 * @orientable: a #GtkOrientable
71 * @orientation: the orientable's new orientation.
73 * Sets the orientation of the @orientable.
78 gtk_orientable_set_orientation (GtkOrientable *orientable,
79 GtkOrientation orientation)
81 g_return_if_fail (GTK_IS_ORIENTABLE (orientable));
83 g_object_set (orientable,
84 "orientation", orientation,
87 if (GTK_IS_WIDGET (orientable))
88 _gtk_orientable_set_style_classes (orientable);
92 * gtk_orientable_get_orientation:
93 * @orientable: a #GtkOrientable
95 * Retrieves the orientation of the @orientable.
97 * Return value: the orientation of the @orientable.
102 gtk_orientable_get_orientation (GtkOrientable *orientable)
104 GtkOrientation orientation;
106 g_return_val_if_fail (GTK_IS_ORIENTABLE (orientable),
107 GTK_ORIENTATION_HORIZONTAL);
109 g_object_get (orientable,
110 "orientation", &orientation,
117 _gtk_orientable_set_style_classes (GtkOrientable *orientable)
119 GtkStyleContext *context;
120 GtkOrientation orientation;
122 g_return_if_fail (GTK_IS_ORIENTABLE (orientable));
123 g_return_if_fail (GTK_IS_WIDGET (orientable));
125 context = gtk_widget_get_style_context (GTK_WIDGET (orientable));
126 orientation = gtk_orientable_get_orientation (orientable);
128 if (orientation == GTK_ORIENTATION_HORIZONTAL)
130 gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
131 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL);
135 gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL);
136 gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL);