glibmm: Gio::DesktopAppInfo Class Reference

glibmm 2.38.1

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

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

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

DesktopAppInfo is an implementation of AppInfo based on desktop files. More...

`#include <giomm/desktopappinfo.h>`

Inheritance diagram for Gio::DesktopAppInfo:
[legend]

## Public Member Functions
virtual | ~DesktopAppInfo ()
GDesktopAppInfo* | gobj ()
| Provides access to the underlying C GObject. More...
const GDesktopAppInfo* | gobj () const
| Provides access to the underlying C GObject. More...
GDesktopAppInfo* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
std::string | get_filename () const
| When info was created from a known filename, return it. More...
bool | is_hidden () const
| A desktop file is hidden if the Hidden key in it is set to True. More...
std::vector< Glib::ustring > | get_keywords () const
| Gets the keywords from the desktop file. More...
std::string | get_startup_wm_class () const
| Retrieves the StartupWMClass field from info. More...
bool | get_nodisplay () const
| Gets the value of the NoDisplay key, which helps determine if the application info should be shown in menus. More...
bool | get_show_in (const std::string& desktop_env) const
| Checks if the application info should be shown in menus that list available applications for a specific name of the desktop, based on the `OnlyShowIn` and `NotShowIn` keys. More...
std::string | get_generic_name () const
| Gets the generic name from the destkop file. More...
std::string | get_categories () const
| Gets the categories from the desktop file. More...
bool | has_key (const Glib::ustring& key) const
| Returns whether key exists in the "Desktop Entry" group of the keyfile backing info. More...
Glib::ustring | get_string (const Glib::ustring& key)
| Looks up a string value in the keyfile backing info. More...
bool | get_boolean (const Glib::ustring& key) const
| Looks up a boolean value in the keyfile backing info. More...
std::vector< Glib::ustring > | list_actions () const
| Returns the list of "additional application actions" supported on the desktop file, as per the desktop file specification. More...
void | launch_action (const Glib::ustring& action_name, const Glib::RefPtr< AppLaunchContext >& launch_context)
| Activates the named application action. More...
void | launch_action (const Glib::ustring& action_name)
| A launch_action() convenience overload. More...
Glib::ustring | get_action_name (const Glib::ustring& action_name) const
| Gets the user-visible display name of the "additional application action" specified by action_name. More...
Public Member Functions inherited from Glib::Object
void* | get_data (const QueryQuark& key)
void | set_data (const Quark& key, void* data)
void | set_data (const Quark& key, void* data, DestroyNotify notify)
void | remove_data (const QueryQuark& quark)
void* | steal_data (const QueryQuark& quark)
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...
Public Member Functions inherited from Gio::AppInfo
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

## Static Public Member Functions
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...
static Glib::RefPtr < DesktopAppInfo > | create (const std::string& desktop_id)
| Creates a new DesktopAppInfo based on a desktop file id. More...
static Glib::RefPtr < DesktopAppInfo > | create_from_keyfile (Glib::KeyFile& key_file)
| Creates a new DesktopAppInfo. More...
static Glib::RefPtr < DesktopAppInfo > | create_from_filename (const std::string& filename)
| Creates a new DesktopAppInfo. More...
static void | set_desktop_env (const std::string& desktop_env)
| Sets the name of the desktop that the application is running in. More...
Static Public Member Functions inherited from Gio::AppInfo
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...

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

## Additional Inherited Members
Public Types inherited from Glib::Object
typedef void(* | DestroyNotify )(gpointer data)
Protected Member Functions inherited from Glib::Object
| Object ()
| Object (const Glib::ConstructParams& construct_params)
| Object (GObject* castitem)
virtual | ~Object ()
Protected Member Functions inherited from Gio::AppInfo
| AppInfo ()
| You should derive from this class to use it. More...

## Detailed Description

DesktopAppInfo is an implementation of AppInfo based on desktop files.

Since glibmm 2.16:

## Constructor & Destructor Documentation

virtual Gio::DesktopAppInfo::~DesktopAppInfo | ( |  | ) |
| virtual

## Member Function Documentation

static Glib::RefPtr<DesktopAppInfo> Gio::DesktopAppInfo::create | ( | const std::string & | desktop_id | ) |
| static

Creates a new DesktopAppInfo based on a desktop file id.

A desktop file id is the basename of the desktop file, including the .desktop extension. GIO is looking for a desktop file with this name in the `applications` subdirectories of the XDG data directories (i.e. the directories specified in the `XDG_DATA_HOME` and `XDG_DATA_DIRS` environment variables). GIO also supports the prefix-to-subdirectory mapping that is described in the Menu Spec (i.e. a desktop id of kde-foo.desktop will match `/usr/share/applications/kde/foo.desktop`).

Parameters

  desktop_id | The desktop file id.

Returns
  A new DesktopAppInfo, or `0` if no desktop file with that id.

static Glib::RefPtr<DesktopAppInfo> Gio::DesktopAppInfo::create_from_filename | ( | const std::string & | filename | ) |
| static

Creates a new DesktopAppInfo.

Parameters

  filename | The path of a desktop file, in the GLib filename encoding.

Returns
  A new DesktopAppInfo or `0` on error.

static Glib::RefPtr<DesktopAppInfo> Gio::DesktopAppInfo::create_from_keyfile | ( | Glib::KeyFile& | key_file | ) |
| static

Creates a new DesktopAppInfo.

Since glibmm 2.18:

Parameters

  key_file | An opened KeyFile.

Returns
  A new DesktopAppInfo or `0` on error.

Glib::ustring Gio::DesktopAppInfo::get_action_name | ( | const Glib::ustring& | action_name | ) | const

Gets the user-visible display name of the "additional application action" specified by action_name.

This corresponds to the "Name" key within the keyfile group for the action.

Since glibmm 2.38:

Parameters

  action_name | The name of the action as from g_desktop_app_info_list_actions().

Returns
  The locale-specific action name.

bool Gio::DesktopAppInfo::get_boolean | ( | const Glib::ustring& | key | ) | const

Looks up a boolean value in the keyfile backing info.

The key is looked up in the "Desktop Entry" group.

Since glibmm 2.36:

Parameters

  key | The key to look up.

Returns
  The boolean value, or `false` if the key is not found.

std::string Gio::DesktopAppInfo::get_categories | ( |  | ) | const

Gets the categories from the desktop file.

Returns
  The unparsed Categories key from the desktop file; i.e. no attempt is made to split it by ';' or validate it.

std::string Gio::DesktopAppInfo::get_filename | ( |  | ) | const

When info was created from a known filename, return it.

In some situations such as the DesktopAppInfo returned from g_desktop_app_info_new_from_keyfile(), this function will return `0`.

Since glibmm 2.24:

Returns
  The full path to the file for info, or `0` if not known.

std::string Gio::DesktopAppInfo::get_generic_name | ( |  | ) | const

Gets the generic name from the destkop file.

Returns
  The value of the GenericName key.

std::vector<Glib::ustring> Gio::DesktopAppInfo::get_keywords | ( |  | ) | const

Gets the keywords from the desktop file.

Since glibmm 2.32:

Returns
  The value of the Keywords key.

bool Gio::DesktopAppInfo::get_nodisplay | ( |  | ) | const

Gets the value of the NoDisplay key, which helps determine if the application info should be shown in menus.

See KEY_FILE_DESKTOP_KEY_NO_DISPLAY and g_app_info_should_show().

Since glibmm 2.30:

Returns
  The value of the NoDisplay key.

bool Gio::DesktopAppInfo::get_show_in | ( | const std::string & | desktop_env | ) | const

Checks if the application info should be shown in menus that list available applications for a specific name of the desktop, based on the `OnlyShowIn` and `NotShowIn` keys.

If desktop_env is `0`, then the name of the desktop set with g_desktop_app_info_set_desktop_env() is used.

Note that g_app_info_should_show() for info will include this check (with `0` for desktop_env) as well as additional checks.

Since glibmm 2.30:

Parameters

  desktop_env | A string specifying a desktop name.

Returns
  `true` if the info should be shown in desktop_env according to the `OnlyShowIn` and `NotShowIn` keys, `false` otherwise.

std::string Gio::DesktopAppInfo::get_startup_wm_class | ( |  | ) | const

Retrieves the StartupWMClass field from info.

This represents the WM_CLASS property of the main window of the application, if launched through info.

Since glibmm 2.34:

Returns
  The startup WM class, or `0` if none is set in the desktop file.

Glib::ustring Gio::DesktopAppInfo::get_string | ( | const Glib::ustring& | key | ) |

Looks up a string value in the keyfile backing info.

The key is looked up in the "Desktop Entry" group.

Since glibmm 2.36:

Parameters

  key | The key to look up.

Returns
  A newly allocated string, or `0` if the key is not found.

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

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

GDesktopAppInfo* Gio::DesktopAppInfo::gobj | ( |  | ) |
| inline

Provides access to the underlying C GObject.

const GDesktopAppInfo* Gio::DesktopAppInfo::gobj | ( |  | ) | const
| inline

Provides access to the underlying C GObject.

GDesktopAppInfo* Gio::DesktopAppInfo::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

bool Gio::DesktopAppInfo::has_key | ( | const Glib::ustring& | key | ) | const

Returns whether key exists in the "Desktop Entry" group of the keyfile backing info.

Since glibmm 2.26:

Parameters

  key | The key to look up.

Returns
  `true` if the key exists.

bool Gio::DesktopAppInfo::is_hidden | ( |  | ) | const

A desktop file is hidden if the Hidden key in it is set to True.

Returns
  `true` if hidden, `false` otherwise.

void Gio::DesktopAppInfo::launch_action | ( | const Glib::ustring& | action_name,
|  | const Glib::RefPtr< AppLaunchContext >& | launch_context
| ) |  |

Activates the named application action.

You may only call this function on action names that were returned from g_desktop_app_info_list_actions().

Note that if the main entry of the desktop file indicates that the application supports startup notification, and launch_context is non-`0`, then startup notification will be used when activating the action (and as such, invocation of the action on the receiving side must signal the end of startup notification when it is completed). This is the expected behaviour of applications declaring additional actions, as per the desktop file specification.

As with g_app_info_launch() there is no way to detect failures that occur while using this function.

Since glibmm 2.38:

Parameters

  action_name | The name of the action as from g_desktop_app_info_list_actions().
  launch_context | A AppLaunchContext.

void Gio::DesktopAppInfo::launch_action | ( | const Glib::ustring& | action_name | ) |

A launch_action() convenience overload.

std::vector<Glib::ustring> Gio::DesktopAppInfo::list_actions | ( |  | ) | const

Returns the list of "additional application actions" supported on the desktop file, as per the desktop file specification.

As per the specification, this is the list of actions that are explicitly listed in the "Actions" key of the [Desktop Entry] group.

Since glibmm 2.38:

Returns
  A list of strings, always non-`0`.

static void Gio::DesktopAppInfo::set_desktop_env | ( | const std::string & | desktop_env | ) |
| static

Sets the name of the desktop that the application is running in.

This is used by g_app_info_should_show() and g_desktop_app_info_get_show_in() to evaluate the `OnlyShowIn` and `NotShowIn` desktop entry fields.

The Desktop Menu specification recognizes the following:
GNOME
KDE
ROX
XFCE
LXDE
Unity
Old

Should be called only once; subsequent calls are ignored.

Parameters

  desktop_env | A string specifying what desktop this is.

## Friends And Related Function Documentation

Glib::RefPtr< Gio::DesktopAppInfo > wrap | ( | GDesktopAppInfo * | 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.