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