diff --git a/capplets/sound-properties-capplet.c b/capplets/sound-properties-capplet.c index 926a9e10f..9ccb3dbc6 100644 --- a/capplets/sound-properties-capplet.c +++ b/capplets/sound-properties-capplet.c @@ -49,6 +49,10 @@ #include #include +static BonoboControl *control = NULL; +static GladeXML *dialog; +static GtkWidget *widget; + /* Capplet-specific prototypes */ static void start_esd (void); @@ -165,22 +169,32 @@ set_moniker_cb (BonoboPropertyBag *bag, BonoboArg *arg, guint arg_id, /* End per-capplet part */ } +/* close_cb + * + * Callback issued when the dialog is destroyed. Just resets the control pointer + * to NULL so that the program does not think the dialog exists when it does + * not. Does not vary from capplet to capplet. + */ + +static void +close_cb (void) +{ + gtk_widget_destroy (widget); + gtk_object_destroy (GTK_OBJECT (dialog)); + control = NULL; +} + /* create_dialog_cb * * Callback to construct the main dialog box for this capplet; invoked by Bonobo * 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 (BonoboGenericFactory *factory, gpointer data) { - static BonoboControl *control = NULL; - static GladeXML *dialog; - static GtkWidget *widget; - BonoboPropertyBag *pb; GtkWidget *pf; @@ -204,6 +218,13 @@ create_dialog_cb (BonoboGenericFactory *factory, gpointer data) bonobo_property_bag_add (pb, "moniker", 1, BONOBO_ARG_STRING, NULL, "Moniker for configuration", BONOBO_PROPERTY_WRITEABLE); + + bonobo_control_set_automerge (control, TRUE); + + gtk_signal_connect (GTK_OBJECT (widget), "destroy", + GTK_SIGNAL_FUNC (close_cb), NULL); + gtk_signal_connect (GTK_OBJECT (control), "destroy", + GTK_SIGNAL_FUNC (close_cb), NULL); } else { gtk_widget_show_all (widget); } diff --git a/configure.in b/configure.in index f5f81eaa9..5c620ea3e 100644 --- a/configure.in +++ b/configure.in @@ -107,7 +107,7 @@ else AC_MSG_ERROR(You need at least pkg-config 0.6.0 or greater for this version of control-center. Please install a newer version from http://www.freedesktop.org/software.) fi -capplet_modules="libcapplet2 libglade gdk_pixbuf bonobo-conf $ARCHIVER_MODULE" +capplet_modules="libcapplet2 libglade gdk_pixbuf bonobo_conf $ARCHIVER_MODULE" PKG_CHECK_MODULES(CAPPLET, $capplet_modules) PKG_CHECK_MODULES(BG_CAPPLET, $capplet_modules gdk_pixbuf_xlib) diff --git a/control-center/ChangeLog b/control-center/ChangeLog index 397434343..ada901daa 100644 --- a/control-center/ChangeLog +++ b/control-center/ChangeLog @@ -1,3 +1,16 @@ +2001-07-03 Bradford Hovinen + + * main.c (main): Connect destroy signal on capplet window to + gtk_main_quit + + * capplet-dir.c (capplet_control_launch): Return pointer to + BonoboWindow + + * main.c (main): Check return value of capplet_control_launch + + * capplet-dir.c (capplet_control_launch): Use goto to make sure + all data structures are freed + 2001-07-02 Bradford Hovinen * capplet-dir.c (capplet_control_launch): Use bonobo_arg_... functions diff --git a/control-center/capplet-dir.c b/control-center/capplet-dir.c index 8e90a393f..81ccee0a8 100644 --- a/control-center/capplet-dir.c +++ b/control-center/capplet-dir.c @@ -393,10 +393,11 @@ capplet_cancel_cb (GtkWidget *widget, GtkWidget *app) /* capplet_control_launch * - * Launch a capplet as a Bonobo control + * Launch a capplet as a Bonobo control; returns the relevant BonoboWindow or + * NULL if the capplet could not be launched */ -void +GtkWidget * capplet_control_launch (const gchar *capplet_name) { gchar *oaf_iid, *moniker; @@ -434,10 +435,8 @@ capplet_control_launch (const gchar *capplet_name) if (control == NULL) { g_critical ("Could not create capplet control"); gtk_widget_destroy (app); - g_free (oaf_iid); - g_free (moniker); - g_free (tmp); - return; + app = NULL; + goto end; } gtk_box_pack_start (GTK_BOX (box), control, TRUE, TRUE, 0); @@ -460,22 +459,32 @@ capplet_control_launch (const gchar *capplet_name) if (BONOBO_EX (&ev)) { g_critical ("Could not get moniker property"); - } else { - value = bonobo_arg_new (BONOBO_ARG_STRING); - BONOBO_ARG_SET_STRING (value, moniker); - - Bonobo_Property_setValue (property, value, &ev); - - if (BONOBO_EX (&ev)) - g_critical ("Could not set moniker property"); - - bonobo_arg_release (value); + gtk_widget_destroy (app); + app = NULL; + goto end; } + value = bonobo_arg_new (BONOBO_ARG_STRING); + BONOBO_ARG_SET_STRING (value, moniker); + + Bonobo_Property_setValue (property, value, &ev); + + if (BONOBO_EX (&ev)) { + g_critical ("Could not set moniker property"); + gtk_widget_destroy (app); + app = NULL; + goto end; + } + + bonobo_arg_release (value); + gtk_widget_show_all (app); + end: CORBA_exception_free (&ev); g_free (oaf_iid); g_free (moniker); g_free (tmp); + + return app; } diff --git a/control-center/capplet-dir.h b/control-center/capplet-dir.h index a1e043c51..4b0c47a9b 100644 --- a/control-center/capplet-dir.h +++ b/control-center/capplet-dir.h @@ -90,6 +90,6 @@ void capplet_dir_init (CappletDirView *(*cb) CappletDir *get_root_capplet_dir (void); -void capplet_control_launch (const gchar *capplet_name); +GtkWidget *capplet_control_launch (const gchar *capplet_name); #endif /* __CAPPLET_DIR_H */ diff --git a/control-center/main.c b/control-center/main.c index dd4856636..5597488cb 100644 --- a/control-center/main.c +++ b/control-center/main.c @@ -37,6 +37,7 @@ int main (int argc, char **argv) { CORBA_ORB orb; + GtkWidget *app; static gchar *capplet = NULL; static struct poptOption gnomecc_options[] = { @@ -61,7 +62,11 @@ main (int argc, char **argv) capplet_dir_entry_activate (CAPPLET_DIR_ENTRY (get_root_capplet_dir ()), NULL); } else { - capplet_control_launch (capplet); + if ((app = capplet_control_launch (capplet)) == NULL) + return -1; + + gtk_signal_connect (GTK_OBJECT (app), "destroy", + GTK_SIGNAL_FUNC (gtk_main_quit), NULL); } bonobo_main ();