Make full moniker (apply_settings): Release the return value (main):
2001-07-10 Bradford Hovinen <hovinen@ximian.com> * sound-properties-capplet.c (set_moniker_cb): Make full moniker (apply_settings): Release the return value (main): Support --get-legacy option (get_legacy_settings): Implement (create_control_cb): Connect apply_cb (COPY_FROM_LEGACY): Use bonobo_config_set_... (main): Open config database regardless of what operation is requested; pass to create_control callback (apply_settings): Use bonobo_config_get_... (get_legacy_settings): (apply_settings): Don't accept CORBA_Environment *ev any more (create_control_cb): Store the config database in the property control (apply_settings): Use the correct setting name (apply_cb): Apply settings and sync (apply_settings): Kill esd when requested * capplet-dir.c (capplet_ok_cb): Notify property control of apply action (capplet_control_launch): Store PropertyControl in app
This commit is contained in:
parent
dde0a2329b
commit
858feb0824
5 changed files with 144 additions and 40 deletions
|
@ -1,6 +1,20 @@
|
|||
2001-07-10 Bradford Hovinen <hovinen@ximian.com>
|
||||
|
||||
* sound-properties-capplet.c (set_moniker_cb): Make full moniker
|
||||
(apply_settings): Release the return value
|
||||
(main): Support --get-legacy option
|
||||
(get_legacy_settings): Implement
|
||||
(create_control_cb): Connect apply_cb
|
||||
(COPY_FROM_LEGACY): Use bonobo_config_set_...
|
||||
(main): Open config database regardless of what operation is
|
||||
requested; pass to create_control callback
|
||||
(apply_settings): Use bonobo_config_get_...
|
||||
(get_legacy_settings):
|
||||
(apply_settings): Don't accept CORBA_Environment *ev any more
|
||||
(create_control_cb): Store the config database in the property control
|
||||
(apply_settings): Use the correct setting name
|
||||
(apply_cb): Apply settings and sync
|
||||
(apply_settings): Kill esd when requested
|
||||
|
||||
* sound-properties.xml: Fixed path name
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* -*- mode: c; style: linux -*- */
|
||||
|
||||
/* sound-properties-capplet.c
|
||||
* Copyright (C) 2000 Ximian, Inc.
|
||||
* Copyright (C) 2001 Ximian, Inc.
|
||||
*
|
||||
* Written by Bradford Hovinen <hovinen@ximian.com>
|
||||
*
|
||||
|
@ -53,6 +53,27 @@
|
|||
#include <esd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/* Macros to make certain repetitive tasks a bit easier */
|
||||
|
||||
/* Retrieve a widget from the Glade object */
|
||||
|
||||
#define WID(s) glade_xml_get_widget (dialog, s)
|
||||
|
||||
/* Copy a setting from the legacy gnome-config settings to the ConfigDatabase */
|
||||
|
||||
#define COPY_FROM_LEGACY(type, key, legacy_type, legacy_key) \
|
||||
val_##type = gnome_config_get_##legacy_type##_with_default \
|
||||
(legacy_key, &def); \
|
||||
\
|
||||
if (!def) \
|
||||
bonobo_config_set_##type (db, key, val_##type, NULL); \
|
||||
|
||||
/* Create a property editor */
|
||||
|
||||
#define CREATE_PEDITOR(type, key, widget) \
|
||||
ed = BONOBO_PEDITOR (bonobo_peditor_##type##_construct (WID (widget))); \
|
||||
bonobo_peditor_set_property (ed, proxy, key, TC_##type, NULL); \
|
||||
|
||||
static BonoboControl *control = NULL;
|
||||
static GladeXML *dialog;
|
||||
static GtkWidget *widget;
|
||||
|
@ -68,21 +89,66 @@ static void start_esd (void);
|
|||
*/
|
||||
|
||||
static void
|
||||
apply_settings (Bonobo_ConfigDatabase db, CORBA_Environment *ev)
|
||||
apply_settings (Bonobo_ConfigDatabase db)
|
||||
{
|
||||
CORBA_any *value;
|
||||
gboolean enable_esd;
|
||||
|
||||
value = Bonobo_ConfigDatabase_getValue (db, "enable_esd", NULL, ev);
|
||||
enable_esd = bonobo_config_get_boolean (db, "/main/enable_esd", NULL);
|
||||
|
||||
if (BONOBO_EX (ev)) return;
|
||||
|
||||
if (BONOBO_ARG_GET_BOOLEAN (value) && gnome_sound_connection < 0)
|
||||
if (enable_esd && gnome_sound_connection < 0)
|
||||
start_esd ();
|
||||
|
||||
if (!enable_esd && gnome_sound_connection >= 0)
|
||||
system ("killall esd");
|
||||
|
||||
/* I'm not going to deal with reloading samples until later. It's
|
||||
* entirely too painful */
|
||||
}
|
||||
|
||||
/* apply_cb
|
||||
*
|
||||
* Callback issued when the user clicks "Apply" or "Ok". This function is
|
||||
* responsible for making sure the current settings are properly applied. It
|
||||
* does not vary between capplets.
|
||||
*/
|
||||
|
||||
static void
|
||||
apply_cb (BonoboPropertyControl *pc, Bonobo_PropertyControl_Action action)
|
||||
{
|
||||
BonoboPropertyFrame *pf;
|
||||
Bonobo_ConfigDatabase db;
|
||||
CORBA_Environment ev;
|
||||
|
||||
if (action == Bonobo_PropertyControl_APPLY) {
|
||||
CORBA_exception_init (&ev);
|
||||
|
||||
pf = gtk_object_get_data (GTK_OBJECT (pc), "property-frame");
|
||||
db = gtk_object_get_data (GTK_OBJECT (pc), "config-database");
|
||||
bonobo_pbproxy_update (pf->proxy);
|
||||
apply_settings (db);
|
||||
Bonobo_ConfigDatabase_sync (db, &ev);
|
||||
|
||||
CORBA_exception_free (&ev);
|
||||
}
|
||||
}
|
||||
|
||||
/* get_legacy_settings
|
||||
*
|
||||
* Retrieve older gnome_config -style settings and store them in the
|
||||
* configuration database. This function is written per-capplet.
|
||||
*
|
||||
* In most cases, it's best to use the COPY_FROM_LEGACY macro defined above.
|
||||
*/
|
||||
|
||||
static void
|
||||
get_legacy_settings (Bonobo_ConfigDatabase db)
|
||||
{
|
||||
gboolean val_boolean, def;
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
/* start_esd
|
||||
*
|
||||
* Start the Enlightenment Sound Daemon. This function is specific to the sound
|
||||
|
@ -139,10 +205,6 @@ get_moniker_cb (BonoboPropertyBag *bag, BonoboArg *arg, guint arg_id,
|
|||
* labelled must be written once for each capplet.
|
||||
*/
|
||||
|
||||
/* Macro to make it easier to reference Glade widgets */
|
||||
|
||||
#define WID(s) glade_xml_get_widget (dialog, s)
|
||||
|
||||
static void
|
||||
set_moniker_cb (BonoboPropertyBag *bag, BonoboArg *arg, guint arg_id,
|
||||
CORBA_Environment *ev, BonoboControl *control)
|
||||
|
@ -166,11 +228,8 @@ set_moniker_cb (BonoboPropertyBag *bag, BonoboArg *arg, guint arg_id,
|
|||
|
||||
/* Begin per-capplet part */
|
||||
|
||||
ed = BONOBO_PEDITOR (bonobo_peditor_boolean_construct (WID ("enable_toggle")));
|
||||
bonobo_peditor_set_property (ed, proxy, "start_esd", TC_boolean, NULL);
|
||||
|
||||
ed = BONOBO_PEDITOR (bonobo_peditor_boolean_construct (WID ("events_toggle")));
|
||||
bonobo_peditor_set_property (ed, proxy, "event_sounds", TC_boolean, NULL);
|
||||
CREATE_PEDITOR (boolean, "enable_esd", "enable_toggle");
|
||||
CREATE_PEDITOR (boolean, "event_sound", "events_toggle");
|
||||
|
||||
/* End per-capplet part */
|
||||
}
|
||||
|
@ -195,17 +254,16 @@ close_cb (void)
|
|||
* whenever capplet activation is requested. Returns a BonoboObject representing
|
||||
* the control that encapsulates the object. This function should not vary from
|
||||
* capplet to capplet, though it assumes that the dialog data in the glade file
|
||||
* has the name "prefs_widget". */
|
||||
* has the name "prefs_widget".
|
||||
*/
|
||||
|
||||
static BonoboObject *
|
||||
create_dialog_cb (BonoboPropertyControl *property_control, gint page_number, gpointer data)
|
||||
create_dialog_cb (BonoboPropertyControl *property_control, gint page_number)
|
||||
{
|
||||
BonoboPropertyBag *pb;
|
||||
GtkWidget *pf;
|
||||
|
||||
if (control == NULL) {
|
||||
DEBUG_MSG ("Creating control");
|
||||
|
||||
dialog = glade_xml_new (GLADE_FILE, "prefs_widget");
|
||||
|
||||
if (dialog == NULL) {
|
||||
|
@ -220,9 +278,9 @@ create_dialog_cb (BonoboPropertyControl *property_control, gint page_number, gpo
|
|||
return NULL;
|
||||
}
|
||||
|
||||
DEBUG_MSG ("Loaded dialog: %p, %p", dialog, widget);
|
||||
|
||||
pf = bonobo_property_frame_new (NULL, NULL);
|
||||
gtk_object_set_data (GTK_OBJECT (property_control),
|
||||
"property-frame", pf);
|
||||
gtk_container_add (GTK_CONTAINER (pf), widget);
|
||||
gtk_widget_show_all (pf);
|
||||
|
||||
|
@ -259,11 +317,22 @@ create_dialog_cb (BonoboPropertyControl *property_control, gint page_number, gpo
|
|||
*/
|
||||
|
||||
static BonoboObject *
|
||||
create_control_cb (BonoboGenericFactory *factory, gpointer data)
|
||||
create_control_cb (BonoboGenericFactory *factory, Bonobo_ConfigDatabase db)
|
||||
{
|
||||
return BONOBO_OBJECT (bonobo_property_control_new
|
||||
((BonoboPropertyControlGetControlFn)
|
||||
create_dialog_cb, 1, NULL));
|
||||
BonoboPropertyControl *property_control;
|
||||
CORBA_Environment ev;
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
|
||||
property_control = bonobo_property_control_new
|
||||
((BonoboPropertyControlGetControlFn) create_dialog_cb, 1, NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (property_control), "action",
|
||||
GTK_SIGNAL_FUNC (apply_cb), NULL);
|
||||
gtk_object_set_data (GTK_OBJECT (property_control), "config-database", db);
|
||||
|
||||
CORBA_exception_free (&ev);
|
||||
|
||||
return BONOBO_OBJECT (property_control);
|
||||
}
|
||||
|
||||
/* main -- This function should not vary from capplet to capplet
|
||||
|
@ -285,15 +354,20 @@ main (int argc, char **argv)
|
|||
CORBA_Environment ev;
|
||||
|
||||
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"), 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);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
|
||||
glade_gnome_init ();
|
||||
gnomelib_register_popt_table (cap_options, _("Capplet options"));
|
||||
gnome_init_with_popt_table (argv[0], VERSION, argc, argv,
|
||||
|
@ -303,26 +377,26 @@ main (int argc, char **argv)
|
|||
if (bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE)
|
||||
g_error ("Cannot initialize bonobo");
|
||||
|
||||
if (apply_only) {
|
||||
CORBA_exception_init (&ev);
|
||||
db = bonobo_get_object (DEFAULT_MONIKER,
|
||||
"IDL:Bonobo/ConfigDatabase:1.0", &ev);
|
||||
db = bonobo_get_object (DEFAULT_MONIKER, "IDL:Bonobo/ConfigDatabase:1.0", &ev);
|
||||
|
||||
if (db == CORBA_OBJECT_NIL) {
|
||||
g_critical ("Cannot open configuration database");
|
||||
return -1;
|
||||
}
|
||||
if (db == CORBA_OBJECT_NIL) {
|
||||
g_critical ("Cannot open configuration database");
|
||||
return -1;
|
||||
}
|
||||
|
||||
apply_settings (db, &ev);
|
||||
|
||||
CORBA_exception_free (&ev);
|
||||
} else {
|
||||
if (apply_only)
|
||||
apply_settings (db);
|
||||
else if (get_legacy)
|
||||
get_legacy_settings (db);
|
||||
else {
|
||||
factory = bonobo_generic_factory_new
|
||||
("OAFIID:Bonobo_Control_Capplet_sound_properties_Factory",
|
||||
(BonoboGenericFactoryFn) create_control_cb, NULL);
|
||||
(BonoboGenericFactoryFn) create_control_cb, db);
|
||||
bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory));
|
||||
bonobo_main ();
|
||||
}
|
||||
|
||||
CORBA_exception_free (&ev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
<bonobo-config>
|
||||
<section path="main">
|
||||
<entry name="start_esd" type="boolean" value="0"/>
|
||||
<entry name="event_sounds" type="boolean" value="1"/>
|
||||
<entry name="event_sounds" type="boolean" value="0"/>
|
||||
</section>
|
||||
</bonobo-config>
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2001-07-10 Bradford Hovinen <hovinen@ximian.com>
|
||||
|
||||
* capplet-dir.c (capplet_ok_cb): Notify property control of apply
|
||||
action
|
||||
(capplet_control_launch): Store PropertyControl in app
|
||||
|
||||
2001-07-09 Bradford Hovinen <hovinen@ximian.com>
|
||||
|
||||
* Makefile.am (gladedir): Update installation directory
|
||||
|
|
|
@ -384,7 +384,16 @@ get_root_capplet_dir (void)
|
|||
static void
|
||||
capplet_ok_cb (GtkWidget *widget, GtkWidget *app)
|
||||
{
|
||||
CORBA_Environment ev;
|
||||
Bonobo_PropertyControl pc;
|
||||
|
||||
CORBA_exception_init (&ev);
|
||||
|
||||
pc = gtk_object_get_data (GTK_OBJECT (app), "property-control");
|
||||
Bonobo_PropertyControl_notifyAction (pc, 0, Bonobo_PropertyControl_APPLY, &ev);
|
||||
gtk_widget_destroy (app);
|
||||
|
||||
CORBA_exception_free (&ev);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -443,6 +452,7 @@ capplet_control_launch (const gchar *capplet_name)
|
|||
/* FIXME: Use a human-readable capplet name here */
|
||||
app = gnome_dialog_new (_("Capplet"), GNOME_STOCK_BUTTON_OK,
|
||||
GNOME_STOCK_BUTTON_CANCEL, NULL);
|
||||
gtk_object_set_data (GTK_OBJECT (app), "property-control", property_control);
|
||||
control = bonobo_widget_new_control_from_objref (control_ref, CORBA_OBJECT_NIL);
|
||||
|
||||
if (control == NULL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue