1
/* $Id: xfsm-compat-gnome.c 4714 2004-11-02 16:52:58Z benny $ */
3
* Copyright (c) 2004 Benedikt Meurer <benny@xfce.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2, or (at your option)
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21
* Most parts of this file where taken from gnome-session.
28
#ifdef HAVE_SYS_TYPES_H
29
#include <sys/types.h>
31
#ifdef HAVE_SYS_WAIT_H
48
#include <X11/Xatom.h>
53
#include <libxfce4util/libxfce4util.h>
56
#include <libgnome/libgnome.h>
57
#include <gconf/gconf-client.h>
60
#include <xfce4-session/xfsm-compat-gnome.h>
64
#define ACCESSIBILITY_KEY "/desktop/gnome/interface/accessibility"
65
#define AT_STARTUP_KEY "/desktop/gnome/accessibility/startup/exec_ats"
67
static GConfClient *gnome_conf_client = NULL;
71
static pid_t gnome_keyring_daemon_pid = 0;
72
static Window gnome_smproxy_window = None;
76
gnome_keyring_daemon_startup (void)
86
// FIXME: use async spawn!
87
g_spawn_command_line_sync ("gnome-keyring-daemon",
88
&sout, NULL, &status, &error);
92
g_printerr ("Failed to run gnome-keyring-daemon: %s\n",
98
if (WIFEXITED (status) && WEXITSTATUS (status) == 0 && sout != NULL)
100
lines = g_strsplit (sout, "\n", 3);
102
if (lines[0] != NULL && lines[1] != NULL
103
&& g_str_has_prefix (lines[1], "GNOME_KEYRING_PID="))
105
pid_str = lines[1] + strlen ("GNOME_KEYRING_PID=");
106
pid = strtol (pid_str, &end, 10);
110
gnome_keyring_daemon_pid = pid;
111
xfce_putenv (lines[0]);
119
/* daemon failed for some reason */
120
g_printerr ("gnome-keyring-daemon failed to start correctly, "
121
"exit code: %d\n", WEXITSTATUS (status));
129
gnome_keyring_daemon_shutdown (void)
131
if (gnome_keyring_daemon_pid != 0)
133
kill (gnome_keyring_daemon_pid, SIGTERM);
134
gnome_keyring_daemon_pid = 0;
141
gnome_ast_startup (void)
143
GError *error = NULL;
148
list = gconf_client_get_list (gnome_conf_client, AT_STARTUP_KEY,
149
GCONF_VALUE_STRING, &error);
153
g_warning ("Failed to query value of " AT_STARTUP_KEY ": %s",
155
g_error_free (error);
159
for (lp = list; lp != NULL; lp = lp->next)
161
path = g_find_program_in_path ((const gchar *) lp->data);
164
g_spawn_command_line_async (path, &error);
167
g_warning ("Failed to execute assistive helper %s: %s",
168
path, error->message);
169
g_error_free (error);
173
/* give it some time to fire up */
174
g_usleep (50 * 1000);
187
xfsm_compat_gnome_smproxy_startup (void)
193
gdk_error_trap_push ();
195
/* Set GNOME_SM_PROXY property, since some apps (like OOo) seem to require
196
* it to behave properly. Thanks to Jasper/Francois for reporting this.
197
* This has another advantage, since it prevents people from running
198
* gnome-smproxy in xfce4, which would cause trouble otherwise.
201
root = RootWindow (dpy, 0);
203
if (gnome_smproxy_window != None)
204
XDestroyWindow (dpy, gnome_smproxy_window);
206
gnome_sm_proxy = XInternAtom (dpy, "GNOME_SM_PROXY", False);
207
gnome_smproxy_window = XCreateSimpleWindow (dpy, root, 1, 1, 1, 1, 0, 0, 0);
209
XChangeProperty (dpy, gnome_smproxy_window, gnome_sm_proxy,
210
XA_CARDINAL, 32, PropModeReplace,
211
(unsigned char *) (void *) &gnome_smproxy_window, 1);
212
XChangeProperty (dpy, root, gnome_sm_proxy,
213
XA_CARDINAL, 32, PropModeReplace,
214
(unsigned char *) (void *) &gnome_smproxy_window, 1);
218
gdk_error_trap_pop ();
223
xfsm_compat_gnome_smproxy_shutdown (void)
225
gdk_error_trap_push ();
227
if (gnome_smproxy_window != None)
229
XDestroyWindow (gdk_display, gnome_smproxy_window);
230
XSync (gdk_display, False);
231
gnome_smproxy_window = None;
234
gdk_error_trap_pop ();
239
xfsm_compat_gnome_startup (XfsmSplashScreen *splash)
241
xfsm_compat_gnome_smproxy_startup ();
243
/* fire up the keyring daemon */
244
if (G_LIKELY (splash != NULL))
245
xfsm_splash_screen_next (splash, _("Starting The Gnome Keyring Daemon"));
246
gnome_keyring_daemon_startup ();
249
/* connect to the GConf daemon */
250
gnome_conf_client = gconf_client_get_default ();
251
if (gnome_conf_client != NULL)
253
if (gconf_client_get_bool (gnome_conf_client, ACCESSIBILITY_KEY, NULL))
255
if (G_LIKELY (splash != NULL))
257
xfsm_splash_screen_next (splash, _("Starting Gnome Assistive Technologies"));
260
gnome_ast_startup ();
268
xfsm_compat_gnome_shutdown (void)
270
GError *error = NULL;
273
/* shutdown the keyring daemon */
274
gnome_keyring_daemon_shutdown ();
277
if (gnome_conf_client != NULL)
279
g_object_unref (G_OBJECT (gnome_conf_client));
280
gnome_conf_client = NULL;
284
/* shutdown the GConf daemon */
285
if (!g_spawn_command_line_sync ("gconftool-2 --shutdown", NULL,
286
NULL, &status, &error))
288
g_warning ("Failed to shutdown the GConf daemon on logout: %s",
290
g_error_free (error);
292
else if (status != 0)
294
g_warning ("Failed to shutdown the GConf daemon on logout: "
295
"gconftool-2 returned status %d", status);
298
xfsm_compat_gnome_smproxy_shutdown ();