Audacious  $Id:Doxyfile42802007-03-2104:39:00Znenolod$
smclient.c
Go to the documentation of this file.
1 /*
2  * Audacious
3  * Copyright (c) 2005-2007 Yoshiki Yazawa
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; under version 3 of the License.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses>.
16  *
17  * The Audacious team does not consider modular code linking to
18  * Audacious or using our public API to be a derived work.
19  */
20 
21 #include <gdk/gdk.h>
22 #include <libaudcore/hook.h>
23 
24 #include "config.h"
25 #include "main.h"
26 
27 #ifdef USE_EGGSM
28 #include "eggsmclient.h"
29 
30 static void
31 signal_session_quit_cb(EggSMClient *client, gpointer user_data)
32 {
33  const char * argv[2];
34 
35  g_print("Session quit requested. Saving state and shutting down.\n");
36 
37  argv[0] = "audacious";
38  argv[1] = g_strdup_printf ("--display=%s", gdk_display_get_name (gdk_display_get_default()));
39  egg_sm_client_set_restart_command (client, 2, argv);
40 
41  hook_call ("quit", NULL);
42 }
43 
44 static void
45 signal_session_save_cb(EggSMClient *client, GKeyFile *state_file, gpointer user_data)
46 {
47  const char * argv[2];
48 
49  g_print("Session save requested. Saving state.\n");
50 
51  argv[0] = "audacious";
52  argv[1] = g_strdup_printf ("--display=%s", gdk_display_get_name (gdk_display_get_default()));
53  egg_sm_client_set_restart_command (client, 2, argv);
54 
55  do_autosave ();
56 }
57 #endif
58 
59 void smclient_init (void)
60 {
61 #ifdef USE_EGGSM
62  EggSMClient *client;
63 
64  client = egg_sm_client_get ();
65  if (client != NULL)
66  {
67  g_signal_connect (client, "quit",
68  G_CALLBACK (signal_session_quit_cb), NULL);
69  g_signal_connect (client, "save-state",
70  G_CALLBACK (signal_session_save_cb), NULL);
71 
72  }
73 #endif
74 }