[Gtk-sharp-list] custom widget handler

borco borco at borco.net
Mon Oct 24 11:13:03 EDT 2005


I am just starting to learn how to use the glade-sharp, but I have been
playing for some time with python-gtk and I am missing some of the
functionality from there. More specifically, I try to add some custom
widgets from glade. In python, it is enough to create a method with the
same name as that specified in glade to create the widget. The python
binding, when autoconnecting all the stuff, also dispatches the calls to
the correct methods for creating the custom controls, if the correct
method is detected.

For example, let's say I add a customTree in glade, to be built by the
createCustomTree method. When the python autoconnects, it searches for a
method named createCustomTree and calls it to produce the customTree widget.

>From what I have seen, with glade-sharp the only solution is to use
SetCustomHandler. However, this method needs some boilerplate that
should go in the binding, in my opinion. For example, now I do this in
my custom handler:


public Widget createCustomTree(string name,
	string s1, string s2, int i1, int i2)
	Button btn = new Button(name);
	return btn;

public Widget custom(XML xml, string func_name,
	string name, string s1, string s2,
	int i1, int i2)
	Widget w;
		case "createCustomTree":
			w = createCustomTree(name, s1, s2, i1, i2);
			// this should throw an exception
			w = new Button("Custom");

	return w;


The problem is this handler has hardcoded the methods used to create the
custom widgets. It would be great if the binding would provide a default
that checks the func_name and, using introspection, dispatches to the
correct method. Also, if the widget is also specified with:

[Widget] CustomTree customTree;

the custom should also store the reference of the custom widget in that

Is this already done and I simply missed it? Can it be done in the binding?

Also, how do I get the properties specified in the glade for the custom
widget (like it's minimum width)?

I have added a simple cs and glade file that illustrates the above state
of affairs...


Ionutz Borcoman

-------------- next part --------------
A non-text attachment was scrubbed...
Name: GuiApp.cs
Type: text/x-csharp
Size: 1068 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20051024/3972d17b/GuiApp-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DeweyGui.glade
Type: application/x-glade
Size: 5904 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20051024/3972d17b/DeweyGui-0001.bin

More information about the Gtk-sharp-list mailing list