[Xfce4-commits] <libxfce4ui:new-sm-client> handle SmDiscardCommand automatically and hide it from the API
Brian J. Tarricone
noreply at xfce.org
Sat Sep 19 11:38:03 CEST 2009
Updating branch refs/heads/kelnos/new-sm-client
to 1bef907e54369a3b08bedc15bb8d347983d2399b (commit)
from b23f7ed1ed86c8da300577b74d4098fe49850083 (commit)
commit 1bef907e54369a3b08bedc15bb8d347983d2399b
Author: Brian J. Tarricone <brian at tarricone.org>
Date: Sat Sep 19 02:35:34 2009 -0700
handle SmDiscardCommand automatically and hide it from the API
âPerfection is reached not when there's nothing left to add, but when
there's nothing left to remove.â
--Antoine de Saint-Exupery
docs/libxfce4ui-sections.txt | 2 -
docs/tmpl/xfce-sm-client.sgml | 24 ----------
libxfce4ui/libxfce4ui.symbols | 2 -
libxfce4ui/xfce-sm-client.c | 102 +++++++++--------------------------------
libxfce4ui/xfce-sm-client.h | 7 +--
5 files changed, 23 insertions(+), 114 deletions(-)
diff --git a/docs/libxfce4ui-sections.txt b/docs/libxfce4ui-sections.txt
index 0cb1f5d..439563a 100644
--- a/docs/libxfce4ui-sections.txt
+++ b/docs/libxfce4ui-sections.txt
@@ -90,8 +90,6 @@ xfce_sm_client_get_client_id
xfce_sm_client_get_state_file
xfce_sm_client_get_current_directory
xfce_sm_client_set_current_directory
-xfce_sm_client_get_discard_command
-xfce_sm_client_set_discard_command
xfce_sm_client_get_priority
xfce_sm_client_set_priority
xfce_sm_client_get_restart_command
diff --git a/docs/tmpl/xfce-sm-client.sgml b/docs/tmpl/xfce-sm-client.sgml
index ec066fe..ef27ad5 100644
--- a/docs/tmpl/xfce-sm-client.sgml
+++ b/docs/tmpl/xfce-sm-client.sgml
@@ -85,11 +85,6 @@
</para>
-<!-- ##### ARG XfceSMClient:discard-command ##### -->
-<para>
-
-</para>
-
<!-- ##### ARG XfceSMClient:priority ##### -->
<para>
@@ -179,7 +174,6 @@
@resumed_client_id:
@current_directory:
@restart_command:
- at discard_command:
@Returns:
@@ -264,24 +258,6 @@
@current_directory:
-<!-- ##### FUNCTION xfce_sm_client_get_discard_command ##### -->
-<para>
-
-</para>
-
- at sm_client:
- at Returns:
-
-
-<!-- ##### FUNCTION xfce_sm_client_set_discard_command ##### -->
-<para>
-
-</para>
-
- at sm_client:
- at discard_command:
-
-
<!-- ##### FUNCTION xfce_sm_client_get_priority ##### -->
<para>
diff --git a/libxfce4ui/libxfce4ui.symbols b/libxfce4ui/libxfce4ui.symbols
index c7a22e8..e072770 100644
--- a/libxfce4ui/libxfce4ui.symbols
+++ b/libxfce4ui/libxfce4ui.symbols
@@ -113,8 +113,6 @@ xfce_sm_client_set_priority
xfce_sm_client_get_priority
xfce_sm_client_set_restart_command
xfce_sm_client_get_restart_command
-xfce_sm_client_set_discard_command
-xfce_sm_client_get_discard_command
#endif
#endif
diff --git a/libxfce4ui/xfce-sm-client.c b/libxfce4ui/xfce-sm-client.c
index 8285b2b..0efd0df 100644
--- a/libxfce4ui/xfce-sm-client.c
+++ b/libxfce4ui/xfce-sm-client.c
@@ -153,7 +153,6 @@ struct _XfceSMClient
gchar *program;
gchar **clone_command;
gchar **restart_command;
- gchar **discard_command;
guint32 resumed:1,
needs_save_state:1,
@@ -209,7 +208,6 @@ enum
PROP_CLIENT_ID,
PROP_CURRENT_DIRECTORY,
PROP_RESTART_COMMAND,
- PROP_DISCARD_COMMAND,
PROP_DESKTOP_FILE,
PROP_ARGC,
PROP_ARGV,
@@ -403,12 +401,6 @@ xfce_sm_client_class_init(XfceSMClientClass *klass)
"A command used to restart this application, preserving the current state",
G_TYPE_STRV,
G_PARAM_READWRITE));
- g_object_class_install_property(gobject_class, PROP_DISCARD_COMMAND,
- g_param_spec_boxed("discard-command",
- "Discard command",
- "A command used to discard any information about the current saved state",
- G_TYPE_STRV,
- G_PARAM_READWRITE));
g_object_class_install_property(gobject_class, PROP_DESKTOP_FILE,
g_param_spec_string("desktop-file",
"Desktop file",
@@ -470,10 +462,6 @@ xfce_sm_client_get_property(GObject *obj,
g_value_set_boxed(value, sm_client->restart_command);
break;
- case PROP_DISCARD_COMMAND:
- g_value_set_boxed(value, sm_client->discard_command);
- break;
-
case PROP_DESKTOP_FILE:
g_value_set_string(value, sm_client->desktop_file);
break;
@@ -517,11 +505,6 @@ xfce_sm_client_set_property(GObject *obj,
g_value_get_boxed(value));
break;
- case PROP_DISCARD_COMMAND:
- xfce_sm_client_set_discard_command(sm_client,
- g_value_get_boxed(value));
- break;
-
case PROP_DESKTOP_FILE:
xfce_sm_client_set_desktop_file(sm_client,
g_value_get_string(value));
@@ -590,7 +573,6 @@ xfce_sm_client_finalize(GObject *obj)
g_free(sm_client->current_directory);
g_strfreev(sm_client->clone_command);
g_strfreev(sm_client->restart_command);
- g_strfreev(sm_client->discard_command);
g_strfreev(sm_client->argv);
@@ -1333,9 +1315,17 @@ xfce_sm_client_set_clone_restart_commands(XfceSMClient *sm_client)
SM_ARG_REMOVE);
/* Discard */
- xfce_sm_client_set_property_from_command(sm_client, SmDiscardCommand,
- sm_client->discard_command,
- FALSE);
+ if(sm_client->state_file) {
+ gchar *discard_command[4];
+ gint i = 0;
+
+ discard_command[i++] = "rm";
+ discard_command[i++] = "-rf";
+ discard_command[i++] = sm_client->state_file;
+ discard_command[i++] = NULL;
+ xfce_sm_client_set_property_from_command(sm_client, SmDiscardCommand,
+ discard_command, FALSE);
+ }
}
#endif
@@ -1465,8 +1455,6 @@ xfce_sm_client_get_with_argv(guint argc,
* @current_directory: The application's working directory
* @restart_command: A command that can resume the application's
* saved state
- * @discard_command: A command that cleans up the application's
- * state when removed from the session
*
* Creates a new SM client instance, allowing the application
* fine-grained control over the initial properties set.
@@ -1486,8 +1474,7 @@ xfce_sm_client_get_full(XfceSMClientRestartStyle restart_style,
gchar priority,
const gchar *resumed_client_id,
const gchar *current_directory,
- const gchar **restart_command,
- const gchar **discard_command)
+ const gchar **restart_command)
{
return g_object_new(XFCE_TYPE_SM_CLIENT,
"restart-style", restart_style,
@@ -1495,7 +1482,6 @@ xfce_sm_client_get_full(XfceSMClientRestartStyle restart_style,
"client-id", resumed_client_id,
"current-directory", current_directory,
"restart-command", restart_command,
- "discard-command", discard_command,
NULL);
}
@@ -2032,34 +2018,6 @@ xfce_sm_client_set_restart_command(XfceSMClient *sm_client,
}
/**
- * xfce_sm_client_set_discard_command:
- * @sm_client: An #XfceSMClient
- * @discard_command: An argument vector
- *
- * Sets the application's "restart" command, which is used to restart
- * the application and restore any saved state from the previous
- * run.
- *
- * If unset, defaults to the command used to start this instance
- * of the application, with session management related arguments
- * added (if not already present).
- **/
-void
-xfce_sm_client_set_discard_command(XfceSMClient *sm_client,
- gchar **discard_command)
-{
- g_return_if_fail(XFCE_IS_SM_CLIENT(sm_client));
- 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->discard_command,
- FALSE);
-#endif
- g_object_notify(G_OBJECT(sm_client), "discard-command");
-}
-
-/**
* xfce_sm_client_get_restart_style:
* @sm_client: An #XfceSMClient
*
@@ -2133,7 +2091,7 @@ xfce_sm_client_get_client_id(XfceSMClient *sm_client)
* the state can be restored from the file.
*
* This function will use a standard location and naming scheme
- * as handle state cleanup (setting of the discard command) for you.
+ * and handle state cleanup (setting of the discard command) for you.
*
* Before calling this function, the application must have a
* valid program identifier set (see xfce_sm_client_set_program())
@@ -2175,18 +2133,18 @@ xfce_sm_client_get_state_file(XfceSMClient *sm_client)
g_free(resource);
#ifdef HAVE_LIBSM
- if(G_LIKELY(sm_client->state_file)
- && sm_client->session_connection
- && !sm_client->discard_command)
+ if(G_LIKELY(sm_client->state_file) && sm_client->session_connection)
{
- 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);
+ gchar *discard_command[4];
+ gint i = 0;
+
+ discard_command[i++] = "rm";
+ discard_command[i++] = "-rf";
+ discard_command[i++] = sm_client->state_file;
+ discard_command[i++] = NULL;
xfce_sm_client_set_property_from_command(sm_client, SmDiscardCommand,
- sm_client->discard_command,
- FALSE);
+ discard_command, FALSE);
}
#endif
@@ -2224,19 +2182,3 @@ xfce_sm_client_get_restart_command(XfceSMClient *sm_client)
g_return_val_if_fail(XFCE_IS_SM_CLIENT(sm_client), NULL);
return sm_client->restart_command;
}
-
-/**
- * xfce_sm_client_get_discard_command:
- * @sm_client: An #XfceSMClient
- *
- * Retrieves the session client's discard command. See
- * xfce_sm_client_set_discard_command() for more information.
- *
- * Returns: an object-owned string vector
- **/
-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->discard_command;
-}
diff --git a/libxfce4ui/xfce-sm-client.h b/libxfce4ui/xfce-sm-client.h
index e143a0d..a8ed7ef 100644
--- a/libxfce4ui/xfce-sm-client.h
+++ b/libxfce4ui/xfce-sm-client.h
@@ -76,8 +76,7 @@ XfceSMClient *xfce_sm_client_get_full(XfceSMClientRestartStyle restart_style,
gchar priority,
const gchar *resumed_client_id,
const gchar *current_directory,
- const gchar **restart_command,
- const gchar **discard_command);
+ const gchar **restart_command);
gboolean xfce_sm_client_connect(XfceSMClient *sm_client,
GError **error);
@@ -111,10 +110,6 @@ void xfce_sm_client_set_restart_command(XfceSMClient *sm_client,
gchar **restart_command);
gchar **xfce_sm_client_get_restart_command(XfceSMClient *sm_client);
-void xfce_sm_client_set_discard_command(XfceSMClient *sm_client,
- gchar **discard_command);
-gchar **xfce_sm_client_get_discard_command(XfceSMClient *sm_client);
-
G_END_DECLS
#endif /* __XFCE_SM_CLIENT_H__ */
More information about the Xfce4-commits
mailing list