Class: Gtk::Application
- Inherits:
-
Gio::Application
- Object
- Gio::Application
- Gtk::Application
- Defined in:
- (unknown)
Instance Method Summary collapse
-
#active_window ⇒ Gtk::Window
The currently focused window of the application.
-
#active_window=(active_window) ⇒ Gtk::Window
The currently focused window of the application.
-
#add_window(window) ⇒ nil
Adds a window to the application.
-
#get_accels_for_action(detailed_action_name) ⇒ Array<String>
Gets the accelerators that are currently associated with the given action.
-
#get_actions_for_accel(accel) ⇒ Array<String>
Returns the list of actions (possibly empty) that the accelerator maps to.
-
#get_menu_by_id(id) ⇒ Gio::Menu
Gets a menu from automatically loaded resources.
-
#get_window_by_id(id) ⇒ Gtk::Window
Returns the window with the given ID.
-
#inhibit(window, flags, reason) ⇒ Integer
Informs the session manager that certain types of actions should be inhibited.
-
#initialize(application_id, flags) ⇒ Gtk::Application
constructor
Creates a new application instance.
-
#list_action_descriptions ⇒ Array<String>
Lists the detailed action names which have associated accelerators.
-
#menubar ⇒ Gio::MenuModel
The menu model to be used for the application's menu bar.
-
#menubar=(menubar) ⇒ Gio::MenuModel
The menu model to be used for the application's menu bar.
-
#register_session=(register_session) ⇒ Boolean
Set this property to true to register with the session manager.
-
#register_session? ⇒ Boolean
Set this property to true to register with the session manager.
-
#remove_window(window) ⇒ nil
Remove a window from the application.
-
#screensaver_active=(screensaver_active) ⇒ Boolean
This property is true if GTK believes that the screensaver is currently active.
-
#screensaver_active? ⇒ Boolean
This property is true if GTK believes that the screensaver is currently active.
-
#set_accels_for_action(detailed_action_name, accels) ⇒ nil
Sets zero or more keyboard accelerators that will trigger the given action.
-
#uninhibit(cookie) ⇒ nil
Removes an inhibitor that has been previously established.
-
#windows ⇒ GLib::List<Gtk::Window>
Gets a list of the window associated with the application.
Constructor Details
#initialize(application_id, flags) ⇒ Gtk::Application
Creates a new application instance.
When using GtkApplication, it is not necessary to call [funcGtk.init]
manually. It is called as soon as the application gets registered as
the primary instance.
Concretely, [funcGtk.init] is called in the default handler for the
GApplication::startup signal. Therefore, GtkApplication subclasses
should always chain up in their [vfuncGIO.Application.startup] handler
before using any GTK API.
Note that commandline arguments are not passed to [funcGtk.init].
If application_id is not NULL, then it must be valid. See
[funcGio.Application.id_is_valid].
If no application ID is given then some features (most notably application
uniqueness) will be disabled.
Instance Method Details
#active_window ⇒ Gtk::Window
The currently focused window of the application.
#active_window=(active_window) ⇒ Gtk::Window
The currently focused window of the application.
#add_window(window) ⇒ nil
Adds a window to the application.
This call can only happen after the application has started;
typically, you should add new application windows in response
to the emission of the [signalGIO.Application::activate] signal.
This call is equivalent to setting the [propertyGtk.Window:application]
property of the window to application.
Normally, the connection between the application and the window
will remain until the window is destroyed, but you can explicitly
remove it with [methodGtk.Application.remove_window].
GTK will keep the application running as long as it has any windows.
#get_accels_for_action(detailed_action_name) ⇒ Array<String>
Gets the accelerators that are currently associated with
the given action.
#get_actions_for_accel(accel) ⇒ Array<String>
Returns the list of actions (possibly empty) that the accelerator maps to.
Each item in the list is a detailed action name in the usual form.
This might be useful to discover if an accel already exists in
order to prevent installation of a conflicting accelerator (from
an accelerator editor or a plugin system, for example). Note that
having more than one action per accelerator may not be a bad thing
and might make sense in cases where the actions never appear in the
same context.
In case there are no actions for a given accelerator, an empty array
is returned. NULL is never returned.
It is a programmer error to pass an invalid accelerator string.
If you are unsure, check it with [funcGtk.accelerator_parse] first.
#get_menu_by_id(id) ⇒ Gio::Menu
Gets a menu from automatically loaded resources.
See the section on Automatic resources
for more information.
#get_window_by_id(id) ⇒ Gtk::Window
Returns the window with the given ID.
The ID of a GtkApplicationWindow can be retrieved with
[methodGtk.ApplicationWindow.get_id].
#inhibit(window, flags, reason) ⇒ Integer
Informs the session manager that certain types of actions should be
inhibited.
This is not guaranteed to work on all platforms and for all types of
actions.
Applications should invoke this method when they begin an operation
that should not be interrupted, such as creating a CD or DVD. The
types of actions that may be blocked are specified by the flags
parameter. When the application completes the operation it should
call [methodGtk.Application.uninhibit] to remove the inhibitor. Note
that an application can have multiple inhibitors, and all of them must
be individually removed. Inhibitors are also cleared when the
application exits.
Applications should not expect that they will always be able to block
the action. In most cases, users will be given the option to force
the action to take place.
The reason message should be short and to the point.
If a window is given, the session manager may point the user to
this window to find out more about why the action is inhibited.
The cookie that is returned by this function should be used as an
argument to [methodGtk.Application.uninhibit] in order to remove
the request.
#list_action_descriptions ⇒ Array<String>
Lists the detailed action names which have associated accelerators.
See [methodGtk.Application.set_accels_for_action].
#menubar ⇒ Gio::MenuModel
The menu model to be used for the application's menu bar.
#menubar=(menubar) ⇒ Gio::MenuModel
The menu model to be used for the application's menu bar.
#register_session=(register_session) ⇒ Boolean
Set this property to true to register with the session manager.
This will make GTK track the session state (such as the
[propertyGtk.Application:screensaver-active] property).
#register_session? ⇒ Boolean
Set this property to true to register with the session manager.
This will make GTK track the session state (such as the
[propertyGtk.Application:screensaver-active] property).
#remove_window(window) ⇒ nil
Remove a window from the application.
If the window belongs to the application then this call is
equivalent to setting the [propertyGtk.Window:application]
property of the window to NULL.
The application may stop running as a result of a call to this
function, if the window was the last window of the application.
#screensaver_active=(screensaver_active) ⇒ Boolean
This property is true if GTK believes that the screensaver
is currently active.
Tracking the screensaver state is currently only supported on
Linux.
#screensaver_active? ⇒ Boolean
This property is true if GTK believes that the screensaver
is currently active.
Tracking the screensaver state is currently only supported on
Linux.
#set_accels_for_action(detailed_action_name, accels) ⇒ nil
Sets zero or more keyboard accelerators that will trigger the
given action.
The first item in accels will be the primary accelerator,
which may be displayed in the UI.
To remove all accelerators for an action, use an empty,
zero-terminated array for accels.
For the detailed_action_name, see [funcGio.Action.parse_detailed_name]
and [Gio.Action.print_detailed_name].
#uninhibit(cookie) ⇒ nil
Removes an inhibitor that has been previously established.
See [methodGtk.Application.inhibit].
Inhibitors are also cleared when the application exits.
#windows ⇒ GLib::List<Gtk::Window>
Gets a list of the window associated with the application.
The list is sorted by most recently focused window, such that the first
element is the currently focused window. (Useful for choosing a parent
for a transient window.)
The list that is returned should not be modified in any way. It will
only remain valid until the next focus change or window creation or
deletion.