Port to GNOME 2.0.

2002-01-08  Richard Hestilow  <hestilow@ximian.com>

	* Port to GNOME 2.0.
This commit is contained in:
Richard Hestilow 2002-01-08 14:58:12 +00:00 committed by Rachel Hestilow
parent 93763d7ddb
commit 53a008eb3c
4 changed files with 205 additions and 311 deletions

View file

@ -1,3 +1,7 @@
2002-01-08 Richard Hestilow <hestilow@ximian.com>
* Port to GNOME 2.0.
2001-11-18 Richard Hestilow <hestilow@ximian.com>
* Makefile.am (sound_properties_control_LDADD): Add libsounds.a.

View file

@ -1,57 +1,20 @@
cappletname = sound
cappletgroup =
bin_PROGRAMS = sound-properties-control
bin_SCRIPTS = sound-properties
bin_PROGRAMS = gnome-sound-properties
sound_properties_control_LDADD = $(GNOMECC_CAPPLETS_LIBS)
gnome_sound_properties_LDADD = $(GNOMECC_CAPPLETS_LIBS) $(top_builddir)/libsounds/libsounds.a
gnome_sound_properties_SOURCES = sound-properties-capplet.c
sound_properties_control_SOURCES = \
sound-properties-capplet.c
DESKTOP_EXEC_LINE = gnomecc --run-capplet sound-properties
pixmap_DATA =
##
## this is not generic
##
defaultsdir= $(datadir)/control-center/defaults
defaults_DATA = sound-properties.xml
oafdir = $(datadir)/oaf
oaf_DATA = Bonobo_Control_Capplet_sound_properties.oaf
##
## You should not need to modify anything below this line
##
@INTLTOOL_DESKTOP_RULE@
$(bin_SCRIPTS): $(top_srcdir)/capplets/common/wrapper-script.in
sed -e "s#@BINDIR@#$(bindir)#" -e "s#@CAPPLET_NAME@#$(cappletname)-properties#" < $< > $@
chmod a+x $@
Gladedir = $(GNOMECC_GLADE_DIR)
Glade_DATA = sound-properties.glade
$(oaf_DATA): %.oaf: $(top_srcdir)/capplets/common/Bonobo_Control_Capplet_generic.oaf.in
sed -e "s#@BINDIR@#$(bindir)#" -e "s#@SHORT_CAPPLET_NAME@#$(cappletname)#" -e "s#@CAPPLET_BINARY_NAME@#$(bin_PROGRAMS)#" < $< > $@
iconsdir = $(GNOMECC_ICONS_DIR)
icons_DATA = sound-capplet.png
####@###GNOMECC_CAPPLETS_DESKTOP_IN_RULE@
$(desktop).in: %.desktop.in: %.desktop.in.in
sed -e "s#@DESKTOP_EXEC_LINE@#$(DESKTOP_EXEC_LINE)#" -e "s#Icon=.*#Icon=$(GNOMECC_ICONS_DIR)/${cappletname}-capplet.png#" < $< > ${cappletname}.desktop.in
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(datadir)/control-center/capplets/$(cappletgroup)
$(INSTALL_DATA) $(desktop) $(DESTDIR)$(datadir)/control-center/capplets/$(cappletgroup)$(desktop)
install-data-am: install-data-local
####@###GNOMECC_CAPPLETS_DESKTOP_IN_RULE@
desktopdir = $(GNOMECC_DESKTOP_DIR)
desktop_DATA = sound.desktop
INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS)
CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES)
EXTRA_DIST = $(GNOMECC_CAPPLETS_EXTRA_DIST) $(defaults_DATA) $(oaf_DATA).in
iconsdir = $(GNOMECC_ICONS_DIR)
Gladedir = $(GNOMECC_GLADE_DIR)
pixmapdir = $(GNOMECC_PIXMAPS_DIR)
Glade_DATA = $(cappletname)-properties.glade
icons_DATA = $(cappletname)-capplet.png
desktop = $(cappletname).desktop
all-local: $(desktop) $(oaffile)
EXTRA_DIST = $(Glade_DATA) $(icons_DATA) $(desktop_DATA)

View file

@ -25,7 +25,11 @@
# include <config.h>
#endif
#include <gnome.h>
#include <gconf/gconf-client.h>
#include "capplet-util.h"
#include "gconf-property-editor.h"
#include "libsounds/sound-view.h"
#include <glade/glade.h>
@ -40,148 +44,21 @@
static SoundProperties *props = NULL;
static void start_esd (void);
static void reload_foreach_cb (SoundEvent *event, gpointer data);
/* 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
apply_settings (Bonobo_ConfigDatabase db)
{
gboolean enable_esd;
gboolean event_sounds;
enable_esd = bonobo_config_get_boolean (db, "/main/enable_esd", NULL);
event_sounds = bonobo_config_get_boolean (db, "/main/event_sounds", NULL);
if (enable_esd && gnome_sound_connection < 0)
start_esd ();
if (!enable_esd)
system ("killall esd");
/* gnome-libs checks this */
gnome_config_set_bool ("/sound/system/settings/event_sounds", event_sounds);
gnome_config_set_bool ("/sound/system/settings/enable_esd", enable_esd);
gnome_config_sync ();
/* Were we created from a dialog? */
if (props)
{
sound_properties_user_save (props);
}
else
{
props = sound_properties_new ();
sound_properties_add_defaults (props, NULL);
}
sound_properties_foreach (props, reload_foreach_cb, NULL);
}
/* 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
}
/* reload_foreach_cb
*
* For a given SoundEvent, reload the sound file associate with the event.
*/
static void
reload_foreach_cb (SoundEvent *event, gpointer data)
{
gchar *file, *tmp, *key;
int sid;
key = sound_event_compose_key (event);
/* We need to free up the old sample, because
* esd allows multiple samples with the same name,
* putting memory to waste. */
sid = esd_sample_getid(gnome_sound_connection, key);
if (sid >= 0)
esd_sample_free(gnome_sound_connection, sid);
if (!event->file || !strcmp (event->file, ""))
return;
file = g_strdup (event->file);
if (file[0] != '/')
{
tmp = gnome_sound_file (file);
g_free (file);
file = tmp;
}
if (!file)
{
g_free (key);
return;
}
sid = gnome_sound_sample_load (key, file);
if (sid < 0)
g_warning ("Couldn't load sound file %s as sample %s",
file, key);
g_free (key);
}
/* create_dialog
*
* Create the dialog box and return it as a GtkWidget
*/
static GtkWidget *
static GladeXML *
create_dialog (void)
{
GladeXML *data;
GtkWidget *widget, *box;
data = glade_xml_new (GNOMECC_GLADE_DIR "/sound-properties.glade", "prefs_widget");
data = glade_xml_new (GNOMECC_DATA_DIR "/interfaces/sound-properties.glade", "prefs_widget", NULL);
widget = glade_xml_get_widget (data, "prefs_widget");
gtk_object_set_data (GTK_OBJECT (widget), "glade-data", data);
gtk_signal_connect_object (GTK_OBJECT (widget), "destroy",
GTK_SIGNAL_FUNC (gtk_object_destroy),
GTK_OBJECT (data));
props = sound_properties_new ();
sound_properties_add_defaults (props, NULL);
box = glade_xml_get_widget (data, "events_vbox");
@ -194,7 +71,7 @@ create_dialog (void)
gtk_widget_set_usize (widget, -1, 250);
return widget;
return data;
}
/* setup_dialog
@ -203,17 +80,14 @@ create_dialog (void)
*/
static void
setup_dialog (GtkWidget *widget, Bonobo_PropertyBag bag)
setup_dialog (GladeXML *dialog, GConfChangeSet *changeset)
{
GladeXML *dialog;
GObject *peditor;
dialog = gtk_object_get_data (GTK_OBJECT (widget), "glade-data");
CREATE_PEDITOR (boolean, "enable_esd", "enable_toggle");
CREATE_PEDITOR (boolean, "event_sounds", "events_toggle");
bonobo_peditor_set_guard (WID ("events_toggle"), bag, "enable_esd");
bonobo_peditor_set_guard (WID ("events_vbox"), bag, "enable_esd");
peditor = gconf_peditor_new_boolean (changeset, "/desktop/gnome/sound/enable_esd", WID ("enable_toggle"), NULL);
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor), WID ("events_toggle"));
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor), WID ("events_vbox"));
peditor = gconf_peditor_new_boolean (changeset, "/desktop/gnome/sound/event_sounds", WID ("events_toggle"), NULL);
}
/* get_legacy_settings
@ -226,22 +100,87 @@ setup_dialog (GtkWidget *widget, Bonobo_PropertyBag bag)
*/
static void
get_legacy_settings (Bonobo_ConfigDatabase db)
get_legacy_settings (void)
{
gboolean val_boolean, def;
GConfClient *client;
gboolean val_bool, def;
COPY_FROM_LEGACY (boolean, "/main/enable_esd", bool, "/sound/system/settings/start_esd=false");
COPY_FROM_LEGACY (boolean, "/main/event_sounds", bool, "/sound/system/settings/event_sounds=false");
client = gconf_client_get_default ();
COPY_FROM_LEGACY (bool, "/desktop/gnome/sound/enable_esd", "/sound/system/settings/start_esd=false");
COPY_FROM_LEGACY (bool, "/desktop/gnome/sound/event_sounds", "/sound/system/settings/event_sounds=false");
g_object_unref (G_OBJECT (client));
}
static void
dialog_button_clicked_cb (GnomeDialog *dialog, gint response_id, GConfChangeSet *changeset)
{
switch (response_id) {
case GTK_RESPONSE_APPLY:
gconf_client_commit_change_set (gconf_client_get_default (), changeset, TRUE, NULL);
break;
case GTK_RESPONSE_CLOSE:
gtk_main_quit ();
break;
}
}
int
main (int argc, char **argv)
{
const gchar* legacy_files[] = { "sound/system", "sound/events", NULL };
glade_gnome_init ();
capplet_init (argc, argv, legacy_files, apply_settings, create_dialog, setup_dialog, get_legacy_settings);
GConfClient *client;
GConfChangeSet *changeset;
GladeXML *dialog;
GtkWidget *dialog_win;
static gboolean apply_only;
static gboolean get_legacy;
static struct poptOption cap_options[] = {
{ "apply", '\0', POPT_ARG_NONE, &apply_only, 0,
N_("Just apply settings and quit (compatibility only; now handled by daemon)"), NULL },
{ "init-session-settings", '\0', POPT_ARG_NONE, &apply_only, 0,
N_("Just apply settings and quit (compatibility only; now handled by daemon)"), NULL },
{ "get-legacy", '\0', POPT_ARG_NONE, &get_legacy, 0,
N_("Retrieve and store legacy settings"), NULL },
{ NULL, '\0', 0, NULL, 0, NULL, NULL }
};
bindtextdomain (PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (PACKAGE, "UTF-8");
textdomain (PACKAGE);
gnome_program_init (argv[0], VERSION, LIBGNOMEUI_MODULE, argc, argv,
GNOME_PARAM_POPT_TABLE, cap_options,
NULL);
client = gconf_client_get_default ();
gconf_client_add_dir (client, "/desktop/gnome/sound", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
if (get_legacy) {
get_legacy_settings ();
} else {
changeset = gconf_change_set_new ();
dialog = create_dialog ();
setup_dialog (dialog, changeset);
#if 0
gnome_window_icon_set_default_from_file
(GNOMECC_ICONS_DIR "keyboard-capplet.png");
#endif
dialog_win = gtk_dialog_new_with_buttons
(_("Sound properties"), NULL, -1,
GTK_STOCK_APPLY, GTK_RESPONSE_APPLY,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
NULL);
g_signal_connect (G_OBJECT (dialog_win), "response", (GCallback) dialog_button_clicked_cb, changeset);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog_win)->vbox), WID ("prefs_widget"), TRUE, TRUE, GNOME_PAD_SMALL);
gtk_widget_show_all (dialog_win);
gtk_main ();
gconf_change_set_unref (changeset);
}
return 0;
}

View file

@ -1,122 +1,110 @@
<?xml version="1.0"?>
<GTK-Interface>
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd" >
<project>
<name>New-sound-properties</name>
<program_name>new-sound-properties</program_name>
<directory></directory>
<source_directory>src</source_directory>
<pixmaps_directory>pixmaps</pixmaps_directory>
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
</project>
<glade-interface>
<widget class="GtkWindow" id="window1">
<property name="title" translatable="yes">window2</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="modal">no</property>
<property name="allow_shrink">no</property>
<property name="allow_grow">yes</property>
<property name="visible">no</property>
<property name="window-position">GTK_WIN_POS_NONE</property>
<widget>
<class>GtkWindow</class>
<name>window1</name>
<title>window2</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>False</allow_shrink>
<allow_grow>True</allow_grow>
<auto_shrink>False</auto_shrink>
<child>
<widget class="GtkNotebook" id="prefs_widget">
<property name="can_focus">yes</property>
<property name="show_tabs">yes</property>
<property name="show_border">yes</property>
<property name="tab_pos">GTK_POS_TOP</property>
<property name="scrollable">no</property>
<property name="tab_hborder">2</property>
<property name="tab_vborder">2</property>
<property name="enable-popup">no</property>
<property name="visible">yes</property>
<widget>
<class>GtkNotebook</class>
<name>prefs_widget</name>
<can_focus>True</can_focus>
<show_tabs>True</show_tabs>
<show_border>True</show_border>
<tab_pos>GTK_POS_TOP</tab_pos>
<scrollable>False</scrollable>
<tab_hborder>2</tab_hborder>
<tab_vborder>2</tab_vborder>
<popup_enable>False</popup_enable>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="homogeneous">no</property>
<property name="spacing">5</property>
<property name="visible">yes</property>
<widget>
<class>GtkVBox</class>
<name>vbox1</name>
<homogeneous>False</homogeneous>
<spacing>5</spacing>
<child>
<widget class="GtkCheckButton" id="enable_toggle">
<property name="can_focus">yes</property>
<property name="label" translatable="yes">Enable sound server startup</property>
<property name="active">no</property>
<property name="draw_indicator">yes</property>
<property name="visible">yes</property>
<widget>
<class>GtkCheckButton</class>
<name>enable_toggle</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>enable_toggled_cb</handler>
<last_modification_time>Sun, 08 Oct 2000 01:49:56 GMT</last_modification_time>
</signal>
<label>Enable sound server startup</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<signal name="toggled" handler="enable_toggled_cb" />
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">no</property>
<property name="fill">no</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="events_toggle">
<property name="can_focus">yes</property>
<property name="label" translatable="yes">Sounds for events</property>
<property name="active">no</property>
<property name="draw_indicator">yes</property>
<property name="visible">yes</property>
<signal name="toggled" handler="events_toggled_cb" />
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">no</property>
<property name="fill">no</property>
</packing>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label1">
<property name="label" translatable="yes">General</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">no</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="visible">yes</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="events_vbox">
<property name="homogeneous">no</property>
<property name="spacing">0</property>
<property name="visible">yes</property>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label2">
<property name="label" translatable="yes">Sound Events</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">no</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="visible">yes</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>events_toggle</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>events_toggled_cb</handler>
<last_modification_time>Sun, 08 Oct 2000 01:50:13 GMT</last_modification_time>
</signal>
<label>Sounds for events</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>Notebook:tab</child_name>
<name>label1</name>
<label>General</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
<widget>
<class>GtkVBox</class>
<name>events_vbox</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<widget>
<class>Placeholder</class>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>Notebook:tab</child_name>
<name>label2</name>
<label>Sound Events</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
</child>
</widget>
</widget>
</GTK-Interface>
</glade-interface>