[gnome-menus] [libmenu] Add gmenu_tree_entry_get_display_name() API
- From: Vincent Untz <vuntz src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-menus] [libmenu] Add gmenu_tree_entry_get_display_name() API
- Date: Mon, 7 Sep 2009 17:23:08 +0000 (UTC)
commit e539c64e99a000b3a89a53bb5a6233a6b16ed96a
Author: Vincent Untz <vuntz gnome org>
Date: Mon Sep 7 19:19:41 2009 +0200
[libmenu] Add gmenu_tree_entry_get_display_name() API
This API returns the content of the X-GNOME-FullName key if available,
and fallbacks to Name.
libmenu/desktop-entries.c | 18 +++++++++++++++++-
libmenu/desktop-entries.h | 1 +
libmenu/gmenu-tree.c | 14 ++++++++++++++
libmenu/gmenu-tree.h | 1 +
4 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/libmenu/desktop-entries.c b/libmenu/desktop-entries.c
index 79bd555..28d0106 100644
--- a/libmenu/desktop-entries.c
+++ b/libmenu/desktop-entries.c
@@ -45,6 +45,7 @@ struct DesktopEntry
char *name;
char *generic_name;
+ char *full_name;
char *comment;
char *icon;
char *exec;
@@ -286,6 +287,7 @@ desktop_entry_load (DesktopEntry *entry)
retval->name = GET_LOCALE_STRING ("Name");
retval->generic_name = GET_LOCALE_STRING ("GenericName");
+ retval->full_name = GET_LOCALE_STRING ("X-GNOME-FullName");
retval->comment = GET_LOCALE_STRING ("Comment");
retval->icon = GET_LOCALE_STRING ("Icon");
retval->flags = get_flags_from_key_file (retval, key_file, desktop_entry_group);
@@ -299,10 +301,11 @@ desktop_entry_load (DesktopEntry *entry)
#undef GET_LOCALE_STRING
- menu_verbose ("Desktop entry \"%s\" (%s, %s, %s, %s) flags: NoDisplay=%s, Hidden=%s, ShowInGNOME=%s, TryExecFailed=%s\n",
+ menu_verbose ("Desktop entry \"%s\" (%s, %s, %s, %s, %s) flags: NoDisplay=%s, Hidden=%s, ShowInGNOME=%s, TryExecFailed=%s\n",
retval->basename,
retval->name,
retval->generic_name ? retval->generic_name : "(null)",
+ retval->full_name ? retval->full_name : "(null)",
retval->comment ? retval->comment : "(null)",
retval->icon ? retval->icon : "(null)",
retval->flags & DESKTOP_ENTRY_NO_DISPLAY ? "(true)" : "(false)",
@@ -368,6 +371,9 @@ desktop_entry_reload (DesktopEntry *entry)
g_free (entry->generic_name);
entry->generic_name = NULL;
+ g_free (entry->full_name);
+ entry->full_name = NULL;
+
g_free (entry->comment);
entry->comment = NULL;
@@ -411,6 +417,7 @@ desktop_entry_copy (DesktopEntry *entry)
retval->path = g_strdup (entry->path);
retval->name = g_strdup (entry->name);
retval->generic_name = g_strdup (entry->generic_name);
+ retval->full_name = g_strdup (entry->full_name);
retval->comment = g_strdup (entry->comment);
retval->icon = g_strdup (entry->icon);
retval->exec = g_strdup (entry->exec);
@@ -453,6 +460,9 @@ desktop_entry_unref (DesktopEntry *entry)
g_free (entry->generic_name);
entry->generic_name = NULL;
+ g_free (entry->full_name);
+ entry->full_name = NULL;
+
g_free (entry->comment);
entry->comment = NULL;
@@ -503,6 +513,12 @@ desktop_entry_get_generic_name (DesktopEntry *entry)
}
const char *
+desktop_entry_get_full_name (DesktopEntry *entry)
+{
+ return entry->full_name;
+}
+
+const char *
desktop_entry_get_comment (DesktopEntry *entry)
{
return entry->comment;
diff --git a/libmenu/desktop-entries.h b/libmenu/desktop-entries.h
index 700f283..f3b4b7a 100644
--- a/libmenu/desktop-entries.h
+++ b/libmenu/desktop-entries.h
@@ -46,6 +46,7 @@ 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_full_name (DesktopEntry *entry);
const char *desktop_entry_get_comment (DesktopEntry *entry);
const char *desktop_entry_get_icon (DesktopEntry *entry);
const char *desktop_entry_get_exec (DesktopEntry *entry);
diff --git a/libmenu/gmenu-tree.c b/libmenu/gmenu-tree.c
index dd4c417..6d50927 100644
--- a/libmenu/gmenu-tree.c
+++ b/libmenu/gmenu-tree.c
@@ -1137,6 +1137,20 @@ gmenu_tree_entry_get_generic_name (GMenuTreeEntry *entry)
}
const char *
+gmenu_tree_entry_get_display_name (GMenuTreeEntry *entry)
+{
+ const char *display_name;
+
+ g_return_val_if_fail (entry != NULL, NULL);
+
+ display_name = desktop_entry_get_full_name (entry->desktop_entry);
+ if (!display_name || display_name[0] == '\0')
+ display_name = desktop_entry_get_name (entry->desktop_entry);
+
+ return display_name;
+}
+
+const char *
gmenu_tree_entry_get_comment (GMenuTreeEntry *entry)
{
g_return_val_if_fail (entry != NULL, NULL);
diff --git a/libmenu/gmenu-tree.h b/libmenu/gmenu-tree.h
index ae98ef1..72bb1e4 100644
--- a/libmenu/gmenu-tree.h
+++ b/libmenu/gmenu-tree.h
@@ -112,6 +112,7 @@ char *gmenu_tree_directory_make_path (GMenuTreeDirectory *directory,
const char *gmenu_tree_entry_get_name (GMenuTreeEntry *entry);
const char *gmenu_tree_entry_get_generic_name (GMenuTreeEntry *entry);
+const char *gmenu_tree_entry_get_display_name (GMenuTreeEntry *entry);
const char *gmenu_tree_entry_get_comment (GMenuTreeEntry *entry);
const char *gmenu_tree_entry_get_icon (GMenuTreeEntry *entry);
const char *gmenu_tree_entry_get_exec (GMenuTreeEntry *entry);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]