Functions
g_app_info_create_from_commandline ()
GAppInfo *
g_app_info_create_from_commandline (const char *commandline,
const char *application_name,
GAppInfoCreateFlags flags,
GError **error);
Creates a new GAppInfo from the given information.
Note that for commandline
, the quoting rules of the Exec key of the
freedesktop.org Desktop Entry Specification
are applied. For example, if the commandline
contains
percent-encoded URIs, the percent-character must be doubled in order to prevent it from
being swallowed by Exec key unquoting. See the specification for exact quoting rules.
Returns
new GAppInfo for given command.
[transfer full]
g_app_info_dup ()
GAppInfo *
g_app_info_dup (GAppInfo *appinfo);
Creates a duplicate of a GAppInfo.
Returns
a duplicate of appinfo
.
[transfer full]
g_app_info_equal ()
gboolean
g_app_info_equal (GAppInfo *appinfo1,
GAppInfo *appinfo2);
Checks if two GAppInfos are equal.
Note that the check <emphasis>may not</emphasis> compare each individual
field, and only does an identity check. In case detecting changes in the
contents is needed, program code must additionally compare relevant fields.
Returns
TRUE if appinfo1
is equal to appinfo2
. FALSE otherwise.
g_app_info_get_id ()
const char *
g_app_info_get_id (GAppInfo *appinfo);
Gets the ID of an application. An id is a string that
identifies the application. The exact format of the id is
platform dependent. For instance, on Unix this is the
desktop file id from the xdg menu specification.
Note that the returned ID may be NULL, depending on how
the appinfo
has been constructed.
Returns
a string containing the application's ID.
g_app_info_get_name ()
const char *
g_app_info_get_name (GAppInfo *appinfo);
Gets the installed name of the application.
Returns
the name of the application for appinfo
.
g_app_info_get_display_name ()
const char *
g_app_info_get_display_name (GAppInfo *appinfo);
Gets the display name of the application. The display name is often more
descriptive to the user than the name itself.
Returns
the display name of the application for appinfo
, or the name if
no display name is available.
Since: 2.24
g_app_info_get_description ()
const char *
g_app_info_get_description (GAppInfo *appinfo);
Gets a human-readable description of an installed application.
Returns
a string containing a description of the
application appinfo
, or NULL if none.
g_app_info_get_executable ()
const char *
g_app_info_get_executable (GAppInfo *appinfo);
Gets the executable's name for the installed application.
Returns
a string containing the appinfo
's application
binaries name.
[type filename]
g_app_info_get_commandline ()
const char *
g_app_info_get_commandline (GAppInfo *appinfo);
Gets the commandline with which the application will be
started.
Returns
a string containing the appinfo
's commandline,
or NULL if this information is not available.
[type filename]
Since: 2.20
g_app_info_get_icon ()
GIcon *
g_app_info_get_icon (GAppInfo *appinfo);
Gets the icon for the application.
Returns
the default GIcon for appinfo
or NULL
if there is no default icon.
[transfer none]
g_app_info_launch ()
gboolean
g_app_info_launch (GAppInfo *appinfo,
GList *files,
GAppLaunchContext *context,
GError **error);
Launches the application. Passes files
to the launched application
as arguments, using the optional context
to get information
about the details of the launcher (like what screen it is on).
On error, error
will be set accordingly.
To launch the application without arguments pass a NULL files
list.
Note that even if the launch is successful the application launched
can fail to start if it runs into problems during startup. There is
no way to detect this.
Some URIs can be changed when passed through a GFile (for instance
unsupported URIs with strange formats like mailto:), so if you have
a textual URI you want to pass in as argument, consider using
g_app_info_launch_uris() instead.
The launched application inherits the environment of the launching
process, but it can be modified with g_app_launch_context_setenv()
and g_app_launch_context_unsetenv().
On UNIX, this function sets the GIO_LAUNCHED_DESKTOP_FILE
environment variable with the path of the launched desktop file and
GIO_LAUNCHED_DESKTOP_FILE_PID to the process id of the launched
process. This can be used to ignore GIO_LAUNCHED_DESKTOP_FILE,
should it be inherited by further processes. The DISPLAY and
DESKTOP_STARTUP_ID environment variables are also set, based
on information provided in context
.
Returns
TRUE on successful launch, FALSE otherwise.
g_app_info_supports_files ()
gboolean
g_app_info_supports_files (GAppInfo *appinfo);
Checks if the application accepts files as arguments.
Returns
TRUE if the appinfo
supports files.
g_app_info_supports_uris ()
gboolean
g_app_info_supports_uris (GAppInfo *appinfo);
Checks if the application supports reading files and directories from URIs.
Returns
TRUE if the appinfo
supports URIs.
g_app_info_launch_uris ()
gboolean
g_app_info_launch_uris (GAppInfo *appinfo,
GList *uris,
GAppLaunchContext *context,
GError **error);
Launches the application. This passes the uris
to the launched application
as arguments, using the optional context
to get information
about the details of the launcher (like what screen it is on).
On error, error
will be set accordingly.
To launch the application without arguments pass a NULL uris
list.
Note that even if the launch is successful the application launched
can fail to start if it runs into problems during startup. There is
no way to detect this.
Returns
TRUE on successful launch, FALSE otherwise.
g_app_info_should_show ()
gboolean
g_app_info_should_show (GAppInfo *appinfo);
Checks if the application info should be shown in menus that
list available applications.
Returns
TRUE if the appinfo
should be shown, FALSE otherwise.
g_app_info_can_delete ()
gboolean
g_app_info_can_delete (GAppInfo *appinfo);
Obtains the information whether the GAppInfo can be deleted.
See g_app_info_delete().
Returns
TRUE if appinfo
can be deleted
Since: 2.20
g_app_info_delete ()
gboolean
g_app_info_delete (GAppInfo *appinfo);
Tries to delete a GAppInfo.
On some platforms, there may be a difference between user-defined
GAppInfos which can be deleted, and system-wide ones which cannot.
See g_app_info_can_delete().
Virtual: do_delete
Returns
TRUE if appinfo
has been deleted
Since: 2.20
g_app_info_set_as_default_for_type ()
gboolean
g_app_info_set_as_default_for_type (GAppInfo *appinfo,
const char *content_type,
GError **error);
Sets the application as the default handler for a given type.
Returns
TRUE on success, FALSE on error.
g_app_info_set_as_default_for_extension ()
gboolean
g_app_info_set_as_default_for_extension
(GAppInfo *appinfo,
const char *extension,
GError **error);
Sets the application as the default handler for the given file extension.
Returns
TRUE on success, FALSE on error.
g_app_info_set_as_last_used_for_type ()
gboolean
g_app_info_set_as_last_used_for_type (GAppInfo *appinfo,
const char *content_type,
GError **error);
Sets the application as the last used application for a given type.
This will make the application appear as first in the list returned
by g_app_info_get_recommended_for_type(), regardless of the default
application for that content type.
Returns
TRUE on success, FALSE on error.
g_app_info_add_supports_type ()
gboolean
g_app_info_add_supports_type (GAppInfo *appinfo,
const char *content_type,
GError **error);
Adds a content type to the application information to indicate the
application is capable of opening files with the given content type.
Returns
TRUE on success, FALSE on error.
g_app_info_can_remove_supports_type ()
gboolean
g_app_info_can_remove_supports_type (GAppInfo *appinfo);
Checks if a supported content type can be removed from an application.
Returns
TRUE if it is possible to remove supported
content types from a given appinfo
, FALSE if not.
g_app_info_remove_supports_type ()
gboolean
g_app_info_remove_supports_type (GAppInfo *appinfo,
const char *content_type,
GError **error);
Removes a supported type from an application, if possible.
Returns
TRUE on success, FALSE on error.
g_app_info_get_supported_types ()
const char **
g_app_info_get_supported_types (GAppInfo *appinfo);
Retrieves the list of content types that app_info
claims to support.
If this information is not provided by the environment, this function
will return NULL.
This function does not take in consideration associations added with
g_app_info_add_supports_type(), but only those exported directly by
the application.
Returns
a list of content types.
[transfer none][array zero-terminated=1][element-type utf8]
Since: 2.34
g_app_info_get_all ()
GList *
g_app_info_get_all (void);
Gets a list of all of the applications currently registered
on this system.
For desktop files, this includes applications that have
NoDisplay=true set or are excluded from display by means
of OnlyShowIn or NotShowIn. See g_app_info_should_show().
The returned list does not include applications which have
the Hidden key set.
Returns
a newly allocated GList of references to GAppInfos.
[element-type GAppInfo][transfer full]
g_app_info_get_default_for_type ()
GAppInfo *
g_app_info_get_default_for_type (const char *content_type,
gboolean must_support_uris);
Gets the default GAppInfo for a given content type.
Returns
GAppInfo for given content_type
or
NULL on error.
[transfer full]
g_app_info_get_default_for_uri_scheme ()
GAppInfo *
g_app_info_get_default_for_uri_scheme (const char *uri_scheme);
Gets the default application for handling URIs with
the given URI scheme. A URI scheme is the initial part
of the URI, up to but not including the ':', e.g. "http",
"ftp" or "sip".
Returns
GAppInfo for given uri_scheme
or NULL on error.
[transfer full]
g_app_info_get_fallback_for_type ()
GList *
g_app_info_get_fallback_for_type (const gchar *content_type);
Gets a list of fallback GAppInfos for a given content type, i.e.
those applications which claim to support the given content type
by MIME type subclassing and not directly.
Returns
GList of GAppInfos
for given content_type
or NULL on error.
[element-type GAppInfo][transfer full]
Since: 2.28
g_app_info_get_recommended_for_type ()
GList *
g_app_info_get_recommended_for_type (const gchar *content_type);
Gets a list of recommended GAppInfos for a given content type, i.e.
those applications which claim to support the given content type exactly,
and not by MIME type subclassing.
Note that the first application of the list is the last used one, i.e.
the last one for which g_app_info_set_as_last_used_for_type() has been
called.
Returns
GList of GAppInfos
for given content_type
or NULL on error.
[element-type GAppInfo][transfer full]
Since: 2.28
g_app_info_launch_default_for_uri ()
gboolean
g_app_info_launch_default_for_uri (const char *uri,
GAppLaunchContext *context,
GError **error);
Utility function that launches the default application
registered to handle the specified uri. Synchronous I/O
is done on the uri to detect the type of the file if
required.
The D-Bus–activated applications don't have to be started if your application
terminates too soon after this function. To prevent this, use
g_app_info_launch_default_for_uri_async() instead.
Returns
TRUE on success, FALSE on error.
g_app_info_launch_default_for_uri_async ()
void
g_app_info_launch_default_for_uri_async
(const char *uri,
GAppLaunchContext *context,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
Async version of g_app_info_launch_default_for_uri().
This version is useful if you are interested in receiving
error information in the case where the application is
sandboxed and the portal may present an application chooser
dialog to the user.
This is also useful if you want to be sure that the D-Bus–activated
applications are really started before termination and if you are interested
in receiving error information from their activation.
Since: 2.50
g_app_info_launch_default_for_uri_finish ()
gboolean
g_app_info_launch_default_for_uri_finish
(GAsyncResult *result,
GError **error);
Finishes an asynchronous launch-default-for-uri operation.
Returns
TRUE if the launch was successful, FALSE if error
is set
Since: 2.50
g_app_launch_context_setenv ()
void
g_app_launch_context_setenv (GAppLaunchContext *context,
const char *variable,
const char *value);
Arranges for variable
to be set to value
in the child's
environment when context
is used to launch an application.
Since: 2.32
g_app_launch_context_unsetenv ()
void
g_app_launch_context_unsetenv (GAppLaunchContext *context,
const char *variable);
Arranges for variable
to be unset in the child's environment
when context
is used to launch an application.
Since: 2.32
g_app_launch_context_get_environment ()
char **
g_app_launch_context_get_environment (GAppLaunchContext *context);
Gets the complete environment variable list to be passed to
the child process when context
is used to launch an application.
This is a NULL-terminated array of strings, where each string has
the form KEY=VALUE.
Returns
the child's environment.
[array zero-terminated=1][element-type filename][transfer full]
Since: 2.32
g_app_launch_context_get_display ()
char *
g_app_launch_context_get_display (GAppLaunchContext *context,
GAppInfo *info,
GList *files);
Gets the display string for the context
. This is used to ensure new
applications are started on the same display as the launching
application, by setting the DISPLAY environment variable.
Returns
a display string for the display.
g_app_launch_context_get_startup_notify_id ()
char *
g_app_launch_context_get_startup_notify_id
(GAppLaunchContext *context,
GAppInfo *info,
GList *files);
Initiates startup notification for the application and returns the
DESKTOP_STARTUP_ID for the launched operation, if supported.
Startup notification IDs are defined in the
FreeDesktop.Org Startup Notifications standard.
Returns
a startup notification ID for the application, or NULL if
not supported.
g_app_launch_context_new ()
GAppLaunchContext *
g_app_launch_context_new (void);
Creates a new application launch context. This is not normally used,
instead you instantiate a subclass of this, such as GdkAppLaunchContext.