[Xfce4-commits] <libxfce4ui:new-sm-client> make XfceSMClient un-subclassable
Brian J. Tarricone
brian at tarricone.org
Tue Sep 15 07:04:01 CEST 2009
Updating branch refs/heads/kelnos/new-sm-client
to 4e6de2230b1fb849809f8f53b1e2040a2fadaa2e (commit)
from 6cb7545b7a1b15af2771e6c6be0a763110ccf070 (commit)
commit 4e6de2230b1fb849809f8f53b1e2040a2fadaa2e
Author: Brian J. Tarricone <brian at tarricone.org>
Date: Mon Sep 14 21:55:47 2009 -0700
make XfceSMClient un-subclassable
libxfce4ui/xfce-sm-client.c | 358 ++++++++++++++++++++++---------------------
libxfce4ui/xfce-sm-client.h | 39 +-----
2 files changed, 188 insertions(+), 209 deletions(-)
diff --git a/libxfce4ui/xfce-sm-client.c b/libxfce4ui/xfce-sm-client.c
index edb2b70..027ce97 100644
--- a/libxfce4ui/xfce-sm-client.c
+++ b/libxfce4ui/xfce-sm-client.c
@@ -64,8 +64,10 @@
? -1 : (!s2 \
? 1 : strcmp(s1, s2))) )
-struct _XfceSMClientPrivate
+struct _XfceSMClient
{
+ GObject parent;
+
#ifdef HAVE_LIBSM
SmcConn session_connection;
#endif
@@ -95,6 +97,26 @@ struct _XfceSMClientPrivate
gchar *state_file;
};
+typedef struct _XfceSMClientClass
+{
+ GObjectClass parent;
+
+ /*< signals >*/
+
+ void (*save_state)(XfceSMClient *sm_client);
+ void (*save_state_extended)(XfceSMClient *sm_client);
+
+ gboolean (*quit_requested)(XfceSMClient *sm_client);
+
+ void (*quit)(XfceSMClient *sm_client);
+
+ void (*quit_cancelled)(XfceSMClient *sm_client);
+
+ void (*state_changed)(XfceSMClient *sm_client,
+ XfceSMClientState old_state,
+ XfceSMClientState new_state);
+} XfceSMClientClass;
+
typedef struct
{
guint argc;
@@ -165,8 +187,6 @@ xfce_sm_client_class_init(XfceSMClientClass *klass)
{
GObjectClass *gobject_class = (GObjectClass *)klass;
- g_type_class_add_private(klass, sizeof(XfceSMClientPrivate));
-
gobject_class->get_property = xfce_sm_client_get_property;
gobject_class->set_property = xfce_sm_client_set_property;
gobject_class->constructor = xfce_sm_client_constructor;
@@ -402,12 +422,8 @@ xfce_sm_client_class_init(XfceSMClientClass *klass)
static void
xfce_sm_client_init(XfceSMClient *sm_client)
{
- sm_client->priv = G_TYPE_INSTANCE_GET_PRIVATE(sm_client,
- XFCE_TYPE_SM_CLIENT,
- XfceSMClientPrivate);
-
- sm_client->priv->state = XFCE_SM_CLIENT_STATE_DISCONNECTED;
- sm_client->priv->program = g_get_prgname() ? g_strdup(g_get_prgname()) : g_strdup("<unknown program>");
+ sm_client->state = XFCE_SM_CLIENT_STATE_DISCONNECTED;
+ sm_client->program = g_get_prgname() ? g_strdup(g_get_prgname()) : g_strdup("<unknown program>");
}
static void
@@ -421,58 +437,58 @@ xfce_sm_client_get_property(GObject *obj,
switch(property_id) {
case PROP_SESSION_CONNECTION:
#ifdef HAVE_LIBSM
- g_value_set_pointer(value, sm_client->priv->session_connection);
+ g_value_set_pointer(value, sm_client->session_connection);
#else
g_value_set_pointer(value, NULL);
#endif
break;
case PROP_STATE:
- g_value_set_enum(value, sm_client->priv->state);
+ g_value_set_enum(value, sm_client->state);
break;
case PROP_RESUMED:
- g_value_set_boolean(value, sm_client->priv->resumed);
+ g_value_set_boolean(value, sm_client->resumed);
break;
case PROP_RESTART_STYLE:
- g_value_set_enum(value, sm_client->priv->restart_style);
+ g_value_set_enum(value, sm_client->restart_style);
break;
case PROP_PRIORITY:
- g_value_set_char(value, sm_client->priv->priority);
+ g_value_set_char(value, sm_client->priority);
break;
case PROP_CLIENT_ID:
- g_value_set_string(value, sm_client->priv->client_id);
+ g_value_set_string(value, sm_client->client_id);
break;
case PROP_CURRENT_DIRECTORY:
- g_value_set_string(value, sm_client->priv->current_directory);
+ g_value_set_string(value, sm_client->current_directory);
break;
case PROP_PROGRAM:
- g_value_set_string(value, sm_client->priv->program);
+ g_value_set_string(value, sm_client->program);
break;
case PROP_CLONE_COMMAND:
- g_value_set_boxed(value, sm_client->priv->clone_command);
+ g_value_set_boxed(value, sm_client->clone_command);
break;
case PROP_RESIGN_COMMAND:
- g_value_set_boxed(value, sm_client->priv->resign_command);
+ g_value_set_boxed(value, sm_client->resign_command);
break;
case PROP_RESTART_COMMAND:
- g_value_set_boxed(value, sm_client->priv->restart_command);
+ g_value_set_boxed(value, sm_client->restart_command);
break;
case PROP_DISCARD_COMMAND:
- g_value_set_boxed(value, sm_client->priv->discard_command);
+ g_value_set_boxed(value, sm_client->discard_command);
break;
case PROP_SHUTDOWN_COMMAND:
- g_value_set_boxed(value, sm_client->priv->shutdown_command);
+ g_value_set_boxed(value, sm_client->shutdown_command);
break;
case PROP_ARGC:
@@ -539,19 +555,19 @@ xfce_sm_client_set_property(GObject *obj,
break;
case PROP_ARGC:
- if(sm_client->priv->argc)
+ if(sm_client->argc)
g_critical("XfceSMClient: Received argc twice");
else {
- sm_client->priv->argc = g_value_get_uint(value);
+ sm_client->argc = g_value_get_uint(value);
xfce_sm_client_parse_argv(sm_client);
}
break;
case PROP_ARGV:
- if(sm_client->priv->argv)
+ if(sm_client->argv)
g_critical("XfceSMClient: Received argv twice");
else {
- sm_client->priv->argv = g_value_dup_boxed(value);
+ sm_client->argv = g_value_dup_boxed(value);
xfce_sm_client_parse_argv(sm_client);
}
break;
@@ -585,22 +601,22 @@ xfce_sm_client_finalize(GObject *obj)
sm_client_singleton = NULL;
#ifdef HAVE_LIBSM
- if(sm_client->priv->session_connection)
+ if(sm_client->session_connection)
xfce_sm_client_disconnect(sm_client);
#endif
- g_free(sm_client->priv->state_file);
+ g_free(sm_client->state_file);
- g_free(sm_client->priv->client_id);
- g_free(sm_client->priv->current_directory);
- g_free(sm_client->priv->program);
- g_strfreev(sm_client->priv->clone_command);
- g_strfreev(sm_client->priv->resign_command);
- g_strfreev(sm_client->priv->restart_command);
- g_strfreev(sm_client->priv->discard_command);
- g_strfreev(sm_client->priv->shutdown_command);
+ g_free(sm_client->client_id);
+ g_free(sm_client->current_directory);
+ g_free(sm_client->program);
+ g_strfreev(sm_client->clone_command);
+ g_strfreev(sm_client->resign_command);
+ g_strfreev(sm_client->restart_command);
+ g_strfreev(sm_client->discard_command);
+ g_strfreev(sm_client->shutdown_command);
- g_strfreev(sm_client->priv->argv);
+ g_strfreev(sm_client->argv);
G_OBJECT_CLASS(xfce_sm_client_parent_class)->finalize(obj);
}
@@ -638,11 +654,11 @@ static void
xfce_sm_client_set_client_id(XfceSMClient *sm_client,
const gchar *client_id)
{
- if(!xfce_safe_strcmp(sm_client->priv->client_id, client_id))
+ if(!xfce_safe_strcmp(sm_client->client_id, client_id))
return;
- g_free(sm_client->priv->client_id);
- sm_client->priv->client_id = g_strdup(client_id);
+ g_free(sm_client->client_id);
+ sm_client->client_id = g_strdup(client_id);
g_object_notify(G_OBJECT(sm_client), "client-id");
}
@@ -657,11 +673,11 @@ xfce_sm_client_parse_argv(XfceSMClient *sm_client)
const gchar *client_id = NULL;
int i;
- if(sm_client->priv->argc == 0 || !sm_client->priv->argv)
+ if(sm_client->argc == 0 || !sm_client->argv)
return;
- argc = sm_client->priv->argc;
- argv = sm_client->priv->argv;
+ argc = sm_client->argc;
+ argv = sm_client->argv;
clone_command = g_new0(gchar *, argc + 1);
@@ -682,9 +698,9 @@ xfce_sm_client_parse_argv(XfceSMClient *sm_client)
g_free(clone_command);
- sm_client->priv->argc = 0;
- g_strfreev(sm_client->priv->argv);
- sm_client->priv->argv = NULL;
+ sm_client->argc = 0;
+ g_strfreev(sm_client->argv);
+ sm_client->argv = NULL;
}
#ifdef HAVE_LIBSM
@@ -693,7 +709,7 @@ static void
xfce_sm_client_set_state(XfceSMClient *sm_client,
XfceSMClientState new_state)
{
- XfceSMClientState old_state = sm_client->priv->state;
+ XfceSMClientState old_state = sm_client->state;
if(G_UNLIKELY(old_state == new_state))
return;
@@ -701,7 +717,7 @@ xfce_sm_client_set_state(XfceSMClient *sm_client,
g_debug("XfceSMClient: %s -> %s", str_from_state(old_state),
str_from_state(new_state));
- sm_client->priv->state = new_state;
+ sm_client->state = new_state;
g_signal_emit(G_OBJECT(sm_client), signals[SIG_STATE_CHANGED], 0,
old_state, new_state);
@@ -844,13 +860,13 @@ xfce_sm_client_handle_save_yourself(XfceSMClient *sm_client,
{
Status status;
- status = SmcInteractRequest(sm_client->priv->session_connection,
+ status = SmcInteractRequest(sm_client->session_connection,
dialog_type, xsmp_interact,
(SmPointer)sm_client);
if(status) {
xfce_sm_client_set_state(sm_client, XFCE_SM_CLIENT_STATE_WAITING_FOR_INTERACT);
- sm_client->priv->needs_save_state = do_save_state;
+ sm_client->needs_save_state = do_save_state;
/* we want save-state to happen *after* quit-requested if we're
* doing both, but we can't do quit-requested until we hear
* about our interact request */
@@ -865,17 +881,17 @@ xfce_sm_client_handle_save_yourself(XfceSMClient *sm_client,
if(do_save_state)
g_signal_emit(G_OBJECT(sm_client), signals[SIG_SAVE_STATE], 0, NULL);
- if(sm_client->priv->shutdown_cancelled) {
+ if(sm_client->shutdown_cancelled) {
/* this is a slightly bizarre case that probably won't happen.
* if we got to this point, then we didn't do quit-requested,
* but the system was shutting down, and then it was later
* cancelled. since we never did a quit-requested, the client
* probably won't expect a quit-cancelled, so we do nothing here. */
- sm_client->priv->shutdown_cancelled = FALSE;
+ sm_client->shutdown_cancelled = FALSE;
xfce_sm_client_set_state(sm_client, XFCE_SM_CLIENT_STATE_IDLE);
} else {
/* otherwise, we're just done with the SaveYourself here */
- SmcSaveYourselfDone(sm_client->priv->session_connection, True);
+ SmcSaveYourselfDone(sm_client->session_connection, True);
/* the XSMP spec state diagram says to go right back to IDLE after a
* non-shutdown SaveYourself, but everything else in the spec disagrees:
* we need to wait for a SaveComplete before going back to IDLE */
@@ -900,17 +916,17 @@ xsmp_save_phase_2(SmcConn smc_conn,
g_signal_emit(G_OBJECT(sm_client), signals[SIG_SAVE_STATE_EXTENDED], 0, NULL);
- SmcSaveYourselfDone(sm_client->priv->session_connection, True);
+ SmcSaveYourselfDone(sm_client->session_connection, True);
/* the XSMP spec state diagram says to go right back to IDLE after a
* non-shutdown SaveYourself, but everything else in the spec disagrees:
* we need to wait for a SaveComplete before going back to IDLE */
xfce_sm_client_set_state(sm_client, XFCE_SM_CLIENT_STATE_FROZEN);
- if(sm_client->priv->shutdown_cancelled) {
+ if(sm_client->shutdown_cancelled) {
/* if we get here, we received ShutdownCancelled while in a recursive
* invocation of the main loop in save-state-extended. in this case, we
* go back to idle and send quit-cancelled. */
- sm_client->priv->shutdown_cancelled = FALSE;
+ sm_client->shutdown_cancelled = FALSE;
xfce_sm_client_set_state(sm_client, XFCE_SM_CLIENT_STATE_IDLE);
g_signal_emit(G_OBJECT(sm_client), signals[SIG_QUIT_CANCELLED], 0,
@@ -938,14 +954,14 @@ xsmp_save_yourself(SmcConn smc_conn,
/* The first SaveYourself after registering for the first time
* is a special case (SM specs 7.2).
*/
- if(sm_client->priv->state == XFCE_SM_CLIENT_STATE_REGISTERING) {
+ if(sm_client->state == XFCE_SM_CLIENT_STATE_REGISTERING) {
if(save_style == SmSaveLocal
&& interact_style == SmInteractStyleNone
&& !shutdown
&& !fast)
{
xfce_sm_client_set_clone_restart_commands(sm_client);
- SmcSaveYourselfDone(sm_client->priv->session_connection, True);
+ SmcSaveYourselfDone(sm_client->session_connection, True);
/* XSMP spec state diagram says idle, but the rest of the spec disagrees */
xfce_sm_client_set_state(sm_client, XFCE_SM_CLIENT_STATE_FROZEN);
} else {
@@ -956,10 +972,10 @@ xsmp_save_yourself(SmcConn smc_conn,
return;
}
- if(sm_client->priv->state != XFCE_SM_CLIENT_STATE_IDLE) {
+ if(sm_client->state != XFCE_SM_CLIENT_STATE_IDLE) {
g_warning("Got SaveYourself while in phase %s, ignoring",
- str_from_state(sm_client->priv->state));
- SmcSaveYourselfDone(sm_client->priv->session_connection, True);
+ str_from_state(sm_client->state));
+ SmcSaveYourselfDone(sm_client->session_connection, True);
xfce_sm_client_set_state(sm_client, XFCE_SM_CLIENT_STATE_FROZEN);
return;
}
@@ -1037,7 +1053,7 @@ xsmp_save_complete(SmcConn smc_conn,
TRACE("entering");
- if(sm_client->priv->state != XFCE_SM_CLIENT_STATE_FROZEN)
+ if(sm_client->state != XFCE_SM_CLIENT_STATE_FROZEN)
g_warning("Got SaveComplete in unexpected state");
xfce_sm_client_set_state(sm_client, XFCE_SM_CLIENT_STATE_IDLE);
@@ -1051,7 +1067,7 @@ xsmp_shutdown_cancelled(SmcConn smc_conn,
TRACE("entering");
- switch(sm_client->priv->state) {
+ switch(sm_client->state) {
case XFCE_SM_CLIENT_STATE_FROZEN:
case XFCE_SM_CLIENT_STATE_WAITING_FOR_PHASE_2:
/* if the client has already handled quit-requested, we just go
@@ -1068,7 +1084,7 @@ xsmp_shutdown_cancelled(SmcConn smc_conn,
* the SaveYourself and move on. we don't inform the client of
* the cancellation since we haven't gotten to inform them about
* the shutdown in the first place. */
- SmcSaveYourselfDone(sm_client->priv->session_connection, True);
+ SmcSaveYourselfDone(sm_client->session_connection, True);
xfce_sm_client_set_state(sm_client, XFCE_SM_CLIENT_STATE_IDLE);
break;
@@ -1080,7 +1096,7 @@ xsmp_shutdown_cancelled(SmcConn smc_conn,
* handlers and is presumably inside a recursive invocation of the
* main loop. we shouldn't inform them of anything just yet, but
* we'll set a flag so we can do so when they return. */
- sm_client->priv->shutdown_cancelled = TRUE;
+ sm_client->shutdown_cancelled = TRUE;
break;
default:
@@ -1103,12 +1119,12 @@ xsmp_interact(SmcConn smc_conn,
* we should receive an interact message is during a normal save
* yourself. */
- if(sm_client->priv->state != XFCE_SM_CLIENT_STATE_WAITING_FOR_INTERACT) {
+ if(sm_client->state != XFCE_SM_CLIENT_STATE_WAITING_FOR_INTERACT) {
g_warning("Got Interact message when not waiting for one");
/* FIXME: not sure if this is the best response to this. we might
* want to actually go through with sending quit-requested etc. */
- SmcInteractDone(sm_client->priv->session_connection, False);
- SmcSaveYourselfDone(sm_client->priv->session_connection, True);
+ SmcInteractDone(sm_client->session_connection, False);
+ SmcSaveYourselfDone(sm_client->session_connection, True);
xfce_sm_client_set_state(sm_client, XFCE_SM_CLIENT_STATE_FROZEN);
return;
}
@@ -1119,11 +1135,11 @@ xsmp_interact(SmcConn smc_conn,
g_signal_emit(G_OBJECT(sm_client), signals[SIG_QUIT_REQUESTED], 0,
&cancel);
- if(sm_client->priv->shutdown_cancelled) {
+ if(sm_client->shutdown_cancelled) {
/* if we get here, we received ShutdownCancelled while in a recursive
* invocation of the main loop in quit-requested. in this case, we
* go back to idle and send quit-cancelled. */
- sm_client->priv->shutdown_cancelled = FALSE;
+ sm_client->shutdown_cancelled = FALSE;
cancel = TRUE;
xfce_sm_client_set_state(sm_client, XFCE_SM_CLIENT_STATE_IDLE);
@@ -1132,21 +1148,21 @@ xsmp_interact(SmcConn smc_conn,
} else {
/* we only send InteractDone if we didn't get ShutdownCancelled */
xfce_sm_client_set_state(sm_client, XFCE_SM_CLIENT_STATE_FROZEN);
- SmcInteractDone(sm_client->priv->session_connection, cancel);
+ SmcInteractDone(sm_client->session_connection, cancel);
}
if(cancel) {
/* if we requested (or got) a shutdown cancellation, we skip the
* save-state signal. */
- sm_client->priv->needs_save_state = FALSE;
- } else if(sm_client->priv->needs_save_state) {
+ sm_client->needs_save_state = FALSE;
+ } else if(sm_client->needs_save_state) {
/* if we still have a pending save-state, send that now */
- sm_client->priv->needs_save_state = FALSE;
+ sm_client->needs_save_state = FALSE;
g_signal_emit(G_OBJECT(sm_client), signals[SIG_SAVE_STATE], 0, NULL);
- if(sm_client->priv->shutdown_cancelled) {
+ if(sm_client->shutdown_cancelled) {
/* this is exceedingly unlikely, but it could happen here too */
- sm_client->priv->shutdown_cancelled = FALSE;
+ sm_client->shutdown_cancelled = FALSE;
cancel = TRUE;
xfce_sm_client_set_state(sm_client, XFCE_SM_CLIENT_STATE_IDLE);
@@ -1162,7 +1178,7 @@ xsmp_interact(SmcConn smc_conn,
{
Status status;
- status = SmcRequestSaveYourselfPhase2(sm_client->priv->session_connection,
+ status = SmcRequestSaveYourselfPhase2(sm_client->session_connection,
xsmp_save_phase_2,
(SmPointer)sm_client);
if(status) {
@@ -1173,7 +1189,7 @@ xsmp_interact(SmcConn smc_conn,
/* finally, signal to the SM that we're done. we also fall through and
* bail to this if a phase2 request failed for some reason. */
- SmcSaveYourselfDone(sm_client->priv->session_connection, True);
+ SmcSaveYourselfDone(sm_client->session_connection, True);
}
static void
@@ -1188,7 +1204,7 @@ xfce_sm_client_set_property_from_command(XfceSMClient *sm_client,
gint argc;
SmPropValue *vals;
- if(!command || !sm_client->priv->session_connection)
+ if(!command || !sm_client->session_connection)
return;
args = command;
@@ -1223,8 +1239,8 @@ xfce_sm_client_set_property_from_command(XfceSMClient *sm_client,
if(alter_sm_id == SM_ARG_APPEND) {
vals[i].length = strlen(SM_ID_ARG);
vals[i++].value = SM_ID_ARG;
- vals[i].length = strlen(sm_client->priv->client_id);
- vals[i++].value = sm_client->priv->client_id;
+ vals[i].length = strlen(sm_client->client_id);
+ vals[i++].value = sm_client->client_id;
}
prop.name = (char *)property_name;
@@ -1233,7 +1249,7 @@ xfce_sm_client_set_property_from_command(XfceSMClient *sm_client,
prop.num_vals = i;
props[0] = ∝
- SmcSetProperties(sm_client->priv->session_connection, 1, props);
+ SmcSetProperties(sm_client->session_connection, 1, props);
g_free(vals);
}
@@ -1242,29 +1258,29 @@ xfce_sm_client_set_clone_restart_commands(XfceSMClient *sm_client)
{
/* Restart */
xfce_sm_client_set_property_from_command(sm_client, SmRestartCommand,
- sm_client->priv->restart_command,
+ sm_client->restart_command,
SM_ARG_APPEND);
/* Clone */
xfce_sm_client_set_property_from_command(sm_client, SmCloneCommand,
- (sm_client->priv->clone_command
- ? sm_client->priv->clone_command
- : sm_client->priv->restart_command),
+ (sm_client->clone_command
+ ? sm_client->clone_command
+ : sm_client->restart_command),
SM_ARG_REMOVE);
/* Resign */
xfce_sm_client_set_property_from_command(sm_client, SmResignCommand,
- sm_client->priv->resign_command,
+ sm_client->resign_command,
FALSE);
/* Discard */
xfce_sm_client_set_property_from_command(sm_client, SmDiscardCommand,
- sm_client->priv->discard_command,
+ sm_client->discard_command,
FALSE);
/* Shutdown */
xfce_sm_client_set_property_from_command(sm_client, SmShutdownCommand,
- sm_client->priv->shutdown_command,
+ sm_client->shutdown_command,
FALSE);
}
@@ -1453,7 +1469,7 @@ xfce_sm_client_connect(XfceSMClient *sm_client,
SmPropValue prop1val, prop2val, prop3val, prop4val, prop5val, prop6val;
char pid[32];
char hint = SmRestartIfRunning;
- char priority = sm_client->priv->priority;
+ char priority = sm_client->priority;
char *given_client_id = NULL;
#endif
@@ -1481,17 +1497,17 @@ xfce_sm_client_connect(XfceSMClient *sm_client,
callbacks.shutdown_cancelled.callback = xsmp_shutdown_cancelled;
callbacks.shutdown_cancelled.client_data = (SmPointer)sm_client;
- sm_client->priv->session_connection = SmcOpenConnection(NULL, NULL,
+ sm_client->session_connection = SmcOpenConnection(NULL, NULL,
SmProtoMajor,
SmProtoMinor,
mask,
&callbacks,
- (char *)sm_client->priv->client_id,
+ (char *)sm_client->client_id,
&given_client_id,
sizeof(buf)-1,
buf);
- if(!sm_client->priv->session_connection) {
+ if(!sm_client->session_connection) {
if(error) {
/* FIXME: error domain/code */
g_set_error(error, 0, 1,
@@ -1507,11 +1523,11 @@ xfce_sm_client_connect(XfceSMClient *sm_client,
return FALSE;
}
- if(sm_client->priv->client_id
- && !strcmp(sm_client->priv->client_id, given_client_id))
+ if(sm_client->client_id
+ && !strcmp(sm_client->client_id, given_client_id))
{
xfce_sm_client_set_state(sm_client, XFCE_SM_CLIENT_STATE_IDLE);
- sm_client->priv->resumed = TRUE;
+ sm_client->resumed = TRUE;
g_object_notify(G_OBJECT(sm_client), "resumed");
} else {
xfce_sm_client_set_client_id(sm_client, given_client_id);
@@ -1520,16 +1536,16 @@ xfce_sm_client_connect(XfceSMClient *sm_client,
free(given_client_id);
- gdk_set_sm_client_id(sm_client->priv->client_id);
+ gdk_set_sm_client_id(sm_client->client_id);
- hint = xsmp_restart_style_from_enum(sm_client->priv->restart_style);
+ hint = xsmp_restart_style_from_enum(sm_client->restart_style);
prop1.name = SmProgram;
prop1.type = SmARRAY8;
prop1.num_vals = 1;
prop1.vals = &prop1val;
- prop1val.value = sm_client->priv->program;
- prop1val.length = strlen(sm_client->priv->program);
+ prop1val.value = sm_client->program;
+ prop1val.length = strlen(sm_client->program);
prop2.name = SmUserID;
prop2.type = SmARRAY8;
@@ -1557,8 +1573,8 @@ xfce_sm_client_connect(XfceSMClient *sm_client,
prop5.type = SmARRAY8;
prop5.num_vals = 1;
prop5.vals = &prop5val;
- if(sm_client->priv->current_directory)
- prop5val.value = (char *)sm_client->priv->current_directory;
+ if(sm_client->current_directory)
+ prop5val.value = (char *)sm_client->current_directory;
else
prop5val.value = (char *)xfce_get_homedir();
prop5val.length = strlen(prop5val.value);
@@ -1577,7 +1593,7 @@ xfce_sm_client_connect(XfceSMClient *sm_client,
props[4] = &prop5;
props[5] = &prop6;
- SmcSetProperties(sm_client->priv->session_connection, 6, props);
+ SmcSetProperties(sm_client->session_connection, 6, props);
g_object_notify(G_OBJECT(sm_client), "session-connection");
#endif
@@ -1603,16 +1619,16 @@ xfce_sm_client_disconnect(XfceSMClient *sm_client)
return;
#ifdef HAVE_LIBSM
- if(G_UNLIKELY(!sm_client->priv->session_connection)) {
+ if(G_UNLIKELY(!sm_client->session_connection)) {
g_warning("%s() called with no session connection", G_STRFUNC);
return;
}
- if(sm_client->priv->restart_style == XFCE_SM_CLIENT_RESTART_IMMEDIATELY)
+ if(sm_client->restart_style == XFCE_SM_CLIENT_RESTART_IMMEDIATELY)
xfce_sm_client_set_restart_style(sm_client, XFCE_SM_CLIENT_RESTART_IF_RUNNING);
- SmcCloseConnection(sm_client->priv->session_connection, 0, NULL);
- sm_client->priv->session_connection = NULL;
+ SmcCloseConnection(sm_client->session_connection, 0, NULL);
+ sm_client->session_connection = NULL;
gdk_set_sm_client_id(NULL);
g_object_notify(G_OBJECT(sm_client), "session-connection");
@@ -1634,7 +1650,7 @@ gboolean
xfce_sm_client_is_resumed(XfceSMClient *sm_client)
{
g_return_val_if_fail(XFCE_IS_SM_CLIENT(sm_client), FALSE);
- return sm_client->priv->resumed;
+ return sm_client->resumed;
}
/**
@@ -1662,8 +1678,8 @@ xfce_sm_client_request_shutdown(XfceSMClient *sm_client,
/* TODO: support xfce4-session's DBus interface */
#ifdef HAVE_LIBSM
- if(G_LIKELY(sm_client->priv->session_connection)) {
- SmcRequestSaveYourself(sm_client->priv->session_connection, SmSaveBoth,
+ if(G_LIKELY(sm_client->session_connection)) {
+ SmcRequestSaveYourself(sm_client->session_connection, SmSaveBoth,
True, SmInteractStyleAny, False, True);
}
#endif
@@ -1682,18 +1698,18 @@ xfce_sm_client_set_restart_style(XfceSMClient *sm_client,
{
g_return_if_fail(XFCE_IS_SM_CLIENT(sm_client));
- if(sm_client->priv->restart_style == restart_style)
+ if(sm_client->restart_style == restart_style)
return;
- sm_client->priv->restart_style = restart_style;
+ sm_client->restart_style = restart_style;
#ifdef HAVE_LIBSM
- if(sm_client->priv->session_connection) {
+ if(sm_client->session_connection) {
SmProp prop, *props[1];
SmPropValue propval;
char hint;
- hint = xsmp_restart_style_from_enum(sm_client->priv->restart_style);
+ hint = xsmp_restart_style_from_enum(sm_client->restart_style);
prop.name = SmRestartStyleHint;
prop.type = SmCARD8;
@@ -1703,7 +1719,7 @@ xfce_sm_client_set_restart_style(XfceSMClient *sm_client,
propval.length = 1;
props[0] = ∝
- SmcSetProperties(sm_client->priv->session_connection, 1, props);
+ SmcSetProperties(sm_client->session_connection, 1, props);
}
#endif /* HAVE_LIBSM */
@@ -1725,13 +1741,13 @@ xfce_sm_client_set_priority(XfceSMClient *sm_client,
{
g_return_if_fail(XFCE_IS_SM_CLIENT(sm_client));
- if(sm_client->priv->priority == priority)
+ if(sm_client->priority == priority)
return;
- sm_client->priv->priority = priority;
+ sm_client->priority = priority;
#ifdef HAVE_LIBSM
- if(sm_client->priv->session_connection) {
+ if(sm_client->session_connection) {
SmProp prop, *props[1];
SmPropValue propval;
@@ -1739,11 +1755,11 @@ xfce_sm_client_set_priority(XfceSMClient *sm_client,
prop.type = SmCARD8;
prop.num_vals = 1;
prop.vals = &propval;
- propval.value = &sm_client->priv->priority;
+ propval.value = &sm_client->priority;
propval.length = 1;
props[0] = ∝
- SmcSetProperties(sm_client->priv->session_connection, 1, props);
+ SmcSetProperties(sm_client->session_connection, 1, props);
}
#endif /* HAVE_LIBSM */
@@ -1765,17 +1781,17 @@ xfce_sm_client_set_current_directory(XfceSMClient *sm_client,
{
g_return_if_fail(XFCE_IS_SM_CLIENT(sm_client));
- if(!xfce_safe_strcmp(sm_client->priv->current_directory, current_directory))
+ if(!xfce_safe_strcmp(sm_client->current_directory, current_directory))
return;
if(!current_directory)
current_directory = xfce_get_homedir();
- g_free(sm_client->priv->current_directory);
- sm_client->priv->current_directory = g_strdup(current_directory);
+ g_free(sm_client->current_directory);
+ sm_client->current_directory = g_strdup(current_directory);
#ifdef HAVE_LIBSM
- if(sm_client->priv->session_connection) {
+ if(sm_client->session_connection) {
SmProp prop, *props[1];
SmPropValue propval;
@@ -1783,11 +1799,11 @@ xfce_sm_client_set_current_directory(XfceSMClient *sm_client,
prop.type = SmARRAY8;
prop.num_vals = 1;
prop.vals = &propval;
- propval.value = sm_client->priv->current_directory;
+ propval.value = sm_client->current_directory;
propval.length = strlen(propval.value);
props[0] = ∝
- SmcSetProperties(sm_client->priv->session_connection, 1, props);
+ SmcSetProperties(sm_client->session_connection, 1, props);
}
#endif /* HAVE_LIBSM */
@@ -1810,17 +1826,17 @@ xfce_sm_client_set_program(XfceSMClient *sm_client,
{
g_return_if_fail(XFCE_IS_SM_CLIENT(sm_client));
- if(!xfce_safe_strcmp(sm_client->priv->program, program))
+ if(!xfce_safe_strcmp(sm_client->program, program))
return;
if(!program)
program = g_get_prgname() ? g_get_prgname() : "<unknown program>";
- g_free(sm_client->priv->program);
- sm_client->priv->program = g_strdup(program);
+ g_free(sm_client->program);
+ sm_client->program = g_strdup(program);
#ifdef HAVE_LIBSM
- if(sm_client->priv->session_connection) {
+ if(sm_client->session_connection) {
SmProp prop, *props[1];
SmPropValue propval;
@@ -1828,10 +1844,10 @@ xfce_sm_client_set_program(XfceSMClient *sm_client,
prop.type = SmARRAY8;
prop.num_vals = 1;
prop.vals = &propval;
- propval.value = sm_client->priv->program;
- propval.length = strlen(sm_client->priv->program);
+ propval.value = sm_client->program;
+ propval.length = strlen(sm_client->program);
- SmcSetProperties(sm_client->priv->session_connection, 1, props);
+ SmcSetProperties(sm_client->session_connection, 1, props);
}
#endif /* HAVE_LIBSM */
@@ -1870,11 +1886,11 @@ xfce_sm_client_set_clone_command(XfceSMClient *sm_client,
gchar **clone_command)
{
g_return_if_fail(XFCE_IS_SM_CLIENT(sm_client));
- sm_client->priv->clone_command = copy_command(sm_client->priv->clone_command,
+ sm_client->clone_command = copy_command(sm_client->clone_command,
clone_command);
#ifdef HAVE_LIBSM
xfce_sm_client_set_property_from_command(sm_client, SmCloneCommand,
- sm_client->priv->clone_command,
+ sm_client->clone_command,
SM_ARG_REMOVE);
#endif
g_object_notify(G_OBJECT(sm_client), "clone-command");
@@ -1896,11 +1912,11 @@ xfce_sm_client_set_resign_command(XfceSMClient *sm_client,
gchar **resign_command)
{
g_return_if_fail(XFCE_IS_SM_CLIENT(sm_client));
- sm_client->priv->resign_command = copy_command(sm_client->priv->resign_command,
+ sm_client->resign_command = copy_command(sm_client->resign_command,
resign_command);
#ifdef HAVE_LIBSM
xfce_sm_client_set_property_from_command(sm_client, SmResignCommand,
- sm_client->priv->resign_command,
+ sm_client->resign_command,
FALSE);
#endif
g_object_notify(G_OBJECT(sm_client), "resign-command");
@@ -1924,11 +1940,11 @@ xfce_sm_client_set_restart_command(XfceSMClient *sm_client,
gchar **restart_command)
{
g_return_if_fail(XFCE_IS_SM_CLIENT(sm_client));
- sm_client->priv->restart_command = copy_command(sm_client->priv->restart_command,
+ sm_client->restart_command = copy_command(sm_client->restart_command,
restart_command);
#ifdef HAVE_LIBSM
xfce_sm_client_set_property_from_command(sm_client, SmRestartCommand,
- sm_client->priv->restart_command,
+ sm_client->restart_command,
SM_ARG_APPEND);
#endif
g_object_notify(G_OBJECT(sm_client), "restart-command");
@@ -1952,11 +1968,11 @@ xfce_sm_client_set_discard_command(XfceSMClient *sm_client,
gchar **discard_command)
{
g_return_if_fail(XFCE_IS_SM_CLIENT(sm_client));
- sm_client->priv->discard_command = copy_command(sm_client->priv->discard_command,
+ sm_client->discard_command = copy_command(sm_client->discard_command,
discard_command);
#ifdef HAVE_LIBSM
xfce_sm_client_set_property_from_command(sm_client, SmDiscardCommand,
- sm_client->priv->discard_command,
+ sm_client->discard_command,
FALSE);
#endif
g_object_notify(G_OBJECT(sm_client), "discard-command");
@@ -1977,11 +1993,11 @@ xfce_sm_client_set_shutdown_command(XfceSMClient *sm_client,
gchar **shutdown_command)
{
g_return_if_fail(XFCE_IS_SM_CLIENT(sm_client));
- sm_client->priv->shutdown_command = copy_command(sm_client->priv->shutdown_command,
+ sm_client->shutdown_command = copy_command(sm_client->shutdown_command,
shutdown_command);
#ifdef HAVE_LIBSM
xfce_sm_client_set_property_from_command(sm_client, SmShutdownCommand,
- sm_client->priv->shutdown_command,
+ sm_client->shutdown_command,
FALSE);
#endif
g_object_notify(G_OBJECT(sm_client), "shutdown-command");
@@ -2004,7 +2020,7 @@ xfce_sm_client_get_state(XfceSMClient *sm_client)
{
g_return_val_if_fail(XFCE_IS_SM_CLIENT(sm_client),
XFCE_SM_CLIENT_STATE_DISCONNECTED);
- return sm_client->priv->state;
+ return sm_client->state;
}
/**
@@ -2021,7 +2037,7 @@ xfce_sm_client_get_restart_style(XfceSMClient *sm_client)
{
g_return_val_if_fail(XFCE_IS_SM_CLIENT(sm_client),
XFCE_SM_CLIENT_RESTART_IF_RUNNING);
- return sm_client->priv->restart_style;
+ return sm_client->restart_style;
}
/**
@@ -2038,7 +2054,7 @@ xfce_sm_client_get_priority(XfceSMClient *sm_client)
{
g_return_val_if_fail(XFCE_IS_SM_CLIENT(sm_client),
XFCE_SM_CLIENT_PRIORITY_DEFAULT);
- return sm_client->priv->priority;
+ return sm_client->priority;
}
/**
@@ -2059,7 +2075,7 @@ G_CONST_RETURN gchar *
xfce_sm_client_get_client_id(XfceSMClient *sm_client)
{
g_return_val_if_fail(XFCE_IS_SM_CLIENT(sm_client), NULL);
- return sm_client->priv->client_id;
+ return sm_client->client_id;
}
/**
@@ -2095,23 +2111,23 @@ xfce_sm_client_get_state_file(XfceSMClient *sm_client)
g_return_val_if_fail(XFCE_IS_SM_CLIENT(sm_client), NULL);
- if(sm_client->priv->state_file)
- return sm_client->priv->state_file;
+ if(sm_client->state_file)
+ return sm_client->state_file;
- g_return_val_if_fail(sm_client->priv->program, NULL);
- g_return_val_if_fail(sm_client->priv->client_id, NULL);
+ g_return_val_if_fail(sm_client->program, NULL);
+ g_return_val_if_fail(sm_client->client_id, NULL);
resource = g_strdup_printf("sessions/%s-%s.state",
- sm_client->priv->program,
- sm_client->priv->client_id);
+ sm_client->program,
+ sm_client->client_id);
for(p = resource; *p; p++) {
if(*p == '/')
*p = '_';
}
- sm_client->priv->state_file = xfce_resource_save_location(XFCE_RESOURCE_CACHE,
+ sm_client->state_file = xfce_resource_save_location(XFCE_RESOURCE_CACHE,
resource, TRUE);
- if(!sm_client->priv->state_file) {
+ if(!sm_client->state_file) {
g_critical("XfceSMClient: Unable to create state file as "
"\"$XDG_CACHE_HOME/%s\"", resource);
}
@@ -2119,22 +2135,22 @@ xfce_sm_client_get_state_file(XfceSMClient *sm_client)
g_free(resource);
#ifdef HAVE_LIBSM
- if(G_LIKELY(sm_client->priv->state_file)
- && sm_client->priv->session_connection
- && !sm_client->priv->discard_command)
+ if(G_LIKELY(sm_client->state_file)
+ && sm_client->session_connection
+ && !sm_client->discard_command)
{
- sm_client->priv->discard_command = g_new0(gchar *, 4);
- sm_client->priv->discard_command[0] = g_strdup("rm");
- sm_client->priv->discard_command[1] = g_strdup("-f");
- sm_client->priv->discard_command[2] = g_strdup(sm_client->priv->state_file);
+ sm_client->discard_command = g_new0(gchar *, 4);
+ sm_client->discard_command[0] = g_strdup("rm");
+ sm_client->discard_command[1] = g_strdup("-f");
+ sm_client->discard_command[2] = g_strdup(sm_client->state_file);
xfce_sm_client_set_property_from_command(sm_client, SmDiscardCommand,
- sm_client->priv->discard_command,
+ sm_client->discard_command,
FALSE);
}
#endif
- return sm_client->priv->state_file;
+ return sm_client->state_file;
}
/**
@@ -2150,7 +2166,7 @@ G_CONST_RETURN gchar *
xfce_sm_client_get_current_directory(XfceSMClient *sm_client)
{
g_return_val_if_fail(XFCE_IS_SM_CLIENT(sm_client), NULL);
- return sm_client->priv->current_directory;
+ return sm_client->current_directory;
}
/**
@@ -2166,7 +2182,7 @@ G_CONST_RETURN gchar *
xfce_sm_client_get_program(XfceSMClient *sm_client)
{
g_return_val_if_fail(XFCE_IS_SM_CLIENT(sm_client), NULL);
- return sm_client->priv->program;
+ return sm_client->program;
}
/**
@@ -2182,7 +2198,7 @@ gchar **
xfce_sm_client_get_clone_command(XfceSMClient *sm_client)
{
g_return_val_if_fail(XFCE_IS_SM_CLIENT(sm_client), NULL);
- return sm_client->priv->clone_command;
+ return sm_client->clone_command;
}
/**
@@ -2198,7 +2214,7 @@ gchar **
xfce_sm_client_get_resign_command(XfceSMClient *sm_client)
{
g_return_val_if_fail(XFCE_IS_SM_CLIENT(sm_client), NULL);
- return sm_client->priv->resign_command;
+ return sm_client->resign_command;
}
/**
@@ -2214,7 +2230,7 @@ gchar **
xfce_sm_client_get_restart_command(XfceSMClient *sm_client)
{
g_return_val_if_fail(XFCE_IS_SM_CLIENT(sm_client), NULL);
- return sm_client->priv->restart_command;
+ return sm_client->restart_command;
}
/**
@@ -2230,7 +2246,7 @@ gchar **
xfce_sm_client_get_discard_command(XfceSMClient *sm_client)
{
g_return_val_if_fail(XFCE_IS_SM_CLIENT(sm_client), NULL);
- return sm_client->priv->discard_command;
+ return sm_client->discard_command;
}
/**
@@ -2246,5 +2262,5 @@ gchar **
xfce_sm_client_get_shutdown_command(XfceSMClient *sm_client)
{
g_return_val_if_fail(XFCE_IS_SM_CLIENT(sm_client), NULL);
- return sm_client->priv->shutdown_command;
+ return sm_client->shutdown_command;
}
diff --git a/libxfce4ui/xfce-sm-client.h b/libxfce4ui/xfce-sm-client.h
index 439e8fa..e44cd7e 100644
--- a/libxfce4ui/xfce-sm-client.h
+++ b/libxfce4ui/xfce-sm-client.h
@@ -74,44 +74,7 @@ typedef enum
XFCE_SM_CLIENT_SHUTDOWN_HINT_REBOOT,
} XfceSMClientShutdownHint;
-typedef struct _XfceSMClient XfceSMClient;
-typedef struct _XfceSMClientClass XfceSMClientClass;
-typedef struct _XfceSMClientPrivate XfceSMClientPrivate;
-
-struct _XfceSMClient
-{
- GObject parent;
-
- /*< private >*/
- XfceSMClientPrivate *priv;
-};
-
-struct _XfceSMClientClass
-{
- GObjectClass parent;
-
- /*< signals >*/
-
- void (*save_state)(XfceSMClient *sm_client);
- void (*save_state_extended)(XfceSMClient *sm_client);
-
- /* return TRUE to cancel shutdown */
- gboolean (*quit_requested)(XfceSMClient *sm_client);
-
- void (*quit)(XfceSMClient *sm_client);
-
- void (*quit_cancelled)(XfceSMClient *sm_client);
-
- void (*state_changed)(XfceSMClient *sm_client,
- XfceSMClientState old_state,
- XfceSMClientState new_state);
-
- void (*_xfce_reserved0)(void);
- void (*_xfce_reserved1)(void);
- void (*_xfce_reserved2)(void);
- void (*_xfce_reserved3)(void);
-};
-
+typedef struct _XfceSMClient XfceSMClient;
GType xfce_sm_client_get_type(void) G_GNUC_CONST;
More information about the Xfce4-commits
mailing list