:right-sidebar: True Toplevel =================================================================== .. currentmodule:: gi.repository.Gdk .. class:: Toplevel(*args, **kwargs) :no-contents-entry: A ``GdkToplevel`` is a freestanding toplevel surface. The ``GdkToplevel`` interface provides useful APIs for interacting with the windowing system, such as controlling maximization and size of the surface, setting icons and transient parents for dialogs. Methods ------- .. rst-class:: interim-class .. class:: Toplevel :no-index: .. method:: begin_move(device: ~gi.repository.Gdk.Device, button: int, x: float, y: float, timestamp: int) -> None Begins an interactive move operation. You might use this function to implement draggable titlebars. :param device: the device used for the operation :param button: the button being used to drag, or 0 for a keyboard-initiated drag :param x: surface X coordinate of mouse click that began the drag :param y: surface Y coordinate of mouse click that began the drag :param timestamp: timestamp of mouse click that began the drag (use :obj:`~gi.repository.Gdk.Event.get_time`\) .. method:: begin_resize(edge: ~gi.repository.Gdk.SurfaceEdge, device: ~gi.repository.Gdk.Device | None, button: int, x: float, y: float, timestamp: int) -> None Begins an interactive resize operation. You might use this function to implement a “window resize grip.” :param edge: the edge or corner from which the drag is started :param device: the device used for the operation :param button: the button being used to drag, or 0 for a keyboard-initiated drag :param x: surface X coordinate of mouse click that began the drag :param y: surface Y coordinate of mouse click that began the drag :param timestamp: timestamp of mouse click that began the drag (use :obj:`~gi.repository.Gdk.Event.get_time`\) .. method:: focus(timestamp: int) -> None Sets keyboard focus to ``surface``\. In most cases, `gtk_window_present_with_time() <../gtk4/method.Window.present_with_time.html>`__ should be used on a `GtkWindow <../gtk4/class.Window.html>`__\, rather than calling this function. :param timestamp: timestamp of the event triggering the surface focus .. method:: get_state() -> ~gi.repository.Gdk.ToplevelState Gets the bitwise or of the currently active surface state flags, from the ``GdkToplevelState`` enumeration. .. method:: inhibit_system_shortcuts(event: ~gi.repository.Gdk.Event | None = None) -> None Requests that the ``toplevel`` inhibit the system shortcuts. This is asking the desktop environment/windowing system to let all keyboard events reach the surface, as long as it is focused, instead of triggering system actions. If granted, the rerouting remains active until the default shortcuts processing is restored with :obj:`~gi.repository.Gdk.Toplevel.restore_system_shortcuts`\, or the request is revoked by the desktop environment, windowing system or the user. A typical use case for this API is remote desktop or virtual machine viewers which need to inhibit the default system keyboard shortcuts so that the remote session or virtual host gets those instead of the local environment. The windowing system or desktop environment may ask the user to grant or deny the request or even choose to ignore the request entirely. The caller can be notified whenever the request is granted or revoked by listening to the :obj:`~gi.repository.Gdk.Toplevel.props.shortcuts_inhibited` property. :param event: the ``GdkEvent`` that is triggering the inhibit request, or :const:`None` if none is available .. method:: lower() -> bool Asks to lower the ``toplevel`` below other windows. The windowing system may choose to ignore the request. .. method:: minimize() -> bool Asks to minimize the ``toplevel``\. The windowing system may choose to ignore the request. .. method:: present(layout: ~gi.repository.Gdk.ToplevelLayout) -> None Present ``toplevel`` after having processed the ``GdkToplevelLayout`` rules. If the toplevel was previously not showing, it will be showed, otherwise it will change layout according to ``layout``\. GDK may emit the :obj:`~gi.repository.Gdk.Toplevel.signals.compute_size` signal to let the user of this toplevel compute the preferred size of the toplevel surface. Presenting is asynchronous and the specified layout parameters are not guaranteed to be respected. :param layout: the ``GdkToplevelLayout`` object used to layout .. method:: restore_system_shortcuts() -> None Restore default system keyboard shortcuts which were previously inhibited. This undoes the effect of :obj:`~gi.repository.Gdk.Toplevel.inhibit_system_shortcuts`\. .. method:: set_decorated(decorated: bool) -> None Sets the toplevel to be decorated. Setting ``decorated`` to :const:`False` hints the desktop environment that the surface has its own, client-side decorations and does not need to have window decorations added. :param decorated: :const:`True` to request decorations .. method:: set_deletable(deletable: bool) -> None Sets the toplevel to be deletable. Setting ``deletable`` to :const:`True` hints the desktop environment that it should offer the user a way to close the surface. :param deletable: :const:`True` to request a delete button .. method:: set_icon_list(surfaces: list[~gi.repository.Gdk.Texture]) -> None Sets a list of icons for the surface. One of these will be used to represent the surface in iconic form. The icon may be shown in window lists or task bars. Which icon size is shown depends on the window manager. The window manager can scale the icon but setting several size icons can give better image quality. Note that some platforms don't support surface icons. :param surfaces: A list of textures to use as icon, of different sizes .. method:: set_modal(modal: bool) -> None Sets the toplevel to be modal. The application can use this hint to tell the window manager that a certain surface has modal behaviour. The window manager can use this information to handle modal surfaces in a special way. You should only use this on surfaces for which you have previously called :obj:`~gi.repository.Gdk.Toplevel.set_transient_for`\. :param modal: :const:`True` if the surface is modal, :const:`False` otherwise. .. method:: set_startup_id(startup_id: str) -> None Sets the startup notification ID. When using GTK, typically you should use `gtk_window_set_startup_id() <../gtk4/method.Window.set_startup_id.html>`__ instead of this low-level function. :param startup_id: a string with startup-notification identifier .. method:: set_title(title: str) -> None Sets the title of a toplevel surface. The title maybe be displayed in the titlebar, in lists of windows, etc. :param title: title of ``surface`` .. method:: set_transient_for(parent: ~gi.repository.Gdk.Surface) -> None Sets a transient-for parent. Indicates to the window manager that ``surface`` is a transient dialog associated with the application surface ``parent``\. This allows the window manager to do things like center ``surface`` on ``parent`` and keep ``surface`` above ``parent``\. See `gtk_window_set_transient_for() <../gtk4/method.Window.set_transient_for.html>`__ if you’re using `GtkWindow <../gtk4/class.Window.html>`__\. :param parent: another toplevel ``GdkSurface`` .. method:: show_window_menu(event: ~gi.repository.Gdk.Event) -> bool Asks the windowing system to show the window menu. The window menu is the menu shown when right-clicking the titlebar on traditional windows managed by the window manager. This is useful for windows using client-side decorations, activating it with a right-click on the window decorations. :param event: a ``GdkEvent`` to show the menu for .. method:: supports_edge_constraints() -> bool Returns whether the desktop environment supports tiled window states. .. method:: titlebar_gesture(gesture: ~gi.repository.Gdk.TitlebarGesture) -> bool Performs a title bar gesture. .. versionadded:: 4.4 :param gesture: a ``GdkTitlebarGesture`` Properties ---------- .. rst-class:: interim-class .. class:: Toplevel :no-index: .. attribute:: props.decorated :type: bool The type of the None singleton. .. attribute:: props.deletable :type: bool The type of the None singleton. .. attribute:: props.fullscreen_mode :type: ~gi.repository.Gdk.FullscreenMode The type of the None singleton. .. attribute:: props.icon_list :type: ~typing.Any The type of the None singleton. .. attribute:: props.modal :type: bool The type of the None singleton. .. attribute:: props.shortcuts_inhibited :type: bool The type of the None singleton. .. attribute:: props.startup_id :type: str The type of the None singleton. .. attribute:: props.state :type: ~gi.repository.Gdk.ToplevelState The type of the None singleton. .. attribute:: props.title :type: str The type of the None singleton. .. attribute:: props.transient_for :type: ~gi.repository.Gdk.Surface The type of the None singleton. Signals ------- .. rst-class:: interim-class .. class:: Toplevel.signals :no-index: .. method:: compute_size(size: ~gi.repository.Gdk.ToplevelSize) -> None The type of the None singleton. :param size: a ``GdkToplevelSize``