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 static void save_state(SmClient
*client
)
39 FilerWindow
*filer_window
;
41 Pinboard
*pinboard
= current_pinboard
;
43 GPtrArray
*restart_cmd
= g_ptr_array_new();
45 gchar
*types
[] = { "-t", "-b", "-l", "-r" };
48 sc_get_prop_value(client
, SmProgram
, &program
, &nvals
);
49 g_ptr_array_add(restart_cmd
, program
->value
);
51 g_ptr_array_add(restart_cmd
, "-c");
52 g_ptr_array_add(restart_cmd
, client
->id
);
54 for (list
= all_filer_windows
; list
; list
= list
->next
)
56 filer_window
= (FilerWindow
*)list
->data
;
57 gdk_window_set_role(filer_window
->window
->window
,
58 filer_window
->sym_path
);
59 g_ptr_array_add(restart_cmd
, "-d");
60 g_ptr_array_add(restart_cmd
, filer_window
->sym_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
, (gchar
*) pinboard_get_name());
78 sc_set_list_of_array_prop(client
, SmRestartCommand
,
79 (const gchar
**) restart_cmd
->pdata
, restart_cmd
->len
);
81 g_ptr_array_free(restart_cmd
, TRUE
);
84 /* Callbacks for various SM messages */
86 static gboolean
save_yourself(SmClient
*client
)
92 static void die(SmClient
*client
)
97 void session_init(const gchar
*client_id
)
104 if (!sc_session_up())
108 bin_path
= g_strconcat(app_dir
, "/AppRun", NULL
);
109 clone_cmd
[0] = bin_path
,
112 client
= sc_new(client_id
);
114 if (!sc_connect(client
))
120 sc_set_array_prop(client
, SmProgram
, bin_path
);
121 sc_set_array_prop(client
, SmUserID
, pw
->pw_name
);
122 sc_set_list_of_array_prop(client
, SmCloneCommand
,
123 (const gchar
**) clone_cmd
, 2);
124 sc_set_card_prop(client
, SmRestartStyleHint
, SmRestartIfRunning
);
126 client
->save_yourself_fn
= &save_yourself
;
127 client
->shutdown_cancelled_fn
= NULL
;
128 client
->save_complete_fn
= NULL
;
129 client
->die_fn
= &die
;