Laying out dialog boxes.




Hello guys,

   I am now in the process of doing a GNU midnight commander port to
Gtk/Gnome and I have 40 dialog boxes that lack any GUI-usable layout
information (in the text mode edition they use dialog-relative
column,rows for positioning).

   The Tk edition of the program (ie, C code calling Tk routines for
the GUI) uses a slick trick to manage dialog boxes: it assigns a name
(a string) to every widget created and then invokes a dialog-run
routine.

   When using the Tk frontend, the dialog-run routine then checks if
the layout information for this dialog box exists or if new widgets
have been added to the box then it invokes a GUI designer and the user
can put the widgets in the most nice way he manages to.  The GUI
information is then saved and later invocations of the program use the
dialog layout.

   I want to do a similar thing for the Gnome edition.  Currently, the
widget names are already assigned (since they are used for the Tk
edition), my plan is to modify Gubi to do the work for me, so creating
a dialog box for Gnome apps would look like:

void 
some_dialog (void)
{
	GtkWidget *username, *pass, *list, *ok_button;
	GnomeDialog *dlg;

	dlg = gnome_dlg_new ("My Dialog");

	input = gnome_widget (dlg, "GtkEntry", "entry-1");
	pass  = gnome_widget (dlg, "GtkEntry", "entry-2");
	list  = gnome_widget (dlg, "GtkList",  "list");
	ok_button = gnome_widget (dlg, "GtkButton", "button");

	gnome_dlg_run (dlg);

	/* do something with the contents of input, pass, list here */
}

The GUI designer would be invoked with those 4 widgets, the user would
be able to add extra decorations and packings to the dialog boxes and
the layout file can be saved either as a text description or as C code
that executes the layout.

The gnome_widget routine will look like:

GtkWidget *
gnome_widget (GnomeDialog *dlg, char *class, char *binding)
{
	if (dlg->have_layout){
		return (g_hash_table_lookup (dlg->hash, binding);
	} else {
		/* setup for invoking GUI designer */
	}
}

Am I missing something?  Is there an important hole in this?

Best wishes,
Miguel.




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