Commit 3d2dc42b authored by Vincent Untz's avatar Vincent Untz

[panel] Update to latest EggSMClient code, and adapt code

We don't need egg_sm_client_startup() anymore: changing the mode will be
enough now.
parent 21b457ed
......@@ -202,7 +202,8 @@ sm_client_post_parse_func (GOptionContext *context,
* use the same client id. */
g_unsetenv ("DESKTOP_AUTOSTART_ID");
if (EGG_SM_CLIENT_GET_CLASS (client)->startup)
if (global_client_mode != EGG_SM_CLIENT_MODE_DISABLED &&
EGG_SM_CLIENT_GET_CLASS (client)->startup)
EGG_SM_CLIENT_GET_CLASS (client)->startup (client, sm_client_id);
return TRUE;
}
......@@ -265,9 +266,9 @@ egg_sm_client_get_option_group (void)
* Sets the "mode" of #EggSMClient as follows:
*
* %EGG_SM_CLIENT_MODE_DISABLED: Session management is completely
* disabled. The application will not even connect to the session
* manager. (egg_sm_client_get() will still return an #EggSMClient,
* but it will just be a dummy object.)
* disabled, until the mode is changed again. The application will
* not even connect to the session manager. (egg_sm_client_get()
* will still return an #EggSMClient object.)
*
* %EGG_SM_CLIENT_MODE_NO_RESTART: The application will connect to
* the session manager (and thus will receive notification when the
......@@ -277,12 +278,27 @@ egg_sm_client_get_option_group (void)
* %EGG_SM_CLIENT_MODE_NORMAL: The default. #EggSMCLient will
* function normally.
*
* This must be called before the application's main loop begins.
* This must be called before the application's main loop begins and
* before any call to egg_sm_client_get(), unless the mode was set
* earlier to %EGG_SM_CLIENT_MODE_DISABLED and this call enables
* session management. Note that option parsing will call
* egg_sm_client_get().
**/
void
egg_sm_client_set_mode (EggSMClientMode mode)
{
EggSMClientMode old_mode = global_client_mode;
g_return_if_fail (global_client == NULL || global_client_mode == EGG_SM_CLIENT_MODE_DISABLED);
g_return_if_fail (!(global_client != NULL && mode == EGG_SM_CLIENT_MODE_DISABLED));
global_client_mode = mode;
if (global_client != NULL && old_mode == EGG_SM_CLIENT_MODE_DISABLED)
{
if (EGG_SM_CLIENT_GET_CLASS (global_client)->startup)
EGG_SM_CLIENT_GET_CLASS (global_client)->startup (global_client, sm_client_id);
}
}
/**
......@@ -317,8 +333,7 @@ egg_sm_client_get (void)
{
if (!global_client)
{
if (global_client_mode != EGG_SM_CLIENT_MODE_DISABLED &&
!sm_client_disable)
if (!sm_client_disable)
{
#if defined (GDK_WINDOWING_WIN32)
global_client = egg_sm_client_win32_new ();
......@@ -349,38 +364,6 @@ egg_sm_client_get (void)
return global_client;
}
/**
* egg_sm_client_startup:
* @client: the client
*
* Connects to the session manager.
*
* This should only be used if the global #EggSMClientMode was set to
* %EGG_SM_CLIENT_MODE_DISABLED before. This is useful when you need to control
* when your application connects to the session manager (by default, it
* connects to it when the options are parsed).
**/
void
egg_sm_client_startup (EggSMClientMode mode)
{
EggSMClient *client;
g_return_if_fail (global_client_mode == EGG_SM_CLIENT_MODE_DISABLED);
/* we make sure that the current client is a dummy one */
g_return_if_fail (global_client == NULL || G_TYPE_FROM_INSTANCE (global_client) == EGG_TYPE_SM_CLIENT);
if (global_client) {
g_object_unref (global_client);
global_client = NULL;
}
egg_sm_client_set_mode (mode);
client = egg_sm_client_get ();
if (EGG_SM_CLIENT_GET_CLASS (client)->startup)
EGG_SM_CLIENT_GET_CLASS (client)->startup (client, sm_client_id);
}
/**
* egg_sm_client_is_resumed:
* @client: the client
......
......@@ -93,7 +93,6 @@ GOptionGroup *egg_sm_client_get_option_group (void);
void egg_sm_client_set_mode (EggSMClientMode mode);
EggSMClientMode egg_sm_client_get_mode (void);
EggSMClient *egg_sm_client_get (void);
void egg_sm_client_startup (EggSMClientMode mode);
/* Resuming a saved session */
gboolean egg_sm_client_is_resumed (EggSMClient *client);
......
......@@ -67,7 +67,7 @@ panel_session_init (void)
else
mode = EGG_SM_CLIENT_MODE_NORMAL;
egg_sm_client_startup (mode);
egg_sm_client_set_mode (mode);
client = egg_sm_client_get ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment