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, see <http://www.gnu.org/licenses/>. 16 */ 17 18 /* 19 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS 20 * file for a list of people on the GTK+ Team. See the ChangeLog 21 * files for a list of changes. These files are distributed with 22 * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 23 */ 24 25 #ifndef __GTK_WINDOW_H__ 26 #define __GTK_WINDOW_H__ 27 28 29 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) 30 #error "Only <gtk/gtk.h> can be included directly." 31 #endif 32 33 #include <gtk/gtkapplication.h> 34 #include <gtk/gtkaccelgroup.h> 35 #include <gtk/gtkbin.h> 36 37 G_BEGIN_DECLS 38 39 #define GTK_TYPE_WINDOW (gtk_window_get_type ()) 40 #define GTK_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_WINDOW, GtkWindow)) 41 #define GTK_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_WINDOW, GtkWindowClass)) 42 #define GTK_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_WINDOW)) 43 #define GTK_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WINDOW)) 44 #define GTK_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_WINDOW, GtkWindowClass)) 45 46 typedef struct _GtkWindowPrivate GtkWindowPrivate; 47 typedef struct _GtkWindowClass GtkWindowClass; 48 typedef struct _GtkWindowGeometryInfo GtkWindowGeometryInfo; 49 typedef struct _GtkWindowGroup GtkWindowGroup; 50 typedef struct _GtkWindowGroupClass GtkWindowGroupClass; 51 typedef struct _GtkWindowGroupPrivate GtkWindowGroupPrivate; 52 53 struct _GtkWindow 54 { 55 GtkBin bin; 56 57 GtkWindowPrivate *priv; 58 }; 59 60 /** 61 * GtkWindowClass: 62 * @parent_class: The parent class. 63 * @set_focus: Sets child as the focus widget for the window. 64 * @activate_focus: Activates the current focused widget within the window. 65 * @activate_default: Activates the default widget for the window. 66 * @keys_changed: Signal gets emitted when the set of accelerators or 67 * mnemonics that are associated with window changes. 68 * @enable_debugging: Class handler for the #GtkWindow::enable-debugging 69 * keybinding signal. Since: 3.14 70 */ 71 struct _GtkWindowClass 72 { 73 GtkBinClass parent_class; 74 75 /*< public >*/ 76 77 void (* set_focus) (GtkWindow *window, 78 GtkWidget *focus); 79 80 /* G_SIGNAL_ACTION signals for keybindings */ 81 82 void (* activate_focus) (GtkWindow *window); 83 void (* activate_default) (GtkWindow *window); 84 void (* keys_changed) (GtkWindow *window); 85 gboolean (* enable_debugging) (GtkWindow *window, 86 gboolean toggle); 87 88 /*< private >*/ 89 90 /* Padding for future expansion */ 91 void (*_gtk_reserved1) (void); 92 void (*_gtk_reserved2) (void); 93 void (*_gtk_reserved3) (void); 94 }; 95 96 /** 97 * GtkWindowType: 98 * @GTK_WINDOW_TOPLEVEL: A regular window, such as a dialog. 99 * @GTK_WINDOW_POPUP: A special window such as a tooltip. 100 * 101 * A #GtkWindow can be one of these types. Most things you’d consider a 102 * “window” should have type #GTK_WINDOW_TOPLEVEL; windows with this type 103 * are managed by the window manager and have a frame by default (call 104 * gtk_window_set_decorated() to toggle the frame). Windows with type 105 * #GTK_WINDOW_POPUP are ignored by the window manager; window manager 106 * keybindings won’t work on them, the window manager won’t decorate the 107 * window with a frame, many GTK+ features that rely on the window 108 * manager will not work (e.g. resize grips and 109 * maximization/minimization). #GTK_WINDOW_POPUP is used to implement 110 * widgets such as #GtkMenu or tooltips that you normally don’t think of 111 * as windows per se. Nearly all windows should be #GTK_WINDOW_TOPLEVEL. 112 * In particular, do not use #GTK_WINDOW_POPUP just to turn off 113 * the window borders; use gtk_window_set_decorated() for that. 114 */ 115 typedef enum 116 { 117 GTK_WINDOW_TOPLEVEL, 118 GTK_WINDOW_POPUP 119 } GtkWindowType; 120 121 /** 122 * GtkWindowPosition: 123 * @GTK_WIN_POS_NONE: No influence is made on placement. 124 * @GTK_WIN_POS_CENTER: Windows should be placed in the center of the screen. 125 * @GTK_WIN_POS_MOUSE: Windows should be placed at the current mouse position. 126 * @GTK_WIN_POS_CENTER_ALWAYS: Keep window centered as it changes size, etc. 127 * @GTK_WIN_POS_CENTER_ON_PARENT: Center the window on its transient 128 * parent (see gtk_window_set_transient_for()). 129 * 130 * Window placement can be influenced using this enumeration. Note that 131 * using #GTK_WIN_POS_CENTER_ALWAYS is almost always a bad idea. 132 * It won’t necessarily work well with all window managers or on all windowing systems. 133 */ 134 typedef enum 135 { 136 GTK_WIN_POS_NONE, 137 GTK_WIN_POS_CENTER, 138 GTK_WIN_POS_MOUSE, 139 GTK_WIN_POS_CENTER_ALWAYS, 140 GTK_WIN_POS_CENTER_ON_PARENT 141 } GtkWindowPosition; 142 143 144 GDK_AVAILABLE_IN_ALL 145 GType gtk_window_get_type (void) G_GNUC_CONST; 146 GDK_AVAILABLE_IN_ALL 147 GtkWidget* gtk_window_new (GtkWindowType type); 148 GDK_AVAILABLE_IN_ALL 149 void gtk_window_set_title (GtkWindow *window, 150 const gchar *title); 151 GDK_AVAILABLE_IN_ALL 152 const gchar * gtk_window_get_title (GtkWindow *window); 153 GDK_DEPRECATED_IN_3_22 154 void gtk_window_set_wmclass (GtkWindow *window, 155 const gchar *wmclass_name, 156 const gchar *wmclass_class); 157 GDK_AVAILABLE_IN_ALL 158 void gtk_window_set_role (GtkWindow *window, 159 const gchar *role); 160 GDK_AVAILABLE_IN_ALL 161 void gtk_window_set_startup_id (GtkWindow *window, 162 const gchar *startup_id); 163 GDK_AVAILABLE_IN_ALL 164 const gchar * gtk_window_get_role (GtkWindow *window); 165 GDK_AVAILABLE_IN_ALL 166 void gtk_window_add_accel_group (GtkWindow *window, 167 GtkAccelGroup *accel_group); 168 GDK_AVAILABLE_IN_ALL 169 void gtk_window_remove_accel_group (GtkWindow *window, 170 GtkAccelGroup *accel_group); 171 GDK_AVAILABLE_IN_ALL 172 void gtk_window_set_position (GtkWindow *window, 173 GtkWindowPosition position); 174 GDK_AVAILABLE_IN_ALL 175 gboolean gtk_window_activate_focus (GtkWindow *window); 176 GDK_AVAILABLE_IN_ALL 177 void gtk_window_set_focus (GtkWindow *window, 178 GtkWidget *focus); 179 GDK_AVAILABLE_IN_ALL 180 GtkWidget *gtk_window_get_focus (GtkWindow *window); 181 GDK_AVAILABLE_IN_ALL 182 void gtk_window_set_default (GtkWindow *window, 183 GtkWidget *default_widget); 184 GDK_AVAILABLE_IN_ALL 185 GtkWidget *gtk_window_get_default_widget (GtkWindow *window); 186 GDK_AVAILABLE_IN_ALL 187 gboolean gtk_window_activate_default (GtkWindow *window); 188 189 GDK_AVAILABLE_IN_ALL 190 void gtk_window_set_transient_for (GtkWindow *window, 191 GtkWindow *parent); 192 GDK_AVAILABLE_IN_ALL 193 GtkWindow *gtk_window_get_transient_for (GtkWindow *window); 194 GDK_AVAILABLE_IN_3_4 195 void gtk_window_set_attached_to (GtkWindow *window, 196 GtkWidget *attach_widget); 197 GDK_AVAILABLE_IN_3_4 198 GtkWidget *gtk_window_get_attached_to (GtkWindow *window); 199 GDK_DEPRECATED_IN_3_8_FOR(gtk_widget_set_opacity) 200 void gtk_window_set_opacity (GtkWindow *window, 201 gdouble opacity); 202 GDK_DEPRECATED_IN_3_8_FOR(gtk_widget_get_opacity) 203 gdouble gtk_window_get_opacity (GtkWindow *window); 204 GDK_AVAILABLE_IN_ALL 205 void gtk_window_set_type_hint (GtkWindow *window, 206 GdkWindowTypeHint hint); 207 GDK_AVAILABLE_IN_ALL 208 GdkWindowTypeHint gtk_window_get_type_hint (GtkWindow *window); 209 GDK_AVAILABLE_IN_ALL 210 void gtk_window_set_skip_taskbar_hint (GtkWindow *window, 211 gboolean setting); 212 GDK_AVAILABLE_IN_ALL 213 gboolean gtk_window_get_skip_taskbar_hint (GtkWindow *window); 214 GDK_AVAILABLE_IN_ALL 215 void gtk_window_set_skip_pager_hint (GtkWindow *window, 216 gboolean setting); 217 GDK_AVAILABLE_IN_ALL 218 gboolean gtk_window_get_skip_pager_hint (GtkWindow *window); 219 GDK_AVAILABLE_IN_ALL 220 void gtk_window_set_urgency_hint (GtkWindow *window, 221 gboolean setting); 222 GDK_AVAILABLE_IN_ALL 223 gboolean gtk_window_get_urgency_hint (GtkWindow *window); 224 GDK_AVAILABLE_IN_ALL 225 void gtk_window_set_accept_focus (GtkWindow *window, 226 gboolean setting); 227 GDK_AVAILABLE_IN_ALL 228 gboolean gtk_window_get_accept_focus (GtkWindow *window); 229 GDK_AVAILABLE_IN_ALL 230 void gtk_window_set_focus_on_map (GtkWindow *window, 231 gboolean setting); 232 GDK_AVAILABLE_IN_ALL 233 gboolean gtk_window_get_focus_on_map (GtkWindow *window); 234 GDK_AVAILABLE_IN_ALL 235 void gtk_window_set_destroy_with_parent (GtkWindow *window, 236 gboolean setting); 237 GDK_AVAILABLE_IN_ALL 238 gboolean gtk_window_get_destroy_with_parent (GtkWindow *window); 239 GDK_AVAILABLE_IN_3_4 240 void gtk_window_set_hide_titlebar_when_maximized (GtkWindow *window, 241 gboolean setting); 242 GDK_AVAILABLE_IN_3_4 243 gboolean gtk_window_get_hide_titlebar_when_maximized (GtkWindow *window); 244 GDK_AVAILABLE_IN_ALL 245 void gtk_window_set_mnemonics_visible (GtkWindow *window, 246 gboolean setting); 247 GDK_AVAILABLE_IN_ALL 248 gboolean gtk_window_get_mnemonics_visible (GtkWindow *window); 249 GDK_AVAILABLE_IN_3_2 250 void gtk_window_set_focus_visible (GtkWindow *window, 251 gboolean setting); 252 GDK_AVAILABLE_IN_3_2 253 gboolean gtk_window_get_focus_visible (GtkWindow *window); 254 255 GDK_AVAILABLE_IN_ALL 256 void gtk_window_set_resizable (GtkWindow *window, 257 gboolean resizable); 258 GDK_AVAILABLE_IN_ALL 259 gboolean gtk_window_get_resizable (GtkWindow *window); 260 261 GDK_AVAILABLE_IN_ALL 262 void gtk_window_set_gravity (GtkWindow *window, 263 GdkGravity gravity); 264 GDK_AVAILABLE_IN_ALL 265 GdkGravity gtk_window_get_gravity (GtkWindow *window); 266 267 268 GDK_AVAILABLE_IN_ALL 269 void gtk_window_set_geometry_hints (GtkWindow *window, 270 GtkWidget *geometry_widget, 271 GdkGeometry *geometry, 272 GdkWindowHints geom_mask); 273 274 GDK_AVAILABLE_IN_ALL 275 void gtk_window_set_screen (GtkWindow *window, 276 GdkScreen *screen); 277 GDK_AVAILABLE_IN_ALL 278 GdkScreen* gtk_window_get_screen (GtkWindow *window); 279 280 GDK_AVAILABLE_IN_ALL 281 gboolean gtk_window_is_active (GtkWindow *window); 282 GDK_AVAILABLE_IN_ALL 283 gboolean gtk_window_has_toplevel_focus (GtkWindow *window); 284 285 GDK_AVAILABLE_IN_ALL 286 void gtk_window_set_decorated (GtkWindow *window, 287 gboolean setting); 288 GDK_AVAILABLE_IN_ALL 289 gboolean gtk_window_get_decorated (GtkWindow *window); 290 GDK_AVAILABLE_IN_ALL 291 void gtk_window_set_deletable (GtkWindow *window, 292 gboolean setting); 293 GDK_AVAILABLE_IN_ALL 294 gboolean gtk_window_get_deletable (GtkWindow *window); 295 296 GDK_AVAILABLE_IN_ALL 297 void gtk_window_set_icon_list (GtkWindow *window, 298 GList *list); 299 GDK_AVAILABLE_IN_ALL 300 GList* gtk_window_get_icon_list (GtkWindow *window); 301 GDK_AVAILABLE_IN_ALL 302 void gtk_window_set_icon (GtkWindow *window, 303 GdkPixbuf *icon); 304 GDK_AVAILABLE_IN_ALL 305 void gtk_window_set_icon_name (GtkWindow *window, 306 const gchar *name); 307 GDK_AVAILABLE_IN_ALL 308 gboolean gtk_window_set_icon_from_file (GtkWindow *window, 309 const gchar *filename, 310 GError **err); 311 GDK_AVAILABLE_IN_ALL 312 GdkPixbuf* gtk_window_get_icon (GtkWindow *window); 313 GDK_AVAILABLE_IN_ALL 314 const gchar * gtk_window_get_icon_name (GtkWindow *window); 315 GDK_AVAILABLE_IN_ALL 316 void gtk_window_set_default_icon_list (GList *list); 317 GDK_AVAILABLE_IN_ALL 318 GList* gtk_window_get_default_icon_list (void); 319 GDK_AVAILABLE_IN_ALL 320 void gtk_window_set_default_icon (GdkPixbuf *icon); 321 GDK_AVAILABLE_IN_ALL 322 void gtk_window_set_default_icon_name (const gchar *name); 323 GDK_AVAILABLE_IN_ALL 324 const gchar * gtk_window_get_default_icon_name (void); 325 GDK_AVAILABLE_IN_ALL 326 gboolean gtk_window_set_default_icon_from_file (const gchar *filename, 327 GError **err); 328 329 GDK_AVAILABLE_IN_ALL 330 void gtk_window_set_auto_startup_notification (gboolean setting); 331 332 /* If window is set modal, input will be grabbed when show and released when hide */ 333 GDK_AVAILABLE_IN_ALL 334 void gtk_window_set_modal (GtkWindow *window, 335 gboolean modal); 336 GDK_AVAILABLE_IN_ALL 337 gboolean gtk_window_get_modal (GtkWindow *window); 338 GDK_AVAILABLE_IN_ALL 339 GList* gtk_window_list_toplevels (void); 340 GDK_AVAILABLE_IN_ALL 341 void gtk_window_set_has_user_ref_count (GtkWindow *window, 342 gboolean setting); 343 344 GDK_AVAILABLE_IN_ALL 345 void gtk_window_add_mnemonic (GtkWindow *window, 346 guint keyval, 347 GtkWidget *target); 348 GDK_AVAILABLE_IN_ALL 349 void gtk_window_remove_mnemonic (GtkWindow *window, 350 guint keyval, 351 GtkWidget *target); 352 GDK_AVAILABLE_IN_ALL 353 gboolean gtk_window_mnemonic_activate (GtkWindow *window, 354 guint keyval, 355 GdkModifierType modifier); 356 GDK_AVAILABLE_IN_ALL 357 void gtk_window_set_mnemonic_modifier (GtkWindow *window, 358 GdkModifierType modifier); 359 GDK_AVAILABLE_IN_ALL 360 GdkModifierType gtk_window_get_mnemonic_modifier (GtkWindow *window); 361 362 GDK_AVAILABLE_IN_ALL 363 gboolean gtk_window_activate_key (GtkWindow *window, 364 GdkEventKey *event); 365 GDK_AVAILABLE_IN_ALL 366 gboolean gtk_window_propagate_key_event (GtkWindow *window, 367 GdkEventKey *event); 368 369 GDK_AVAILABLE_IN_ALL 370 void gtk_window_present (GtkWindow *window); 371 GDK_AVAILABLE_IN_ALL 372 void gtk_window_present_with_time (GtkWindow *window, 373 guint32 timestamp); 374 GDK_AVAILABLE_IN_ALL 375 void gtk_window_iconify (GtkWindow *window); 376 GDK_AVAILABLE_IN_ALL 377 void gtk_window_deiconify (GtkWindow *window); 378 GDK_AVAILABLE_IN_ALL 379 void gtk_window_stick (GtkWindow *window); 380 GDK_AVAILABLE_IN_ALL 381 void gtk_window_unstick (GtkWindow *window); 382 GDK_AVAILABLE_IN_ALL 383 void gtk_window_maximize (GtkWindow *window); 384 GDK_AVAILABLE_IN_ALL 385 void gtk_window_unmaximize (GtkWindow *window); 386 GDK_AVAILABLE_IN_ALL 387 void gtk_window_fullscreen (GtkWindow *window); 388 GDK_AVAILABLE_IN_ALL 389 void gtk_window_unfullscreen (GtkWindow *window); 390 GDK_AVAILABLE_IN_3_18 391 void gtk_window_fullscreen_on_monitor(GtkWindow *window, 392 GdkScreen *screen, 393 gint monitor); 394 GDK_AVAILABLE_IN_3_10 395 void gtk_window_close (GtkWindow *window); 396 GDK_AVAILABLE_IN_ALL 397 void gtk_window_set_keep_above (GtkWindow *window, gboolean setting); 398 GDK_AVAILABLE_IN_ALL 399 void gtk_window_set_keep_below (GtkWindow *window, gboolean setting); 400 401 GDK_AVAILABLE_IN_ALL 402 void gtk_window_begin_resize_drag (GtkWindow *window, 403 GdkWindowEdge edge, 404 gint button, 405 gint root_x, 406 gint root_y, 407 guint32 timestamp); 408 GDK_AVAILABLE_IN_ALL 409 void gtk_window_begin_move_drag (GtkWindow *window, 410 gint button, 411 gint root_x, 412 gint root_y, 413 guint32 timestamp); 414 415 /* Set initial default size of the window (does not constrain user 416 * resize operations) 417 */ 418 GDK_AVAILABLE_IN_ALL 419 void gtk_window_set_default_size (GtkWindow *window, 420 gint width, 421 gint height); 422 GDK_AVAILABLE_IN_ALL 423 void gtk_window_get_default_size (GtkWindow *window, 424 gint *width, 425 gint *height); 426 GDK_AVAILABLE_IN_ALL 427 void gtk_window_resize (GtkWindow *window, 428 gint width, 429 gint height); 430 GDK_AVAILABLE_IN_ALL 431 void gtk_window_get_size (GtkWindow *window, 432 gint *width, 433 gint *height); 434 GDK_AVAILABLE_IN_ALL 435 void gtk_window_move (GtkWindow *window, 436 gint x, 437 gint y); 438 GDK_AVAILABLE_IN_ALL 439 void gtk_window_get_position (GtkWindow *window, 440 gint *root_x, 441 gint *root_y); 442 GDK_DEPRECATED_IN_3_20 443 gboolean gtk_window_parse_geometry (GtkWindow *window, 444 const gchar *geometry); 445 446 GDK_DEPRECATED_IN_3_20_FOR(gtk_window_set_default_size) 447 void gtk_window_set_default_geometry (GtkWindow *window, 448 gint width, 449 gint height); 450 GDK_DEPRECATED_IN_3_20_FOR(gtk_window_resize) 451 void gtk_window_resize_to_geometry (GtkWindow *window, 452 gint width, 453 gint height); 454 455 GDK_AVAILABLE_IN_ALL 456 GtkWindowGroup *gtk_window_get_group (GtkWindow *window); 457 GDK_AVAILABLE_IN_ALL 458 gboolean gtk_window_has_group (GtkWindow *window); 459 460 /* Ignore this unless you are writing a GUI builder */ 461 GDK_DEPRECATED_IN_3_10 462 void gtk_window_reshow_with_initial_size (GtkWindow *window); 463 464 GDK_AVAILABLE_IN_ALL 465 GtkWindowType gtk_window_get_window_type (GtkWindow *window); 466 467 468 GDK_AVAILABLE_IN_ALL 469 GtkApplication *gtk_window_get_application (GtkWindow *window); 470 GDK_AVAILABLE_IN_ALL 471 void gtk_window_set_application (GtkWindow *window, 472 GtkApplication *application); 473 474 475 /* Window grips 476 */ 477 GDK_DEPRECATED_IN_3_14 478 void gtk_window_set_has_resize_grip (GtkWindow *window, 479 gboolean value); 480 GDK_DEPRECATED_IN_3_14 481 gboolean gtk_window_get_has_resize_grip (GtkWindow *window); 482 GDK_DEPRECATED_IN_3_14 483 gboolean gtk_window_resize_grip_is_visible (GtkWindow *window); 484 GDK_DEPRECATED_IN_3_14 485 gboolean gtk_window_get_resize_grip_area (GtkWindow *window, 486 GdkRectangle *rect); 487 488 GDK_AVAILABLE_IN_3_10 489 void gtk_window_set_titlebar (GtkWindow *window, 490 GtkWidget *titlebar); 491 GDK_AVAILABLE_IN_3_16 492 GtkWidget *gtk_window_get_titlebar (GtkWindow *window); 493 494 GDK_AVAILABLE_IN_3_12 495 gboolean gtk_window_is_maximized (GtkWindow *window); 496 497 GDK_AVAILABLE_IN_3_14 498 void gtk_window_set_interactive_debugging (gboolean enable); 499 500 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkWindow, g_object_unref) 501 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkWindowGroup, g_object_unref) 502 503 G_END_DECLS 504 505 #endif /* __GTK_WINDOW_H__ */ 506