diff options
author | Alexander Larsson <alexl@redhat.com> | 2008-10-09 09:37:45 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2008-10-09 09:37:45 +0000 |
commit | 2a691e62f7c99888f68c032492e44a982c2a850f (patch) | |
tree | 65c131e8cb2204cadd191b92c1406748ea3917bc | |
parent | 2f340fc51713b924af8458bb7093cb8e74c26358 (diff) | |
download | nautilus-2a691e62f7c99888f68c032492e44a982c2a850f.tar.gz |
Update EggSMClient from libegg
2008-10-09 Alexander Larsson <alexl@redhat.com>
* cut-n-paste-code/libegg/eggdesktopfile.c:
* cut-n-paste-code/libegg/eggdesktopfile.h:
* cut-n-paste-code/libegg/eggsmclient-xsmp.c:
* cut-n-paste-code/libegg/eggsmclient.c:
Update EggSMClient from libegg
svn path=/trunk/; revision=14710
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | cut-n-paste-code/libegg/eggdesktopfile.c | 45 | ||||
-rw-r--r-- | cut-n-paste-code/libegg/eggdesktopfile.h | 8 | ||||
-rw-r--r-- | cut-n-paste-code/libegg/eggsmclient-xsmp.c | 158 | ||||
-rw-r--r-- | cut-n-paste-code/libegg/eggsmclient.c | 20 |
5 files changed, 128 insertions, 111 deletions
@@ -1,5 +1,13 @@ 2008-10-09 Alexander Larsson <alexl@redhat.com> + * cut-n-paste-code/libegg/eggdesktopfile.c: + * cut-n-paste-code/libegg/eggdesktopfile.h: + * cut-n-paste-code/libegg/eggsmclient-xsmp.c: + * cut-n-paste-code/libegg/eggsmclient.c: + Update EggSMClient from libegg + +2008-10-09 Alexander Larsson <alexl@redhat.com> + * src/nautilus-property-browser.c: (nautilus_property_browser_drag_data_get): Don't use eel_gdk_color_parse anymore. We don't have any colors diff --git a/cut-n-paste-code/libegg/eggdesktopfile.c b/cut-n-paste-code/libegg/eggdesktopfile.c index 4119095d3..114149f43 100644 --- a/cut-n-paste-code/libegg/eggdesktopfile.c +++ b/cut-n-paste-code/libegg/eggdesktopfile.c @@ -125,7 +125,7 @@ egg_desktop_file_new_from_dirs (const char *desktop_file_path, key_file = g_key_file_new (); if (!g_key_file_load_from_dirs (key_file, desktop_file_path, search_dirs, - &full_path, 0, error)) + &full_path, 0, error)) { g_key_file_free (key_file); return NULL; @@ -426,13 +426,9 @@ egg_desktop_file_get_numeric (EggDesktopFile *desktop_file, const char *key, GError **error) { -#if 0 return g_key_file_get_double (desktop_file->key_file, EGG_DESKTOP_FILE_GROUP, key, error); -#else - return 0.0; -#endif } char ** @@ -913,7 +909,7 @@ parse_link (EggDesktopFile *desktop_file, return TRUE; } -#ifdef HAVE_GDK_X11_DISPLAY_BROADCAST_STARTUP_MESSAGE +#if GTK_CHECK_VERSION (2, 12, 0) static char * start_startup_notification (GdkDisplay *display, EggDesktopFile *desktop_file, @@ -1024,9 +1020,7 @@ set_startup_notification_timeout (GdkDisplay *display, g_timeout_add (EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH, startup_notification_timeout, sn_data); } -#endif /* HAVE_GDK_X11_DISPLAY_BROADCAST_STARTUP_MESSAGE */ - -extern char **environ; +#endif /* GTK 2.12 */ static GPtrArray * array_putenv (GPtrArray *env, char *variable) @@ -1035,10 +1029,20 @@ array_putenv (GPtrArray *env, char *variable) if (!env) { + char **envp; + env = g_ptr_array_new (); - for (i = 0; environ[i]; i++) - g_ptr_array_add (env, g_strdup (environ[i])); + envp = g_listenv (); + for (i = 0; envp[i]; i++) + { + const char *value; + + value = g_getenv (envp[i]); + g_ptr_array_add (env, g_strdup_printf ("%s=%s", envp[i], + value ? value : "")); + } + g_strfreev (envp); } keylen = strcspn (variable, "="); @@ -1068,7 +1072,7 @@ egg_desktop_file_launchv (EggDesktopFile *desktop_file, GError **error) { EggDesktopFileLaunchOption option; - GSList *translated_documents = NULL, *docs; + GSList *translated_documents, *docs; char *command, **argv; int argc, i, screen_num; gboolean success, current_success; @@ -1203,7 +1207,7 @@ egg_desktop_file_launchv (EggDesktopFile *desktop_file, } g_free (command); -#ifdef HAVE_GDK_X11_DISPLAY_BROADCAST_STARTUP_MESSAGE +#if GTK_CHECK_VERSION (2, 12, 0) startup_id = start_startup_notification (display, desktop_file, argv[0], screen_num, workspace, launch_time); @@ -1216,13 +1220,10 @@ egg_desktop_file_launchv (EggDesktopFile *desktop_file, } #else startup_id = NULL; -#endif /* HAVE_GDK_X11_DISPLAY_BROADCAST_STARTUP_MESSAGE */ +#endif /* GTK 2.12 */ if (env != NULL) - { - /* Add NULL item in the end of array */ - g_ptr_array_add (env, NULL); - } + g_ptr_array_add (env, NULL); current_success = g_spawn_async_with_pipes (directory, @@ -1237,7 +1238,7 @@ egg_desktop_file_launchv (EggDesktopFile *desktop_file, if (startup_id) { -#ifdef HAVE_GDK_X11_DISPLAY_BROADCAST_STARTUP_MESSAGE +#if GTK_CHECK_VERSION (2, 12, 0) if (current_success) { set_startup_notification_timeout (display, startup_id); @@ -1248,7 +1249,7 @@ egg_desktop_file_launchv (EggDesktopFile *desktop_file, g_free (startup_id); } else -#endif /* HAVE_GDK_X11_DISPLAY_BROADCAST_STARTUP_MESSAGE */ +#endif /* GTK 2.12 */ g_free (startup_id); } else if (ret_startup_id) @@ -1273,8 +1274,8 @@ egg_desktop_file_launchv (EggDesktopFile *desktop_file, out: if (env) { - g_ptr_array_foreach (env, (GFunc)g_free, NULL); - g_ptr_array_free (env, TRUE); + g_strfreev ((char **)env->pdata); + g_ptr_array_free (env, FALSE); } free_document_list (translated_documents); diff --git a/cut-n-paste-code/libegg/eggdesktopfile.h b/cut-n-paste-code/libegg/eggdesktopfile.h index 1e47ba064..f8a3d3e03 100644 --- a/cut-n-paste-code/libegg/eggdesktopfile.h +++ b/cut-n-paste-code/libegg/eggdesktopfile.h @@ -48,12 +48,12 @@ EggDesktopFile *egg_desktop_file_new_from_key_file (GKeyFile *key_file, void egg_desktop_file_free (EggDesktopFile *desktop_file); -const char *egg_desktop_file_get_source (EggDesktopFile *desktop_file) G_GNUC_PURE; +const char *egg_desktop_file_get_source (EggDesktopFile *desktop_file); -EggDesktopFileType egg_desktop_file_get_desktop_file_type (EggDesktopFile *desktop_file) G_GNUC_PURE; +EggDesktopFileType egg_desktop_file_get_desktop_file_type (EggDesktopFile *desktop_file); -const char *egg_desktop_file_get_name (EggDesktopFile *desktop_file) G_GNUC_PURE; -const char *egg_desktop_file_get_icon (EggDesktopFile *desktop_file) G_GNUC_PURE; +const char *egg_desktop_file_get_name (EggDesktopFile *desktop_file); +const char *egg_desktop_file_get_icon (EggDesktopFile *desktop_file); gboolean egg_desktop_file_can_launch (EggDesktopFile *desktop_file, const char *desktop_environment); diff --git a/cut-n-paste-code/libegg/eggsmclient-xsmp.c b/cut-n-paste-code/libegg/eggsmclient-xsmp.c index b52fd2bad..86dfdb74f 100644 --- a/cut-n-paste-code/libegg/eggsmclient-xsmp.c +++ b/cut-n-paste-code/libegg/eggsmclient-xsmp.c @@ -56,7 +56,6 @@ typedef struct _EggSMClientXSMPClass EggSMClientXSMPClass; */ typedef enum { - XSMP_STATE_START, XSMP_STATE_IDLE, XSMP_STATE_SAVE_YOURSELF, XSMP_STATE_INTERACT_REQUEST, @@ -67,7 +66,6 @@ typedef enum } EggSMClientXSMPState; static const char *state_names[] = { - "start", "idle", "save-yourself", "interact-request", @@ -101,6 +99,7 @@ struct _EggSMClientXSMP guint shutting_down : 1; /* Todo list */ + guint waiting_to_set_initial_properties : 1; guint waiting_to_emit_quit : 1; guint waiting_to_emit_quit_cancelled : 1; guint waiting_to_save_myself : 1; @@ -200,72 +199,19 @@ egg_sm_client_xsmp_new (void) } static gboolean -sm_client_xsmp_connect (gpointer user_data) +sm_client_xsmp_set_initial_properties (gpointer user_data) { EggSMClientXSMP *xsmp = user_data; - SmcCallbacks callbacks; - char *client_id; - char error_string_ret[256]; - char pid_str[64]; EggDesktopFile *desktop_file; GPtrArray *clone, *restart; + char pid_str[64]; - g_source_remove (xsmp->idle); - xsmp->idle = 0; - - ice_init (); - SmcSetErrorHandler (smc_error_handler); - - callbacks.save_yourself.callback = xsmp_save_yourself; - callbacks.die.callback = xsmp_die; - callbacks.save_complete.callback = xsmp_save_complete; - callbacks.shutdown_cancelled.callback = xsmp_shutdown_cancelled; - - callbacks.save_yourself.client_data = xsmp; - callbacks.die.client_data = xsmp; - callbacks.save_complete.client_data = xsmp; - callbacks.shutdown_cancelled.client_data = xsmp; - - client_id = NULL; - error_string_ret[0] = '\0'; - xsmp->connection = - SmcOpenConnection (NULL, xsmp, SmProtoMajor, SmProtoMinor, - SmcSaveYourselfProcMask | SmcDieProcMask | - SmcSaveCompleteProcMask | - SmcShutdownCancelledProcMask, - &callbacks, - xsmp->client_id, &client_id, - sizeof (error_string_ret), error_string_ret); - - if (!xsmp->connection) - { - g_warning ("Failed to connect to the session manager: %s\n", - error_string_ret[0] ? - error_string_ret : "no error message given"); - xsmp->state = XSMP_STATE_CONNECTION_CLOSED; - return FALSE; - } - - /* We expect a pointless initial SaveYourself if either (a) we - * didn't have an initial client ID, or (b) we DID have an initial - * client ID, but the server rejected it and gave us a new one. - */ - if (!xsmp->client_id || - (client_id && strcmp (xsmp->client_id, client_id) != 0)) - xsmp->expecting_initial_save_yourself = TRUE; - - if (client_id) + if (xsmp->idle) { - g_free (xsmp->client_id); - xsmp->client_id = g_strdup (client_id); - free (client_id); - - gdk_threads_enter (); - gdk_set_sm_client_id (xsmp->client_id); - gdk_threads_leave (); - - g_debug ("Got client ID \"%s\"", xsmp->client_id); + g_source_remove (xsmp->idle); + xsmp->idle = 0; } + xsmp->waiting_to_set_initial_properties = FALSE; if (egg_sm_client_get_mode () == EGG_SM_CLIENT_MODE_NO_RESTART) xsmp->restart_style = SmRestartNever; @@ -300,7 +246,7 @@ sm_client_xsmp_connect (gpointer user_data) err->message); g_error_free (err); } - g_free (cmdline); + g_free (cmdline); } } @@ -335,7 +281,7 @@ sm_client_xsmp_connect (gpointer user_data) NULL); } - xsmp->state = XSMP_STATE_IDLE; + update_pending_events (xsmp); return FALSE; } @@ -367,19 +313,76 @@ sm_client_xsmp_startup (EggSMClient *client, const char *client_id) { EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client; + SmcCallbacks callbacks; + char *ret_client_id; + char error_string_ret[256]; - xsmp->state = XSMP_STATE_START; - if (xsmp->client_id) - g_free (xsmp->client_id); xsmp->client_id = g_strdup (client_id); - /* Don't connect to the session manager until we reach the main - * loop, since the session manager may assume we're fully up and - * running once we connect. (This also gives the application a - * chance to call egg_set_desktop_file() before we set the initial - * properties.) + ice_init (); + SmcSetErrorHandler (smc_error_handler); + + callbacks.save_yourself.callback = xsmp_save_yourself; + callbacks.die.callback = xsmp_die; + callbacks.save_complete.callback = xsmp_save_complete; + callbacks.shutdown_cancelled.callback = xsmp_shutdown_cancelled; + + callbacks.save_yourself.client_data = xsmp; + callbacks.die.client_data = xsmp; + callbacks.save_complete.client_data = xsmp; + callbacks.shutdown_cancelled.client_data = xsmp; + + client_id = NULL; + error_string_ret[0] = '\0'; + xsmp->connection = + SmcOpenConnection (NULL, xsmp, SmProtoMajor, SmProtoMinor, + SmcSaveYourselfProcMask | SmcDieProcMask | + SmcSaveCompleteProcMask | + SmcShutdownCancelledProcMask, + &callbacks, + xsmp->client_id, &ret_client_id, + sizeof (error_string_ret), error_string_ret); + + if (!xsmp->connection) + { + g_warning ("Failed to connect to the session manager: %s\n", + error_string_ret[0] ? + error_string_ret : "no error message given"); + xsmp->state = XSMP_STATE_CONNECTION_CLOSED; + return; + } + + /* We expect a pointless initial SaveYourself if either (a) we + * didn't have an initial client ID, or (b) we DID have an initial + * client ID, but the server rejected it and gave us a new one. + */ + if (!xsmp->client_id || + (ret_client_id && strcmp (xsmp->client_id, ret_client_id) != 0)) + xsmp->expecting_initial_save_yourself = TRUE; + + if (ret_client_id) + { + g_free (xsmp->client_id); + xsmp->client_id = g_strdup (ret_client_id); + free (ret_client_id); + + gdk_threads_enter (); + gdk_set_sm_client_id (xsmp->client_id); + gdk_threads_leave (); + + g_debug ("Got client ID \"%s\"", xsmp->client_id); + } + + xsmp->state = XSMP_STATE_IDLE; + + /* Do not set the initial properties until we reach the main loop, + * so that the application has a chance to call + * egg_set_desktop_file(). (This may also help the session manager + * have a better idea of when the application is fully up and + * running.) */ - xsmp->idle = g_idle_add (sm_client_xsmp_connect, client); + xsmp->waiting_to_set_initial_properties = TRUE; + xsmp->idle = g_idle_add (sm_client_xsmp_set_initial_properties, client); } static void @@ -469,11 +472,6 @@ sm_client_xsmp_end_session (EggSMClient *client, switch (xsmp->state) { - case XSMP_STATE_START: - /* Force the connection to complete (or fail) now. */ - sm_client_xsmp_connect (xsmp); - break; - case XSMP_STATE_CONNECTION_CLOSED: return FALSE; @@ -494,6 +492,9 @@ sm_client_xsmp_end_session (EggSMClient *client, return TRUE; case XSMP_STATE_IDLE: + if (xsmp->waiting_to_set_initial_properties) + sm_client_xsmp_set_initial_properties (xsmp); + if (!xsmp->expecting_initial_save_yourself) break; /* else fall through */ @@ -634,6 +635,9 @@ xsmp_save_yourself (SmcConn smc_conn, return; } + if (xsmp->waiting_to_set_initial_properties) + sm_client_xsmp_set_initial_properties (xsmp); + /* If this is the initial SaveYourself, ignore it; we've already set * properties and there's no reason to actually save state too. */ diff --git a/cut-n-paste-code/libegg/eggsmclient.c b/cut-n-paste-code/libegg/eggsmclient.c index 1c88dd2cc..b24968dad 100644 --- a/cut-n-paste-code/libegg/eggsmclient.c +++ b/cut-n-paste-code/libegg/eggsmclient.c @@ -189,6 +189,10 @@ static GOptionEntry entries[] = { { "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 } }; @@ -263,7 +267,7 @@ egg_sm_client_get_option_group (void) * user is logging out, etc), but will request to not be * automatically restarted with saved state in future sessions. * - * %EGG_SM_CLIENT_MODE_NORMAL: The default. #EggSMClient will + * %EGG_SM_CLIENT_MODE_NORMAL: The default. #EggSMCLient will * function normally. * * This must be called before the application's main loop begins. @@ -314,16 +318,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 } |