bonobo-conf generated preferences dialog



Hi all,

Here's an example that shows how bonobo-conf generates preferences
dialogs for you. It uses the same data as the evolution-calendar-config
example from the bonobo-conf-0.6/examples dir. Just modify the
Makefile.am to reflect the new filename (prefdialog).

When you've got it running, you can compare the generated stuff to a
custom gui (prefdialog vs evolution-calendar-config). The last one is
obviously nicer and easier to use, but that one needs custom
programming. For gIDE, we might consider a mix of the two: for default
components like the scintilla editor, we might want to write custom gui
code. For non-standard components, we might want to use the generated
stuff.

Maybe there is a way for a BonoboControl to provide it's own custom
preferences dialog, but i haven't seen it.

Jeroen
#include <config.h>
#include <bonobo.h>
#include <bonobo-conf/bonobo-config-control.h>

static gint
create_dialog ()
{
	BonoboConfigControl *config_control;
	Bonobo_PropertyBag pb;
	GtkWidget *dialog;
	
	CORBA_Environment ev;
	CORBA_exception_init (&ev);
	
	config_control = bonobo_config_control_new (NULL);
	
	pb = bonobo_get_object ("xmldb:/tmp/calendar.xmldb#config:Calendar", "Bonobo/PropertyBag", &ev);	
	bonobo_config_control_add_page (config_control, "Calendar", pb, NULL, NULL);
	
	pb = bonobo_get_object ("xmldb:/tmp/calendar.xmldb#config:TaskPad", "Bonobo/PropertyBag", &ev);	
	bonobo_config_control_add_page (config_control, "TaskPad", pb, NULL, NULL);

	pb = bonobo_get_object ("xmldb:/tmp/calendar.xmldb#config:Reminders", "Bonobo/PropertyBag", &ev);	
	bonobo_config_control_add_page (config_control, "Reminders", pb, NULL, NULL);

	dialog = bonobo_preferences_new (BONOBO_OBJREF (config_control));
	
	gtk_signal_connect (GTK_OBJECT (dialog), "destroy",
			    gtk_main_quit, NULL);

	gtk_widget_show (dialog);
	
	return 0;
}

int
main (int argc, char **argv)
{
	bindtextdomain (PACKAGE, GNOMELOCALEDIR);
	textdomain (PACKAGE);

	gnome_init ("pref-dialog-test", "0.0", argc, argv);

	if ((oaf_init (argc, argv)) == NULL)
		g_error ("Cannot init oaf");

	if (bonobo_init (NULL, NULL, NULL) == FALSE)
		g_error ("Cannot init bonobo");

	gtk_idle_add ((GtkFunction) create_dialog, NULL);

	bonobo_main ();

	exit (0);
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]