Audacious
$Id:Doxyfile42802007-03-2104:39:00Znenolod$
|
00001 /* 00002 * Audacious 00003 * Copyright (c) 2005-2007 Yoshiki Yazawa 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; under version 3 of the License. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program. If not, see <http://www.gnu.org/licenses>. 00016 * 00017 * The Audacious team does not consider modular code linking to 00018 * Audacious or using our public API to be a derived work. 00019 */ 00020 00021 #include <gdk/gdk.h> 00022 #include <libaudcore/hook.h> 00023 00024 #include "config.h" 00025 #include "main.h" 00026 00027 #ifdef USE_EGGSM 00028 #include "eggsmclient.h" 00029 00030 static void 00031 signal_session_quit_cb(EggSMClient *client, gpointer user_data) 00032 { 00033 const char * argv[2]; 00034 00035 g_print("Session quit requested. Saving state and shutting down.\n"); 00036 00037 argv[0] = "audacious"; 00038 argv[1] = g_strdup_printf ("--display=%s", gdk_display_get_name (gdk_display_get_default())); 00039 egg_sm_client_set_restart_command (client, 2, argv); 00040 00041 hook_call ("quit", NULL); 00042 } 00043 00044 static void 00045 signal_session_save_cb(EggSMClient *client, GKeyFile *state_file, gpointer user_data) 00046 { 00047 const char * argv[2]; 00048 00049 g_print("Session save requested. Saving state.\n"); 00050 00051 argv[0] = "audacious"; 00052 argv[1] = g_strdup_printf ("--display=%s", gdk_display_get_name (gdk_display_get_default())); 00053 egg_sm_client_set_restart_command (client, 2, argv); 00054 00055 do_autosave (); 00056 } 00057 #endif 00058 00059 void smclient_init (void) 00060 { 00061 #ifdef USE_EGGSM 00062 EggSMClient *client; 00063 00064 client = egg_sm_client_get (); 00065 if (client != NULL) 00066 { 00067 g_signal_connect (client, "quit", 00068 G_CALLBACK (signal_session_quit_cb), NULL); 00069 g_signal_connect (client, "save-state", 00070 G_CALLBACK (signal_session_save_cb), NULL); 00071 00072 } 00073 #endif 00074 }