GDesktopAppInfo: Add g_desktop_app_info_get_generic_name
authorColin Walters <walters@verbum.org>
Wed, 27 Apr 2011 15:34:23 +0000 (11:34 -0400)
committerColin Walters <walters@verbum.org>
Wed, 27 Apr 2011 15:34:43 +0000 (11:34 -0400)
Necessary for rebasing gnome-menus on top of GDesktopAppInfo.

https://bugzilla.gnome.org/show_bug.cgi?id=647967

gio/gdesktopappinfo.c
gio/gdesktopappinfo.h

index a65ef31..f72de34 100644 (file)
@@ -64,6 +64,7 @@
 #define ADDED_ASSOCIATIONS_GROUP    "Added Associations"
 #define REMOVED_ASSOCIATIONS_GROUP  "Removed Associations"
 #define MIME_CACHE_GROUP            "MIME Cache"
+#define GENERIC_NAME_KEY            "GenericName"
 #define FULL_NAME_KEY               "X-GNOME-FullName"
 
 enum {
@@ -93,7 +94,7 @@ struct _GDesktopAppInfo
   char *filename;
 
   char *name;
-  /* FIXME: what about GenericName ? */
+  char *generic_name;
   char *fullname;
   char *comment;
   char *icon_name;
@@ -167,6 +168,7 @@ g_desktop_app_info_finalize (GObject *object)
   g_free (info->desktop_id);
   g_free (info->filename);
   g_free (info->name);
+  g_free (info->generic_name);
   g_free (info->fullname);
   g_free (info->comment);
   g_free (info->icon_name);
@@ -308,6 +310,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->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;
@@ -515,6 +518,7 @@ g_desktop_app_info_dup (GAppInfo *appinfo)
   new_info->desktop_id = g_strdup (info->desktop_id);
   
   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->comment = g_strdup (info->comment);
   new_info->nodisplay = info->nodisplay;
@@ -653,6 +657,18 @@ g_desktop_app_info_get_categories    (GDesktopAppInfo *info)
   return info->categories;
 }
 
+/**
+ * g_desktop_app_info_get_generic_name:
+ * @info: a #GDesktopAppInfo
+ *
+ * Returns: The value of the GenericName key
+ */
+const char *
+g_desktop_app_info_get_generic_name  (GDesktopAppInfo *info)
+{
+  return info->generic_name;
+}
+
 static char *
 expand_macro_single (char macro, char *uri)
 {
@@ -1911,6 +1927,10 @@ g_desktop_app_info_ensure_saved (GDesktopAppInfo  *info,
   g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
                         G_KEY_FILE_DESKTOP_KEY_NAME, info->name);
 
+  if (info->generic_name != NULL)
+    g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
+                          GENERIC_NAME_KEY, info->generic_name);
+
   if (info->fullname != NULL)
     g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
                           FULL_NAME_KEY, info->fullname);
index cb9e685..f44acad 100644 (file)
@@ -50,6 +50,7 @@ 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_generic_name  (GDesktopAppInfo *info);
 const char *     g_desktop_app_info_get_categories    (GDesktopAppInfo *info);
 
 GDesktopAppInfo *g_desktop_app_info_new               (const char      *desktop_id);