Search code examples
monogtk#glade

Adding custom GTK# widget to Glade catalog


I've created a custom widget (with my own drawing) in C# using GTK# 3 toolkit. Now i want to use it in Glade designer. Is it possible to add this widget to Glade palette?

It seems that this documentation: https://developer.gnome.org/gladeui/unstable/catalogintro.html can be used to add widgets written in C/C++ to Glade palette, but what is the correct way to get the same result for widgets written in C#?

Thanks.


Solution

  • It may not be possible. The way to approach it would be to write a shim library in C that uses libmono to interoperate with your C# widgets. Here is a link to Mono's documentation on how to do that. The entry point into your shim library would then be listed in the <init-function> element in the Glade catalog.

    Alternatively, you can "fake" the widget classes in the Glade catalog; their properties and signals will appear (though you have to manually write them in the catalog file.) If they are container widgets you won't be able to add child widgets to them. They'll just appear as grey boxes in Glade. You do this by adding <glade-widget-class> elements to the catalog as described on this page of Glade's documentation.