[glib] Bug 600620 - Add g_app_info_get_display_name()
- From: Ryan Lortie <ryanl src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glib] Bug 600620 - Add g_app_info_get_display_name()
- Date: Thu, 19 Nov 2009 15:47:55 +0000 (UTC)
commit 3257e8ebe470fce6b2eb935589f18d509336a227
Author: Vincent Untz <vuntz gnome org>
Date: Wed Nov 18 16:37:47 2009 -0600
Bug 600620 - Add g_app_info_get_display_name()
This new API can make use of X-GNOME-FullName in .desktop files, to have
the full name of applications.
gio/gappinfo.c | 27 +++++++++++++++++++++++++++
gio/gappinfo.h | 2 ++
gio/gdesktopappinfo.c | 20 ++++++++++++++++++++
3 files changed, 49 insertions(+), 0 deletions(-)
---
diff --git a/gio/gappinfo.c b/gio/gappinfo.c
index 88ff2d1..ecc5c95 100644
--- a/gio/gappinfo.c
+++ b/gio/gappinfo.c
@@ -227,6 +227,33 @@ g_app_info_get_name (GAppInfo *appinfo)
}
/**
+ * g_app_info_get_display_name:
+ * @appinfo: a #GAppInfo.
+ *
+ * Gets the display name of the application. The display name is often more
+ * descriptive to the user than the name itself.
+ *
+ * Returns: the display name of the application for @appinfo, or the name if
+ * no display name is available.
+ *
+ * Since: 2.24
+ **/
+const char *
+g_app_info_get_display_name (GAppInfo *appinfo)
+{
+ GAppInfoIface *iface;
+
+ g_return_val_if_fail (G_IS_APP_INFO (appinfo), NULL);
+
+ iface = G_APP_INFO_GET_IFACE (appinfo);
+
+ if (iface->get_display_name == NULL)
+ return (* iface->get_name) (appinfo);
+
+ return (* iface->get_display_name) (appinfo);
+}
+
+/**
* g_app_info_get_description:
* @appinfo: a #GAppInfo.
*
diff --git a/gio/gappinfo.h b/gio/gappinfo.h
index 8bf228a..b1c713a 100644
--- a/gio/gappinfo.h
+++ b/gio/gappinfo.h
@@ -126,6 +126,7 @@ struct _GAppInfoIface
gboolean (* can_delete) (GAppInfo *appinfo);
gboolean (* do_delete) (GAppInfo *appinfo);
const char * (* get_commandline) (GAppInfo *appinfo);
+ const char * (* get_display_name) (GAppInfo *appinfo);
};
GType g_app_info_get_type (void) G_GNUC_CONST;
@@ -138,6 +139,7 @@ gboolean g_app_info_equal (GAppInfo *appin
GAppInfo *appinfo2);
const char *g_app_info_get_id (GAppInfo *appinfo);
const char *g_app_info_get_name (GAppInfo *appinfo);
+const char *g_app_info_get_display_name (GAppInfo *appinfo);
const char *g_app_info_get_description (GAppInfo *appinfo);
const char *g_app_info_get_executable (GAppInfo *appinfo);
const char *g_app_info_get_commandline (GAppInfo *appinfo);
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
index a8fc4e8..187ce4a 100644
--- a/gio/gdesktopappinfo.c
+++ b/gio/gdesktopappinfo.c
@@ -62,6 +62,7 @@
#define ADDED_ASSOCIATIONS_GROUP "Added Associations"
#define REMOVED_ASSOCIATIONS_GROUP "Removed Associations"
#define MIME_CACHE_GROUP "MIME Cache"
+#define FULL_NAME_KEY "X-GNOME-FullName"
static void g_desktop_app_info_iface_init (GAppInfoIface *iface);
static GList * get_all_desktop_entries_for_mime_type (const char *base_mime_type,
@@ -84,6 +85,7 @@ struct _GDesktopAppInfo
char *name;
/* FIXME: what about GenericName ? */
+ char *fullname;
char *comment;
char *icon_name;
GIcon *icon;
@@ -147,6 +149,7 @@ g_desktop_app_info_finalize (GObject *object)
g_free (info->desktop_id);
g_free (info->filename);
g_free (info->name);
+ g_free (info->fullname);
g_free (info->comment);
g_free (info->icon_name);
if (info->icon)
@@ -247,6 +250,7 @@ g_desktop_app_info_new_from_keyfile (GKeyFile *key_file)
info->filename = NULL;
info->name = g_key_file_get_locale_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_NAME, 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;
info->icon_name = g_key_file_get_locale_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL, NULL);
@@ -414,6 +418,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->fullname = g_strdup (info->fullname);
new_info->comment = g_strdup (info->comment);
new_info->nodisplay = info->nodisplay;
new_info->icon_name = g_strdup (info->icon_name);
@@ -464,6 +469,16 @@ g_desktop_app_info_get_name (GAppInfo *appinfo)
return info->name;
}
+static const char *
+g_desktop_app_info_get_display_name (GAppInfo *appinfo)
+{
+ GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo);
+
+ if (info->fullname == NULL)
+ return g_desktop_app_info_get_name (appinfo);
+ return info->fullname;
+}
+
/**
* g_desktop_app_info_get_is_hidden:
* @info: a #GDesktopAppInfo.
@@ -1482,6 +1497,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->fullname != NULL)
+ g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
+ FULL_NAME_KEY, info->fullname);
+
g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP,
G_KEY_FILE_DESKTOP_KEY_COMMENT, info->comment);
@@ -1643,6 +1662,7 @@ g_desktop_app_info_iface_init (GAppInfoIface *iface)
iface->can_delete = g_desktop_app_info_can_delete;
iface->do_delete = g_desktop_app_info_delete;
iface->get_commandline = g_desktop_app_info_get_commandline;
+ iface->get_display_name = g_desktop_app_info_get_display_name;
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]