file: application.aus

class: GtkApplicationWindowremovedCallback

[1094:7] extends: object

Generated low-level callback wrapper for GIR callback window-removed.

Members

Methods

class: GtkApplicationRestorewindowCallback

[880:7] extends: object

Generated low-level callback wrapper for GIR callback restore-window.

Members

Methods

class: GtkApplicationRestorestateCallback

[808:7] extends: object

Generated low-level callback wrapper for GIR callback restore-state.

Members

Methods

class: GtkApplicationMeta

[1165:14] static extends: object

Generated metadata helpers for Application class surfaces.

Methods

class: GtkApplication

[79:7] extends: object

A high-level API for writing applications. GtkApplication supports many aspects of writing a GTK application in a convenient fashion, without enforcing a one-size-fits-all model. Currently, it handles GTK initialization, application uniqueness, session management, provides some basic scriptability and desktop shell integration by exporting actions and menus and manages a list of toplevel windows whose life-cycle is automatically tied to the life-cycle of your application. While GtkApplication works fine with plain [class@Gtk.Window]s, it is recommended to use it together with [class@Gtk.ApplicationWindow]. ## Initialization A typical GtkApplication will create a window in its [signal@GIO.Application::activate], [signal@GIO.Application::open] or [signal@GIO.Application::command-line] handlers. Note that all of these signals may be emitted multiple times, so handlers must be careful to take existing windows into account. A typical ::activate handler should look like this: static void activate (GApplication *gapp) { GtkApplication *app = GTK_APPLICATION (gapp); GtkWindow *window; window = gtk_application_get_active_window (app); if (!window) window = create_window (app); gtk_window_present (window); } ## Automatic resources GtkApplication will automatically load menus from the GtkBuilder resource located at "gtk/menus.ui", relative to the application's resource base path (see [method@Gio.Application.set_resource_base_path]). The menu with the ID "menubar" is taken as the application's menubar. Additional menus (most interesting submenus) can be named and accessed via [method@Gtk.Application.get_menu_by_id] which allows for dynamic population of a part of the menu structure. Note that automatic resource loading uses the resource base path that is set at construction time and will not work if the resource base path is changed at a later time. It is also possible to provide the menubar manually using [method@Gtk.Application.set_menubar]. GtkApplication will also automatically setup an icon search path for the default icon theme by appending "icons" to the resource base path. This allows your application to easily store its icons as resources. See [method@Gtk.IconTheme.add_resource_path] for more information. If there is a resource located at gtk/help-overlay.ui which defines a [class@Gtk.ShortcutsWindow] with ID help_overlay then GtkApplication associates an instance of this shortcuts window with each [class@Gtk.ApplicationWindow] and sets up the keyboard accelerator Control+? to open it. To create a menu item that displays the shortcuts window, associate the item with the action win.show-help-overlay. GtkApplication will also automatically set the application id as the default window icon. Use [func@Gtk.Window.set_default_icon_name] or [property@Gtk.Window:icon-name] to override that behavior. ## State saving GtkApplication registers with a session manager if possible and offers various functionality related to the session life-cycle, such as state saving. State-saving functionality can be enabled by setting the [property@Gtk.Application:support-save] property to true. In order to save and restore per-window state, applications must connect to the [signal@Gtk.Application::restore-window] signal and handle the [signal@Gtk.ApplicationWindow::save-state] signal. There are also [signal@Gtk.Application::restore-state] and [signal@GtkApplication::save-state] signals, which can be used for global state that is not connected to any window. GtkApplication automatically saves state before app shutdown, and by default periodically auto-saves app state (as configured by the [property@Gtk.Application:autosave-interval] property). Applications can also call [method@Gtk.Application.save] themselves at opportune times. # Inhibiting An application can block various ways to end the session with the [method@Gtk.Application.inhibit] function. Typical use cases for this kind of inhibiting are long-running, uninterruptible operations, such as burning a CD or performing a disk backup. The session manager may not honor the inhibitor, but it can be expected to inform the user about the negative consequences of ending the session while inhibitors are present. ## A simple application A simple example is available in the GTK source code repository ## See Also - Using GtkApplication

Members

Methods

class: GtkApplicationSavestateCallback

[952:7] extends: object

Generated low-level callback wrapper for GIR callback save-state.

Members

Methods

class: GtkApplicationQueryendCallback

[738:7] extends: object

Generated low-level callback wrapper for GIR callback query-end.

Members

Methods

class: GtkApplicationWindowaddedCallback

[1023:7] extends: object

Generated low-level callback wrapper for GIR callback window-added.

Members

Methods