4 * ROX-Filer, filer for the ROX desktop project
5 * Copyright (C) 2001, the ROX-Filer team.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2 of the License, or (at your option)
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 * Place, Suite 330, Boston, MA 02111-1307 USA
22 /* session.c - XSMP client support */
29 #include <X11/SM/SMlib.h>
38 void save_state(SmClient
*client
)
40 FilerWindow
*filer_window
;
42 Pinboard
*pinboard
= current_pinboard
;
44 GPtrArray
*restart_cmd
= g_ptr_array_new();
46 gchar
*types
[] = { "-t", "-b", "-l", "-r" };
49 sc_get_prop_value(client
, SmProgram
, &program
, &nvals
);
50 g_ptr_array_add(restart_cmd
, program
->value
);
52 g_ptr_array_add(restart_cmd
, "-c");
53 g_ptr_array_add(restart_cmd
, client
->id
);
55 for(list
= all_filer_windows
; list
!= NULL
; list
= g_list_next(list
))
57 filer_window
= (FilerWindow
*)list
->data
;
58 gdk_window_set_role(filer_window
->window
->window
, filer_window
->path
);
59 g_ptr_array_add(restart_cmd
, "-d");
60 g_ptr_array_add(restart_cmd
, filer_window
->path
);
63 for(i
= 0; i
< PANEL_NUMBER_OF_SIDES
; i
++)
65 panel
= current_panel
[i
];
68 g_ptr_array_add(restart_cmd
, types
[panel
->side
]);
69 g_ptr_array_add(restart_cmd
, panel
->name
);
74 g_ptr_array_add(restart_cmd
, "-p");
75 g_ptr_array_add(restart_cmd
, pinboard
->name
);
78 sc_set_list_of_array_prop(client
, SmRestartCommand
,
79 (gchar
**)restart_cmd
->pdata
, restart_cmd
->len
);
81 g_ptr_array_free(restart_cmd
, TRUE
);
84 /* Callbacks for various SM messages */
86 gboolean
save_yourself(SmClient
*client
)
92 void shutdown_cancelled(SmClient
*client
)
96 void save_complete(SmClient
*client
)
100 void die(SmClient
*client
)
105 void session_init(gchar
*client_id
)
112 if (!sc_session_up())
116 bin_path
= g_strconcat(app_dir
, "/AppRun", NULL
);
117 clone_cmd
[0] = bin_path
,
120 client
= sc_new(client_id
);
122 if (!sc_connect(client
))
128 sc_set_array_prop(client
, SmProgram
, bin_path
);
129 sc_set_array_prop(client
, SmUserID
, pw
->pw_name
);
130 sc_set_list_of_array_prop(client
, SmCloneCommand
, clone_cmd
, 2);
131 sc_set_card_prop(client
, SmRestartStyleHint
, SmRestartIfRunning
);
133 client
->save_yourself_fn
= &save_yourself
;
134 client
->shutdown_cancelled_fn
= &shutdown_cancelled
;
135 client
->save_complete_fn
= &save_complete
;
136 client
->die_fn
= &die
;