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.Display; 28 private import gdk.MonitorGdk; 29 private import gio.ListModelIF; 30 private import glib.ConstructionException; 31 private import glib.ListG; 32 private import glib.Str; 33 private import glib.c.functions; 34 private import gobject.ObjectG; 35 private import gobject.Signals; 36 private import gtk.Application; 37 private import gtk.NativeIF; 38 private import gtk.NativeT; 39 private import gtk.RootIF; 40 private import gtk.RootT; 41 private import gtk.ShortcutManagerIF; 42 private import gtk.ShortcutManagerT; 43 private import gtk.Widget; 44 private import gtk.WindowGroup; 45 private import gtk.c.functions; 46 public import gtk.c.types; 47 private import std.algorithm; 48 49 50 /** 51 * A `GtkWindow` is a toplevel window which can contain other widgets. 52 * 53 * ![An example GtkWindow](window.png) 54 * 55 * Windows normally have decorations that are under the control 56 * of the windowing system and allow the user to manipulate the window 57 * (resize it, move it, close it,...). 58 * 59 * # GtkWindow as GtkBuildable 60 * 61 * The `GtkWindow` implementation of the [iface@Gtk.Buildable] interface supports 62 * setting a child as the titlebar by specifying “titlebar” as the “type” 63 * attribute of a <child> element. 64 * 65 * # CSS nodes 66 * 67 * ``` 68 * window.background [.csd / .solid-csd / .ssd] [.maximized / .fullscreen / .tiled] 69 * ├── <child> 70 * ╰── <titlebar child>.titlebar [.default-decoration] 71 * ``` 72 * 73 * `GtkWindow` has a main CSS node with name window and style class .background. 74 * 75 * Style classes that are typically used with the main CSS node are .csd (when 76 * client-side decorations are in use), .solid-csd (for client-side decorations 77 * without invisible borders), .ssd (used by mutter when rendering server-side 78 * decorations). GtkWindow also represents window states with the following 79 * style classes on the main node: .maximized, .fullscreen, .tiled (when supported, 80 * also .tiled-top, .tiled-left, .tiled-right, .tiled-bottom). 81 * 82 * `GtkWindow` subclasses often add their own discriminating style classes, 83 * such as .dialog, .popup or .tooltip. 84 * 85 * Generally, some CSS properties don't make sense on the toplevel window node, 86 * such as margins or padding. When client-side decorations without invisible 87 * borders are in use (i.e. the .solid-csd style class is added to the 88 * main window node), the CSS border of the toplevel window is used for 89 * resize drags. In the .csd case, the shadow area outside of the window 90 * can be used to resize it. 91 * 92 * `GtkWindow` adds the .titlebar and .default-decoration style classes to the 93 * widget that is added as a titlebar child. 94 * 95 * # Accessibility 96 * 97 * `GtkWindow` uses the %GTK_ACCESSIBLE_ROLE_WINDOW role. 98 */ 99 public class Window : Widget, NativeIF, RootIF, ShortcutManagerIF 100 { 101 /** the main Gtk struct */ 102 protected GtkWindow* gtkWindow; 103 104 /** Get the main Gtk struct */ 105 public GtkWindow* getWindowStruct(bool transferOwnership = false) 106 { 107 if (transferOwnership) 108 ownedRef = false; 109 return gtkWindow; 110 } 111 112 /** the main Gtk struct as a void* */ 113 protected override void* getStruct() 114 { 115 return cast(void*)gtkWindow; 116 } 117 118 /** 119 * Sets our main struct and passes it to the parent class. 120 */ 121 public this (GtkWindow* gtkWindow, bool ownedRef = false) 122 { 123 this.gtkWindow = gtkWindow; 124 super(cast(GtkWidget*)gtkWindow, ownedRef); 125 } 126 127 // add the Native capabilities 128 mixin NativeT!(GtkWindow); 129 130 // add the Root capabilities 131 mixin RootT!(GtkWindow); 132 133 // add the ShortcutManager capabilities 134 mixin ShortcutManagerT!(GtkWindow); 135 136 137 /** */ 138 public static GType getType() 139 { 140 return gtk_window_get_type(); 141 } 142 143 /** 144 * Creates a new `GtkWindow`. 145 * 146 * To get an undecorated window (no window borders), use 147 * [method@Gtk.Window.set_decorated]. 148 * 149 * All top-level windows created by gtk_window_new() are stored 150 * in an internal top-level window list. This list can be obtained 151 * from [func@Gtk.Window.list_toplevels]. Due to GTK keeping a 152 * reference to the window internally, gtk_window_new() does not 153 * return a reference to the caller. 154 * 155 * To delete a `GtkWindow`, call [method@Gtk.Window.destroy]. 156 * 157 * Returns: a new `GtkWindow`. 158 * 159 * Throws: ConstructionException GTK+ fails to create the object. 160 */ 161 public this() 162 { 163 auto __p = gtk_window_new(); 164 165 if(__p is null) 166 { 167 throw new ConstructionException("null returned by new"); 168 } 169 170 this(cast(GtkWindow*) __p); 171 } 172 173 /** 174 * Returns the fallback icon name for windows. 175 * 176 * The returned string is owned by GTK and should not 177 * be modified. It is only valid until the next call to 178 * [func@Gtk.Window.set_default_icon_name]. 179 * 180 * Returns: the fallback icon name for windows 181 */ 182 public static string getDefaultIconName() 183 { 184 return Str.toString(gtk_window_get_default_icon_name()); 185 } 186 187 /** 188 * Returns a list of all existing toplevel windows. 189 * 190 * If you want to iterate through the list and perform actions involving 191 * callbacks that might destroy the widgets or add new ones, be aware that 192 * the list of toplevels will change and emit the "items-changed" signal. 193 * 194 * Returns: the list 195 * of toplevel widgets 196 */ 197 public static ListModelIF getToplevels() 198 { 199 auto __p = gtk_window_get_toplevels(); 200 201 if(__p is null) 202 { 203 return null; 204 } 205 206 return ObjectG.getDObject!(ListModelIF)(cast(GListModel*) __p); 207 } 208 209 /** 210 * Returns a list of all existing toplevel windows. 211 * 212 * The widgets in the list are not individually referenced. 213 * If you want to iterate through the list and perform actions 214 * involving callbacks that might destroy the widgets, you must 215 * call `g_list_foreach (result, (GFunc)g_object_ref, NULL)` first, 216 * and then unref all the widgets afterwards. 217 * 218 * Returns: list of 219 * toplevel widgets 220 */ 221 public static ListG listToplevels() 222 { 223 auto __p = gtk_window_list_toplevels(); 224 225 if(__p is null) 226 { 227 return null; 228 } 229 230 return new ListG(cast(GList*) __p); 231 } 232 233 /** 234 * Sets whether the window should request startup notification. 235 * 236 * By default, after showing the first `GtkWindow`, GTK calls 237 * [method@Gdk.Display.notify_startup_complete]. Call this function 238 * to disable the automatic startup notification. You might do this 239 * if your first window is a splash screen, and you want to delay 240 * notification until after your real main window has been shown, 241 * for example. 242 * 243 * In that example, you would disable startup notification 244 * temporarily, show your splash screen, then re-enable it so that 245 * showing the main window would automatically result in notification. 246 * 247 * Params: 248 * setting = %TRUE to automatically do startup notification 249 */ 250 public static void setAutoStartupNotification(bool setting) 251 { 252 gtk_window_set_auto_startup_notification(setting); 253 } 254 255 /** 256 * Sets an icon to be used as fallback. 257 * 258 * The fallback icon is used for windows that 259 * haven't had [method@Gtk.Window.set_icon_name] 260 * called on them. 261 * 262 * Params: 263 * name = the name of the themed icon 264 */ 265 public static void setDefaultIconName(string name) 266 { 267 gtk_window_set_default_icon_name(Str.toStringz(name)); 268 } 269 270 /** 271 * Opens or closes the [interactive debugger](#interactive-debugging). 272 * 273 * The debugger offers access to the widget hierarchy of the application 274 * and to useful debugging tools. 275 * 276 * Params: 277 * enable = %TRUE to enable interactive debugging 278 */ 279 public static void setInteractiveDebugging(bool enable) 280 { 281 gtk_window_set_interactive_debugging(enable); 282 } 283 284 /** 285 * Requests that the window is closed. 286 * 287 * This is similar to what happens when a window manager 288 * close button is clicked. 289 * 290 * This function can be used with close buttons in custom 291 * titlebars. 292 */ 293 public void close() 294 { 295 gtk_window_close(gtkWindow); 296 } 297 298 /** 299 * Drop the internal reference GTK holds on toplevel windows. 300 */ 301 public void destroy() 302 { 303 gtk_window_destroy(gtkWindow); 304 } 305 306 /** 307 * Asks to place @window in the fullscreen state. 308 * 309 * Note that you shouldn’t assume the window is definitely fullscreen 310 * afterward, because other entities (e.g. the user or window manager 311 * unfullscreen it again, and not all window managers honor requests 312 * to fullscreen windows. 313 * 314 * You can track the result of this operation via the 315 * [property@Gdk.Toplevel:state] property, or by listening to 316 * notifications of the [property@Gtk.Window:fullscreened] property. 317 */ 318 public void fullscreen() 319 { 320 gtk_window_fullscreen(gtkWindow); 321 } 322 323 /** 324 * Asks to place @window in the fullscreen state on the given @monitor. 325 * 326 * Note that you shouldn't assume the window is definitely fullscreen 327 * afterward, or that the windowing system allows fullscreen windows on 328 * any given monitor. 329 * 330 * You can track the result of this operation via the 331 * [property@Gdk.Toplevel:state] property, or by listening to 332 * notifications of the [property@Gtk.Window:fullscreened] property. 333 * 334 * Params: 335 * monitor = which monitor to go fullscreen on 336 */ 337 public void fullscreenOnMonitor(MonitorGdk monitor) 338 { 339 gtk_window_fullscreen_on_monitor(gtkWindow, (monitor is null) ? null : monitor.getMonitorGdkStruct()); 340 } 341 342 /** 343 * Gets the `GtkApplication` associated with the window. 344 * 345 * Returns: a `GtkApplication`, or %NULL 346 */ 347 public Application getApplication() 348 { 349 auto __p = gtk_window_get_application(gtkWindow); 350 351 if(__p is null) 352 { 353 return null; 354 } 355 356 return ObjectG.getDObject!(Application)(cast(GtkApplication*) __p); 357 } 358 359 /** 360 * Gets the child widget of @window. 361 * 362 * Returns: the child widget of @window 363 */ 364 public Widget getChild() 365 { 366 auto __p = gtk_window_get_child(gtkWindow); 367 368 if(__p is null) 369 { 370 return null; 371 } 372 373 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p); 374 } 375 376 /** 377 * Returns whether the window has been set to have decorations. 378 * 379 * Returns: %TRUE if the window has been set to have decorations 380 */ 381 public bool getDecorated() 382 { 383 return gtk_window_get_decorated(gtkWindow) != 0; 384 } 385 386 /** 387 * Gets the default size of the window. 388 * 389 * A value of 0 for the width or height indicates that a default 390 * size has not been explicitly set for that dimension, so the 391 * “natural” size of the window will be used. 392 * 393 * Params: 394 * width = location to store the default width, or %NULL 395 * height = location to store the default height, or %NULL 396 */ 397 public void getDefaultSize(out int width, out int height) 398 { 399 gtk_window_get_default_size(gtkWindow, &width, &height); 400 } 401 402 /** 403 * Returns the default widget for @window. 404 * 405 * Returns: the default widget, or %NULL 406 * if there is none. 407 */ 408 public Widget getDefaultWidget() 409 { 410 auto __p = gtk_window_get_default_widget(gtkWindow); 411 412 if(__p is null) 413 { 414 return null; 415 } 416 417 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p); 418 } 419 420 /** 421 * Returns whether the window has been set to have a close button. 422 * 423 * Returns: %TRUE if the window has been set to have a close button 424 */ 425 public bool getDeletable() 426 { 427 return gtk_window_get_deletable(gtkWindow) != 0; 428 } 429 430 /** 431 * Returns whether the window will be destroyed with its transient parent. 432 * 433 * Returns: %TRUE if the window will be destroyed with its transient parent. 434 */ 435 public bool getDestroyWithParent() 436 { 437 return gtk_window_get_destroy_with_parent(gtkWindow) != 0; 438 } 439 440 /** 441 * Retrieves the current focused widget within the window. 442 * 443 * Note that this is the widget that would have the focus 444 * if the toplevel window focused; if the toplevel window 445 * is not focused then `gtk_widget_has_focus (widget)` will 446 * not be %TRUE for the widget. 447 * 448 * Returns: the currently focused widget, 449 * or %NULL if there is none. 450 */ 451 public Widget getFocus() 452 { 453 auto __p = gtk_window_get_focus(gtkWindow); 454 455 if(__p is null) 456 { 457 return null; 458 } 459 460 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p); 461 } 462 463 /** 464 * Gets whether “focus rectangles” are supposed to be visible. 465 * 466 * Returns: %TRUE if “focus rectangles” are supposed to be visible 467 * in this window. 468 */ 469 public bool getFocusVisible() 470 { 471 return gtk_window_get_focus_visible(gtkWindow) != 0; 472 } 473 474 /** 475 * Returns the group for @window. 476 * 477 * If the window has no group, then the default group is returned. 478 * 479 * Returns: the `GtkWindowGroup` for a window 480 * or the default group 481 */ 482 public WindowGroup getGroup() 483 { 484 auto __p = gtk_window_get_group(gtkWindow); 485 486 if(__p is null) 487 { 488 return null; 489 } 490 491 return ObjectG.getDObject!(WindowGroup)(cast(GtkWindowGroup*) __p); 492 } 493 494 /** 495 * Returns whether this window reacts to F10 key presses by 496 * activating a menubar it contains. 497 * 498 * Returns: %TRUE if the window handles F10 499 * 500 * Since: 4.2 501 */ 502 public bool getHandleMenubarAccel() 503 { 504 return gtk_window_get_handle_menubar_accel(gtkWindow) != 0; 505 } 506 507 /** 508 * Returns whether the window will be hidden when the close button is clicked. 509 * 510 * Returns: %TRUE if the window will be hidden 511 */ 512 public bool getHideOnClose() 513 { 514 return gtk_window_get_hide_on_close(gtkWindow) != 0; 515 } 516 517 /** 518 * Returns the name of the themed icon for the window. 519 * 520 * Returns: the icon name or %NULL if the window has 521 * no themed icon 522 */ 523 public string getIconName() 524 { 525 return Str.toString(gtk_window_get_icon_name(gtkWindow)); 526 } 527 528 /** 529 * Gets whether mnemonics are supposed to be visible. 530 * 531 * Returns: %TRUE if mnemonics are supposed to be visible 532 * in this window. 533 */ 534 public bool getMnemonicsVisible() 535 { 536 return gtk_window_get_mnemonics_visible(gtkWindow) != 0; 537 } 538 539 /** 540 * Returns whether the window is modal. 541 * 542 * Returns: %TRUE if the window is set to be modal and 543 * establishes a grab when shown 544 */ 545 public bool getModal() 546 { 547 return gtk_window_get_modal(gtkWindow) != 0; 548 } 549 550 /** 551 * Gets the value set by gtk_window_set_resizable(). 552 * 553 * Returns: %TRUE if the user can resize the window 554 */ 555 public bool getResizable() 556 { 557 return gtk_window_get_resizable(gtkWindow) != 0; 558 } 559 560 /** 561 * Retrieves the title of the window. 562 * 563 * Returns: the title of the window, or %NULL if none has 564 * been set explicitly. The returned string is owned by the widget 565 * and must not be modified or freed. 566 */ 567 public string getTitle() 568 { 569 return Str.toString(gtk_window_get_title(gtkWindow)); 570 } 571 572 /** 573 * Returns the custom titlebar that has been set with 574 * gtk_window_set_titlebar(). 575 * 576 * Returns: the custom titlebar, or %NULL 577 */ 578 public Widget getTitlebar() 579 { 580 auto __p = gtk_window_get_titlebar(gtkWindow); 581 582 if(__p is null) 583 { 584 return null; 585 } 586 587 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p); 588 } 589 590 /** 591 * Fetches the transient parent for this window. 592 * 593 * Returns: the transient parent for this 594 * window, or %NULL if no transient parent has been set. 595 */ 596 public Window getTransientFor() 597 { 598 auto __p = gtk_window_get_transient_for(gtkWindow); 599 600 if(__p is null) 601 { 602 return null; 603 } 604 605 return ObjectG.getDObject!(Window)(cast(GtkWindow*) __p); 606 } 607 608 /** 609 * Returns whether @window has an explicit window group. 610 * 611 * Returns: %TRUE if @window has an explicit window group. 612 */ 613 public bool hasGroup() 614 { 615 return gtk_window_has_group(gtkWindow) != 0; 616 } 617 618 /** 619 * Returns whether the window is part of the current active toplevel. 620 * 621 * The active toplevel is the window receiving keystrokes. 622 * 623 * The return value is %TRUE if the window is active toplevel itself. 624 * You might use this function if you wanted to draw a widget 625 * differently in an active window from a widget in an inactive window. 626 * 627 * Returns: %TRUE if the window part of the current active window. 628 */ 629 public bool isActive() 630 { 631 return gtk_window_is_active(gtkWindow) != 0; 632 } 633 634 /** 635 * Retrieves the current fullscreen state of @window. 636 * 637 * Note that since fullscreening is ultimately handled by the window 638 * manager and happens asynchronously to an application request, you 639 * shouldn’t assume the return value of this function changing 640 * immediately (or at all), as an effect of calling 641 * [method@Gtk.Window.fullscreen] or [method@Gtk.Window.unfullscreen]. 642 * 643 * If the window isn't yet mapped, the value returned will whether the 644 * initial requested state is fullscreen. 645 * 646 * Returns: whether the window has a fullscreen state. 647 */ 648 public bool isFullscreen() 649 { 650 return gtk_window_is_fullscreen(gtkWindow) != 0; 651 } 652 653 /** 654 * Retrieves the current maximized state of @window. 655 * 656 * Note that since maximization is ultimately handled by the window 657 * manager and happens asynchronously to an application request, you 658 * shouldn’t assume the return value of this function changing 659 * immediately (or at all), as an effect of calling 660 * [method@Gtk.Window.maximize] or [method@Gtk.Window.unmaximize]. 661 * 662 * If the window isn't yet mapped, the value returned will whether the 663 * initial requested state is maximized. 664 * 665 * Returns: whether the window has a maximized state. 666 */ 667 public bool isMaximized() 668 { 669 return gtk_window_is_maximized(gtkWindow) != 0; 670 } 671 672 /** 673 * Asks to maximize @window, so that it fills the screen. 674 * 675 * Note that you shouldn’t assume the window is definitely maximized 676 * afterward, because other entities (e.g. the user or window manager 677 * could unmaximize it again, and not all window managers support 678 * maximization. 679 * 680 * It’s permitted to call this function before showing a window, 681 * in which case the window will be maximized when it appears onscreen 682 * initially. 683 * 684 * You can track the result of this operation via the 685 * [property@Gdk.Toplevel:state] property, or by listening to 686 * notifications on the [property@Gtk.Window:maximized] 687 * property. 688 */ 689 public void maximize() 690 { 691 gtk_window_maximize(gtkWindow); 692 } 693 694 /** 695 * Asks to minimize the specified @window. 696 * 697 * Note that you shouldn’t assume the window is definitely minimized 698 * afterward, because the windowing system might not support this 699 * functionality; other entities (e.g. the user or the window manager 700 * could unminimize it again, or there may not be a window manager in 701 * which case minimization isn’t possible, etc. 702 * 703 * It’s permitted to call this function before showing a window, 704 * in which case the window will be minimized before it ever appears 705 * onscreen. 706 * 707 * You can track result of this operation via the 708 * [property@Gdk.Toplevel:state] property. 709 */ 710 public void minimize() 711 { 712 gtk_window_minimize(gtkWindow); 713 } 714 715 /** 716 * Presents a window to the user. 717 * 718 * This function should not be used as when it is called, 719 * it is too late to gather a valid timestamp to allow focus 720 * stealing prevention to work correctly. 721 */ 722 public void present() 723 { 724 gtk_window_present(gtkWindow); 725 } 726 727 /** 728 * Presents a window to the user. 729 * 730 * This may mean raising the window in the stacking order, 731 * unminimizing it, moving it to the current desktop, and/or 732 * giving it the keyboard focus, possibly dependent on the user’s 733 * platform, window manager, and preferences. 734 * 735 * If @window is hidden, this function calls [method@Gtk.Widget.show] 736 * as well. 737 * 738 * This function should be used when the user tries to open a window 739 * that’s already open. Say for example the preferences dialog is 740 * currently open, and the user chooses Preferences from the menu 741 * a second time; use [method@Gtk.Window.present] to move the 742 * already-open dialog where the user can see it. 743 * 744 * Presents a window to the user in response to a user interaction. 745 * The timestamp should be gathered when the window was requested 746 * to be shown (when clicking a link for example), rather than once 747 * the window is ready to be shown. 748 * 749 * Params: 750 * timestamp = the timestamp of the user interaction (typically a 751 * button or key press event) which triggered this call 752 */ 753 public void presentWithTime(uint timestamp) 754 { 755 gtk_window_present_with_time(gtkWindow, timestamp); 756 } 757 758 /** 759 * Sets or unsets the `GtkApplication` associated with the window. 760 * 761 * The application will be kept alive for at least as long as it has 762 * any windows associated with it (see g_application_hold() for a way 763 * to keep it alive without windows). 764 * 765 * Normally, the connection between the application and the window will 766 * remain until the window is destroyed, but you can explicitly remove 767 * it by setting the @application to %NULL. 768 * 769 * This is equivalent to calling [method@Gtk.Application.remove_window] 770 * and/or [method@Gtk.Application.add_window] on the old/new applications 771 * as relevant. 772 * 773 * Params: 774 * application = a `GtkApplication`, or %NULL to unset 775 */ 776 public void setApplication(Application application) 777 { 778 gtk_window_set_application(gtkWindow, (application is null) ? null : application.getGtkApplicationStruct()); 779 } 780 781 /** 782 * Sets the child widget of @window. 783 * 784 * Params: 785 * child = the child widget 786 */ 787 public void setChild(Widget child) 788 { 789 gtk_window_set_child(gtkWindow, (child is null) ? null : child.getWidgetStruct()); 790 } 791 792 /** 793 * Sets whether the window should be decorated. 794 * 795 * By default, windows are decorated with a title bar, resize 796 * controls, etc. Some window managers allow GTK to disable these 797 * decorations, creating a borderless window. If you set the decorated 798 * property to %FALSE using this function, GTK will do its best to 799 * convince the window manager not to decorate the window. Depending on 800 * the system, this function may not have any effect when called on a 801 * window that is already visible, so you should call it before calling 802 * [method@Gtk.Widget.show]. 803 * 804 * On Windows, this function always works, since there’s no window manager 805 * policy involved. 806 * 807 * Params: 808 * setting = %TRUE to decorate the window 809 */ 810 public void setDecorated(bool setting) 811 { 812 gtk_window_set_decorated(gtkWindow, setting); 813 } 814 815 /** 816 * Sets the default size of a window. 817 * 818 * If the window’s “natural” size (its size request) is larger than 819 * the default, the default will be ignored. 820 * 821 * Unlike [method@Gtk.Widget.set_size_request], which sets a size 822 * request for a widget and thus would keep users from shrinking 823 * the window, this function only sets the initial size, just as 824 * if the user had resized the window themselves. Users can still 825 * shrink the window again as they normally would. Setting a default 826 * size of -1 means to use the “natural” default size (the size request 827 * of the window). 828 * 829 * The default size of a window only affects the first time a window is 830 * shown; if a window is hidden and re-shown, it will remember the size 831 * it had prior to hiding, rather than using the default size. 832 * 833 * Windows can’t actually be 0x0 in size, they must be at least 1x1, but 834 * passing 0 for @width and @height is OK, resulting in a 1x1 default size. 835 * 836 * If you use this function to reestablish a previously saved window size, 837 * note that the appropriate size to save is the one returned by 838 * [method@Gtk.Window.get_default_size]. Using the window allocation 839 * directly will not work in all circumstances and can lead to growing 840 * or shrinking windows. 841 * 842 * Params: 843 * width = width in pixels, or -1 to unset the default width 844 * height = height in pixels, or -1 to unset the default height 845 */ 846 public void setDefaultSize(int width, int height) 847 { 848 gtk_window_set_default_size(gtkWindow, width, height); 849 } 850 851 /** 852 * Sets the default widget. 853 * 854 * The default widget is the widget that is activated when the user 855 * presses Enter in a dialog (for example). 856 * 857 * Params: 858 * defaultWidget = widget to be the default, or %NULL 859 * to unset the default widget for the toplevel 860 */ 861 public void setDefaultWidget(Widget defaultWidget) 862 { 863 gtk_window_set_default_widget(gtkWindow, (defaultWidget is null) ? null : defaultWidget.getWidgetStruct()); 864 } 865 866 /** 867 * Sets whether the window should be deletable. 868 * 869 * By default, windows have a close button in the window frame. 870 * Some window managers allow GTK to disable this button. If you 871 * set the deletable property to %FALSE using this function, GTK 872 * will do its best to convince the window manager not to show a 873 * close button. Depending on the system, this function may not 874 * have any effect when called on a window that is already visible, 875 * so you should call it before calling [method@Gtk.Widget.show]. 876 * 877 * On Windows, this function always works, since there’s no window 878 * manager policy involved. 879 * 880 * Params: 881 * setting = %TRUE to decorate the window as deletable 882 */ 883 public void setDeletable(bool setting) 884 { 885 gtk_window_set_deletable(gtkWindow, setting); 886 } 887 888 /** 889 * If @setting is %TRUE, then destroying the transient parent of @window 890 * will also destroy @window itself. 891 * 892 * This is useful for dialogs that shouldn’t persist beyond the lifetime 893 * of the main window they are associated with, for example. 894 * 895 * Params: 896 * setting = whether to destroy @window with its transient parent 897 */ 898 public void setDestroyWithParent(bool setting) 899 { 900 gtk_window_set_destroy_with_parent(gtkWindow, setting); 901 } 902 903 /** 904 * Sets the `GdkDisplay` where the @window is displayed. 905 * 906 * If the window is already mapped, it will be unmapped, 907 * and then remapped on the new display. 908 * 909 * Params: 910 * display = a `GdkDisplay` 911 */ 912 public void setDisplay(Display display) 913 { 914 gtk_window_set_display(gtkWindow, (display is null) ? null : display.getDisplayStruct()); 915 } 916 917 /** 918 * Sets the focus widget. 919 * 920 * If @focus is not the current focus widget, and is focusable, 921 * sets it as the focus widget for the window. If @focus is %NULL, 922 * unsets the focus widget for this window. To set the focus to a 923 * particular widget in the toplevel, it is usually more convenient 924 * to use [method@Gtk.Widget.grab_focus] instead of this function. 925 * 926 * Params: 927 * focus = widget to be the new focus widget, or %NULL to unset 928 * any focus widget for the toplevel window. 929 */ 930 public void setFocus(Widget focus) 931 { 932 gtk_window_set_focus(gtkWindow, (focus is null) ? null : focus.getWidgetStruct()); 933 } 934 935 /** 936 * Sets whether “focus rectangles” are supposed to be visible. 937 * 938 * Params: 939 * setting = the new value 940 */ 941 public void setFocusVisible(bool setting) 942 { 943 gtk_window_set_focus_visible(gtkWindow, setting); 944 } 945 946 /** 947 * Sets whether this window should react to F10 key presses 948 * by activating a menubar it contains. 949 * 950 * Params: 951 * handleMenubarAccel = %TRUE to make @window handle F10 952 * 953 * Since: 4.2 954 */ 955 public void setHandleMenubarAccel(bool handleMenubarAccel) 956 { 957 gtk_window_set_handle_menubar_accel(gtkWindow, handleMenubarAccel); 958 } 959 960 /** 961 * If @setting is %TRUE, then clicking the close button on the window 962 * will not destroy it, but only hide it. 963 * 964 * Params: 965 * setting = whether to hide the window when it is closed 966 */ 967 public void setHideOnClose(bool setting) 968 { 969 gtk_window_set_hide_on_close(gtkWindow, setting); 970 } 971 972 /** 973 * Sets the icon for the window from a named themed icon. 974 * 975 * See the docs for [class@Gtk.IconTheme] for more details. 976 * On some platforms, the window icon is not used at all. 977 * 978 * Note that this has nothing to do with the WM_ICON_NAME 979 * property which is mentioned in the ICCCM. 980 * 981 * Params: 982 * name = the name of the themed icon 983 */ 984 public void setIconName(string name) 985 { 986 gtk_window_set_icon_name(gtkWindow, Str.toStringz(name)); 987 } 988 989 /** 990 * Sets whether mnemonics are supposed to be visible. 991 * 992 * Params: 993 * setting = the new value 994 */ 995 public void setMnemonicsVisible(bool setting) 996 { 997 gtk_window_set_mnemonics_visible(gtkWindow, setting); 998 } 999 1000 /** 1001 * Sets a window modal or non-modal. 1002 * 1003 * Modal windows prevent interaction with other windows in the same 1004 * application. To keep modal dialogs on top of main application windows, 1005 * use [method@Gtk.Window.set_transient_for] to make the dialog transient 1006 * for the parent; most window managers will then disallow lowering the 1007 * dialog below the parent. 1008 * 1009 * Params: 1010 * modal = whether the window is modal 1011 */ 1012 public void setModal(bool modal) 1013 { 1014 gtk_window_set_modal(gtkWindow, modal); 1015 } 1016 1017 /** 1018 * Sets whether the user can resize a window. 1019 * 1020 * Windows are user resizable by default. 1021 * 1022 * Params: 1023 * resizable = %TRUE if the user can resize this window 1024 */ 1025 public void setResizable(bool resizable) 1026 { 1027 gtk_window_set_resizable(gtkWindow, resizable); 1028 } 1029 1030 /** 1031 * Sets the startup notification ID. 1032 * 1033 * Startup notification identifiers are used by desktop environment 1034 * to track application startup, to provide user feedback and other 1035 * features. This function changes the corresponding property on the 1036 * underlying `GdkSurface`. 1037 * 1038 * Normally, startup identifier is managed automatically and you should 1039 * only use this function in special cases like transferring focus from 1040 * other processes. You should use this function before calling 1041 * [method@Gtk.Window.present] or any equivalent function generating 1042 * a window map event. 1043 * 1044 * This function is only useful on X11, not with other GTK targets. 1045 * 1046 * Params: 1047 * startupId = a string with startup-notification identifier 1048 */ 1049 public void setStartupId(string startupId) 1050 { 1051 gtk_window_set_startup_id(gtkWindow, Str.toStringz(startupId)); 1052 } 1053 1054 /** 1055 * Sets the title of the `GtkWindow`. 1056 * 1057 * The title of a window will be displayed in its title bar; on the 1058 * X Window System, the title bar is rendered by the window manager 1059 * so exactly how the title appears to users may vary according to a 1060 * user’s exact configuration. The title should help a user distinguish 1061 * this window from other windows they may have open. A good title might 1062 * include the application name and current document filename, for example. 1063 * 1064 * Passing %NULL does the same as setting the title to an empty string. 1065 * 1066 * Params: 1067 * title = title of the window 1068 */ 1069 public void setTitle(string title) 1070 { 1071 gtk_window_set_title(gtkWindow, Str.toStringz(title)); 1072 } 1073 1074 /** 1075 * Sets a custom titlebar for @window. 1076 * 1077 * A typical widget used here is [class@Gtk.HeaderBar], as it 1078 * provides various features expected of a titlebar while allowing 1079 * the addition of child widgets to it. 1080 * 1081 * If you set a custom titlebar, GTK will do its best to convince 1082 * the window manager not to put its own titlebar on the window. 1083 * Depending on the system, this function may not work for a window 1084 * that is already visible, so you set the titlebar before calling 1085 * [method@Gtk.Widget.show]. 1086 * 1087 * Params: 1088 * titlebar = the widget to use as titlebar 1089 */ 1090 public void setTitlebar(Widget titlebar) 1091 { 1092 gtk_window_set_titlebar(gtkWindow, (titlebar is null) ? null : titlebar.getWidgetStruct()); 1093 } 1094 1095 /** 1096 * Dialog windows should be set transient for the main application 1097 * window they were spawned from. This allows window managers to e.g. 1098 * keep the dialog on top of the main window, or center the dialog 1099 * over the main window. [ctor@Gtk.Dialog.new_with_buttons] and other 1100 * convenience functions in GTK will sometimes call 1101 * gtk_window_set_transient_for() on your behalf. 1102 * 1103 * Passing %NULL for @parent unsets the current transient window. 1104 * 1105 * On Windows, this function puts the child window on top of the parent, 1106 * much as the window manager would have done on X. 1107 * 1108 * Params: 1109 * parent = parent window, or %NULL 1110 */ 1111 public void setTransientFor(Window parent) 1112 { 1113 gtk_window_set_transient_for(gtkWindow, (parent is null) ? null : parent.getWindowStruct()); 1114 } 1115 1116 /** 1117 * Asks to remove the fullscreen state for @window, and return to 1118 * its previous state. 1119 * 1120 * Note that you shouldn’t assume the window is definitely not 1121 * fullscreen afterward, because other entities (e.g. the user or 1122 * window manager could fullscreen it again, and not all window 1123 * managers honor requests to unfullscreen windows; normally the 1124 * window will end up restored to its normal state. Just don’t 1125 * write code that crashes if not. 1126 * 1127 * You can track the result of this operation via the 1128 * [property@Gdk.Toplevel:state] property, or by listening to 1129 * notifications of the [property@Gtk.Window:fullscreened] property. 1130 */ 1131 public void unfullscreen() 1132 { 1133 gtk_window_unfullscreen(gtkWindow); 1134 } 1135 1136 /** 1137 * Asks to unmaximize @window. 1138 * 1139 * Note that you shouldn’t assume the window is definitely unmaximized 1140 * afterward, because other entities (e.g. the user or window manager 1141 * maximize it again, and not all window managers honor requests to 1142 * unmaximize. 1143 * 1144 * You can track the result of this operation via the 1145 * [property@Gdk.Toplevel:state] property, or by listening to 1146 * notifications on the [property@Gtk.Window:maximized] property. 1147 */ 1148 public void unmaximize() 1149 { 1150 gtk_window_unmaximize(gtkWindow); 1151 } 1152 1153 /** 1154 * Asks to unminimize the specified @window. 1155 * 1156 * Note that you shouldn’t assume the window is definitely unminimized 1157 * afterward, because the windowing system might not support this 1158 * functionality; other entities (e.g. the user or the window manager 1159 * could minimize it again, or there may not be a window manager in 1160 * which case minimization isn’t possible, etc. 1161 * 1162 * You can track result of this operation via the 1163 * [property@Gdk.Toplevel:state] property. 1164 */ 1165 public void unminimize() 1166 { 1167 gtk_window_unminimize(gtkWindow); 1168 } 1169 1170 /** 1171 * Emitted when the user activates the default widget 1172 * of @window. 1173 * 1174 * This is a [keybinding signal](class.SignalAction.html). 1175 */ 1176 gulong addOnActivateDefault(void delegate(Window) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1177 { 1178 return Signals.connect(this, "activate-default", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1179 } 1180 1181 /** 1182 * Emitted when the user activates the currently focused 1183 * widget of @window. 1184 * 1185 * This is a [keybinding signal](class.SignalAction.html). 1186 */ 1187 gulong addOnActivateFocus(void delegate(Window) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1188 { 1189 return Signals.connect(this, "activate-focus", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1190 } 1191 1192 /** 1193 * Emitted when the user clicks on the close button of the window. 1194 * 1195 * Returns: %TRUE to stop other handlers from being invoked for the signal 1196 */ 1197 gulong addOnCloseRequest(bool delegate(Window) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1198 { 1199 return Signals.connect(this, "close-request", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1200 } 1201 1202 /** 1203 * Emitted when the user enables or disables interactive debugging. 1204 * 1205 * When @toggle is %TRUE, interactive debugging is toggled on or off, 1206 * when it is %FALSE, the debugger will be pointed at the widget 1207 * under the pointer. 1208 * 1209 * This is a [keybinding signal](class.SignalAction.html). 1210 * 1211 * The default bindings for this signal are Ctrl-Shift-I 1212 * and Ctrl-Shift-D. 1213 * 1214 * Params: 1215 * toggle = toggle the debugger 1216 * 1217 * Returns: %TRUE if the key binding was handled 1218 */ 1219 gulong addOnEnableDebugging(bool delegate(bool, Window) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1220 { 1221 return Signals.connect(this, "enable-debugging", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1222 } 1223 1224 /** 1225 * emitted when the set of accelerators or mnemonics that 1226 * are associated with @window changes. 1227 */ 1228 gulong addOnKeysChanged(void delegate(Window) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1229 { 1230 return Signals.connect(this, "keys-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1231 } 1232 }