4 * ROX-Filer, filer for the ROX desktop project
5 * Copyright (C) 2002, 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
,
60 g_ptr_array_add(restart_cmd
, "-d");
61 g_ptr_array_add(restart_cmd
, filer_window
->path
);
64 for(i
= 0; i
< PANEL_NUMBER_OF_SIDES
; i
++)
66 panel
= current_panel
[i
];
69 g_ptr_array_add(restart_cmd
, types
[panel
->side
]);
70 g_ptr_array_add(restart_cmd
, panel
->name
);
75 g_ptr_array_add(restart_cmd
, "-p");
76 g_ptr_array_add(restart_cmd
, pinboard
->name
);
79 sc_set_list_of_array_prop(client
, SmRestartCommand
,
80 (const gchar
**) restart_cmd
->pdata
, restart_cmd
->len
);
82 g_ptr_array_free(restart_cmd
, TRUE
);
85 /* Callbacks for various SM messages */
87 gboolean
save_yourself(SmClient
*client
)
93 void die(SmClient
*client
)
98 void session_init(gchar
*client_id
)
105 if (!sc_session_up())
109 bin_path
= g_strconcat(app_dir
, "/AppRun", NULL
);
110 clone_cmd
[0] = bin_path
,
113 client
= sc_new(client_id
);
115 if (!sc_connect(client
))
121 sc_set_array_prop(client
, SmProgram
, bin_path
);
122 sc_set_array_prop(client
, SmUserID
, pw
->pw_name
);
123 sc_set_list_of_array_prop(client
, SmCloneCommand
,
124 (const gchar
**) clone_cmd
, 2);
125 sc_set_card_prop(client
, SmRestartStyleHint
, SmRestartIfRunning
);
127 client
->save_yourself_fn
= &save_yourself
;
128 client
->shutdown_cancelled_fn
= NULL
;
129 client
->save_complete_fn
= NULL
;
130 client
->die_fn
= &die
;