Class: Gio::DesktopAppInfo

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key_file) ⇒ Gio::DesktopAppInfo

Creates a new GDesktop::AppInfo.

Parameters:

  • key_file (GLib::KeyFile)

    an opened GKey::File

Class Method Details

.desktop_env=(desktop_env) ⇒ nil

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.

Should be called only once; subsequent calls are ignored.

Parameters:

  • desktop_env (String)

    a string specifying what desktop this is

Returns:

  • (nil)

.get_implementations(interface) ⇒ GLib::List<Gio::DesktopAppInfo>

Gets all applications that implement interface.

An application implements an interface if that interface is listed in the Implements= line of the desktop file of the application. objects.

Parameters:

  • interface (String)

    the name of the interface

Returns:

Instance Method Details

#categoriesString

Gets the categories from the desktop file.

Returns:

  • (String)

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

#filenameString

The origin filename of this GDesktop::AppInfo

Returns:

  • (String)

    filename

#filename=(filename) ⇒ String

The origin filename of this GDesktop::AppInfo

Parameters:

  • filename (String)

Returns:

  • (String)

    filename

  • (String)

    filename

#generic_nameString

Gets the generic name from the desktop file.

Returns:

  • (String)

    The value of the GenericName key

#get_action_name(action_name) ⇒ String

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.

Parameters:

  • action_name (String)

    the name of the action as from g_desktop_app_info_list_actions()

Returns:

  • (String)

    the locale-specific action name

#get_boolean(key) ⇒ Boolean

Looks up a boolean value in the keyfile backing info.

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

Parameters:

  • key (String)

    the key to look up

Returns:

  • (Boolean)

    the boolean value, or false if the key is not found

#get_locale_string(key) ⇒ String

Looks up a localized string value in the keyfile backing info translated to the current locale.

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

Parameters:

  • key (String)

    the key to look up

Returns:

  • (String)

    a newly allocated string, or nil if the key is not found

#get_show_in(desktop_env) ⇒ Boolean

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.

desktop_env should typically be given as nil, in which case the XDG_CURRENT_DESKTOP environment variable is consulted. If you want to override the default mechanism then you may specify desktop_env, but this is not recommended.

Note that g_app_info_should_show() for info will include this check (with nil for desktop_env) as well as additional checks. OnlyShowIn and NotShowIn keys, false otherwise.

Parameters:

  • desktop_env (String)

    a string specifying a desktop name

Returns:

  • (Boolean)

    true if the info should be shown in desktop_env according to the

#get_string(key) ⇒ String

Looks up a string value in the keyfile backing info.

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

Parameters:

  • key (String)

    the key to look up

Returns:

  • (String)

    a newly allocated string, or nil if the key is not found

#get_string_list(key, length) ⇒ Array<String>

Looks up a string list value in the keyfile backing info.

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

Parameters:

  • key (String)

    the key to look up

  • length (Integer)

    return location for the number of returned strings, or nil

Returns:

  • (Array<String>)

    a nil-terminated string array or nil if the specified key cannot be found. The array should be freed with g_strfreev().

#has_key(key) ⇒ Boolean

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

Parameters:

  • key (String)

    the key to look up

Returns:

  • (Boolean)

    true if the key exists

#is_hiddenBoolean

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

Returns:

  • (Boolean)

    true if hidden, false otherwise.

#keywordsArray<String>

Gets the keywords from the desktop file.

Returns:

  • (Array<String>)

    The value of the Keywords key

#launch_action(action_name, launch_context) ⇒ nil

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-nil, 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.

Parameters:

  • action_name (String)

    the name of the action as from g_desktop_app_info_list_actions()

  • launch_context (Gio::AppLaunchContext)

    a GApp::LaunchContext

Returns:

  • (nil)

#launch_uris_as_manager(uris, launch_context, spawn_flags, user_setup, user_setup_data, pid_callback, pid_callback_data) ⇒ Boolean

This function performs the equivalent of g_app_info_launch_uris(), but is intended primarily for operating system components that launch applications. Ordinary applications should use g_app_info_launch_uris().

If the application is launched via GSpawn, then spawn_flags, user_setup and user_setup_data are used for the call to g_spawn_async(). Additionally, pid_callback (with pid_callback_data) will be called to inform about the PID of the created process. See g_spawn_async_with_pipes() for information on certain parameter conditions that can enable an optimized posix_spawn() codepath to be used.

If application launching occurs via some other mechanism (eg: D-Bus activation) then spawn_flags, user_setup, user_setup_data, pid_callback and pid_callback_data are ignored.

Parameters:

  • uris (GLib::List<String>)

    List of URIs

  • launch_context (Gio::AppLaunchContext)

    a GApp::LaunchContext

  • spawn_flags (GLib::SpawnFlags)

    GSpawn::Flags, used for each process

  • user_setup (GLib::SpawnChildSetupFunc)

    a GSpawn::ChildSetupFunc, used once for each process.

  • user_setup_data (GObject)

    User data for user_setup

  • pid_callback (Gio::DesktopAppLaunchCallback)

    Callback for child processes

  • pid_callback_data (GObject)

    User data for callback

Returns:

  • (Boolean)

    true on successful launch, false otherwise.

#launch_uris_as_manager_with_fds(uris, launch_context, spawn_flags, user_setup, user_setup_data, pid_callback, pid_callback_data, stdin_fd, stdout_fd, stderr_fd) ⇒ Boolean

Equivalent to g_desktop_app_info_launch_uris_as_manager() but allows you to pass in file descriptors for the stdin, stdout and stderr streams of the launched process.

If application launching occurs via some non-spawn mechanism (e.g. D-Bus activation) then stdin_fd, stdout_fd and stderr_fd are ignored.

Parameters:

  • uris (GLib::List<String>)

    List of URIs

  • launch_context (Gio::AppLaunchContext)

    a GApp::LaunchContext

  • spawn_flags (GLib::SpawnFlags)

    GSpawn::Flags, used for each process

  • user_setup (GLib::SpawnChildSetupFunc)

    a GSpawn::ChildSetupFunc, used once for each process.

  • user_setup_data (GObject)

    User data for user_setup

  • pid_callback (Gio::DesktopAppLaunchCallback)

    Callback for child processes

  • pid_callback_data (GObject)

    User data for callback

  • stdin_fd (Integer)

    file descriptor to use for child's stdin, or -1

  • stdout_fd (Integer)

    file descriptor to use for child's stdout, or -1

  • stderr_fd (Integer)

    file descriptor to use for child's stderr, or -1

Returns:

  • (Boolean)

    true on successful launch, false otherwise.

#list_actionsArray<String>

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.

Returns:

  • (Array<String>)

    a list of strings, always non-nil

#nodisplayBoolean

Gets the value of the NoDisplay key, which helps determine if the application info should be shown in menus. See %G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY and g_app_info_should_show().

Returns:

  • (Boolean)

    The value of the NoDisplay key

#startup_wm_classString

Retrieves the StartupWMClass field from info. This represents the WM_CLASS property of the main window of the application, if launched through info. in the desktop file.

Returns:

  • (String)

    the startup WM class, or nil if none is set