Synopsis#include <gio/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_files (GAppInfo *appinfo); 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); 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); gboolean g_app_info_launch_default_for_uri (const char *uri, GAppLaunchContext *launch_context, GError **error); 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); DescriptionGAppInfo and GAppLaunchContext are used for describing and launching applications installed on the system.
As of GLib 2.20, URIs will always be converted to POSIX paths
(using
Specifically for gvfs 2.26 and later, the POSIX URI will be mapped
back to the GIO URI in the GFile constructors (since gvfs
implements the GVfs extension point). As such, if the application
needs to examine the URI, it needs to use
GFile *f; char *uri; file = g_file_new_for_commandline_arg (uri_from_commandline); uri = g_file_get_uri (file); strcmp (uri, uri_from_commandline) == 0; // FALSE g_free (uri); if (g_file_has_uri_scheme (file, "cdda")) { // do something special with uri } g_object_unref (file);
This code will work when both
Detailsenum GAppInfoCreateFlagstypedef enum { G_APP_INFO_CREATE_NONE = 0, /*< nick=none >*/ G_APP_INFO_CREATE_NEEDS_TERMINAL = (1 << 0), /*< nick=needs-terminal >*/ G_APP_INFO_CREATE_SUPPORTS_URIS = (1 << 1) /*< nick=supports-uris >*/ } GAppInfoCreateFlags; Flags used when creating a GAppInfo.
GAppInfotypedef struct _GAppInfo GAppInfo; Information about an installed application and methods to launch it (with file arguments).
GAppInfoIfacetypedef 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 (* supports_files) (GAppInfo *appinfo); gboolean (* launch_uris) (GAppInfo *appinfo, GList *uris, GAppLaunchContext *launch_context, GError **error); gboolean (* should_show) (GAppInfo *appinfo); /* 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); gboolean (* can_delete) (GAppInfo *appinfo); gboolean (* do_delete) (GAppInfo *appinfo); } GAppInfoIface; Application Information interface, for operating system portability.
GAppLaunchContexttypedef struct _GAppLaunchContext 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.
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.
g_app_info_dup ()GAppInfo* g_app_info_dup (GAppInfo *appinfo); Creates a duplicate of a GAppInfo.
g_app_info_equal ()gboolean g_app_info_equal (GAppInfo *appinfo1, GAppInfo *appinfo2); Checks if two GAppInfos are equal.
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
g_app_info_get_name ()const char* g_app_info_get_name (GAppInfo *appinfo); Gets the installed name of the application.
g_app_info_get_description ()const char* g_app_info_get_description (GAppInfo *appinfo); Gets a human-readable description of an installed application.
g_app_info_get_executable ()const char* g_app_info_get_executable (GAppInfo *appinfo); Gets the executable's name for the installed application.
g_app_info_get_icon ()GIcon* g_app_info_get_icon (GAppInfo *appinfo); Gets the icon for the application.
g_app_info_launch ()gboolean g_app_info_launch (GAppInfo *appinfo, GList *files, GAppLaunchContext *launch_context, GError **error);
Launches the application. Passes
To lauch the application without arguments pass a 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_supports_files ()gboolean g_app_info_supports_files (GAppInfo *appinfo); Checks if the application accepts files as arguments.
g_app_info_supports_uris ()gboolean g_app_info_supports_uris (GAppInfo *appinfo); Checks if the application supports reading files and directories from URIs.
g_app_info_launch_uris ()gboolean g_app_info_launch_uris (GAppInfo *appinfo, GList *uris, GAppLaunchContext *launch_context, GError **error);
Launches the application. Passes
To lauch the application without arguments pass a 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.
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.
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.
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 extention.
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.
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.
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.
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
g_app_info_get_all_for_type ()GList* g_app_info_get_all_for_type (const char *content_type); Gets a list of all GAppInfo s for a given content type.
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 GAppInfo that correspond to a given content type.
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 launching applications using this URI scheme. A URI scheme is the initial part of the URI, up to but not including the ':', e.g. "http", "ftp" or "sip".
g_app_info_launch_default_for_uri ()gboolean g_app_info_launch_default_for_uri (const char *uri, GAppLaunchContext *launch_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 detext the type of the file if required.
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 display. This is used to ensure new applications are started on the same display as the launching application.
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.
g_app_launch_context_launch_failed ()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_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.
|