1
/* $Id: session.c 4782 2005-01-22 17:55:32Z benny $ */
3
* Copyright (c) 2003-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
34
#include <libxfce4mcs/mcs-manager.h>
35
#include <libxfce4util/libxfce4util.h>
36
#include <libxfcegui4/libxfcegui4.h>
37
#include <xfce-mcs-manager/manager-plugin.h>
46
static GtkWidget *dialog = NULL;
47
static GtkWidget *general_chooser;
48
static GtkWidget *general_autosave;
49
static GtkWidget *general_prompt;
50
static GtkWidget *advanced_kde;
51
static GtkWidget *advanced_gnome;
52
static GtkWidget *advanced_remote;
53
static GtkTooltips *tooltips;
54
static gboolean kiosk_can_chooser;
55
static gboolean kiosk_can_logout;
56
static gboolean kiosk_can_compat;
57
static gboolean kiosk_can_security;
65
config_open (gboolean readonly)
67
return xfce_rc_config_open (XFCE_RESOURCE_CONFIG,
68
"xfce4-session/xfce4-session.rc",
78
g_return_if_fail (dialog != NULL);
80
rc = config_open (FALSE);
82
xfce_rc_set_group (rc, "General");
83
if (G_LIKELY (kiosk_can_logout))
85
xfce_rc_write_bool_entry (rc, "AutoSave", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (general_autosave)));
86
xfce_rc_write_bool_entry (rc, "PromptOnLogout", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (general_prompt)));
88
if (G_LIKELY (kiosk_can_security))
90
xfce_rc_write_bool_entry (rc, "DisableTcp", !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (advanced_remote)));
93
if (G_LIKELY (kiosk_can_compat))
95
xfce_rc_set_group (rc, "Compatibility");
96
xfce_rc_write_bool_entry (rc, "LaunchGnome", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (advanced_gnome)));
97
xfce_rc_write_bool_entry (rc, "LaunchKDE", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (advanced_kde)));
100
if (G_LIKELY (kiosk_can_chooser))
102
xfce_rc_set_group (rc, "Chooser");
103
xfce_rc_write_bool_entry (rc, "AlwaysDisplay", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (general_chooser)));
115
general_create (XfceRc *rc)
124
xfce_rc_set_group (rc, "General");
125
autosave = xfce_rc_read_bool_entry (rc, "AutoSave", FALSE);
126
prompt = xfce_rc_read_bool_entry (rc, "PromptOnLogout", TRUE);
127
xfce_rc_set_group (rc, "Chooser");
128
chooser = xfce_rc_read_bool_entry (rc, "AlwaysDisplay", FALSE);
130
page = gtk_vbox_new (FALSE, BORDER);
131
gtk_container_set_border_width (GTK_CONTAINER (page), BORDER);
133
frame = xfce_framebox_new (_("Session chooser"), TRUE);
134
gtk_box_pack_start (GTK_BOX (page), frame, FALSE, TRUE, 0);
135
vbox = gtk_vbox_new (FALSE, 0);
136
xfce_framebox_add (XFCE_FRAMEBOX (frame), vbox);
138
general_chooser = gtk_check_button_new_with_label (_("Display chooser "
140
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (general_chooser), chooser);
141
g_signal_connect (G_OBJECT (general_chooser), "toggled",
142
G_CALLBACK (config_store), NULL);
143
gtk_widget_set_sensitive (general_chooser, kiosk_can_chooser);
144
gtk_box_pack_start (GTK_BOX (vbox), general_chooser, FALSE, TRUE, 0);
145
gtk_tooltips_set_tip (tooltips, general_chooser,
146
_("If set, the session manager will ask you to choose "
147
"a session every time you log in to Xfce."),
150
frame = xfce_framebox_new (_("Logout settings"), TRUE);
151
gtk_box_pack_start (GTK_BOX (page), frame, FALSE, TRUE, 0);
152
vbox = gtk_vbox_new (FALSE, 0);
153
gtk_widget_set_sensitive (vbox, kiosk_can_logout);
154
xfce_framebox_add (XFCE_FRAMEBOX (frame), vbox);
156
general_autosave = gtk_check_button_new_with_label (_("Automatically save session on logout"));
157
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (general_autosave), autosave);
158
g_signal_connect (G_OBJECT (general_autosave), "toggled",
159
G_CALLBACK (config_store), NULL);
160
gtk_box_pack_start (GTK_BOX (vbox), general_autosave, FALSE, TRUE, 0);
161
gtk_tooltips_set_tip (tooltips, general_autosave,
162
_("This option instructs the session manager to "
163
"save the current session automatically when "
164
"you log out. If you don't select this option "
165
"you'll be prompted whether you want to save "
166
"the current session on each logout."),
169
general_prompt = gtk_check_button_new_with_label (_("Prompt on logout"));
170
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (general_prompt), prompt);
171
g_signal_connect (G_OBJECT (general_prompt), "toggled",
172
G_CALLBACK (config_store), NULL);
173
gtk_box_pack_start (GTK_BOX (vbox), general_prompt, FALSE, TRUE, 0);
174
gtk_tooltips_set_tip (tooltips, general_prompt,
175
_("This option disables the logout confirmation "
176
"dialog. Whether the session will be saved or not "
177
"depends on whether you enabled the automatic "
178
"saving of sessions on logout or not."),
190
advanced_create (XfceRc *rc)
202
xfce_rc_set_group (rc, "Compatibility");
203
gnome = xfce_rc_read_bool_entry (rc, "LaunchGnome", FALSE);
204
kde = xfce_rc_read_bool_entry (rc, "LaunchKDE", FALSE);
205
xfce_rc_set_group (rc, "General");
206
remote = !xfce_rc_read_bool_entry (rc, "DisableTcp", TRUE);
208
page = gtk_vbox_new (FALSE, BORDER);
209
gtk_container_set_border_width (GTK_CONTAINER (page), BORDER);
211
frame = xfce_framebox_new (_("Compatibility"), TRUE);
212
gtk_box_pack_start (GTK_BOX (page), frame, FALSE, TRUE, 0);
213
hbox = gtk_hbox_new (FALSE, 0);
214
xfce_framebox_add (XFCE_FRAMEBOX (frame), hbox);
216
vbox = gtk_vbox_new (FALSE, 0);
217
gtk_widget_set_sensitive (vbox, kiosk_can_compat);
218
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
220
advanced_gnome = gtk_check_button_new_with_label (_("Launch Gnome services on startup"));
221
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (advanced_gnome), gnome);
222
g_signal_connect (G_OBJECT (advanced_gnome), "toggled",
223
G_CALLBACK (config_store), NULL);
224
gtk_box_pack_start (GTK_BOX (vbox), advanced_gnome, FALSE, TRUE, 0);
225
gtk_tooltips_set_tip (tooltips, advanced_gnome,
226
_("Enable this if you plan to use Gnome applications. "
227
"This will instruct the session manager to start "
228
"some vital Gnome services for you. You should "
229
"also enable this if you want to use the Assistive "
230
"Technologies that ship with Gnome."),
233
advanced_kde = gtk_check_button_new_with_label (_("Launch KDE services on startup"));
234
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (advanced_kde), kde);
235
g_signal_connect (G_OBJECT (advanced_kde), "toggled",
236
G_CALLBACK (config_store), NULL);
237
gtk_box_pack_start (GTK_BOX (vbox), advanced_kde, FALSE, TRUE, 0);
238
gtk_tooltips_set_tip (tooltips, advanced_kde,
239
_("Enable this option if you plan to run KDE "
240
"applications as part of your Xfce Desktop session. "
241
"This will notably increase the startup time, but "
242
"on the other hand, KDE applications will startup "
243
"faster. Some KDE applications may not work at all "
244
"if you don't enable this option."),
247
icon = xfce_themed_icon_load ("xfsm-gnome-kde-logo", 64);
248
image = gtk_image_new_from_pixbuf (icon);
249
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
250
g_object_unref (icon);
252
frame = xfce_framebox_new (_("Security"), TRUE);
253
gtk_box_pack_start (GTK_BOX (page), frame, FALSE, TRUE, 0);
254
vbox = gtk_vbox_new (FALSE, 0);
255
xfce_framebox_add (XFCE_FRAMEBOX (frame), vbox);
257
advanced_remote = gtk_check_button_new_with_label (_("Manage remote applications"));
258
#ifdef HAVE__ICETRANSNOLISTEN
259
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (advanced_remote), remote);
260
gtk_widget_set_sensitive (advanced_remote, kiosk_can_security);
262
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (advanced_remote), TRUE);
263
gtk_widget_set_sensitive (advanced_remote, FALSE);
265
g_signal_connect (G_OBJECT (advanced_remote), "toggled",
266
G_CALLBACK (config_store), NULL);
267
gtk_box_pack_start (GTK_BOX (vbox), advanced_remote, FALSE, TRUE, 0);
268
gtk_tooltips_set_tip (tooltips, advanced_remote,
269
_("Allow the session manager to manage applications "
270
"running on remote hosts. Do not enable this "
271
"option unless you know what you are doing."),
283
dialog_response (void)
287
gtk_widget_destroy (dialog);
291
if (tooltips != NULL)
293
gtk_object_destroy (GTK_OBJECT (tooltips));
302
dialog_run (McsPlugin *plugin)
314
gtk_window_present (GTK_WINDOW (dialog));
318
xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
320
kiosk = xfce_kiosk_new ("xfce4-session");
321
kiosk_can_chooser = xfce_kiosk_query (kiosk, "Chooser");
322
kiosk_can_logout = xfce_kiosk_query (kiosk, "Logout");
323
kiosk_can_compat = xfce_kiosk_query (kiosk, "Compatibility");
324
kiosk_can_security = xfce_kiosk_query (kiosk, "Security");
325
xfce_kiosk_free (kiosk);
326
tooltips = gtk_tooltips_new ();
328
rc = config_open (TRUE);
330
dialog = gtk_dialog_new_with_buttons (_("Sessions and Startup"),
332
GTK_DIALOG_NO_SEPARATOR,
333
GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
336
gtk_window_set_icon (GTK_WINDOW (dialog), plugin->icon);
338
g_signal_connect (G_OBJECT (dialog), "response",
339
G_CALLBACK (dialog_response), NULL);
340
g_signal_connect (G_OBJECT (dialog), "delete-event",
341
G_CALLBACK (dialog_response), NULL);
343
dbox = GTK_DIALOG (dialog)->vbox;
345
header = xfce_create_header (plugin->icon, _("Sessions and Startup"));
346
gtk_box_pack_start (GTK_BOX (dbox), header, FALSE, TRUE, 0);
347
gtk_widget_show (header);
349
notebook = gtk_notebook_new ();
350
gtk_box_pack_start (GTK_BOX (dbox), notebook, TRUE, TRUE, 0);
351
gtk_widget_show (notebook);
352
gtk_container_set_border_width (GTK_CONTAINER (notebook), 6);
354
label = gtk_label_new (_("General"));
355
page = general_create (rc);
356
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label);
357
gtk_widget_show_all (page);
358
gtk_widget_show (label);
360
label = gtk_label_new (_("Advanced"));
361
page = advanced_create (rc);
362
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label);
363
gtk_widget_show_all (page);
364
gtk_widget_show (label);
366
xfce_gtk_window_center_on_monitor_with_pointer (GTK_WINDOW (dialog));
367
gtk_widget_show (dialog);
378
mcs_plugin_init (McsPlugin *plugin)
380
xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
382
plugin->plugin_name = g_strdup ("session");
383
plugin->caption = g_strdup (_("Sessions and Startup"));
384
plugin->run_dialog = dialog_run;
385
plugin->icon = xfce_themed_icon_load ("xfce4-session", 48);
387
return MCS_PLUGIN_INIT_OK;
391
MCS_PLUGIN_CHECK_INIT;