gtk.h wrapper: Added *_set_realized and set_mapped
[pspp] / src / ui / gui / include / gtk / gtk.in.h
1 /* Wrapper for <gtk/gtk.h>.
2    Copyright (C) 2011, 2012 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
16
17 #ifndef PSPP_GTK_GTK_H
18 #define PSPP_GTK_GTK_H
19
20 #if __GNUC__ >= 3
21 @PRAGMA_SYSTEM_HEADER@
22 #endif
23 @PRAGMA_COLUMNS@
24
25 #@INCLUDE_NEXT@ @NEXT_GTK_GTK_H@
26
27 #if !GTK_CHECK_VERSION(2,20,0)
28 /**
29  * gtk_widget_get_realized:
30  * @widget: a #GtkWidget
31  *
32  * Determines whether @widget is realized.
33  *
34  * Return value: %TRUE if @widget is realized, %FALSE otherwise
35  *
36  * Since: 2.20
37  **/
38 static inline gboolean
39 gtk_widget_get_realized (GtkWidget *widget)
40 {
41   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
42
43   return (GTK_WIDGET_FLAGS (widget) & GTK_REALIZED) != 0;
44 }
45
46 /**
47  * gtk_widget_set_realized:
48  * @widget: a #GtkWidget
49  * @realized: %TRUE to mark the widget as realized
50  *
51  * Marks the widget as being realized.
52  *
53  * This function should only ever be called in a derived widget's
54  * "realize" or "unrealize" implementation.
55  *
56  * Since: 2.20
57  */
58 static inline void
59 gtk_widget_set_realized (GtkWidget *widget,
60                          gboolean   realized)
61 {
62   g_return_if_fail (GTK_IS_WIDGET (widget));
63
64   if (realized)
65     GTK_OBJECT_FLAGS (widget) |= GTK_REALIZED;
66   else
67     GTK_OBJECT_FLAGS (widget) &= ~(GTK_REALIZED);
68 }
69
70 #endif  /* gtk < 2.20 */
71
72 #if !GTK_CHECK_VERSION(2,20,0)
73 /**
74  * gtk_widget_get_mapped:
75  * @widget: a #GtkWidget
76  *
77  * Whether the widget is mapped.
78  *
79  * Return value: %TRUE if the widget is mapped, %FALSE otherwise.
80  *
81  * Since: 2.20
82  */
83 static inline gboolean
84 gtk_widget_get_mapped (GtkWidget *widget)
85 {
86   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
87
88   return (GTK_WIDGET_FLAGS (widget) & GTK_MAPPED) != 0;
89 }
90
91 /**
92  * gtk_widget_set_mapped:
93  * @widget: a #GtkWidget
94  * @mapped: %TRUE to mark the widget as mapped
95  *
96  * Marks the widget as being realized.
97  *
98  * This function should only ever be called in a derived widget's
99  * "map" or "unmap" implementation.
100  *
101  * Since: 2.20
102  */
103 static inline void
104 gtk_widget_set_mapped (GtkWidget *widget,
105                        gboolean   mapped)
106 {
107   g_return_if_fail (GTK_IS_WIDGET (widget));
108
109   if (mapped)
110     GTK_OBJECT_FLAGS (widget) |= GTK_MAPPED;
111   else
112     GTK_OBJECT_FLAGS (widget) &= ~(GTK_MAPPED);
113 }
114
115 #endif  /* gtk < 2.20 */
116
117 #if !GTK_CHECK_VERSION(2,18,0)
118 /**
119  * gtk_widget_get_visible:
120  * @widget: a #GtkWidget
121  *
122  * Determines whether the widget is visible. Note that this doesn't
123  * take into account whether the widget's parent is also visible
124  * or the widget is obscured in any way.
125  *
126  * See gtk_widget_set_visible().
127  *
128  * Return value: %TRUE if the widget is visible
129  *
130  * Since: 2.18
131  **/
132 static inline gboolean
133 gtk_widget_get_visible (GtkWidget *widget)
134 {
135   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
136
137   return (GTK_WIDGET_FLAGS (widget) & GTK_VISIBLE) != 0;
138 }
139 #endif  /* gtk < 2.18 */
140
141 #if !GTK_CHECK_VERSION(2,18,0)
142 /**
143  * gtk_widget_is_drawable:
144  * @widget: a #GtkWidget
145  *
146  * Determines whether @widget can be drawn to. A widget can be drawn
147  * to if it is mapped and visible.
148  *
149  * Return value: %TRUE if @widget is drawable, %FALSE otherwise
150  *
151  * Since: 2.18
152  **/
153 static inline gboolean
154 gtk_widget_is_drawable (GtkWidget *widget)
155 {
156   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
157
158   return ((GTK_WIDGET_FLAGS (wid) & GTK_VISIBLE) != 0 &&
159           (GTK_WIDGET_FLAGS (wid) & GTK_MAPPED) != 0);
160 }
161 #endif  /* gtk < 2.18 */
162
163 #if !GTK_CHECK_VERSION(2,18,0)
164 /**
165  * gtk_widget_has_focus:
166  * @widget: a #GtkWidget
167  *
168  * Determines if the widget has the global input focus. See
169  * gtk_widget_is_focus() for the difference between having the global
170  * input focus, and only having the focus within a toplevel.
171  *
172  * Return value: %TRUE if the widget has the global input focus.
173  *
174  * Since: 2.18
175  **/
176 static inline gboolean
177 gtk_widget_has_focus (GtkWidget *widget)
178 {
179   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
180
181   return GTK_WIDGET_HAS_FOCUS (widget);
182 }
183 #endif  /* gtk < 2.18 */
184
185 #if !GTK_CHECK_VERSION(2,18,0)
186 /**
187  * gtk_widget_set_can_focus:
188  * @widget: a #GtkWidget
189  * @can_focus: whether or not @widget can own the input focus.
190  *
191  * Specifies whether @widget can own the input focus. See
192  * gtk_widget_grab_focus() for actually setting the input focus on a
193  * widget.
194  *
195  * Since: 2.18
196  **/
197 static inline void
198 gtk_widget_set_can_focus (GtkWidget *widget,
199                           gboolean   can_focus)
200 {
201   g_return_if_fail (GTK_IS_WIDGET (widget));
202
203   if (can_focus != GTK_WIDGET_CAN_FOCUS (widget))
204     {
205       if (can_focus)
206         GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
207       else
208         GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
209
210       gtk_widget_queue_resize (widget);
211       g_object_notify (G_OBJECT (widget), "can-focus");
212     }
213 }
214 #endif  /* gtk < 2.18 */
215
216 #if !GTK_CHECK_VERSION(2,22,0)
217 /**
218  * gtk_button_get_event_window:
219  * @button: a #GtkButton
220  *
221  * Returns the button's event window if it is realized, %NULL otherwise.
222  * This function should be rarely needed.
223  *
224  * Return value: (transfer none): @button's event window.
225  *
226  * Since: 2.22
227  */
228 static inline GdkWindow*
229 gtk_button_get_event_window (GtkButton *button)
230 {
231   g_return_val_if_fail (GTK_IS_BUTTON (button), NULL);
232
233   return button->event_window;
234 }
235 #endif  /* gtk < 2.22 */
236
237 #endif /* PSPP_GTK_GTK_H */