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