1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.Window; 26 27 private import gdk.Screen; 28 private import gdkpixbuf.Pixbuf; 29 private import glib.ConstructionException; 30 private import glib.ErrorG; 31 private import glib.GException; 32 private import glib.ListG; 33 private import glib.Str; 34 private import gobject.ObjectG; 35 private import gobject.Signals; 36 private import gtk.AccelGroup; 37 private import gtk.Application; 38 private import gtk.Bin; 39 private import gtk.Widget; 40 private import gtk.WindowGroup; 41 private import gtk.c.functions; 42 public import gtk.c.types; 43 public import gtkc.gtktypes; 44 private import std.algorithm; 45 46 47 /** 48 * A GtkWindow is a toplevel window which can contain other widgets. 49 * Windows normally have decorations that are under the control 50 * of the windowing system and allow the user to manipulate the window 51 * (resize it, move it, close it,...). 52 * 53 * # GtkWindow as GtkBuildable 54 * 55 * The GtkWindow implementation of the GtkBuildable interface supports a 56 * custom <accel-groups> element, which supports any number of <group> 57 * elements representing the #GtkAccelGroup objects you want to add to 58 * your window (synonymous with gtk_window_add_accel_group(). 59 * 60 * It also supports the <initial-focus> element, whose name property names 61 * the widget to receive the focus when the window is mapped. 62 * 63 * An example of a UI definition fragment with accel groups: 64 * |[ 65 * <object class="GtkWindow"> 66 * <accel-groups> 67 * <group name="accelgroup1"/> 68 * </accel-groups> 69 * <initial-focus name="thunderclap"/> 70 * </object> 71 * 72 * ... 73 * 74 * <object class="GtkAccelGroup" id="accelgroup1"/> 75 * ]| 76 * 77 * The GtkWindow implementation of the GtkBuildable interface supports 78 * setting a child as the titlebar by specifying “titlebar” as the “type” 79 * attribute of a <child> element. 80 * 81 * # CSS nodes 82 * 83 * |[<!-- language="plain" --> 84 * window.background 85 * ├── decoration 86 * ├── <titlebar child>.titlebar [.default-decoration] 87 * ╰── <child> 88 * ]| 89 * 90 * GtkWindow has a main CSS node with name window and style class .background, 91 * and a subnode with name decoration. 92 * 93 * Style classes that are typically used with the main CSS node are .csd (when 94 * client-side decorations are in use), .solid-csd (for client-side decorations 95 * without invisible borders), .ssd (used by mutter when rendering server-side 96 * decorations). GtkWindow also represents window states with the following 97 * style classes on the main node: .tiled, .maximized, .fullscreen. Specialized 98 * types of window often add their own discriminating style classes, such as 99 * .popup or .tooltip. 100 * 101 * GtkWindow adds the .titlebar and .default-decoration style classes to the 102 * widget that is added as a titlebar child. 103 */ 104 public class Window : Bin 105 { 106 /** the main Gtk struct */ 107 protected GtkWindow* gtkWindow; 108 109 /** Get the main Gtk struct */ 110 public GtkWindow* getWindowStruct(bool transferOwnership = false) 111 { 112 if (transferOwnership) 113 ownedRef = false; 114 return gtkWindow; 115 } 116 117 /** the main Gtk struct as a void* */ 118 protected override void* getStruct() 119 { 120 return cast(void*)gtkWindow; 121 } 122 123 /** 124 * Sets our main struct and passes it to the parent class. 125 */ 126 public this (GtkWindow* gtkWindow, bool ownedRef = false) 127 { 128 this.gtkWindow = gtkWindow; 129 super(cast(GtkBin*)gtkWindow, ownedRef); 130 } 131 132 /** 133 * Creates a top level window with a title 134 * Params: 135 * title = The Window title 136 */ 137 public this(string title) 138 { 139 this(GtkWindowType.TOPLEVEL); 140 setTitle(title); 141 } 142 143 /** 144 * Move the window to an absolute position. 145 * just calls move(int, int). 146 * convinience because GdkEvent structs return the position coords as doubles 147 */ 148 public void move(double x, double y) 149 { 150 move(cast(int)x, cast(int)y); 151 } 152 153 /** 154 */ 155 156 /** */ 157 public static GType getType() 158 { 159 return gtk_window_get_type(); 160 } 161 162 /** 163 * Creates a new #GtkWindow, which is a toplevel window that can 164 * contain other widgets. Nearly always, the type of the window should 165 * be #GTK_WINDOW_TOPLEVEL. If you’re implementing something like a 166 * popup menu from scratch (which is a bad idea, just use #GtkMenu), 167 * you might use #GTK_WINDOW_POPUP. #GTK_WINDOW_POPUP is not for 168 * dialogs, though in some other toolkits dialogs are called “popups”. 169 * In GTK+, #GTK_WINDOW_POPUP means a pop-up menu or pop-up tooltip. 170 * On X11, popup windows are not controlled by the 171 * [window manager][gtk-X11-arch]. 172 * 173 * If you simply want an undecorated window (no window borders), use 174 * gtk_window_set_decorated(), don’t use #GTK_WINDOW_POPUP. 175 * 176 * All top-level windows created by gtk_window_new() are stored in 177 * an internal top-level window list. This list can be obtained from 178 * gtk_window_list_toplevels(). Due to Gtk+ keeping a reference to 179 * the window internally, gtk_window_new() does not return a reference 180 * to the caller. 181 * 182 * To delete a #GtkWindow, call gtk_widget_destroy(). 183 * 184 * Params: 185 * type = type of window 186 * 187 * Returns: a new #GtkWindow. 188 * 189 * Throws: ConstructionException GTK+ fails to create the object. 190 */ 191 public this(GtkWindowType type) 192 { 193 auto p = gtk_window_new(type); 194 195 if(p is null) 196 { 197 throw new ConstructionException("null returned by new"); 198 } 199 200 this(cast(GtkWindow*) p); 201 } 202 203 /** 204 * Gets the value set by gtk_window_set_default_icon_list(). 205 * The list is a copy and should be freed with g_list_free(), 206 * but the pixbufs in the list have not had their reference count 207 * incremented. 208 * 209 * Returns: copy of default icon list 210 */ 211 public static ListG getDefaultIconList() 212 { 213 auto p = gtk_window_get_default_icon_list(); 214 215 if(p is null) 216 { 217 return null; 218 } 219 220 return new ListG(cast(GList*) p); 221 } 222 223 /** 224 * Returns the fallback icon name for windows that has been set 225 * with gtk_window_set_default_icon_name(). The returned 226 * string is owned by GTK+ and should not be modified. It 227 * is only valid until the next call to 228 * gtk_window_set_default_icon_name(). 229 * 230 * Returns: the fallback icon name for windows 231 * 232 * Since: 2.16 233 */ 234 public static string getDefaultIconName() 235 { 236 return Str.toString(gtk_window_get_default_icon_name()); 237 } 238 239 /** 240 * Returns a list of all existing toplevel windows. The widgets 241 * in the list are not individually referenced. If you want 242 * to iterate through the list and perform actions involving 243 * callbacks that might destroy the widgets, you must call 244 * `g_list_foreach (result, (GFunc)g_object_ref, NULL)` first, and 245 * then unref all the widgets afterwards. 246 * 247 * Returns: list of toplevel widgets 248 */ 249 public static ListG listToplevels() 250 { 251 auto p = gtk_window_list_toplevels(); 252 253 if(p is null) 254 { 255 return null; 256 } 257 258 return new ListG(cast(GList*) p); 259 } 260 261 /** 262 * By default, after showing the first #GtkWindow, GTK+ calls 263 * gdk_notify_startup_complete(). Call this function to disable 264 * the automatic startup notification. You might do this if your 265 * first window is a splash screen, and you want to delay notification 266 * until after your real main window has been shown, for example. 267 * 268 * In that example, you would disable startup notification 269 * temporarily, show your splash screen, then re-enable it so that 270 * showing the main window would automatically result in notification. 271 * 272 * Params: 273 * setting = %TRUE to automatically do startup notification 274 * 275 * Since: 2.2 276 */ 277 public static void setAutoStartupNotification(bool setting) 278 { 279 gtk_window_set_auto_startup_notification(setting); 280 } 281 282 /** 283 * Sets an icon to be used as fallback for windows that haven't 284 * had gtk_window_set_icon() called on them from a pixbuf. 285 * 286 * Params: 287 * icon = the icon 288 * 289 * Since: 2.4 290 */ 291 public static void setDefaultIcon(Pixbuf icon) 292 { 293 gtk_window_set_default_icon((icon is null) ? null : icon.getPixbufStruct()); 294 } 295 296 /** 297 * Sets an icon to be used as fallback for windows that haven't 298 * had gtk_window_set_icon_list() called on them from a file 299 * on disk. Warns on failure if @err is %NULL. 300 * 301 * Params: 302 * filename = location of icon file 303 * 304 * Returns: %TRUE if setting the icon succeeded. 305 * 306 * Since: 2.2 307 * 308 * Throws: GException on failure. 309 */ 310 public static bool setDefaultIconFromFile(string filename) 311 { 312 GError* err = null; 313 314 auto p = gtk_window_set_default_icon_from_file(Str.toStringz(filename), &err) != 0; 315 316 if (err !is null) 317 { 318 throw new GException( new ErrorG(err) ); 319 } 320 321 return p; 322 } 323 324 /** 325 * Sets an icon list to be used as fallback for windows that haven't 326 * had gtk_window_set_icon_list() called on them to set up a 327 * window-specific icon list. This function allows you to set up the 328 * icon for all windows in your app at once. 329 * 330 * See gtk_window_set_icon_list() for more details. 331 * 332 * Params: 333 * list = a list of #GdkPixbuf 334 */ 335 public static void setDefaultIconList(ListG list) 336 { 337 gtk_window_set_default_icon_list((list is null) ? null : list.getListGStruct()); 338 } 339 340 /** 341 * Sets an icon to be used as fallback for windows that haven't 342 * had gtk_window_set_icon_list() called on them from a named 343 * themed icon, see gtk_window_set_icon_name(). 344 * 345 * Params: 346 * name = the name of the themed icon 347 * 348 * Since: 2.6 349 */ 350 public static void setDefaultIconName(string name) 351 { 352 gtk_window_set_default_icon_name(Str.toStringz(name)); 353 } 354 355 /** 356 * Opens or closes the [interactive debugger][interactive-debugging], 357 * which offers access to the widget hierarchy of the application 358 * and to useful debugging tools. 359 * 360 * Params: 361 * enable = %TRUE to enable interactive debugging 362 * 363 * Since: 3.14 364 */ 365 public static void setInteractiveDebugging(bool enable) 366 { 367 gtk_window_set_interactive_debugging(enable); 368 } 369 370 /** 371 * Activates the default widget for the window, unless the current 372 * focused widget has been configured to receive the default action 373 * (see gtk_widget_set_receives_default()), in which case the 374 * focused widget is activated. 375 * 376 * Returns: %TRUE if a widget got activated. 377 */ 378 public bool activateDefault() 379 { 380 return gtk_window_activate_default(gtkWindow) != 0; 381 } 382 383 /** 384 * Activates the current focused widget within the window. 385 * 386 * Returns: %TRUE if a widget got activated. 387 */ 388 public bool activateFocus() 389 { 390 return gtk_window_activate_focus(gtkWindow) != 0; 391 } 392 393 /** 394 * Activates mnemonics and accelerators for this #GtkWindow. This is normally 395 * called by the default ::key_press_event handler for toplevel windows, 396 * however in some cases it may be useful to call this directly when 397 * overriding the standard key handling for a toplevel window. 398 * 399 * Params: 400 * event = a #GdkEventKey 401 * 402 * Returns: %TRUE if a mnemonic or accelerator was found and activated. 403 * 404 * Since: 2.4 405 */ 406 public bool activateKey(GdkEventKey* event) 407 { 408 return gtk_window_activate_key(gtkWindow, event) != 0; 409 } 410 411 /** 412 * Associate @accel_group with @window, such that calling 413 * gtk_accel_groups_activate() on @window will activate accelerators 414 * in @accel_group. 415 * 416 * Params: 417 * accelGroup = a #GtkAccelGroup 418 */ 419 public void addAccelGroup(AccelGroup accelGroup) 420 { 421 gtk_window_add_accel_group(gtkWindow, (accelGroup is null) ? null : accelGroup.getAccelGroupStruct()); 422 } 423 424 /** 425 * Adds a mnemonic to this window. 426 * 427 * Params: 428 * keyval = the mnemonic 429 * target = the widget that gets activated by the mnemonic 430 */ 431 public void addMnemonic(uint keyval, Widget target) 432 { 433 gtk_window_add_mnemonic(gtkWindow, keyval, (target is null) ? null : target.getWidgetStruct()); 434 } 435 436 /** 437 * Starts moving a window. This function is used if an application has 438 * window movement grips. When GDK can support it, the window movement 439 * will be done using the standard mechanism for the 440 * [window manager][gtk-X11-arch] or windowing 441 * system. Otherwise, GDK will try to emulate window movement, 442 * potentially not all that well, depending on the windowing system. 443 * 444 * Params: 445 * button = mouse button that initiated the drag 446 * rootX = X position where the user clicked to initiate the drag, in root window coordinates 447 * rootY = Y position where the user clicked to initiate the drag 448 * timestamp = timestamp from the click event that initiated the drag 449 */ 450 public void beginMoveDrag(int button, int rootX, int rootY, uint timestamp) 451 { 452 gtk_window_begin_move_drag(gtkWindow, button, rootX, rootY, timestamp); 453 } 454 455 /** 456 * Starts resizing a window. This function is used if an application 457 * has window resizing controls. When GDK can support it, the resize 458 * will be done using the standard mechanism for the 459 * [window manager][gtk-X11-arch] or windowing 460 * system. Otherwise, GDK will try to emulate window resizing, 461 * potentially not all that well, depending on the windowing system. 462 * 463 * Params: 464 * edge = position of the resize control 465 * button = mouse button that initiated the drag 466 * rootX = X position where the user clicked to initiate the drag, in root window coordinates 467 * rootY = Y position where the user clicked to initiate the drag 468 * timestamp = timestamp from the click event that initiated the drag 469 */ 470 public void beginResizeDrag(GdkWindowEdge edge, int button, int rootX, int rootY, uint timestamp) 471 { 472 gtk_window_begin_resize_drag(gtkWindow, edge, button, rootX, rootY, timestamp); 473 } 474 475 /** 476 * Requests that the window is closed, similar to what happens 477 * when a window manager close button is clicked. 478 * 479 * This function can be used with close buttons in custom 480 * titlebars. 481 * 482 * Since: 3.10 483 */ 484 public void close() 485 { 486 gtk_window_close(gtkWindow); 487 } 488 489 /** 490 * Asks to deiconify (i.e. unminimize) the specified @window. Note 491 * that you shouldn’t assume the window is definitely deiconified 492 * afterward, because other entities (e.g. the user or 493 * [window manager][gtk-X11-arch])) could iconify it 494 * again before your code which assumes deiconification gets to run. 495 * 496 * You can track iconification via the “window-state-event” signal 497 * on #GtkWidget. 498 */ 499 public void deiconify() 500 { 501 gtk_window_deiconify(gtkWindow); 502 } 503 504 /** 505 * Asks to place @window in the fullscreen state. Note that you 506 * shouldn’t assume the window is definitely full screen afterward, 507 * because other entities (e.g. the user or 508 * [window manager][gtk-X11-arch]) could unfullscreen it 509 * again, and not all window managers honor requests to fullscreen 510 * windows. But normally the window will end up fullscreen. Just 511 * don’t write code that crashes if not. 512 * 513 * You can track the fullscreen state via the “window-state-event” signal 514 * on #GtkWidget. 515 * 516 * Since: 2.2 517 */ 518 public void fullscreen() 519 { 520 gtk_window_fullscreen(gtkWindow); 521 } 522 523 /** 524 * Asks to place @window in the fullscreen state. Note that you shouldn't assume 525 * the window is definitely full screen afterward. 526 * 527 * You can track the fullscreen state via the "window-state-event" signal 528 * on #GtkWidget. 529 * 530 * Params: 531 * screen = a #GdkScreen to draw to 532 * monitor = which monitor to go fullscreen on 533 * 534 * Since: 3.18 535 */ 536 public void fullscreenOnMonitor(Screen screen, int monitor) 537 { 538 gtk_window_fullscreen_on_monitor(gtkWindow, (screen is null) ? null : screen.getScreenStruct(), monitor); 539 } 540 541 /** 542 * Gets the value set by gtk_window_set_accept_focus(). 543 * 544 * Returns: %TRUE if window should receive the input focus 545 * 546 * Since: 2.4 547 */ 548 public bool getAcceptFocus() 549 { 550 return gtk_window_get_accept_focus(gtkWindow) != 0; 551 } 552 553 /** 554 * Gets the #GtkApplication associated with the window (if any). 555 * 556 * Returns: a #GtkApplication, or %NULL 557 * 558 * Since: 3.0 559 */ 560 public Application getApplication() 561 { 562 auto p = gtk_window_get_application(gtkWindow); 563 564 if(p is null) 565 { 566 return null; 567 } 568 569 return ObjectG.getDObject!(Application)(cast(GtkApplication*) p); 570 } 571 572 /** 573 * Fetches the attach widget for this window. See 574 * gtk_window_set_attached_to(). 575 * 576 * Returns: the widget where the window 577 * is attached, or %NULL if the window is not attached to any widget. 578 * 579 * Since: 3.4 580 */ 581 public Widget getAttachedTo() 582 { 583 auto p = gtk_window_get_attached_to(gtkWindow); 584 585 if(p is null) 586 { 587 return null; 588 } 589 590 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 591 } 592 593 /** 594 * Returns whether the window has been set to have decorations 595 * such as a title bar via gtk_window_set_decorated(). 596 * 597 * Returns: %TRUE if the window has been set to have decorations 598 */ 599 public bool getDecorated() 600 { 601 return gtk_window_get_decorated(gtkWindow) != 0; 602 } 603 604 /** 605 * Gets the default size of the window. A value of -1 for the width or 606 * height indicates that a default size has not been explicitly set 607 * for that dimension, so the “natural” size of the window will be 608 * used. 609 * 610 * Params: 611 * width = location to store the default width, or %NULL 612 * height = location to store the default height, or %NULL 613 */ 614 public void getDefaultSize(out int width, out int height) 615 { 616 gtk_window_get_default_size(gtkWindow, &width, &height); 617 } 618 619 /** 620 * Returns the default widget for @window. See 621 * gtk_window_set_default() for more details. 622 * 623 * Returns: the default widget, or %NULL 624 * if there is none. 625 * 626 * Since: 2.14 627 */ 628 public Widget getDefaultWidget() 629 { 630 auto p = gtk_window_get_default_widget(gtkWindow); 631 632 if(p is null) 633 { 634 return null; 635 } 636 637 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 638 } 639 640 /** 641 * Returns whether the window has been set to have a close button 642 * via gtk_window_set_deletable(). 643 * 644 * Returns: %TRUE if the window has been set to have a close button 645 * 646 * Since: 2.10 647 */ 648 public bool getDeletable() 649 { 650 return gtk_window_get_deletable(gtkWindow) != 0; 651 } 652 653 /** 654 * Returns whether the window will be destroyed with its transient parent. See 655 * gtk_window_set_destroy_with_parent (). 656 * 657 * Returns: %TRUE if the window will be destroyed with its transient parent. 658 */ 659 public bool getDestroyWithParent() 660 { 661 return gtk_window_get_destroy_with_parent(gtkWindow) != 0; 662 } 663 664 /** 665 * Retrieves the current focused widget within the window. 666 * Note that this is the widget that would have the focus 667 * if the toplevel window focused; if the toplevel window 668 * is not focused then `gtk_widget_has_focus (widget)` will 669 * not be %TRUE for the widget. 670 * 671 * Returns: the currently focused widget, 672 * or %NULL if there is none. 673 */ 674 public Widget getFocus() 675 { 676 auto p = gtk_window_get_focus(gtkWindow); 677 678 if(p is null) 679 { 680 return null; 681 } 682 683 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 684 } 685 686 /** 687 * Gets the value set by gtk_window_set_focus_on_map(). 688 * 689 * Returns: %TRUE if window should receive the input focus when 690 * mapped. 691 * 692 * Since: 2.6 693 */ 694 public bool getFocusOnMap() 695 { 696 return gtk_window_get_focus_on_map(gtkWindow) != 0; 697 } 698 699 /** 700 * Gets the value of the #GtkWindow:focus-visible property. 701 * 702 * Returns: %TRUE if “focus rectangles” are supposed to be visible 703 * in this window. 704 * 705 * Since: 3.2 706 */ 707 public bool getFocusVisible() 708 { 709 return gtk_window_get_focus_visible(gtkWindow) != 0; 710 } 711 712 /** 713 * Gets the value set by gtk_window_set_gravity(). 714 * 715 * Returns: window gravity 716 */ 717 public GdkGravity getGravity() 718 { 719 return gtk_window_get_gravity(gtkWindow); 720 } 721 722 /** 723 * Returns the group for @window or the default group, if 724 * @window is %NULL or if @window does not have an explicit 725 * window group. 726 * 727 * Returns: the #GtkWindowGroup for a window or the default group 728 * 729 * Since: 2.10 730 */ 731 public WindowGroup getGroup() 732 { 733 auto p = gtk_window_get_group(gtkWindow); 734 735 if(p is null) 736 { 737 return null; 738 } 739 740 return ObjectG.getDObject!(WindowGroup)(cast(GtkWindowGroup*) p); 741 } 742 743 /** 744 * Determines whether the window may have a resize grip. 745 * 746 * Deprecated: Resize grips have been removed. 747 * 748 * Returns: %TRUE if the window has a resize grip 749 * 750 * Since: 3.0 751 */ 752 public bool getHasResizeGrip() 753 { 754 return gtk_window_get_has_resize_grip(gtkWindow) != 0; 755 } 756 757 /** 758 * Returns whether the window has requested to have its titlebar hidden 759 * when maximized. See gtk_window_set_hide_titlebar_when_maximized (). 760 * 761 * Returns: %TRUE if the window has requested to have its titlebar 762 * hidden when maximized 763 * 764 * Since: 3.4 765 */ 766 public bool getHideTitlebarWhenMaximized() 767 { 768 return gtk_window_get_hide_titlebar_when_maximized(gtkWindow) != 0; 769 } 770 771 /** 772 * Gets the value set by gtk_window_set_icon() (or if you've 773 * called gtk_window_set_icon_list(), gets the first icon in 774 * the icon list). 775 * 776 * Returns: icon for window 777 */ 778 public Pixbuf getIcon() 779 { 780 auto p = gtk_window_get_icon(gtkWindow); 781 782 if(p is null) 783 { 784 return null; 785 } 786 787 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 788 } 789 790 /** 791 * Retrieves the list of icons set by gtk_window_set_icon_list(). 792 * The list is copied, but the reference count on each 793 * member won’t be incremented. 794 * 795 * Returns: copy of window’s icon list 796 */ 797 public ListG getIconList() 798 { 799 auto p = gtk_window_get_icon_list(gtkWindow); 800 801 if(p is null) 802 { 803 return null; 804 } 805 806 return new ListG(cast(GList*) p); 807 } 808 809 /** 810 * Returns the name of the themed icon for the window, 811 * see gtk_window_set_icon_name(). 812 * 813 * Returns: the icon name or %NULL if the window has 814 * no themed icon 815 * 816 * Since: 2.6 817 */ 818 public string getIconName() 819 { 820 return Str.toString(gtk_window_get_icon_name(gtkWindow)); 821 } 822 823 /** 824 * Returns the mnemonic modifier for this window. See 825 * gtk_window_set_mnemonic_modifier(). 826 * 827 * Returns: the modifier mask used to activate 828 * mnemonics on this window. 829 */ 830 public GdkModifierType getMnemonicModifier() 831 { 832 return gtk_window_get_mnemonic_modifier(gtkWindow); 833 } 834 835 /** 836 * Gets the value of the #GtkWindow:mnemonics-visible property. 837 * 838 * Returns: %TRUE if mnemonics are supposed to be visible 839 * in this window. 840 * 841 * Since: 2.20 842 */ 843 public bool getMnemonicsVisible() 844 { 845 return gtk_window_get_mnemonics_visible(gtkWindow) != 0; 846 } 847 848 /** 849 * Returns whether the window is modal. See gtk_window_set_modal(). 850 * 851 * Returns: %TRUE if the window is set to be modal and 852 * establishes a grab when shown 853 */ 854 public bool getModal() 855 { 856 return gtk_window_get_modal(gtkWindow) != 0; 857 } 858 859 /** 860 * Fetches the requested opacity for this window. See 861 * gtk_window_set_opacity(). 862 * 863 * Deprecated: Use gtk_widget_get_opacity instead. 864 * 865 * Returns: the requested opacity for this window. 866 * 867 * Since: 2.12 868 */ 869 public override double getOpacity() 870 { 871 return gtk_window_get_opacity(gtkWindow); 872 } 873 874 /** 875 * This function returns the position you need to pass to 876 * gtk_window_move() to keep @window in its current position. 877 * This means that the meaning of the returned value varies with 878 * window gravity. See gtk_window_move() for more details. 879 * 880 * The reliability of this function depends on the windowing system 881 * currently in use. Some windowing systems, such as Wayland, do not 882 * support a global coordinate system, and thus the position of the 883 * window will always be (0, 0). Others, like X11, do not have a reliable 884 * way to obtain the geometry of the decorations of a window if they are 885 * provided by the window manager. Additionally, on X11, window manager 886 * have been known to mismanage window gravity, which result in windows 887 * moving even if you use the coordinates of the current position as 888 * returned by this function. 889 * 890 * If you haven’t changed the window gravity, its gravity will be 891 * #GDK_GRAVITY_NORTH_WEST. This means that gtk_window_get_position() 892 * gets the position of the top-left corner of the window manager 893 * frame for the window. gtk_window_move() sets the position of this 894 * same top-left corner. 895 * 896 * If a window has gravity #GDK_GRAVITY_STATIC the window manager 897 * frame is not relevant, and thus gtk_window_get_position() will 898 * always produce accurate results. However you can’t use static 899 * gravity to do things like place a window in a corner of the screen, 900 * because static gravity ignores the window manager decorations. 901 * 902 * Ideally, this function should return appropriate values if the 903 * window has client side decorations, assuming that the windowing 904 * system supports global coordinates. 905 * 906 * In practice, saving the window position should not be left to 907 * applications, as they lack enough knowledge of the windowing 908 * system and the window manager state to effectively do so. The 909 * appropriate way to implement saving the window position is to 910 * use a platform-specific protocol, wherever that is available. 911 * 912 * Params: 913 * rootX = return location for X coordinate of 914 * gravity-determined reference point, or %NULL 915 * rootY = return location for Y coordinate of 916 * gravity-determined reference point, or %NULL 917 */ 918 public void getPosition(out int rootX, out int rootY) 919 { 920 gtk_window_get_position(gtkWindow, &rootX, &rootY); 921 } 922 923 /** 924 * Gets the value set by gtk_window_set_resizable(). 925 * 926 * Returns: %TRUE if the user can resize the window 927 */ 928 public bool getResizable() 929 { 930 return gtk_window_get_resizable(gtkWindow) != 0; 931 } 932 933 /** 934 * If a window has a resize grip, this will retrieve the grip 935 * position, width and height into the specified #GdkRectangle. 936 * 937 * Deprecated: Resize grips have been removed. 938 * 939 * Params: 940 * rect = a pointer to a #GdkRectangle which we should store 941 * the resize grip area 942 * 943 * Returns: %TRUE if the resize grip’s area was retrieved 944 * 945 * Since: 3.0 946 */ 947 public bool getResizeGripArea(out GdkRectangle rect) 948 { 949 return gtk_window_get_resize_grip_area(gtkWindow, &rect) != 0; 950 } 951 952 /** 953 * Returns the role of the window. See gtk_window_set_role() for 954 * further explanation. 955 * 956 * Returns: the role of the window if set, or %NULL. The 957 * returned is owned by the widget and must not be modified or freed. 958 */ 959 public string getRole() 960 { 961 return Str.toString(gtk_window_get_role(gtkWindow)); 962 } 963 964 /** 965 * Returns the #GdkScreen associated with @window. 966 * 967 * Returns: a #GdkScreen. 968 * 969 * Since: 2.2 970 */ 971 public override Screen getScreen() 972 { 973 auto p = gtk_window_get_screen(gtkWindow); 974 975 if(p is null) 976 { 977 return null; 978 } 979 980 return ObjectG.getDObject!(Screen)(cast(GdkScreen*) p); 981 } 982 983 /** 984 * Obtains the current size of @window. 985 * 986 * If @window is not visible on screen, this function return the size GTK+ 987 * will suggest to the [window manager][gtk-X11-arch] for the initial window 988 * size (but this is not reliably the same as the size the window manager 989 * will actually select). See: gtk_window_set_default_size(). 990 * 991 * Depending on the windowing system and the window manager constraints, 992 * the size returned by this function may not match the size set using 993 * gtk_window_resize(); additionally, since gtk_window_resize() may be 994 * implemented as an asynchronous operation, GTK+ cannot guarantee in any 995 * way that this code: 996 * 997 * |[<!-- language="C" --> 998 * // width and height are set elsewhere 999 * gtk_window_resize (window, width, height); 1000 * 1001 * int new_width, new_height; 1002 * gtk_window_get_size (window, &new_width, &new_height); 1003 * ]| 1004 * 1005 * will result in `new_width` and `new_height` matching `width` and 1006 * `height`, respectively. 1007 * 1008 * This function will return the logical size of the #GtkWindow, 1009 * excluding the widgets used in client side decorations; there is, 1010 * however, no guarantee that the result will be completely accurate 1011 * because client side decoration may include widgets that depend on 1012 * the user preferences and that may not be visibile at the time you 1013 * call this function. 1014 * 1015 * The dimensions returned by this function are suitable for being 1016 * stored across sessions; use gtk_window_set_default_size() to 1017 * restore them when before showing the window. 1018 * 1019 * To avoid potential race conditions, you should only call this 1020 * function in response to a size change notification, for instance 1021 * inside a handler for the #GtkWidget::size-allocate signal, or 1022 * inside a handler for the #GtkWidget::configure-event signal: 1023 * 1024 * |[<!-- language="C" --> 1025 * static void 1026 * on_size_allocate (GtkWidget *widget, GtkAllocation *allocation) 1027 * { 1028 * int new_width, new_height; 1029 * 1030 * gtk_window_get_size (GTK_WINDOW (widget), &new_width, &new_height); 1031 * 1032 * ... 1033 * } 1034 * ]| 1035 * 1036 * Note that, if you connect to the #GtkWidget::size-allocate signal, 1037 * you should not use the dimensions of the #GtkAllocation passed to 1038 * the signal handler, as the allocation may contain client side 1039 * decorations added by GTK+, depending on the windowing system in 1040 * use. 1041 * 1042 * If you are getting a window size in order to position the window 1043 * on the screen, you should, instead, simply set the window’s semantic 1044 * type with gtk_window_set_type_hint(), which allows the window manager 1045 * to e.g. center dialogs. Also, if you set the transient parent of 1046 * dialogs with gtk_window_set_transient_for() window managers will 1047 * often center the dialog over its parent window. It's much preferred 1048 * to let the window manager handle these cases rather than doing it 1049 * yourself, because all apps will behave consistently and according to 1050 * user or system preferences, if the window manager handles it. Also, 1051 * the window manager can take into account the size of the window 1052 * decorations and border that it may add, and of which GTK+ has no 1053 * knowledge. Additionally, positioning windows in global screen coordinates 1054 * may not be allowed by the windowing system. For more information, 1055 * see: gtk_window_set_position(). 1056 * 1057 * Params: 1058 * width = return location for width, or %NULL 1059 * height = return location for height, or %NULL 1060 */ 1061 public void getSize(out int width, out int height) 1062 { 1063 gtk_window_get_size(gtkWindow, &width, &height); 1064 } 1065 1066 /** 1067 * Gets the value set by gtk_window_set_skip_pager_hint(). 1068 * 1069 * Returns: %TRUE if window shouldn’t be in pager 1070 * 1071 * Since: 2.2 1072 */ 1073 public bool getSkipPagerHint() 1074 { 1075 return gtk_window_get_skip_pager_hint(gtkWindow) != 0; 1076 } 1077 1078 /** 1079 * Gets the value set by gtk_window_set_skip_taskbar_hint() 1080 * 1081 * Returns: %TRUE if window shouldn’t be in taskbar 1082 * 1083 * Since: 2.2 1084 */ 1085 public bool getSkipTaskbarHint() 1086 { 1087 return gtk_window_get_skip_taskbar_hint(gtkWindow) != 0; 1088 } 1089 1090 /** 1091 * Retrieves the title of the window. See gtk_window_set_title(). 1092 * 1093 * Returns: the title of the window, or %NULL if none has 1094 * been set explicitly. The returned string is owned by the widget 1095 * and must not be modified or freed. 1096 */ 1097 public string getTitle() 1098 { 1099 return Str.toString(gtk_window_get_title(gtkWindow)); 1100 } 1101 1102 /** 1103 * Returns the custom titlebar that has been set with 1104 * gtk_window_set_titlebar(). 1105 * 1106 * Returns: the custom titlebar, or %NULL 1107 * 1108 * Since: 3.16 1109 */ 1110 public Widget getTitlebar() 1111 { 1112 auto p = gtk_window_get_titlebar(gtkWindow); 1113 1114 if(p is null) 1115 { 1116 return null; 1117 } 1118 1119 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 1120 } 1121 1122 /** 1123 * Fetches the transient parent for this window. See 1124 * gtk_window_set_transient_for(). 1125 * 1126 * Returns: the transient parent for this 1127 * window, or %NULL if no transient parent has been set. 1128 */ 1129 public Window getTransientFor() 1130 { 1131 auto p = gtk_window_get_transient_for(gtkWindow); 1132 1133 if(p is null) 1134 { 1135 return null; 1136 } 1137 1138 return ObjectG.getDObject!(Window)(cast(GtkWindow*) p); 1139 } 1140 1141 /** 1142 * Gets the type hint for this window. See gtk_window_set_type_hint(). 1143 * 1144 * Returns: the type hint for @window. 1145 */ 1146 public GdkWindowTypeHint getTypeHint() 1147 { 1148 return gtk_window_get_type_hint(gtkWindow); 1149 } 1150 1151 /** 1152 * Gets the value set by gtk_window_set_urgency_hint() 1153 * 1154 * Returns: %TRUE if window is urgent 1155 * 1156 * Since: 2.8 1157 */ 1158 public bool getUrgencyHint() 1159 { 1160 return gtk_window_get_urgency_hint(gtkWindow) != 0; 1161 } 1162 1163 /** 1164 * Gets the type of the window. See #GtkWindowType. 1165 * 1166 * Returns: the type of the window 1167 * 1168 * Since: 2.20 1169 */ 1170 public GtkWindowType getWindowType() 1171 { 1172 return gtk_window_get_window_type(gtkWindow); 1173 } 1174 1175 /** 1176 * Returns whether @window has an explicit window group. 1177 * 1178 * Returns: %TRUE if @window has an explicit window group. 1179 * 1180 * Since 2.22 1181 */ 1182 public bool hasGroup() 1183 { 1184 return gtk_window_has_group(gtkWindow) != 0; 1185 } 1186 1187 /** 1188 * Returns whether the input focus is within this GtkWindow. 1189 * For real toplevel windows, this is identical to gtk_window_is_active(), 1190 * but for embedded windows, like #GtkPlug, the results will differ. 1191 * 1192 * Returns: %TRUE if the input focus is within this GtkWindow 1193 * 1194 * Since: 2.4 1195 */ 1196 public bool hasToplevelFocus() 1197 { 1198 return gtk_window_has_toplevel_focus(gtkWindow) != 0; 1199 } 1200 1201 /** 1202 * Asks to iconify (i.e. minimize) the specified @window. Note that 1203 * you shouldn’t assume the window is definitely iconified afterward, 1204 * because other entities (e.g. the user or 1205 * [window manager][gtk-X11-arch]) could deiconify it 1206 * again, or there may not be a window manager in which case 1207 * iconification isn’t possible, etc. But normally the window will end 1208 * up iconified. Just don’t write code that crashes if not. 1209 * 1210 * It’s permitted to call this function before showing a window, 1211 * in which case the window will be iconified before it ever appears 1212 * onscreen. 1213 * 1214 * You can track iconification via the “window-state-event” signal 1215 * on #GtkWidget. 1216 */ 1217 public void iconify() 1218 { 1219 gtk_window_iconify(gtkWindow); 1220 } 1221 1222 /** 1223 * Returns whether the window is part of the current active toplevel. 1224 * (That is, the toplevel window receiving keystrokes.) 1225 * The return value is %TRUE if the window is active toplevel 1226 * itself, but also if it is, say, a #GtkPlug embedded in the active toplevel. 1227 * You might use this function if you wanted to draw a widget 1228 * differently in an active window from a widget in an inactive window. 1229 * See gtk_window_has_toplevel_focus() 1230 * 1231 * Returns: %TRUE if the window part of the current active window. 1232 * 1233 * Since: 2.4 1234 */ 1235 public bool isActive() 1236 { 1237 return gtk_window_is_active(gtkWindow) != 0; 1238 } 1239 1240 /** 1241 * Retrieves the current maximized state of @window. 1242 * 1243 * Note that since maximization is ultimately handled by the window 1244 * manager and happens asynchronously to an application request, you 1245 * shouldn’t assume the return value of this function changing 1246 * immediately (or at all), as an effect of calling 1247 * gtk_window_maximize() or gtk_window_unmaximize(). 1248 * 1249 * Returns: whether the window has a maximized state. 1250 * 1251 * Since: 3.12 1252 */ 1253 public bool isMaximized() 1254 { 1255 return gtk_window_is_maximized(gtkWindow) != 0; 1256 } 1257 1258 /** 1259 * Asks to maximize @window, so that it becomes full-screen. Note that 1260 * you shouldn’t assume the window is definitely maximized afterward, 1261 * because other entities (e.g. the user or 1262 * [window manager][gtk-X11-arch]) could unmaximize it 1263 * again, and not all window managers support maximization. But 1264 * normally the window will end up maximized. Just don’t write code 1265 * that crashes if not. 1266 * 1267 * It’s permitted to call this function before showing a window, 1268 * in which case the window will be maximized when it appears onscreen 1269 * initially. 1270 * 1271 * You can track maximization via the “window-state-event” signal 1272 * on #GtkWidget, or by listening to notifications on the 1273 * #GtkWindow:is-maximized property. 1274 */ 1275 public void maximize() 1276 { 1277 gtk_window_maximize(gtkWindow); 1278 } 1279 1280 /** 1281 * Activates the targets associated with the mnemonic. 1282 * 1283 * Params: 1284 * keyval = the mnemonic 1285 * modifier = the modifiers 1286 * 1287 * Returns: %TRUE if the activation is done. 1288 */ 1289 public bool mnemonicActivate(uint keyval, GdkModifierType modifier) 1290 { 1291 return gtk_window_mnemonic_activate(gtkWindow, keyval, modifier) != 0; 1292 } 1293 1294 /** 1295 * Asks the [window manager][gtk-X11-arch] to move 1296 * @window to the given position. Window managers are free to ignore 1297 * this; most window managers ignore requests for initial window 1298 * positions (instead using a user-defined placement algorithm) and 1299 * honor requests after the window has already been shown. 1300 * 1301 * Note: the position is the position of the gravity-determined 1302 * reference point for the window. The gravity determines two things: 1303 * first, the location of the reference point in root window 1304 * coordinates; and second, which point on the window is positioned at 1305 * the reference point. 1306 * 1307 * By default the gravity is #GDK_GRAVITY_NORTH_WEST, so the reference 1308 * point is simply the @x, @y supplied to gtk_window_move(). The 1309 * top-left corner of the window decorations (aka window frame or 1310 * border) will be placed at @x, @y. Therefore, to position a window 1311 * at the top left of the screen, you want to use the default gravity 1312 * (which is #GDK_GRAVITY_NORTH_WEST) and move the window to 0,0. 1313 * 1314 * To position a window at the bottom right corner of the screen, you 1315 * would set #GDK_GRAVITY_SOUTH_EAST, which means that the reference 1316 * point is at @x + the window width and @y + the window height, and 1317 * the bottom-right corner of the window border will be placed at that 1318 * reference point. So, to place a window in the bottom right corner 1319 * you would first set gravity to south east, then write: 1320 * `gtk_window_move (window, gdk_screen_width () - window_width, 1321 * gdk_screen_height () - window_height)` (note that this 1322 * example does not take multi-head scenarios into account). 1323 * 1324 * The [Extended Window Manager Hints Specification](http://www.freedesktop.org/Standards/wm-spec) 1325 * has a nice table of gravities in the “implementation notes” section. 1326 * 1327 * The gtk_window_get_position() documentation may also be relevant. 1328 * 1329 * Params: 1330 * x = X coordinate to move window to 1331 * y = Y coordinate to move window to 1332 */ 1333 public void move(int x, int y) 1334 { 1335 gtk_window_move(gtkWindow, x, y); 1336 } 1337 1338 /** 1339 * Parses a standard X Window System geometry string - see the 1340 * manual page for X (type “man X”) for details on this. 1341 * gtk_window_parse_geometry() does work on all GTK+ ports 1342 * including Win32 but is primarily intended for an X environment. 1343 * 1344 * If either a size or a position can be extracted from the 1345 * geometry string, gtk_window_parse_geometry() returns %TRUE 1346 * and calls gtk_window_set_default_size() and/or gtk_window_move() 1347 * to resize/move the window. 1348 * 1349 * If gtk_window_parse_geometry() returns %TRUE, it will also 1350 * set the #GDK_HINT_USER_POS and/or #GDK_HINT_USER_SIZE hints 1351 * indicating to the window manager that the size/position of 1352 * the window was user-specified. This causes most window 1353 * managers to honor the geometry. 1354 * 1355 * Note that for gtk_window_parse_geometry() to work as expected, it has 1356 * to be called when the window has its “final” size, i.e. after calling 1357 * gtk_widget_show_all() on the contents and gtk_window_set_geometry_hints() 1358 * on the window. 1359 * |[<!-- language="C" --> 1360 * #include <gtk/gtk.h> 1361 * 1362 * static void 1363 * fill_with_content (GtkWidget *vbox) 1364 * { 1365 * // fill with content... 1366 * } 1367 * 1368 * int 1369 * main (int argc, char *argv[]) 1370 * { 1371 * GtkWidget *window, *vbox; 1372 * GdkGeometry size_hints = { 1373 * 100, 50, 0, 0, 100, 50, 10, 1374 * 10, 0.0, 0.0, GDK_GRAVITY_NORTH_WEST 1375 * }; 1376 * 1377 * gtk_init (&argc, &argv); 1378 * 1379 * window = gtk_window_new (GTK_WINDOW_TOPLEVEL); 1380 * vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); 1381 * 1382 * gtk_container_add (GTK_CONTAINER (window), vbox); 1383 * fill_with_content (vbox); 1384 * gtk_widget_show_all (vbox); 1385 * 1386 * gtk_window_set_geometry_hints (GTK_WINDOW (window), 1387 * NULL, 1388 * &size_hints, 1389 * GDK_HINT_MIN_SIZE | 1390 * GDK_HINT_BASE_SIZE | 1391 * GDK_HINT_RESIZE_INC); 1392 * 1393 * if (argc > 1) 1394 * { 1395 * gboolean res; 1396 * res = gtk_window_parse_geometry (GTK_WINDOW (window), 1397 * argv[1]); 1398 * if (! res) 1399 * fprintf (stderr, 1400 * "Failed to parse “%s”\n", 1401 * argv[1]); 1402 * } 1403 * 1404 * gtk_widget_show_all (window); 1405 * gtk_main (); 1406 * 1407 * return 0; 1408 * } 1409 * ]| 1410 * 1411 * Deprecated: Geometry handling in GTK is deprecated. 1412 * 1413 * Params: 1414 * geometry = geometry string 1415 * 1416 * Returns: %TRUE if string was parsed successfully 1417 */ 1418 public bool parseGeometry(string geometry) 1419 { 1420 return gtk_window_parse_geometry(gtkWindow, Str.toStringz(geometry)) != 0; 1421 } 1422 1423 /** 1424 * Presents a window to the user. This may mean raising the window 1425 * in the stacking order, deiconifying it, moving it to the current 1426 * desktop, and/or giving it the keyboard focus, possibly dependent 1427 * on the user’s platform, window manager, and preferences. 1428 * 1429 * If @window is hidden, this function calls gtk_widget_show() 1430 * as well. 1431 * 1432 * This function should be used when the user tries to open a window 1433 * that’s already open. Say for example the preferences dialog is 1434 * currently open, and the user chooses Preferences from the menu 1435 * a second time; use gtk_window_present() to move the already-open dialog 1436 * where the user can see it. 1437 * 1438 * If you are calling this function in response to a user interaction, 1439 * it is preferable to use gtk_window_present_with_time(). 1440 */ 1441 public void present() 1442 { 1443 gtk_window_present(gtkWindow); 1444 } 1445 1446 /** 1447 * Presents a window to the user in response to a user interaction. 1448 * If you need to present a window without a timestamp, use 1449 * gtk_window_present(). See gtk_window_present() for details. 1450 * 1451 * Params: 1452 * timestamp = the timestamp of the user interaction (typically a 1453 * button or key press event) which triggered this call 1454 * 1455 * Since: 2.8 1456 */ 1457 public void presentWithTime(uint timestamp) 1458 { 1459 gtk_window_present_with_time(gtkWindow, timestamp); 1460 } 1461 1462 /** 1463 * Propagate a key press or release event to the focus widget and 1464 * up the focus container chain until a widget handles @event. 1465 * This is normally called by the default ::key_press_event and 1466 * ::key_release_event handlers for toplevel windows, 1467 * however in some cases it may be useful to call this directly when 1468 * overriding the standard key handling for a toplevel window. 1469 * 1470 * Params: 1471 * event = a #GdkEventKey 1472 * 1473 * Returns: %TRUE if a widget in the focus chain handled the event. 1474 * 1475 * Since: 2.4 1476 */ 1477 public bool propagateKeyEvent(GdkEventKey* event) 1478 { 1479 return gtk_window_propagate_key_event(gtkWindow, event) != 0; 1480 } 1481 1482 /** 1483 * Reverses the effects of gtk_window_add_accel_group(). 1484 * 1485 * Params: 1486 * accelGroup = a #GtkAccelGroup 1487 */ 1488 public void removeAccelGroup(AccelGroup accelGroup) 1489 { 1490 gtk_window_remove_accel_group(gtkWindow, (accelGroup is null) ? null : accelGroup.getAccelGroupStruct()); 1491 } 1492 1493 /** 1494 * Removes a mnemonic from this window. 1495 * 1496 * Params: 1497 * keyval = the mnemonic 1498 * target = the widget that gets activated by the mnemonic 1499 */ 1500 public void removeMnemonic(uint keyval, Widget target) 1501 { 1502 gtk_window_remove_mnemonic(gtkWindow, keyval, (target is null) ? null : target.getWidgetStruct()); 1503 } 1504 1505 /** 1506 * Hides @window, then reshows it, resetting the 1507 * default size and position of the window. Used 1508 * by GUI builders only. 1509 * 1510 * Deprecated: GUI builders can call gtk_widget_hide(), 1511 * gtk_widget_unrealize() and then gtk_widget_show() on @window 1512 * themselves, if they still need this functionality. 1513 */ 1514 public void reshowWithInitialSize() 1515 { 1516 gtk_window_reshow_with_initial_size(gtkWindow); 1517 } 1518 1519 /** 1520 * Resizes the window as if the user had done so, obeying geometry 1521 * constraints. The default geometry constraint is that windows may 1522 * not be smaller than their size request; to override this 1523 * constraint, call gtk_widget_set_size_request() to set the window's 1524 * request to a smaller value. 1525 * 1526 * If gtk_window_resize() is called before showing a window for the 1527 * first time, it overrides any default size set with 1528 * gtk_window_set_default_size(). 1529 * 1530 * Windows may not be resized smaller than 1 by 1 pixels. 1531 * 1532 * When using client side decorations, GTK+ will do its best to adjust 1533 * the given size so that the resulting window size matches the 1534 * requested size without the title bar, borders and shadows added for 1535 * the client side decorations, but there is no garantee that the 1536 * result will be totally accurate because these widgets added for 1537 * client side decorations depend on the theme and may not be realized 1538 * or visible at the time gtk_window_resize() is issued. 1539 * 1540 * Typically, gtk_window_resize() will compensate for the GtkHeaderBar 1541 * height only if it's known at the time the resulting GtkWindow 1542 * configuration is issued. 1543 * For example, if new widgets are added after the GtkWindow configuration 1544 * and cause the GtkHeaderBar to grow in height, this will result in a 1545 * window content smaller that specified by gtk_window_resize() and not 1546 * a larger window. 1547 * 1548 * Params: 1549 * width = width in pixels to resize the window to 1550 * height = height in pixels to resize the window to 1551 */ 1552 public void resize(int width, int height) 1553 { 1554 gtk_window_resize(gtkWindow, width, height); 1555 } 1556 1557 /** 1558 * Determines whether a resize grip is visible for the specified window. 1559 * 1560 * Deprecated: Resize grips have been removed. 1561 * 1562 * Returns: %TRUE if a resize grip exists and is visible 1563 * 1564 * Since: 3.0 1565 */ 1566 public bool resizeGripIsVisible() 1567 { 1568 return gtk_window_resize_grip_is_visible(gtkWindow) != 0; 1569 } 1570 1571 /** 1572 * Like gtk_window_resize(), but @width and @height are interpreted 1573 * in terms of the base size and increment set with 1574 * gtk_window_set_geometry_hints. 1575 * 1576 * Deprecated: This function does nothing. Use 1577 * gtk_window_resize() and compute the geometry yourself. 1578 * 1579 * Params: 1580 * width = width in resize increments to resize the window to 1581 * height = height in resize increments to resize the window to 1582 * 1583 * Since: 3.0 1584 */ 1585 public void resizeToGeometry(int width, int height) 1586 { 1587 gtk_window_resize_to_geometry(gtkWindow, width, height); 1588 } 1589 1590 /** 1591 * Windows may set a hint asking the desktop environment not to receive 1592 * the input focus. This function sets this hint. 1593 * 1594 * Params: 1595 * setting = %TRUE to let this window receive input focus 1596 * 1597 * Since: 2.4 1598 */ 1599 public void setAcceptFocus(bool setting) 1600 { 1601 gtk_window_set_accept_focus(gtkWindow, setting); 1602 } 1603 1604 /** 1605 * Sets or unsets the #GtkApplication associated with the window. 1606 * 1607 * The application will be kept alive for at least as long as it has any windows 1608 * associated with it (see g_application_hold() for a way to keep it alive 1609 * without windows). 1610 * 1611 * Normally, the connection between the application and the window will remain 1612 * until the window is destroyed, but you can explicitly remove it by setting 1613 * the @application to %NULL. 1614 * 1615 * This is equivalent to calling gtk_application_remove_window() and/or 1616 * gtk_application_add_window() on the old/new applications as relevant. 1617 * 1618 * Params: 1619 * application = a #GtkApplication, or %NULL to unset 1620 * 1621 * Since: 3.0 1622 */ 1623 public void setApplication(Application application) 1624 { 1625 gtk_window_set_application(gtkWindow, (application is null) ? null : application.getGtkApplicationStruct()); 1626 } 1627 1628 /** 1629 * Marks @window as attached to @attach_widget. This creates a logical binding 1630 * between the window and the widget it belongs to, which is used by GTK+ to 1631 * propagate information such as styling or accessibility to @window as if it 1632 * was a children of @attach_widget. 1633 * 1634 * Examples of places where specifying this relation is useful are for instance 1635 * a #GtkMenu created by a #GtkComboBox, a completion popup window 1636 * created by #GtkEntry or a typeahead search entry created by #GtkTreeView. 1637 * 1638 * Note that this function should not be confused with 1639 * gtk_window_set_transient_for(), which specifies a window manager relation 1640 * between two toplevels instead. 1641 * 1642 * Passing %NULL for @attach_widget detaches the window. 1643 * 1644 * Params: 1645 * attachWidget = a #GtkWidget, or %NULL 1646 * 1647 * Since: 3.4 1648 */ 1649 public void setAttachedTo(Widget attachWidget) 1650 { 1651 gtk_window_set_attached_to(gtkWindow, (attachWidget is null) ? null : attachWidget.getWidgetStruct()); 1652 } 1653 1654 /** 1655 * By default, windows are decorated with a title bar, resize 1656 * controls, etc. Some [window managers][gtk-X11-arch] 1657 * allow GTK+ to disable these decorations, creating a 1658 * borderless window. If you set the decorated property to %FALSE 1659 * using this function, GTK+ will do its best to convince the window 1660 * manager not to decorate the window. Depending on the system, this 1661 * function may not have any effect when called on a window that is 1662 * already visible, so you should call it before calling gtk_widget_show(). 1663 * 1664 * On Windows, this function always works, since there’s no window manager 1665 * policy involved. 1666 * 1667 * Params: 1668 * setting = %TRUE to decorate the window 1669 */ 1670 public void setDecorated(bool setting) 1671 { 1672 gtk_window_set_decorated(gtkWindow, setting); 1673 } 1674 1675 /** 1676 * The default widget is the widget that’s activated when the user 1677 * presses Enter in a dialog (for example). This function sets or 1678 * unsets the default widget for a #GtkWindow. When setting (rather 1679 * than unsetting) the default widget it’s generally easier to call 1680 * gtk_widget_grab_default() on the widget. Before making a widget 1681 * the default widget, you must call gtk_widget_set_can_default() on 1682 * the widget you’d like to make the default. 1683 * 1684 * Params: 1685 * defaultWidget = widget to be the default, or %NULL 1686 * to unset the default widget for the toplevel 1687 */ 1688 public void setDefault(Widget defaultWidget) 1689 { 1690 gtk_window_set_default(gtkWindow, (defaultWidget is null) ? null : defaultWidget.getWidgetStruct()); 1691 } 1692 1693 /** 1694 * Like gtk_window_set_default_size(), but @width and @height are interpreted 1695 * in terms of the base size and increment set with 1696 * gtk_window_set_geometry_hints. 1697 * 1698 * Deprecated: This function does nothing. If you want to set a default 1699 * size, use gtk_window_set_default_size() instead. 1700 * 1701 * Params: 1702 * width = width in resize increments, or -1 to unset the default width 1703 * height = height in resize increments, or -1 to unset the default height 1704 * 1705 * Since: 3.0 1706 */ 1707 public void setDefaultGeometry(int width, int height) 1708 { 1709 gtk_window_set_default_geometry(gtkWindow, width, height); 1710 } 1711 1712 /** 1713 * Sets the default size of a window. If the window’s “natural” size 1714 * (its size request) is larger than the default, the default will be 1715 * ignored. More generally, if the default size does not obey the 1716 * geometry hints for the window (gtk_window_set_geometry_hints() can 1717 * be used to set these explicitly), the default size will be clamped 1718 * to the nearest permitted size. 1719 * 1720 * Unlike gtk_widget_set_size_request(), which sets a size request for 1721 * a widget and thus would keep users from shrinking the window, this 1722 * function only sets the initial size, just as if the user had 1723 * resized the window themselves. Users can still shrink the window 1724 * again as they normally would. Setting a default size of -1 means to 1725 * use the “natural” default size (the size request of the window). 1726 * 1727 * For more control over a window’s initial size and how resizing works, 1728 * investigate gtk_window_set_geometry_hints(). 1729 * 1730 * For some uses, gtk_window_resize() is a more appropriate function. 1731 * gtk_window_resize() changes the current size of the window, rather 1732 * than the size to be used on initial display. gtk_window_resize() always 1733 * affects the window itself, not the geometry widget. 1734 * 1735 * The default size of a window only affects the first time a window is 1736 * shown; if a window is hidden and re-shown, it will remember the size 1737 * it had prior to hiding, rather than using the default size. 1738 * 1739 * Windows can’t actually be 0x0 in size, they must be at least 1x1, but 1740 * passing 0 for @width and @height is OK, resulting in a 1x1 default size. 1741 * 1742 * If you use this function to reestablish a previously saved window size, 1743 * note that the appropriate size to save is the one returned by 1744 * gtk_window_get_size(). Using the window allocation directly will not 1745 * work in all circumstances and can lead to growing or shrinking windows. 1746 * 1747 * Params: 1748 * width = width in pixels, or -1 to unset the default width 1749 * height = height in pixels, or -1 to unset the default height 1750 */ 1751 public void setDefaultSize(int width, int height) 1752 { 1753 gtk_window_set_default_size(gtkWindow, width, height); 1754 } 1755 1756 /** 1757 * By default, windows have a close button in the window frame. Some 1758 * [window managers][gtk-X11-arch] allow GTK+ to 1759 * disable this button. If you set the deletable property to %FALSE 1760 * using this function, GTK+ will do its best to convince the window 1761 * manager not to show a close button. Depending on the system, this 1762 * function may not have any effect when called on a window that is 1763 * already visible, so you should call it before calling gtk_widget_show(). 1764 * 1765 * On Windows, this function always works, since there’s no window manager 1766 * policy involved. 1767 * 1768 * Params: 1769 * setting = %TRUE to decorate the window as deletable 1770 * 1771 * Since: 2.10 1772 */ 1773 public void setDeletable(bool setting) 1774 { 1775 gtk_window_set_deletable(gtkWindow, setting); 1776 } 1777 1778 /** 1779 * If @setting is %TRUE, then destroying the transient parent of @window 1780 * will also destroy @window itself. This is useful for dialogs that 1781 * shouldn’t persist beyond the lifetime of the main window they're 1782 * associated with, for example. 1783 * 1784 * Params: 1785 * setting = whether to destroy @window with its transient parent 1786 */ 1787 public void setDestroyWithParent(bool setting) 1788 { 1789 gtk_window_set_destroy_with_parent(gtkWindow, setting); 1790 } 1791 1792 /** 1793 * If @focus is not the current focus widget, and is focusable, sets 1794 * it as the focus widget for the window. If @focus is %NULL, unsets 1795 * the focus widget for this window. To set the focus to a particular 1796 * widget in the toplevel, it is usually more convenient to use 1797 * gtk_widget_grab_focus() instead of this function. 1798 * 1799 * Params: 1800 * focus = widget to be the new focus widget, or %NULL to unset 1801 * any focus widget for the toplevel window. 1802 */ 1803 public void setFocus(Widget focus) 1804 { 1805 gtk_window_set_focus(gtkWindow, (focus is null) ? null : focus.getWidgetStruct()); 1806 } 1807 1808 /** 1809 * Windows may set a hint asking the desktop environment not to receive 1810 * the input focus when the window is mapped. This function sets this 1811 * hint. 1812 * 1813 * Params: 1814 * setting = %TRUE to let this window receive input focus on map 1815 * 1816 * Since: 2.6 1817 */ 1818 public void setFocusOnMap(bool setting) 1819 { 1820 gtk_window_set_focus_on_map(gtkWindow, setting); 1821 } 1822 1823 /** 1824 * Sets the #GtkWindow:focus-visible property. 1825 * 1826 * Params: 1827 * setting = the new value 1828 * 1829 * Since: 3.2 1830 */ 1831 public void setFocusVisible(bool setting) 1832 { 1833 gtk_window_set_focus_visible(gtkWindow, setting); 1834 } 1835 1836 /** 1837 * This function sets up hints about how a window can be resized by 1838 * the user. You can set a minimum and maximum size; allowed resize 1839 * increments (e.g. for xterm, you can only resize by the size of a 1840 * character); aspect ratios; and more. See the #GdkGeometry struct. 1841 * 1842 * Params: 1843 * geometryWidget = widget the geometry hints used to be applied to 1844 * or %NULL. Since 3.20 this argument is ignored and GTK behaves as if %NULL was 1845 * set. 1846 * geometry = struct containing geometry information or %NULL 1847 * geomMask = mask indicating which struct fields should be paid attention to 1848 */ 1849 public void setGeometryHints(Widget geometryWidget, GdkGeometry* geometry, GdkWindowHints geomMask) 1850 { 1851 gtk_window_set_geometry_hints(gtkWindow, (geometryWidget is null) ? null : geometryWidget.getWidgetStruct(), geometry, geomMask); 1852 } 1853 1854 /** 1855 * Window gravity defines the meaning of coordinates passed to 1856 * gtk_window_move(). See gtk_window_move() and #GdkGravity for 1857 * more details. 1858 * 1859 * The default window gravity is #GDK_GRAVITY_NORTH_WEST which will 1860 * typically “do what you mean.” 1861 * 1862 * Params: 1863 * gravity = window gravity 1864 */ 1865 public void setGravity(GdkGravity gravity) 1866 { 1867 gtk_window_set_gravity(gtkWindow, gravity); 1868 } 1869 1870 /** 1871 * Sets whether @window has a corner resize grip. 1872 * 1873 * Note that the resize grip is only shown if the window 1874 * is actually resizable and not maximized. Use 1875 * gtk_window_resize_grip_is_visible() to find out if the 1876 * resize grip is currently shown. 1877 * 1878 * Deprecated: Resize grips have been removed. 1879 * 1880 * Params: 1881 * value = %TRUE to allow a resize grip 1882 * 1883 * Since: 3.0 1884 */ 1885 public void setHasResizeGrip(bool value) 1886 { 1887 gtk_window_set_has_resize_grip(gtkWindow, value); 1888 } 1889 1890 /** 1891 * Tells GTK+ whether to drop its extra reference to the window 1892 * when gtk_widget_destroy() is called. 1893 * 1894 * This function is only exported for the benefit of language 1895 * bindings which may need to keep the window alive until their 1896 * wrapper object is garbage collected. There is no justification 1897 * for ever calling this function in an application. 1898 * 1899 * Params: 1900 * setting = the new value 1901 * 1902 * Since: 3.0 1903 */ 1904 public void setHasUserRefCount(bool setting) 1905 { 1906 gtk_window_set_has_user_ref_count(gtkWindow, setting); 1907 } 1908 1909 /** 1910 * If @setting is %TRUE, then @window will request that it’s titlebar 1911 * should be hidden when maximized. 1912 * This is useful for windows that don’t convey any information other 1913 * than the application name in the titlebar, to put the available 1914 * screen space to better use. If the underlying window system does not 1915 * support the request, the setting will not have any effect. 1916 * 1917 * Note that custom titlebars set with gtk_window_set_titlebar() are 1918 * not affected by this. The application is in full control of their 1919 * content and visibility anyway. 1920 * 1921 * Params: 1922 * setting = whether to hide the titlebar when @window is maximized 1923 * 1924 * Since: 3.4 1925 */ 1926 public void setHideTitlebarWhenMaximized(bool setting) 1927 { 1928 gtk_window_set_hide_titlebar_when_maximized(gtkWindow, setting); 1929 } 1930 1931 /** 1932 * Sets up the icon representing a #GtkWindow. This icon is used when 1933 * the window is minimized (also known as iconified). Some window 1934 * managers or desktop environments may also place it in the window 1935 * frame, or display it in other contexts. On others, the icon is not 1936 * used at all, so your mileage may vary. 1937 * 1938 * The icon should be provided in whatever size it was naturally 1939 * drawn; that is, don’t scale the image before passing it to 1940 * GTK+. Scaling is postponed until the last minute, when the desired 1941 * final size is known, to allow best quality. 1942 * 1943 * If you have your icon hand-drawn in multiple sizes, use 1944 * gtk_window_set_icon_list(). Then the best size will be used. 1945 * 1946 * This function is equivalent to calling gtk_window_set_icon_list() 1947 * with a 1-element list. 1948 * 1949 * See also gtk_window_set_default_icon_list() to set the icon 1950 * for all windows in your application in one go. 1951 * 1952 * Params: 1953 * icon = icon image, or %NULL 1954 */ 1955 public void setIcon(Pixbuf icon) 1956 { 1957 gtk_window_set_icon(gtkWindow, (icon is null) ? null : icon.getPixbufStruct()); 1958 } 1959 1960 /** 1961 * Sets the icon for @window. 1962 * Warns on failure if @err is %NULL. 1963 * 1964 * This function is equivalent to calling gtk_window_set_icon() 1965 * with a pixbuf created by loading the image from @filename. 1966 * 1967 * Params: 1968 * filename = location of icon file 1969 * 1970 * Returns: %TRUE if setting the icon succeeded. 1971 * 1972 * Since: 2.2 1973 * 1974 * Throws: GException on failure. 1975 */ 1976 public bool setIconFromFile(string filename) 1977 { 1978 GError* err = null; 1979 1980 auto p = gtk_window_set_icon_from_file(gtkWindow, Str.toStringz(filename), &err) != 0; 1981 1982 if (err !is null) 1983 { 1984 throw new GException( new ErrorG(err) ); 1985 } 1986 1987 return p; 1988 } 1989 1990 /** 1991 * Sets up the icon representing a #GtkWindow. The icon is used when 1992 * the window is minimized (also known as iconified). Some window 1993 * managers or desktop environments may also place it in the window 1994 * frame, or display it in other contexts. On others, the icon is not 1995 * used at all, so your mileage may vary. 1996 * 1997 * gtk_window_set_icon_list() allows you to pass in the same icon in 1998 * several hand-drawn sizes. The list should contain the natural sizes 1999 * your icon is available in; that is, don’t scale the image before 2000 * passing it to GTK+. Scaling is postponed until the last minute, 2001 * when the desired final size is known, to allow best quality. 2002 * 2003 * By passing several sizes, you may improve the final image quality 2004 * of the icon, by reducing or eliminating automatic image scaling. 2005 * 2006 * Recommended sizes to provide: 16x16, 32x32, 48x48 at minimum, and 2007 * larger images (64x64, 128x128) if you have them. 2008 * 2009 * See also gtk_window_set_default_icon_list() to set the icon 2010 * for all windows in your application in one go. 2011 * 2012 * Note that transient windows (those who have been set transient for another 2013 * window using gtk_window_set_transient_for()) will inherit their 2014 * icon from their transient parent. So there’s no need to explicitly 2015 * set the icon on transient windows. 2016 * 2017 * Params: 2018 * list = list of #GdkPixbuf 2019 */ 2020 public void setIconList(ListG list) 2021 { 2022 gtk_window_set_icon_list(gtkWindow, (list is null) ? null : list.getListGStruct()); 2023 } 2024 2025 /** 2026 * Sets the icon for the window from a named themed icon. 2027 * See the docs for #GtkIconTheme for more details. 2028 * On some platforms, the window icon is not used at all. 2029 * 2030 * Note that this has nothing to do with the WM_ICON_NAME 2031 * property which is mentioned in the ICCCM. 2032 * 2033 * Params: 2034 * name = the name of the themed icon 2035 * 2036 * Since: 2.6 2037 */ 2038 public void setIconName(string name) 2039 { 2040 gtk_window_set_icon_name(gtkWindow, Str.toStringz(name)); 2041 } 2042 2043 /** 2044 * Asks to keep @window above, so that it stays on top. Note that 2045 * you shouldn’t assume the window is definitely above afterward, 2046 * because other entities (e.g. the user or 2047 * [window manager][gtk-X11-arch]) could not keep it above, 2048 * and not all window managers support keeping windows above. But 2049 * normally the window will end kept above. Just don’t write code 2050 * that crashes if not. 2051 * 2052 * It’s permitted to call this function before showing a window, 2053 * in which case the window will be kept above when it appears onscreen 2054 * initially. 2055 * 2056 * You can track the above state via the “window-state-event” signal 2057 * on #GtkWidget. 2058 * 2059 * Note that, according to the 2060 * [Extended Window Manager Hints Specification](http://www.freedesktop.org/Standards/wm-spec), 2061 * the above state is mainly meant for user preferences and should not 2062 * be used by applications e.g. for drawing attention to their 2063 * dialogs. 2064 * 2065 * Params: 2066 * setting = whether to keep @window above other windows 2067 * 2068 * Since: 2.4 2069 */ 2070 public void setKeepAbove(bool setting) 2071 { 2072 gtk_window_set_keep_above(gtkWindow, setting); 2073 } 2074 2075 /** 2076 * Asks to keep @window below, so that it stays in bottom. Note that 2077 * you shouldn’t assume the window is definitely below afterward, 2078 * because other entities (e.g. the user or 2079 * [window manager][gtk-X11-arch]) could not keep it below, 2080 * and not all window managers support putting windows below. But 2081 * normally the window will be kept below. Just don’t write code 2082 * that crashes if not. 2083 * 2084 * It’s permitted to call this function before showing a window, 2085 * in which case the window will be kept below when it appears onscreen 2086 * initially. 2087 * 2088 * You can track the below state via the “window-state-event” signal 2089 * on #GtkWidget. 2090 * 2091 * Note that, according to the 2092 * [Extended Window Manager Hints Specification](http://www.freedesktop.org/Standards/wm-spec), 2093 * the above state is mainly meant for user preferences and should not 2094 * be used by applications e.g. for drawing attention to their 2095 * dialogs. 2096 * 2097 * Params: 2098 * setting = whether to keep @window below other windows 2099 * 2100 * Since: 2.4 2101 */ 2102 public void setKeepBelow(bool setting) 2103 { 2104 gtk_window_set_keep_below(gtkWindow, setting); 2105 } 2106 2107 /** 2108 * Sets the mnemonic modifier for this window. 2109 * 2110 * Params: 2111 * modifier = the modifier mask used to activate 2112 * mnemonics on this window. 2113 */ 2114 public void setMnemonicModifier(GdkModifierType modifier) 2115 { 2116 gtk_window_set_mnemonic_modifier(gtkWindow, modifier); 2117 } 2118 2119 /** 2120 * Sets the #GtkWindow:mnemonics-visible property. 2121 * 2122 * Params: 2123 * setting = the new value 2124 * 2125 * Since: 2.20 2126 */ 2127 public void setMnemonicsVisible(bool setting) 2128 { 2129 gtk_window_set_mnemonics_visible(gtkWindow, setting); 2130 } 2131 2132 /** 2133 * Sets a window modal or non-modal. Modal windows prevent interaction 2134 * with other windows in the same application. To keep modal dialogs 2135 * on top of main application windows, use 2136 * gtk_window_set_transient_for() to make the dialog transient for the 2137 * parent; most [window managers][gtk-X11-arch] 2138 * will then disallow lowering the dialog below the parent. 2139 * 2140 * Params: 2141 * modal = whether the window is modal 2142 */ 2143 public void setModal(bool modal) 2144 { 2145 gtk_window_set_modal(gtkWindow, modal); 2146 } 2147 2148 /** 2149 * Request the windowing system to make @window partially transparent, 2150 * with opacity 0 being fully transparent and 1 fully opaque. (Values 2151 * of the opacity parameter are clamped to the [0,1] range.) On X11 2152 * this has any effect only on X screens with a compositing manager 2153 * running. See gtk_widget_is_composited(). On Windows it should work 2154 * always. 2155 * 2156 * Note that setting a window’s opacity after the window has been 2157 * shown causes it to flicker once on Windows. 2158 * 2159 * Deprecated: Use gtk_widget_set_opacity instead. 2160 * 2161 * Params: 2162 * opacity = desired opacity, between 0 and 1 2163 * 2164 * Since: 2.12 2165 */ 2166 public override void setOpacity(double opacity) 2167 { 2168 gtk_window_set_opacity(gtkWindow, opacity); 2169 } 2170 2171 /** 2172 * Sets a position constraint for this window. If the old or new 2173 * constraint is %GTK_WIN_POS_CENTER_ALWAYS, this will also cause 2174 * the window to be repositioned to satisfy the new constraint. 2175 * 2176 * Params: 2177 * position = a position constraint. 2178 */ 2179 public void setPosition(GtkWindowPosition position) 2180 { 2181 gtk_window_set_position(gtkWindow, position); 2182 } 2183 2184 /** 2185 * Sets whether the user can resize a window. Windows are user resizable 2186 * by default. 2187 * 2188 * Params: 2189 * resizable = %TRUE if the user can resize this window 2190 */ 2191 public void setResizable(bool resizable) 2192 { 2193 gtk_window_set_resizable(gtkWindow, resizable); 2194 } 2195 2196 /** 2197 * This function is only useful on X11, not with other GTK+ targets. 2198 * 2199 * In combination with the window title, the window role allows a 2200 * [window manager][gtk-X11-arch] to identify "the 2201 * same" window when an application is restarted. So for example you 2202 * might set the “toolbox” role on your app’s toolbox window, so that 2203 * when the user restarts their session, the window manager can put 2204 * the toolbox back in the same place. 2205 * 2206 * If a window already has a unique title, you don’t need to set the 2207 * role, since the WM can use the title to identify the window when 2208 * restoring the session. 2209 * 2210 * Params: 2211 * role = unique identifier for the window to be used when restoring a session 2212 */ 2213 public void setRole(string role) 2214 { 2215 gtk_window_set_role(gtkWindow, Str.toStringz(role)); 2216 } 2217 2218 /** 2219 * Sets the #GdkScreen where the @window is displayed; if 2220 * the window is already mapped, it will be unmapped, and 2221 * then remapped on the new screen. 2222 * 2223 * Params: 2224 * screen = a #GdkScreen. 2225 * 2226 * Since: 2.2 2227 */ 2228 public void setScreen(Screen screen) 2229 { 2230 gtk_window_set_screen(gtkWindow, (screen is null) ? null : screen.getScreenStruct()); 2231 } 2232 2233 /** 2234 * Windows may set a hint asking the desktop environment not to display 2235 * the window in the pager. This function sets this hint. 2236 * (A "pager" is any desktop navigation tool such as a workspace 2237 * switcher that displays a thumbnail representation of the windows 2238 * on the screen.) 2239 * 2240 * Params: 2241 * setting = %TRUE to keep this window from appearing in the pager 2242 * 2243 * Since: 2.2 2244 */ 2245 public void setSkipPagerHint(bool setting) 2246 { 2247 gtk_window_set_skip_pager_hint(gtkWindow, setting); 2248 } 2249 2250 /** 2251 * Windows may set a hint asking the desktop environment not to display 2252 * the window in the task bar. This function sets this hint. 2253 * 2254 * Params: 2255 * setting = %TRUE to keep this window from appearing in the task bar 2256 * 2257 * Since: 2.2 2258 */ 2259 public void setSkipTaskbarHint(bool setting) 2260 { 2261 gtk_window_set_skip_taskbar_hint(gtkWindow, setting); 2262 } 2263 2264 /** 2265 * Startup notification identifiers are used by desktop environment to 2266 * track application startup, to provide user feedback and other 2267 * features. This function changes the corresponding property on the 2268 * underlying GdkWindow. Normally, startup identifier is managed 2269 * automatically and you should only use this function in special cases 2270 * like transferring focus from other processes. You should use this 2271 * function before calling gtk_window_present() or any equivalent 2272 * function generating a window map event. 2273 * 2274 * This function is only useful on X11, not with other GTK+ targets. 2275 * 2276 * Params: 2277 * startupId = a string with startup-notification identifier 2278 * 2279 * Since: 2.12 2280 */ 2281 public void setStartupId(string startupId) 2282 { 2283 gtk_window_set_startup_id(gtkWindow, Str.toStringz(startupId)); 2284 } 2285 2286 /** 2287 * Sets the title of the #GtkWindow. The title of a window will be 2288 * displayed in its title bar; on the X Window System, the title bar 2289 * is rendered by the [window manager][gtk-X11-arch], 2290 * so exactly how the title appears to users may vary 2291 * according to a user’s exact configuration. The title should help a 2292 * user distinguish this window from other windows they may have 2293 * open. A good title might include the application name and current 2294 * document filename, for example. 2295 * 2296 * Params: 2297 * title = title of the window 2298 */ 2299 public void setTitle(string title) 2300 { 2301 gtk_window_set_title(gtkWindow, Str.toStringz(title)); 2302 } 2303 2304 /** 2305 * Sets a custom titlebar for @window. 2306 * 2307 * If you set a custom titlebar, GTK+ will do its best to convince 2308 * the window manager not to put its own titlebar on the window. 2309 * Depending on the system, this function may not work for a window 2310 * that is already visible, so you set the titlebar before calling 2311 * gtk_widget_show(). 2312 * 2313 * Params: 2314 * titlebar = the widget to use as titlebar 2315 * 2316 * Since: 3.10 2317 */ 2318 public void setTitlebar(Widget titlebar) 2319 { 2320 gtk_window_set_titlebar(gtkWindow, (titlebar is null) ? null : titlebar.getWidgetStruct()); 2321 } 2322 2323 /** 2324 * Dialog windows should be set transient for the main application 2325 * window they were spawned from. This allows 2326 * [window managers][gtk-X11-arch] to e.g. keep the 2327 * dialog on top of the main window, or center the dialog over the 2328 * main window. gtk_dialog_new_with_buttons() and other convenience 2329 * functions in GTK+ will sometimes call 2330 * gtk_window_set_transient_for() on your behalf. 2331 * 2332 * Passing %NULL for @parent unsets the current transient window. 2333 * 2334 * On Wayland, this function can also be used to attach a new 2335 * #GTK_WINDOW_POPUP to a #GTK_WINDOW_TOPLEVEL parent already mapped 2336 * on screen so that the #GTK_WINDOW_POPUP will be created as a 2337 * subsurface-based window #GDK_WINDOW_SUBSURFACE which can be 2338 * positioned at will relatively to the #GTK_WINDOW_TOPLEVEL surface. 2339 * 2340 * On Windows, this function puts the child window on top of the parent, 2341 * much as the window manager would have done on X. 2342 * 2343 * Params: 2344 * parent = parent window, or %NULL 2345 */ 2346 public void setTransientFor(Window parent) 2347 { 2348 gtk_window_set_transient_for(gtkWindow, (parent is null) ? null : parent.getWindowStruct()); 2349 } 2350 2351 /** 2352 * By setting the type hint for the window, you allow the window 2353 * manager to decorate and handle the window in a way which is 2354 * suitable to the function of the window in your application. 2355 * 2356 * This function should be called before the window becomes visible. 2357 * 2358 * gtk_dialog_new_with_buttons() and other convenience functions in GTK+ 2359 * will sometimes call gtk_window_set_type_hint() on your behalf. 2360 * 2361 * Params: 2362 * hint = the window type 2363 */ 2364 public void setTypeHint(GdkWindowTypeHint hint) 2365 { 2366 gtk_window_set_type_hint(gtkWindow, hint); 2367 } 2368 2369 /** 2370 * Windows may set a hint asking the desktop environment to draw 2371 * the users attention to the window. This function sets this hint. 2372 * 2373 * Params: 2374 * setting = %TRUE to mark this window as urgent 2375 * 2376 * Since: 2.8 2377 */ 2378 public void setUrgencyHint(bool setting) 2379 { 2380 gtk_window_set_urgency_hint(gtkWindow, setting); 2381 } 2382 2383 /** 2384 * Don’t use this function. It sets the X Window System “class” and 2385 * “name” hints for a window. According to the ICCCM, you should 2386 * always set these to the same value for all windows in an 2387 * application, and GTK+ sets them to that value by default, so calling 2388 * this function is sort of pointless. However, you may want to call 2389 * gtk_window_set_role() on each window in your application, for the 2390 * benefit of the session manager. Setting the role allows the window 2391 * manager to restore window positions when loading a saved session. 2392 * 2393 * Params: 2394 * wmclassName = window name hint 2395 * wmclassClass = window class hint 2396 */ 2397 public void setWmclass(string wmclassName, string wmclassClass) 2398 { 2399 gtk_window_set_wmclass(gtkWindow, Str.toStringz(wmclassName), Str.toStringz(wmclassClass)); 2400 } 2401 2402 /** 2403 * Asks to stick @window, which means that it will appear on all user 2404 * desktops. Note that you shouldn’t assume the window is definitely 2405 * stuck afterward, because other entities (e.g. the user or 2406 * [window manager][gtk-X11-arch] could unstick it 2407 * again, and some window managers do not support sticking 2408 * windows. But normally the window will end up stuck. Just don't 2409 * write code that crashes if not. 2410 * 2411 * It’s permitted to call this function before showing a window. 2412 * 2413 * You can track stickiness via the “window-state-event” signal 2414 * on #GtkWidget. 2415 */ 2416 public void stick() 2417 { 2418 gtk_window_stick(gtkWindow); 2419 } 2420 2421 /** 2422 * Asks to toggle off the fullscreen state for @window. Note that you 2423 * shouldn’t assume the window is definitely not full screen 2424 * afterward, because other entities (e.g. the user or 2425 * [window manager][gtk-X11-arch]) could fullscreen it 2426 * again, and not all window managers honor requests to unfullscreen 2427 * windows. But normally the window will end up restored to its normal 2428 * state. Just don’t write code that crashes if not. 2429 * 2430 * You can track the fullscreen state via the “window-state-event” signal 2431 * on #GtkWidget. 2432 * 2433 * Since: 2.2 2434 */ 2435 public void unfullscreen() 2436 { 2437 gtk_window_unfullscreen(gtkWindow); 2438 } 2439 2440 /** 2441 * Asks to unmaximize @window. Note that you shouldn’t assume the 2442 * window is definitely unmaximized afterward, because other entities 2443 * (e.g. the user or [window manager][gtk-X11-arch]) 2444 * could maximize it again, and not all window 2445 * managers honor requests to unmaximize. But normally the window will 2446 * end up unmaximized. Just don’t write code that crashes if not. 2447 * 2448 * You can track maximization via the “window-state-event” signal 2449 * on #GtkWidget. 2450 */ 2451 public void unmaximize() 2452 { 2453 gtk_window_unmaximize(gtkWindow); 2454 } 2455 2456 /** 2457 * Asks to unstick @window, which means that it will appear on only 2458 * one of the user’s desktops. Note that you shouldn’t assume the 2459 * window is definitely unstuck afterward, because other entities 2460 * (e.g. the user or [window manager][gtk-X11-arch]) could 2461 * stick it again. But normally the window will 2462 * end up stuck. Just don’t write code that crashes if not. 2463 * 2464 * You can track stickiness via the “window-state-event” signal 2465 * on #GtkWidget. 2466 */ 2467 public void unstick() 2468 { 2469 gtk_window_unstick(gtkWindow); 2470 } 2471 2472 protected class OnActivateDefaultDelegateWrapper 2473 { 2474 void delegate(Window) dlg; 2475 gulong handlerId; 2476 2477 this(void delegate(Window) dlg) 2478 { 2479 this.dlg = dlg; 2480 onActivateDefaultListeners ~= this; 2481 } 2482 2483 void remove(OnActivateDefaultDelegateWrapper source) 2484 { 2485 foreach(index, wrapper; onActivateDefaultListeners) 2486 { 2487 if (wrapper.handlerId == source.handlerId) 2488 { 2489 onActivateDefaultListeners[index] = null; 2490 onActivateDefaultListeners = std.algorithm.remove(onActivateDefaultListeners, index); 2491 break; 2492 } 2493 } 2494 } 2495 } 2496 OnActivateDefaultDelegateWrapper[] onActivateDefaultListeners; 2497 2498 /** 2499 * The ::activate-default signal is a 2500 * [keybinding signal][GtkBindingSignal] 2501 * which gets emitted when the user activates the default widget 2502 * of @window. 2503 */ 2504 gulong addOnActivateDefault(void delegate(Window) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2505 { 2506 auto wrapper = new OnActivateDefaultDelegateWrapper(dlg); 2507 wrapper.handlerId = Signals.connectData( 2508 this, 2509 "activate-default", 2510 cast(GCallback)&callBackActivateDefault, 2511 cast(void*)wrapper, 2512 cast(GClosureNotify)&callBackActivateDefaultDestroy, 2513 connectFlags); 2514 return wrapper.handlerId; 2515 } 2516 2517 extern(C) static void callBackActivateDefault(GtkWindow* windowStruct, OnActivateDefaultDelegateWrapper wrapper) 2518 { 2519 wrapper.dlg(wrapper.outer); 2520 } 2521 2522 extern(C) static void callBackActivateDefaultDestroy(OnActivateDefaultDelegateWrapper wrapper, GClosure* closure) 2523 { 2524 wrapper.remove(wrapper); 2525 } 2526 2527 protected class OnActivateFocusDelegateWrapper 2528 { 2529 void delegate(Window) dlg; 2530 gulong handlerId; 2531 2532 this(void delegate(Window) dlg) 2533 { 2534 this.dlg = dlg; 2535 onActivateFocusListeners ~= this; 2536 } 2537 2538 void remove(OnActivateFocusDelegateWrapper source) 2539 { 2540 foreach(index, wrapper; onActivateFocusListeners) 2541 { 2542 if (wrapper.handlerId == source.handlerId) 2543 { 2544 onActivateFocusListeners[index] = null; 2545 onActivateFocusListeners = std.algorithm.remove(onActivateFocusListeners, index); 2546 break; 2547 } 2548 } 2549 } 2550 } 2551 OnActivateFocusDelegateWrapper[] onActivateFocusListeners; 2552 2553 /** 2554 * The ::activate-focus signal is a 2555 * [keybinding signal][GtkBindingSignal] 2556 * which gets emitted when the user activates the currently 2557 * focused widget of @window. 2558 */ 2559 gulong addOnActivateFocus(void delegate(Window) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2560 { 2561 auto wrapper = new OnActivateFocusDelegateWrapper(dlg); 2562 wrapper.handlerId = Signals.connectData( 2563 this, 2564 "activate-focus", 2565 cast(GCallback)&callBackActivateFocus, 2566 cast(void*)wrapper, 2567 cast(GClosureNotify)&callBackActivateFocusDestroy, 2568 connectFlags); 2569 return wrapper.handlerId; 2570 } 2571 2572 extern(C) static void callBackActivateFocus(GtkWindow* windowStruct, OnActivateFocusDelegateWrapper wrapper) 2573 { 2574 wrapper.dlg(wrapper.outer); 2575 } 2576 2577 extern(C) static void callBackActivateFocusDestroy(OnActivateFocusDelegateWrapper wrapper, GClosure* closure) 2578 { 2579 wrapper.remove(wrapper); 2580 } 2581 2582 protected class OnEnableDebuggingDelegateWrapper 2583 { 2584 bool delegate(bool, Window) dlg; 2585 gulong handlerId; 2586 2587 this(bool delegate(bool, Window) dlg) 2588 { 2589 this.dlg = dlg; 2590 onEnableDebuggingListeners ~= this; 2591 } 2592 2593 void remove(OnEnableDebuggingDelegateWrapper source) 2594 { 2595 foreach(index, wrapper; onEnableDebuggingListeners) 2596 { 2597 if (wrapper.handlerId == source.handlerId) 2598 { 2599 onEnableDebuggingListeners[index] = null; 2600 onEnableDebuggingListeners = std.algorithm.remove(onEnableDebuggingListeners, index); 2601 break; 2602 } 2603 } 2604 } 2605 } 2606 OnEnableDebuggingDelegateWrapper[] onEnableDebuggingListeners; 2607 2608 /** 2609 * The ::enable-debugging signal is a [keybinding signal][GtkBindingSignal] 2610 * which gets emitted when the user enables or disables interactive 2611 * debugging. When @toggle is %TRUE, interactive debugging is toggled 2612 * on or off, when it is %FALSE, the debugger will be pointed at the 2613 * widget under the pointer. 2614 * 2615 * The default bindings for this signal are Ctrl-Shift-I 2616 * and Ctrl-Shift-D. 2617 * 2618 * Params: 2619 * toggle = toggle the debugger 2620 * 2621 * Returns: %TRUE if the key binding was handled 2622 */ 2623 gulong addOnEnableDebugging(bool delegate(bool, Window) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2624 { 2625 auto wrapper = new OnEnableDebuggingDelegateWrapper(dlg); 2626 wrapper.handlerId = Signals.connectData( 2627 this, 2628 "enable-debugging", 2629 cast(GCallback)&callBackEnableDebugging, 2630 cast(void*)wrapper, 2631 cast(GClosureNotify)&callBackEnableDebuggingDestroy, 2632 connectFlags); 2633 return wrapper.handlerId; 2634 } 2635 2636 extern(C) static int callBackEnableDebugging(GtkWindow* windowStruct, bool toggle, OnEnableDebuggingDelegateWrapper wrapper) 2637 { 2638 return wrapper.dlg(toggle, wrapper.outer); 2639 } 2640 2641 extern(C) static void callBackEnableDebuggingDestroy(OnEnableDebuggingDelegateWrapper wrapper, GClosure* closure) 2642 { 2643 wrapper.remove(wrapper); 2644 } 2645 2646 protected class OnKeysChangedDelegateWrapper 2647 { 2648 void delegate(Window) dlg; 2649 gulong handlerId; 2650 2651 this(void delegate(Window) dlg) 2652 { 2653 this.dlg = dlg; 2654 onKeysChangedListeners ~= this; 2655 } 2656 2657 void remove(OnKeysChangedDelegateWrapper source) 2658 { 2659 foreach(index, wrapper; onKeysChangedListeners) 2660 { 2661 if (wrapper.handlerId == source.handlerId) 2662 { 2663 onKeysChangedListeners[index] = null; 2664 onKeysChangedListeners = std.algorithm.remove(onKeysChangedListeners, index); 2665 break; 2666 } 2667 } 2668 } 2669 } 2670 OnKeysChangedDelegateWrapper[] onKeysChangedListeners; 2671 2672 /** 2673 * The ::keys-changed signal gets emitted when the set of accelerators 2674 * or mnemonics that are associated with @window changes. 2675 */ 2676 gulong addOnKeysChanged(void delegate(Window) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2677 { 2678 auto wrapper = new OnKeysChangedDelegateWrapper(dlg); 2679 wrapper.handlerId = Signals.connectData( 2680 this, 2681 "keys-changed", 2682 cast(GCallback)&callBackKeysChanged, 2683 cast(void*)wrapper, 2684 cast(GClosureNotify)&callBackKeysChangedDestroy, 2685 connectFlags); 2686 return wrapper.handlerId; 2687 } 2688 2689 extern(C) static void callBackKeysChanged(GtkWindow* windowStruct, OnKeysChangedDelegateWrapper wrapper) 2690 { 2691 wrapper.dlg(wrapper.outer); 2692 } 2693 2694 extern(C) static void callBackKeysChangedDestroy(OnKeysChangedDelegateWrapper wrapper, GClosure* closure) 2695 { 2696 wrapper.remove(wrapper); 2697 } 2698 2699 protected class OnSetFocusDelegateWrapper 2700 { 2701 void delegate(Widget, Window) dlg; 2702 gulong handlerId; 2703 2704 this(void delegate(Widget, Window) dlg) 2705 { 2706 this.dlg = dlg; 2707 onSetFocusListeners ~= this; 2708 } 2709 2710 void remove(OnSetFocusDelegateWrapper source) 2711 { 2712 foreach(index, wrapper; onSetFocusListeners) 2713 { 2714 if (wrapper.handlerId == source.handlerId) 2715 { 2716 onSetFocusListeners[index] = null; 2717 onSetFocusListeners = std.algorithm.remove(onSetFocusListeners, index); 2718 break; 2719 } 2720 } 2721 } 2722 } 2723 OnSetFocusDelegateWrapper[] onSetFocusListeners; 2724 2725 /** */ 2726 gulong addOnSetFocus(void delegate(Widget, Window) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2727 { 2728 auto wrapper = new OnSetFocusDelegateWrapper(dlg); 2729 wrapper.handlerId = Signals.connectData( 2730 this, 2731 "set-focus", 2732 cast(GCallback)&callBackSetFocus, 2733 cast(void*)wrapper, 2734 cast(GClosureNotify)&callBackSetFocusDestroy, 2735 connectFlags); 2736 return wrapper.handlerId; 2737 } 2738 2739 extern(C) static void callBackSetFocus(GtkWindow* windowStruct, GtkWidget* object, OnSetFocusDelegateWrapper wrapper) 2740 { 2741 wrapper.dlg(ObjectG.getDObject!(Widget)(object), wrapper.outer); 2742 } 2743 2744 extern(C) static void callBackSetFocusDestroy(OnSetFocusDelegateWrapper wrapper, GClosure* closure) 2745 { 2746 wrapper.remove(wrapper); 2747 } 2748 2749 /** 2750 * This is a convenience function for launching the default application 2751 * to show the uri. The uri must be of a form understood by GIO (i.e. you 2752 * need to install gvfs to get support for uri schemes such as http:// 2753 * or ftp://, as only local files are handled by GIO itself). 2754 * Typical examples are 2755 * - `file:///home/gnome/pict.jpg` 2756 * - `http://www.gnome.org` 2757 * - `mailto:me@gnome.org` 2758 * 2759 * Ideally the timestamp is taken from the event triggering 2760 * the gtk_show_uri() call. If timestamp is not known you can take 2761 * %GDK_CURRENT_TIME. 2762 * 2763 * This is the recommended call to be used as it passes information 2764 * necessary for sandbox helpers to parent their dialogs properly. 2765 * 2766 * Params: 2767 * parent = parent window 2768 * uri = the uri to show 2769 * timestamp = a timestamp to prevent focus stealing 2770 * 2771 * Returns: %TRUE on success, %FALSE on error 2772 * 2773 * Since: 3.22 2774 * 2775 * Throws: GException on failure. 2776 */ 2777 public static bool showUriOnWindow(Window parent, string uri, uint timestamp) 2778 { 2779 GError* err = null; 2780 2781 auto p = gtk_show_uri_on_window((parent is null) ? null : parent.getWindowStruct(), Str.toStringz(uri), timestamp, &err) != 0; 2782 2783 if (err !is null) 2784 { 2785 throw new GException( new ErrorG(err) ); 2786 } 2787 2788 return p; 2789 } 2790 }