package ocgtk

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Wrappers.Window

type t = [ `window | `widget | `initially_unowned | `object_ ] Gobject.obj
val new_ : unit -> t

Create a new Window

val unminimize : t -> unit

Asks to unminimize the specified @window.

Note that you shouldn’t assume the window is definitely unminimized afterward, because the windowing system might not support this functionality; other entities (e.g. the user or the window manager) could minimize it again, or there may not be a window manager in which case minimization isn’t possible, etc.

You can track result of this operation via the property@Gdk.Toplevel:state property.

val unmaximize : t -> unit

Asks to unmaximize @window.

Note that you shouldn’t assume the window is definitely unmaximized afterward, because other entities (e.g. the user or window manager) maximize it again, and not all window managers honor requests to unmaximize.

You can track the result of this operation via the property@Gdk.Toplevel:state property, or by listening to notifications on the property@Gtk.Window:maximized property.

val unfullscreen : t -> unit

Asks to remove the fullscreen state for @window, and return to its previous state.

Note that you shouldn’t assume the window is definitely not fullscreen afterward, because other entities (e.g. the user or window manager) could fullscreen it again, and not all window managers honor requests to unfullscreen windows; normally the window will end up restored to its normal state. Just don’t write code that crashes if not.

You can track the result of this operation via the property@Gdk.Toplevel:state property, or by listening to notifications of the property@Gtk.Window:fullscreened property.

val set_transient_for : t -> t option -> unit

Dialog windows should be set transient for the main application window they were spawned from. This allows window managers to e.g. keep the dialog on top of the main window, or center the dialog over the main window. ctor@Gtk.Dialog.new_with_buttons and other convenience functions in GTK will sometimes call gtk_window_set_transient_for() on your behalf.

Passing %NULL for @parent unsets the current transient window.

On Windows, this function puts the child window on top of the parent, much as the window manager would have done on X.

val set_titlebar : t -> [ `widget | `initially_unowned | `object_ ] Gobject.obj option -> unit

Sets a custom titlebar for @window.

A typical widget used here is class@Gtk.HeaderBar, as it provides various features expected of a titlebar while allowing the addition of child widgets to it.

If you set a custom titlebar, GTK will do its best to convince the window manager not to put its own titlebar on the window. Depending on the system, this function may not work for a window that is already visible, so you set the titlebar before calling method@Gtk.Widget.show.

val set_title : t -> string option -> unit

Sets the title of the `GtkWindow`.

The title of a window will be displayed in its title bar; on the X Window System, the title bar is rendered by the window manager so exactly how the title appears to users may vary according to a user’s exact configuration. The title should help a user distinguish this window from other windows they may have open. A good title might include the application name and current document filename, for example.

Passing %NULL does the same as setting the title to an empty string.

val set_startup_id : t -> string -> unit

Sets the startup notification ID.

Startup notification identifiers are used by desktop environment to track application startup, to provide user feedback and other features. This function changes the corresponding property on the underlying `GdkSurface`.

Normally, startup identifier is managed automatically and you should only use this function in special cases like transferring focus from other processes. You should use this function before calling method@Gtk.Window.present or any equivalent function generating a window map event.

This function is only useful on X11, not with other GTK targets.

val set_resizable : t -> bool -> unit

Sets whether the user can resize a window.

Windows are user resizable by default.

val set_modal : t -> bool -> unit

Sets a window modal or non-modal.

Modal windows prevent interaction with other windows in the same application. To keep modal dialogs on top of main application windows, use method@Gtk.Window.set_transient_for to make the dialog transient for the parent; most window managers will then disallow lowering the dialog below the parent.

val set_mnemonics_visible : t -> bool -> unit

Sets whether mnemonics are supposed to be visible.

This property is maintained by GTK based on user input, and should not be set by applications.

val set_icon_name : t -> string option -> unit

Sets the icon for the window from a named themed icon.

See the docs for class@Gtk.IconTheme for more details. On some platforms, the window icon is not used at all.

Note that this has nothing to do with the WM_ICON_NAME property which is mentioned in the ICCCM.

val set_hide_on_close : t -> bool -> unit

If @setting is %TRUE, then clicking the close button on the window will not destroy it, but only hide it.

val set_handle_menubar_accel : t -> bool -> unit

Sets whether this window should react to F10 key presses by activating a menubar it contains.

val set_focus_visible : t -> bool -> unit

Sets whether “focus rectangles” are supposed to be visible.

This property is maintained by GTK based on user input, and should not be set by applications.

val set_focus : t -> [ `widget | `initially_unowned | `object_ ] Gobject.obj option -> unit

Sets the focus widget.

If @focus is not the current focus widget, and is focusable, sets it as the focus widget for the window. If @focus is %NULL, unsets the focus widget for this window. To set the focus to a particular widget in the toplevel, it is usually more convenient to use method@Gtk.Widget.grab_focus instead of this function.

val set_display : t -> Ocgtk_gdk.Gdk.Wrappers.Display.t -> unit

Sets the `GdkDisplay` where the @window is displayed.

If the window is already mapped, it will be unmapped, and then remapped on the new display.

val set_destroy_with_parent : t -> bool -> unit

If @setting is %TRUE, then destroying the transient parent of @window will also destroy @window itself.

This is useful for dialogs that shouldn’t persist beyond the lifetime of the main window they are associated with, for example.

val set_deletable : t -> bool -> unit

Sets whether the window should be deletable.

By default, windows have a close button in the window frame. Some window managers allow GTK to disable this button. If you set the deletable property to %FALSE using this function, GTK will do its best to convince the window manager not to show a close button. Depending on the system, this function may not have any effect when called on a window that is already visible, so you should call it before calling method@Gtk.Widget.show.

On Windows, this function always works, since there’s no window manager policy involved.

val set_default_widget : t -> [ `widget | `initially_unowned | `object_ ] Gobject.obj option -> unit

Sets the default widget.

The default widget is the widget that is activated when the user presses Enter in a dialog (for example).

val set_default_size : t -> int -> int -> unit

Sets the default size of a window.

The default size of a window is the size that will be used if no other constraints apply.

The default size will be updated whenever the window is resized to reflect the new size, unless the window is forced to a size, like when it is maximized or fullscreened.

If the window’s minimum size request is larger than the default, the default will be ignored.

Setting the default size to a value <= 0 will cause it to be ignored and the natural size request will be used instead. It is possible to do this while the window is showing to "reset" it to its initial size.

Unlike method@Gtk.Widget.set_size_request, which sets a size request for a widget and thus would keep users from shrinking the window, this function only sets the initial size, just as if the user had resized the window themselves. Users can still shrink the window again as they normally would. Setting a default size of -1 means to use the “natural” default size (the size request of the window).

If you use this function to reestablish a previously saved window size, note that the appropriate size to save is the one returned by method@Gtk.Window.get_default_size. Using the window allocation directly will not work in all circumstances and can lead to growing or shrinking windows.

val set_decorated : t -> bool -> unit

Sets whether the window should be decorated.

By default, windows are decorated with a title bar, resize controls, etc. Some window managers allow GTK to disable these decorations, creating a borderless window. If you set the decorated property to %FALSE using this function, GTK will do its best to convince the window manager not to decorate the window. Depending on the system, this function may not have any effect when called on a window that is already visible, so you should call it before calling method@Gtk.Widget.show.

On Windows, this function always works, since there’s no window manager policy involved.

val set_child : t -> [ `widget | `initially_unowned | `object_ ] Gobject.obj option -> unit

Sets the child widget of @window.

val set_application : t -> [ `application | `object_ ] Gobject.obj option -> unit

Sets or unsets the `GtkApplication` associated with the window.

The application will be kept alive for at least as long as it has any windows associated with it (see g_application_hold() for a way to keep it alive without windows).

Normally, the connection between the application and the window will remain until the window is destroyed, but you can explicitly remove it by setting the @application to %NULL.

This is equivalent to calling method@Gtk.Application.remove_window and/or method@Gtk.Application.add_window on the old/new applications as relevant.

val present_with_time : t -> UInt32.t -> unit

Presents a window to the user in response to an user interaction.

See method@Gtk.Window.present for more details.

The timestamp should be gathered when the window was requested to be shown (when clicking a link for example), rather than once the window is ready to be shown.

val present : t -> unit

Presents a window to the user.

This may mean raising the window in the stacking order, unminimizing it, moving it to the current desktop and/or giving it the keyboard focus (possibly dependent on the user’s platform, window manager and preferences).

If @window is hidden, this function also makes it visible.

val minimize : t -> unit

Asks to minimize the specified @window.

Note that you shouldn’t assume the window is definitely minimized afterward, because the windowing system might not support this functionality; other entities (e.g. the user or the window manager) could unminimize it again, or there may not be a window manager in which case minimization isn’t possible, etc.

It’s permitted to call this function before showing a window, in which case the window will be minimized before it ever appears onscreen.

You can track result of this operation via the property@Gdk.Toplevel:state property.

val maximize : t -> unit

Asks to maximize @window, so that it fills the screen.

Note that you shouldn’t assume the window is definitely maximized afterward, because other entities (e.g. the user or window manager) could unmaximize it again, and not all window managers support maximization.

It’s permitted to call this function before showing a window, in which case the window will be maximized when it appears onscreen initially.

You can track the result of this operation via the property@Gdk.Toplevel:state property, or by listening to notifications on the property@Gtk.Window:maximized property.

val is_suspended : t -> bool

Retrieves the current suspended state of @window.

A window being suspended means it's currently not visible to the user, for example by being on a inactive workspace, minimized, obstructed.

val is_maximized : t -> bool

Retrieves the current maximized state of @window.

Note that since maximization is ultimately handled by the window manager and happens asynchronously to an application request, you shouldn’t assume the return value of this function changing immediately (or at all), as an effect of calling method@Gtk.Window.maximize or method@Gtk.Window.unmaximize.

If the window isn't yet mapped, the value returned will whether the initial requested state is maximized.

val is_fullscreen : t -> bool

Retrieves the current fullscreen state of @window.

Note that since fullscreening is ultimately handled by the window manager and happens asynchronously to an application request, you shouldn’t assume the return value of this function changing immediately (or at all), as an effect of calling method@Gtk.Window.fullscreen or method@Gtk.Window.unfullscreen.

If the window isn't yet mapped, the value returned will whether the initial requested state is fullscreen.

val is_active : t -> bool

Returns whether the window is part of the current active toplevel.

The active toplevel is the window receiving keystrokes.

The return value is %TRUE if the window is active toplevel itself. You might use this function if you wanted to draw a widget differently in an active window from a widget in an inactive window.

val has_group : t -> bool

Returns whether @window has an explicit window group.

val get_transient_for : t -> t option

Fetches the transient parent for this window.

val get_titlebar : t -> [ `widget | `initially_unowned | `object_ ] Gobject.obj option

Returns the custom titlebar that has been set with gtk_window_set_titlebar().

val get_title : t -> string option

Retrieves the title of the window.

val get_resizable : t -> bool

Gets the value set by gtk_window_set_resizable().

val get_modal : t -> bool

Returns whether the window is modal.

val get_mnemonics_visible : t -> bool

Gets whether mnemonics are supposed to be visible.

val get_icon_name : t -> string option

Returns the name of the themed icon for the window.

val get_hide_on_close : t -> bool

Returns whether the window will be hidden when the close button is clicked.

val get_handle_menubar_accel : t -> bool

Returns whether this window reacts to F10 key presses by activating a menubar it contains.

val get_group : t -> [ `window_group | `object_ ] Gobject.obj

Returns the group for @window.

If the window has no group, then the default group is returned.

val get_focus_visible : t -> bool

Gets whether “focus rectangles” are supposed to be visible.

val get_focus : t -> [ `widget | `initially_unowned | `object_ ] Gobject.obj option

Retrieves the current focused widget within the window.

Note that this is the widget that would have the focus if the toplevel window focused; if the toplevel window is not focused then `gtk_widget_has_focus (widget)` will not be %TRUE for the widget.

val get_destroy_with_parent : t -> bool

Returns whether the window will be destroyed with its transient parent.

val get_deletable : t -> bool

Returns whether the window has been set to have a close button.

val get_default_widget : t -> [ `widget | `initially_unowned | `object_ ] Gobject.obj option

Returns the default widget for @window.

val get_default_size : t -> int * int

Gets the default size of the window.

A value of 0 for the width or height indicates that a default size has not been explicitly set for that dimension, so the “natural” size of the window will be used.

This function is the recommended way for saving window state across restarts of applications(https://developer.gnome.org/documentation/tutorials/save-state.html).

val get_decorated : t -> bool

Returns whether the window has been set to have decorations.

val get_child : t -> [ `widget | `initially_unowned | `object_ ] Gobject.obj option

Gets the child widget of @window.

val get_application : t -> [ `application | `object_ ] Gobject.obj option

Gets the `GtkApplication` associated with the window.

val fullscreen_on_monitor : t -> Ocgtk_gdk.Gdk.Wrappers.Monitor.t -> unit

Asks to place @window in the fullscreen state on the given @monitor.

Note that you shouldn't assume the window is definitely fullscreen afterward, or that the windowing system allows fullscreen windows on any given monitor.

You can track the result of this operation via the property@Gdk.Toplevel:state property, or by listening to notifications of the property@Gtk.Window:fullscreened property.

val fullscreen : t -> unit

Asks to place @window in the fullscreen state.

Note that you shouldn’t assume the window is definitely fullscreen afterward, because other entities (e.g. the user or window manager) unfullscreen it again, and not all window managers honor requests to fullscreen windows.

You can track the result of this operation via the property@Gdk.Toplevel:state property, or by listening to notifications of the property@Gtk.Window:fullscreened property.

val destroy : t -> unit

Drop the internal reference GTK holds on toplevel windows.

val close : t -> unit

Requests that the window is closed.

This is similar to what happens when a window manager close button is clicked.

This function can be used with close buttons in custom titlebars.

val get_default_height : t -> int

Get property: default-height

val set_default_height : t -> int -> unit

Set property: default-height

val get_default_width : t -> int

Get property: default-width

val set_default_width : t -> int -> unit

Set property: default-width

val get_focus_widget : t -> [ `widget | `initially_unowned | `object_ ] Gobject.obj

Get property: focus-widget

val set_focus_widget : t -> [ `widget | `initially_unowned | `object_ ] Gobject.obj -> unit

Set property: focus-widget

val get_fullscreened : t -> bool

Get property: fullscreened

val set_fullscreened : t -> bool -> unit

Set property: fullscreened

val get_maximized : t -> bool

Get property: maximized

val set_maximized : t -> bool -> unit

Set property: maximized

val get_suspended : t -> bool

Get property: suspended

val on_activate_default : ?after:bool -> t -> callback:(unit -> unit) -> Gobject.Signal.handler_id
val on_activate_focus : ?after:bool -> t -> callback:(unit -> unit) -> Gobject.Signal.handler_id
val on_close_request : ?after:bool -> t -> callback:(unit -> bool) -> Gobject.Signal.handler_id
val on_enable_debugging : ?after:bool -> t -> callback:(toggle:bool -> bool) -> Gobject.Signal.handler_id
val on_keys_changed : ?after:bool -> t -> callback:(unit -> unit) -> Gobject.Signal.handler_id