summaryrefslogtreecommitdiff
path: root/src/eggsmclient.c
diff options
context:
space:
mode:
authorPerberos <[email protected]>2011-11-06 19:14:03 -0300
committerPerberos <[email protected]>2011-11-06 19:14:03 -0300
commitf2a13175e5a3a38d1340d2fff5e03f8c2e0d8f8e (patch)
tree5bc248a29ae93e5534428e6908a94d50d419ceb9 /src/eggsmclient.c
parentdef492f92d29f294c62d94ef562dd6271bd9b84b (diff)
downloadmate-terminal-f2a13175e5a3a38d1340d2fff5e03f8c2e0d8f8e.tar.bz2
mate-terminal-f2a13175e5a3a38d1340d2fff5e03f8c2e0d8f8e.tar.xz
aplicando formato allman
Diffstat (limited to 'src/eggsmclient.c')
-rw-r--r--src/eggsmclient.c631
1 files changed, 322 insertions, 309 deletions
diff --git a/src/eggsmclient.c b/src/eggsmclient.c
index 31906b6..a347eae 100644
--- a/src/eggsmclient.c
+++ b/src/eggsmclient.c
@@ -26,22 +26,24 @@
#include "eggsmclient-private.h"
static void egg_sm_client_debug_handler (const char *log_domain,
- GLogLevelFlags log_level,
- const char *message,
- gpointer user_data);
-
-enum {
- SAVE_STATE,
- QUIT_REQUESTED,
- QUIT_CANCELLED,
- QUIT,
- LAST_SIGNAL
+ GLogLevelFlags log_level,
+ const char *message,
+ gpointer user_data);
+
+enum
+{
+ SAVE_STATE,
+ QUIT_REQUESTED,
+ QUIT_CANCELLED,
+ QUIT,
+ LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
-struct _EggSMClientPrivate {
- GKeyFile *state_file;
+struct _EggSMClientPrivate
+{
+ GKeyFile *state_file;
};
#define EGG_SM_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EGG_TYPE_SM_CLIENT, EggSMClientPrivate))
@@ -54,125 +56,125 @@ static EggSMClientMode global_client_mode = EGG_SM_CLIENT_MODE_NORMAL;
static void
egg_sm_client_init (EggSMClient *client)
{
- ;
+ ;
}
static void
egg_sm_client_class_init (EggSMClientClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (EggSMClientPrivate));
-
- /**
- * EggSMClient::save_state:
- * @client: the client
- * @state_file: a #GKeyFile to save state information into
- *
- * Emitted when the session manager has requested that the
- * application save information about its current state. The
- * application should save its state into @state_file, and then the
- * session manager may then restart the application in a future
- * session and tell it to initialize itself from that state.
- *
- * You should not save any data into @state_file's "start group"
- * (ie, the %NULL group). Instead, applications should save their
- * data into groups with names that start with the application name,
- * and libraries that connect to this signal should save their data
- * into groups with names that start with the library name.
- *
- * Alternatively, rather than (or in addition to) using @state_file,
- * the application can save its state by calling
- * egg_sm_client_set_restart_command() during the processing of this
- * signal (eg, to include a list of files to open).
- **/
- signals[SAVE_STATE] =
- g_signal_new ("save_state",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggSMClientClass, save_state),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE,
- 1, G_TYPE_POINTER);
-
- /**
- * EggSMClient::quit_requested:
- * @client: the client
- *
- * Emitted when the session manager requests that the application
- * exit (generally because the user is logging out). The application
- * should decide whether or not it is willing to quit (perhaps after
- * asking the user what to do with documents that have unsaved
- * changes) and then call egg_sm_client_will_quit(), passing %TRUE
- * or %FALSE to give its answer to the session manager. (It does not
- * need to give an answer before returning from the signal handler;
- * it can interact with the user asynchronously and then give its
- * answer later on.) If the application does not connect to this
- * signal, then #EggSMClient will automatically return %TRUE on its
- * behalf.
- *
- * The application should not save its session state as part of
- * handling this signal; if the user has requested that the session
- * be saved when logging out, then ::save_state will be emitted
- * separately.
- *
- * If the application agrees to quit, it should then wait for either
- * the ::quit_cancelled or ::quit signals to be emitted.
- **/
- signals[QUIT_REQUESTED] =
- g_signal_new ("quit_requested",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggSMClientClass, quit_requested),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- /**
- * EggSMClient::quit_cancelled:
- * @client: the client
- *
- * Emitted when the session manager decides to cancel a logout after
- * the application has already agreed to quit. After receiving this
- * signal, the application can go back to what it was doing before
- * receiving the ::quit_requested signal.
- **/
- signals[QUIT_CANCELLED] =
- g_signal_new ("quit_cancelled",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggSMClientClass, quit_cancelled),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- /**
- * EggSMClient::quit:
- * @client: the client
- *
- * Emitted when the session manager wants the application to quit
- * (generally because the user is logging out). The application
- * should exit as soon as possible after receiving this signal; if
- * it does not, the session manager may choose to forcibly kill it.
- *
- * Normally a GUI application would only be sent a ::quit if it
- * agreed to quit in response to a ::quit_requested signal. However,
- * this is not guaranteed; in some situations the session manager
- * may decide to end the session without giving applications a
- * chance to object.
- **/
- signals[QUIT] =
- g_signal_new ("quit",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggSMClientClass, quit),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (EggSMClientPrivate));
+
+ /**
+ * EggSMClient::save_state:
+ * @client: the client
+ * @state_file: a #GKeyFile to save state information into
+ *
+ * Emitted when the session manager has requested that the
+ * application save information about its current state. The
+ * application should save its state into @state_file, and then the
+ * session manager may then restart the application in a future
+ * session and tell it to initialize itself from that state.
+ *
+ * You should not save any data into @state_file's "start group"
+ * (ie, the %NULL group). Instead, applications should save their
+ * data into groups with names that start with the application name,
+ * and libraries that connect to this signal should save their data
+ * into groups with names that start with the library name.
+ *
+ * Alternatively, rather than (or in addition to) using @state_file,
+ * the application can save its state by calling
+ * egg_sm_client_set_restart_command() during the processing of this
+ * signal (eg, to include a list of files to open).
+ **/
+ signals[SAVE_STATE] =
+ g_signal_new ("save_state",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EggSMClientClass, save_state),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1, G_TYPE_POINTER);
+
+ /**
+ * EggSMClient::quit_requested:
+ * @client: the client
+ *
+ * Emitted when the session manager requests that the application
+ * exit (generally because the user is logging out). The application
+ * should decide whether or not it is willing to quit (perhaps after
+ * asking the user what to do with documents that have unsaved
+ * changes) and then call egg_sm_client_will_quit(), passing %TRUE
+ * or %FALSE to give its answer to the session manager. (It does not
+ * need to give an answer before returning from the signal handler;
+ * it can interact with the user asynchronously and then give its
+ * answer later on.) If the application does not connect to this
+ * signal, then #EggSMClient will automatically return %TRUE on its
+ * behalf.
+ *
+ * The application should not save its session state as part of
+ * handling this signal; if the user has requested that the session
+ * be saved when logging out, then ::save_state will be emitted
+ * separately.
+ *
+ * If the application agrees to quit, it should then wait for either
+ * the ::quit_cancelled or ::quit signals to be emitted.
+ **/
+ signals[QUIT_REQUESTED] =
+ g_signal_new ("quit_requested",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EggSMClientClass, quit_requested),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
+ /**
+ * EggSMClient::quit_cancelled:
+ * @client: the client
+ *
+ * Emitted when the session manager decides to cancel a logout after
+ * the application has already agreed to quit. After receiving this
+ * signal, the application can go back to what it was doing before
+ * receiving the ::quit_requested signal.
+ **/
+ signals[QUIT_CANCELLED] =
+ g_signal_new ("quit_cancelled",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EggSMClientClass, quit_cancelled),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
+ /**
+ * EggSMClient::quit:
+ * @client: the client
+ *
+ * Emitted when the session manager wants the application to quit
+ * (generally because the user is logging out). The application
+ * should exit as soon as possible after receiving this signal; if
+ * it does not, the session manager may choose to forcibly kill it.
+ *
+ * Normally a GUI application would only be sent a ::quit if it
+ * agreed to quit in response to a ::quit_requested signal. However,
+ * this is not guaranteed; in some situations the session manager
+ * may decide to end the session without giving applications a
+ * chance to object.
+ **/
+ signals[QUIT] =
+ g_signal_new ("quit",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EggSMClientClass, quit),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
static gboolean sm_client_disable = FALSE;
@@ -182,29 +184,29 @@ static char *sm_config_prefix = NULL;
static gboolean
sm_client_post_parse_func (GOptionContext *context,
- GOptionGroup *group,
- gpointer data,
- GError **error)
+ GOptionGroup *group,
+ gpointer data,
+ GError **error)
{
- EggSMClient *client = egg_sm_client_get ();
+ EggSMClient *client = egg_sm_client_get ();
- if (sm_client_id == NULL)
- {
- const gchar *desktop_autostart_id;
+ if (sm_client_id == NULL)
+ {
+ const gchar *desktop_autostart_id;
- desktop_autostart_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+ desktop_autostart_id = g_getenv ("DESKTOP_AUTOSTART_ID");
- if (desktop_autostart_id != NULL)
- sm_client_id = g_strdup (desktop_autostart_id);
- }
+ if (desktop_autostart_id != NULL)
+ sm_client_id = g_strdup (desktop_autostart_id);
+ }
- /* Unset DESKTOP_AUTOSTART_ID in order to avoid child processes to
- * use the same client id. */
- g_unsetenv ("DESKTOP_AUTOSTART_ID");
+ /* Unset DESKTOP_AUTOSTART_ID in order to avoid child processes to
+ * use the same client id. */
+ g_unsetenv ("DESKTOP_AUTOSTART_ID");
- if (EGG_SM_CLIENT_GET_CLASS (client)->startup)
- EGG_SM_CLIENT_GET_CLASS (client)->startup (client, sm_client_id);
- return TRUE;
+ if (EGG_SM_CLIENT_GET_CLASS (client)->startup)
+ EGG_SM_CLIENT_GET_CLASS (client)->startup (client, sm_client_id);
+ return TRUE;
}
/**
@@ -219,43 +221,54 @@ 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") },
- /* MateClient compatibility option */
- { "sm-disable", 0, G_OPTION_FLAG_HIDDEN,
- G_OPTION_ARG_NONE, &sm_client_disable,
- NULL, NULL },
- /* MateClient compatibility option. This is a dummy option that only
- * exists so that sessions saved by apps with MateClient 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. */
- g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
- egg_sm_client_debug_handler, NULL);
-
- group = g_option_group_new ("sm-client",
- _("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);
-
- return group;
+ 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")
+ },
+ /* MateClient compatibility option */
+ {
+ "sm-disable", 0, G_OPTION_FLAG_HIDDEN,
+ G_OPTION_ARG_NONE, &sm_client_disable,
+ NULL, NULL
+ },
+ /* MateClient compatibility option. This is a dummy option that only
+ * exists so that sessions saved by apps with MateClient 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. */
+ g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
+ egg_sm_client_debug_handler, NULL);
+
+ group = g_option_group_new ("sm-client",
+ _("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);
+
+ return group;
}
/**
@@ -282,7 +295,7 @@ egg_sm_client_get_option_group (void)
void
egg_sm_client_set_mode (EggSMClientMode mode)
{
- global_client_mode = mode;
+ global_client_mode = mode;
}
/**
@@ -296,7 +309,7 @@ egg_sm_client_set_mode (EggSMClientMode mode)
EggSMClientMode
egg_sm_client_get_mode (void)
{
- return global_client_mode;
+ return global_client_mode;
}
/**
@@ -315,38 +328,38 @@ egg_sm_client_get_mode (void)
EggSMClient *
egg_sm_client_get (void)
{
- if (!global_client)
- {
- if (global_client_mode != EGG_SM_CLIENT_MODE_DISABLED &&
- !sm_client_disable)
+ if (!global_client)
{
+ if (global_client_mode != EGG_SM_CLIENT_MODE_DISABLED &&
+ !sm_client_disable)
+ {
#if defined (GDK_WINDOWING_WIN32)
- global_client = egg_sm_client_win32_new ();
+ global_client = egg_sm_client_win32_new ();
#elif defined (GDK_WINDOWING_QUARTZ)
- global_client = egg_sm_client_osx_new ();
+ global_client = egg_sm_client_osx_new ();
#else
- /* 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.
- */
+ /* 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_XSMP
- global_client = egg_sm_client_xsmp_new ();
+ global_client = egg_sm_client_xsmp_new ();
# endif
# ifdef EGG_SM_CLIENT_BACKEND_DBUS
- if (!global_client)
- global_client = egg_sm_client_dbus_new ();
+ if (!global_client)
+ global_client = egg_sm_client_dbus_new ();
# endif
#endif
- }
+ }
- /* Fallback: create a dummy client, so that callers don't have
- * to worry about a %NULL return value.
- */
- if (!global_client)
- global_client = g_object_new (EGG_TYPE_SM_CLIENT, NULL);
- }
+ /* Fallback: create a dummy client, so that callers don't have
+ * to worry about a %NULL return value.
+ */
+ if (!global_client)
+ global_client = g_object_new (EGG_TYPE_SM_CLIENT, NULL);
+ }
- return global_client;
+ return global_client;
}
/**
@@ -363,9 +376,9 @@ egg_sm_client_get (void)
gboolean
egg_sm_client_is_resumed (EggSMClient *client)
{
- g_return_val_if_fail (client == global_client, FALSE);
+ g_return_val_if_fail (client == global_client, FALSE);
- return sm_client_state_file != NULL;
+ return sm_client_state_file != NULL;
}
/**
@@ -390,34 +403,34 @@ egg_sm_client_is_resumed (EggSMClient *client)
GKeyFile *
egg_sm_client_get_state_file (EggSMClient *client)
{
- EggSMClientPrivate *priv = EGG_SM_CLIENT_GET_PRIVATE (client);
- char *state_file_path;
- GError *err = NULL;
-
- g_return_val_if_fail (client == global_client, NULL);
-
- if (!sm_client_state_file)
- return NULL;
- if (priv->state_file)
- return priv->state_file;
-
- if (!strncmp (sm_client_state_file, "file://", 7))
- state_file_path = g_filename_from_uri (sm_client_state_file, NULL, NULL);
- else
- state_file_path = g_strdup (sm_client_state_file);
-
- priv->state_file = g_key_file_new ();
- if (!g_key_file_load_from_file (priv->state_file, state_file_path, 0, &err))
- {
- g_warning ("Could not load SM state file '%s': %s",
- sm_client_state_file, err->message);
- g_clear_error (&err);
- g_key_file_free (priv->state_file);
- priv->state_file = NULL;
- }
-
- g_free (state_file_path);
- return priv->state_file;
+ EggSMClientPrivate *priv = EGG_SM_CLIENT_GET_PRIVATE (client);
+ char *state_file_path;
+ GError *err = NULL;
+
+ g_return_val_if_fail (client == global_client, NULL);
+
+ if (!sm_client_state_file)
+ return NULL;
+ if (priv->state_file)
+ return priv->state_file;
+
+ if (!strncmp (sm_client_state_file, "file://", 7))
+ state_file_path = g_filename_from_uri (sm_client_state_file, NULL, NULL);
+ else
+ state_file_path = g_strdup (sm_client_state_file);
+
+ priv->state_file = g_key_file_new ();
+ if (!g_key_file_load_from_file (priv->state_file, state_file_path, 0, &err))
+ {
+ g_warning ("Could not load SM state file '%s': %s",
+ sm_client_state_file, err->message);
+ g_clear_error (&err);
+ g_key_file_free (priv->state_file);
+ priv->state_file = NULL;
+ }
+
+ g_free (state_file_path);
+ return priv->state_file;
}
/**
@@ -435,13 +448,13 @@ egg_sm_client_get_state_file (EggSMClient *client)
**/
void
egg_sm_client_set_restart_command (EggSMClient *client,
- int argc,
- const char **argv)
+ int argc,
+ const char **argv)
{
- g_return_if_fail (EGG_IS_SM_CLIENT (client));
+ g_return_if_fail (EGG_IS_SM_CLIENT (client));
- if (EGG_SM_CLIENT_GET_CLASS (client)->set_restart_command)
- EGG_SM_CLIENT_GET_CLASS (client)->set_restart_command (client, argc, argv);
+ if (EGG_SM_CLIENT_GET_CLASS (client)->set_restart_command)
+ EGG_SM_CLIENT_GET_CLASS (client)->set_restart_command (client, argc, argv);
}
/**
@@ -451,18 +464,18 @@ egg_sm_client_set_restart_command (EggSMClient *client,
* @argv: argument vector
*
* Sets the command used to discard a custom state file if using
- * egg_sm_client_set_restart_command(), which must be called before
+ * egg_sm_client_set_restart_command(), which must be called before
* using this function.
**/
void
egg_sm_client_set_discard_command (EggSMClient *client,
- int argc,
- const char **argv)
+ int argc,
+ const char **argv)
{
- g_return_if_fail (EGG_IS_SM_CLIENT (client));
+ g_return_if_fail (EGG_IS_SM_CLIENT (client));
- if (EGG_SM_CLIENT_GET_CLASS (client)->set_discard_command)
- EGG_SM_CLIENT_GET_CLASS (client)->set_discard_command (client, argc, argv);
+ if (EGG_SM_CLIENT_GET_CLASS (client)->set_discard_command)
+ EGG_SM_CLIENT_GET_CLASS (client)->set_discard_command (client, argc, argv);
}
/**
@@ -485,12 +498,12 @@ egg_sm_client_set_discard_command (EggSMClient *client,
**/
void
egg_sm_client_will_quit (EggSMClient *client,
- gboolean will_quit)
+ gboolean will_quit)
{
- g_return_if_fail (EGG_IS_SM_CLIENT (client));
+ g_return_if_fail (EGG_IS_SM_CLIENT (client));
- if (EGG_SM_CLIENT_GET_CLASS (client)->will_quit)
- EGG_SM_CLIENT_GET_CLASS (client)->will_quit (client, will_quit);
+ if (EGG_SM_CLIENT_GET_CLASS (client)->will_quit)
+ EGG_SM_CLIENT_GET_CLASS (client)->will_quit (client, will_quit);
}
/**
@@ -511,19 +524,19 @@ egg_sm_client_will_quit (EggSMClient *client,
**/
gboolean
egg_sm_client_end_session (EggSMClientEndStyle style,
- gboolean request_confirmation)
+ gboolean request_confirmation)
{
- EggSMClient *client = egg_sm_client_get ();
+ EggSMClient *client = egg_sm_client_get ();
- g_return_val_if_fail (EGG_IS_SM_CLIENT (client), FALSE);
+ g_return_val_if_fail (EGG_IS_SM_CLIENT (client), FALSE);
- if (EGG_SM_CLIENT_GET_CLASS (client)->end_session)
- {
- return EGG_SM_CLIENT_GET_CLASS (client)->end_session (client, style,
- request_confirmation);
- }
- else
- return FALSE;
+ if (EGG_SM_CLIENT_GET_CLASS (client)->end_session)
+ {
+ return EGG_SM_CLIENT_GET_CLASS (client)->end_session (client, style,
+ request_confirmation);
+ }
+ else
+ return FALSE;
}
/* Signal-emitting callbacks from platform-specific code */
@@ -531,80 +544,80 @@ egg_sm_client_end_session (EggSMClientEndStyle style,
GKeyFile *
egg_sm_client_save_state (EggSMClient *client)
{
- GKeyFile *state_file;
- char *group;
-
- g_return_val_if_fail (client == global_client, NULL);
-
- state_file = g_key_file_new ();
-
- g_debug ("Emitting save_state");
- g_signal_emit (client, signals[SAVE_STATE], 0, state_file);
- g_debug ("Done emitting save_state");
-
- group = g_key_file_get_start_group (state_file);
- if (group)
- {
- g_free (group);
- return state_file;
- }
- else
- {
- g_key_file_free (state_file);
- return NULL;
- }
+ GKeyFile *state_file;
+ char *group;
+
+ g_return_val_if_fail (client == global_client, NULL);
+
+ state_file = g_key_file_new ();
+
+ g_debug ("Emitting save_state");
+ g_signal_emit (client, signals[SAVE_STATE], 0, state_file);
+ g_debug ("Done emitting save_state");
+
+ group = g_key_file_get_start_group (state_file);
+ if (group)
+ {
+ g_free (group);
+ return state_file;
+ }
+ else
+ {
+ g_key_file_free (state_file);
+ return NULL;
+ }
}
void
egg_sm_client_quit_requested (EggSMClient *client)
{
- g_return_if_fail (client == global_client);
-
- if (!g_signal_has_handler_pending (client, signals[QUIT_REQUESTED], 0, FALSE))
- {
- g_debug ("Not emitting quit_requested because no one is listening");
- egg_sm_client_will_quit (client, TRUE);
- return;
- }
-
- g_debug ("Emitting quit_requested");
- g_signal_emit (client, signals[QUIT_REQUESTED], 0);
- g_debug ("Done emitting quit_requested");
+ g_return_if_fail (client == global_client);
+
+ if (!g_signal_has_handler_pending (client, signals[QUIT_REQUESTED], 0, FALSE))
+ {
+ g_debug ("Not emitting quit_requested because no one is listening");
+ egg_sm_client_will_quit (client, TRUE);
+ return;
+ }
+
+ g_debug ("Emitting quit_requested");
+ g_signal_emit (client, signals[QUIT_REQUESTED], 0);
+ g_debug ("Done emitting quit_requested");
}
void
egg_sm_client_quit_cancelled (EggSMClient *client)
{
- g_return_if_fail (client == global_client);
+ g_return_if_fail (client == global_client);
- g_debug ("Emitting quit_cancelled");
- g_signal_emit (client, signals[QUIT_CANCELLED], 0);
- g_debug ("Done emitting quit_cancelled");
+ g_debug ("Emitting quit_cancelled");
+ g_signal_emit (client, signals[QUIT_CANCELLED], 0);
+ g_debug ("Done emitting quit_cancelled");
}
void
egg_sm_client_quit (EggSMClient *client)
{
- g_return_if_fail (client == global_client);
+ g_return_if_fail (client == global_client);
- g_debug ("Emitting quit");
- g_signal_emit (client, signals[QUIT], 0);
- g_debug ("Done emitting quit");
+ g_debug ("Emitting quit");
+ g_signal_emit (client, signals[QUIT], 0);
+ g_debug ("Done emitting quit");
- /* FIXME: should we just call gtk_main_quit() here? */
+ /* FIXME: should we just call gtk_main_quit() here? */
}
static void
egg_sm_client_debug_handler (const char *log_domain,
- GLogLevelFlags log_level,
- const char *message,
- gpointer user_data)
+ GLogLevelFlags log_level,
+ const char *message,
+ gpointer user_data)
{
- static int debug = -1;
+ static int debug = -1;
- if (debug < 0)
- debug = (g_getenv ("EGG_SM_CLIENT_DEBUG") != NULL);
+ if (debug < 0)
+ debug = (g_getenv ("EGG_SM_CLIENT_DEBUG") != NULL);
- if (debug)
- g_log_default_handler (log_domain, log_level, message, NULL);
+ if (debug)
+ g_log_default_handler (log_domain, log_level, message, NULL);
}