summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/reference/ChangeLog4
-rw-r--r--docs/reference/gio/gio-sections.txt1
-rw-r--r--gio/ChangeLog8
-rw-r--r--gio/gdesktopappinfo.c59
-rw-r--r--gio/gdesktopappinfo.h2
-rw-r--r--gio/gio.symbols1
6 files changed, 54 insertions, 21 deletions
diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog
index 2271d6bfc..ab426e21f 100644
--- a/docs/reference/ChangeLog
+++ b/docs/reference/ChangeLog
@@ -1,3 +1,7 @@
+2008-07-02 Matthias Clasen <mclasen@redhat.com>
+
+ * gio/gio-sections.txt: Add g_desktop_app_info_new_from_keyfile
+
2008-07-01 Matthias Clasen <mclasen@redhat.com>
* gio/gio.types: Add missing types. Pointed out by David Zeuthen.
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index 8f68bd0d6..3e07ce9ab 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -1172,6 +1172,7 @@ GUnixVolumeMonitorClass
<TITLE>Desktop file based GAppInfo</TITLE>
GDesktopAppInfo
g_desktop_app_info_new_from_filename
+g_desktop_app_info_new_from_keyfile
g_desktop_app_info_new
g_desktop_app_info_get_is_hidden
g_desktop_app_info_set_desktop_env
diff --git a/gio/ChangeLog b/gio/ChangeLog
index 475f8dd05..126828d7b 100644
--- a/gio/ChangeLog
+++ b/gio/ChangeLog
@@ -1,3 +1,11 @@
+2008-07-02 Matthias Clasen <mclasen@redhat.com>
+
+ Bug 534639 – add g_desktop_app_info_new_from_keyfile
+
+ * gio.symbols:
+ * gdesktopappinfo.[hc]: Add a function to create a
+ GDesktopAppInfo from a GKeyFile. Proposed by Josselin Mouette.
+
2008-07-02 Wouter Bolsterlee <wbolster@svn.gnome.org>
* gappinfo.c: Fix ulink in doc to make gtk-doc happy.
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
index 3ca79f46d..02d97d210 100644
--- a/gio/gdesktopappinfo.c
+++ b/gio/gdesktopappinfo.c
@@ -186,38 +186,27 @@ binary_from_exec (const char *exec)
}
/**
- * g_desktop_app_info_new_from_filename:
- * @filename: a string containing a file name.
+ * g_desktop_app_info_new_from_keyfile:
+ * @key_file: an opened #GKeyFile
*
* Creates a new #GDesktopAppInfo.
*
* Returns: a new #GDesktopAppInfo or %NULL on error.
+ *
+ * Since: 2.18
**/
GDesktopAppInfo *
-g_desktop_app_info_new_from_filename (const char *filename)
+g_desktop_app_info_new_from_keyfile (GKeyFile *key_file)
{
GDesktopAppInfo *info;
- GKeyFile *key_file;
char *start_group;
char *type;
char *try_exec;
- key_file = g_key_file_new ();
-
- if (!g_key_file_load_from_file (key_file,
- filename,
- G_KEY_FILE_NONE,
- NULL))
- {
- g_key_file_free (key_file);
- return NULL;
- }
-
start_group = g_key_file_get_start_group (key_file);
if (start_group == NULL || strcmp (start_group, G_KEY_FILE_DESKTOP_GROUP) != 0)
{
g_free (start_group);
- g_key_file_free (key_file);
return NULL;
}
g_free (start_group);
@@ -229,7 +218,6 @@ g_desktop_app_info_new_from_filename (const char *filename)
if (type == NULL || strcmp (type, G_KEY_FILE_DESKTOP_TYPE_APPLICATION) != 0)
{
g_free (type);
- g_key_file_free (key_file);
return NULL;
}
g_free (type);
@@ -245,14 +233,14 @@ g_desktop_app_info_new_from_filename (const char *filename)
if (t == NULL)
{
g_free (try_exec);
- g_key_file_free (key_file);
return NULL;
}
g_free (t);
}
+ g_free (try_exec);
info = g_object_new (G_TYPE_DESKTOP_APP_INFO, NULL);
- info->filename = g_strdup (filename);
+ 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->comment = g_key_file_get_locale_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_COMMENT, NULL, NULL);
@@ -266,8 +254,6 @@ g_desktop_app_info_new_from_filename (const char *filename)
info->terminal = g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_TERMINAL, NULL) != FALSE;
info->startup_notify = g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY, NULL) != FALSE;
info->hidden = g_key_file_get_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_HIDDEN, NULL) != FALSE;
-
- g_key_file_free (key_file);
info->icon = NULL;
if (info->icon_name)
@@ -291,6 +277,37 @@ g_desktop_app_info_new_from_filename (const char *filename)
}
/**
+ * g_desktop_app_info_new_from_filename:
+ * @filename: a string containing a file name.
+ *
+ * Creates a new #GDesktopAppInfo.
+ *
+ * Returns: a new #GDesktopAppInfo or %NULL on error.
+ **/
+GDesktopAppInfo *
+g_desktop_app_info_new_from_filename (const char *filename)
+{
+ GKeyFile *key_file;
+ GDesktopAppInfo *info = NULL;
+
+ key_file = g_key_file_new ();
+
+ if (g_key_file_load_from_file (key_file,
+ filename,
+ G_KEY_FILE_NONE,
+ NULL))
+ {
+ info = g_desktop_app_info_new_from_keyfile (key_file);
+ if (info)
+ info->filename = g_strdup (filename);
+ }
+
+ g_key_file_free (key_file);
+
+ return info;
+}
+
+/**
* g_desktop_app_info_new:
* @desktop_id: the desktop file id
*
diff --git a/gio/gdesktopappinfo.h b/gio/gdesktopappinfo.h
index ea13a42ac..bbda74ed1 100644
--- a/gio/gdesktopappinfo.h
+++ b/gio/gdesktopappinfo.h
@@ -46,6 +46,8 @@ struct _GDesktopAppInfoClass
GType g_desktop_app_info_get_type (void) G_GNUC_CONST;
GDesktopAppInfo *g_desktop_app_info_new_from_filename (const char *filename);
+GDesktopAppInfo *g_desktop_app_info_new_from_keyfile (GKeyFile *key_file);
+
GDesktopAppInfo *g_desktop_app_info_new (const char *desktop_id);
gboolean g_desktop_app_info_get_is_hidden (GDesktopAppInfo *info);
diff --git a/gio/gio.symbols b/gio/gio.symbols
index 28776c144..6c5738ad0 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -68,6 +68,7 @@ g_app_info_get_default_for_uri_scheme
#if IN_FILE(__G_DESKTOP_APP_INFO_C__)
#ifdef G_OS_UNIX
g_desktop_app_info_new_from_filename
+g_desktop_app_info_new_from_keyfile
g_desktop_app_info_new
g_desktop_app_info_get_type G_GNUC_CONST
g_desktop_app_info_get_is_hidden