1.3 <GApplication>

Class: <GApplication>

It derives from <GObject>.

<GApplication> is the core class for application support.

A <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 <GtkApplication> or MxApplication. 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 application:hold and application:release. If it drops to zero, the application exits. Higher-level classes such as <GtkApplication> 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 always the current instance. On Linux, the D-Bus session bus is used for communication.

The use of <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 main() function of a <GApplication> should do very little more than instantiating the application instance, possibly connecting signal handlers, then calling application:run. All checks for uniqueness are done internally. If the application is the primary instance then the startup signal is emitted and the mainloop runs. If the application is not the primary instance then a signal is sent to the primary instance and application:run promptly returns. See the code examples below.

If used, the expected form of an application identifier is the same as that of a D-Bus well-known bus name. Examples include: com.example.MyApp, org.example.internal_apps.Calculator, org._7_zip.Archiver. For details on valid application identifiers, see 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 <GApplication> attempts to acquire the bus name of your application (which happens in application:register?). Unfortunately, this means that you cannot use application:is-remote to decide if you want to register object paths.

<GApplication> also implements the <GActionGroup> and <GActionMap> interfaces and lets you easily export actions by adding them with action-map:add-action. When invoking an action by calling 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 <GDBusActionGroup> wrapper to conveniently access them remotely. GIO provides a <GDBusMenuModel> wrapper for remote access to exported <GMenuModel>s.

Note: Due to the fact that actions are exported on the session bus, using maybe parameters is not supported, since D-Bus does not support maybe types.

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 application: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 ‘platform data’ from the launching instance to the primary instance, in the form of a <GVariant> dictionary mapping strings to variants. To use platform data, override the application:do-before-emit or application:do-after-emit virtual functions in your <GApplication> subclass. When dealing with <GApplicationCommandLine> objects, the platform data is directly available via application-command-line:get-cwd, application-command-line:get-environ and application-command-line: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 send-environment flag is set. <GApplication> subclasses can add their own platform data by overriding the application:do-add-platform-data virtual function. For instance, <GtkApplication> adds startup notification data in this way.

To parse commandline arguments you may handle the application:command-line signal or override the application:do-local-command-line virtual function, to parse them in either the primary instance or the local instance, respectively.

For an example of opening files with a <GApplication>, see gapplication-example-open.c.

For an example of using actions with <GApplication>, see gapplication-example-actions.c.

For an example of using extra D-Bus hooks with <GApplication>, see gapplication-example-dbushooks.c.

Properties

Property: application:action-group self

The group of actions that the application exports.

Its value is a <GActionGroup>, or #f.

It can only be set, with (set! (application:action-group self) value).

Property: application:application-id self

The unique identifier for the application.

Its value is a string, or #f.

Set it with (set! (application:application-id self) value).

Property: application:flags self

Flags specifying the behaviour of the application.

Its value is a <GApplicationFlags> (or, to set it, a list of its symbols, or one of them).

Set it with (set! (application:flags self) value).

Property: application:inactivity-timeout self

Time (in milliseconds) to stay alive after becoming idle.

Its value is an unsigned 32-bit integer.

Set it with (set! (application:inactivity-timeout self) value).

Property: application:is-busy self

Whether the application is currently marked as busy through application:mark-busy or application:bind-busy-property.

Its value is a boolean.

It is read only.

Property: application:is-registered self

Whether application:register? has been called.

Its value is a boolean.

It is read only.

Property: application:is-remote self

Whether this application instance is remote.

Its value is a boolean.

It is read only.

Property: application:resource-base-path self

The base resource path for the application.

Its value is a string, or #f.

Set it with (set! (application:resource-base-path self) value).

Property: application:version self

The human-readable version number of the application.

Its value is a string, or #f.

Set it with (set! (application:version self) value).

Procedures

Method: application:activate self
Method: activate self

Activates the application.

In essence, this results in the application:activate signal being emitted in the primary instance.

The application must be registered before calling this function.

self

Passed: a <GApplication>.

a <GApplication>

Method: application:add-main-option self long-name short-name flags arg description [arg-description]
Method: add-main-option self long-name short-name flags arg description [arg-description]

Add an option to be handled by self.

Calling this function is the equivalent of calling g_application_add_main_option_entries() with a single GOptionEntry that has its arg_data member set to #f.

The parsed arguments will be packed into a <GVariantDict> which is passed to application:handle-local-options. If handles-command-line is set, then it will also be sent to the primary instance. See g_application_add_main_option_entries() for more details.

See GOptionEntry for more documentation of the arguments.

self

Passed: a <GApplication>.

the <GApplication>

long-name

Passed: a string.

the long name of an option used to specify it in a commandline

short-name

Passed: an 8-bit integer, or a character.

the short name of an option

flags

Passed: a <%GOptionFlags>, or a list of its symbols, or one of them.

flags from <%GOptionFlags>

arg

Passed: a <%GOptionArg>, or one of its symbols.

the type of the option, as a <%GOptionArg>

description

Passed: a string.

the description for the option in --help output

arg-description

Passed, or left out: a string, or #f.

the placeholder to use for the extra argument parsed by the option in --help output

Method: application:add-option-group self group
Method: add-option-group self group

Adds a <GOptionGroup> to the commandline handling of self.

This function is comparable to g_option_context_add_group().

Unlike g_application_add_main_option_entries(), this function does not deal with #f arg-data and never transmits options to the primary instance.

The reason for that is because, by the time the options arrive at the primary instance, it is typically too late to do anything with them. Taking the GTK option group as an example: GTK will already have been initialised by the time the application:command-line handler runs. In the case that this is not the first-running instance of the application, the existing instance may already have been running for a very long time.

This means that the options from <GOptionGroup> are only really usable in the case that the instance of the application being run is the first instance. Passing options like --display= or --gdk-debug= on future runs will have no effect on the existing primary instance.

Calling this function will cause the options in the supplied option group to be parsed, but it does not cause you to be "opted in" to the new functionality whereby unrecognized options are rejected even if handles-command-line was given.

self

Passed: a <GApplication>.

the <GApplication>

group

Passed: a <GOptionGroup>.

a <GOptionGroup>

Method: application:bind-busy-property self object property
Method: bind-busy-property self object property

Marks self as busy (see application:mark-busy) while property on object is #t.

The binding holds a reference to self while it is active, but not to object. Instead, the binding is destroyed when object is finalized.

self

Passed: a <GApplication>.

a <GApplication>

object

Passed: a <GObject>.

a <GObject>

property

Passed: a string.

the name of a boolean property of object

Method: application:get-application-id self ⇒ %return
Method: get-application-id self ⇒ %return

Gets the unique identifier for self.

self

Passed: a <GApplication>.

a <GApplication>

%return

Returned: a string, or #f.

the identifier for self, owned by self

Method: application:get-dbus-connection self ⇒ %return
Method: get-dbus-connection self ⇒ %return

Gets the <GDBusConnection> being used by the application, or #f.

If <GApplication> is using its D-Bus backend then this function will return the <GDBusConnection> being used for uniqueness and communication with the desktop environment and other instances of the application.

If <GApplication> is not using D-Bus then this function will return #f. This includes the situation where the D-Bus backend would normally be in use but we were unable to connect to the bus.

This function must not be called before the application has been registered. See application:get-is-registered?.

self

Passed: a <GApplication>.

a <GApplication>

%return

Returned: a <GDBusConnection>, or #f.

a <GDBusConnection>, or #f

Method: application:get-dbus-object-path self ⇒ %return
Method: get-dbus-object-path self ⇒ %return

Gets the D-Bus object path being used by the application, or #f.

If <GApplication> is using its D-Bus backend then this function will return the D-Bus object path that <GApplication> is using. If the application is the primary instance then there is an object published at this path. If the application is not the primary instance then the result of this function is undefined.

If <GApplication> is not using D-Bus then this function will return #f. This includes the situation where the D-Bus backend would normally be in use but we were unable to connect to the bus.

This function must not be called before the application has been registered. See application:get-is-registered?.

self

Passed: a <GApplication>.

a <GApplication>

%return

Returned: a string, or #f.

the object path, or #f

Procedure: application:get-default ⇒ %return

Returns the default <GApplication> instance for this process.

Normally there is only one <GApplication> per process and it becomes the default when it is created. You can exercise more control over this by using application:set-default.

If there is no default application then #f is returned.

%return

Returned: a <GApplication>, or #f.

the default application for this process, or #f

Method: application:get-flags self ⇒ %return
Method: get-flags self ⇒ %return

Gets the flags for self.

See <GApplicationFlags>.

self

Passed: a <GApplication>.

a <GApplication>

%return

Returned: a <GApplicationFlags>.

the flags for self

Method: application:get-inactivity-timeout self ⇒ %return
Method: get-inactivity-timeout self ⇒ %return

Gets the current inactivity timeout for the application.

This is the amount of time (in milliseconds) after the last call to application:release before the application stops running.

self

Passed: a <GApplication>.

a <GApplication>

%return

Returned: an unsigned 32-bit integer.

the timeout, in milliseconds

Method: application:get-is-busy? self ⇒ %return
Method: get-is-busy? self ⇒ %return

Gets the application’s current busy state, as set through application:mark-busy or application:bind-busy-property.

self

Passed: a <GApplication>.

a <GApplication>

%return

Returned: a boolean.

#t if self is currently marked as busy

Method: application:get-is-registered? self ⇒ %return
Method: get-is-registered? self ⇒ %return

Checks if self is registered.

An application is registered if application:register? has been successfully called.

self

Passed: a <GApplication>.

a <GApplication>

%return

Returned: a boolean.

#t if self is registered

Method: application:get-is-remote? self ⇒ %return
Method: get-is-remote? self ⇒ %return

Checks if self is remote.

If self is remote then it means that another instance of application already exists (the ’primary’ instance). Calls to perform actions on self will result in the actions being performed by the primary instance.

The value of this property cannot be accessed before application:register? has been called. See application:get-is-registered?.

self

Passed: a <GApplication>.

a <GApplication>

%return

Returned: a boolean.

#t if self is remote

Method: application:get-resource-base-path self ⇒ %return
Method: get-resource-base-path self ⇒ %return

Gets the resource base path of self.

See application:set-resource-base-path for more information.

self

Passed: a <GApplication>.

a <GApplication>

%return

Returned: a string, or #f.

the base resource path, if one is set

Method: application:get-version self ⇒ %return
Method: get-version self ⇒ %return

Gets the version of self.

self

Passed: a <GApplication>.

a <GApplication>

%return

Returned: a string, or #f.

the version of self

Method: application:hold self
Method: hold self

Increases the use count of self.

Use this function to indicate that the application has a reason to continue to run. For example, application:hold is called by GTK when a toplevel window is on the screen.

To cancel the hold, call application:release.

self

Passed: a <GApplication>.

a <GApplication>

Procedure: application:id-is-valid? application-id ⇒ %return

Checks if application-id is a valid application identifier.

A valid ID is required for calls to application:new and application:set-application-id.

Application identifiers follow the same format as D-Bus well-known bus names. For convenience, the restrictions on application identifiers are reproduced here:

  • Application identifiers are composed of 1 or more elements separated by a period (.) character. All elements must contain at least one character.
  • Each element must only contain the ASCII characters [A-Z][a-z][0-9]_-, with - discouraged in new application identifiers. Each element must not begin with a digit.
  • Application identifiers must contain at least one . (period) character (and thus at least two elements).
  • Application identifiers must not begin with a . (period) character.
  • Application identifiers must not exceed 255 characters.

Note that the hyphen (-) character is allowed in application identifiers, but is problematic or not allowed in various specifications and APIs that refer to D-Bus, such as Flatpak application IDs, the ‘DBusActivatable‘ interface in the Desktop Entry Specification, and the convention that an application’s "main" interface and object path resemble its application identifier and bus name. To avoid situations that require special-case handling, it is recommended that new application identifiers consistently replace hyphens with underscores.

Like D-Bus interface names, application identifiers should start with the reversed DNS domain name of the author of the interface (in lower-case), and it is conventional for the rest of the application identifier to consist of words run together, with initial capital letters.

As with D-Bus interface names, if the author’s DNS domain name contains hyphen/minus characters they should be replaced by underscores, and if it contains leading digits they should be escaped by prepending an underscore. For example, if the owner of 7-zip.org used an application identifier for an archiving application, it might be named org._7_zip.Archiver.

application-id

Passed: a string.

a potential application identifier

%return

Returned: a boolean.

#t if application-id is valid

Method: application:mark-busy self
Method: mark-busy self

Increases the busy count of self.

Use this function to indicate that the application is busy, for instance while a long running operation is pending.

The busy state will be exposed to other processes, so a session shell will use that information to indicate the state to the user (e.g. with a spinner).

To cancel the busy indication, use application:unmark-busy.

The application must be registered before calling this function.

self

Passed: a <GApplication>.

a <GApplication>

Procedure: application:new application-id flags ⇒ %return

Creates a new <GApplication> instance.

If non-#f, the application id must be valid. See application:id-is-valid?.

If no application ID is given then some features of <GApplication> (most notably application uniqueness) will be disabled.

application-id

Passed: a string, or #f.

the application id

flags

Passed: a <GApplicationFlags>, or a list of its symbols, or one of them.

the application flags

%return

Returned: a <GApplication>.

a new <GApplication> instance

Method: application:open self files hint
Method: open self files hint

Opens the given files.

In essence, this results in the application:open signal being emitted in the primary instance.

n-files must be greater than zero.

hint is simply passed through to the ::open signal. It is intended to be used by applications that have multiple modes for opening files (eg: "view" vs "edit", etc). Unless you have a need for this functionality, you should use "".

The application must be registered before calling this function and it must have the handles-open flag set.

self

Passed: a <GApplication>.

a <GApplication>

files

Passed: a list or vector, each a <GFile>.

an array of GFiles to open

hint

Passed: a string.

a hint (or ""), but never #f

n-files

Not passed: guile-gi gives the length of files.

the length of the files array

Method: application:quit self
Method: quit self

Immediately quits the application.

Upon return to the mainloop, application:run will return, calling only the ’shutdown’ function before doing so.

The hold count is ignored. Take care if your code has called application:hold on the application and is therefore still expecting it to exist. (Note that you may have called application:hold indirectly, for example through application:add-window.)

The result of calling application:run again after it returns is unspecified.

self

Passed: a <GApplication>.

a <GApplication>

Method: application:register? self [cancellable] ⇒ %return
Method: register? self [cancellable] ⇒ %return

Attempts registration of the application.

This is the point at which the application discovers if it is the primary instance or merely acting as a remote for an already-existing primary instance. This is implemented by attempting to acquire the application identifier as a unique bus name on the session bus using GDBus.

If there is no application ID or if non-unique was given, then this process will always become the primary instance.

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 calling this function.

If the application has already been registered then #t is returned with no work performed.

The application:startup signal is emitted if registration succeeds and self is the primary instance (including the non-unique case).

In the event of an error (such as cancellable being cancelled, or a failure to connect to the session bus), #f is returned and error is set appropriately.

Note: the return value of this function is not an indicator that this instance is or is not the primary instance of the application. See application:get-is-remote? for that.

self

Passed: a <GApplication>.

a <GApplication>

cancellable

Passed, or left out: a <GCancellable>, or #f.

a <GCancellable>, or #f

%return

Returned: a boolean.

#t if registration succeeded

Method: application:release self
Method: release self

Decrease the use count of self.

When the use count reaches zero, the application will stop running.

Never call this function except to cancel the effect of a previous call to application:hold.

self

Passed: a <GApplication>.

a <GApplication>

Method: application:run self [argv] ⇒ %return
Method: run self [argv] ⇒ %return

Runs the application.

This function is intended to be run from main() and its return value is intended to be returned by main(). Although you are expected to pass the argc, argv parameters from main() to this function, it is possible to pass #f if argv is not available or commandline handling is not required. Note that on Windows, argc and argv are ignored, and g_win32_get_command_line() is called internally (for proper support of Unicode commandline arguments).

<GApplication> will attempt to parse the commandline arguments. You can add commandline flags to the list of recognised options by way of g_application_add_main_option_entries(). After this, the application:handle-local-options signal is emitted, from which the application can inspect the values of its GOptionEntrys.

application:handle-local-options is a good place to handle options such as --version, where an immediate reply from the local process is desired (instead of communicating with an already-running instance). A application:handle-local-options handler can stop further processing by returning a non-negative value, which then becomes the exit status of the process.

What happens next depends on the flags: if handles-command-line was specified then the remaining commandline arguments are sent to the primary instance, where a application:command-line signal is emitted. Otherwise, the remaining commandline arguments are assumed to be a list of files. If there are no files listed, the application is activated via the application:activate signal. If there are one or more files, and handles-open was specified then the files are opened via the application:open signal.

If you are interested in doing more complicated local handling of the commandline then you should implement your own <GApplication> subclass and override local_command_line(). In this case, you most likely want to return #t from your local_command_line() implementation to suppress the default handling. See gapplication-example-cmdline2.c for an example.

If, after the above is done, the use count of the application is zero then the exit status is returned immediately. If the use count is non-zero then the default main context is iterated until the use count falls to zero, at which point 0 is returned.

If the is-service flag is set, then the service will run for as much as 10 seconds with a use count of zero while waiting for the message that caused the activation to arrive. After that, if the use count falls to zero the application will exit immediately, except in the case that application:set-inactivity-timeout is in use.

This function sets the prgname (set-prgname), if not already set, to the basename of argv[0].

Much like main-loop:run, this function will acquire the main context for the duration that the application is running.

Since 2.40, applications that are not explicitly flagged as services or launchers (ie: neither is-service or is-launcher are given as flags) will check (from the default handler for local_command_line) if "–gapplication-service" was given in the command line. If this flag is present then normal commandline processing is interrupted and the is-service flag is set. This provides a "compromise" solution whereby running an application directly from the commandline will invoke it in the normal way (which can be useful for debugging) while still allowing applications to be D-Bus activated in service mode. The D-Bus service file should invoke the executable with "–gapplication-service" as the sole commandline argument. This approach is suitable for use by most graphical applications but should not be used from applications like editors that need precise control over when processes invoked via the commandline will exit and what their exit status will be.

self

Passed: a <GApplication>.

a <GApplication>

argv

Passed, or left out: a list or vector, each a file name, as a string, or #f.

the argv from main(), or #f

%return

Returned: a 32-bit integer.

the exit status

argc

Not passed: guile-gi gives the length of argv.

the argc from main() (or 0 if argv is #f)

Method: application:send-notification self id notification
Method: send-notification self id notification

Sends a notification on behalf of self to the desktop shell. There is no guarantee that the notification is displayed immediately, or even at all.

Notifications may persist after the application exits. It will be D-Bus-activated when the notification or one of its actions is activated.

Modifying notification after this call has no effect. However, the object can be reused for a later call to this function.

id may be any string that uniquely identifies the event for the application. It does not need to be in any special format. For example, "new-message" might be appropriate for a notification about new messages.

If a previous notification was sent with the same id, it will be replaced with notification and shown again as if it was a new notification. This works even for notifications sent from a previous execution of the application, as long as id is the same string.

id may be NULL, but it is impossible to replace or withdraw notifications without an id.

If notification is no longer relevant, it can be withdrawn with application:withdraw-notification.

It is an error to call this function if self has no application ID.

self

Passed: a <GApplication>.

a <GApplication>

id

Passed: a string, or #f.

id of the notification, or #f

notification

Passed: a <GNotification>.

the <GNotification> to send

Method: application:set-action-group self [action-group]
Method: set-action-group self [action-group]

This used to be how actions were associated with a <GApplication>. Now there is <GActionMap> for that.

self

Passed: a <GApplication>.

a <GApplication>

action-group

Passed, or left out: a <GActionGroup>, or #f.

a <GActionGroup>, or #f

Method: application:set-application-id self [application-id]
Method: set-application-id self [application-id]

Sets the unique identifier for self.

The application id can only be modified if self has not yet been registered.

If non-#f, the application id must be valid. See application:id-is-valid?.

self

Passed: a <GApplication>.

a <GApplication>

application-id

Passed, or left out: a string, or #f.

the identifier for self

Method: application:set-default self
Method: set-default self

Sets or unsets the default application for the process, as returned by application:get-default.

This function does not take its own reference on self. If self is destroyed then the default application will revert back to #f.

self

Passed: a <GApplication>.

the application to set as default, or #f

Method: application:set-flags self flags
Method: set-flags self flags

Sets the flags for self.

The flags can only be modified if self has not yet been registered.

See <GApplicationFlags>.

self

Passed: a <GApplication>.

a <GApplication>

flags

Passed: a <GApplicationFlags>, or a list of its symbols, or one of them.

the flags for self

Method: application:set-inactivity-timeout self inactivity-timeout
Method: set-inactivity-timeout self inactivity-timeout

Sets the current inactivity timeout for the application.

This is the amount of time (in milliseconds) after the last call to application:release before the application stops running.

This call has no side effects of its own. The value set here is only used for next time application:release drops the use count to zero. Any timeouts currently in progress are not impacted.

self

Passed: a <GApplication>.

a <GApplication>

inactivity-timeout

Passed: an unsigned 32-bit integer.

the timeout, in milliseconds

Method: application:set-option-context-description self [description]
Method: set-option-context-description self [description]

Adds a description to the self option context.

See g_option_context_set_description() for more information.

self

Passed: a <GApplication>.

the <GApplication>

description

Passed, or left out: a string, or #f.

a string to be shown in --help output after the list of options, or #f

Method: application:set-option-context-parameter-string self [parameter-string]
Method: set-option-context-parameter-string self [parameter-string]

Sets the parameter string to be used by the commandline handling of self.

This function registers the argument to be passed to g_option_context_new() when the internal GOptionContext of self is created.

See g_option_context_new() for more information about parameter-string.

self

Passed: a <GApplication>.

the <GApplication>

parameter-string

Passed, or left out: a string, or #f.

a string which is displayed in the first line of --help output, after the usage summary programname [OPTION...].

Method: application:set-option-context-summary self [summary]
Method: set-option-context-summary self [summary]

Adds a summary to the self option context.

See g_option_context_set_summary() for more information.

self

Passed: a <GApplication>.

the <GApplication>

summary

Passed, or left out: a string, or #f.

a string to be shown in --help output before the list of options, or #f

Method: application:set-resource-base-path self [resource-path]
Method: set-resource-base-path self [resource-path]

Sets (or unsets) the base resource path of self.

The path is used to automatically load various [application resources]<GResource> such as menu layouts and action descriptions. The various types of resources will be found at fixed names relative to the given base path.

By default, the resource base path is determined from the application ID by prefixing ’/’ and replacing each ’.’ with ’/’. This is done at the time that the <GApplication> object is constructed. Changes to the application ID after that point will not have an impact on the resource base path.

As an example, if the application has an ID of "org.example.app" then the default resource base path will be "/org/example/app". If this is a <GtkApplication> (and you have not manually changed the path) then Gtk will then search for the menus of the application at "/org/example/app/gtk/menus.ui".

See <GResource> for more information about adding resources to your application.

You can disable automatic resource loading functionality by setting the path to #f.

Changing the resource base path once the application is running is not recommended. The point at which the resource path is consulted for forming paths for various purposes is unspecified. When writing a sub-class of <GApplication> you should either set the application:resource-base-path property at construction time, or call this function during the instance initialization. Alternatively, you can call this function in the GApplicationClass.startup virtual function, before chaining up to the parent implementation.

self

Passed: a <GApplication>.

a <GApplication>

resource-path

Passed, or left out: a string, or #f.

the resource path to use

Method: application:set-version self version
Method: set-version self version

Sets the version number of self. This will be used to implement a --version command line argument

The application version can only be modified if self has not yet been registered.

self

Passed: a <GApplication>.

a <GApplication>

version

Passed: a string.

the version of self

Method: application:unbind-busy-property self object property
Method: unbind-busy-property self object property

Destroys a binding between property and the busy state of self that was previously created with application:bind-busy-property.

self

Passed: a <GApplication>.

a <GApplication>

object

Passed: a <GObject>.

a <GObject>

property

Passed: a string.

the name of a boolean property of object

Method: application:unmark-busy self
Method: unmark-busy self

Decreases the busy count of self.

When the busy count reaches zero, the new state will be propagated to other processes.

This function must only be called to cancel the effect of a previous call to application:mark-busy.

self

Passed: a <GApplication>.

a <GApplication>

Method: application:withdraw-notification self id
Method: withdraw-notification self id

Withdraws a notification that was sent with application:send-notification.

This call does nothing if a notification with id doesn’t exist or the notification was never sent.

This function works even for notifications sent in previous executions of this application, as long id is the same as it was for the sent notification.

Note that notifications are dismissed when the user clicks on one of the buttons in a notification or triggers its default action, so there is no need to explicitly withdraw the notification in that case.

self

Passed: a <GApplication>.

a <GApplication>

id

Passed: a string.

id of a previously sent notification

Signals

Signal: application:activate

Connect a handler with (connect object application:activate handler). It is called as (handler self).

The ::activate signal is emitted on the primary instance when an activation occurs. See application:activate.

self

Passed: a <GApplication>.

Signal: application:command-line

Connect a handler with (connect object application:command-line handler). It is called as (handler self command-line) ⇒ %return.

The ::command-line signal is emitted on the primary instance when a commandline is not handled locally. See application:run and the <GApplicationCommandLine> documentation for more information.

self

Passed: a <GApplication>.

command-line

Passed: a <GApplicationCommandLine>.

a <GApplicationCommandLine> representing the passed commandline

%return

Returned: a 32-bit integer.

An integer that is set as the exit status for the calling process. See application-command-line:set-exit-status.

Signal: application:handle-local-options

Connect a handler with (connect object application:handle-local-options handler). It is called as (handler self options) ⇒ %return.

The ::handle-local-options signal is emitted on the local instance after the parsing of the commandline options has occurred.

You can add options to be recognised during commandline option parsing using g_application_add_main_option_entries() and application:add-option-group.

Signal handlers can inspect options (along with values pointed to from the arg-data of an installed GOptionEntrys) in order to decide to perform certain actions, including direct local handling (which may be useful for options like –version).

In the event that the application is marked handles-command-line the "normal processing" will send the options dictionary to the primary instance where it can be read with application-command-line:get-options-dict. The signal handler can modify the dictionary before returning, and the modified dictionary will be sent.

In the event that handles-command-line is not set, "normal processing" will treat the remaining uncollected command line arguments as filenames or URIs. If there are no arguments, the application is activated by application:activate. One or more arguments results in a call to application:open.

If you want to handle the local commandline arguments for yourself by converting them to calls to application:open or action-group:activate-action then you must be sure to register the application first. You should probably not call application:activate for yourself, however: just return -1 and allow the default handler to do it for you. This will ensure that the --gapplication-service switch works properly (i.e. no activation in that case).

Note that this signal is emitted from the default implementation of local_command_line(). If you override that function and don’t chain up then this signal will never be emitted.

You can override local_command_line() if you need more powerful capabilities than what is provided here, but this should not normally be required.

self

Passed: a <GApplication>.

options

Passed: a <GVariantDict>.

the options dictionary

%return

Returned: a 32-bit integer.

an exit code. If you have handled your options and want to exit the process, return a non-negative option, 0 for success, and a positive value for failure. To continue, return -1 to let the default option processing continue.

Signal: application:name-lost

Connect a handler with (connect object application:name-lost handler). It is called as (handler self) ⇒ %return.

The ::name-lost signal is emitted only on the registered primary instance when a new instance has taken over. This can only happen if the application is using the allow-replacement flag.

The default handler for this signal calls application:quit.

self

Passed: a <GApplication>.

%return

Returned: a boolean.

#t if the signal has been handled

Signal: application:open

Connect a handler with (connect object application:open handler). It is called as (handler self files hint).

The ::open signal is emitted on the primary instance when there are files to open. See application:open for more information.

self

Passed: a <GApplication>.

files

Passed: a vector, each a <GFile>.

an array of GFiles

hint

Passed: a string.

a hint provided by the calling instance

n-files

Not passed: guile-gi gives the length of files.

the length of files

Signal: application:shutdown

Connect a handler with (connect object application:shutdown handler). It is called as (handler self).

The ::shutdown signal is emitted only on the registered primary instance immediately after the main loop terminates.

self

Passed: a <GApplication>.

Signal: application:startup

Connect a handler with (connect object application:startup handler). It is called as (handler self).

The ::startup signal is emitted on the primary instance immediately after registration. See application:register?.

self

Passed: a <GApplication>.

Virtual methods

Virtual method: application:do-activate implementor self

Activates the application.

In essence, this results in the application:activate signal being emitted in the primary instance.

The application must be registered before calling this function.

To override it in a new class, give register-type #:vfuncs `((activate . ,procedure)). The procedure is called as (procedure self).

implementor

Passed: the class whose implementation to call: <GApplication>, or a class that derives from it, or its GType number.

self

Passed: a <GApplication>.

a <GApplication>

Virtual method: application:do-add-platform-data implementor self builder

invoked (locally) to add ’platform data’ to be sent to the primary instance when activating, opening or invoking actions. Must chain up

To override it in a new class, give register-type #:vfuncs `((add-platform-data . ,procedure)). The procedure is called as (procedure self builder).

implementor

Passed: the class whose implementation to call: <GApplication>, or a class that derives from it, or its GType number.

self

Passed: a <GApplication>.

builder

Passed: a <GVariantBuilder>.

Virtual method: application:do-after-emit implementor self platform-data

invoked on the primary instance after ’activate’, ’open’, ’command-line’ or any action invocation, gets the ’platform data’ from the calling instance. Must chain up

To override it in a new class, give register-type #:vfuncs `((after-emit . ,procedure)). The procedure is called as (procedure self platform-data).

implementor

Passed: the class whose implementation to call: <GApplication>, or a class that derives from it, or its GType number.

self

Passed: a <GApplication>.

platform-data

Passed: a <GVariant>.

Virtual method: application:do-before-emit implementor self platform-data

invoked on the primary instance before ’activate’, ’open’, ’command-line’ or any action invocation, gets the ’platform data’ from the calling instance. Must chain up

To override it in a new class, give register-type #:vfuncs `((before-emit . ,procedure)). The procedure is called as (procedure self platform-data).

implementor

Passed: the class whose implementation to call: <GApplication>, or a class that derives from it, or its GType number.

self

Passed: a <GApplication>.

platform-data

Passed: a <GVariant>.

Virtual method: application:do-command-line implementor self command-line ⇒ %return

invoked on the primary instance when a command-line is not handled locally

To override it in a new class, give register-type #:vfuncs `((command-line . ,procedure)). The procedure is called as (procedure self command-line) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GApplication>, or a class that derives from it, or its GType number.

self

Passed: a <GApplication>.

command-line

Passed: a <GApplicationCommandLine>.

%return

Returned: a 32-bit integer.

Virtual method: application:do-dbus-register implementor self connection object-path ⇒ %return

invoked locally during registration, if the application is using its D-Bus backend. You can use this to export extra objects on the bus, that need to exist before the application tries to own the bus name. The function is passed the <GDBusConnection> to to session bus, and the object path that <GApplication> will use to export its D-Bus API. If this function returns #t, registration will proceed; otherwise registration will abort. Since: 2.34

To override it in a new class, give register-type #:vfuncs `((dbus-register . ,procedure)). The procedure is called as (procedure self connection object-path) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GApplication>, or a class that derives from it, or its GType number.

self

Passed: a <GApplication>.

connection

Passed: a <GDBusConnection>.

object-path

Passed: a string.

%return

Returned: a boolean.

Virtual method: application:do-dbus-unregister implementor self connection object-path

invoked locally during unregistration, if the application is using its D-Bus backend. Use this to undo anything done by the dbus-register vfunc. Since: 2.34

To override it in a new class, give register-type #:vfuncs `((dbus-unregister . ,procedure)). The procedure is called as (procedure self connection object-path).

implementor

Passed: the class whose implementation to call: <GApplication>, or a class that derives from it, or its GType number.

self

Passed: a <GApplication>.

connection

Passed: a <GDBusConnection>.

object-path

Passed: a string.

Virtual method: application:do-handle-local-options implementor self options ⇒ %return

invoked locally after the parsing of the commandline options has occurred. Since: 2.40

To override it in a new class, give register-type #:vfuncs `((handle-local-options . ,procedure)). The procedure is called as (procedure self options) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GApplication>, or a class that derives from it, or its GType number.

self

Passed: a <GApplication>.

options

Passed: a <GVariantDict>.

%return

Returned: a 32-bit integer.

Virtual method: application:do-local-command-line implementor self arguments ⇒ %return arguments exit-status

This virtual function is always invoked in the local instance. It gets passed a pointer to a #f-terminated copy of argv and is expected to remove arguments that it handled (shifting up remaining arguments).

The last argument to local_command_line() is a pointer to the status variable which can used to set the exit status that is returned from application:run.

See application:run for more details on <GApplication> startup.

To override it in a new class, give register-type #:vfuncs `((local-command-line . ,procedure)). The procedure is called as (procedure self arguments) ⇒ %return arguments exit-status.

implementor

Passed: the class whose implementation to call: <GApplication>, or a class that derives from it, or its GType number.

self

Passed: a <GApplication>.

a <GApplication>

arguments

Passed: a list or vector, each a string. Returned: a vector, each a string.

array of command line arguments

%return

Returned: a boolean.

#t if the commandline has been completely handled

exit-status

Returned: a 32-bit integer.

exit status to fill after processing the command line.

Virtual method: application:do-name-lost implementor self ⇒ %return

invoked when another instance is taking over the name. Since: 2.60

To override it in a new class, give register-type #:vfuncs `((name-lost . ,procedure)). The procedure is called as (procedure self) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GApplication>, or a class that derives from it, or its GType number.

self

Passed: a <GApplication>.

%return

Returned: a boolean.

Virtual method: application:do-open implementor self files hint

Opens the given files.

In essence, this results in the application:open signal being emitted in the primary instance.

n-files must be greater than zero.

hint is simply passed through to the ::open signal. It is intended to be used by applications that have multiple modes for opening files (eg: "view" vs "edit", etc). Unless you have a need for this functionality, you should use "".

The application must be registered before calling this function and it must have the handles-open flag set.

To override it in a new class, give register-type #:vfuncs `((open . ,procedure)). The procedure is called as (procedure self files hint).

implementor

Passed: the class whose implementation to call: <GApplication>, or a class that derives from it, or its GType number.

self

Passed: a <GApplication>.

a <GApplication>

files

Passed: a list or vector, each a <GFile>.

an array of GFiles to open

hint

Passed: a string.

a hint (or ""), but never #f

n-files

Not passed: guile-gi gives the length of files.

the length of the files array

Virtual method: application:do-quit-mainloop implementor self

Used to be invoked on the primary instance when the use count of the application drops to zero (and after any inactivity timeout, if requested). Not used anymore since 2.32

To override it in a new class, give register-type #:vfuncs `((quit-mainloop . ,procedure)). The procedure is called as (procedure self).

implementor

Passed: the class whose implementation to call: <GApplication>, or a class that derives from it, or its GType number.

self

Passed: a <GApplication>.

Virtual method: application:do-run-mainloop implementor self

Used to be invoked on the primary instance from application:run if the use-count is non-zero. Since 2.32, GApplication is iterating the main context directly and is not using run-mainloop anymore

To override it in a new class, give register-type #:vfuncs `((run-mainloop . ,procedure)). The procedure is called as (procedure self).

implementor

Passed: the class whose implementation to call: <GApplication>, or a class that derives from it, or its GType number.

self

Passed: a <GApplication>.

Virtual method: application:do-shutdown implementor self

invoked only on the registered primary instance immediately after the main loop terminates

To override it in a new class, give register-type #:vfuncs `((shutdown . ,procedure)). The procedure is called as (procedure self).

implementor

Passed: the class whose implementation to call: <GApplication>, or a class that derives from it, or its GType number.

self

Passed: a <GApplication>.

Virtual method: application:do-startup implementor self

invoked on the primary instance immediately after registration

To override it in a new class, give register-type #:vfuncs `((startup . ,procedure)). The procedure is called as (procedure self).

implementor

Passed: the class whose implementation to call: <GApplication>, or a class that derives from it, or its GType number.

self

Passed: a <GApplication>.