4 * ROX-Filer, filer for the ROX desktop project
5 * Copyright (C) 2003, 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>
39 static void save_state(SmClient
*client
)
41 FilerWindow
*filer_window
;
43 Pinboard
*pinboard
= current_pinboard
;
45 GPtrArray
*restart_cmd
= g_ptr_array_new();
47 gchar
*types
[] = { "-t", "-b", "-l", "-r" };
50 sc_get_prop_value(client
, SmProgram
, &program
, &nvals
);
51 g_ptr_array_add(restart_cmd
, program
->value
);
53 g_ptr_array_add(restart_cmd
, "-c");
54 g_ptr_array_add(restart_cmd
, client
->id
);
56 for (list
= all_filer_windows
; list
; list
= list
->next
)
58 filer_window
= (FilerWindow
*)list
->data
;
59 gdk_window_set_role(filer_window
->window
->window
,
60 filer_window
->sym_path
);
61 g_ptr_array_add(restart_cmd
, "-d");
62 g_ptr_array_add(restart_cmd
, filer_window
->sym_path
);
65 for(i
= 0; i
< PANEL_NUMBER_OF_SIDES
; i
++)
67 panel
= current_panel
[i
];
70 g_ptr_array_add(restart_cmd
, types
[panel
->side
]);
71 g_ptr_array_add(restart_cmd
, panel
->name
);
76 g_ptr_array_add(restart_cmd
, "-p");
77 g_ptr_array_add(restart_cmd
, (gchar
*) pinboard_get_name());
80 sc_set_list_of_array_prop(client
, SmRestartCommand
,
81 (const gchar
**) restart_cmd
->pdata
, restart_cmd
->len
);
83 g_ptr_array_free(restart_cmd
, TRUE
);
86 /* Callbacks for various SM messages */
88 static gboolean
save_yourself(SmClient
*client
)
94 static void die(SmClient
*client
)
99 void session_init(const gchar
*client_id
)
106 if (!sc_session_up())
110 bin_path
= g_strconcat(app_dir
, "/AppRun", NULL
);
111 clone_cmd
[0] = bin_path
,
114 client
= sc_new(client_id
);
116 if (!sc_connect(client
))
122 sc_set_array_prop(client
, SmProgram
, bin_path
);
123 sc_set_array_prop(client
, SmUserID
, pw
->pw_name
);
124 sc_set_list_of_array_prop(client
, SmCloneCommand
,
125 (const gchar
**) clone_cmd
, 2);
126 sc_set_card_prop(client
, SmRestartStyleHint
, SmRestartIfRunning
);
128 client
->save_yourself_fn
= &save_yourself
;
129 client
->shutdown_cancelled_fn
= NULL
;
130 client
->save_complete_fn
= NULL
;
131 client
->die_fn
= &die
;