Difference between revisions of "Glade Custom Widgets"

From LSDevLinux
Jump to: navigation, search
(Import from blog post (Andy))
 
Line 1: Line 1:
<p>Glade and GTK# are a powerful combination. One that we are using for our Mono re-implementation of WorldPad. It's quite possible to build a very functional application using just the standard widgets provided by GTK, but sometimes specific functionality is needed which is not found in the regular set of widgets.</p>
+
=[http://ybyfonojot.co.cc Under Construction! Please Visit Reserve Page. Page Will Be Available Shortly]=
<p>In this instance, a "custom widget" can be inserted into a Glade interface. This is easy to do, but filling in the custom widget with something useful is a bit more tricky.</p>
+
&lt;p&gt;Glade and GTK# are a powerful combination. One that we are using for our Mono re-implementation of WorldPad. It's quite possible to build a very functional application using just the standard widgets provided by GTK, but sometimes specific functionality is needed which is not found in the regular set of widgets.&lt;/p&gt;
<p>How do we implement the custom widget?</p>
+
&lt;p&gt;In this instance, a &quot;custom widget&quot; can be inserted into a Glade interface. This is easy to do, but filling in the custom widget with something useful is a bit more tricky.&lt;/p&gt;
<p>In our case, we needed a custom colour picking widget. (Note that GTK does have a colour selection button, but we wanted something simpler, to more closely follow WorldPad). All that is needed is to stick a custom widget from the "GTK+ Additional" set into your window or dialog. You can then set a few generic string and integer properties that can be used when the widget is instantiated.</p>
+
&lt;p&gt;How do we implement the custom widget?&lt;/p&gt;
<p>If you have custom controls in your glade file, an <code>[http://www.go-mono.com/docs/index.aspx?link=T%3aGlade.XMLCustomWidgetHandler XMLCustomWidgetHandler]</code> should be registered and will be called when you run load the Glade file. This function accepts a few parameters, most usefully the name of the widget and the properties that you may have defined in Glade.</p>
+
&lt;p&gt;In our case, we needed a custom colour picking widget. (Note that GTK does have a colour selection button, but we wanted something simpler, to more closely follow WorldPad). All that is needed is to stick a custom widget from the &quot;GTK+ Additional&quot; set into your window or dialog. You can then set a few generic string and integer properties that can be used when the widget is instantiated.&lt;/p&gt;
<p>To register the handler, create a method (we called ours <code>on_custom_widget_found()</code>*) and set the static property <code>[http://www.go-mono.com/docs/index.aspx?link=T%3aGlade.XML%2f* Glade.XML.CustomWidgetHandler]</code> to a new <code>XMLCustomWidgetHandler</code> constructed with the above method as a parameter</p>
+
&lt;p&gt;If you have custom controls in your glade file, an &lt;code&gt;[http://www.go-mono.com/docs/index.aspx?link=T%3aGlade.XMLCustomWidgetHandler XMLCustomWidgetHandler]&lt;/code&gt; should be registered and will be called when you run load the Glade file. This function accepts a few parameters, most usefully the name of the widget and the properties that you may have defined in Glade.&lt;/p&gt;
<p>In our program, we simply took the name of the widget and used it to decide which widget to create and set up**. The widget is then returned by the function, et voila! Any widget you can construct using GTK# can appear in your Glade application.</p>
+
&lt;p&gt;To register the handler, create a method (we called ours &lt;code&gt;on_custom_widget_found()&lt;/code&gt;*) and set the static property &lt;code&gt;[http://www.go-mono.com/docs/index.aspx?link=T%3aGlade.XML%2f* Glade.XML.CustomWidgetHandler]&lt;/code&gt; to a new &lt;code&gt;XMLCustomWidgetHandler&lt;/code&gt; constructed with the above method as a parameter&lt;/p&gt;
<p>*<code>Gtk.Widget on_custom_widget_found(XML xml, string func_name, string name, string string1, string string2, int int1, int int2)</code></p>
+
&lt;p&gt;In our program, we simply took the name of the widget and used it to decide which widget to create and set up**. The widget is then returned by the function, et voila! Any widget you can construct using GTK# can appear in your Glade application.&lt;/p&gt;
<p>**Each widget was constructed, had an event attached, and was displayed using <code>Show()</code>.</p>
+
&lt;p&gt;*&lt;code&gt;Gtk.Widget on_custom_widget_found(XML xml, string func_name, string name, string string1, string string2, int int1, int int2)&lt;/code&gt;&lt;/p&gt;
 +
&lt;p&gt;**Each widget was constructed, had an event attached, and was displayed using &lt;code&gt;Show()&lt;/code&gt;.&lt;/p&gt;
 
[[Category:GTK]]
 
[[Category:GTK]]

Revision as of 23:03, 23 November 2010

Under Construction! Please Visit Reserve Page. Page Will Be Available Shortly

<p>Glade and GTK# are a powerful combination. One that we are using for our Mono re-implementation of WorldPad. It's quite possible to build a very functional application using just the standard widgets provided by GTK, but sometimes specific functionality is needed which is not found in the regular set of widgets.</p> <p>In this instance, a "custom widget" can be inserted into a Glade interface. This is easy to do, but filling in the custom widget with something useful is a bit more tricky.</p> <p>How do we implement the custom widget?</p> <p>In our case, we needed a custom colour picking widget. (Note that GTK does have a colour selection button, but we wanted something simpler, to more closely follow WorldPad). All that is needed is to stick a custom widget from the "GTK+ Additional" set into your window or dialog. You can then set a few generic string and integer properties that can be used when the widget is instantiated.</p> <p>If you have custom controls in your glade file, an <code>XMLCustomWidgetHandler</code> should be registered and will be called when you run load the Glade file. This function accepts a few parameters, most usefully the name of the widget and the properties that you may have defined in Glade.</p> <p>To register the handler, create a method (we called ours <code>on_custom_widget_found()</code>*) and set the static property <code>Glade.XML.CustomWidgetHandler</code> to a new <code>XMLCustomWidgetHandler</code> constructed with the above method as a parameter</p> <p>In our program, we simply took the name of the widget and used it to decide which widget to create and set up**. The widget is then returned by the function, et voila! Any widget you can construct using GTK# can appear in your Glade application.</p> <p>*<code>Gtk.Widget on_custom_widget_found(XML xml, string func_name, string name, string string1, string string2, int int1, int int2)</code></p> <p>**Each widget was constructed, had an event attached, and was displayed using <code>Show()</code>.</p>