[glib] desktop-app-info: Add support for X-GNOME-Keywords



commit 1ed88f0615d1be4d629f3f1933ec5b249cb6429e
Author: Florian MÃllner <fmuellner gnome org>
Date:   Thu Oct 13 22:33:21 2011 +0200

    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

 docs/reference/gio/gio-sections.txt |    1 +
 gio/gdesktopappinfo.c               |   21 +++++++++++++++++++++
 gio/gdesktopappinfo.h               |    1 +
 gio/gio.symbols                     |    1 +
 4 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index f14fc3b..7d7def3 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -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
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
index 22d7621..381dbe4 100644
--- a/gio/gdesktopappinfo.c
+++ b/gio/gdesktopappinfo.c
@@ -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);
@@ -663,6 +668,22 @@ g_desktop_app_info_get_categories (GDesktopAppInfo *info)
 }
 
 /**
+ * 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
  *
diff --git a/gio/gdesktopappinfo.h b/gio/gdesktopappinfo.h
index 21c4efe..392dca7 100644
--- a/gio/gdesktopappinfo.h
+++ b/gio/gdesktopappinfo.h
@@ -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);
diff --git a/gio/gio.symbols b/gio/gio.symbols
index 3bc3be5..029c102 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]