1 /* Wrapper for <gtk/gtk.h>.
2 Copyright (C) 2011, 2012 Free Software Foundation, Inc.
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.
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.
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/>. */
17 #ifndef PSPP_GTK_GTK_H
18 #define PSPP_GTK_GTK_H
21 @PRAGMA_SYSTEM_HEADER@
25 #@INCLUDE_NEXT@ @NEXT_GTK_GTK_H@
27 #if !GTK_CHECK_VERSION(2,20,0)
29 * gtk_widget_get_realized:
30 * @widget: a #GtkWidget
32 * Determines whether @widget is realized.
34 * Return value: %TRUE if @widget is realized, %FALSE otherwise
38 static inline gboolean
39 gtk_widget_get_realized (GtkWidget *widget)
41 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
43 return (GTK_WIDGET_FLAGS (widget) & GTK_REALIZED) != 0;
47 * gtk_widget_set_realized:
48 * @widget: a #GtkWidget
49 * @realized: %TRUE to mark the widget as realized
51 * Marks the widget as being realized.
53 * This function should only ever be called in a derived widget's
54 * "realize" or "unrealize" implementation.
59 gtk_widget_set_realized (GtkWidget *widget,
62 g_return_if_fail (GTK_IS_WIDGET (widget));
65 GTK_OBJECT_FLAGS (widget) |= GTK_REALIZED;
67 GTK_OBJECT_FLAGS (widget) &= ~(GTK_REALIZED);
70 #endif /* gtk < 2.20 */
72 #if !GTK_CHECK_VERSION(2,20,0)
74 * gtk_widget_get_mapped:
75 * @widget: a #GtkWidget
77 * Whether the widget is mapped.
79 * Return value: %TRUE if the widget is mapped, %FALSE otherwise.
83 static inline gboolean
84 gtk_widget_get_mapped (GtkWidget *widget)
86 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
88 return (GTK_WIDGET_FLAGS (widget) & GTK_MAPPED) != 0;
92 * gtk_widget_set_mapped:
93 * @widget: a #GtkWidget
94 * @mapped: %TRUE to mark the widget as mapped
96 * Marks the widget as being realized.
98 * This function should only ever be called in a derived widget's
99 * "map" or "unmap" implementation.
104 gtk_widget_set_mapped (GtkWidget *widget,
107 g_return_if_fail (GTK_IS_WIDGET (widget));
110 GTK_OBJECT_FLAGS (widget) |= GTK_MAPPED;
112 GTK_OBJECT_FLAGS (widget) &= ~(GTK_MAPPED);
115 #endif /* gtk < 2.20 */
117 #if !GTK_CHECK_VERSION(2,18,0)
119 * gtk_widget_get_visible:
120 * @widget: a #GtkWidget
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.
126 * See gtk_widget_set_visible().
128 * Return value: %TRUE if the widget is visible
132 static inline gboolean
133 gtk_widget_get_visible (GtkWidget *widget)
135 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
137 return (GTK_WIDGET_FLAGS (widget) & GTK_VISIBLE) != 0;
139 #endif /* gtk < 2.18 */
141 #if !GTK_CHECK_VERSION(2,18,0)
143 * gtk_widget_is_drawable:
144 * @widget: a #GtkWidget
146 * Determines whether @widget can be drawn to. A widget can be drawn
147 * to if it is mapped and visible.
149 * Return value: %TRUE if @widget is drawable, %FALSE otherwise
153 static inline gboolean
154 gtk_widget_is_drawable (GtkWidget *widget)
156 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
158 return ((GTK_WIDGET_FLAGS (wid) & GTK_VISIBLE) != 0 &&
159 (GTK_WIDGET_FLAGS (wid) & GTK_MAPPED) != 0);
161 #endif /* gtk < 2.18 */
163 #if !GTK_CHECK_VERSION(2,18,0)
165 * gtk_widget_has_focus:
166 * @widget: a #GtkWidget
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.
172 * Return value: %TRUE if the widget has the global input focus.
176 static inline gboolean
177 gtk_widget_has_focus (GtkWidget *widget)
179 g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
181 return GTK_WIDGET_HAS_FOCUS (widget);
183 #endif /* gtk < 2.18 */
185 #if !GTK_CHECK_VERSION(2,18,0)
187 * gtk_widget_set_can_focus:
188 * @widget: a #GtkWidget
189 * @can_focus: whether or not @widget can own the input focus.
191 * Specifies whether @widget can own the input focus. See
192 * gtk_widget_grab_focus() for actually setting the input focus on a
198 gtk_widget_set_can_focus (GtkWidget *widget,
201 g_return_if_fail (GTK_IS_WIDGET (widget));
203 if (can_focus != GTK_WIDGET_CAN_FOCUS (widget))
206 GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
208 GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
210 gtk_widget_queue_resize (widget);
211 g_object_notify (G_OBJECT (widget), "can-focus");
214 #endif /* gtk < 2.18 */
216 #if !GTK_CHECK_VERSION(2,22,0)
218 * gtk_button_get_event_window:
219 * @button: a #GtkButton
221 * Returns the button's event window if it is realized, %NULL otherwise.
222 * This function should be rarely needed.
224 * Return value: (transfer none): @button's event window.
228 static inline GdkWindow*
229 gtk_button_get_event_window (GtkButton *button)
231 g_return_val_if_fail (GTK_IS_BUTTON (button), NULL);
233 return button->event_window;
235 #endif /* gtk < 2.22 */
238 #ifndef G_CONST_RETURN
239 #define G_CONST_RETURN const
243 /* Like GSEAL but only used in PSPP */
246 #endif /* PSPP_GTK_GTK_H */