Class: Gtk::Application
- Inherits:
-
Gio::Application
- Object
- Gio::Application
- Gtk::Application
- Defined in:
- lib/gtk3/application.rb
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
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
accelmaps to. -
#get_menu_by_id(id) ⇒ Gio::Menu
Gets a menu from automatically loaded resources.
-
#get_window_by_id(id) ⇒ Gtk::Window
Returns the [classGtk.ApplicationWindow] with the given ID.
-
#inhibit(window, flags, reason) ⇒ Integer
Inform the session manager that certain types of actions should be inhibited.
-
#initialize(*args) ⇒ Gtk::Application
constructor
Creates a new
GtkApplicationinstance. -
#initialize_raw ⇒ Gtk::Application
Creates a new
GtkApplicationinstance. -
#list_action_descriptions ⇒ Array<String>
Lists the detailed action names which have associated accelerators.
-
#menubar ⇒ Gio::MenuModel
The
GMenuModelto be used for the application's menu bar. -
#menubar=(menubar) ⇒ Gio::MenuModel
The
GMenuModelto be used for the application's menu bar. -
#register_session=(register_session) ⇒ Boolean
Set this property to
TRUEto register with the session manager. -
#register_session? ⇒ Boolean
Set this property to
TRUEto register with the session manager. -
#remove_window(window) ⇒ nil
Remove a window from
application. -
#screensaver_active=(screensaver_active) ⇒ Boolean
This property is
TRUEif GTK believes that the screensaver is currently active. -
#screensaver_active? ⇒ Boolean
This property is
TRUEif 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 [classGtk.Window] instances associated with
application.
Constructor Details
#initialize(*args) ⇒ Gtk::Application
Creates a new GtkApplication 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 GApplication::startup handler before using any GTK
API.
Note that commandline arguments are not passed to [funcGtk.init].
If application_id is not nil, then it must be valid. See
g_application_id_is_valid().
If no application ID is given then some features (most notably application uniqueness) will be disabled.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gtk3/application.rb', line 20 def initialize(*args) case args.size when 0 initialize_raw(nil, :flags_none) when 1 if args[0].is_a?(String) initialize_raw(args[0], :flags_none) else initialize_raw(nil, args[0]) end else initialize_raw(*args) end end |
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 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 GApplication::activate signal.
This call is equivalent to setting the [propertyGtk.Window:application]
property of 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 accel 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 [classGtk.ApplicationWindow] with the given ID.
The ID of a GtkApplicationWindow can be retrieved with
[methodGtk.ApplicationWindow.get_id].
#inhibit(window, flags, reason) ⇒ Integer
Inform 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 window is given, the session manager may point the user to
this window to find out more about why the action is inhibited.
#initialize_raw ⇒ Gtk::Application
Creates a new GtkApplication 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 GApplication::startup handler before using any GTK
API.
Note that commandline arguments are not passed to [funcGtk.init].
If application_id is not nil, then it must be valid. See
g_application_id_is_valid().
If no application ID is given then some features (most notably application uniqueness) will be disabled.
|
|
# File 'lib/gtk3/application.rb', line 19
|
#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 GMenuModel to be used for the application's menu bar.
#menubar=(menubar) ⇒ Gio::MenuModel
The GMenuModel 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 application.
If window belongs to application then this call is equivalent to
setting the [propertyGtk.Window:application] property of window to
NULL.
The application may stop running as a result of a call to this
function, if 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.
GTK only tracks session state (including this) when [propertyGtk.Application:register-session] is set to true.
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.
GTK only tracks session state (including this) when [propertyGtk.Application:register-session] is set to true.
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 g_action_parse_detailed_name() and
g_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 [classGtk.Window] instances associated with 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.