cvs: php-gtk-doc /examples/tutorials/helloglade autoconnect.phpw autoconnect_instance.phpw connecting_by_hand.phpw helloglade.glade loading.phpw
partially.phpw /manual tutorials.xml /manual/en/tutorials glade.xml
| From: | Christian Weiske | Date: | Thu, 27 Apr 2006 13:59:50 +0000 |
| Subject: | cvs: php-gtk-doc /examples/tutorials/helloglade autoconnect.phpw autoconnect_instance.phpw connecting_by_hand.phpw helloglade.glade loading.phpw partially.phpw /manual tutorials.xml /manual/en/tutorials glade.xml |
||
| Groups: | php.gtk.doc | ||
| Request: | Send a blank email to php-gtk-doc+get-2528@lists.php.net to get a copy of this message | ||
cweiske Thu Apr 27 13:59:50 2006 UTC
Added files:
/php-gtk-doc/examples/tutorials/helloglade autoconnect.phpw
autoconnect_instance.phpw
connecting_by_hand.phpw
helloglade.glade
loading.phpw
partially.phpw
Modified files:
/php-gtk-doc/manual/en/tutorials glade.xml
/php-gtk-doc/manual tutorials.xml
Log:
Adding simple glade tutorial
http://cvs.php.net/viewcvs.cgi/php-gtk-doc/manual/en/tutorials/glade.xml?r1=1.2&r2=1.3&diff_format=u Index: php-gtk-doc/manual/en/tutorials/glade.xml diff -u php-gtk-doc/manual/en/tutorials/glade.xml:1.2 php-gtk-doc/manual/en/tutorials/glade.xml:1.3 --- php-gtk-doc/manual/en/tutorials/glade.xml:1.2 Sat Mar 25 16:31:22 2006 +++ php-gtk-doc/manual/en/tutorials/glade.xml Thu Apr 27 13:59:49 2006 @@ -1,11 +1,180 @@ <?xml version="1.0" encoding="utf-8" ?> -<chapter id="tutorials.glade"> - <title>Building Applications with Glade</title> +<chapter id="tutorials.helloglade"> + <title>Hello Glade!</title> <sect1> <title>About this tutorial</title> + <para> + This tutorial will show you the basics on how to use + <literal>.glade</literal> files from within your PHP-Gtk2 application. + </para> + <para> + Glade2 is a User Interface Designer, allowing you to create Gtk2 + application with just your mouse and no programming. The results of your + work are saved in a <filename>.glade</filename> file and can be loaded + into your PHP-Gtk2 application easily. + </para> <simpara> - <!-- TODO --> + Creating the user interface with Glade saves a lot of time, especially + in large projects and even gives you the ability to divide the work: + The interface designer person designes the GUI with Glade (and doesn't need + to know anything about programming) and you can concentrate on programming + rather than bother your mind with GUI accessibility tasks. </simpara> </sect1> -</chapter> + + + <sect1 id="tutorials.helloglade.preparation"> + <title>Preparation</title> + <simpara> + We will concentrate on doing things with Glade, not designing a + sophisticated interface. That's why the example + <filename>.glade</filename> file is pretty + simple; a window with a single button in it. + </simpara> + <para> + The window gets the name (id) <literal>wndClose</literal>, and the button + receives the name <literal>btnClose</literal>. + </para> + <example> + <title>The example .glade file - helloglade.glade</title> + <programlisting role="xml"> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" + href="&directory.examples;/tutorials/helloglade/helloglade.glade" parse="text"> + <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback> + </xi:include> + </programlisting> + </example> + </sect1> + + + <sect1 id="tutorials.helloglade.loading"> + <title>Loading the file</title> + + <para> + The first thing to do is loading the <filename>.glade</filename> + file from the previous section. <classname>GladeXML</classname> constructor + takes the file path as first parameter, so all we need to do is this: + </para> + <example> + <title>Loading the .glade file</title> + <programlisting role="xml"> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" + href="&directory.examples;/tutorials/helloglade/loading.phpw" parse="text"> + <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback> + </xi:include> + </programlisting> + </example> + <para> + When running the script, you will note that the window with the button appears + on your screen, but doesn't react to anything other than closing the window. + Even there, the window is destroyed but your script continues to run + - clearly a case of missing signal connections. + </para> + + <sect2 id="tutorials.helloglade.connecting"> + <title>Connecting signals by hand</title> + <para> + Next, we will just connect the signals as we know it: Call + <function class="GtkObject">connect</function> or + <function class="GtkObject">connect_simple</function> on + the widget object. To get the object, just use the + <function class="GladeXML">get_widget</function> method and pass + the widget's name (id) to it. Then do the job as usual: + </para> + <example> + <title>Getting and connecting the widgets</title> + <programlisting role="xml"> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" + href="&directory.examples;/tutorials/helloglade/connecting_by_hand.phpw" parse="text"> + <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback> + </xi:include> + </programlisting> + </example> + </sect2> + + <sect2 id="tutorials.helloglade.autoconnect"> + <title>Use Glade to connect the signals</title> + <para> + You probably noted the <signal> tags in the + <filename>.glade</filename> file - it is + possible to define signal handlers directly in the file. All we have to do + is telling Glade to establish the connections by calling + <function class="GladeXML">signal_autoconnect</function>. + </para> + <para> + You can either define plain function names as handler that will be + called when an event occurs, or use a special notation for + static method calls by separating class name and method name + with double colons as in <literal>Classname::methodName</literal>. + </para> + <example> + <title>Using signal_autoconnect</title> + <programlisting role="xml"> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" + href="&directory.examples;/tutorials/helloglade/autoconnect.phpw" parse="text"> + <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback> + </xi:include> + </programlisting> + </example> + </sect2> + + <sect2 id="tutorials.helloglade.autoconnect_instance"> + <title>Connecting to object methods</title> + <para> + Just connecting to plain functions or static methods doesn't really + fulfill the needs of a good programmer. To get away from spaghetti code, + we need to be able to connect signals to methods of objects. + </para> + <para> + Doing that is really simple: Just use + <function class="GladeXML">signal_autoconnect_instance</function> with + the object as first parameter instead of using + <function class="GladeXML">signal_autoconnect</function>: + </para> + <example> + <title>Using signal_autoconnect</title> + <programlisting role="xml"> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" + href="&directory.examples;/tutorials/helloglade/autoconnect_instance.phpw" parse="text"> + <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback> + </xi:include> + </programlisting> + </example> + </sect2> + + </sect1> + + + <sect1 id="tutorials.helloglade.partial"> + <title>Loading a part of a .glade file</title> + + <para> + In large projects, you might have many windows defined in your + <filename>.glade</filename> file, + and all are loaded when loading the + <filename>.glade</filename> file. That a) slows down the + start of your application and b) shows all windows immediately, if you + didn't set their visibility to hidden in Glade. Further, you may want to + <function class="GladeXML">signal_autoconnect_instance</function> + only a part of the <filename>.glade</filename> file to one object, + while connecting another part to another object. + </para> + <para> + The solution to this problem is the second parameter of the + <classname>GladeXML</classname> constructor: Just pass the id + of the to-be root widget, and only this part of the + <filename>.glade</filename> file will be loaded. + </para> + <example> + <title>Partially loading a .glade file</title> + <programlisting role="xml"> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" + href="&directory.examples;/tutorials/helloglade/partially.phpw" parse="text"> + <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback> + </xi:include> + </programlisting> + </example> + +</sect1> +</chapter> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/manual/tutorials.xml?r1=1.8&r2=1.9&diff_format=u Index: php-gtk-doc/manual/tutorials.xml diff -u php-gtk-doc/manual/tutorials.xml:1.8 php-gtk-doc/manual/tutorials.xml:1.9 --- php-gtk-doc/manual/tutorials.xml:1.8 Fri Mar 31 17:35:46 2006 +++ php-gtk-doc/manual/tutorials.xml Thu Apr 27 13:59:49 2006 @@ -4,10 +4,10 @@ <!-- &tutorials.installation; --> &tutorials.hello_world; &tutorials.helloadvanced; + &tutorials.glade; &tutorials.changes; &tutorials.gtk_pango_co; &tutorials.packing; -<!-- &tutorials.glade; --> &tutorials.objectorientation; &tutorials.signals; &tutorials.doccing; http://cvs.php.net/viewcvs.cgi/php-gtk-doc/examples/tutorials/helloglade/autoconnect.phpw?view=markup&rev=1.1 Index: php-gtk-doc/examples/tutorials/helloglade/autoconnect.phpw +++ php-gtk-doc/examples/tutorials/helloglade/autoconnect.phpw <?php //Create a new glade instance, load the // widgets from the file passed as parameter //We use the absolute file path as it is not uncommon // that the application is run from a different working directory $glade = new GladeXML(dirname(__FILE__) . '/helloglade.glade'); //Let glade do all the signal connections we specified in the file $glade->signal_autoconnect(); //This method is called when the button is clicked function onClickButton() { echo "button clicked!\r\n"; Gtk::main_quit(); } //Start the main loop Gtk::main(); ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/examples/tutorials/helloglade/autoconnect_instance.phpw?view=markup&rev=1.1 Index: php-gtk-doc/examples/tutorials/helloglade/autoconnect_instance.phpw +++ php-gtk-doc/examples/tutorials/helloglade/autoconnect_instance.phpw <?php //Here we use an object and connect all the // signals to *object methods* instead of // functions class MyClass { //This method is called when the button is clicked function onClickButton() { echo "MyClass->onClickButton!\r\n"; Gtk::main_quit(); } function staticMethod() { echo "MyClass::staticMethod()\r\n"; } } $glade = new GladeXML(dirname(__FILE__) . '/helloglade.glade'); //Let glade do all the signal connections we specified in the file // but this time, connect to the object methods $myClassInstance = new MyClass(); $glade->signal_autoconnect_instance($myClassInstance); //Start the main loop Gtk::main(); ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/examples/tutorials/helloglade/connecting_by_hand.phpw?view=markup&rev=1.1 Index: php-gtk-doc/examples/tutorials/helloglade/connecting_by_hand.phpw +++ php-gtk-doc/examples/tutorials/helloglade/connecting_by_hand.phpw <?php //Create a new glade instance, load the // widgets from the file passed as parameter //We use the absolute file path as it is not uncommon // that the application is run from a different working directory $glade = new GladeXML(dirname(__FILE__) . '/helloglade.glade'); //Nothing happened when you clicked the button or closed // the window with Step 1's code. //Here we manually connect the widget signals as you know it $window = $glade->get_widget('wndClose'); $window->connect_simple('destroy', array('Gtk', 'main_quit')); //Again, get the widget object and connect the clicked signal $button = $glade->get_widget('btnClose'); $button->connect_simple('clicked', 'onClickButton'); //This method is called when the button is clicked function onClickButton() { echo "button clicked!\r\n"; Gtk::main_quit(); } //Start the main loop Gtk::main(); ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/examples/tutorials/helloglade/helloglade.glade?view=markup&rev=1.1 Index: php-gtk-doc/examples/tutorials/helloglade/helloglade.glade +++ php-gtk-doc/examples/tutorials/helloglade/helloglade.glade <?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> <glade-interface> <widget class="GtkWindow" id="wndClose"> <property name="visible">True</property> <property name="title" translatable="yes">Close me</property> <property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="window_position">GTK_WIN_POS_NONE</property> <property name="modal">False</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</property> <property name="decorated">True</property> <property name="skip_taskbar_hint">False</property> <property name="skip_pager_hint">False</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <signal name="destroy" handler="gtk::main_quit"/> <child> <widget class="GtkButton" id="btnClose"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="label">gtk-close</property> <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> <signal name="clicked" handler="onClickButton"/> </widget> </child> </widget> </glade-interface> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/examples/tutorials/helloglade/loading.phpw?view=markup&rev=1.1 Index: php-gtk-doc/examples/tutorials/helloglade/loading.phpw +++ php-gtk-doc/examples/tutorials/helloglade/loading.phpw <?php //Create a new glade instance, load the // widgets from the file passed as parameter $glade = new GladeXML('helloglade.glade'); //Start the main loop Gtk::main(); ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/examples/tutorials/helloglade/partially.phpw?view=markup&rev=1.1 Index: php-gtk-doc/examples/tutorials/helloglade/partially.phpw +++ php-gtk-doc/examples/tutorials/helloglade/partially.phpw <?php //Loading a part of the glade file only //We want "btnClose" to be the root of the widget tree to load $glade = new GladeXML('helloglade.glade', 'btnClose'); //That will work $btn = $glade->get_widget('btnClose'); //This will fail, as the window isn't loaded: $window = $glade->get_widget('wndClose'); //Output is NULL var_dump($window); ?>
http://cvs.php.net/viewcvs.cgi/php-gtk-doc/manual/en/tutorials/glade.xml?r1=1.2&r2=1.3&diff_format=u Index: php-gtk-doc/manual/en/tutorials/glade.xml diff -u php-gtk-doc/manual/en/tutorials/glade.xml:1.2 php-gtk-doc/manual/en/tutorials/glade.xml:1.3 --- php-gtk-doc/manual/en/tutorials/glade.xml:1.2 Sat Mar 25 16:31:22 2006 +++ php-gtk-doc/manual/en/tutorials/glade.xml Thu Apr 27 13:59:49 2006 @@ -1,11 +1,180 @@ <?xml version="1.0" encoding="utf-8" ?> -<chapter id="tutorials.glade"> - <title>Building Applications with Glade</title> +<chapter id="tutorials.helloglade"> + <title>Hello Glade!</title> <sect1> <title>About this tutorial</title> + <para> + This tutorial will show you the basics on how to use + <literal>.glade</literal> files from within your PHP-Gtk2 application. + </para> + <para> + Glade2 is a User Interface Designer, allowing you to create Gtk2 + application with just your mouse and no programming. The results of your + work are saved in a <filename>.glade</filename> file and can be loaded + into your PHP-Gtk2 application easily. + </para> <simpara> - <!-- TODO --> + Creating the user interface with Glade saves a lot of time, especially + in large projects and even gives you the ability to divide the work: + The interface designer person designes the GUI with Glade (and doesn't need + to know anything about programming) and you can concentrate on programming + rather than bother your mind with GUI accessibility tasks. </simpara> </sect1> -</chapter> + + + <sect1 id="tutorials.helloglade.preparation"> + <title>Preparation</title> + <simpara> + We will concentrate on doing things with Glade, not designing a + sophisticated interface. That's why the example + <filename>.glade</filename> file is pretty + simple; a window with a single button in it. + </simpara> + <para> + The window gets the name (id) <literal>wndClose</literal>, and the button + receives the name <literal>btnClose</literal>. + </para> + <example> + <title>The example .glade file - helloglade.glade</title> + <programlisting role="xml"> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" + href="&directory.examples;/tutorials/helloglade/helloglade.glade" parse="text"> + <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback> + </xi:include> + </programlisting> + </example> + </sect1> + + + <sect1 id="tutorials.helloglade.loading"> + <title>Loading the file</title> + + <para> + The first thing to do is loading the <filename>.glade</filename> + file from the previous section. <classname>GladeXML</classname> constructor + takes the file path as first parameter, so all we need to do is this: + </para> + <example> + <title>Loading the .glade file</title> + <programlisting role="xml"> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" + href="&directory.examples;/tutorials/helloglade/loading.phpw" parse="text"> + <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback> + </xi:include> + </programlisting> + </example> + <para> + When running the script, you will note that the window with the button appears + on your screen, but doesn't react to anything other than closing the window. + Even there, the window is destroyed but your script continues to run + - clearly a case of missing signal connections. + </para> + + <sect2 id="tutorials.helloglade.connecting"> + <title>Connecting signals by hand</title> + <para> + Next, we will just connect the signals as we know it: Call + <function class="GtkObject">connect</function> or + <function class="GtkObject">connect_simple</function> on + the widget object. To get the object, just use the + <function class="GladeXML">get_widget</function> method and pass + the widget's name (id) to it. Then do the job as usual: + </para> + <example> + <title>Getting and connecting the widgets</title> + <programlisting role="xml"> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" + href="&directory.examples;/tutorials/helloglade/connecting_by_hand.phpw" parse="text"> + <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback> + </xi:include> + </programlisting> + </example> + </sect2> + + <sect2 id="tutorials.helloglade.autoconnect"> + <title>Use Glade to connect the signals</title> + <para> + You probably noted the <signal> tags in the + <filename>.glade</filename> file - it is + possible to define signal handlers directly in the file. All we have to do + is telling Glade to establish the connections by calling + <function class="GladeXML">signal_autoconnect</function>. + </para> + <para> + You can either define plain function names as handler that will be + called when an event occurs, or use a special notation for + static method calls by separating class name and method name + with double colons as in <literal>Classname::methodName</literal>. + </para> + <example> + <title>Using signal_autoconnect</title> + <programlisting role="xml"> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" + href="&directory.examples;/tutorials/helloglade/autoconnect.phpw" parse="text"> + <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback> + </xi:include> + </programlisting> + </example> + </sect2> + + <sect2 id="tutorials.helloglade.autoconnect_instance"> + <title>Connecting to object methods</title> + <para> + Just connecting to plain functions or static methods doesn't really + fulfill the needs of a good programmer. To get away from spaghetti code, + we need to be able to connect signals to methods of objects. + </para> + <para> + Doing that is really simple: Just use + <function class="GladeXML">signal_autoconnect_instance</function> with + the object as first parameter instead of using + <function class="GladeXML">signal_autoconnect</function>: + </para> + <example> + <title>Using signal_autoconnect</title> + <programlisting role="xml"> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" + href="&directory.examples;/tutorials/helloglade/autoconnect_instance.phpw" parse="text"> + <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback> + </xi:include> + </programlisting> + </example> + </sect2> + + </sect1> + + + <sect1 id="tutorials.helloglade.partial"> + <title>Loading a part of a .glade file</title> + + <para> + In large projects, you might have many windows defined in your + <filename>.glade</filename> file, + and all are loaded when loading the + <filename>.glade</filename> file. That a) slows down the + start of your application and b) shows all windows immediately, if you + didn't set their visibility to hidden in Glade. Further, you may want to + <function class="GladeXML">signal_autoconnect_instance</function> + only a part of the <filename>.glade</filename> file to one object, + while connecting another part to another object. + </para> + <para> + The solution to this problem is the second parameter of the + <classname>GladeXML</classname> constructor: Just pass the id + of the to-be root widget, and only this part of the + <filename>.glade</filename> file will be loaded. + </para> + <example> + <title>Partially loading a .glade file</title> + <programlisting role="xml"> + <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" + href="&directory.examples;/tutorials/helloglade/partially.phpw" parse="text"> + <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback> + </xi:include> + </programlisting> + </example> + +</sect1> +</chapter> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/manual/tutorials.xml?r1=1.8&r2=1.9&diff_format=u Index: php-gtk-doc/manual/tutorials.xml diff -u php-gtk-doc/manual/tutorials.xml:1.8 php-gtk-doc/manual/tutorials.xml:1.9 --- php-gtk-doc/manual/tutorials.xml:1.8 Fri Mar 31 17:35:46 2006 +++ php-gtk-doc/manual/tutorials.xml Thu Apr 27 13:59:49 2006 @@ -4,10 +4,10 @@ <!-- &tutorials.installation; --> &tutorials.hello_world; &tutorials.helloadvanced; + &tutorials.glade; &tutorials.changes; &tutorials.gtk_pango_co; &tutorials.packing; -<!-- &tutorials.glade; --> &tutorials.objectorientation; &tutorials.signals; &tutorials.doccing; http://cvs.php.net/viewcvs.cgi/php-gtk-doc/examples/tutorials/helloglade/autoconnect.phpw?view=markup&rev=1.1 Index: php-gtk-doc/examples/tutorials/helloglade/autoconnect.phpw +++ php-gtk-doc/examples/tutorials/helloglade/autoconnect.phpw <?php //Create a new glade instance, load the // widgets from the file passed as parameter //We use the absolute file path as it is not uncommon // that the application is run from a different working directory $glade = new GladeXML(dirname(__FILE__) . '/helloglade.glade'); //Let glade do all the signal connections we specified in the file $glade->signal_autoconnect(); //This method is called when the button is clicked function onClickButton() { echo "button clicked!\r\n"; Gtk::main_quit(); } //Start the main loop Gtk::main(); ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/examples/tutorials/helloglade/autoconnect_instance.phpw?view=markup&rev=1.1 Index: php-gtk-doc/examples/tutorials/helloglade/autoconnect_instance.phpw +++ php-gtk-doc/examples/tutorials/helloglade/autoconnect_instance.phpw <?php //Here we use an object and connect all the // signals to *object methods* instead of // functions class MyClass { //This method is called when the button is clicked function onClickButton() { echo "MyClass->onClickButton!\r\n"; Gtk::main_quit(); } function staticMethod() { echo "MyClass::staticMethod()\r\n"; } } $glade = new GladeXML(dirname(__FILE__) . '/helloglade.glade'); //Let glade do all the signal connections we specified in the file // but this time, connect to the object methods $myClassInstance = new MyClass(); $glade->signal_autoconnect_instance($myClassInstance); //Start the main loop Gtk::main(); ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/examples/tutorials/helloglade/connecting_by_hand.phpw?view=markup&rev=1.1 Index: php-gtk-doc/examples/tutorials/helloglade/connecting_by_hand.phpw +++ php-gtk-doc/examples/tutorials/helloglade/connecting_by_hand.phpw <?php //Create a new glade instance, load the // widgets from the file passed as parameter //We use the absolute file path as it is not uncommon // that the application is run from a different working directory $glade = new GladeXML(dirname(__FILE__) . '/helloglade.glade'); //Nothing happened when you clicked the button or closed // the window with Step 1's code. //Here we manually connect the widget signals as you know it $window = $glade->get_widget('wndClose'); $window->connect_simple('destroy', array('Gtk', 'main_quit')); //Again, get the widget object and connect the clicked signal $button = $glade->get_widget('btnClose'); $button->connect_simple('clicked', 'onClickButton'); //This method is called when the button is clicked function onClickButton() { echo "button clicked!\r\n"; Gtk::main_quit(); } //Start the main loop Gtk::main(); ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/examples/tutorials/helloglade/helloglade.glade?view=markup&rev=1.1 Index: php-gtk-doc/examples/tutorials/helloglade/helloglade.glade +++ php-gtk-doc/examples/tutorials/helloglade/helloglade.glade <?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> <glade-interface> <widget class="GtkWindow" id="wndClose"> <property name="visible">True</property> <property name="title" translatable="yes">Close me</property> <property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="window_position">GTK_WIN_POS_NONE</property> <property name="modal">False</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</property> <property name="decorated">True</property> <property name="skip_taskbar_hint">False</property> <property name="skip_pager_hint">False</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <signal name="destroy" handler="gtk::main_quit"/> <child> <widget class="GtkButton" id="btnClose"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="label">gtk-close</property> <property name="use_stock">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> <signal name="clicked" handler="onClickButton"/> </widget> </child> </widget> </glade-interface> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/examples/tutorials/helloglade/loading.phpw?view=markup&rev=1.1 Index: php-gtk-doc/examples/tutorials/helloglade/loading.phpw +++ php-gtk-doc/examples/tutorials/helloglade/loading.phpw <?php //Create a new glade instance, load the // widgets from the file passed as parameter $glade = new GladeXML('helloglade.glade'); //Start the main loop Gtk::main(); ?> http://cvs.php.net/viewcvs.cgi/php-gtk-doc/examples/tutorials/helloglade/partially.phpw?view=markup&rev=1.1 Index: php-gtk-doc/examples/tutorials/helloglade/partially.phpw +++ php-gtk-doc/examples/tutorials/helloglade/partially.phpw <?php //Loading a part of the glade file only //We want "btnClose" to be the root of the widget tree to load $glade = new GladeXML('helloglade.glade', 'btnClose'); //That will work $btn = $glade->get_widget('btnClose'); //This will fail, as the window isn't loaded: $window = $glade->get_widget('wndClose'); //Output is NULL var_dump($window); ?>