glibmm 2.80.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Symbols | 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:
Inheritance graph
[legend]

Public Types

enum class  CreateFlags {
  NONE = 0x0 ,
  NEEDS_TERMINAL = (1 << 0) ,
  SUPPORTS_URIS = (1 << 1) ,
  SUPPORTS_STARTUP_NOTIFICATION = (1 << 2)
}
 

Public Member Functions

 AppInfo (AppInfo &&src) noexcept
 
AppInfooperator= (AppInfo &&src) noexcept
 
 ~AppInfo () noexcept override
 
GAppInfogobj ()
 Provides access to the underlying C GObject.
 
const GAppInfogobj () const
 Provides access to the underlying C GObject.
 
Glib::RefPtr< AppInfocreate_duplicate () const
 Creates a duplicate of this AppInfo.
 
bool equal (const Glib::RefPtr< AppInfo > &other) const
 Checks if two AppInfos are equal.
 
std::string get_id () const
 Gets the ID of an application.
 
std::string get_name () const
 Gets the installed name of the application.
 
std::string get_display_name () const
 Gets the display name of the application.
 
std::string get_description () const
 Gets a human-readable description of an installed application.
 
std::string get_executable () const
 Gets the executable's name for the installed application.
 
std::string get_commandline () const
 Gets the commandline with which the application will be started.
 
Glib::RefPtr< Iconget_icon ()
 Gets the icon for the application.
 
const Glib::RefPtr< const Iconget_icon () const
 Gets the icon for the application.
 
bool launch (const Glib::RefPtr< Gio::File > & file, const Glib::RefPtr< AppLaunchContext > &context)
 Launches the application.
 
bool launch (const Glib::RefPtr< Gio::File > & file)
 Launches the application.
 
bool launch (const std::vector< Glib::RefPtr< Gio::File > > &files, const Glib::RefPtr< AppLaunchContext > &context)
 Launches the application.
 
bool launch (const std::vector< Glib::RefPtr< Gio::File > > &files)
 A launch() convenience overload.
 
bool supports_uris () const
 Checks if the application supports reading files and directories from URIs.
 
bool supports_files () const
 Checks if the application accepts files as arguments.
 
bool launch_uris (const std::vector< std::string > &uris, const Glib::RefPtr< AppLaunchContext > &context)
 Launches the application.
 
bool launch_uris (const std::vector< std::string > &uris)
 A launch_uris() convenience overload.
 
bool launch_uri (const std::string &uri, const Glib::RefPtr< AppLaunchContext > &context)
 Launches the application.
 
bool launch_uri (const std::string &uris)
 A launch_uri() convenience overload.
 
void launch_uris_async (const std::vector< std::string > &uris, const Glib::RefPtr< AppLaunchContext > &context, const SlotAsyncReady &slot, const Glib::RefPtr< Cancellable > &cancellable={})
 Async version of g_app_info_launch_uris().
 
void launch_uris_async (const std::vector< std::string > &uris, const Glib::RefPtr< AppLaunchContext > &context, const Glib::RefPtr< Cancellable > &cancellable={})
 A launch_uris_async() convenience overload.
 
bool launch_uris_finish (const Glib::RefPtr< AsyncResult > &result)
 Finishes a g_app_info_launch_uris_async() operation.
 
bool should_show () const
 Checks if the application info should be shown in menus that list available applications.
 
bool can_delete () const
 Obtains the information whether the AppInfo can be deleted.
 
bool do_delete ()
 Tries to delete a AppInfo.
 
bool set_as_default_for_type (const std::string &content_type)
 Sets the application as the default handler for a given type.
 
bool set_as_default_for_extension (const std::string &extension)
 Sets the application as the default handler for the given file extension.
 
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.
 
bool can_remove_supports_type () const
 Checks if a supported content type can be removed from an application.
 
bool remove_supports_type (const std::string &content_type)
 Removes a supported type from an application, if possible.
 
std::vector< Glib::ustringget_supported_types () const
 Retrieves the list of content types that app_info claims to support.
 
bool set_as_last_used_for_type (const std::string &content_type)
 Sets the application as the last used application for a given type.
 
- Public Member Functions inherited from Glib::Interface
 Interface ()
 A Default constructor.
 
 Interface (Interface &&src) noexcept
 
Interfaceoperator= (Interface &&src) noexcept
 
 Interface (const Glib::Interface_Class &interface_class)
 Called by constructors of derived classes.
 
 Interface (GObject *castitem)
 Called by constructors of derived classes.
 
 ~Interface () noexcept override
 
 Interface (const Interface &)=delete
 
Interfaceoperator= (const Interface &)=delete
 
GObject * gobj ()
 
const GObject * gobj () const
 
- Public Member Functions inherited from Glib::ObjectBase
 ObjectBase (const ObjectBase &)=delete
 
ObjectBaseoperator= (const ObjectBase &)=delete
 
void set_property_value (const Glib::ustring & property_name, const Glib::ValueBase & value)
 You probably want to use a specific property_*() accessor method instead.
 
void get_property_value (const Glib::ustring & property_name, Glib::ValueBase & value) const
 You probably want to use a specific property_*() accessor method instead.
 
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.
 
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.
 
template<class PropertyType >
PropertyType get_property (const Glib::ustring & property_name) const
 You probably want to use a specific property_*() accessor method instead.
 
sigc::connection 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.
 
sigc::connection connect_property_changed (const Glib::ustring & property_name, sigc::slot< void()> &&slot)
 You can use the signal_changed() signal of the property proxy instead.
 
void freeze_notify ()
 Increases the freeze count on object.
 
void thaw_notify ()
 Reverts the effect of a previous call to freeze_notify().
 
virtual void reference () const
 Increment the reference count for this object.
 
virtual void unreference () const
 Decrement the reference count for this object.
 
GObject * gobj ()
 Provides access to the underlying C GObject.
 
const GObject * gobj () const
 Provides access to the underlying C GObject.
 
GObject * gobj_copy () const
 Give a ref-ed copy to someone. Use for direct struct access.
 

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.
 
static Glib::RefPtr< AppInfocreate_from_commandline (const std::string &commandline, const std::string &application_name, CreateFlags flags)
 
static std::vector< Glib::RefPtr< AppInfo > > get_all ()
 Gets a list of all of the applications currently registered on this system.
 
static std::vector< 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.
 
static std::vector< Glib::RefPtr< AppInfo > > get_recommended_for_type (const std::string &content_type)
 Gets a list of recommended AppInfos for a given content type, i.e. those applications which claim to support the given content type exactly, and not by MIME type subclassing.
 
static std::vector< Glib::RefPtr< AppInfo > > get_fallback_for_type (const std::string &content_type)
 Gets a list of fallback AppInfos for a given content type, i.e. those applications which claim to support the given content type by MIME type subclassing and not directly.
 
static Glib::RefPtr< AppInfoget_default_for_type (const std::string &content_type, bool must_support_uris=true)
 Gets the default AppInfo for a given content type.
 
static void get_default_for_type_async (const std::string &content_type, bool must_support_uris, const SlotAsyncReady &slot, const Glib::RefPtr< Cancellable > &cancellable={})
 Asynchronously gets the default AppInfo for a given content type.
 
static void get_default_for_type_async (const std::string &content_type, bool must_support_uris, const Glib::RefPtr< Cancellable > &cancellable={})
 A get_default_for_type_async() convenience overload.
 
static Glib::RefPtr< AppInfoget_default_for_type_finish (const Glib::RefPtr< AsyncResult > &result)
 Finishes a default AppInfo lookup started by g_app_info_get_default_for_type_async().
 
static Glib::RefPtr< AppInfoget_default_for_uri_scheme (const std::string &uri_scheme)
 Gets the default application for handling URIs with the given URI scheme.
 
static void get_default_for_uri_scheme_async (const std::string &content_type, const SlotAsyncReady &slot, const Glib::RefPtr< Cancellable > &cancellable={})
 Asynchronously gets the default application for handling URIs with the given URI scheme.
 
static void get_default_for_uri_scheme_async (const std::string &content_type, const Glib::RefPtr< Cancellable > &cancellable={})
 A get_default_for_uri_scheme_async() convenience overload.
 
static Glib::RefPtr< AppInfoget_default_for_uri_scheme_finish (const Glib::RefPtr< AsyncResult > &result)
 Finishes a default AppInfo lookup started by g_app_info_get_default_for_uri_scheme_async().
 
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().
 
static bool launch_default_for_uri (const std::string &uri, const Glib::RefPtr< AppLaunchContext > &context)
 Utility function that launches the default application registered to handle the specified uri.
 
static bool launch_default_for_uri (const std::string &uri)
 A launch_default_for_uri() convenience overload.
 
static void launch_default_for_uri_async (const std::string &uri, const Glib::RefPtr< AppLaunchContext > &context, const SlotAsyncReady &slot, const Glib::RefPtr< Cancellable > &cancellable)
 Async version of g_app_info_launch_default_for_uri().
 
static void launch_default_for_uri_async (const std::string &uri, const Glib::RefPtr< AppLaunchContext > &context, const SlotAsyncReady &slot)
 A launch_default_for_uri_async() convenience overload.
 
static void launch_default_for_uri_async (const std::string &uri, const Glib::RefPtr< AppLaunchContext > &context, const Glib::RefPtr< Cancellable > &cancellable)
 A launch_default_for_uri_async() convenience overload.
 
static void launch_default_for_uri_async (const std::string &uri, const Glib::RefPtr< AppLaunchContext > &context)
 A launch_default_for_uri_async() convenience overload.
 
static void launch_default_for_uri_async (const std::string &uri, const SlotAsyncReady &slot, const Glib::RefPtr< Cancellable > &cancellable)
 A launch_default_for_uri_async() convenience overload.
 
static void launch_default_for_uri_async (const std::string &uri, const SlotAsyncReady &slot)
 A launch_default_for_uri_async() convenience overload.
 
static void launch_default_for_uri_async (const std::string &uri, const Glib::RefPtr< Cancellable > &cancellable)
 A launch_default_for_uri_async() convenience overload.
 
static void launch_default_for_uri_async (const std::string &uri)
 A launch_default_for_uri_async() convenience overload.
 
static bool launch_default_for_uri_finish (const Glib::RefPtr< AsyncResult > &result)
 Finishes an asynchronous launch-default-for-uri operation.
 

Protected Member Functions

 AppInfo ()
 You should derive from this class to use it.
 
- Protected Member Functions inherited from Glib::ObjectBase
 ObjectBase ()
 This default constructor is called implicitly from the constructor of user-derived classes, even if, for instance, Gtk::Button calls a different ObjectBase constructor.
 
 ObjectBase (const char *custom_type_name)
 A derived constructor always overrides this choice.
 
 ObjectBase (const std::type_info &custom_type_info)
 This constructor is a special feature to allow creation of derived types on the fly, without having to use g_object_new() manually.
 
 ObjectBase (ObjectBase &&src) noexcept
 
ObjectBaseoperator= (ObjectBase &&src) noexcept
 
virtual ~ObjectBase () noexcept=0
 
void initialize (GObject *castitem)
 
void initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)
 

Related Symbols

(Note that these are not member symbols.)

Glib::RefPtr< Gio::AppInfowrap (GAppInfo *object, bool take_copy=false)
 A Glib::wrap() method for this object.
 

Detailed Description

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

See also AppLaunchContext.

Since glibmm 2.16:

Member Enumeration Documentation

◆ CreateFlags

Enumerator
NONE 

No flags.

NEEDS_TERMINAL 

Application opens in a terminal window.

SUPPORTS_URIS 

Application supports URI arguments.

SUPPORTS_STARTUP_NOTIFICATION 

Application supports startup notification.

Since glibmm 2.26:

Constructor & Destructor Documentation

◆ AppInfo() [1/2]

Gio::AppInfo::AppInfo ( )
protected

You should derive from this class to use it.

◆ AppInfo() [2/2]

Gio::AppInfo::AppInfo ( AppInfo &&  src)
noexcept

◆ ~AppInfo()

Gio::AppInfo::~AppInfo ( )
overridenoexcept

Member Function Documentation

◆ add_interface()

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

◆ add_supports_type()

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_typeA string.
Returns
true on success, false on error.
Exceptions
Glib::Error

◆ can_delete()

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.

◆ can_remove_supports_type()

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.

◆ create_duplicate()

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

Creates a duplicate of this AppInfo.

Returns
A duplicate of this AppInfo.
Since glibmm 2.36:

◆ create_from_commandline()

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

◆ do_delete()

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

Since glibmm 2.20:
Returns
true if appinfo has been deleted.

◆ equal()

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

Checks if two AppInfos are equal.

Parameters
otherThe other AppInfo.
Returns
true if *this is equal to other, false otherwise.

◆ get_all()

static std::vector< 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.

◆ get_all_for_type()

static std::vector< 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_typeThe content type to find a AppInfo for.
Returns
List of AppInfos for given content_type or nullptr on error.

◆ get_commandline()

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 nullptr if this information is not available.

◆ get_default_for_type()

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_typeThe content type to find a AppInfo for.
must_support_urisIf true, the AppInfo is expected to support URIs.
Returns
AppInfo for given content_type or nullptr on error.

◆ get_default_for_type_async() [1/2]

static void Gio::AppInfo::get_default_for_type_async ( const std::string content_type,
bool  must_support_uris,
const Glib::RefPtr< Cancellable > &  cancellable = {} 
)
static

A get_default_for_type_async() convenience overload.

◆ get_default_for_type_async() [2/2]

static void Gio::AppInfo::get_default_for_type_async ( const std::string content_type,
bool  must_support_uris,
const SlotAsyncReady &  slot,
const Glib::RefPtr< Cancellable > &  cancellable = {} 
)
static

Asynchronously gets the default AppInfo for a given content type.

Since glibmm 2.74:
Parameters
content_typeThe content type to find a AppInfo for.
must_support_urisIf true, the AppInfo is expected to support URIs.
cancellableOptional Cancellable object, nullptr to ignore.
slotA SlotAsyncReady to call when the request is done.

◆ get_default_for_type_finish()

static Glib::RefPtr< AppInfo > Gio::AppInfo::get_default_for_type_finish ( const Glib::RefPtr< AsyncResult > &  result)
static

Finishes a default AppInfo lookup started by g_app_info_get_default_for_type_async().

If no AppInfo is found, then error will be set to Gio::Error::NOT_FOUND.

Since glibmm 2.74:
Parameters
resultA AsyncResult.
Returns
AppInfo for given content_type or nullptr on error.
Exceptions
Glib::Error

◆ get_default_for_uri_scheme()

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_schemeA string containing a URI scheme.
Returns
AppInfo for given uri_scheme or nullptr on error.

◆ get_default_for_uri_scheme_async() [1/2]

static void Gio::AppInfo::get_default_for_uri_scheme_async ( const std::string content_type,
const Glib::RefPtr< Cancellable > &  cancellable = {} 
)
static

A get_default_for_uri_scheme_async() convenience overload.

◆ get_default_for_uri_scheme_async() [2/2]

static void Gio::AppInfo::get_default_for_uri_scheme_async ( const std::string content_type,
const SlotAsyncReady &  slot,
const Glib::RefPtr< Cancellable > &  cancellable = {} 
)
static

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

Since glibmm 2.74:
Parameters
content_typeA string containing a URI scheme.
cancellableOptional Cancellable object, nullptr to ignore.
slotA SlotAsyncReady to call when the request is done.

◆ get_default_for_uri_scheme_finish()

static Glib::RefPtr< AppInfo > Gio::AppInfo::get_default_for_uri_scheme_finish ( const Glib::RefPtr< AsyncResult > &  result)
static

Finishes a default AppInfo lookup started by g_app_info_get_default_for_uri_scheme_async().

If no AppInfo is found, then error will be set to Gio::Error::NOT_FOUND.

Since glibmm 2.74:
Parameters
resultA AsyncResult.
Returns
AppInfo for given uri_scheme or nullptr on error.
Exceptions
Glib::Error

◆ get_description()

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 nullptr if none.

◆ get_display_name()

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.

◆ get_executable()

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

Gets the executable's name for the installed application.

This is intended to be used for debugging or labelling what program is going to be run. To launch the executable, use g_app_info_launch() and related functions, rather than spawning the return value from this function.

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

◆ get_fallback_for_type()

static std::vector< Glib::RefPtr< AppInfo > > Gio::AppInfo::get_fallback_for_type ( const std::string content_type)
static

Gets a list of fallback AppInfos for a given content type, i.e. those applications which claim to support the given content type by MIME type subclassing and not directly.

Since glibmm 2.76:
Parameters
content_typeThe content type to find a AppInfo for.
Returns
List of AppInfos for given content_type or nullptr on error.

◆ get_icon() [1/2]

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

Gets the icon for the application.

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

◆ get_icon() [2/2]

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

Gets the icon for the application.

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

◆ get_id()

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

Returns
A string containing the application's ID.

◆ get_name()

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

Gets the installed name of the application.

Returns
The name of the application for appinfo.

◆ get_recommended_for_type()

static std::vector< Glib::RefPtr< AppInfo > > Gio::AppInfo::get_recommended_for_type ( const std::string content_type)
static

Gets a list of recommended AppInfos 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.

Since glibmm 2.76:
Parameters
content_typeThe content type to find a AppInfo for.
Returns
List of AppInfos for given content_type or nullptr on error.

◆ get_supported_types()

std::vector< Glib::ustring > 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 nullptr. 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.

◆ get_type()

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

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

◆ gobj() [1/2]

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

Provides access to the underlying C GObject.

◆ gobj() [2/2]

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

Provides access to the underlying C GObject.

◆ launch() [1/4]

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

Parameters
fileA File object.
Returns
true on successful launch, false otherwise.
Since glibmm 2.30:

◆ launch() [2/4]

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

Launches the application.

This passes the file to the launched application as an argument, using the optional 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 context.

Parameters
fileA File object.
contextAn AppLaunchContext.
Returns
true on successful launch, false otherwise.
Since glibmm 2.30:

◆ launch() [3/4]

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

A launch() convenience overload.

◆ launch() [4/4]

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

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 nullptr 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, XDG_ACTIVATION_TOKEN and DESKTOP_STARTUP_ID environment variables are also set, based on information provided in context.

Parameters
filesA List of File objects.
contextA AppLaunchContext or nullptr.
Returns
true on successful launch, false otherwise.
Exceptions
Glib::Error

◆ launch_default_for_uri() [1/2]

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

A launch_default_for_uri() convenience overload.

◆ launch_default_for_uri() [2/2]

static bool Gio::AppInfo::launch_default_for_uri ( const std::string uri,
const Glib::RefPtr< AppLaunchContext > &  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.

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.

Parameters
uriThe uri to show.
contextAn optional AppLaunchContext.
Returns
true on success, false on error.
Exceptions
Glib::Error

◆ launch_default_for_uri_async() [1/8]

static void Gio::AppInfo::launch_default_for_uri_async ( const std::string uri)
static

A launch_default_for_uri_async() convenience overload.

◆ launch_default_for_uri_async() [2/8]

static void Gio::AppInfo::launch_default_for_uri_async ( const std::string uri,
const Glib::RefPtr< AppLaunchContext > &  context 
)
static

A launch_default_for_uri_async() convenience overload.

◆ launch_default_for_uri_async() [3/8]

static void Gio::AppInfo::launch_default_for_uri_async ( const std::string uri,
const Glib::RefPtr< AppLaunchContext > &  context,
const Glib::RefPtr< Cancellable > &  cancellable 
)
static

A launch_default_for_uri_async() convenience overload.

◆ launch_default_for_uri_async() [4/8]

static void Gio::AppInfo::launch_default_for_uri_async ( const std::string uri,
const Glib::RefPtr< AppLaunchContext > &  context,
const SlotAsyncReady &  slot 
)
static

A launch_default_for_uri_async() convenience overload.

◆ launch_default_for_uri_async() [5/8]

static void Gio::AppInfo::launch_default_for_uri_async ( const std::string uri,
const Glib::RefPtr< AppLaunchContext > &  context,
const SlotAsyncReady &  slot,
const Glib::RefPtr< Cancellable > &  cancellable 
)
static

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 glibmm 2.50:
Parameters
uriThe uri to show.
contextAn optional AppLaunchContext.
cancellableA Cancellable.
slotA SlotAsyncReady to call when the request is done.

◆ launch_default_for_uri_async() [6/8]

static void Gio::AppInfo::launch_default_for_uri_async ( const std::string uri,
const Glib::RefPtr< Cancellable > &  cancellable 
)
static

A launch_default_for_uri_async() convenience overload.

◆ launch_default_for_uri_async() [7/8]

static void Gio::AppInfo::launch_default_for_uri_async ( const std::string uri,
const SlotAsyncReady &  slot 
)
static

A launch_default_for_uri_async() convenience overload.

◆ launch_default_for_uri_async() [8/8]

static void Gio::AppInfo::launch_default_for_uri_async ( const std::string uri,
const SlotAsyncReady &  slot,
const Glib::RefPtr< Cancellable > &  cancellable 
)
static

A launch_default_for_uri_async() convenience overload.

◆ launch_default_for_uri_finish()

static bool Gio::AppInfo::launch_default_for_uri_finish ( const Glib::RefPtr< AsyncResult > &  result)
static

Finishes an asynchronous launch-default-for-uri operation.

Since glibmm 2.50:
Parameters
resultA AsyncResult.
Returns
true if the launch was successful, false if error is set.
Exceptions
Glib::Error

◆ launch_uri() [1/2]

bool Gio::AppInfo::launch_uri ( const std::string uri,
const Glib::RefPtr< AppLaunchContext > &  context 
)

Launches the application.

This passes the uri to the launched application as an arguments, using the optional 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
uriA URI to launch.
contextAn AppLaunchContext.
Returns
true on successful launch, false otherwise.
Since glibmm 2.30:

◆ launch_uri() [2/2]

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

A launch_uri() convenience overload.

Since glibmm 2.30:

◆ launch_uris() [1/2]

bool Gio::AppInfo::launch_uris ( const std::vector< std::string > &  uris)

A launch_uris() convenience overload.

◆ launch_uris() [2/2]

bool Gio::AppInfo::launch_uris ( const std::vector< std::string > &  uris,
const Glib::RefPtr< AppLaunchContext > &  context 
)

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. If the application only supports one URI per invocation as part of their command-line, multiple instances of the application will be spawned.

To launch the application without arguments pass a nullptr 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
urisA List containing URIs to launch.
contextA AppLaunchContext or nullptr.
Returns
true on successful launch, false otherwise.
Exceptions
Glib::Error

◆ launch_uris_async() [1/2]

void Gio::AppInfo::launch_uris_async ( const std::vector< std::string > &  uris,
const Glib::RefPtr< AppLaunchContext > &  context,
const Glib::RefPtr< Cancellable > &  cancellable = {} 
)

A launch_uris_async() convenience overload.

◆ launch_uris_async() [2/2]

void Gio::AppInfo::launch_uris_async ( const std::vector< std::string > &  uris,
const Glib::RefPtr< AppLaunchContext > &  context,
const SlotAsyncReady &  slot,
const Glib::RefPtr< Cancellable > &  cancellable = {} 
)

Async version of g_app_info_launch_uris().

The slot is invoked immediately after the application launch, but it waits for activation in case of D-Bus–activated applications and also provides extended error information for sandboxed applications, see notes for g_app_info_launch_default_for_uri_async().

Since glibmm 2.60:
Parameters
urisA List containing URIs to launch.
contextA AppLaunchContext or nullptr.
cancellableA Cancellable.
slotA SlotAsyncReady to call when the request is done.

◆ launch_uris_finish()

bool Gio::AppInfo::launch_uris_finish ( const Glib::RefPtr< AsyncResult > &  result)

Finishes a g_app_info_launch_uris_async() operation.

Since glibmm 2.60:
Parameters
resultA AsyncResult.
Returns
true on successful launch, false otherwise.
Exceptions
Glib::Error

◆ operator=()

AppInfo & Gio::AppInfo::operator= ( AppInfo &&  src)
noexcept

◆ remove_supports_type()

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

Removes a supported type from an application, if possible.

Parameters
content_typeA string.
Returns
true on success, false on error.
Exceptions
Glib::Error

◆ reset_type_associations()

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

◆ set_as_default_for_extension()

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
extensionA string containing the file extension (without the dot).
Returns
true on success, false on error.
Exceptions
Glib::Error

◆ set_as_default_for_type()

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_typeThe content type.
Returns
true on success, false on error.
Exceptions
Glib::Error

◆ set_as_last_used_for_type()

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_typeThe content type.
Returns
true on success, false on error.
Exceptions
Glib::Error

◆ should_show()

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.

◆ supports_files()

bool Gio::AppInfo::supports_files ( ) const

Checks if the application accepts files as arguments.

Returns
true if the appinfo supports files.

◆ supports_uris()

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 Symbol Documentation

◆ wrap()

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

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

Parameters
objectThe C instance.
take_copyFalse 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.