1/* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library 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 GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
19
20/*
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
25 */
26
27#ifndef __GTK_WINDOW_H__
28#define __GTK_WINDOW_H__
29
30
31#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
32#error "Only <gtk/gtk.h> can be included directly."
33#endif
34
35#include <gtk/gtkaccelgroup.h>
36#include <gtk/gtkbin.h>
37
38
39G_BEGIN_DECLS
40
41#define GTK_TYPE_WINDOW (gtk_window_get_type ())
42#define GTK_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_WINDOW, GtkWindow))
43#define GTK_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_WINDOW, GtkWindowClass))
44#define GTK_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_WINDOW))
45#define GTK_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WINDOW))
46#define GTK_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_WINDOW, GtkWindowClass))
47
48
49typedef struct _GtkWindowClass GtkWindowClass;
50typedef struct _GtkWindowGeometryInfo GtkWindowGeometryInfo;
51typedef struct _GtkWindowGroup GtkWindowGroup;
52typedef struct _GtkWindowGroupClass GtkWindowGroupClass;
53
54struct _GtkWindow
55{
56 GtkBin bin;
57
58 gchar *GSEAL (title);
59 gchar *GSEAL (wmclass_name);
60 gchar *GSEAL (wmclass_class);
61 gchar *GSEAL (wm_role);
62
63 GtkWidget *GSEAL (focus_widget);
64 GtkWidget *GSEAL (default_widget);
65 GtkWindow *GSEAL (transient_parent);
66 GtkWindowGeometryInfo *GSEAL (geometry_info);
67 GdkWindow *GSEAL (frame);
68 GtkWindowGroup *GSEAL (group);
69
70 guint16 GSEAL (configure_request_count);
71 guint GSEAL (allow_shrink) : 1;
72 guint GSEAL (allow_grow) : 1;
73 guint GSEAL (configure_notify_received) : 1;
74 /* The following flags are initially TRUE (before a window is mapped).
75 * They cause us to compute a configure request that involves
76 * default-only parameters. Once mapped, we set them to FALSE.
77 * Then we set them to TRUE again on unmap (for position)
78 * and on unrealize (for size).
79 */
80 guint GSEAL (need_default_position) : 1;
81 guint GSEAL (need_default_size) : 1;
82 guint GSEAL (position) : 3;
83 guint GSEAL (type) : 4; /* GtkWindowType */
84 guint GSEAL (has_user_ref_count) : 1;
85 guint GSEAL (has_focus) : 1;
86
87 guint GSEAL (modal) : 1;
88 guint GSEAL (destroy_with_parent) : 1;
89
90 guint GSEAL (has_frame) : 1;
91
92 /* gtk_window_iconify() called before realization */
93 guint GSEAL (iconify_initially) : 1;
94 guint GSEAL (stick_initially) : 1;
95 guint GSEAL (maximize_initially) : 1;
96 guint GSEAL (decorated) : 1;
97
98 guint GSEAL (type_hint) : 3; /* GdkWindowTypeHint if the hint is one of the original eight. If not, then
99 * it contains GDK_WINDOW_TYPE_HINT_NORMAL
100 */
101 guint GSEAL (gravity) : 5; /* GdkGravity */
102
103 guint GSEAL (is_active) : 1;
104 guint GSEAL (has_toplevel_focus) : 1;
105
106 guint GSEAL (frame_left);
107 guint GSEAL (frame_top);
108 guint GSEAL (frame_right);
109 guint GSEAL (frame_bottom);
110
111 guint GSEAL (keys_changed_handler);
112
113 GdkModifierType GSEAL (mnemonic_modifier);
114 GdkScreen *GSEAL (screen);
115};
116
117struct _GtkWindowClass
118{
119 GtkBinClass parent_class;
120
121 void (* set_focus) (GtkWindow *window,
122 GtkWidget *focus);
123 gboolean (* frame_event) (GtkWindow *window,
124 GdkEvent *event);
125
126 /* G_SIGNAL_ACTION signals for keybindings */
127
128 void (* activate_focus) (GtkWindow *window);
129 void (* activate_default) (GtkWindow *window);
130
131 /* as of GTK+ 2.12 the "move-focus" signal has been moved to GtkWidget,
132 * so this is merley a virtual function now. Overriding it in subclasses
133 * continues to work though.
134 */
135 void (* move_focus) (GtkWindow *window,
136 GtkDirectionType direction);
137
138 void (*keys_changed) (GtkWindow *window);
139
140 /* Padding for future expansion */
141 void (*_gtk_reserved1) (void);
142 void (*_gtk_reserved2) (void);
143 void (*_gtk_reserved3) (void);
144 void (*_gtk_reserved4) (void);
145};
146
147#define GTK_TYPE_WINDOW_GROUP (gtk_window_group_get_type ())
148#define GTK_WINDOW_GROUP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_WINDOW_GROUP, GtkWindowGroup))
149#define GTK_WINDOW_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_WINDOW_GROUP, GtkWindowGroupClass))
150#define GTK_IS_WINDOW_GROUP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_WINDOW_GROUP))
151#define GTK_IS_WINDOW_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WINDOW_GROUP))
152#define GTK_WINDOW_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_WINDOW_GROUP, GtkWindowGroupClass))
153
154struct _GtkWindowGroup
155{
156 GObject parent_instance;
157
158 GSList *GSEAL (grabs);
159};
160
161struct _GtkWindowGroupClass
162{
163 GObjectClass parent_class;
164
165 /* Padding for future expansion */
166 void (*_gtk_reserved1) (void);
167 void (*_gtk_reserved2) (void);
168 void (*_gtk_reserved3) (void);
169 void (*_gtk_reserved4) (void);
170};
171
172#ifdef G_OS_WIN32
173/* Reserve old names for DLL ABI backward compatibility */
174#define gtk_window_set_icon_from_file gtk_window_set_icon_from_file_utf8
175#define gtk_window_set_default_icon_from_file gtk_window_set_default_icon_from_file_utf8
176#endif
177
178GType gtk_window_get_type (void) G_GNUC_CONST;
179GtkWidget* gtk_window_new (GtkWindowType type);
180void gtk_window_set_title (GtkWindow *window,
181 const gchar *title);
182const gchar *gtk_window_get_title (GtkWindow *window);
183void gtk_window_set_wmclass (GtkWindow *window,
184 const gchar *wmclass_name,
185 const gchar *wmclass_class);
186void gtk_window_set_role (GtkWindow *window,
187 const gchar *role);
188void gtk_window_set_startup_id (GtkWindow *window,
189 const gchar *startup_id);
190const gchar *gtk_window_get_role (GtkWindow *window);
191void gtk_window_add_accel_group (GtkWindow *window,
192 GtkAccelGroup *accel_group);
193void gtk_window_remove_accel_group (GtkWindow *window,
194 GtkAccelGroup *accel_group);
195void gtk_window_set_position (GtkWindow *window,
196 GtkWindowPosition position);
197gboolean gtk_window_activate_focus (GtkWindow *window);
198void gtk_window_set_focus (GtkWindow *window,
199 GtkWidget *focus);
200GtkWidget *gtk_window_get_focus (GtkWindow *window);
201void gtk_window_set_default (GtkWindow *window,
202 GtkWidget *default_widget);
203GtkWidget *gtk_window_get_default_widget (GtkWindow *window);
204gboolean gtk_window_activate_default (GtkWindow *window);
205
206void gtk_window_set_transient_for (GtkWindow *window,
207 GtkWindow *parent);
208GtkWindow *gtk_window_get_transient_for (GtkWindow *window);
209void gtk_window_set_opacity (GtkWindow *window,
210 gdouble opacity);
211gdouble gtk_window_get_opacity (GtkWindow *window);
212void gtk_window_set_type_hint (GtkWindow *window,
213 GdkWindowTypeHint hint);
214GdkWindowTypeHint gtk_window_get_type_hint (GtkWindow *window);
215void gtk_window_set_skip_taskbar_hint (GtkWindow *window,
216 gboolean setting);
217gboolean gtk_window_get_skip_taskbar_hint (GtkWindow *window);
218void gtk_window_set_skip_pager_hint (GtkWindow *window,
219 gboolean setting);
220gboolean gtk_window_get_skip_pager_hint (GtkWindow *window);
221void gtk_window_set_urgency_hint (GtkWindow *window,
222 gboolean setting);
223gboolean gtk_window_get_urgency_hint (GtkWindow *window);
224void gtk_window_set_accept_focus (GtkWindow *window,
225 gboolean setting);
226gboolean gtk_window_get_accept_focus (GtkWindow *window);
227void gtk_window_set_focus_on_map (GtkWindow *window,
228 gboolean setting);
229gboolean gtk_window_get_focus_on_map (GtkWindow *window);
230void gtk_window_set_destroy_with_parent (GtkWindow *window,
231 gboolean setting);
232gboolean gtk_window_get_destroy_with_parent (GtkWindow *window);
233void gtk_window_set_mnemonics_visible (GtkWindow *window,
234 gboolean setting);
235gboolean gtk_window_get_mnemonics_visible (GtkWindow *window);
236
237void gtk_window_set_resizable (GtkWindow *window,
238 gboolean resizable);
239gboolean gtk_window_get_resizable (GtkWindow *window);
240
241void gtk_window_set_gravity (GtkWindow *window,
242 GdkGravity gravity);
243GdkGravity gtk_window_get_gravity (GtkWindow *window);
244
245
246void gtk_window_set_geometry_hints (GtkWindow *window,
247 GtkWidget *geometry_widget,
248 GdkGeometry *geometry,
249 GdkWindowHints geom_mask);
250
251void gtk_window_set_screen (GtkWindow *window,
252 GdkScreen *screen);
253GdkScreen* gtk_window_get_screen (GtkWindow *window);
254
255gboolean gtk_window_is_active (GtkWindow *window);
256gboolean gtk_window_has_toplevel_focus (GtkWindow *window);
257
258
259#ifndef GTK_DISABLE_DEPRECATED
260/* gtk_window_set_has_frame () must be called before realizing the window_*/
261void gtk_window_set_has_frame (GtkWindow *window,
262 gboolean setting);
263gboolean gtk_window_get_has_frame (GtkWindow *window);
264void gtk_window_set_frame_dimensions (GtkWindow *window,
265 gint left,
266 gint top,
267 gint right,
268 gint bottom);
269void gtk_window_get_frame_dimensions (GtkWindow *window,
270 gint *left,
271 gint *top,
272 gint *right,
273 gint *bottom);
274#endif
275void gtk_window_set_decorated (GtkWindow *window,
276 gboolean setting);
277gboolean gtk_window_get_decorated (GtkWindow *window);
278void gtk_window_set_deletable (GtkWindow *window,
279 gboolean setting);
280gboolean gtk_window_get_deletable (GtkWindow *window);
281
282void gtk_window_set_icon_list (GtkWindow *window,
283 GList *list);
284GList* gtk_window_get_icon_list (GtkWindow *window);
285void gtk_window_set_icon (GtkWindow *window,
286 GdkPixbuf *icon);
287void gtk_window_set_icon_name (GtkWindow *window,
288 const gchar *name);
289gboolean gtk_window_set_icon_from_file (GtkWindow *window,
290 const gchar *filename,
291 GError **err);
292GdkPixbuf* gtk_window_get_icon (GtkWindow *window);
293const gchar *
294 gtk_window_get_icon_name (GtkWindow *window);
295void gtk_window_set_default_icon_list (GList *list);
296GList* gtk_window_get_default_icon_list (void);
297void gtk_window_set_default_icon (GdkPixbuf *icon);
298void gtk_window_set_default_icon_name (const gchar *name);
299const gchar *
300 gtk_window_get_default_icon_name (void);
301gboolean gtk_window_set_default_icon_from_file (const gchar *filename,
302 GError **err);
303
304void gtk_window_set_auto_startup_notification (gboolean setting);
305
306/* If window is set modal, input will be grabbed when show and released when hide */
307void gtk_window_set_modal (GtkWindow *window,
308 gboolean modal);
309gboolean gtk_window_get_modal (GtkWindow *window);
310GList* gtk_window_list_toplevels (void);
311
312void gtk_window_add_mnemonic (GtkWindow *window,
313 guint keyval,
314 GtkWidget *target);
315void gtk_window_remove_mnemonic (GtkWindow *window,
316 guint keyval,
317 GtkWidget *target);
318gboolean gtk_window_mnemonic_activate (GtkWindow *window,
319 guint keyval,
320 GdkModifierType modifier);
321void gtk_window_set_mnemonic_modifier (GtkWindow *window,
322 GdkModifierType modifier);
323GdkModifierType gtk_window_get_mnemonic_modifier (GtkWindow *window);
324
325gboolean gtk_window_activate_key (GtkWindow *window,
326 GdkEventKey *event);
327gboolean gtk_window_propagate_key_event (GtkWindow *window,
328 GdkEventKey *event);
329
330void gtk_window_present (GtkWindow *window);
331void gtk_window_present_with_time (GtkWindow *window,
332 guint32 timestamp);
333void gtk_window_iconify (GtkWindow *window);
334void gtk_window_deiconify (GtkWindow *window);
335void gtk_window_stick (GtkWindow *window);
336void gtk_window_unstick (GtkWindow *window);
337void gtk_window_maximize (GtkWindow *window);
338void gtk_window_unmaximize (GtkWindow *window);
339void gtk_window_fullscreen (GtkWindow *window);
340void gtk_window_unfullscreen (GtkWindow *window);
341void gtk_window_set_keep_above (GtkWindow *window, gboolean setting);
342void gtk_window_set_keep_below (GtkWindow *window, gboolean setting);
343
344void gtk_window_begin_resize_drag (GtkWindow *window,
345 GdkWindowEdge edge,
346 gint button,
347 gint root_x,
348 gint root_y,
349 guint32 timestamp);
350void gtk_window_begin_move_drag (GtkWindow *window,
351 gint button,
352 gint root_x,
353 gint root_y,
354 guint32 timestamp);
355
356#ifndef GTK_DISABLE_DEPRECATED
357void gtk_window_set_policy (GtkWindow *window,
358 gint allow_shrink,
359 gint allow_grow,
360 gint auto_shrink);
361#define gtk_window_position gtk_window_set_position
362#endif /* GTK_DISABLE_DEPRECATED */
363
364/* Set initial default size of the window (does not constrain user
365 * resize operations)
366 */
367void gtk_window_set_default_size (GtkWindow *window,
368 gint width,
369 gint height);
370void gtk_window_get_default_size (GtkWindow *window,
371 gint *width,
372 gint *height);
373void gtk_window_resize (GtkWindow *window,
374 gint width,
375 gint height);
376void gtk_window_get_size (GtkWindow *window,
377 gint *width,
378 gint *height);
379void gtk_window_move (GtkWindow *window,
380 gint x,
381 gint y);
382void gtk_window_get_position (GtkWindow *window,
383 gint *root_x,
384 gint *root_y);
385gboolean gtk_window_parse_geometry (GtkWindow *window,
386 const gchar *geometry);
387GtkWindowGroup *gtk_window_get_group (GtkWindow *window);
388gboolean gtk_window_has_group (GtkWindow *window);
389
390/* Ignore this unless you are writing a GUI builder */
391void gtk_window_reshow_with_initial_size (GtkWindow *window);
392
393GtkWindowType gtk_window_get_window_type (GtkWindow *window);
394
395/* Window groups
396 */
397GType gtk_window_group_get_type (void) G_GNUC_CONST;
398
399GtkWindowGroup * gtk_window_group_new (void);
400void gtk_window_group_add_window (GtkWindowGroup *window_group,
401 GtkWindow *window);
402void gtk_window_group_remove_window (GtkWindowGroup *window_group,
403 GtkWindow *window);
404GList * gtk_window_group_list_windows (GtkWindowGroup *window_group);
405
406
407/* --- internal functions --- */
408void _gtk_window_internal_set_focus (GtkWindow *window,
409 GtkWidget *focus);
410void gtk_window_remove_embedded_xid (GtkWindow *window,
411 GdkNativeWindow xid);
412void gtk_window_add_embedded_xid (GtkWindow *window,
413 GdkNativeWindow xid);
414void _gtk_window_reposition (GtkWindow *window,
415 gint x,
416 gint y);
417void _gtk_window_constrain_size (GtkWindow *window,
418 gint width,
419 gint height,
420 gint *new_width,
421 gint *new_height);
422GtkWidget *gtk_window_group_get_current_grab (GtkWindowGroup *window_group);
423
424void _gtk_window_set_has_toplevel_focus (GtkWindow *window,
425 gboolean has_toplevel_focus);
426void _gtk_window_unset_focus_and_default (GtkWindow *window,
427 GtkWidget *widget);
428
429void _gtk_window_set_is_active (GtkWindow *window,
430 gboolean is_active);
431
432void _gtk_window_set_is_toplevel (GtkWindow *window,
433 gboolean is_toplevel);
434
435typedef void (*GtkWindowKeysForeachFunc) (GtkWindow *window,
436 guint keyval,
437 GdkModifierType modifiers,
438 gboolean is_mnemonic,
439 gpointer data);
440
441void _gtk_window_keys_foreach (GtkWindow *window,
442 GtkWindowKeysForeachFunc func,
443 gpointer func_data);
444
445/* --- internal (GtkAcceleratable) --- */
446gboolean _gtk_window_query_nonaccels (GtkWindow *window,
447 guint accel_key,
448 GdkModifierType accel_mods);
449
450G_END_DECLS
451
452#endif /* __GTK_WINDOW_H__ */
453