Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (inaki@blueleaf.cc) |
Safe Haskell | None |
Language | Haskell2010 |
- Exported types
- Methods
- activate
- addMainOption
- addMainOptionEntries
- addOptionGroup
- bindBusyProperty
- getApplicationId
- getDbusConnection
- getDbusObjectPath
- getDefault
- getFlags
- getInactivityTimeout
- getIsBusy
- getIsRegistered
- getIsRemote
- getResourceBasePath
- hold
- idIsValid
- markBusy
- new
- open
- quit
- register
- release
- run
- sendNotification
- setActionGroup
- setApplicationId
- setDefault
- setFlags
- setInactivityTimeout
- setOptionContextDescription
- setOptionContextParameterString
- setOptionContextSummary
- setResourceBasePath
- unbindBusyProperty
- unmarkBusy
- withdrawNotification
- Properties
- Signals
A Application
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 applicationHold
and applicationRelease
. 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 the always the current instance. On Linux, the D-Bus session bus is used for communication.
The use of Application
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
Application
should do very little more than instantiating the
application instance, possibly connecting signal handlers, then
calling applicationRun
. 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 applicationRun
promptly returns. See the code
examples below.
If used, the expected form of an application identifier is the same as
that of 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 applicationIdIsValid
.
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 Application
attempts to acquire the bus name of your application (which happens in
applicationRegister
). Unfortunately, this means that you cannot use
applicationGetIsRemote
to decide if you want to register object paths.
GApplication also implements the ActionGroup
and ActionMap
interfaces and lets you easily export actions by adding them with
actionMapAddAction
. When invoking an action by calling
actionGroupActivateAction
on the application, it is always
invoked in the primary instance. The actions are also exported on
the session bus, and GIO provides the DBusActionGroup
wrapper to
conveniently access them remotely. GIO provides a DBusMenuModel
wrapper
for remote access to exported GMenuModels
.
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 beforeEmit
or afterEmit
virtual functions
in your Application
subclass. When dealing with
ApplicationCommandLine
objects, the platform data is
directly available via applicationCommandLineGetCwd
,
applicationCommandLineGetEnviron
and
applicationCommandLineGetPlatformData
.
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
ApplicationFlagsSendEnvironment
flag is set. Application
subclasses
can add their own platform data by overriding the addPlatformData
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 local_command_line()
vfunc, 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.
Since: 2.28
Synopsis
- newtype Application = Application (ManagedPtr Application)
- class (GObject o, IsDescendantOf Application o) => IsApplication o
- toApplication :: (MonadIO m, IsApplication o) => o -> m Application
- noApplication :: Maybe Application
- applicationActivate :: (HasCallStack, MonadIO m, IsApplication a) => a -> m ()
- applicationAddMainOption :: (HasCallStack, MonadIO m, IsApplication a) => a -> Text -> Int8 -> [OptionFlags] -> OptionArg -> Text -> Maybe Text -> m ()
- applicationAddMainOptionEntries :: (HasCallStack, MonadIO m, IsApplication a) => a -> [OptionEntry] -> m ()
- applicationAddOptionGroup :: (HasCallStack, MonadIO m, IsApplication a) => a -> OptionGroup -> m ()
- applicationBindBusyProperty :: (HasCallStack, MonadIO m, IsApplication a, IsObject b) => a -> b -> Text -> m ()
- applicationGetApplicationId :: (HasCallStack, MonadIO m, IsApplication a) => a -> m Text
- applicationGetDbusConnection :: (HasCallStack, MonadIO m, IsApplication a) => a -> m DBusConnection
- applicationGetDbusObjectPath :: (HasCallStack, MonadIO m, IsApplication a) => a -> m Text
- applicationGetDefault :: (HasCallStack, MonadIO m) => m Application
- applicationGetFlags :: (HasCallStack, MonadIO m, IsApplication a) => a -> m [ApplicationFlags]
- applicationGetInactivityTimeout :: (HasCallStack, MonadIO m, IsApplication a) => a -> m Word32
- applicationGetIsBusy :: (HasCallStack, MonadIO m, IsApplication a) => a -> m Bool
- applicationGetIsRegistered :: (HasCallStack, MonadIO m, IsApplication a) => a -> m Bool
- applicationGetIsRemote :: (HasCallStack, MonadIO m, IsApplication a) => a -> m Bool
- applicationGetResourceBasePath :: (HasCallStack, MonadIO m, IsApplication a) => a -> m (Maybe Text)
- applicationHold :: (HasCallStack, MonadIO m, IsApplication a) => a -> m ()
- applicationIdIsValid :: (HasCallStack, MonadIO m) => Text -> m Bool
- applicationMarkBusy :: (HasCallStack, MonadIO m, IsApplication a) => a -> m ()
- applicationNew :: (HasCallStack, MonadIO m) => Maybe Text -> [ApplicationFlags] -> m (Maybe Application)
- applicationOpen :: (HasCallStack, MonadIO m, IsApplication a) => a -> [File] -> Text -> m ()
- applicationQuit :: (HasCallStack, MonadIO m, IsApplication a) => a -> m ()
- applicationRegister :: (HasCallStack, MonadIO m, IsApplication a, IsCancellable b) => a -> Maybe b -> m ()
- applicationRelease :: (HasCallStack, MonadIO m, IsApplication a) => a -> m ()
- applicationRun :: (HasCallStack, MonadIO m, IsApplication a) => a -> Maybe [[Char]] -> m Int32
- applicationSendNotification :: (HasCallStack, MonadIO m, IsApplication a, IsNotification b) => a -> Maybe Text -> b -> m ()
- applicationSetActionGroup :: (HasCallStack, MonadIO m, IsApplication a, IsActionGroup b) => a -> Maybe b -> m ()
- applicationSetApplicationId :: (HasCallStack, MonadIO m, IsApplication a) => a -> Maybe Text -> m ()
- applicationSetDefault :: (HasCallStack, MonadIO m, IsApplication a) => a -> m ()
- applicationSetFlags :: (HasCallStack, MonadIO m, IsApplication a) => a -> [ApplicationFlags] -> m ()
- applicationSetInactivityTimeout :: (HasCallStack, MonadIO m, IsApplication a) => a -> Word32 -> m ()
- applicationSetOptionContextDescription :: (HasCallStack, MonadIO m, IsApplication a) => a -> Maybe Text -> m ()
- applicationSetOptionContextParameterString :: (HasCallStack, MonadIO m, IsApplication a) => a -> Maybe Text -> m ()
- applicationSetOptionContextSummary :: (HasCallStack, MonadIO m, IsApplication a) => a -> Maybe Text -> m ()
- applicationSetResourceBasePath :: (HasCallStack, MonadIO m, IsApplication a) => a -> Maybe Text -> m ()
- applicationUnbindBusyProperty :: (HasCallStack, MonadIO m, IsApplication a, IsObject b) => a -> b -> Text -> m ()
- applicationUnmarkBusy :: (HasCallStack, MonadIO m, IsApplication a) => a -> m ()
- applicationWithdrawNotification :: (HasCallStack, MonadIO m, IsApplication a) => a -> Text -> m ()
- clearApplicationActionGroup :: (MonadIO m, IsApplication o) => o -> m ()
- constructApplicationActionGroup :: (IsApplication o, IsActionGroup a) => a -> IO (GValueConstruct o)
- setApplicationActionGroup :: (MonadIO m, IsApplication o, IsActionGroup a) => o -> a -> m ()
- clearApplicationApplicationId :: (MonadIO m, IsApplication o) => o -> m ()
- constructApplicationApplicationId :: IsApplication o => Text -> IO (GValueConstruct o)
- getApplicationApplicationId :: (MonadIO m, IsApplication o) => o -> m Text
- setApplicationApplicationId :: (MonadIO m, IsApplication o) => o -> Text -> m ()
- constructApplicationFlags :: IsApplication o => [ApplicationFlags] -> IO (GValueConstruct o)
- getApplicationFlags :: (MonadIO m, IsApplication o) => o -> m [ApplicationFlags]
- setApplicationFlags :: (MonadIO m, IsApplication o) => o -> [ApplicationFlags] -> m ()
- constructApplicationInactivityTimeout :: IsApplication o => Word32 -> IO (GValueConstruct o)
- getApplicationInactivityTimeout :: (MonadIO m, IsApplication o) => o -> m Word32
- setApplicationInactivityTimeout :: (MonadIO m, IsApplication o) => o -> Word32 -> m ()
- getApplicationIsBusy :: (MonadIO m, IsApplication o) => o -> m Bool
- getApplicationIsRegistered :: (MonadIO m, IsApplication o) => o -> m Bool
- getApplicationIsRemote :: (MonadIO m, IsApplication o) => o -> m Bool
- clearApplicationResourceBasePath :: (MonadIO m, IsApplication o) => o -> m ()
- constructApplicationResourceBasePath :: IsApplication o => Text -> IO (GValueConstruct o)
- getApplicationResourceBasePath :: (MonadIO m, IsApplication o) => o -> m (Maybe Text)
- setApplicationResourceBasePath :: (MonadIO m, IsApplication o) => o -> Text -> m ()
- type ApplicationActivateCallback = IO ()
- type C_ApplicationActivateCallback = Ptr () -> Ptr () -> IO ()
- afterApplicationActivate :: (IsApplication a, MonadIO m) => a -> ApplicationActivateCallback -> m SignalHandlerId
- genClosure_ApplicationActivate :: MonadIO m => ApplicationActivateCallback -> m (GClosure C_ApplicationActivateCallback)
- mk_ApplicationActivateCallback :: C_ApplicationActivateCallback -> IO (FunPtr C_ApplicationActivateCallback)
- noApplicationActivateCallback :: Maybe ApplicationActivateCallback
- onApplicationActivate :: (IsApplication a, MonadIO m) => a -> ApplicationActivateCallback -> m SignalHandlerId
- wrap_ApplicationActivateCallback :: ApplicationActivateCallback -> C_ApplicationActivateCallback
- type ApplicationCommandLineCallback = ApplicationCommandLine -> IO Int32
- type C_ApplicationCommandLineCallback = Ptr () -> Ptr ApplicationCommandLine -> Ptr () -> IO Int32
- afterApplicationCommandLine :: (IsApplication a, MonadIO m) => a -> ApplicationCommandLineCallback -> m SignalHandlerId
- genClosure_ApplicationCommandLine :: MonadIO m => ApplicationCommandLineCallback -> m (GClosure C_ApplicationCommandLineCallback)
- mk_ApplicationCommandLineCallback :: C_ApplicationCommandLineCallback -> IO (FunPtr C_ApplicationCommandLineCallback)
- noApplicationCommandLineCallback :: Maybe ApplicationCommandLineCallback
- onApplicationCommandLine :: (IsApplication a, MonadIO m) => a -> ApplicationCommandLineCallback -> m SignalHandlerId
- wrap_ApplicationCommandLineCallback :: ApplicationCommandLineCallback -> C_ApplicationCommandLineCallback
- type ApplicationHandleLocalOptionsCallback = VariantDict -> IO Int32
- type C_ApplicationHandleLocalOptionsCallback = Ptr () -> Ptr VariantDict -> Ptr () -> IO Int32
- afterApplicationHandleLocalOptions :: (IsApplication a, MonadIO m) => a -> ApplicationHandleLocalOptionsCallback -> m SignalHandlerId
- genClosure_ApplicationHandleLocalOptions :: MonadIO m => ApplicationHandleLocalOptionsCallback -> m (GClosure C_ApplicationHandleLocalOptionsCallback)
- mk_ApplicationHandleLocalOptionsCallback :: C_ApplicationHandleLocalOptionsCallback -> IO (FunPtr C_ApplicationHandleLocalOptionsCallback)
- noApplicationHandleLocalOptionsCallback :: Maybe ApplicationHandleLocalOptionsCallback
- onApplicationHandleLocalOptions :: (IsApplication a, MonadIO m) => a -> ApplicationHandleLocalOptionsCallback -> m SignalHandlerId
- wrap_ApplicationHandleLocalOptionsCallback :: ApplicationHandleLocalOptionsCallback -> C_ApplicationHandleLocalOptionsCallback
- type ApplicationNameLostCallback = IO Bool
- type C_ApplicationNameLostCallback = Ptr () -> Ptr () -> IO CInt
- afterApplicationNameLost :: (IsApplication a, MonadIO m) => a -> ApplicationNameLostCallback -> m SignalHandlerId
- genClosure_ApplicationNameLost :: MonadIO m => ApplicationNameLostCallback -> m (GClosure C_ApplicationNameLostCallback)
- mk_ApplicationNameLostCallback :: C_ApplicationNameLostCallback -> IO (FunPtr C_ApplicationNameLostCallback)
- noApplicationNameLostCallback :: Maybe ApplicationNameLostCallback
- onApplicationNameLost :: (IsApplication a, MonadIO m) => a -> ApplicationNameLostCallback -> m SignalHandlerId
- wrap_ApplicationNameLostCallback :: ApplicationNameLostCallback -> C_ApplicationNameLostCallback
- type ApplicationOpenCallback = [File] -> Text -> IO ()
- type C_ApplicationOpenCallback = Ptr () -> Ptr (Ptr File) -> Int32 -> CString -> Ptr () -> IO ()
- afterApplicationOpen :: (IsApplication a, MonadIO m) => a -> ApplicationOpenCallback -> m SignalHandlerId
- genClosure_ApplicationOpen :: MonadIO m => ApplicationOpenCallback -> m (GClosure C_ApplicationOpenCallback)
- mk_ApplicationOpenCallback :: C_ApplicationOpenCallback -> IO (FunPtr C_ApplicationOpenCallback)
- noApplicationOpenCallback :: Maybe ApplicationOpenCallback
- onApplicationOpen :: (IsApplication a, MonadIO m) => a -> ApplicationOpenCallback -> m SignalHandlerId
- wrap_ApplicationOpenCallback :: ApplicationOpenCallback -> C_ApplicationOpenCallback
- type ApplicationShutdownCallback = IO ()
- type C_ApplicationShutdownCallback = Ptr () -> Ptr () -> IO ()
- afterApplicationShutdown :: (IsApplication a, MonadIO m) => a -> ApplicationShutdownCallback -> m SignalHandlerId
- genClosure_ApplicationShutdown :: MonadIO m => ApplicationShutdownCallback -> m (GClosure C_ApplicationShutdownCallback)
- mk_ApplicationShutdownCallback :: C_ApplicationShutdownCallback -> IO (FunPtr C_ApplicationShutdownCallback)
- noApplicationShutdownCallback :: Maybe ApplicationShutdownCallback
- onApplicationShutdown :: (IsApplication a, MonadIO m) => a -> ApplicationShutdownCallback -> m SignalHandlerId
- wrap_ApplicationShutdownCallback :: ApplicationShutdownCallback -> C_ApplicationShutdownCallback
- type ApplicationStartupCallback = IO ()
- type C_ApplicationStartupCallback = Ptr () -> Ptr () -> IO ()
- afterApplicationStartup :: (IsApplication a, MonadIO m) => a -> ApplicationStartupCallback -> m SignalHandlerId
- genClosure_ApplicationStartup :: MonadIO m => ApplicationStartupCallback -> m (GClosure C_ApplicationStartupCallback)
- mk_ApplicationStartupCallback :: C_ApplicationStartupCallback -> IO (FunPtr C_ApplicationStartupCallback)
- noApplicationStartupCallback :: Maybe ApplicationStartupCallback
- onApplicationStartup :: (IsApplication a, MonadIO m) => a -> ApplicationStartupCallback -> m SignalHandlerId
- wrap_ApplicationStartupCallback :: ApplicationStartupCallback -> C_ApplicationStartupCallback
Exported types
newtype Application Source #
Memory-managed wrapper type.
Instances
GObject Application Source # | |
Defined in GI.Gio.Objects.Application gobjectType :: IO GType # | |
HasParentTypes Application Source # | |
Defined in GI.Gio.Objects.Application | |
type ParentTypes Application Source # | |
Defined in GI.Gio.Objects.Application |
class (GObject o, IsDescendantOf Application o) => IsApplication o Source #
Type class for types which can be safely cast to Application
, for instance with toApplication
.
Instances
(GObject o, IsDescendantOf Application o) => IsApplication o Source # | |
Defined in GI.Gio.Objects.Application |
toApplication :: (MonadIO m, IsApplication o) => o -> m Application Source #
Cast to Application
, for types for which this is known to be safe. For general casts, use castTo
.
noApplication :: Maybe Application Source #
A convenience alias for Nothing
:: Maybe
Application
.
Methods
activate
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> m () |
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.
Since: 2.28
addMainOption
applicationAddMainOption Source #
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> Text |
|
-> Int8 |
|
-> [OptionFlags] |
|
-> OptionArg |
|
-> Text |
|
-> Maybe Text |
|
-> m () |
Add an option to be handled by application
.
Calling this function is the equivalent of calling
applicationAddMainOptionEntries
with a single OptionEntry
that has its arg_data member set to Nothing
.
The parsed arguments will be packed into a VariantDict
which
is passed to Application
::handle-local-options
. If
ApplicationFlagsHandlesCommandLine
is set, then it will also
be sent to the primary instance. See
applicationAddMainOptionEntries
for more details.
See OptionEntry
for more documentation of the arguments.
Since: 2.42
addMainOptionEntries
applicationAddMainOptionEntries Source #
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> [OptionEntry] |
|
-> m () |
Adds main option entries to be handled by application
.
This function is comparable to optionContextAddMainEntries
.
After the commandline arguments are parsed, the
Application
::handle-local-options
signal will be emitted. At this
point, the application can inspect the values pointed to by argData
in the given GOptionEntrys
.
Unlike OptionContext
, Application
supports giving a Nothing
argData
for a non-callback OptionEntry
. This results in the
argument in question being packed into a VariantDict
which is also
passed to Application
::handle-local-options
, where it can be
inspected and modified. If ApplicationFlagsHandlesCommandLine
is
set, then the resulting dictionary is sent to the primary instance,
where applicationCommandLineGetOptionsDict
will return it.
This "packing" is done according to the type of the argument --
booleans for normal flags, strings for strings, bytestrings for
filenames, etc. The packing only occurs if the flag is given (ie: we
do not pack a "false" GVariant
in the case that a flag is missing).
In general, it is recommended that all commandline arguments are
parsed locally. The options dictionary should then be used to
transmit the result of the parsing to the primary instance, where
g_variant_dict_lookup()
can be used. For local options, it is
possible to either use argData
in the usual way, or to consult (and
potentially remove) the option from the options dictionary.
This function is new in GLib 2.40. Before then, the only real choice
was to send all of the commandline arguments (options and all) to the
primary instance for handling. Application
ignored them completely
on the local side. Calling this function "opts in" to the new
behaviour, and in particular, means that unrecognised options will be
treated as errors. Unrecognised options have never been ignored when
ApplicationFlagsHandlesCommandLine
is unset.
If Application
::handle-local-options
needs to see the list of
filenames, then the use of OPTION_REMAINING
is recommended. If
argData
is Nothing
then OPTION_REMAINING
can be used as a key into
the options dictionary. If you do use OPTION_REMAINING
then you
need to handle these arguments for yourself because once they are
consumed, they will no longer be visible to the default handling
(which treats them as filenames to be opened).
It is important to use the proper GVariant format when retrieving
the options with g_variant_dict_lookup()
:
- for
OptionArgNone
, use b - for
OptionArgString
, use &s - for
OptionArgInt
, use i - for
OptionArgInt64
, use x - for
OptionArgDouble
, use d - for
OptionArgFilename
, use ^ay - for
OptionArgStringArray
, use &as - for
OptionArgFilenameArray
, use ^aay
Since: 2.40
addOptionGroup
applicationAddOptionGroup Source #
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> OptionGroup |
|
-> m () |
Adds a OptionGroup
to the commandline handling of application
.
This function is comparable to optionContextAddGroup
.
Unlike applicationAddMainOptionEntries
, this function does
not deal with Nothing
argData
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 OptionGroup
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 unrecognised options are rejected even if
ApplicationFlagsHandlesCommandLine
was given.
Since: 2.40
bindBusyProperty
applicationBindBusyProperty Source #
:: (HasCallStack, MonadIO m, IsApplication a, IsObject b) | |
=> a |
|
-> b |
|
-> Text |
|
-> m () |
Marks application
as busy (see applicationMarkBusy
) while
property
on object
is True
.
The binding holds a reference to application
while it is active, but
not to object
. Instead, the binding is destroyed when object
is
finalized.
Since: 2.44
getApplicationId
applicationGetApplicationId Source #
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> m Text | Returns: the identifier for |
Gets the unique identifier for application
.
Since: 2.28
getDbusConnection
applicationGetDbusConnection Source #
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> m DBusConnection | Returns: a |
Gets the DBusConnection
being used by the application, or Nothing
.
If Application
is using its D-Bus backend then this function will
return the DBusConnection
being used for uniqueness and
communication with the desktop environment and other instances of the
application.
If Application
is not using D-Bus then this function will return
Nothing
. 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 applicationGetIsRegistered
.
Since: 2.34
getDbusObjectPath
applicationGetDbusObjectPath Source #
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> m Text | Returns: the object path, or |
Gets the D-Bus object path being used by the application, or Nothing
.
If Application
is using its D-Bus backend then this function will
return the D-Bus object path that Application
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 Application
is not using D-Bus then this function will return
Nothing
. 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 applicationGetIsRegistered
.
Since: 2.34
getDefault
applicationGetDefault Source #
:: (HasCallStack, MonadIO m) | |
=> m Application | Returns: the default application for this process, or |
Returns the default Application
instance for this process.
Normally there is only one Application
per process and it becomes
the default when it is created. You can exercise more control over
this by using applicationSetDefault
.
If there is no default application then Nothing
is returned.
Since: 2.32
getFlags
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> m [ApplicationFlags] | Returns: the flags for |
getInactivityTimeout
applicationGetInactivityTimeout Source #
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> m Word32 | Returns: the timeout, in milliseconds |
Gets the current inactivity timeout for the application.
This is the amount of time (in milliseconds) after the last call to
applicationRelease
before the application stops running.
Since: 2.28
getIsBusy
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> m Bool | Returns: |
Gets the application's current busy state, as set through
applicationMarkBusy
or applicationBindBusyProperty
.
Since: 2.44
getIsRegistered
applicationGetIsRegistered Source #
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> m Bool | Returns: |
Checks if application
is registered.
An application is registered if applicationRegister
has been
successfully called.
Since: 2.28
getIsRemote
applicationGetIsRemote Source #
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> m Bool | Returns: |
Checks if application
is remote.
If application
is remote then it means that another instance of
application already exists (the 'primary' instance). Calls to
perform actions on application
will result in the actions being
performed by the primary instance.
The value of this property cannot be accessed before
applicationRegister
has been called. See
applicationGetIsRegistered
.
Since: 2.28
getResourceBasePath
applicationGetResourceBasePath Source #
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> m (Maybe Text) | Returns: the base resource path, if one is set |
Gets the resource base path of application
.
See applicationSetResourceBasePath
for more information.
Since: 2.42
hold
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> m () |
Increases the use count of application
.
Use this function to indicate that the application has a reason to
continue to run. For example, applicationHold
is called by GTK+
when a toplevel window is on the screen.
To cancel the hold, call applicationRelease
.
idIsValid
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m Bool | Returns: |
Checks if applicationId
is a valid application identifier.
A valid ID is required for calls to applicationNew
and
applicationSetApplicationId
.
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
.
markBusy
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> m () |
Increases the busy count of application
.
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 applicationUnmarkBusy
.
Since: 2.38
new
:: (HasCallStack, MonadIO m) | |
=> Maybe Text |
|
-> [ApplicationFlags] |
|
-> m (Maybe Application) | Returns: a new |
Creates a new Application
instance.
If non-Nothing
, the application id must be valid. See
applicationIdIsValid
.
If no application ID is given then some features of Application
(most notably application uniqueness) will be disabled.
open
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> [File] |
|
-> Text |
|
-> m () |
Opens the given files.
In essence, this results in the Application
::open
signal being emitted
in the primary instance.
nFiles
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 ApplicationFlagsHandlesOpen
flag set.
Since: 2.28
quit
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> m () |
Immediately quits the application.
Upon return to the mainloop, applicationRun
will return,
calling only the 'shutdown' function before doing so.
The hold count is ignored.
Take care if your code has called applicationHold
on the application and
is therefore still expecting it to exist.
(Note that you may have called applicationHold
indirectly, for example
through gtk_application_add_window()
.)
The result of calling applicationRun
again after it returns is
unspecified.
Since: 2.32
register
:: (HasCallStack, MonadIO m, IsApplication a, IsCancellable b) | |
=> a |
|
-> Maybe b |
|
-> m () | (Can throw |
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 ApplicationFlagsNonUnique
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 True
is
returned with no work performed.
The Application
::startup
signal is emitted if registration succeeds
and application
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), False
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
applicationGetIsRemote
for that.
Since: 2.28
release
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> m () |
Decrease the use count of application
.
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 applicationHold
.
run
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> Maybe [[Char]] |
|
-> m Int32 | Returns: the exit status |
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 Nothing
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).
Application
will attempt to parse the commandline arguments. You
can add commandline flags to the list of recognised options by way of
applicationAddMainOptionEntries
. 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
ApplicationFlagsHandlesCommandLine
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
ApplicationFlagsHandlesOpen
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 Application
subclass
and override local_command_line()
. In this case, you most likely want
to return True
from your local_command_line()
implementation to
suppress the default handling. See
[gapplication-example-cmdline2.c][gapplication-example-cmdline2]
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 ApplicationFlagsIsService
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 applicationSetInactivityTimeout
is in
use.
This function sets the prgname (setPrgname
), if not already set,
to the basename of argv[0].
Much like mainLoopRun
, 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 ApplicationFlagsIsService
or
ApplicationFlagsIsLauncher
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
ApplicationFlagsIsService
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.
Since: 2.28
sendNotification
applicationSendNotification Source #
:: (HasCallStack, MonadIO m, IsApplication a, IsNotification b) | |
=> a |
|
-> Maybe Text |
|
-> b |
|
-> m () |
Sends a notification on behalf of application
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 Nothing
, but it is impossible to replace or withdraw
notifications without an id.
If notification
is no longer relevant, it can be withdrawn with
applicationWithdrawNotification
.
Since: 2.40
setActionGroup
applicationSetActionGroup Source #
:: (HasCallStack, MonadIO m, IsApplication a, IsActionGroup b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Deprecated: (Since version 2.32)Use the ActionMap
interface instead. Never evermix use of this API with use of ActionMap
on the same application
or things will go very badly wrong. This function is known tointroduce buggy behaviour (ie: signals not emitted on changes to theaction group), so you should really use ActionMap
instead.
This used to be how actions were associated with a Application
.
Now there is ActionMap
for that.
Since: 2.28
setApplicationId
applicationSetApplicationId Source #
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> Maybe Text |
|
-> m () |
Sets the unique identifier for application
.
The application id can only be modified if application
has not yet
been registered.
If non-Nothing
, the application id must be valid. See
applicationIdIsValid
.
Since: 2.28
setDefault
applicationSetDefault Source #
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> m () |
Sets or unsets the default application for the process, as returned
by applicationGetDefault
.
This function does not take its own reference on application
. If
application
is destroyed then the default application will revert
back to Nothing
.
Since: 2.32
setFlags
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> [ApplicationFlags] |
|
-> m () |
Sets the flags for application
.
The flags can only be modified if application
has not yet been
registered.
See ApplicationFlags
.
Since: 2.28
setInactivityTimeout
applicationSetInactivityTimeout Source #
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> Word32 |
|
-> m () |
Sets the current inactivity timeout for the application.
This is the amount of time (in milliseconds) after the last call to
applicationRelease
before the application stops running.
This call has no side effects of its own. The value set here is only
used for next time applicationRelease
drops the use count to
zero. Any timeouts currently in progress are not impacted.
Since: 2.28
setOptionContextDescription
applicationSetOptionContextDescription Source #
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> Maybe Text |
|
-> m () |
Adds a description to the application
option context.
See optionContextSetDescription
for more information.
Since: 2.56
setOptionContextParameterString
applicationSetOptionContextParameterString Source #
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> Maybe Text |
|
-> m () |
Sets the parameter string to be used by the commandline handling of application
.
This function registers the argument to be passed to g_option_context_new()
when the internal OptionContext
of application
is created.
See g_option_context_new()
for more information about parameterString
.
Since: 2.56
setOptionContextSummary
applicationSetOptionContextSummary Source #
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> Maybe Text |
|
-> m () |
Adds a summary to the application
option context.
See optionContextSetSummary
for more information.
Since: 2.56
setResourceBasePath
applicationSetResourceBasePath Source #
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> Maybe Text |
|
-> m () |
Sets (or unsets) the base resource path of application
.
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 Application
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 Resource
for more information about adding resources to your
application.
You can disable automatic resource loading functionality by setting
the path to Nothing
.
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 Application
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 ApplicationClass
.startup
virtual function,
before chaining up to the parent implementation.
Since: 2.42
unbindBusyProperty
applicationUnbindBusyProperty Source #
:: (HasCallStack, MonadIO m, IsApplication a, IsObject b) | |
=> a |
|
-> b |
|
-> Text |
|
-> m () |
Destroys a binding between property
and the busy state of
application
that was previously created with
applicationBindBusyProperty
.
Since: 2.44
unmarkBusy
applicationUnmarkBusy Source #
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> m () |
Decreases the busy count of application
.
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 applicationMarkBusy
.
Since: 2.38
withdrawNotification
applicationWithdrawNotification Source #
:: (HasCallStack, MonadIO m, IsApplication a) | |
=> a |
|
-> Text |
|
-> m () |
Withdraws a notification that was sent with
applicationSendNotification
.
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.
Since: 2.40
Properties
actionGroup
No description available in the introspection data.
clearApplicationActionGroup :: (MonadIO m, IsApplication o) => o -> m () Source #
Set the value of the “action-group
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#actionGroup
constructApplicationActionGroup :: (IsApplication o, IsActionGroup a) => a -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “action-group
” property. This is rarely needed directly, but it is used by new
.
setApplicationActionGroup :: (MonadIO m, IsApplication o, IsActionGroup a) => o -> a -> m () Source #
Set the value of the “action-group
” property.
When overloading is enabled, this is equivalent to
set
application [ #actionGroup:=
value ]
applicationId
No description available in the introspection data.
clearApplicationApplicationId :: (MonadIO m, IsApplication o) => o -> m () Source #
Set the value of the “application-id
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#applicationId
constructApplicationApplicationId :: IsApplication o => Text -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “application-id
” property. This is rarely needed directly, but it is used by new
.
getApplicationApplicationId :: (MonadIO m, IsApplication o) => o -> m Text Source #
Get the value of the “application-id
” property.
When overloading is enabled, this is equivalent to
get
application #applicationId
setApplicationApplicationId :: (MonadIO m, IsApplication o) => o -> Text -> m () Source #
Set the value of the “application-id
” property.
When overloading is enabled, this is equivalent to
set
application [ #applicationId:=
value ]
flags
No description available in the introspection data.
constructApplicationFlags :: IsApplication o => [ApplicationFlags] -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “flags
” property. This is rarely needed directly, but it is used by new
.
getApplicationFlags :: (MonadIO m, IsApplication o) => o -> m [ApplicationFlags] Source #
Get the value of the “flags
” property.
When overloading is enabled, this is equivalent to
get
application #flags
setApplicationFlags :: (MonadIO m, IsApplication o) => o -> [ApplicationFlags] -> m () Source #
Set the value of the “flags
” property.
When overloading is enabled, this is equivalent to
set
application [ #flags:=
value ]
inactivityTimeout
No description available in the introspection data.
constructApplicationInactivityTimeout :: IsApplication o => Word32 -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “inactivity-timeout
” property. This is rarely needed directly, but it is used by new
.
getApplicationInactivityTimeout :: (MonadIO m, IsApplication o) => o -> m Word32 Source #
Get the value of the “inactivity-timeout
” property.
When overloading is enabled, this is equivalent to
get
application #inactivityTimeout
setApplicationInactivityTimeout :: (MonadIO m, IsApplication o) => o -> Word32 -> m () Source #
Set the value of the “inactivity-timeout
” property.
When overloading is enabled, this is equivalent to
set
application [ #inactivityTimeout:=
value ]
isBusy
Whether the application is currently marked as busy through
applicationMarkBusy
or applicationBindBusyProperty
.
Since: 2.44
getApplicationIsBusy :: (MonadIO m, IsApplication o) => o -> m Bool Source #
Get the value of the “is-busy
” property.
When overloading is enabled, this is equivalent to
get
application #isBusy
isRegistered
No description available in the introspection data.
getApplicationIsRegistered :: (MonadIO m, IsApplication o) => o -> m Bool Source #
Get the value of the “is-registered
” property.
When overloading is enabled, this is equivalent to
get
application #isRegistered
isRemote
No description available in the introspection data.
getApplicationIsRemote :: (MonadIO m, IsApplication o) => o -> m Bool Source #
Get the value of the “is-remote
” property.
When overloading is enabled, this is equivalent to
get
application #isRemote
resourceBasePath
No description available in the introspection data.
clearApplicationResourceBasePath :: (MonadIO m, IsApplication o) => o -> m () Source #
Set the value of the “resource-base-path
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#resourceBasePath
constructApplicationResourceBasePath :: IsApplication o => Text -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “resource-base-path
” property. This is rarely needed directly, but it is used by new
.
getApplicationResourceBasePath :: (MonadIO m, IsApplication o) => o -> m (Maybe Text) Source #
Get the value of the “resource-base-path
” property.
When overloading is enabled, this is equivalent to
get
application #resourceBasePath
setApplicationResourceBasePath :: (MonadIO m, IsApplication o) => o -> Text -> m () Source #
Set the value of the “resource-base-path
” property.
When overloading is enabled, this is equivalent to
set
application [ #resourceBasePath:=
value ]
Signals
activate
type ApplicationActivateCallback = IO () Source #
The ::activate signal is emitted on the primary instance when an
activation occurs. See applicationActivate
.
type C_ApplicationActivateCallback = Ptr () -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
afterApplicationActivate :: (IsApplication a, MonadIO m) => a -> ApplicationActivateCallback -> m SignalHandlerId Source #
Connect a signal handler for the “activate
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
application #activate callback
genClosure_ApplicationActivate :: MonadIO m => ApplicationActivateCallback -> m (GClosure C_ApplicationActivateCallback) Source #
Wrap the callback into a GClosure
.
mk_ApplicationActivateCallback :: C_ApplicationActivateCallback -> IO (FunPtr C_ApplicationActivateCallback) Source #
Generate a function pointer callable from C code, from a C_ApplicationActivateCallback
.
noApplicationActivateCallback :: Maybe ApplicationActivateCallback Source #
A convenience synonym for
.Nothing
:: Maybe
ApplicationActivateCallback
onApplicationActivate :: (IsApplication a, MonadIO m) => a -> ApplicationActivateCallback -> m SignalHandlerId Source #
Connect a signal handler for the “activate
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
application #activate callback
wrap_ApplicationActivateCallback :: ApplicationActivateCallback -> C_ApplicationActivateCallback Source #
Wrap a ApplicationActivateCallback
into a C_ApplicationActivateCallback
.
commandLine
type ApplicationCommandLineCallback Source #
= ApplicationCommandLine |
|
-> IO Int32 | Returns: An integer that is set as the exit status for the calling
process. See |
The ::command-line signal is emitted on the primary instance when
a commandline is not handled locally. See applicationRun
and
the ApplicationCommandLine
documentation for more information.
type C_ApplicationCommandLineCallback = Ptr () -> Ptr ApplicationCommandLine -> Ptr () -> IO Int32 Source #
Type for the callback on the (unwrapped) C side.
afterApplicationCommandLine :: (IsApplication a, MonadIO m) => a -> ApplicationCommandLineCallback -> m SignalHandlerId Source #
Connect a signal handler for the “command-line
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
application #commandLine callback
genClosure_ApplicationCommandLine :: MonadIO m => ApplicationCommandLineCallback -> m (GClosure C_ApplicationCommandLineCallback) Source #
Wrap the callback into a GClosure
.
mk_ApplicationCommandLineCallback :: C_ApplicationCommandLineCallback -> IO (FunPtr C_ApplicationCommandLineCallback) Source #
Generate a function pointer callable from C code, from a C_ApplicationCommandLineCallback
.
noApplicationCommandLineCallback :: Maybe ApplicationCommandLineCallback Source #
A convenience synonym for
.Nothing
:: Maybe
ApplicationCommandLineCallback
onApplicationCommandLine :: (IsApplication a, MonadIO m) => a -> ApplicationCommandLineCallback -> m SignalHandlerId Source #
Connect a signal handler for the “command-line
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
application #commandLine callback
wrap_ApplicationCommandLineCallback :: ApplicationCommandLineCallback -> C_ApplicationCommandLineCallback Source #
Wrap a ApplicationCommandLineCallback
into a C_ApplicationCommandLineCallback
.
handleLocalOptions
type ApplicationHandleLocalOptionsCallback Source #
= VariantDict |
|
-> IO Int32 | Returns: 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. |
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 applicationAddMainOptionEntries
and
applicationAddOptionGroup
.
Signal handlers can inspect options
(along with values pointed to
from the argData
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
ApplicationFlagsHandlesCommandLine
the "normal processing" will
send the options
dictionary to the primary instance where it can be
read with applicationCommandLineGetOptionsDict
. The signal
handler can modify the dictionary before returning, and the
modified dictionary will be sent.
In the event that ApplicationFlagsHandlesCommandLine
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 applicationActivate
. One or
more arguments results in a call to applicationOpen
.
If you want to handle the local commandline arguments for yourself
by converting them to calls to applicationOpen
or
actionGroupActivateAction
then you must be sure to register
the application first. You should probably not call
applicationActivate
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.
Since: 2.40
type C_ApplicationHandleLocalOptionsCallback = Ptr () -> Ptr VariantDict -> Ptr () -> IO Int32 Source #
Type for the callback on the (unwrapped) C side.
afterApplicationHandleLocalOptions :: (IsApplication a, MonadIO m) => a -> ApplicationHandleLocalOptionsCallback -> m SignalHandlerId Source #
Connect a signal handler for the “handle-local-options
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
application #handleLocalOptions callback
genClosure_ApplicationHandleLocalOptions :: MonadIO m => ApplicationHandleLocalOptionsCallback -> m (GClosure C_ApplicationHandleLocalOptionsCallback) Source #
Wrap the callback into a GClosure
.
mk_ApplicationHandleLocalOptionsCallback :: C_ApplicationHandleLocalOptionsCallback -> IO (FunPtr C_ApplicationHandleLocalOptionsCallback) Source #
Generate a function pointer callable from C code, from a C_ApplicationHandleLocalOptionsCallback
.
noApplicationHandleLocalOptionsCallback :: Maybe ApplicationHandleLocalOptionsCallback Source #
A convenience synonym for
.Nothing
:: Maybe
ApplicationHandleLocalOptionsCallback
onApplicationHandleLocalOptions :: (IsApplication a, MonadIO m) => a -> ApplicationHandleLocalOptionsCallback -> m SignalHandlerId Source #
Connect a signal handler for the “handle-local-options
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
application #handleLocalOptions callback
wrap_ApplicationHandleLocalOptionsCallback :: ApplicationHandleLocalOptionsCallback -> C_ApplicationHandleLocalOptionsCallback Source #
nameLost
type ApplicationNameLostCallback Source #
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 ApplicationFlagsAllowReplacement
flag.
The default handler for this signal calls applicationQuit
.
Since: 2.60
type C_ApplicationNameLostCallback = Ptr () -> Ptr () -> IO CInt Source #
Type for the callback on the (unwrapped) C side.
afterApplicationNameLost :: (IsApplication a, MonadIO m) => a -> ApplicationNameLostCallback -> m SignalHandlerId Source #
Connect a signal handler for the “name-lost
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
application #nameLost callback
genClosure_ApplicationNameLost :: MonadIO m => ApplicationNameLostCallback -> m (GClosure C_ApplicationNameLostCallback) Source #
Wrap the callback into a GClosure
.
mk_ApplicationNameLostCallback :: C_ApplicationNameLostCallback -> IO (FunPtr C_ApplicationNameLostCallback) Source #
Generate a function pointer callable from C code, from a C_ApplicationNameLostCallback
.
noApplicationNameLostCallback :: Maybe ApplicationNameLostCallback Source #
A convenience synonym for
.Nothing
:: Maybe
ApplicationNameLostCallback
onApplicationNameLost :: (IsApplication a, MonadIO m) => a -> ApplicationNameLostCallback -> m SignalHandlerId Source #
Connect a signal handler for the “name-lost
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
application #nameLost callback
wrap_ApplicationNameLostCallback :: ApplicationNameLostCallback -> C_ApplicationNameLostCallback Source #
Wrap a ApplicationNameLostCallback
into a C_ApplicationNameLostCallback
.
open
type ApplicationOpenCallback Source #
The ::open signal is emitted on the primary instance when there are
files to open. See applicationOpen
for more information.
type C_ApplicationOpenCallback = Ptr () -> Ptr (Ptr File) -> Int32 -> CString -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
afterApplicationOpen :: (IsApplication a, MonadIO m) => a -> ApplicationOpenCallback -> m SignalHandlerId Source #
Connect a signal handler for the “open
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
application #open callback
genClosure_ApplicationOpen :: MonadIO m => ApplicationOpenCallback -> m (GClosure C_ApplicationOpenCallback) Source #
Wrap the callback into a GClosure
.
mk_ApplicationOpenCallback :: C_ApplicationOpenCallback -> IO (FunPtr C_ApplicationOpenCallback) Source #
Generate a function pointer callable from C code, from a C_ApplicationOpenCallback
.
noApplicationOpenCallback :: Maybe ApplicationOpenCallback Source #
A convenience synonym for
.Nothing
:: Maybe
ApplicationOpenCallback
onApplicationOpen :: (IsApplication a, MonadIO m) => a -> ApplicationOpenCallback -> m SignalHandlerId Source #
Connect a signal handler for the “open
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
application #open callback
wrap_ApplicationOpenCallback :: ApplicationOpenCallback -> C_ApplicationOpenCallback Source #
Wrap a ApplicationOpenCallback
into a C_ApplicationOpenCallback
.
shutdown
type ApplicationShutdownCallback = IO () Source #
The ::shutdown signal is emitted only on the registered primary instance immediately after the main loop terminates.
type C_ApplicationShutdownCallback = Ptr () -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
afterApplicationShutdown :: (IsApplication a, MonadIO m) => a -> ApplicationShutdownCallback -> m SignalHandlerId Source #
Connect a signal handler for the “shutdown
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
application #shutdown callback
genClosure_ApplicationShutdown :: MonadIO m => ApplicationShutdownCallback -> m (GClosure C_ApplicationShutdownCallback) Source #
Wrap the callback into a GClosure
.
mk_ApplicationShutdownCallback :: C_ApplicationShutdownCallback -> IO (FunPtr C_ApplicationShutdownCallback) Source #
Generate a function pointer callable from C code, from a C_ApplicationShutdownCallback
.
noApplicationShutdownCallback :: Maybe ApplicationShutdownCallback Source #
A convenience synonym for
.Nothing
:: Maybe
ApplicationShutdownCallback
onApplicationShutdown :: (IsApplication a, MonadIO m) => a -> ApplicationShutdownCallback -> m SignalHandlerId Source #
Connect a signal handler for the “shutdown
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
application #shutdown callback
wrap_ApplicationShutdownCallback :: ApplicationShutdownCallback -> C_ApplicationShutdownCallback Source #
Wrap a ApplicationShutdownCallback
into a C_ApplicationShutdownCallback
.
startup
type ApplicationStartupCallback = IO () Source #
The ::startup signal is emitted on the primary instance immediately
after registration. See applicationRegister
.
type C_ApplicationStartupCallback = Ptr () -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
afterApplicationStartup :: (IsApplication a, MonadIO m) => a -> ApplicationStartupCallback -> m SignalHandlerId Source #
Connect a signal handler for the “startup
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
application #startup callback
genClosure_ApplicationStartup :: MonadIO m => ApplicationStartupCallback -> m (GClosure C_ApplicationStartupCallback) Source #
Wrap the callback into a GClosure
.
mk_ApplicationStartupCallback :: C_ApplicationStartupCallback -> IO (FunPtr C_ApplicationStartupCallback) Source #
Generate a function pointer callable from C code, from a C_ApplicationStartupCallback
.
noApplicationStartupCallback :: Maybe ApplicationStartupCallback Source #
A convenience synonym for
.Nothing
:: Maybe
ApplicationStartupCallback
onApplicationStartup :: (IsApplication a, MonadIO m) => a -> ApplicationStartupCallback -> m SignalHandlerId Source #
Connect a signal handler for the “startup
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
application #startup callback