2001-07-09 13:29:14 +00:00
|
|
|
/* -*- mode: c; style: linux -*- */
|
|
|
|
|
|
|
|
/* sound-properties-capplet.c
|
2001-07-10 18:27:43 +00:00
|
|
|
* Copyright (C) 2001 Ximian, Inc.
|
2001-07-09 13:29:14 +00:00
|
|
|
*
|
|
|
|
* Written by Bradford Hovinen <hovinen@ximian.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2001-07-13 18:51:28 +00:00
|
|
|
#include "capplet-util.h"
|
2001-07-09 13:29:14 +00:00
|
|
|
|
|
|
|
/* Needed only for the sound capplet */
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <esd.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
/* Capplet-specific prototypes */
|
|
|
|
|
|
|
|
static void start_esd (void);
|
|
|
|
|
|
|
|
/* apply_settings
|
|
|
|
*
|
|
|
|
* Apply the settings of the property bag. This function is per-capplet, though
|
|
|
|
* there are some cases where it does not do anything.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2001-07-10 18:27:43 +00:00
|
|
|
apply_settings (Bonobo_ConfigDatabase db)
|
2001-07-09 13:29:14 +00:00
|
|
|
{
|
2001-07-10 18:27:43 +00:00
|
|
|
gboolean enable_esd;
|
2001-07-09 13:29:14 +00:00
|
|
|
|
2001-07-10 18:27:43 +00:00
|
|
|
enable_esd = bonobo_config_get_boolean (db, "/main/enable_esd", NULL);
|
2001-07-09 13:29:14 +00:00
|
|
|
|
2001-07-12 21:40:03 +00:00
|
|
|
#if 0
|
2001-07-10 18:27:43 +00:00
|
|
|
if (enable_esd && gnome_sound_connection < 0)
|
2001-07-09 13:29:14 +00:00
|
|
|
start_esd ();
|
2001-07-12 21:40:03 +00:00
|
|
|
#endif
|
2001-07-09 13:29:14 +00:00
|
|
|
|
2001-07-10 18:27:43 +00:00
|
|
|
if (!enable_esd && gnome_sound_connection >= 0)
|
|
|
|
system ("killall esd");
|
|
|
|
|
2001-07-09 13:29:14 +00:00
|
|
|
/* I'm not going to deal with reloading samples until later. It's
|
|
|
|
* entirely too painful */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* start_esd
|
|
|
|
*
|
|
|
|
* Start the Enlightenment Sound Daemon. This function is specific to the sound
|
|
|
|
* properties capplet.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
start_esd (void)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_ESD
|
|
|
|
int esdpid;
|
|
|
|
static const char *esd_cmdline[] = {"esd", "-nobeeps", NULL};
|
|
|
|
char *tmpargv[3];
|
|
|
|
char argbuf[32];
|
|
|
|
time_t starttime;
|
|
|
|
GnomeClient *client = gnome_master_client ();
|
|
|
|
|
|
|
|
esdpid = gnome_execute_async (NULL, 2, (char **)esd_cmdline);
|
|
|
|
g_snprintf (argbuf, sizeof (argbuf), "%d", esdpid);
|
|
|
|
tmpargv[0] = "kill"; tmpargv[1] = argbuf; tmpargv[2] = NULL;
|
|
|
|
gnome_client_set_shutdown_command (client, 2, tmpargv);
|
|
|
|
starttime = time (NULL);
|
|
|
|
gnome_sound_init (NULL);
|
|
|
|
|
|
|
|
while (gnome_sound_connection < 0
|
|
|
|
&& ((time(NULL) - starttime) < 4))
|
|
|
|
{
|
|
|
|
#ifdef HAVE_USLEEP
|
|
|
|
usleep(1000);
|
|
|
|
#endif
|
|
|
|
gnome_sound_init(NULL);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2001-07-13 18:51:28 +00:00
|
|
|
/* setup_dialog
|
2001-07-09 13:29:14 +00:00
|
|
|
*
|
2001-07-13 18:51:28 +00:00
|
|
|
* Set up the property editors for our dialog
|
2001-07-09 13:29:14 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2001-07-13 18:51:28 +00:00
|
|
|
setup_dialog (GladeXML *dialog, Bonobo_PropertyBag bag)
|
2001-07-09 13:29:14 +00:00
|
|
|
{
|
2001-07-10 18:27:43 +00:00
|
|
|
CREATE_PEDITOR (boolean, "enable_esd", "enable_toggle");
|
2001-07-12 19:42:51 +00:00
|
|
|
CREATE_PEDITOR (boolean, "event_sounds", "events_toggle");
|
2001-07-09 13:29:14 +00:00
|
|
|
}
|
|
|
|
|
2001-07-13 18:51:28 +00:00
|
|
|
/* get_legacy_settings
|
2001-07-09 13:29:14 +00:00
|
|
|
*
|
2001-07-13 18:51:28 +00:00
|
|
|
* Retrieve older gnome_config -style settings and store them in the
|
|
|
|
* configuration database.
|
2001-07-09 18:36:10 +00:00
|
|
|
*
|
2001-07-13 18:51:28 +00:00
|
|
|
* In most cases, it's best to use the COPY_FROM_LEGACY macro defined in
|
|
|
|
* capplets/common/capplet-util.h.
|
2001-07-09 18:36:10 +00:00
|
|
|
*/
|
|
|
|
|
2001-07-13 18:51:28 +00:00
|
|
|
static void
|
|
|
|
get_legacy_settings (Bonobo_ConfigDatabase db)
|
2001-07-09 18:36:10 +00:00
|
|
|
{
|
2001-07-13 18:51:28 +00:00
|
|
|
gboolean val_boolean, def;
|
2001-07-10 18:27:43 +00:00
|
|
|
|
2001-07-13 18:51:28 +00:00
|
|
|
COPY_FROM_LEGACY (boolean, "enable_esd", bool, "/sound/system/settings/start_esd=false");
|
|
|
|
COPY_FROM_LEGACY (boolean, "event_sounds", bool, "/sound/system/settings/event_sounds=false");
|
2001-07-09 18:36:10 +00:00
|
|
|
}
|
|
|
|
|
2001-07-09 13:29:14 +00:00
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
2001-07-13 18:51:28 +00:00
|
|
|
capplet_init (argc, argv, apply_settings, setup_dialog, get_legacy_settings);
|
2001-07-10 18:27:43 +00:00
|
|
|
|
2001-07-09 13:29:14 +00:00
|
|
|
return 0;
|
|
|
|
}
|