[gnome-menus/wip/gobject-review] libmenu: Handle GenericName for .directory files
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-menus/wip/gobject-review] libmenu: Handle GenericName for .directory files
- Date: Sun, 12 Jun 2011 10:12:09 +0000 (UTC)
commit 6d911083080ca4aaa636dbbc1b509c4ae3ec8ab8
Author: Vincent Untz <vuntz gnome org>
Date: Sun Jun 12 12:11:31 2011 +0200
libmenu: Handle GenericName for .directory files
While we do not strictly need them right now, this is allowed by the
specification and might be used later.
libmenu/desktop-entries.c | 10 ++++++++++
libmenu/desktop-entries.h | 1 +
libmenu/gmenu-tree.c | 11 +++++++++++
libmenu/gmenu-tree.h | 1 +
4 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/libmenu/desktop-entries.c b/libmenu/desktop-entries.c
index 03c0717..eed0e62 100644
--- a/libmenu/desktop-entries.c
+++ b/libmenu/desktop-entries.c
@@ -52,6 +52,7 @@ typedef struct
DesktopEntry base;
char *name;
+ char *generic_name;
char *comment;
char *icon;
@@ -165,6 +166,7 @@ desktop_entry_load_directory (DesktopEntry *entry,
if (entry_directory->name == NULL)
return FALSE;
+ entry_directory->generic_name = g_key_file_get_locale_string (key_file, DESKTOP_ENTRY_GROUP, "GenericName", NULL, NULL);
entry_directory->comment = g_key_file_get_locale_string (key_file, DESKTOP_ENTRY_GROUP, "Comment", NULL, NULL);
entry_directory->icon = g_key_file_get_locale_string (key_file, DESKTOP_ENTRY_GROUP, "Icon", NULL, NULL);
entry_directory->nodisplay = g_key_file_get_boolean (key_file,
@@ -449,6 +451,14 @@ desktop_entry_get_name (DesktopEntry *entry)
}
const char *
+desktop_entry_get_generic_name (DesktopEntry *entry)
+{
+ if (entry->type == DESKTOP_ENTRY_DESKTOP)
+ return g_desktop_app_info_get_generic_name (((DesktopEntryDesktop*)entry)->appinfo);
+ return ((DesktopEntryDirectory*)entry)->generic_name;
+}
+
+const char *
desktop_entry_get_comment (DesktopEntry *entry)
{
if (entry->type == DESKTOP_ENTRY_DESKTOP)
diff --git a/libmenu/desktop-entries.h b/libmenu/desktop-entries.h
index ab4edce..6ca4855 100644
--- a/libmenu/desktop-entries.h
+++ b/libmenu/desktop-entries.h
@@ -44,6 +44,7 @@ DesktopEntryType desktop_entry_get_type (DesktopEntry *entry);
const char *desktop_entry_get_path (DesktopEntry *entry);
const char *desktop_entry_get_basename (DesktopEntry *entry);
const char *desktop_entry_get_name (DesktopEntry *entry);
+const char *desktop_entry_get_generic_name (DesktopEntry *entry);
const char *desktop_entry_get_comment (DesktopEntry *entry);
gboolean desktop_entry_get_hidden (DesktopEntry *entry);
gboolean desktop_entry_get_no_display (DesktopEntry *entry);
diff --git a/libmenu/gmenu-tree.c b/libmenu/gmenu-tree.c
index 84d3bda..673e023 100644
--- a/libmenu/gmenu-tree.c
+++ b/libmenu/gmenu-tree.c
@@ -938,6 +938,17 @@ gmenu_tree_directory_get_name (GMenuTreeDirectory *directory)
}
const char *
+gmenu_tree_directory_get_generic_name (GMenuTreeDirectory *directory)
+{
+ g_return_val_if_fail (directory != NULL, NULL);
+
+ if (!directory->directory_entry)
+ return NULL;
+
+ return desktop_entry_get_generic_name (directory->directory_entry);
+}
+
+const char *
gmenu_tree_directory_get_comment (GMenuTreeDirectory *directory)
{
g_return_val_if_fail (directory != NULL, NULL);
diff --git a/libmenu/gmenu-tree.h b/libmenu/gmenu-tree.h
index 0ba91dd..7fd740b 100644
--- a/libmenu/gmenu-tree.h
+++ b/libmenu/gmenu-tree.h
@@ -99,6 +99,7 @@ void gmenu_tree_item_unref (gpointer item);
GMenuTreeDirectory *gmenu_tree_directory_get_parent (GMenuTreeDirectory *directory);
const char *gmenu_tree_directory_get_name (GMenuTreeDirectory *directory);
+const char *gmenu_tree_directory_get_generic_name (GMenuTreeDirectory *directory);
const char *gmenu_tree_directory_get_comment (GMenuTreeDirectory *directory);
const char *gmenu_tree_directory_get_icon (GMenuTreeDirectory *directory);
const char *gmenu_tree_directory_get_desktop_file_path (GMenuTreeDirectory *directory);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]