glibmm 2.40.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gio::AppInfo Class Reference

Application information, to describe applications installed on the system, and launch them. More...

`#include <giomm/appinfo.h>`

Inheritance diagram for Gio::AppInfo:
[legend]

## Public Member Functions
virtual | ~AppInfo ()
GAppInfo* | gobj ()
| Provides access to the underlying C GObject. More...
const GAppInfo* | gobj () const
| Provides access to the underlying C GObject. More...
Glib::RefPtr< AppInfo > | create_duplicate () const
| Creates a duplicate of this AppInfo. More...
bool | equal (const Glib::RefPtr< AppInfo >& other) const
| Checks if two AppInfos are equal. More...
std::string | get_id () const
| Gets the ID of an application. More...
std::string | get_name () const
| Gets the installed name of the application. More...
std::string | get_display_name () const
| Gets the display name of the application. More...
std::string | get_description () const
| Gets a human-readable description of an installed application. More...
std::string | get_executable () const
| Gets the executable's name for the installed application. More...
std::string | get_commandline () const
| Gets the commandline with which the application will be started. More...
Glib::RefPtr< Icon > | get_icon ()
| Gets the icon for the application. More...
const Glib::RefPtr< const Icon > | get_icon () const
| Gets the icon for the application. More...
bool | launch (const Glib::RefPtr< Gio::File >& file, const Glib::RefPtr< AppLaunchContext >& launch_context)
| Launches the application. More...
bool | launch (const Glib::RefPtr< Gio::File >& file)
| Launches the application. More...
bool | launch (const std::vector< Glib::RefPtr< Gio::File > >& files, const Glib::RefPtr< AppLaunchContext >& launch_context)
| Launches the application. More...
bool | launch (const std::vector< Glib::RefPtr< Gio::File > >& files)
| A launch() convenience overload. More...
bool | supports_uris () const
| Checks if the application supports reading files and directories from URIs. More...
bool | supports_files () const
| Checks if the application accepts files as arguments. More...
bool | launch_uris (const Glib::ListHandle< std::string >& uris, GAppLaunchContext* launch_context)
| Launches the application. More...
bool | launch_uris (const Glib::ListHandle< std::string >& uris, const Glib::RefPtr< AppLaunchContext >& launch_context)
| Launches the application. More...
bool | launch_uris (const Glib::ListHandle< std::string >& uris)
| A launch_uris() convenience overload. More...
bool | launch_uri (const std::string& uris, const Glib::RefPtr< AppLaunchContext >& launch_context)
| Launches the application. More...
bool | launch_uri (const std::string& uris)
| A launch_uri() convenience overload. More...
bool | should_show () const
| Checks if the application info should be shown in menus that list available applications. More...
bool | can_delete () const
| Obtains the information whether the AppInfo can be deleted. More...
bool | do_delete ()
| Tries to delete a AppInfo. More...
bool | set_as_default_for_type (const std::string& content_type)
| Sets the application as the default handler for a given type. More...
bool | set_as_default_for_extension (const std::string& extension)
| Sets the application as the default handler for the given file extension. More...
bool | add_supports_type (const std::string& content_type)
| Adds a content type to the application information to indicate the application is capable of opening files with the given content type. More...
bool | can_remove_supports_type () const
| Checks if a supported content type can be removed from an application. More...
bool | remove_supports_type (const std::string& content_type)
| Removes a supported type from an application, if possible. More...
Glib::StringArrayHandle | get_supported_types () const
| Retrieves the list of content types that app_info claims to support. More...
bool | set_as_last_used_for_type (const std::string& content_type)
| Sets the application as the last used application for a given type. More...
Public Member Functions inherited from Glib::Interface
| Interface ()
| A Default constructor. More...
| Interface (const Glib::Interface_Class& interface_class)
| Called by constructors of derived classes. More...
| Interface (GObject* castitem)
| Called by constructors of derived classes. More...
virtual | ~Interface ()
GObject* | gobj ()
const GObject* | gobj () const
Public Member Functions inherited from Glib::ObjectBase
void | set_property_value (const Glib::ustring& property_name, const Glib::ValueBase& value)
| You probably want to use a specific property_*() accessor method instead. More...
void | get_property_value (const Glib::ustring& property_name, Glib::ValueBase& value) const
| You probably want to use a specific property_*() accessor method instead. More...
template<class PropertyType >
void | set_property (const Glib::ustring& property_name, const PropertyType& value)
| You probably want to use a specific property_*() accessor method instead. More...
template<class PropertyType >
void | get_property (const Glib::ustring& property_name, PropertyType& value) const
| You probably want to use a specific property_*() accessor method instead. More...
void | connect_property_changed (const Glib::ustring& property_name, const sigc::slot< void >& slot)
| You can use the signal_changed() signal of the property proxy instead, but this is necessary when using the reduced API. More...
sigc::connection | connect_property_changed_with_return (const Glib::ustring& property_name, const sigc::slot< void >& slot)
| You can use the signal_changed() signal of the property proxy instead, but this is necessary when using the reduced API. More...
void | freeze_notify ()
| Increases the freeze count on object. More...
void | thaw_notify ()
| Reverts the effect of a previous call to freeze_notify(). More...
virtual void | reference () const
| Increment the reference count for this object. More...
virtual void | unreference () const
| Decrement the reference count for this object. More...
GObject* | gobj ()
| Provides access to the underlying C GObject. More...
const GObject* | gobj () const
| Provides access to the underlying C GObject. More...
GObject* | gobj_copy () const
| Give a ref-ed copy to someone. Use for direct struct access. More...

## Static Public Member Functions
static void | add_interface (GType gtype_implementer)
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...
static Glib::RefPtr< AppInfo > | create_from_commandline (const std::string& commandline, const std::string& application_name, AppInfoCreateFlags flags)
static Glib::ListHandle < Glib::RefPtr< AppInfo > > | get_all ()
| Gets a list of all of the applications currently registered on this system. More...
static Glib::ListHandle < Glib::RefPtr< AppInfo > > | get_all_for_type (const std::string& content_type)
| Gets a list of all AppInfos for a given content type, including the recommended and fallback AppInfos. More...
static Glib::RefPtr< AppInfo > | get_default_for_type (const std::string& content_type, bool must_support_uris=true)
| Gets the default AppInfo for a given content type. More...
static Glib::RefPtr< AppInfo > | get_default_for_uri_scheme (const std::string& uri_scheme)
| Gets the default application for handling URIs with the given URI scheme. More...
static void | reset_type_associations (const std::string& content_type)
| Removes all changes to the type associations done by g_app_info_set_as_default_for_type(), g_app_info_set_as_default_for_extension(), g_app_info_add_supports_type() or g_app_info_remove_supports_type(). More...
static bool | launch_default_for_uri (const std::string& uri, const Glib::RefPtr< AppLaunchContext >& launch_context)
| Utility function that launches the default application registered to handle the specified uri. More...
static bool | launch_default_for_uri (const std::string& uri)
| A launch_default_for_uri() convenience overload. More...

## Protected Member Functions
| AppInfo ()
| You should derive from this class to use it. More...

## Related Functions
(Note that these are not member functions.)
Glib::RefPtr< Gio::AppInfo > | wrap (GAppInfo* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...

## Detailed Description

Application information, to describe applications installed on the system, and launch them.

See also AppLaunchContext.

Since glibmm 2.16:

## Constructor & Destructor Documentation

Gio::AppInfo::AppInfo | ( | ) |  |
| protected

You should derive from this class to use it.

virtual Gio::AppInfo::~AppInfo | ( | ) |  |
| virtual

## Member Function Documentation

static void Gio::AppInfo::add_interface | ( | GType | gtype_implementer) |  |
| static

bool Gio::AppInfo::add_supports_type | ( | const std::string & | content_type) |  |

Adds a content type to the application information to indicate the application is capable of opening files with the given content type.

Parameters

  content_type | A string.

Returns
  `true` on success, `false` on error.

bool Gio::AppInfo::can_delete | ( | ) |  | const

Obtains the information whether the AppInfo can be deleted.

See g_app_info_delete().

Since glibmm 2.20:

Returns
  `true` if appinfo can be deleted.

bool Gio::AppInfo::can_remove_supports_type | ( | ) |  | const

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.

Glib::RefPtr<AppInfo> Gio::AppInfo::create_duplicate | ( | ) |  | const

Creates a duplicate of this AppInfo.

Returns
  A duplicate of this AppInfo.

Since glibmm 2.36:

static Glib::RefPtr<AppInfo> Gio::AppInfo::create_from_commandline | ( | const std::string & | commandline,
|  | const std::string & | application_name,
|  | AppInfoCreateFlags | flags
| ) |  |
| static

bool Gio::AppInfo::do_delete | ( | ) |  |

Tries to delete a AppInfo.

On some platforms, there may be a difference between user-defined AppInfos which can be deleted, and system-wide ones which cannot. See g_app_info_can_delete().

Virtual: do_delete

Since glibmm 2.20:

Returns
  `true` if appinfo has been deleted.

bool Gio::AppInfo::equal | ( | const Glib::RefPtr< AppInfo >& | other) |  | const

Checks if two AppInfos are equal.

Parameters

  other | The other AppInfo.

Returns
  `true` if *this is equal to other, `false` otherwise.

static Glib::ListHandle<Glib::RefPtr<AppInfo> > Gio::AppInfo::get_all | ( | ) |  |
| static

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 List of references to AppInfos.

static Glib::ListHandle<Glib::RefPtr<AppInfo> > Gio::AppInfo::get_all_for_type | ( | const std::string & | content_type) |  |
| static

Gets a list of all AppInfos for a given content type, including the recommended and fallback AppInfos.

See g_app_info_get_recommended_for_type() and g_app_info_get_fallback_for_type().

Parameters

  content_type | The content type to find a AppInfo for.

Returns
  List of AppInfos for given content_type or `0` on error.

std::string Gio::AppInfo::get_commandline | ( | ) |  | const

Gets the commandline with which the application will be started.

Since glibmm 2.20:

Returns
  A string containing the appinfo's commandline, or `0` if this information is not available.

static Glib::RefPtr<AppInfo> Gio::AppInfo::get_default_for_type | ( | const std::string & | content_type,
|  | bool | must_support_uris = `true`
| ) |  |
| static

Gets the default AppInfo for a given content type.

Parameters

  content_type | The content type to find a AppInfo for.
  must_support_uris | If `true`, the AppInfo is expected to support URIs.

Returns
  AppInfo for given content_type or `0` on error.

static Glib::RefPtr<AppInfo> Gio::AppInfo::get_default_for_uri_scheme | ( | const std::string & | uri_scheme) |  |
| static

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".

Parameters

  uri_scheme | A string containing a URI scheme.

Returns
  AppInfo for given uri_scheme or `0` on error.

std::string Gio::AppInfo::get_description | ( | ) |  | const

Gets a human-readable description of an installed application.

Returns
  A string containing a description of the application appinfo, or `0` if none.

std::string Gio::AppInfo::get_display_name | ( | ) |  | const

Gets the display name of the application.

The display name is often more descriptive to the user than the name itself.

Since glibmm 2.24:

Returns
  The display name of the application for appinfo, or the name if no display name is available.

std::string Gio::AppInfo::get_executable | ( | ) |  | const

Gets the executable's name for the installed application.

Returns
  A string containing the appinfo's application binaries name.

Glib::RefPtr<Icon> Gio::AppInfo::get_icon | ( | ) |  |

Gets the icon for the application.

Returns
  The default Icon for appinfo or `0` if there is no default icon.

const Glib::RefPtr<const Icon> Gio::AppInfo::get_icon | ( | ) |  | const

Gets the icon for the application.

Returns
  The default Icon for appinfo or `0` if there is no default icon.

std::string Gio::AppInfo::get_id | ( | ) |  | const

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 `0`, depending on how the appinfo has been constructed.

Returns
  A string containing the application's ID.

std::string Gio::AppInfo::get_name | ( | ) |  | const

Gets the installed name of the application.

Returns
  The name of the application for appinfo.

Glib::StringArrayHandle Gio::AppInfo::get_supported_types | ( | ) |  | const

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 `0`. This function does not take in consideration associations added with g_app_info_add_supports_type(), but only those exported directly by the application.

Since glibmm 2.34:

Returns
  A list of content types.

static GType Gio::AppInfo::get_type | ( | ) |  |
| static

Get the GType for this class, for use with the underlying GObject type system.

GAppInfo* Gio::AppInfo::gobj | ( | ) |  |
| inline

Provides access to the underlying C GObject.

const GAppInfo* Gio::AppInfo::gobj | ( | ) |  | const
| inline

Provides access to the underlying C GObject.

bool Gio::AppInfo::launch | ( | const Glib::RefPtr< Gio::File >& | file,
|  | const Glib::RefPtr< AppLaunchContext >& | launch_context
| ) |  |

Launches the application.

This passes the file to the launched application as an argument, using the optional launch_context to get information about the details of the launcher (like what screen it is on). On error, an exception will be thrown accordingly.

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 launch_uris() instead.

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 launch_context.

Parameters

  file | A File object.
  launch_context | An AppLaunchContext.

Returns
  `true` on successful launch, `false` otherwise.

Since glibmm 3.2:

bool Gio::AppInfo::launch | ( | const Glib::RefPtr< Gio::File >& | file) |  |

Launches the application.

This passes the file to the launched application as an argument. On error, an exception will be thrown accordingly.

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 launch_uris() instead.

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 launch_context.

Parameters

  file | A File object.

Returns
  `true` on successful launch, `false` otherwise.

Since glibmm 3.2:

bool Gio::AppInfo::launch | ( | const std::vector< Glib::RefPtr< Gio::File > >& | files,
|  | const Glib::RefPtr< AppLaunchContext >& | launch_context
| ) |  |

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 it is on). On error, error will be set accordingly.

To launch the application without arguments pass a `0` 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 launch_context.

Parameters

  files | A List of File objects.
  launch_context | A AppLaunchContext or `0`.

Returns
  `true` on successful launch, `false` otherwise.

bool Gio::AppInfo::launch | ( | const std::vector< Glib::RefPtr< Gio::File > >& | files) |  |

A launch() convenience overload.

static bool Gio::AppInfo::launch_default_for_uri | ( | const std::string & | uri,
|  | const Glib::RefPtr< AppLaunchContext >& | launch_context
| ) |  |
| static

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.

Parameters

  uri | The uri to show.
  launch_context | An optional AppLaunchContext.

Returns
  `true` on success, `false` on error.

static bool Gio::AppInfo::launch_default_for_uri | ( | const std::string & | uri) |  |
| static

A launch_default_for_uri() convenience overload.

bool Gio::AppInfo::launch_uri | ( | const std::string & | uris,
|  | const Glib::RefPtr< AppLaunchContext >& | launch_context
| ) |  |

Launches the application.

This passes the uri to the launched application as an arguments, using the optional launch_context to get information about the details of the launcher (like what screen it is on). On error, an exception will be thrown accordingly.

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.

Parameters

  uris | A URIs to launch.
  launch_context | An AppLaunchContext.

Returns
  `true` on successful launch, `false` otherwise.

Since glibmm 3.2:

bool Gio::AppInfo::launch_uri | ( | const std::string & | uris) |  |

A launch_uri() convenience overload.

Since glibmm 3.2:

bool Gio::AppInfo::launch_uris | ( | const Glib::ListHandle< std::string >& | uris,
|  | GAppLaunchContext * | launch_context
| ) |  |

Launches the application.

This passes the uris to the launched application as arguments, using the optional launch_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 `0` 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.

Deprecated:
  Use the method that takes an AppLaunchContext

Parameters

  uris | A List containing URIs to launch.
  launch_context | A AppLaunchContext or `0`.

Returns
  `true` on successful launch, `false` otherwise.

bool Gio::AppInfo::launch_uris | ( | const Glib::ListHandle< std::string >& | uris,
|  | const Glib::RefPtr< AppLaunchContext >& | launch_context
| ) |  |

Launches the application.

This passes the uris to the launched application as arguments, using the optional launch_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 `0` 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.

Parameters

  uris | A List containing URIs to launch.
  launch_context | A AppLaunchContext or `0`.

Returns
  `true` on successful launch, `false` otherwise.

bool Gio::AppInfo::launch_uris | ( | const Glib::ListHandle< std::string >& | uris) |  |

A launch_uris() convenience overload.

bool Gio::AppInfo::remove_supports_type | ( | const std::string & | content_type) |  |

Removes a supported type from an application, if possible.

Parameters

  content_type | A string.

Returns
  `true` on success, `false` on error.

static void Gio::AppInfo::reset_type_associations | ( | const std::string & | content_type) |  |
| static

Removes all changes to the type associations done by g_app_info_set_as_default_for_type(), g_app_info_set_as_default_for_extension(), g_app_info_add_supports_type() or g_app_info_remove_supports_type().

Since glibmm 2.20:

Parameters

  content_type | A content type.

bool Gio::AppInfo::set_as_default_for_extension | ( | const std::string & | extension) |  |

Sets the application as the default handler for the given file extension.

Parameters

  extension | A string containing the file extension (without the dot).

Returns
  `true` on success, `false` on error.

bool Gio::AppInfo::set_as_default_for_type | ( | const std::string & | content_type) |  |

Sets the application as the default handler for a given type.

Parameters

  content_type | The content type.

Returns
  `true` on success, `false` on error.

bool Gio::AppInfo::set_as_last_used_for_type | ( | const std::string & | content_type) |  |

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.

Parameters

  content_type | The content type.

Returns
  `true` on success, `false` on error.

bool Gio::AppInfo::should_show | ( | ) |  | const

Checks if the application info should be shown in menus that list available applications.

Returns
  `true` if the appinfo should be shown, `false` otherwise.

bool Gio::AppInfo::supports_files | ( | ) |  | const

Checks if the application accepts files as arguments.

Returns
  `true` if the appinfo supports files.

bool Gio::AppInfo::supports_uris | ( | ) |  | const

Checks if the application supports reading files and directories from URIs.

Returns
  `true` if the appinfo supports URIs.

## Friends And Related Function Documentation

Glib::RefPtr< Gio::AppInfo > wrap | ( | GAppInfo * | object,
|  | bool | take_copy = `false`
| ) |  |
| related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.