Re: Milestones document



> George wrote:
> > 
> > On Mon, Dec 06, 1999 at 01:09:24PM +1030, NotZed wrote:
> > > On that note, writing prefs dialogues and config saving sux bigtime -
> > > so much bloat for so little functionality, but anyway.
> > 
> > I was thinnking about a sort of preprocessor to create all the properties
> > code from a description of the peroperties themselves.  One of these days I
> > may actually write it :)
> > 
> > George
> 
> While this may appear a good idea from the standpoint of "it is easy to
> code", it is a horrible idea from a UI standpoint, because the UI is not
> being touched by the author of the application, and this makes small
> tweaks to improve the UI impossible, because it is being autogenerated.

As a compromise between the two, I have some code (not committed, and 
currently
very capplet specific) that will take a glade file, and let you hook up a 
GConf key to each widget.  This way, simple capplets can be written with a 
minimal
amount of hassling.  If you want to extend this to be more generic, it could 
be done.

-Jonathan

Here's a sample program.

static CappletInfo info[] =
{
	{"checkbutton", "/GNOME/Desktop/CappletTest/checkbutton_bool", 
GCONF_VALUE_BOOL, NULL, NULL, NULL, NULL, FALSE, NULL},
	{"checkbutton1", "/GNOME/Desktop/CappletTest/checkbutton_int", 
GCONF_VALUE_INT,  NULL, NULL, NULL, NULL, FALSE, NULL},
	{"radiobutton1", "/GNOME/Desktop/CappletTest/radiotest_bool", 
GCONF_VALUE_BOOL, NULL, NULL, NULL, NULL, FALSE, NULL},
	{"radiobutton4", "/GNOME/Desktop/CappletTest/radiotest_int", GCONF_VALUE_INT, 
NULL, NULL, NULL, NULL, FALSE, NULL},
	/* ... */
	{NULL}
};


int
main (gint argc, gchar *argv[])
{
	GladeXML *xml;
	GtkWidget *box;
	GConfError *error = NULL;
	GtkWidget *capplet;

	/* init various modules */
	glade_gnome_init ();
	gnome_capplet_init ("newcc", "0.1", argc, argv, NULL, 0, NULL);
	if (!gconf_init(argc, argv, &error)) {
		g_assert(error != NULL);
		g_warning("GConf init failed:\n  %s", error->str);
		return 1;
	}
	g_assert(error == NULL);

	/* Make the capplet */
	xml = glade_xml_new ("newcc.glade", NULL);
        box = glade_xml_get_widget (xml, "vbox1");
	capplet = capplet_widget_new ();

        gtk_container_add (GTK_CONTAINER (capplet), box);
	gtk_widget_show_all (capplet);

	/* initialize the rest of the widgets */
	capplet_info_set (CAPPLET_WIDGET (capplet), xml, info);

	gtk_signal_connect_after (GTK_OBJECT (capplet), "try", my_apply, NULL);
	gtk_signal_connect_after (GTK_OBJECT (capplet), "ok", my_apply, NULL);
	gtk_signal_connect_after (GTK_OBJECT (capplet), "revert", my_revert, NULL);
	gtk_signal_connect_after (GTK_OBJECT (capplet), "cancel", my_revert, NULL);
	capplet_gtk_main ();

	return 0;
}




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