Audacious $Id:Doxyfile42802007-03-2104:39:00Znenolod$
smclient.c
Go to the documentation of this file.
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 "audconfig.h"
00025 #include "config.h"
00026 
00027 #ifdef USE_EGGSM
00028 
00029 #include "eggsmclient.h"
00030 
00031 static void
00032 signal_session_quit_cb(EggSMClient *client, gpointer user_data)
00033 {
00034     const gchar * argv[2];
00035 
00036     g_print("Session quit requested. Saving state and shutting down.\n");
00037 
00038     argv[0] = "audacious";
00039     argv[1] = g_strdup_printf ("--display=%s", gdk_display_get_name (gdk_display_get_default()));
00040     egg_sm_client_set_restart_command (client, 2, argv);
00041 
00042     hook_call ("quit", NULL);
00043 }
00044 
00045 static void
00046 signal_session_save_cb(EggSMClient *client, GKeyFile *state_file, gpointer user_data)
00047 {
00048     const gchar * argv[2];
00049 
00050     g_print("Session save requested. Saving state.\n");
00051 
00052     argv[0] = "audacious";
00053     argv[1] = g_strdup_printf ("--display=%s", gdk_display_get_name (gdk_display_get_default()));
00054     egg_sm_client_set_restart_command (client, 2, argv);
00055 
00056     aud_config_save();
00057 }
00058 #endif
00059 
00060 void smclient_init (void)
00061 {
00062 #ifdef USE_EGGSM
00063     EggSMClient *client;
00064 
00065     client = egg_sm_client_get ();
00066     if (client != NULL)
00067     {
00068         g_signal_connect (client, "quit",
00069                           G_CALLBACK (signal_session_quit_cb), NULL);
00070         g_signal_connect (client, "save-state",
00071                           G_CALLBACK (signal_session_save_cb), NULL);
00072 
00073     }
00074 #endif
00075 }