Index

Package: Application

Description

package Gtk.Application is

Gtk.Application.Gtk_Application is a class that handles many important aspects of a GTK+ application in a convenient fashion, without enforcing a one-size-fits-all application model.

Currently, GtkApplication 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 Gtk_Windows, it is recommended to use it together with Gtk.Application_Window.Gtk_Application_Window.

When GDK threads are enabled, GtkApplication will acquire the GDK lock when invoking actions that arrive from other processes. The GDK lock is not touched for local action invocations. In order to have actions invoked in a predictable context it is therefore recommended that the GDK lock be held while invoking actions locally with Glib.Action_Group.Activate_Action. The same applies to actions associated with Gtk.Application_Window.Gtk_Application_Window and to the 'activate' and 'open' Glib.Application.Gapplication methods.

To set an application menu for a GtkApplication, use Gtk.Application.Set_App_Menu. The Glib.Menu_Model.Gmenu_Model that this function expects is usually constructed using Gtk.Builder.Gtk_Builder, as seen in the following example. To specify a menubar that will be shown by Gtk_Application_Windows, use Gtk.Application.Set_Menubar. Use the base Glib.Action_Map.Gaction_Map interface to add actions, to respond to the user selecting these menu items.

GTK+ displays these menus as expected, depending on the platform the application is running on. <figure label="Menu integration in OS X"> <graphic fileref="bloatpad-osx.png" format="PNG"/> </figure> <figure label="Menu integration in GNOME"> <graphic fileref="bloatpad-gnome.png" format="PNG"/> </figure> <figure label="Menu integration in Xfce"> <graphic fileref="bloatpad-xfce.png" format="PNG"/> </figure>

== A simple application == <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../examples/bloatpad.c"> <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback> </xi:include> GtkApplication optionally registers with a session manager of the users session (if you set the Gtk.Application.Gtk_Application:register-session property) and offers various functionality related to the session life-cycle.

An application can block various ways to end the session with the 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. </description>

Packages

Gtk_Application_Inhibit_Flags_Properties (new Glib.Generic_Properties.Generic_Internal_Discrete_Property)

package Gtk_Application_Inhibit_Flags_Properties is
      new Generic_Internal_Discrete_Property (Gtk_Application_Inhibit_Flags);

Implements_Gaction_Group (new Glib.Types.Implements)

Implements_Gaction_Map (new Glib.Types.Implements)

Classes

Gtk_Application_Record

type Gtk_Application_Record is new Gapplication_Record with null record;

Ancestors:

Immediate Children:

Primitive operations:

Action_Added
Action_Enabled_Changed
Action_Removed
Action_State_Changed
Activate_Action
Add_Accelerator
Add_Action_Entries
Change_Action_State
Get_Action_Enabled
Get_Action_Parameter_Type
Get_Action_State
Get_Action_State_Hint
Get_Action_State_Type
Get_Active_Window
Get_App_Menu
Get_Window_By_Id
Glib.Application.Action_Added (Inherited)
Glib.Application.Action_Enabled_Changed (Inherited)
Glib.Application.Action_Removed (Inherited)
Glib.Application.Action_State_Changed (Inherited)
Glib.Application.Activate (Inherited)
Glib.Application.Activate_Action (Inherited)
Glib.Application.Add_Action (Inherited)
Glib.Application.Add_Action_Entries (Inherited)
Glib.Application.Change_Action_State (Inherited)
Glib.Application.Get_Action_Enabled (Inherited)
Glib.Application.Get_Action_Parameter_Type (Inherited)
Glib.Application.Get_Action_State (Inherited)
Glib.Application.Get_Action_State_Hint (Inherited)
Glib.Application.Get_Action_State_Type (Inherited)
Glib.Application.Get_Application_Id (Inherited)
Glib.Application.Get_Dbus_Object_Path (Inherited)
Glib.Application.Get_Flags (Inherited)
Glib.Application.Get_Inactivity_Timeout (Inherited)
Glib.Application.Get_Is_Registered (Inherited)
Glib.Application.Get_Is_Remote (Inherited)
Glib.Application.Has_Action (Inherited)
Glib.Application.Hold (Inherited)
Glib.Application.List_Actions (Inherited)
Glib.Application.Lookup_Action (Inherited)
Glib.Application.On_Activate (Inherited)
Glib.Application.On_Activate (Inherited)
Glib.Application.On_Command_Line (Inherited)
Glib.Application.On_Command_Line (Inherited)
Glib.Application.On_Shutdown (Inherited)
Glib.Application.On_Shutdown (Inherited)
Glib.Application.On_Startup (Inherited)
Glib.Application.On_Startup (Inherited)
Glib.Application.Query_Action (Inherited)
Glib.Application.Quit (Inherited)
Glib.Application.Register (Inherited)
Glib.Application.Release (Inherited)
Glib.Application.Remove_Action (Inherited)
Glib.Application.Run (Inherited)
Glib.Application.Run (Inherited)
Glib.Application.Set_Action_Group (Inherited)
Glib.Application.Set_Application_Id (Inherited)
Glib.Application.Set_Default (Inherited)
Glib.Application.Set_Flags (Inherited)
Glib.Application.Set_Inactivity_Timeout (Inherited)
Glib.Object.Deallocate (Inherited)
Glib.Object.Get_Type (Inherited)
Glib.Object.Notify (Inherited)
Glib.Object.Ref (Inherited)
Glib.Object.Ref_Sink (Inherited)
Glib.Object.Unref (Inherited)
Is_Inhibited
List_Actions
Lookup_Action
On_Window_Added
On_Window_Added
On_Window_Removed
On_Window_Removed
Query_Action
Remove_Accelerator
Remove_Action
Remove_Window
Set_App_Menu

Types

Gtk_Application

type Gtk_Application is access all Gtk_Application_Record'Class;

Gtk_Application_Inhibit_Flags

type Gtk_Application_Inhibit_Flags is mod 2 ** Integer'Size;

Property_Gtk_Application_Inhibit_Flags

type Property_Gtk_Application_Inhibit_Flags is new Gtk_Application_Inhibit_Flags_Properties.Property;

Cb_Gtk_Application_Gtk_Window_Void

type Cb_Gtk_Application_Gtk_Window_Void is not null access procedure
     (Self   : access Gtk_Application_Record'Class;
      Window : not null access Gtk.Window.Gtk_Window_Record'Class);

Cb_GObject_Gtk_Window_Void

type Cb_GObject_Gtk_Window_Void is not null access procedure
     (Self   : access Glib.Object.GObject_Record'Class;
      Window : not null access Gtk.Window.Gtk_Window_Record'Class);

Constants & Global variables

Application_Inhibit_Logout (Gtk_Application_Inhibit_Flags)

Application_Inhibit_Logout : constant Gtk_Application_Inhibit_Flags := 1;

Application_Inhibit_Switch (Gtk_Application_Inhibit_Flags)

Application_Inhibit_Switch : constant Gtk_Application_Inhibit_Flags := 2;

Application_Inhibit_Suspend (Gtk_Application_Inhibit_Flags)

Application_Inhibit_Suspend : constant Gtk_Application_Inhibit_Flags := 4;

Application_Inhibit_Idle (Gtk_Application_Inhibit_Flags)

Application_Inhibit_Idle : constant Gtk_Application_Inhibit_Flags := 8;

App_Menu_Property (Glib.Properties.Property_Boxed)

App_Menu_Property : constant Glib.Properties.Property_Boxed;
Type: Gio.Menu_Model

Menubar_Property (Glib.Properties.Property_Boxed)

Menubar_Property : constant Glib.Properties.Property_Boxed;
Type: Gio.Menu_Model

Register_Session_Property (Glib.Properties.Property_Boolean)

Register_Session_Property : constant Glib.Properties.Property_Boolean;
Set this property to True to register with the session manager.

Signal_Window_Added (Glib.Signal_Name)

Signal_Window_Added : constant Glib.Signal_Name := "window-added";

Signal_Window_Removed (Glib.Signal_Name)

Signal_Window_Removed : constant Glib.Signal_Name := "window-removed";

Subprograms & Entries

Gtk_New

procedure Gtk_New 
(Self: out Gtk_Application;
Application_Id: UTF8_String := "";
Flags: Glib.Application.GApplication_Flags);

Initialize

procedure Initialize 
(Self: not null access Gtk_Application_Record'Class;
Application_Id: UTF8_String := "";
Flags: Glib.Application.GApplication_Flags);
Creates a new Gtk.Application.Gtk_Application instance. When using Gtk.Application.Gtk_Application, it is not necessary to call gtk_init manually. It is called as soon as the application gets registered as the primary instance. Concretely, gtk_init is called in the default handler for the Glib.Application.Gapplication::startup signal. Therefore, Gtk.Application.Gtk_Application subclasses should chain up in their Glib.Application.Gapplication:startup handler before using any GTK+ API. Note that commandline arguments are not passed to gtk_init. All GTK+ functionality that is available via commandline arguments can also be achieved by setting suitable environment variables such as <envar>G_DEBUG</envar>, so this should not be a big problem. If you absolutely must support GTK+ commandline arguments, you can explicitly call gtk_init before creating the application instance. If non-null, the application ID must be valid. See Glib.Application.Id_Is_Valid. If no application ID is given then some features (most notably application uniqueness) will be disabled. A null application ID is only allowed with GTK+ 3.6 or later. Since: gtk+ 3.0 "application_id": The application ID. "flags": the application flags

Gtk_Application_New

function Gtk_Application_New 
(Application_Id: UTF8_String := "";
Flags: Glib.Application.GApplication_Flags) return Gtk_Application;
Creates a new Gtk.Application.Gtk_Application instance. When using Gtk.Application.Gtk_Application, it is not necessary to call gtk_init manually. It is called as soon as the application gets registered as the primary instance. Concretely, gtk_init is called in the default handler for the Glib.Application.Gapplication::startup signal. Therefore, Gtk.Application.Gtk_Application subclasses should chain up in their Glib.Application.Gapplication:startup handler before using any GTK+ API. Note that commandline arguments are not passed to gtk_init. All GTK+ functionality that is available via commandline arguments can also be achieved by setting suitable environment variables such as <envar>G_DEBUG</envar>, so this should not be a big problem. If you absolutely must support GTK+ commandline arguments, you can explicitly call gtk_init before creating the application instance. If non-null, the application ID must be valid. See Glib.Application.Id_Is_Valid. If no application ID is given then some features (most notably application uniqueness) will be disabled. A null application ID is only allowed with GTK+ 3.6 or later. Since: gtk+ 3.0 "application_id": The application ID. "flags": the application flags

Get_Type

function Get_Type return Glib.GType;

Add_Accelerator

procedure Add_Accelerator 
(Self: not null access Gtk_Application_Record;
Accelerator: UTF8_String;
Action_Name: UTF8_String;
Parameter: Glib.Variant.Gvariant);
Installs an accelerator that will cause the named action to be activated when the key combination specificed by Accelerator is pressed. Accelerator must be a string that can be parsed by Gtk.Accel_Group.Accelerator_Parse, e.g. "<Primary>q" or "<Control><Alt>p". Action_Name must be the name of an action as it would be used in the app menu, i.e. actions that have been added to the application are referred to with an "app." prefix, and window-specific actions with a "win." prefix. GtkApplication also extracts accelerators out of 'accel' attributes in the GMenu_Models passed to Gtk.Application.Set_App_Menu and Gtk.Application.Set_Menubar, which is usually more convenient than calling this function for each accelerator. Since: gtk+ 3.4 "accelerator": accelerator string "action_name": the name of the action to activate "parameter": parameter to pass when activating the action, or null if the action does not accept an activation parameter

Add_Window

procedure Add_Window 
(Self: not null access Gtk_Application_Record;
Window: not null access Gtk.Window.Gtk_Window_Record'Class);
Adds a window to Application. This call is equivalent to setting the Gtk.Window.Gtk_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 Gtk.Application.Remove_Window. GTK+ will keep the application running as long as it has any windows. Since: gtk+ 3.0 "window": a Gtk.Window.Gtk_Window

Get_Active_Window

function Get_Active_Window 
(Self: not null access Gtk_Application_Record) return Gtk.Window.Gtk_Window;
Gets the "active" window for the application. The active window is the one that was most recently focused (within the application). This window may not have the focus at the moment if another application has it -- this is just the most recently-focused window within this application. Since: gtk+ 3.6

Get_App_Menu

function Get_App_Menu 
(Self: not null access Gtk_Application_Record) return Glib.Menu_Model.Gmenu_Model;
Returns the menu model that has been set with Gtk.Application.Set_App_Menu. Since: gtk+ 3.4

Set_App_Menu

procedure Set_App_Menu 
(Self: not null access Gtk_Application_Record;
App_Menu: access Glib.Menu_Model.Gmenu_Model_Record'Class);
Sets or unsets the application menu for Application. This can only be done in the primary instance of the application, after it has been registered. Glib.Application.Gapplication:startup is a good place to call this. The application menu is a single menu containing items that typically impact the application as a whole, rather than acting on a specific window or document. For example, you would expect to see "Preferences" or "Quit" in an application menu, but not "Save" or "Print". If supported, the application menu will be rendered by the desktop environment. Use the base Glib.Action_Map.Gaction_Map interface to add actions, to respond to the user selecting these menu items. Since: gtk+ 3.4 "app_menu": a Glib.Menu_Model.Gmenu_Model, or null

Get_Menubar

function Get_Menubar 
(Self: not null access Gtk_Application_Record) return Glib.Menu_Model.Gmenu_Model;
Returns the menu model that has been set with Gtk.Application.Set_Menubar. Since: gtk+ 3.4

Set_Menubar

procedure Set_Menubar 
(Self: not null access Gtk_Application_Record;
Menubar: access Glib.Menu_Model.Gmenu_Model_Record'Class);
Sets or unsets the menubar for windows of Application. This is a menubar in the traditional sense. This can only be done in the primary instance of the application, after it has been registered. Glib.Application.Gapplication:startup is a good place to call this. Depending on the desktop environment, this may appear at the top of each window, or at the top of the screen. In some environments, if both the application menu and the menubar are set, the application menu will be presented as if it were the first item of the menubar. Other environments treat the two as completely separate -- for example, the application menu may be rendered by the desktop shell while the menubar (if set) remains in each individual window. Use the base Glib.Action_Map.Gaction_Map interface to add actions, to respond to the user selecting these menu items. Since: gtk+ 3.4 "menubar": a Glib.Menu_Model.Gmenu_Model, or null

Get_Window_By_Id

function Get_Window_By_Id 
(Self: not null access Gtk_Application_Record;
Id: Guint) return Gtk.Window.Gtk_Window;
Returns the Gtk.Application_Window.Gtk_Application_Window with the given ID. Since: gtk+ 3.6 "id": an identifier number

Get_Windows

function Get_Windows 
(Self: not null access Gtk_Application_Record) return Gtk.Widget.Widget_List.Glist;
Gets a list of the Gtk_Windows 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. Since: gtk+ 3.0

Inhibit

function Inhibit 
(Self: not null access Gtk_Application_Record;
Window: access Gtk.Window.Gtk_Window_Record'Class;
Flags: Gtk_Application_Inhibit_Flags;
Reason: UTF8_String := "") return Guint;
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 Gtk.Application.Uninhibit to remove the inhibitor. Note that an application can have multiple inhibitors, and all of the 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. Reasons 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. Since: gtk+ 3.4 "window": a Gtk.Window.Gtk_Window, or null "flags": what types of actions should be inhibited "reason": a short, human-readable string that explains why these operations are inhibited

Is_Inhibited

function Is_Inhibited 
(Self: not null access Gtk_Application_Record;
Flags: Gtk_Application_Inhibit_Flags) return Boolean;
Determines if any of the actions specified in Flags are currently inhibited (possibly by another application). Since: gtk+ 3.4 "flags": what types of actions should be queried

Remove_Accelerator

procedure Remove_Accelerator 
(Self: not null access Gtk_Application_Record;
Action_Name: UTF8_String;
Parameter: Glib.Variant.Gvariant);
Removes an accelerator that has been previously added with Gtk.Application.Add_Accelerator. Since: gtk+ 3.4 "action_name": the name of the action to activate "parameter": parameter to pass when activating the action, or null if the action does not accept an activation parameter

Remove_Window

procedure Remove_Window 
(Self: not null access Gtk_Application_Record;
Window: not null access Gtk.Window.Gtk_Window_Record'Class);
Remove a window from Application. If Window belongs to Application then this call is equivalent to setting the Gtk.Window.Gtk_Window:application property of Window to null. The application may stop running as a result of a call to this function. Since: gtk+ 3.0 "window": a Gtk.Window.Gtk_Window

Uninhibit

procedure Uninhibit 
(Self: not null access Gtk_Application_Record;
Cookie: Guint);
Removes an inhibitor that has been established with Gtk.Application.Inhibit. Inhibitors are also cleared when the application exits. Since: gtk+ 3.4 "cookie": a cookie that was returned by Gtk.Application.Inhibit

Action_Added

procedure Action_Added 
(Self: not null access Gtk_Application_Record;
Action_Name: UTF8_String);

Action_Enabled_Changed

procedure Action_Enabled_Changed 
(Self: not null access Gtk_Application_Record;
Action_Name: UTF8_String;
Enabled: Boolean);

Action_Removed

procedure Action_Removed 
(Self: not null access Gtk_Application_Record;
Action_Name: UTF8_String);

Action_State_Changed

procedure Action_State_Changed 
(Self: not null access Gtk_Application_Record;
Action_Name: UTF8_String;
State: Glib.Variant.Gvariant);

Activate_Action

procedure Activate_Action 
(Self: not null access Gtk_Application_Record;
Action_Name: UTF8_String;
Parameter: Glib.Variant.Gvariant);

Change_Action_State

procedure Change_Action_State 
(Self: not null access Gtk_Application_Record;
Action_Name: UTF8_String;
Value: Glib.Variant.Gvariant);

Get_Action_Enabled

function Get_Action_Enabled 
(Self: not null access Gtk_Application_Record;
Action_Name: UTF8_String) return Boolean;

Get_Action_Parameter_Type

function Get_Action_Parameter_Type 
(Self: not null access Gtk_Application_Record;
Action_Name: UTF8_String) return Glib.Variant.Gvariant_Type;

Get_Action_State

function Get_Action_State 
(Self: not null access Gtk_Application_Record;
Action_Name: UTF8_String) return Glib.Variant.Gvariant;

Get_Action_State_Hint

function Get_Action_State_Hint 
(Self: not null access Gtk_Application_Record;
Action_Name: UTF8_String) return Glib.Variant.Gvariant;

Get_Action_State_Type

function Get_Action_State_Type 
(Self: not null access Gtk_Application_Record;
Action_Name: UTF8_String) return Glib.Variant.Gvariant_Type;

Has_Action

function Has_Action 
(Self: not null access Gtk_Application_Record;
Action_Name: UTF8_String) return Boolean;

List_Actions

function List_Actions 
(Self: not null access Gtk_Application_Record) return GNAT.Strings.String_List;

Query_Action

function Query_Action 
(Self: not null access Gtk_Application_Record;
Action_Name: UTF8_String;
Enabled: access Boolean;
Parameter_Type: access Glib.Variant.Gvariant_Type;
State_Type: access Glib.Variant.Gvariant_Type;
State_Hint: access Glib.Variant.Gvariant;
State: access Glib.Variant.Gvariant) return Boolean;

Add_Action

procedure Add_Action 
(Self: not null access Gtk_Application_Record;
Action: Glib.Action.Gaction);

Add_Action_Entries

procedure Add_Action_Entries 
(Self: not null access Gtk_Application_Record;
Entries: GAction_Entry_Array;
User_Data: System.Address := System.Null_Address);

Lookup_Action

function Lookup_Action 
(Self: not null access Gtk_Application_Record;
Action_Name: UTF8_String) return Glib.Action.Gaction;

Remove_Action

procedure Remove_Action 
(Self: not null access Gtk_Application_Record;
Action_Name: UTF8_String);

On_Window_Added

procedure On_Window_Added 
(Self: not null access Gtk_Application_Record;
Call: Cb_Gtk_Application_Gtk_Window_Void;
After: Boolean := False);

On_Window_Added

procedure On_Window_Added 
(Self: not null access Gtk_Application_Record;
Call: Cb_GObject_Gtk_Window_Void;
Slot: not null access Glib.Object.GObject_Record'Class;
After: Boolean := False);
Emitted when a Gtk.Window.Gtk_Window is added to Application through Gtk.Application.Add_Window.

On_Window_Removed

procedure On_Window_Removed 
(Self: not null access Gtk_Application_Record;
Call: Cb_Gtk_Application_Gtk_Window_Void;
After: Boolean := False);

On_Window_Removed

procedure On_Window_Removed 
(Self: not null access Gtk_Application_Record;
Call: Cb_GObject_Gtk_Window_Void;
Slot: not null access Glib.Object.GObject_Record'Class;
After: Boolean := False);
Emitted when a Gtk.Window.Gtk_Window is removed from Application, either as a side-effect of being destroyed or explicitly through Gtk.Application.Remove_Window.