From c09362e12a71e1593aca4416ea9a9cceb2d9fae1 Mon Sep 17 00:00:00 2001 From: Bradford Hovinen Date: Mon, 9 Jul 2001 18:36:10 +0000 Subject: [PATCH] Use .gnome/capplet-archive rather than .gnome/control-center 2001-07-09 Bradford Hovinen * archive.c (archive_load): Use .gnome/capplet-archive rather than .gnome/control-center * sound-properties-capplet.c (create_control_cb): Implement (main): Use create_control_cb * Bonobo_Control_Capplet_sound_properties.oaf: Use PropertyControl interface * sound-properties-capplet.c (create_dialog_cb): Update signature for use as a BonoboPropertyControlGetControlFn * capplet-dir.c (capplet_control_launch): Create a control by first retrieving the PropertyControl and then extracting the control from it (capplet_control_launch): Connect button signals (capplet_cancel_cb): Implement. Just destroy the app widget (capplet_ok_cb): Ditto. (capplet_control_launch): Don't use a BonoboArg when setting the property --- archiver/ChangeLog | 3 ++ archiver/archive.c | 2 +- ...onobo_Control_Capplet_sound_properties.oaf | 5 ++- capplets/sound/ChangeLog | 8 ++++ capplets/sound/sound-properties-capplet.c | 19 ++++++++- control-center/ChangeLog | 9 ++++ control-center/capplet-dir.c | 41 ++++++++++++++----- 7 files changed, 72 insertions(+), 15 deletions(-) diff --git a/archiver/ChangeLog b/archiver/ChangeLog index 415eadb1f..e2255b45d 100644 --- a/archiver/ChangeLog +++ b/archiver/ChangeLog @@ -1,5 +1,8 @@ 2001-07-09 Bradford Hovinen + * archive.c (archive_load): Use .gnome/capplet-archive rather than + .gnome/control-center + * bonobo-config-archiver.c (bonobo_config_archiver_new): Try to load the defaults file if no rollback data can be found diff --git a/archiver/archive.c b/archiver/archive.c index f4b0a6b9b..14024754d 100644 --- a/archiver/archive.c +++ b/archiver/archive.c @@ -240,7 +240,7 @@ archive_load (gboolean is_global) prefix = "/var/ximian-setup-tools"; else prefix = g_concat_dir_and_file (g_get_home_dir (), - ".gnome/control-center"); + ".gnome/capplet-archive"); object = gtk_object_new (archive_get_type (), "prefix", prefix, diff --git a/capplets/sound/Bonobo_Control_Capplet_sound_properties.oaf b/capplets/sound/Bonobo_Control_Capplet_sound_properties.oaf index e0bebaeab..6fdc7eed8 100644 --- a/capplets/sound/Bonobo_Control_Capplet_sound_properties.oaf +++ b/capplets/sound/Bonobo_Control_Capplet_sound_properties.oaf @@ -2,7 +2,7 @@ - + @@ -11,9 +11,10 @@ - + + diff --git a/capplets/sound/ChangeLog b/capplets/sound/ChangeLog index 7b8017a1d..70ff4a5b9 100644 --- a/capplets/sound/ChangeLog +++ b/capplets/sound/ChangeLog @@ -1,5 +1,13 @@ 2001-07-09 Bradford Hovinen + * sound-properties-capplet.c (create_control_cb): Implement + (main): Use create_control_cb + + * Bonobo_Control_Capplet_sound_properties.oaf: Use PropertyControl interface + + * sound-properties-capplet.c (create_dialog_cb): Update signature + for use as a BonoboPropertyControlGetControlFn + * Makefile.am (defaults_DATA): Add sound-properties.xml (EXTRA_DIST): Add defaults_DATA diff --git a/capplets/sound/sound-properties-capplet.c b/capplets/sound/sound-properties-capplet.c index 515a3464e..68bbfc87c 100644 --- a/capplets/sound/sound-properties-capplet.c +++ b/capplets/sound/sound-properties-capplet.c @@ -196,7 +196,7 @@ close_cb (void) * has the name "prefs_widget". */ static BonoboObject * -create_dialog_cb (BonoboGenericFactory *factory, gpointer data) +create_dialog_cb (BonoboPropertyControl *property_control, gint page_number, gpointer data) { BonoboPropertyBag *pb; GtkWidget *pf; @@ -250,6 +250,20 @@ create_dialog_cb (BonoboGenericFactory *factory, gpointer data) return BONOBO_OBJECT (control); } +/* create_control_cb + * + * Small function to create the PropertyControl and return it. It may be copied + * and pasted from capplet to capplet. + */ + +static BonoboObject * +create_control_cb (BonoboGenericFactory *factory, gpointer data) +{ + return BONOBO_OBJECT (bonobo_property_control_new + ((BonoboPropertyControlGetControlFn) + create_dialog_cb, 1, NULL)); +} + /* main -- This function should not vary from capplet to capplet * * FIXME: Should there be this much code in main()? Seems a tad complicated; @@ -302,7 +316,8 @@ main (int argc, char **argv) CORBA_exception_free (&ev); } else { factory = bonobo_generic_factory_new - (FACTORY_IID, (BonoboGenericFactoryFn) create_dialog_cb, NULL); + ("OAFIID:Bonobo_Control_Capplet_sound_properties_Factory", + (BonoboGenericFactoryFn) create_control_cb, NULL); bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory)); bonobo_main (); } diff --git a/control-center/ChangeLog b/control-center/ChangeLog index 4eee0c005..eefd9cc7f 100644 --- a/control-center/ChangeLog +++ b/control-center/ChangeLog @@ -1,5 +1,14 @@ 2001-07-09 Bradford Hovinen + * capplet-dir.c (capplet_control_launch): Create a control by + first retrieving the PropertyControl and then extracting the + control from it + (capplet_control_launch): Connect button signals + (capplet_cancel_cb): Implement. Just destroy the app widget + (capplet_ok_cb): Ditto. + (capplet_control_launch): Don't use a BonoboArg when setting the + property + * Makefile.am (INCLUDES): Update directory locations * capplet-dir.c (capplet_control_launch): Terminate the list of diff --git a/control-center/capplet-dir.c b/control-center/capplet-dir.c index 8ad9d5986..6d55bbd9d 100644 --- a/control-center/capplet-dir.c +++ b/control-center/capplet-dir.c @@ -384,11 +384,13 @@ get_root_capplet_dir (void) static void capplet_ok_cb (GtkWidget *widget, GtkWidget *app) { + gtk_widget_destroy (app); } static void capplet_cancel_cb (GtkWidget *widget, GtkWidget *app) { + gtk_widget_destroy (app); } /* capplet_control_launch @@ -405,7 +407,9 @@ capplet_control_launch (const gchar *capplet_name) GtkWidget *app, *control; CORBA_Environment ev; - BonoboArg *value; + + Bonobo_PropertyControl property_control; + Bonobo_Control control_ref; g_return_val_if_fail (capplet_name != NULL, NULL); @@ -416,31 +420,48 @@ capplet_control_launch (const gchar *capplet_name) while ((tmp1 = strchr (tmp, '-'))) *tmp1 = '_'; oaf_iid = g_strconcat ("OAFIID:Bonobo_Control_Capplet_", tmp, NULL); - moniker = g_strconcat ("archiver:", tmp, NULL); + + property_control = bonobo_get_object (oaf_iid, "IDL:Bonobo/PropertyControl:1.0", &ev); + g_free (oaf_iid); + + if (BONOBO_EX (&ev) || property_control == CORBA_OBJECT_NIL) { + g_critical ("Could not resolve PropertyControl"); + g_free (tmp); + return NULL; + } + + control_ref = Bonobo_PropertyControl_getControl (property_control, 0, &ev); + + if (BONOBO_EX (&ev) || property_control == CORBA_OBJECT_NIL) { + g_critical ("Could not extract control from PropertyControl"); + bonobo_object_release_unref (property_control, &ev); + g_free (tmp); + return NULL; + } /* FIXME: Use a human-readable capplet name here */ app = gnome_dialog_new (_("Capplet"), GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL); - control = bonobo_widget_new_control (oaf_iid, CORBA_OBJECT_NIL); + control = bonobo_widget_new_control_from_objref (control_ref, CORBA_OBJECT_NIL); if (control == NULL) { - g_critical ("Could not create capplet control"); + g_critical ("Could not create widget from control"); gtk_widget_destroy (app); app = NULL; } else { gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (app)->vbox), control, TRUE, TRUE, 0); - value = bonobo_arg_new (BONOBO_ARG_STRING); - BONOBO_ARG_SET_STRING (value, moniker); - bonobo_widget_set_property (BONOBO_WIDGET (control), "moniker", value, NULL); - bonobo_arg_release (value); + moniker = g_strconcat ("archiver:", tmp, NULL); + bonobo_widget_set_property (BONOBO_WIDGET (control), "moniker", moniker, NULL); + g_free (moniker); gtk_widget_show_all (app); } + gnome_dialog_button_connect (GNOME_DIALOG (app), 0, GTK_SIGNAL_FUNC (capplet_ok_cb), app); + gnome_dialog_button_connect (GNOME_DIALOG (app), 1, GTK_SIGNAL_FUNC (capplet_cancel_cb), app); + CORBA_exception_free (&ev); - g_free (oaf_iid); - g_free (moniker); g_free (tmp); return app;