2 * ROX-Filer, filer for the ROX desktop project
3 * Copyright (C) 2006, Thomas Leonard and others (see changelog for details).
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 * Place, Suite 330, Boston, MA 02111-1307 USA
20 /* session.c - XSMP client support */
27 #include <X11/SM/SMlib.h>
37 #define ROX_FILER_URI "http://rox.sourceforge.net/2005/interfaces/ROX-Filer"
39 static gboolean use_0launch
;
40 gboolean session_auto_respawn
= FALSE
; /* If we were started as 'rox -S' */
42 static void save_state(SmClient
*client
)
44 FilerWindow
*filer_window
;
46 Pinboard
*pinboard
= current_pinboard
;
48 GPtrArray
*restart_cmd
= g_ptr_array_new();
50 gchar
*types
[] = { "-t", "-B", "-l", "-r" };
55 g_ptr_array_add(restart_cmd
, "0launch");
56 g_ptr_array_add(restart_cmd
, ROX_FILER_URI
);
60 sc_get_prop_value(client
, SmProgram
, &program
, &nvals
);
61 g_ptr_array_add(restart_cmd
, program
->value
);
64 g_ptr_array_add(restart_cmd
, "-c");
65 g_ptr_array_add(restart_cmd
, client
->id
);
67 for (list
= all_filer_windows
; list
; list
= list
->next
)
69 filer_window
= (FilerWindow
*)list
->data
;
70 gdk_window_set_role(filer_window
->window
->window
,
71 filer_window
->sym_path
);
72 g_ptr_array_add(restart_cmd
, "-d");
73 g_ptr_array_add(restart_cmd
, filer_window
->sym_path
);
76 if (session_auto_respawn
)
78 for(i
= 0; i
< PANEL_NUMBER_OF_SIDES
; i
++)
80 panel
= current_panel
[i
];
83 g_ptr_array_add(restart_cmd
, types
[panel
->side
]);
84 g_ptr_array_add(restart_cmd
, panel
->name
);
89 g_ptr_array_add(restart_cmd
, "-p");
90 g_ptr_array_add(restart_cmd
, (gchar
*) pinboard_get_name());
95 g_ptr_array_add(restart_cmd
, "-S");
98 sc_set_list_of_array_prop(client
, SmRestartCommand
,
99 (const gchar
**) restart_cmd
->pdata
, restart_cmd
->len
);
101 g_ptr_array_free(restart_cmd
, TRUE
);
104 /* Callbacks for various SM messages */
106 static gboolean
save_yourself(SmClient
*client
)
112 static void die(SmClient
*client
)
117 void session_init(const gchar
*client_id
)
125 if (!sc_session_up())
130 zerolaunch
= g_find_program_in_path("0launch");
131 use_0launch
= (zerolaunch
!= NULL
);
136 bin_path
= "0launch";
137 clone_cmd
[0] = bin_path
;
138 clone_cmd
[1] = ROX_FILER_URI
,
143 bin_path
= g_strconcat(app_dir
, "/AppRun", NULL
);
144 clone_cmd
[0] = bin_path
;
149 client
= sc_new(client_id
);
151 if (!sc_connect(client
))
157 sc_set_array_prop(client
, SmProgram
, bin_path
);
158 sc_set_array_prop(client
, SmUserID
, pw
->pw_name
);
159 sc_set_list_of_array_prop(client
, SmCloneCommand
,
160 (const gchar
**) clone_cmd
,
161 clone_cmd
[2] == NULL
? 2 : 3);
162 sc_set_card_prop(client
, SmRestartStyleHint
,
163 session_auto_respawn
? SmRestartImmediately
: SmRestartIfRunning
);
165 client
->save_yourself_fn
= &save_yourself
;
166 client
->shutdown_cancelled_fn
= NULL
;
167 client
->save_complete_fn
= NULL
;
168 client
->die_fn
= &die
;