[gnome-session] [egg] Update smclient code from libegg
- From: Vincent Untz <vuntz src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-session] [egg] Update smclient code from libegg
- Date: Mon, 29 Jun 2009 20:59:22 +0000 (UTC)
commit fb300d7c90c5de17ca6249d2c806e86299a48b3f
Author: Vincent Untz <vuntz gnome org>
Date: Mon Jun 29 22:58:07 2009 +0200
[egg] Update smclient code from libegg
egg/eggdesktopfile.c | 97 ++++++++++++++++++++++++++++++++---------------
egg/eggdesktopfile.h | 5 +-
egg/eggsmclient-xsmp.c | 31 +++++++++------
egg/eggsmclient.c | 61 +++++++++++++++++-------------
4 files changed, 122 insertions(+), 72 deletions(-)
---
diff --git a/egg/eggdesktopfile.c b/egg/eggdesktopfile.c
index 114149f..af8a98e 100644
--- a/egg/eggdesktopfile.c
+++ b/egg/eggdesktopfile.c
@@ -987,7 +987,7 @@ end_startup_notification (GdkDisplay *display,
NULL);
}
-#define EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH (30 /* seconds */ * 1000)
+#define EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH (30 /* seconds */)
typedef struct {
GdkDisplay *display;
@@ -1017,15 +1017,15 @@ set_startup_notification_timeout (GdkDisplay *display,
sn_data->display = g_object_ref (display);
sn_data->startup_id = g_strdup (startup_id);
- g_timeout_add (EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH,
- startup_notification_timeout, sn_data);
+ g_timeout_add_seconds (EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH,
+ startup_notification_timeout, sn_data);
}
#endif /* GTK 2.12 */
static GPtrArray *
array_putenv (GPtrArray *env, char *variable)
{
- int i, keylen;
+ guint i, keylen;
if (!env)
{
@@ -1072,7 +1072,7 @@ egg_desktop_file_launchv (EggDesktopFile *desktop_file,
GError **error)
{
EggDesktopFileLaunchOption option;
- GSList *translated_documents, *docs;
+ GSList *translated_documents = NULL, *docs = NULL;
char *command, **argv;
int argc, i, screen_num;
gboolean success, current_success;
@@ -1386,6 +1386,8 @@ egg_desktop_file_launch (EggDesktopFile *desktop_file,
free_document_list (documents);
break;
+ case EGG_DESKTOP_FILE_TYPE_UNRECOGNIZED:
+ case EGG_DESKTOP_FILE_TYPE_DIRECTORY:
default:
g_set_error (error, EGG_DESKTOP_FILE_ERROR,
EGG_DESKTOP_FILE_ERROR_NOT_LAUNCHABLE,
@@ -1408,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
@@ -1419,39 +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);
- }
-
- /* 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);
- }
+ 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/egg/eggdesktopfile.h b/egg/eggdesktopfile.h
index f8a3d3e..18fe463 100644
--- a/egg/eggdesktopfile.h
+++ b/egg/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
diff --git a/egg/eggsmclient-xsmp.c b/egg/eggsmclient-xsmp.c
index 86dfdb7..8bebfba 100644
--- a/egg/eggsmclient-xsmp.c
+++ b/egg/eggsmclient-xsmp.c
@@ -795,14 +795,18 @@ save_state (EggSMClientXSMP *xsmp)
if (desktop_file)
{
GKeyFile *merged_file;
+ char *desktop_file_path;
merged_file = g_key_file_new ();
- if (g_key_file_load_from_file (merged_file,
- egg_desktop_file_get_source (desktop_file),
+ desktop_file_path =
+ g_filename_from_uri (egg_desktop_file_get_source (desktop_file),
+ NULL, NULL);
+ if (desktop_file_path &&
+ g_key_file_load_from_file (merged_file, desktop_file_path,
G_KEY_FILE_KEEP_COMMENTS |
G_KEY_FILE_KEEP_TRANSLATIONS, NULL))
{
- int g, k, i;
+ guint g, k, i;
char **groups, **keys, *value, *exec;
groups = g_key_file_get_groups (state_file, NULL);
@@ -841,8 +845,11 @@ save_state (EggSMClientXSMP *xsmp)
EGG_DESKTOP_FILE_KEY_EXEC,
exec);
g_free (exec);
-
}
+ else
+ desktop_file = NULL;
+
+ g_free (desktop_file_path);
}
/* Now write state_file to disk. (We can't use mktemp(), because
@@ -1045,13 +1052,13 @@ generate_command (char **restart_command, const char *client_id,
if (client_id)
{
- g_ptr_array_add (cmd, "--sm-client-id");
+ g_ptr_array_add (cmd, (char *)"--sm-client-id");
g_ptr_array_add (cmd, (char *)client_id);
}
if (state_file)
{
- g_ptr_array_add (cmd, "--sm-client-state-file");
+ g_ptr_array_add (cmd, (char *)"--sm-client-state-file");
g_ptr_array_add (cmd, (char *)state_file);
}
@@ -1071,7 +1078,7 @@ set_properties (EggSMClientXSMP *xsmp, ...)
GPtrArray *props;
SmProp *prop;
va_list ap;
- int i;
+ guint i;
props = g_ptr_array_new ();
@@ -1134,7 +1141,7 @@ array_prop (const char *name, ...)
prop = g_new (SmProp, 1);
prop->name = (char *)name;
- prop->type = SmLISTofARRAY8;
+ prop->type = (char *)SmLISTofARRAY8;
vals = g_array_new (FALSE, FALSE, sizeof (SmPropValue));
@@ -1164,11 +1171,11 @@ ptrarray_prop (const char *name, GPtrArray *values)
SmProp *prop;
SmPropValue pv;
GArray *vals;
- int i;
+ guint i;
prop = g_new (SmProp, 1);
prop->name = (char *)name;
- prop->type = SmLISTofARRAY8;
+ prop->type = (char *)SmLISTofARRAY8;
vals = g_array_new (FALSE, FALSE, sizeof (SmPropValue));
@@ -1198,7 +1205,7 @@ string_prop (const char *name, const char *value)
prop = g_new (SmProp, 1);
prop->name = (char *)name;
- prop->type = SmARRAY8;
+ prop->type = (char *)SmARRAY8;
prop->num_vals = 1;
prop->vals = g_new (SmPropValue, 1);
@@ -1223,7 +1230,7 @@ card8_prop (const char *name, unsigned char value)
prop = g_new (SmProp, 1);
prop->name = (char *)name;
- prop->type = SmCARD8;
+ prop->type = (char *)SmCARD8;
prop->num_vals = 1;
prop->vals = g_new (SmPropValue, 2);
diff --git a/egg/eggsmclient.c b/egg/eggsmclient.c
index efe49c0..efa901d 100644
--- a/egg/eggsmclient.c
+++ b/egg/eggsmclient.c
@@ -38,7 +38,7 @@ enum {
LAST_SIGNAL
};
-static guint signals[LAST_SIGNAL] = { 0 };
+static guint signals[LAST_SIGNAL];
struct _EggSMClientPrivate {
GKeyFile *state_file;
@@ -178,23 +178,7 @@ egg_sm_client_class_init (EggSMClientClass *klass)
static gboolean sm_client_disable = FALSE;
static char *sm_client_state_file = NULL;
static char *sm_client_id = NULL;
-
-static GOptionEntry entries[] = {
- { "sm-client-disable", 0, 0,
- G_OPTION_ARG_NONE, &sm_client_disable,
- N_("Disable connection to session manager"), NULL },
- { "sm-client-state-file", 0, 0,
- G_OPTION_ARG_STRING, &sm_client_state_file,
- N_("Specify file containing saved configuration"), N_("FILE") },
- { "sm-client-id", 0, 0,
- G_OPTION_ARG_STRING, &sm_client_id,
- N_("Specify session management ID"), N_("ID") },
- /* Compatibility options */
- { "sm-disable", 0, G_OPTION_FLAG_HIDDEN,
- G_OPTION_ARG_NONE, &sm_client_disable,
- NULL, NULL },
- { NULL }
-};
+static char *sm_config_prefix = NULL;
static gboolean
sm_client_post_parse_func (GOptionContext *context,
@@ -235,6 +219,29 @@ sm_client_post_parse_func (GOptionContext *context,
GOptionGroup *
egg_sm_client_get_option_group (void)
{
+ const GOptionEntry entries[] = {
+ { "sm-client-disable", 0, 0,
+ G_OPTION_ARG_NONE, &sm_client_disable,
+ N_("Disable connection to session manager"), NULL },
+ { "sm-client-state-file", 0, 0,
+ G_OPTION_ARG_FILENAME, &sm_client_state_file,
+ N_("Specify file containing saved configuration"), N_("FILE") },
+ { "sm-client-id", 0, 0,
+ G_OPTION_ARG_STRING, &sm_client_id,
+ N_("Specify session management ID"), N_("ID") },
+ /* GnomeClient compatibility option */
+ { "sm-disable", 0, G_OPTION_FLAG_HIDDEN,
+ G_OPTION_ARG_NONE, &sm_client_disable,
+ NULL, NULL },
+ /* GnomeClient compatibility option. This is a dummy option that only
+ * exists so that sessions saved by apps with GnomeClient can be restored
+ * later when they've switched to EggSMClient. See bug #575308.
+ */
+ { "sm-config-prefix", 0, G_OPTION_FLAG_HIDDEN,
+ G_OPTION_ARG_STRING, &sm_config_prefix,
+ NULL, NULL },
+ { NULL }
+ };
GOptionGroup *group;
/* Use our own debug handler for the "EggSMClient" domain. */
@@ -242,8 +249,8 @@ egg_sm_client_get_option_group (void)
egg_sm_client_debug_handler, NULL);
group = g_option_group_new ("sm-client",
- _("Session Management Options"),
- _("Show Session Management options"),
+ _("Session management options:"),
+ _("Show session management options"),
NULL, NULL);
g_option_group_add_entries (group, entries);
g_option_group_set_parse_hooks (group, NULL, sm_client_post_parse_func);
@@ -318,16 +325,16 @@ egg_sm_client_get (void)
#elif defined (GDK_WINDOWING_QUARTZ)
global_client = egg_sm_client_osx_new ();
#else
- /* If both D-Bus and XSMP are compiled in, try D-Bus first
- * and fall back to XSMP if D-Bus session management isn't
- * available.
+ /* If both D-Bus and XSMP are compiled in, try XSMP first
+ * (since it supports state saving) and fall back to D-Bus
+ * if XSMP isn't available.
*/
-# ifdef EGG_SM_CLIENT_BACKEND_DBUS
- global_client = egg_sm_client_dbus_new ();
-# endif
# ifdef EGG_SM_CLIENT_BACKEND_XSMP
+ global_client = egg_sm_client_xsmp_new ();
+# endif
+# ifdef EGG_SM_CLIENT_BACKEND_DBUS
if (!global_client)
- global_client = egg_sm_client_xsmp_new ();
+ global_client = egg_sm_client_dbus_new ();
# endif
#endif
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]