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