1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
diff --git a/libegg/smclient/eggdesktopfile.c b/libegg/smclient/eggdesktopfile.c
index 357e548..c185998 100644
--- a/libegg/smclient/eggdesktopfile.c
+++ b/libegg/smclient/eggdesktopfile.c
@@ -1440,6 +1440,7 @@ egg_set_desktop_file (const char *desktop_file_path)
g_error_free (error);
}
+#if 0
if (egg_desktop_file) {
/* Set localized application name and default window icon */
if (egg_desktop_file->name)
@@ -1452,6 +1453,7 @@ egg_set_desktop_file (const char *desktop_file_path)
gtk_window_set_default_icon_name (egg_desktop_file->icon);
}
}
+#endif
G_UNLOCK (egg_desktop_file);
}
diff --git a/libegg/smclient/eggsmclient-xsmp.c b/libegg/smclient/eggsmclient-xsmp.c
index 1a56156..81af7d2 100644
--- a/libegg/smclient/eggsmclient-xsmp.c
+++ b/libegg/smclient/eggsmclient-xsmp.c
@@ -88,6 +88,8 @@ struct _EggSMClientXSMP
char **restart_command;
gboolean set_restart_command;
int restart_style;
+ char **discard_command;
+ gboolean set_discard_command;
guint idle;
@@ -117,6 +119,9 @@ static void sm_client_xsmp_startup (EggSMClient *client,
static void sm_client_xsmp_set_restart_command (EggSMClient *client,
int argc,
const char **argv);
+static void sm_client_xsmp_set_discard_command (EggSMClient *client,
+ int argc,
+ const char **argv);
static void sm_client_xsmp_will_quit (EggSMClient *client,
gboolean will_quit);
static gboolean sm_client_xsmp_end_session (EggSMClient *client,
@@ -150,7 +155,7 @@ static SmProp *card8_prop (const char *name,
static void set_properties (EggSMClientXSMP *xsmp, ...);
static void delete_properties (EggSMClientXSMP *xsmp, ...);
-static GPtrArray *generate_command (char **restart_command,
+static GPtrArray *generate_command (char **argv,
const char *client_id,
const char *state_file);
@@ -185,6 +190,7 @@ egg_sm_client_xsmp_class_init (EggSMClientXSMPClass *klass)
sm_client_class->startup = sm_client_xsmp_startup;
sm_client_class->set_restart_command = sm_client_xsmp_set_restart_command;
+ sm_client_class->set_discard_command = sm_client_xsmp_set_discard_command;
sm_client_class->will_quit = sm_client_xsmp_will_quit;
sm_client_class->end_session = sm_client_xsmp_end_session;
}
@@ -404,6 +410,24 @@ sm_client_xsmp_set_restart_command (EggSMClient *client,
}
static void
+sm_client_xsmp_set_discard_command (EggSMClient *client,
+ int argc,
+ const char **argv)
+{
+ EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
+ int i;
+
+ g_strfreev (xsmp->discard_command);
+
+ xsmp->discard_command = g_new (char *, argc + 1);
+ for (i = 0; i < argc; i++)
+ xsmp->discard_command[i] = g_strdup (argv[i]);
+ xsmp->discard_command[i] = NULL;
+
+ xsmp->set_discard_command = TRUE;
+}
+
+static void
sm_client_xsmp_will_quit (EggSMClient *client,
gboolean will_quit)
{
@@ -771,7 +795,7 @@ save_state (EggSMClientXSMP *xsmp)
GKeyFile *state_file;
char *state_file_path, *data;
EggDesktopFile *desktop_file;
- GPtrArray *restart;
+ GPtrArray *restart, *discard;
int offset, fd;
/* We set xsmp->state before emitting save_state, but our caller is
@@ -787,7 +811,18 @@ save_state (EggSMClientXSMP *xsmp)
ptrarray_prop (SmRestartCommand, restart),
NULL);
g_ptr_array_free (restart, TRUE);
- delete_properties (xsmp, SmDiscardCommand, NULL);
+
+ if (xsmp->set_discard_command)
+ {
+ discard = generate_command (xsmp->discard_command, NULL, NULL);
+ set_properties (xsmp,
+ ptrarray_prop (SmDiscardCommand, discard),
+ NULL);
+ g_ptr_array_free (discard, TRUE);
+ }
+ else
+ delete_properties (xsmp, SmDiscardCommand, NULL);
+
return;
}
@@ -1041,14 +1076,14 @@ xsmp_shutdown_cancelled (SmcConn smc_conn,
* then free the array, but not its contents.
*/
static GPtrArray *
-generate_command (char **restart_command, const char *client_id,
+generate_command (char **argv, const char *client_id,
const char *state_file)
{
GPtrArray *cmd;
int i;
cmd = g_ptr_array_new ();
- g_ptr_array_add (cmd, restart_command[0]);
+ g_ptr_array_add (cmd, argv[0]);
if (client_id)
{
@@ -1062,8 +1097,8 @@ generate_command (char **restart_command, const char *client_id,
g_ptr_array_add (cmd, (char *)state_file);
}
- for (i = 1; restart_command[i]; i++)
- g_ptr_array_add (cmd, restart_command[i]);
+ for (i = 1; argv[i]; i++)
+ g_ptr_array_add (cmd, argv[i]);
return cmd;
}
diff --git a/libegg/smclient/eggsmclient.c b/libegg/smclient/eggsmclient.c
index efa901d..85aaee4 100644
--- a/libegg/smclient/eggsmclient.c
+++ b/libegg/smclient/eggsmclient.c
@@ -445,6 +445,27 @@ egg_sm_client_set_restart_command (EggSMClient *client,
}
/**
+ * egg_sm_client_set_discard_command:
+ * @client: the client
+ * @argc: the length of @argv
+ * @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
+ * using this function.
+ **/
+void
+egg_sm_client_set_discard_command (EggSMClient *client,
+ int argc,
+ const char **argv)
+{
+ 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);
+}
+
+/**
* egg_sm_client_will_quit:
* @client: the client
* @will_quit: whether or not the application is willing to quit
diff --git a/libegg/smclient/eggsmclient.h b/libegg/smclient/eggsmclient.h
index e620b75..f13bcec 100644
--- a/libegg/smclient/eggsmclient.h
+++ b/libegg/smclient/eggsmclient.h
@@ -72,6 +72,9 @@ struct _EggSMClientClass
void (*set_restart_command) (EggSMClient *client,
int argc,
const char **argv);
+ void (*set_discard_command) (EggSMClient *client,
+ int argc,
+ const char **argv);
void (*will_quit) (EggSMClient *client,
gboolean will_quit);
gboolean (*end_session) (EggSMClient *client,
@@ -102,6 +105,9 @@ GKeyFile *egg_sm_client_get_state_file (EggSMClient *client);
void egg_sm_client_set_restart_command (EggSMClient *client,
int argc,
const char **argv);
+void egg_sm_client_set_discard_command (EggSMClient *client,
+ int argc,
+ const char **argv);
/* Handling "quit_requested" signal */
void egg_sm_client_will_quit (EggSMClient *client,
|