2
* Copyright (c) 2003 Benedikt Meurer <benedikt.meurer@unix-ag.uni-siegen.de>
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
9
* 1. Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* 2. Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
15
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
#include <X11/ICE/ICElib.h>
32
#include <X11/ICE/ICEutil.h>
33
#include <X11/SM/SMlib.h>
36
#include <libxfce4util/i18n.h>
37
#include <libxfce4util/util.h>
38
#include <libxfcegui4/netk-util.h>
41
#include <xfce4-session/client.h>
42
#include <xfce4-session/manager.h>
43
#include <xfce4-session/splash-screen.h>
44
#include <xfce4-session/startup.h>
46
/* list of clients to restore */
47
GList *pendingClients = NULL;
50
static guint pendingTimeoutId = 0;
53
static GtkWidget *splash = NULL;
56
gchar *startupSplashTheme = NULL;
59
#define PENDING_TIMEOUT (5 * 1000)
66
gtk_widget_destroy(splash);
71
* Run ~/Desktop/Autostart/ stuff
74
pending_Autostart(void)
79
gchar *argv[] = { NULL, NULL };
83
dir = xfce_get_homefile("Desktop", "Autostart", NULL);
86
if ((dp = g_dir_open(dir, 0, NULL)) != NULL) {
87
while ((entry = g_dir_read_name(dp)) != NULL) {
88
*argv = g_build_filename(dir, entry, NULL);
91
if (g_spawn_async(NULL, argv, NULL, 0, NULL, NULL, NULL,
96
g_warning("Unable to launch %s: %s", *argv,
110
g_timeout_add(timer * 400, (GSourceFunc)destroy_splash, NULL);
120
pending_timeout(Client *client)
122
/* client startup timed out */
124
g_warning("client %s timed out", client->id);
125
pending_continue(client);
142
/* check if we are finished */
143
if (g_list_length(pendingClients) == 0) {
145
* All session aware apps are up and running,
146
* launch the Autostart stuff.
148
xfsm_splash_screen_set_text(XFSM_SPLASH_SCREEN(splash),
149
_("Doing Autostart..."));
151
g_idle_add((GSourceFunc)pending_Autostart, NULL);
155
/* get next client to fire up */
156
client = CLIENT(g_list_first(pendingClients)->data);
158
/* try to start client */
159
if (!client_run_command(client, SmRestartCommand, &error)) {
160
g_warning("Unable to start client %s: %s", client->id,
164
/* run DiscardCommand */
165
client_run_command(client, SmDiscardCommand, NULL);
168
pendingClients = g_list_remove(pendingClients, client);
171
/* try next client */
175
/* notify the user of what we are doing */
176
if ((program = client_get_program(client)) != NULL) {
177
xfsm_splash_screen_launch(XFSM_SPLASH_SCREEN(splash),
182
/* add startup timeout */
183
pendingTimeoutId = g_timeout_add(PENDING_TIMEOUT,
184
(GSourceFunc)pending_timeout, client);
194
pending_continue(Client *client)
196
if (pendingTimeoutId != 0)
197
g_source_remove(pendingTimeoutId);
199
if (client != NULL) {
200
pendingClients = g_list_remove(pendingClients, client);
203
else if (splash == NULL) {
204
/* Ok, start up the splash screen */
205
splash = xfsm_splash_screen_new(startupSplashTheme,
206
g_list_length(pendingClients),
207
_("Starting session manager..."));
209
gtk_widget_show(splash);
211
/* XXX - give time to the splash screen to appear */
212
(void)g_timeout_add(100, (GSourceFunc)pending_timeout, NULL);
216
(void)g_timeout_add(100, (GSourceFunc)pending_launch, NULL);