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