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, see <http://www.gnu.org/licenses/>. |
20 | */ |
21 | |
22 | #include "config.h" |
23 | |
24 | #include "gtkorientable.h" |
25 | |
26 | #include "gtkprivate.h" |
27 | #include "gtkwidgetprivate.h" |
28 | #include "gtktypebuiltins.h" |
29 | #include "gtkintl.h" |
30 | |
31 | |
32 | /** |
33 | * GtkOrientable: |
34 | * |
35 | * The `GtkOrientable` interface is implemented by all widgets that can be |
36 | * oriented horizontally or vertically. |
37 | * |
38 | * `GtkOrientable` is more flexible in that it allows the orientation to be |
39 | * changed at runtime, allowing the widgets to “flip”. |
40 | */ |
41 | |
42 | |
43 | typedef GtkOrientableIface GtkOrientableInterface; |
44 | G_DEFINE_INTERFACE (GtkOrientable, gtk_orientable, G_TYPE_OBJECT) |
45 | |
46 | static void |
47 | gtk_orientable_default_init (GtkOrientableInterface *iface) |
48 | { |
49 | /** |
50 | * GtkOrientable:orientation: (attributes org.gtk.Property.get=gtk_orientable_get_orientation org.gtk.Property.set=gtk_orientable_set_orientation) |
51 | * |
52 | * The orientation of the orientable. |
53 | **/ |
54 | g_object_interface_install_property (g_iface: iface, |
55 | pspec: g_param_spec_enum (name: "orientation" , |
56 | P_("Orientation" ), |
57 | P_("The orientation of the orientable" ), |
58 | enum_type: GTK_TYPE_ORIENTATION, |
59 | default_value: GTK_ORIENTATION_HORIZONTAL, |
60 | GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY)); |
61 | } |
62 | |
63 | /** |
64 | * gtk_orientable_set_orientation: (attributes org.gtk.Method.set_property=orientation) |
65 | * @orientable: a `GtkOrientable` |
66 | * @orientation: the orientable’s new orientation |
67 | * |
68 | * Sets the orientation of the @orientable. |
69 | */ |
70 | void |
71 | gtk_orientable_set_orientation (GtkOrientable *orientable, |
72 | GtkOrientation orientation) |
73 | { |
74 | g_return_if_fail (GTK_IS_ORIENTABLE (orientable)); |
75 | |
76 | g_object_set (object: orientable, |
77 | first_property_name: "orientation" , orientation, |
78 | NULL); |
79 | |
80 | if (GTK_IS_WIDGET (orientable)) |
81 | gtk_widget_update_orientation (GTK_WIDGET (orientable), orientation); |
82 | } |
83 | |
84 | /** |
85 | * gtk_orientable_get_orientation: (attributes org.gtk.Method.get_property=orientation) |
86 | * @orientable: a `GtkOrientable` |
87 | * |
88 | * Retrieves the orientation of the @orientable. |
89 | * |
90 | * Returns: the orientation of the @orientable |
91 | */ |
92 | GtkOrientation |
93 | gtk_orientable_get_orientation (GtkOrientable *orientable) |
94 | { |
95 | GtkOrientation orientation; |
96 | |
97 | g_return_val_if_fail (GTK_IS_ORIENTABLE (orientable), |
98 | GTK_ORIENTATION_HORIZONTAL); |
99 | |
100 | g_object_get (object: orientable, |
101 | first_property_name: "orientation" , &orientation, |
102 | NULL); |
103 | |
104 | return orientation; |
105 | } |
106 | |