Connect destroy signal on capplet window to gtk_main_quit

2001-07-03  Bradford Hovinen  <hovinen@ximian.com>

	* 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
This commit is contained in:
Bradford Hovinen 2001-07-03 17:18:50 +00:00 committed by Bradford Hovinen (Gdict maintainer)
parent 9a1ac9dd28
commit 8496ca47a5
6 changed files with 73 additions and 25 deletions

View file

@ -49,6 +49,10 @@
#include <esd.h>
#include <sys/types.h>
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);
}

View file

@ -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)

View file

@ -1,3 +1,16 @@
2001-07-03 Bradford Hovinen <hovinen@ximian.com>
* 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 <hovinen@ximian.com>
* capplet-dir.c (capplet_control_launch): Use bonobo_arg_... functions

View file

@ -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 {
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))
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;
}

View file

@ -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 */

View file

@ -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 ();