![]() |
![]() |
![]() |
GIO Reference Manual | ![]() |
---|---|---|---|---|
#include <gio.h> enum GAppInfoCreateFlags; GAppInfo; GAppInfoIface; GAppLaunchContext; GAppInfo* g_app_info_create_from_commandline (const char *commandline, const char *application_name, GAppInfoCreateFlags flags, GError **error); GAppInfo* g_app_info_dup (GAppInfo *appinfo); gboolean g_app_info_equal (GAppInfo *appinfo1, GAppInfo *appinfo2); const char* g_app_info_get_id (GAppInfo *appinfo); const char* g_app_info_get_name (GAppInfo *appinfo); const char* g_app_info_get_description (GAppInfo *appinfo); const char* g_app_info_get_executable (GAppInfo *appinfo); GIcon* g_app_info_get_icon (GAppInfo *appinfo); gboolean g_app_info_launch (GAppInfo *appinfo, GList *files, GAppLaunchContext *launch_context, GError **error); gboolean g_app_info_supports_uris (GAppInfo *appinfo); gboolean g_app_info_launch_uris (GAppInfo *appinfo, GList *uris, GAppLaunchContext *launch_context, GError **error); gboolean g_app_info_should_show (GAppInfo *appinfo, const char *desktop_env); gboolean g_app_info_set_as_default_for_type (GAppInfo *appinfo, const char *content_type, GError **error); gboolean g_app_info_set_as_default_for_extension (GAppInfo *appinfo, const char *extension, GError **error); gboolean g_app_info_add_supports_type (GAppInfo *appinfo, const char *content_type, GError **error); gboolean g_app_info_can_remove_supports_type (GAppInfo *appinfo); gboolean g_app_info_remove_supports_type (GAppInfo *appinfo, const char *content_type, GError **error); GList* g_app_info_get_all (void); GList* g_app_info_get_all_for_type (const char *content_type); GAppInfo* g_app_info_get_default_for_type (const char *content_type, gboolean must_support_uris); GAppInfo* g_app_info_get_default_for_uri_scheme (const char *uri_scheme); char* g_app_launch_context_get_display (GAppLaunchContext *context, GAppInfo *info, GList *files); char* g_app_launch_context_get_startup_notify_id (GAppLaunchContext *context, GAppInfo *info, GList *files); void g_app_launch_context_launch_failed (GAppLaunchContext *context, const char *startup_notify_id); GAppLaunchContext* g_app_launch_context_new (void);
GAppInfo and GAppLaunchContext are used for describing and launching applications installed on the system.
typedef enum { G_APP_INFO_CREATE_NONE = 0, /*< nick=none >*/ G_APP_INFO_CREATE_NEEDS_TERMINAL = (1<<0) /*< nick=needs-terminal >*/ } GAppInfoCreateFlags;
Flags used when creating a GAppInfo.
typedef struct _GAppInfo GAppInfo;
Information about an installed application and methods to launch it (with file arguments).
typedef struct { GTypeInterface g_iface; /* Virtual Table */ GAppInfo * (*dup) (GAppInfo *appinfo); gboolean (*equal) (GAppInfo *appinfo1, GAppInfo *appinfo2); const char * (*get_id) (GAppInfo *appinfo); const char * (*get_name) (GAppInfo *appinfo); const char * (*get_description) (GAppInfo *appinfo); const char * (*get_executable) (GAppInfo *appinfo); GIcon * (*get_icon) (GAppInfo *appinfo); gboolean (*launch) (GAppInfo *appinfo, GList *filenames, GAppLaunchContext *launch_context, GError **error); gboolean (*supports_uris) (GAppInfo *appinfo); gboolean (*launch_uris) (GAppInfo *appinfo, GList *uris, GAppLaunchContext *launch_context, GError **error); gboolean (*should_show) (GAppInfo *appinfo, const char *desktop_env); /* For changing associations */ gboolean (*set_as_default_for_type) (GAppInfo *appinfo, const char *content_type, GError **error); gboolean (*set_as_default_for_extension) (GAppInfo *appinfo, const char *extension, GError **error); gboolean (*add_supports_type) (GAppInfo *appinfo, const char *content_type, GError **error); gboolean (*can_remove_supports_type) (GAppInfo *appinfo); gboolean (*remove_supports_type) (GAppInfo *appinfo, const char *content_type, GError **error); } GAppInfoIface;
Application Information interface, for operating system portability.
GTypeInterface |
The parent interface. |
|
Copies a GAppInfo. |
|
Checks two GAppInfos for equality. |
|
Gets a string identifier for a GAppInfo. |
|
Gets the name of the application for a GAppInfo. |
|
Gets a short description for the application described by the GAppInfo. |
|
Gets the execuable name for the GAppInfo. |
|
Gets the GIcon for the GAppInfo. |
|
Launches an application specified by the GAppInfo. |
|
Indicates whether the application specified supports launching URIs. |
|
Launches an application with a list of URIs. |
|
Returns whether an application should be shown (e.g. when getting a list of installed applications). FreeDesktop.Org Startup Notification Specification. |
|
Sets an application as default for a given content type. |
|
Sets an application as default for a given file extention. |
|
Adds to the GAppInfo information about supported file types. |
|
Checks for support for removing supported file types from a GAppInfo. |
|
Removes a supported application type from a GAppInfo. |
typedef struct { GObject parent_instance; } GAppLaunchContext;
Integrating the launch with the launching application. This is used to handle for instance startup notification and launching the new application on the same screen as the launching window.
GObject |
The parent instance. |
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.
GAppInfo* g_app_info_dup (GAppInfo *appinfo);
Creates a duplicate of a GAppInfo.
|
a GAppInfo. |
Returns : |
a duplicate of appinfo .
|
gboolean g_app_info_equal (GAppInfo *appinfo1, GAppInfo *appinfo2);
Checks if two GAppInfos are equal.
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.
|
a GAppInfo. |
Returns : |
a string containing the application's ID. |
const char* g_app_info_get_name (GAppInfo *appinfo);
Gets the installed name of the application.
|
a GAppInfo. |
Returns : |
the name of the application for appinfo .
|
const char* g_app_info_get_description (GAppInfo *appinfo);
Gets a human-readable description of an installed application.
|
a GAppInfo. |
Returns : |
a string containing a description of the
application appinfo , or NULL if none. The returned string should be not freed
when no longer needed.
|
const char* g_app_info_get_executable (GAppInfo *appinfo);
Gets the executable's name for the installed application.
|
a GAppInfo. |
Returns : |
a string containing the appinfo 's application
binary's name.
|
GIcon* g_app_info_get_icon (GAppInfo *appinfo);
Gets the icon for the application.
gboolean g_app_info_launch (GAppInfo *appinfo, GList *files, GAppLaunchContext *launch_context, GError **error);
Launches the application. Passes files
to the launched application
as arguments, using the optional launch_context
to get information
about the details of the launcher (like what screen its is on).
On error, error
will be set accordingly.
To lauch 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.
|
a GAppInfo. |
|
a GList of GFile objects. |
|
a GAppLaunchContext. |
|
a GError. |
Returns : |
TRUE on successful launch, FALSE otherwise.
|
gboolean g_app_info_supports_uris (GAppInfo *appinfo);
Checks if the application supports reading files and directories from URIs.
|
a GAppInfo. |
Returns : |
TRUE if the appinfo supports URIs.
|
gboolean g_app_info_launch_uris (GAppInfo *appinfo, GList *uris, GAppLaunchContext *launch_context, GError **error);
Launches the application. Passes uris
to the launched application
as arguments, using the optional launch_context
to get information
about the details of the launcher (like what screen its is on).
On error, error
will be set accordingly.
To lauch 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.
|
a GAppInfo. |
|
a GList containing URIs to launch. |
|
a GAppLaunchContext. |
|
a GError. |
Returns : |
TRUE on successful launch, FALSE otherwise.
|
gboolean g_app_info_should_show (GAppInfo *appinfo, const char *desktop_env);
Checks if the application info should be shown when listing applications available.
destkop_env
is used to hide applications that are specified to
just show up in specific desktops. For instance, passing in "GNOME"
would show all applications specific to the Gnome desktop.
|
a GAppInfo. |
|
A string specifying what desktop this is, or NULL .
|
Returns : |
TRUE if the appinfo should be shown, FALSE otherwise.
|
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.
|
a GAppInfo. |
|
the content type. |
|
a GError. |
Returns : |
TRUE on success, FALSE on error.
|
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 extention.
|
a GAppInfo. |
|
a string containing the file extension (without the dot). |
|
a GError. |
Returns : |
TRUE on success, FALSE on error.
|
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.
|
a GAppInfo. |
|
a string. |
|
a GError. |
Returns : |
TRUE on success, FALSE on error.
|
gboolean g_app_info_can_remove_supports_type (GAppInfo *appinfo);
Checks if a supported content type can be removed from an application.
|
a GAppInfo. |
Returns : |
TRUE if it is possible to remove supported
content types from a given appinfo , FALSE if not.
|
gboolean g_app_info_remove_supports_type (GAppInfo *appinfo, const char *content_type, GError **error);
Removes a supported type from an application, if possible.
|
a GAppInfo. |
|
a string. |
|
a GError. |
Returns : |
TRUE on success, FALSE on error.
|
GList* g_app_info_get_all (void);
Gets a list of all of the applications currently registered on this system.
Returns : |
a newly allocated GList of references to GAppInfos. |
GList* g_app_info_get_all_for_type (const char *content_type);
Gets a list of all GAppInfo s for a given content type.
GAppInfo* g_app_info_get_default_for_type (const char *content_type, gboolean must_support_uris);
Gets the GAppInfo that correspond to a given content type.
GAppInfo* g_app_info_get_default_for_uri_scheme (const char *uri_scheme);
Gets the default application for launching applications using this URI scheme.
TODO: This is currently unimplemented.
|
a string containing a URI scheme. |
Returns : |
NULL .
|
char* g_app_launch_context_get_display (GAppLaunchContext *context, GAppInfo *info, GList *files);
Gets the display string for the display. This is used to ensure new applications are started on the same display as the launching application.
|
a GAppLaunchContext. |
|
a GAppInfo. |
|
a GList of files. |
Returns : |
a display string for the display. |
char* g_app_launch_context_get_startup_notify_id (GAppLaunchContext *context, GAppInfo *info, GList *files);
Initiates startup notification for the applicaiont and returns the DESKTOP_STARTUP_ID for the launched operation, if supported.
Startup notification IDs are defined in the FreeDesktop.Org Startup Notifications standard, at http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt.
|
a GAppLaunchContext. |
|
a GAppInfo. |
|
a GList of files. |
Returns : |
a startup notification ID for the application, or NULL if
not supported.
|
void g_app_launch_context_launch_failed (GAppLaunchContext *context, const char *startup_notify_id);
Called when an application has failed to launch, so that it can cancel
the application startup notification started in g_app_launch_context_get_startup_notify_id()
.
|
a GAppLaunchContext. |
|
the startup notification id that was returned by g_app_launch_context_get_startup_notify_id() .
|
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 GdkLaunchContext.
Returns : |
a GAppLaunchContext. |