package GApplication_Flags_Properties is new Generic_Internal_Discrete_Property (GApplication_Flags);
package Implements_Gaction_Group is new Glib.Types.Implements (Glib.Action_Group.Gaction_Group, Gapplication_Record, Gapplication);
package Implements_Gaction_Map is new Glib.Types.Implements (Glib.Action_Map.Gaction_Map, Gapplication_Record, Gapplication);
type Gapplication_Record is new GObject_Record with null record;
type Gapplication_Command_Line_Record is new GObject_Record with null record;
type Gapplication is access all Gapplication_Record'Class;
type Gapplication_Command_Line is access all Gapplication_Command_Line_Record'Class;
type Property_GApplication_Flags is new GApplication_Flags_Properties.Property;
type Cb_Gapplication_Void is not null access procedure (Self : access Gapplication_Record'Class);
type Cb_GObject_Void is not null access procedure (Self : access Glib.Object.GObject_Record'Class);
type Cb_Gapplication_Gapplication_Command_Line_Gint is not null access function (Self : access Gapplication_Record'Class; Command_Line : not null access Gapplication_Command_Line_Record'Class) return Gint;
type Cb_GObject_Gapplication_Command_Line_Gint is not null access function (Self : access Glib.Object.GObject_Record'Class; Command_Line : not null access Gapplication_Command_Line_Record'Class) return Gint;
G_Application_Flags_None : constant GApplication_Flags := 0;
G_Application_Is_Service : constant GApplication_Flags := 1;
G_Application_Is_Launcher : constant GApplication_Flags := 2;
G_Application_Handles_Open : constant GApplication_Flags := 4;
G_Application_Handles_Command_Line : constant GApplication_Flags := 8;
G_Application_Send_Environment : constant GApplication_Flags := 16;
G_Application_Non_Unique : constant GApplication_Flags := 32;
Action_Group_Property : constant Glib.Properties.Property_Object;
Application_Id_Property : constant Glib.Properties.Property_String;
Flags_Property : constant Glib.Properties.Property_Boxed;
Inactivity_Timeout_Property : constant Glib.Properties.Property_Uint;
Is_Registered_Property : constant Glib.Properties.Property_Boolean;
Is_Remote_Property : constant Glib.Properties.Property_Boolean;
Arguments_Property : constant Glib.Properties.Property_Object;
Platform_Data_Property : constant Glib.Properties.Property_Object;
Signal_Activate : constant Glib.Signal_Name := "activate";
Signal_Command_Line : constant Glib.Signal_Name := "command-line";
Signal_Open : constant Glib.Signal_Name := "open";
Signal_Shutdown : constant Glib.Signal_Name := "shutdown";
Signal_Startup : constant Glib.Signal_Name := "startup";
procedure G_New
( | Self | : out Gapplication; |
Application_Id | : UTF8_String := ""; | |
Flags | : GApplication_Flags); |
procedure Initialize
( | Self | : not null access Gapplication_Record'Class; |
Application_Id | : UTF8_String := ""; | |
Flags | : GApplication_Flags); |
function Gapplication_New
( | Application_Id | : UTF8_String := ""; |
Flags | : GApplication_Flags) return Gapplication; |
function Get_Type return Glib.GType;
function Get_Type_Command_Line return Glib.GType;
procedure Activate
( | Self | : not null access Gapplication_Record); |
function Get_Application_Id
( | Self | : not null access Gapplication_Record) return UTF8_String; |
procedure Set_Application_Id
( | Self | : not null access Gapplication_Record; |
Application_Id | : UTF8_String := ""); |
function Get_Dbus_Object_Path
( | Self | : not null access Gapplication_Record) return UTF8_String; |
function Get_Flags
( | Self | : not null access Gapplication_Record) return GApplication_Flags; |
procedure Set_Flags
( | Self | : not null access Gapplication_Record; |
Flags | : GApplication_Flags); |
function Get_Inactivity_Timeout
( | Self | : not null access Gapplication_Record) return Guint; |
procedure Set_Inactivity_Timeout
( | Self | : not null access Gapplication_Record; |
Inactivity_Timeout | : Guint); |
function Get_Is_Registered
( | Self | : not null access Gapplication_Record) return Boolean; |
function Get_Is_Remote
( | Self | : not null access Gapplication_Record) return Boolean; |
function Get_Is_Remote
( | Self | : not null access Gapplication_Command_Line_Record) return Boolean; |
procedure Hold
( | Self | : not null access Gapplication_Record); |
procedure Quit
( | Self | : not null access Gapplication_Record); |
function Register
( | Self | : not null access Gapplication_Record; |
Cancellable | : access Glib.Cancellable.Gcancellable_Record'Class) return Boolean; |
procedure Release
( | Self | : not null access Gapplication_Record); |
function Run
( | Self | : not null access Gapplication_Record; |
Argc | : Gint; | |
Argv | : GNAT.Strings.String_List) return Gint; |
procedure Set_Action_Group
( | Self | : not null access Gapplication_Record; |
Action_Group | : Glib.Action_Group.Gaction_Group); |
procedure Set_Default
( | Self | : not null access Gapplication_Record); |
function Get_Arguments
( | Self | : not null access Gapplication_Command_Line_Record) return GNAT.Strings.String_List; |
function Get_Cwd
( | Self | : not null access Gapplication_Command_Line_Record) return UTF8_String; |
function Get_Environ
( | Self | : not null access Gapplication_Command_Line_Record) return GNAT.Strings.String_List; |
function Get_Exit_Status
( | Self | : not null access Gapplication_Command_Line_Record) return Gint; |
procedure Set_Exit_Status
( | Self | : not null access Gapplication_Command_Line_Record; |
Exit_Status | : Gint); |
function Get_Platform_Data
( | Self | : not null access Gapplication_Command_Line_Record) return Glib.Variant.Gvariant; |
function Getenv
( | Self | : not null access Gapplication_Command_Line_Record; |
Name | : UTF8_String) return UTF8_String; |
function Run
( | Self | : not null access Gapplication_Record) return Gint; |
procedure Action_Added
( | Self | : not null access Gapplication_Record; |
Action_Name | : UTF8_String); |
procedure Action_Enabled_Changed
( | Self | : not null access Gapplication_Record; |
Action_Name | : UTF8_String; | |
Enabled | : Boolean); |
procedure Action_Removed
( | Self | : not null access Gapplication_Record; |
Action_Name | : UTF8_String); |
procedure Action_State_Changed
( | Self | : not null access Gapplication_Record; |
Action_Name | : UTF8_String; | |
State | : Glib.Variant.Gvariant); |
procedure Activate_Action
( | Self | : not null access Gapplication_Record; |
Action_Name | : UTF8_String; | |
Parameter | : Glib.Variant.Gvariant); |
procedure Change_Action_State
( | Self | : not null access Gapplication_Record; |
Action_Name | : UTF8_String; | |
Value | : Glib.Variant.Gvariant); |
function Get_Action_Enabled
( | Self | : not null access Gapplication_Record; |
Action_Name | : UTF8_String) return Boolean; |
function Get_Action_Parameter_Type
( | Self | : not null access Gapplication_Record; |
Action_Name | : UTF8_String) return Glib.Variant.Gvariant_Type; |
function Get_Action_State
( | Self | : not null access Gapplication_Record; |
Action_Name | : UTF8_String) return Glib.Variant.Gvariant; |
function Get_Action_State_Hint
( | Self | : not null access Gapplication_Record; |
Action_Name | : UTF8_String) return Glib.Variant.Gvariant; |
function Get_Action_State_Type
( | Self | : not null access Gapplication_Record; |
Action_Name | : UTF8_String) return Glib.Variant.Gvariant_Type; |
function Has_Action
( | Self | : not null access Gapplication_Record; |
Action_Name | : UTF8_String) return Boolean; |
function List_Actions
( | Self | : not null access Gapplication_Record) return GNAT.Strings.String_List; |
function Query_Action
( | Self | : not null access Gapplication_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; |
procedure Add_Action
( | Self | : not null access Gapplication_Record; |
Action | : Glib.Action.Gaction); |
procedure Add_Action_Entries
( | Self | : not null access Gapplication_Record; |
Entries | : GAction_Entry_Array; | |
User_Data | : System.Address := System.Null_Address); |
function Lookup_Action
( | Self | : not null access Gapplication_Record; |
Action_Name | : UTF8_String) return Glib.Action.Gaction; |
procedure Remove_Action
( | Self | : not null access Gapplication_Record; |
Action_Name | : UTF8_String); |
function Get_Default return Gapplication;
function Id_Is_Valid
( | Application_Id | : UTF8_String) return Boolean; |
procedure On_Activate
( | Self | : not null access Gapplication_Record; |
Call | : Cb_Gapplication_Void; | |
After | : Boolean := False); |
procedure On_Activate
( | Self | : not null access Gapplication_Record; |
Call | : Cb_GObject_Void; | |
Slot | : not null access Glib.Object.GObject_Record'Class; | |
After | : Boolean := False); |
procedure On_Command_Line
( | Self | : not null access Gapplication_Record; |
Call | : Cb_Gapplication_Gapplication_Command_Line_Gint; | |
After | : Boolean := False); |
procedure On_Command_Line
( | Self | : not null access Gapplication_Record; |
Call | : Cb_GObject_Gapplication_Command_Line_Gint; | |
Slot | : not null access Glib.Object.GObject_Record'Class; | |
After | : Boolean := False); |
procedure On_Shutdown
( | Self | : not null access Gapplication_Record; |
Call | : Cb_Gapplication_Void; | |
After | : Boolean := False); |
procedure On_Shutdown
( | Self | : not null access Gapplication_Record; |
Call | : Cb_GObject_Void; | |
Slot | : not null access Glib.Object.GObject_Record'Class; | |
After | : Boolean := False); |
procedure On_Startup
( | Self | : not null access Gapplication_Record; |
Call | : Cb_Gapplication_Void; | |
After | : Boolean := False); |
procedure On_Startup
( | Self | : not null access Gapplication_Record; |
Call | : Cb_GObject_Void; | |
Slot | : not null access Glib.Object.GObject_Record'Class; | |
After | : Boolean := False); |
function "+"
( | Widget | : access Gapplication_Record'Class) return Glib.Action_Group.Gaction_Group renames Implements_Gaction_Group.To_Interface; |
function "-"
( | Interf | : Glib.Action_Group.Gaction_Group) return Gapplication renames Implements_Gaction_Group.To_Object; |
function "+"
( | Widget | : access Gapplication_Record'Class) return Glib.Action_Map.Gaction_Map renames Implements_Gaction_Map.To_Interface; |
function "-"
( | Interf | : Glib.Action_Map.Gaction_Map) return Gapplication renames Implements_Gaction_Map.To_Object; |
A Glib.Application.Gapplication is the foundation of an application. It wraps some low-level platform-specific services and is intended to act as the foundation for higher-level application classes such as Gtk.Application.Gtk_Application or Mx_Application. In general, you should not use this class outside of a higher level framework.
GApplication provides convenient life cycle management by maintaining a 'use count' for the primary application instance. The use count can be changed using Glib.Application.Hold and Glib.Application.Release. If it drops to zero, the application exits. Higher-level classes such as Gtk.Application.Gtk_Application employ the use count to ensure that the application stays alive as long as it has any opened windows.
Another feature that GApplication (optionally) provides is process uniqueness. Applications can make use of this functionality by providing a unique application ID. If given, only one application with this ID can be running at a time per session. The session concept is platform-dependent, but corresponds roughly to a graphical desktop login. When your application is launched again, its arguments are passed through platform communication to the already running program. The already running instance of the program is called the 'primary instance'; for non-unique applications this is the always the current instance. On Linux, the D-Bus session bus is used for communication.
The use of Glib.Application.Gapplication differs from some other commonly-used uniqueness libraries (such as libunique) in important ways.
The application is not expected to manually register itself and check if it is the primary instance. Instead, the
If used, the expected form of an application identifier is very close to that of of a <ulink url="http://dbus.freedesktop.org/doc/dbus-specification.htmlmessage-protocol-names-interface">DBus bus name</ulink>. Examples include: "com.example.MyApp", "org.example.internal-apps.Calculator". For details on valid application identifiers, see Glib.Application.Id_Is_Valid.
On Linux, the application identifier is claimed as a well-known bus name on the user's session bus. This means that the uniqueness of your application is scoped to the current session. It also means that your application may provide additional services (through registration of other object paths) at that bus name. The registration of these object paths should be done with the shared GDBus session bus. Note that due to the internal architecture of GDBus, method calls can be dispatched at any time (even if a main loop is not running). For this reason, you must ensure that any object paths that you wish to register are registered before Glib.Application.Gapplication attempts to acquire the bus name of your application (which happens in Glib.Application.Register). Unfortunately, this means that you cannot use Glib.Application.Get_Is_Remote to decide if you want to register object paths.
GApplication also implements the Glib.Action_Group.Gaction_Group and Glib.Action_Map.Gaction_Map interfaces and lets you easily export actions by adding them with Glib.Action_Map.Add_Action. When invoking an action by calling Glib.Action_Group.Activate_Action on the application, it is always invoked in the primary instance. The actions are also exported on the session bus, and GIO provides the Gdbus.Action_Group.Gdbus_Action_Group wrapper to conveniently access them remotely. GIO provides a Gdbus.Menu_Model.Gdbus_Menu_Model wrapper for remote access to exported GMenu_Models.
There is a number of different entry points into a GApplication: * via 'Activate' (i.e. just starting the application) * via 'Open' (i.e. opening some files) * by handling a command-line * via activating an action The Glib.Application.Gapplication::startup signal lets you handle the application initialization for all of these in a single place.
Regardless of which of these entry points is used to start the application, GApplication passes some <firstterm id="platform-data">platform data' from the launching instance to the primary instance, in the form of a Glib.Variant.Gvariant dictionary mapping strings to variants. To use platform data, override the Before_Emit or After_Emit virtual functions in your Glib.Application.Gapplication subclass. When dealing with Glib.Application.Gapplication_Command_Line objects, the platform data is directly available via Glib.Application.Get_Cwd, Glib.Application.Get_Environ and Glib.Application.Get_Platform_Data.
As the name indicates, the platform data may vary depending on the operating system, but it always includes the current directory (key "cwd"), and optionally the environment (ie the set of environment variables and their values) of the calling process (key "environ"). The environment is only added to the platform data if the Glib.Application.G_Application_Send_Environment flag is set.
Glib.Application.Gapplication subclasses can add their own platform data by overriding the Add_Platform_Data virtual function. For instance, Gtk.Application.Gtk_Application adds startup notification data in this way.
To parse commandline arguments you may handle the Glib.Application.Gapplication::command-line signal or override the local_command_line vfunc, to parse them in either the primary instance or the local instance, respectively.