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