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