[glib] GDesktopAppInfo: Add g_desktop_app_info_get_generic_name
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GDesktopAppInfo: Add g_desktop_app_info_get_generic_name
- Date: Wed, 27 Apr 2011 15:36:53 +0000 (UTC)
commit 4098ddcb066f40bf9563973753bbb7867a553700
Author: Colin Walters <walters verbum org>
Date: Wed Apr 27 11:34:23 2011 -0400
GDesktopAppInfo: Add g_desktop_app_info_get_generic_name
Necessary for rebasing gnome-menus on top of GDesktopAppInfo.
https://bugzilla.gnome.org/show_bug.cgi?id=647967
gio/gdesktopappinfo.c | 22 +++++++++++++++++++++-
gio/gdesktopappinfo.h | 1 +
2 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
index a65ef31..f72de34 100644
--- a/gio/gdesktopappinfo.c
+++ b/gio/gdesktopappinfo.c
@@ -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);
diff --git a/gio/gdesktopappinfo.h b/gio/gdesktopappinfo.h
index cb9e685..f44acad 100644
--- a/gio/gdesktopappinfo.h
+++ b/gio/gdesktopappinfo.h
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]