Commit 1ed88f06 authored by Florian Müllner's avatar Florian Müllner

desktop-app-info: Add support for X-GNOME-Keywords

With search gaining traction as being the preferred way to locate
applications, the existing .desktop file fields meant for browsing
often produce insufficient results.
gnome-control-center introduced a custom X-GNOME-Keywords field for
that purpose, which we plan to support in gnome-shell as well.

https://bugzilla.gnome.org/show_bug.cgi?id=661763
parent 14e3b128
......@@ -1408,6 +1408,7 @@ g_desktop_app_info_get_nodisplay
g_desktop_app_info_get_show_in
g_desktop_app_info_get_generic_name
g_desktop_app_info_get_categories
g_desktop_app_info_get_keywords
g_desktop_app_info_set_desktop_env
GDesktopAppLaunchCallback
g_desktop_app_info_launch_uris_as_manager
......
......@@ -66,6 +66,7 @@
#define MIME_CACHE_GROUP "MIME Cache"
#define GENERIC_NAME_KEY "GenericName"
#define FULL_NAME_KEY "X-GNOME-FullName"
#define KEYWORDS_KEY "X-GNOME-Keywords"
enum {
PROP_0,
......@@ -99,6 +100,7 @@ struct _GDesktopAppInfo
char *comment;
char *icon_name;
GIcon *icon;
char **keywords;
char **only_show_in;
char **not_show_in;
char *try_exec;
......@@ -177,6 +179,7 @@ g_desktop_app_info_finalize (GObject *object)
g_free (info->icon_name);
if (info->icon)
g_object_unref (info->icon);
g_strfreev (info->keywords);
g_strfreev (info->only_show_in);
g_strfreev (info->not_show_in);
g_free (info->try_exec);
......@@ -315,6 +318,7 @@ g_desktop_app_info_load_from_keyfile (GDesktopAppInfo *info,
info->name = g_key_file_get_locale_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_NAME, NULL, NULL);
info->generic_name = g_key_file_get_locale_string (key_file, G_KEY_FILE_DESKTOP_GROUP, GENERIC_NAME_KEY, NULL, NULL);
info->fullname = g_key_file_get_locale_string (key_file, G_KEY_FILE_DESKTOP_GROUP, FULL_NAME_KEY, NULL, NULL);
info->keywords = g_key_file_get_locale_string_list (key_file, G_KEY_FILE_DESKTOP_GROUP, KEYWORDS_KEY, NULL, NULL, NULL);
info->comment = g_key_file_get_locale_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_COMMENT, NULL, NULL);
info->nodisplay = g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY, NULL) != FALSE;
info->icon_name = g_key_file_get_locale_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL, NULL);
......@@ -523,6 +527,7 @@ g_desktop_app_info_dup (GAppInfo *appinfo)
new_info->name = g_strdup (info->name);
new_info->generic_name = g_strdup (info->generic_name);
new_info->fullname = g_strdup (info->fullname);
new_info->keywords = g_strdupv (info->keywords);
new_info->comment = g_strdup (info->comment);
new_info->nodisplay = info->nodisplay;
new_info->icon_name = g_strdup (info->icon_name);
......@@ -662,6 +667,22 @@ g_desktop_app_info_get_categories (GDesktopAppInfo *info)
return info->categories;
}
/**
* g_desktop_app_info_get_keywords:
* @info: a #GDesktopAppInfo
*
* Gets the keywords from the desktop file.
*
* Returns: The value of the X-GNOME-Keywords key
*
* Since: 2.32
*/
const char * const *
g_desktop_app_info_get_keywords (GDesktopAppInfo *info)
{
return (const char * const *)info->keywords;
}
/**
* g_desktop_app_info_get_generic_name:
* @info: a #GDesktopAppInfo
......
......@@ -52,6 +52,7 @@ const char * g_desktop_app_info_get_filename (GDesktopAppInfo *info);
const char * g_desktop_app_info_get_generic_name (GDesktopAppInfo *info);
const char * g_desktop_app_info_get_categories (GDesktopAppInfo *info);
const char * const *g_desktop_app_info_get_keywords (GDesktopAppInfo *info);
gboolean g_desktop_app_info_get_nodisplay (GDesktopAppInfo *info);
gboolean g_desktop_app_info_get_show_in (GDesktopAppInfo *info,
const gchar *desktop_env);
......
......@@ -97,6 +97,7 @@ g_desktop_app_info_get_categories
g_desktop_app_info_get_filename
g_desktop_app_info_get_generic_name
g_desktop_app_info_get_is_hidden
g_desktop_app_info_get_keywords
g_desktop_app_info_get_nodisplay
g_desktop_app_info_get_show_in
g_desktop_app_info_get_type
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment