[gnome-games] libgames-support: [smclient] Update copy from libegg master
- From: Christian Persch <chpe src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-games] libgames-support: [smclient] Update copy from libegg master
- Date: Thu, 9 Jul 2009 23:10:55 +0000 (UTC)
commit 284478e9b9960b7e64d51a5fff8ddea02b48d616
Author: Christian Persch <chpe gnome org>
Date: Fri Jul 3 13:24:54 2009 +0200
libgames-support: [smclient] Update copy from libegg master
libgames-support/eggdesktopfile.c | 78 +++++++++++++++++++++++++++++--------
libgames-support/eggdesktopfile.h | 5 +-
2 files changed, 64 insertions(+), 19 deletions(-)
---
diff --git a/libgames-support/eggdesktopfile.c b/libgames-support/eggdesktopfile.c
index 4795ebe..6f6b946 100644
--- a/libgames-support/eggdesktopfile.c
+++ b/libgames-support/eggdesktopfile.c
@@ -1274,8 +1274,8 @@ egg_desktop_file_launchv (EggDesktopFile *desktop_file,
out:
if (env)
{
- g_strfreev ((char **)env->pdata);
- g_ptr_array_free (env, FALSE);
+ g_ptr_array_foreach (env, (GFunc)g_free, NULL);
+ g_ptr_array_free (env, TRUE);
}
free_document_list (translated_documents);
@@ -1410,6 +1410,40 @@ egg_desktop_file_error_quark (void)
G_LOCK_DEFINE_STATIC (egg_desktop_file);
static EggDesktopFile *egg_desktop_file;
+static void
+egg_set_desktop_file_internal (const char *desktop_file_path,
+ gboolean set_defaults)
+{
+ GError *error = NULL;
+
+ G_LOCK (egg_desktop_file);
+ if (egg_desktop_file)
+ egg_desktop_file_free (egg_desktop_file);
+
+ egg_desktop_file = egg_desktop_file_new (desktop_file_path, &error);
+ if (error)
+ {
+ g_warning ("Could not load desktop file '%s': %s",
+ desktop_file_path, error->message);
+ g_error_free (error);
+ }
+
+ if (set_defaults && egg_desktop_file != NULL) {
+ /* Set localized application name and default window icon */
+ if (egg_desktop_file->name)
+ g_set_application_name (egg_desktop_file->name);
+ if (egg_desktop_file->icon)
+ {
+ if (g_path_is_absolute (egg_desktop_file->icon))
+ gtk_window_set_default_icon_from_file (egg_desktop_file->icon, NULL);
+ else
+ gtk_window_set_default_icon_name (egg_desktop_file->icon);
+ }
+ }
+
+ G_UNLOCK (egg_desktop_file);
+}
+
/**
* egg_set_desktop_file:
* @desktop_file_path: path to the application's desktop file
@@ -1421,28 +1455,38 @@ static EggDesktopFile *egg_desktop_file;
* gtk_window_set_default_icon_from_file() with the application's
* icon. Other code may use additional information from the desktop
* file.
+ * See egg_set_desktop_file_without_defaults() for a variant of this
+ * function that does not set the application name and default window
+ * icon.
*
* Note that for thread safety reasons, this function can only
- * be called once.
+ * be called once, and is mutually exclusive with calling
+ * egg_set_desktop_file_without_defaults().
**/
void
egg_set_desktop_file (const char *desktop_file_path)
{
- GError *error = NULL;
-
- G_LOCK (egg_desktop_file);
- if (egg_desktop_file)
- egg_desktop_file_free (egg_desktop_file);
-
- egg_desktop_file = egg_desktop_file_new (desktop_file_path, &error);
- if (error)
- {
- g_warning ("Could not load desktop file '%s': %s",
- desktop_file_path, error->message);
- g_error_free (error);
- }
+ egg_set_desktop_file_internal (desktop_file_path, TRUE);
+}
- G_UNLOCK (egg_desktop_file);
+/**
+ * egg_set_desktop_file_without_defaults:
+ * @desktop_file_path: path to the application's desktop file
+ *
+ * Creates an #EggDesktopFile for the application from the data at
+ * @desktop_file_path.
+ * See egg_set_desktop_file() for a variant of this function that
+ * sets the application name and default window icon from the information
+ * in the desktop file.
+ *
+ * Note that for thread safety reasons, this function can only
+ * be called once, and is mutually exclusive with calling
+ * egg_set_desktop_file().
+ **/
+void
+egg_set_desktop_file_without_defaults (const char *desktop_file_path)
+{
+ egg_set_desktop_file_internal (desktop_file_path, FALSE);
}
/**
diff --git a/libgames-support/eggdesktopfile.h b/libgames-support/eggdesktopfile.h
index f8a3d3e..18fe463 100644
--- a/libgames-support/eggdesktopfile.h
+++ b/libgames-support/eggdesktopfile.h
@@ -150,8 +150,9 @@ typedef enum {
} EggDesktopFileError;
/* Global application desktop file */
-void egg_set_desktop_file (const char *desktop_file_path);
-EggDesktopFile *egg_get_desktop_file (void);
+void egg_set_desktop_file (const char *desktop_file_path);
+void egg_set_desktop_file_without_defaults (const char *desktop_file_path);
+EggDesktopFile *egg_get_desktop_file (void);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]