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