[glib] GDesktopAppInfo: Add g_desktop_app_info_get_categories()



commit 276e6a7be8a2d31bd67cac7c571f65dfd8b2fd88
Author: Colin Walters <walters verbum org>
Date:   Fri Apr 15 15:52:33 2011 -0400

    GDesktopAppInfo: Add g_desktop_app_info_get_categories()
    
    This is needed to rebase gnome-menus on top of GDesktopAppInfo.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=647903

 gio/gdesktopappinfo.c |   16 ++++++++++++++++
 gio/gdesktopappinfo.h |    2 ++
 2 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
index 1236d36..a65ef31 100644
--- a/gio/gdesktopappinfo.c
+++ b/gio/gdesktopappinfo.c
@@ -104,6 +104,7 @@ struct _GDesktopAppInfo
   char *exec;
   char *binary;
   char *path;
+  char *categories;
 
   guint nodisplay       : 1;
   guint hidden          : 1;
@@ -177,6 +178,7 @@ g_desktop_app_info_finalize (GObject *object)
   g_free (info->exec);
   g_free (info->binary);
   g_free (info->path);
+  g_free (info->categories);
   
   G_OBJECT_CLASS (g_desktop_app_info_parent_class)->finalize (object);
 }
@@ -319,6 +321,7 @@ g_desktop_app_info_load_from_keyfile (GDesktopAppInfo *info,
   info->startup_notify = g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY, NULL) != FALSE;
   info->no_fuse = g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, "X-GIO-NoFuse", NULL) != FALSE;
   info->hidden = g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_HIDDEN, NULL) != FALSE;
+  info->categories = g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_CATEGORIES, NULL);
   
   info->icon = NULL;
   if (info->icon_name)
@@ -637,6 +640,19 @@ g_desktop_app_info_get_icon (GAppInfo *appinfo)
   return info->icon;
 }
 
+/**
+ * g_desktop_app_info_get_categories:
+ * @info: a #GDesktopAppInfo
+ *
+ * Returns: The unparsed Categories key from the file; i.e. no attempt
+ *   is made to split it by ';' or validate it.
+ */
+const char *
+g_desktop_app_info_get_categories    (GDesktopAppInfo *info)
+{
+  return info->categories;
+}
+
 static char *
 expand_macro_single (char macro, char *uri)
 {
diff --git a/gio/gdesktopappinfo.h b/gio/gdesktopappinfo.h
index 162cbb6..cb9e685 100644
--- a/gio/gdesktopappinfo.h
+++ b/gio/gdesktopappinfo.h
@@ -50,6 +50,8 @@ GDesktopAppInfo *g_desktop_app_info_new_from_keyfile  (GKeyFile        *key_file
 
 const char *     g_desktop_app_info_get_filename      (GDesktopAppInfo *info);
 
+const char *     g_desktop_app_info_get_categories    (GDesktopAppInfo *info);
+
 GDesktopAppInfo *g_desktop_app_info_new               (const char      *desktop_id);
 gboolean         g_desktop_app_info_get_is_hidden     (GDesktopAppInfo *info);
 



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