Class DesktopAppInfo

All Implemented Interfaces:
PointerInterface

public class DesktopAppInfo extends Object
#GDesktopAppInfo is an implementation of #GAppInfo based on
desktop files.

Note that `<gio/gdesktopappinfo.h>` belongs to the UNIX-specific
GIO interfaces, thus you have to use the `gio-unix-2.0.pc` pkg-config
file when using it.

https://docs.gtk.org/gio/class.DesktopAppInfo.html

  • Constructor Details

    • DesktopAppInfo

      public DesktopAppInfo(PointerContainer pointer)
    • DesktopAppInfo

      public DesktopAppInfo(@Nonnull Str desktop_id)
      Creates a new #GDesktopAppInfo 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](http://standards.freedesktop.org/menu-spec/latest/)
      (i.e. a desktop id of kde-foo.desktop will match
      `/usr/share/applications/kde/foo.desktop`).
      Parameters:
      desktop_id - the desktop file id
    • DesktopAppInfo

      public DesktopAppInfo(String desktop_id)
      Creates a new #GDesktopAppInfo 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](http://standards.freedesktop.org/menu-spec/latest/)
      (i.e. a desktop id of kde-foo.desktop will match
      `/usr/share/applications/kde/foo.desktop`).
      Parameters:
      desktop_id - the desktop file id
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • newFromFilenameDesktopAppInfo

      public static DesktopAppInfo newFromFilenameDesktopAppInfo(@Nonnull Str filename)
      Creates a new #GDesktopAppInfo.
      Parameters:
      filename - the path of a desktop file, in the GLib filename encoding
      Returns:
      a new #GDesktopAppInfo or %NULL on error.
    • newFromFilenameDesktopAppInfo

      public static DesktopAppInfo newFromFilenameDesktopAppInfo(String filename)
      Creates a new #GDesktopAppInfo.
      Parameters:
      filename - the path of a desktop file, in the GLib filename encoding
      Returns:
      a new #GDesktopAppInfo or %NULL on error.
    • newFromKeyfileDesktopAppInfo

      public static DesktopAppInfo newFromKeyfileDesktopAppInfo(@Nonnull KeyFile key_file)
      Creates a new #GDesktopAppInfo.
      Parameters:
      key_file - an opened #GKeyFile
      Returns:
      a new #GDesktopAppInfo or %NULL on error.
    • getActionName

      public Str getActionName(@Nonnull Str action_name)
      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 - the name of the action as from g_desktop_app_info_list_actions()
      Returns:
      the locale-specific action name
    • getActionName

      public Str getActionName(String action_name)
      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 - the name of the action as from g_desktop_app_info_list_actions()
      Returns:
      the locale-specific action name
    • getBoolean

      public boolean getBoolean(@Nonnull Str key)
      Looks up a boolean value in the keyfile backing @info.

      The @key is looked up in the "Desktop Entry" group.
      Parameters:
      key - the key to look up
      Returns:
      the boolean value, or %FALSE if the key is not found
    • getBoolean

      public boolean getBoolean(String key)
      Looks up a boolean value in the keyfile backing @info.

      The @key is looked up in the "Desktop Entry" group.
      Parameters:
      key - the key to look up
      Returns:
      the boolean value, or %FALSE if the key is not found
    • getCategories

      public Str getCategories()
      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.
    • getFilename

      public Str getFilename()
      When @info was created from a known filename, return it. In some
      situations such as the #GDesktopAppInfo returned from
      g_desktop_app_info_new_from_keyfile(), this function will return %NULL.
      Returns:
      The full path to the file for @info, or %NULL if not known.
    • getGenericName

      public Str getGenericName()
      Gets the generic name from the desktop file.
      Returns:
      The value of the GenericName key
    • getIsHidden

      public boolean getIsHidden()
      A desktop file is hidden if the Hidden key in it is
      set to True.
      Returns:
      %TRUE if hidden, %FALSE otherwise.
    • getKeywords

      public Strs getKeywords()
      Gets the keywords from the desktop file.
      Returns:
      The value of the Keywords key
    • getLocaleString

      public Str getLocaleString(@Nonnull Str key)
      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 - the key to look up
      Returns:
      a newly allocated string, or %NULL if the key is not found
    • getLocaleString

      public Str getLocaleString(String key)
      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 - the key to look up
      Returns:
      a newly allocated string, or %NULL if the key is not found
    • getNodisplay

      public boolean getNodisplay()
      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:
      The value of the NoDisplay key
    • getShowIn

      public boolean getShowIn(@Nullable Str desktop_env)
      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 %NULL, 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
      %NULL for @desktop_env) as well as additional checks.
      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.
    • getShowIn

      public boolean getShowIn(String desktop_env)
      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 %NULL, 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
      %NULL for @desktop_env) as well as additional checks.
      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.
    • getStartupWmClass

      public Str getStartupWmClass()
      Retrieves the StartupWMClass field from @info. This represents the
      WM_CLASS property of the main window of the application, if launched
      through @info.
      Returns:
      the startup WM class, or %NULL if none is set in the desktop file.
    • getString

      public Str getString(@Nonnull Str key)
      Looks up a string value in the keyfile backing @info.

      The @key is looked up in the "Desktop Entry" group.
      Parameters:
      key - the key to look up
      Returns:
      a newly allocated string, or %NULL if the key is not found
    • getString

      public Str getString(String key)
      Looks up a string value in the keyfile backing @info.

      The @key is looked up in the "Desktop Entry" group.
      Parameters:
      key - the key to look up
      Returns:
      a newly allocated string, or %NULL if the key is not found
    • hasKey

      public boolean hasKey(@Nonnull Str key)
      Returns whether @key exists in the "Desktop Entry" group
      of the keyfile backing @info.
      Parameters:
      key - the key to look up
      Returns:
      %TRUE if the @key exists
    • hasKey

      public boolean hasKey(String key)
      Returns whether @key exists in the "Desktop Entry" group
      of the keyfile backing @info.
      Parameters:
      key - the key to look up
      Returns:
      %TRUE if the @key exists
    • launchAction

      public void launchAction(@Nonnull Str action_name, @Nullable 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-%NULL, 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 - the name of the action as from g_desktop_app_info_list_actions()
      launch_context - a #GAppLaunchContext
    • launchAction

      public void launchAction(String action_name, @Nullable 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-%NULL, 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 - the name of the action as from g_desktop_app_info_list_actions()
      launch_context - a #GAppLaunchContext
    • getImplementations

      public static List getImplementations(@Nonnull Str _interface)
      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.
      Parameters:
      _interface - the name of the interface
      Returns:
      a list of #GDesktopAppInfo objects.
    • asAppInfo

      public AppInfo asAppInfo()
      Implements interface AppInfo. Call this to get access to interface functions.
      Returns:
      AppInfo
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()