Basic builder » History » Revision 4
Revision 3 (iri, 02/22/2011 02:23 PM) → Revision 4/7 (iri, 02/22/2011 02:29 PM)
h1. Basic builder It's a very simple interface built with GtkBuilder. # add the file with _gtkBuilderNewFromFile # if needed, get any included object (for example, a window, a button ...) with _gtkBuilderWidgetGet # if needed, define any callback and others codes ... # run the GTK+ loop. Note : It don't need to call _gtkWidgetShow(All), all included widgets will be automatically shown. Look this Scol code : <pre><code class="php"> fun cbDestroy (obj, uparam)= _fooS strcat "upram = " itoa uparam; _gtkMainQuit; 0;; fun cbButtonClicked (obj, uparam)= _fooS strcat "button param = " uparam; 0;; fun main ()= _showconsole; // add a .xml .glade file let _gtkBuilderNewFromFile _channel _checkpack "tests/2dgtk/0.glade" -> builder in // get object from the builder : a window and a button let _gtkBuilderWidgetGet builder "main_window" -> win in let _gtkBuilderWidgetGet builder "button_1" -> button in ( // define the callbacks _gtkWindowCBdestroyed win @cbDestroy 10; _gtkButtonCB button @cbButtonClicked "yes !" SCOL_GTK_BUTTON_CB_CLICKED; // run the GTK+ loop _gtkMain; 0 );; </code></pre> and now, the xml file : <pre><code class="xml"> <?xml version="1.0"?> <interface> <requires lib="gtk+" version="2.16"/> <!-- interface-naming-policy project-wide --> <object class="GtkWindow" id="main_window"> <property name="visible">True</property> <property name="title" translatable="yes">Test 2dGtk - 0</property> <child> <object class="GtkVBox" id="main_box"> <property name="visible">True</property> <property name="spacing">5</property> <child> <object class="GtkButton" id="button_1"> <property name="label" translatable="yes">button 1</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> </object> <packing> <property name="position">0</property> </packing> </child> </object> </child> </object> </interface> </code></pre> Return [[Examples]]