cvs: presentations /slides/gtk boxes.xml callbacks.xml connecting.xml connecting2.xml creating.xml extensions.xml focus.xml gencontainer.xml
gensteps.xml glade.xml mainloop.xml php-gtk-2.xml php-gtk-2a.xml php-gtk-2b.xml problems.xml resources.xml sensitivity.xml showing.xml signals.xml
sizepos.xml tempconv-g.php tempconv.glade tempconv.php tempconv.xml thankyou.xml widget-hierarchy.xml windows.xml windows2.xml
| From: | Andrei Zmievski | Date: | Mon, 19 Jan 2004 00:51:46 +0000 |
| Subject: | cvs: presentations /slides/gtk boxes.xml callbacks.xml connecting.xml connecting2.xml creating.xml extensions.xml focus.xml gencontainer.xml gensteps.xml glade.xml mainloop.xml php-gtk-2.xml php-gtk-2a.xml php-gtk-2b.xml problems.xml resources.xml sensitivity.xml showing.xml signals.xml sizepos.xml tempconv-g.php tempconv.glade tempconv.php tempconv.xml thankyou.xml widget-hierarchy.xml windows.xml windows2.xml |
||
| Groups: | php.pres | ||
| Request: | Send a blank email to pres+get-936@lists.php.net to get a copy of this message | ||
andrei Sun Jan 18 19:51:46 2004 EDT
Added files:
/presentations/slides/gtk boxes.xml connecting.xml connecting2.xml
extensions.xml focus.xml gencontainer.xml
glade.xml mainloop.xml php-gtk-2.xml
php-gtk-2a.xml php-gtk-2b.xml
problems.xml resources.xml
sensitivity.xml showing.xml sizepos.xml
tempconv-g.php tempconv.glade
tempconv.php tempconv.xml thankyou.xml
widget-hierarchy.xml windows.xml
windows2.xml
Modified files:
/presentations/slides/gtk callbacks.xml creating.xml gensteps.xml
signals.xml
Log:
Index: presentations/slides/gtk/callbacks.xml diff -u presentations/slides/gtk/callbacks.xml:1.1 presentations/slides/gtk/callbacks.xml:1.2 --- presentations/slides/gtk/callbacks.xml:1.1 Wed Jan 7 18:49:18 2004 +++ presentations/slides/gtk/callbacks.xml Sun Jan 18 19:51:45 2004 @@ -2,14 +2,17 @@ <blurb>The user-defined signal handlers are called ~callbacks~.</blurb> - <blurb>The first parameter normally passed to callbacks is the widget that + <blurb>The first parameter the callback receives is the widget that emitted the signal. The rest are signal-dependent. For example, the callback - for 'switch_page' signal of GtkNotebook class would look like this:</blurb> + for %switch_page% signal of *GtkNotebook* class would look like this:</blurb> <example fontsize="1.5ex"><![CDATA[<?php function on_switch_page($notebook, $page, page_num) { } ?>]]></example> - <blurb>The low-level event callbacks receive an additional parameter object - describing the event. It has fields for event type, button number if it was a - mouse click, key code if it was a key press, etc.</blurb> + <blurb>where %$page% is the object representing the page that was switched to, + and %$page_num% is its page number.</blurb> + + <blurb>The low-level event callbacks receive an additional object describing + the event. It has properties for event type, button number if it was a mouse + click, key code if it was a key press, etc.</blurb> <blurb>It is possible to connect more than one callback to the same signal. They will be run in the order they are connected. It is also possible to Index: presentations/slides/gtk/creating.xml diff -u presentations/slides/gtk/creating.xml:1.1 presentations/slides/gtk/creating.xml:1.2 --- presentations/slides/gtk/creating.xml:1.1 Wed Jan 7 18:49:18 2004 +++ presentations/slides/gtk/creating.xml Sun Jan 18 19:51:45 2004 @@ -1,16 +1,22 @@ <slide title="Creating and Destroying" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> - To create a widget, use %&new% operator instead of %new%. Some - widgets take constructor parameters to initialize themselves to some - state. + To create a widget, use |0033aa|%&new%| operator instead of + |0033aa|%new%|. Some widgets take constructor parameters to initialize + themselves to some state. </blurb> + <example fontsize="1.5ex"><![CDATA[<?php $vbox =& new GtkVBox(false, 5); ?>]]></example> <blurb> - To destroy a widget, use %destroy()% method. This is rarely used because all + Some widgets may be created by factories or other static methods: + </blurb> + <example fontsize="1.5ex"><![CDATA[<?php list($pixmap, $mask) = gdk::pixmap_create_from_xpm(...); ?>]]></example> + <blurb> + To destroy a widget, call its %destroy()% method. This is rarely used because all widgets are destroyed automatically upon the application's exit. </blurb> <blurb> - Destroying a widget will not + Note that simply unsetting the widget variable will not work in PHP 4 due to + Zend Engine limitations. </blurb> </slide> Index: presentations/slides/gtk/gensteps.xml diff -u presentations/slides/gtk/gensteps.xml:1.1 presentations/slides/gtk/gensteps.xml:1.2 --- presentations/slides/gtk/gensteps.xml:1.1 Wed Jan 7 18:49:18 2004 +++ presentations/slides/gtk/gensteps.xml Sun Jan 18 19:51:45 2004 @@ -3,7 +3,7 @@ <list type="number" fontsize="2ex"> <bullet>Instantiate the widget object of the appropriate class</bullet> </list> - <example fontsize="1ex"><![CDATA[<?php $ok = &new GtkButton('OK'); ?>]]></example> + <example fontsize="1ex"><![CDATA[<?php $ok =& new GtkButton('OK'); ?>]]></example> <list type="number" num="2" fontsize="2ex"> <bullet>Connect the signals to callbacks</bullet> </list> Index: presentations/slides/gtk/signals.xml diff -u presentations/slides/gtk/signals.xml:1.1 presentations/slides/gtk/signals.xml:1.2 --- presentations/slides/gtk/signals.xml:1.1 Wed Jan 7 18:49:18 2004 +++ presentations/slides/gtk/signals.xml Sun Jan 18 19:51:45 2004 @@ -7,7 +7,9 @@ <blurb>The passing of control is implemented via ~signals~. When a widget experiences an event, it ~emits~ a signal. Every signal is uniquely identified by name, but two different widgets may have the signal of the - same name but different meaning.</blurb> + same name but different meaning. Signals are inherited by widgets from up the + widget hierarchy, i.e. *GtkButton* will have all the signals that *GtkWidget* + has.</blurb> <blurb>Signals present a way to customize application's behavior according to the developer's needs and user's actions. Each signal has a default Index: presentations/slides/gtk/boxes.xml +++ presentations/slides/gtk/boxes.xml <slide title="Boxes" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> A more sophisticated container is a ~box~. It allows you to place, or ~pack~, more than one widget inside a simple container. There are horizontal (*GtkHBox*) and vertical (*GtkVBox*) boxes that pack their widgets correspondingly. First, create a new box: </blurb> <example fontsize="1.3ex"><![CDATA[<?php $box =& new GtkHBox($homogenous = false, $spacing = 0); ?>]]></example> <blurb> </blurb> <blurb> Then place some widgets into it using either %pack_start()% method (packs left-to-right for HBox and top-to-bottom for VBox) or %pack_end()% method (vice versa). </blurb> <example fontsize="1.3ex"><![CDATA[<?php $box->pack_start($child, $expand = true, $fill = true, $padding = 0); ?>]]></example> <blurb> </blurb> <blurb> You can nest the boxes to any degree, thus creating complex containment patterns. </blurb> </slide> Index: presentations/slides/gtk/connecting.xml +++ presentations/slides/gtk/connecting.xml <slide title="Connecting Signals" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> The most basic way of connecting a signal to a callback with with %connect()% method. For example, to respond to a %'clicked'% signal on a *GtkButton* widget, you would do this: </blurb> <example fontsize="1ex"><![CDATA[<?php function on_ok_clicked($button) { } $ok_button->connect('clicked', 'on_ok_clicked'); ?>]]></example> <blurb> If you wanted to connect to a class method or an object method, you have to use a special syntax for denoting that: </blurb> <example fontsize="1ex"><![CDATA[<?php class A { function on_ok_clicked($button) { } } $ok_button->connect('clicked', array('A', 'on_ok_clicked')); // connect to a class method $a_obj = new A(); $ok_button->connect('clicked', array(&$a_obj, 'on_ok_clicked')); // connect to an instance method ?>]]></example> </slide> Index: presentations/slides/gtk/connecting2.xml +++ presentations/slides/gtk/connecting2.xml <slide title="Connecting Signals" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> Sometimes the callbacks needs access to program data or other information. To avoid messing with global variables, you can pass the additional data to the callback when you connect it. </blurb> <example fontsize="1.3ex"><![CDATA[<?php function on_ok_clicked($button, $window, $my_data) { } $ok_button->connect('clicked', 'on_ok_clicked', $window, 'some data'); ?>]]></example> <blurb>%connect()% returns an number that uniquely identifies the connection made. This can be useful if you want to disable or remove the callback during the execution. </blurb> <example fontsize="1.3ex"><![CDATA[<?php $conn_id = $ok_button->connect('clicked', 'on_ok_clicked'); $ok_button->signal_handler_block($conn_id); // disable callback $ok_button->signal_handler_unblock($conn_id); // re-enable callback $ok_button->disconnect($conn_id); // remove callback ?>]]></example> </slide> Index: presentations/slides/gtk/extensions.xml +++ presentations/slides/gtk/extensions.xml <slide title="Extensions" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> PHP-GTK is actually a mini-PHP: it provides the core functionality and API, and a set of extensions for additional features. The Glade support is implemented via an extension. Some other ones in the main distribution are: </blurb> <list fontsize="2.5ex"> <bullet> |d04a21|gdkpixbuf| - provides image loading and rendering functionality </bullet> <bullet> |d04a21|scintilla| - a source code editing widget with syntax highlighting, code completion, and much more </bullet> <bullet> |d04a21|gtkhtml| - makes HTML rendering and editing possible </bullet> <bullet> |d04a21|canvas| - antialiased vector graphics rendering and manipulation </bullet> <bullet> |d04a21|extra| - additional widgets for plotting, spreadsheets, etc </bullet> </list> <blurb> There are some other extensions created by users, such as GLArea (for OpenGL rendering). </blurb> </slide> Index: presentations/slides/gtk/focus.xml +++ presentations/slides/gtk/focus.xml <slide title="Focus" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> Widgets can grab the keyboard focus if needed, but it only makes sense for those that interact with keyboard with some way. So, *GtkEntry* will work for example, while *GtkArrow* won't. </blurb> <example fontsize="1.5ex"><![CDATA[<?php $entry->grab_focus(); ?>]]></example> <blurb> </blurb> <blurb> </blurb> <blurb> It is possible to specify which widget should be activated when the user presses the *Enter* key in a dialog box. Such a widget is called a ~default~ one. </blurb> <example fontsize="1.5ex"><![CDATA[<?php $ok_button->can_default(TRUE); $ok_button->grab_default(); ?>]]></example> </slide> Index: presentations/slides/gtk/gencontainer.xml +++ presentations/slides/gtk/gencontainer.xml <slide title="Containers Overview" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> Remember that containers are widgets that can contain other widgets. The simplest type of container is *GtkBin* - it can only hold one child widget. An example of this container is a regular button. </blurb> <blurb> To add to or remove a widget from a container: </blurb> <example fontsize="1ex"><![CDATA[<?php $container->add($widget); $container->remove($widget); ?>]]></example> <blurb> To obtain all the widgets in a container, use one of the following approaches. </blurb> <example fontsize="1ex"><![CDATA[<?php $child_widgets = $container->children(); $child_widgets = $container->children; ?>]]></example> <blurb> In either case %$child_widgets% will be an array of widgets, but the second approach lets you access a specific child directly, e.g. %$container->children[0]%. </blurb> </slide> Index: presentations/slides/gtk/glade.xml +++ presentations/slides/gtk/glade.xml <slide title="Glade" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> Building complicated interfaces by hand is tedious. Thankfully, there is Glade. You can visually drag-n-drop widgets, set properties, connect signals, and then just load the resulting XML file into PHP-GTK. </blurb> <link align="center" text="Temperature Conversion (Glade variant)" href="presentations/slides/gtk/tempconv-g.php" /> <example fontsize="1ex" filename="tempconv-g.php" /> </slide> Index: presentations/slides/gtk/mainloop.xml +++ presentations/slides/gtk/mainloop.xml <slide title="Main Loop" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> Once you set up your application, you have to give control over to Gtk's ~main loop~. This is where all the events are processed and dispatched. </blurb> <example fontsize="1.3ex"><![CDATA[<?php gtk::main(); // start the main loop gtk::main_quit() // end the main loop ?>]]></example> </slide> Index: presentations/slides/gtk/php-gtk-2.xml +++ presentations/slides/gtk/php-gtk-2.xml <slide title="PHP-GTK 2" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> PHP-GTK 2 (currently under development) is based on PHP 5 and Gtk+ 2. </blurb> <blurb> PHP 5 has a brand new object model that solves all the lingering technical issues and allows for much more powerful control of the Gtk+ 2 interface. </blurb> <list fontsize="2.5ex"> <bullet> objects are no longer glorified arrays - they are always passed by reference </bullet> <bullet> since objects have destructors, memory is properly cleaned up </bullet> <bullet> no problems with method invocation (even something like %$button->get_child()->set_text()% is possible) </bullet> </list> <blurb> PHP 5 also adds a number of features to aid OO programming: abstract classes, interface, private and protected methods and variables, exceptions, and much more. </blurb> </slide> Index: presentations/slides/gtk/php-gtk-2a.xml +++ presentations/slides/gtk/php-gtk-2a.xml <slide title="PHP-GTK 2" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> Gtk+ 2 is a substantial change from the first version. </blurb> <list fontsize="2.5ex"> <bullet> generalized type system </bullet> <bullet> fully internationalized, all text is UTF-8 </bullet> <bullet> Pango-based Text widget can render any text in any language in the same box, and provides enough visual and navigation features to make a reasonable code editor </bullet> <bullet> GdkPixbuf is integrated </bullet> <bullet> GDK is no longer an orphan child, as far as objects are concerned and has double-buffering for smoooooth rendering </bullet> <bullet> Powerful new tree widget based on model-view approach </bullet> <bullet> Accessibility support for disabled users </bullet> <bullet> lots of cleanup and simplification </bullet> </list> </slide> Index: presentations/slides/gtk/php-gtk-2b.xml +++ presentations/slides/gtk/php-gtk-2b.xml <slide title="PHP-GTK 2" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <example fontsize="1ex"><![CDATA[From: Benjamin Smith Subject: PHP5, PHP-GTK, and SQLite Groups: php.gtk.general Maybe I'm just a bit weird, but I just read about (and started playing with) SQLite on PHP5 beta. Wow. Combine SQLite and PHP-GTK, and you have an INCREDIBLE development environment for client-side or client-server development! Wow. I spent the last year putting together a 50,000 line software package, and did it all with data arrays because using SQL would be too "heavy" and a pain to write an installer for all the various releases of Windows, MacOS, Linux, etc. to be supported. So many loops, so many painful recursive functions... foreach($clients as $key => $client)... But, if SQLite is BUILT IN... select clients from clienttable... I could probably re-write this in 30k lines or less with SQL support. Wow. PHP-GTK2, Glade, SQLite. It's like LAMP all over again, only on Windows, OSX, Linux, Sparc, and god knows what else. This is truly a platform for quick, powerful, multi-platform, client-side GUI development under development... I CAN'T WAIT UNTIL PHP-GTK2 IS OUT!!!!!!! W00t! -Ben ]]></example> </slide> Index: presentations/slides/gtk/problems.xml +++ presentations/slides/gtk/problems.xml <slide title="What's bad?" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> Due to limitations of Zend Engine in PHP 4, PHP-GTK has some problematic issues. </blurb> <list fontsize="2.5ex"> <bullet> byref constructor (using %&new% instead of %new%, and not consistently at that) </bullet> <bullet> method invocation on properties (%$button->child->set_text()% will not work) </bullet> <bullet> memory deallocation (object destructors are never called) </bullet> <bullet> a couple of other minor ones </bullet> </list> <blurb> Since it is such a large codebase and API, the documentation is lagging. We only have one active person working on the English version of documentation and a couple of translators for other languages. </blurb> <blurb> The applications have to be distributed with their source code, which may be beneficial or disadvantageous depending on your point of view. Some attemps have been made to encode the source, but the solution is not quite there yet. </blurb> <blurb> Finally, it would be nice to have a better way to install PHP-GTK applications on the desktop. There are some custom installers but a standard, professional one is still needed. </blurb> </slide> Index: presentations/slides/gtk/resources.xml +++ presentations/slides/gtk/resources.xml <slide title="Resources" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb fontsize="2ex">|006699|Sites|</blurb> <list fontsize="1.8ex"> <bullet> http://gtk.php.net/ </bullet> <bullet> http://wiki.gtk.php.net/ </bullet> <bullet> http://www.gtk.org/ </bullet> <bullet> http://www.kromann.info/php4-gtk.php </bullet> <bullet> http://www.cweiske.de/phpgtk.htm </bullet> <bullet> http://binary.gamer.net.nz/ </bullet> <bullet> http://www.akbkhome.com/Projects/ </bullet> </list> <blurb fontsize="2ex">|006699|Documentation|</blurb> <list fontsize="1.8ex"> <bullet> http://gtk.php.net/manual </bullet> <bullet> http://www.gtk.org/api </bullet> <bullet> http://www.gtk.org/tutorial1.2/ </bullet> </list> <blurb fontsize="2ex">|006699|Articles|</blurb> <list fontsize="1.8ex"> <bullet> http://www.sitepoint.com/article/697 </bullet> <bullet> http://www.sitepoint.com/article/839 </bullet> </list> <blurb fontsize="2ex">|006699|Mailing Lists|</blurb> <list fontsize="1.8ex"> <bullet> General: http://news.php.net/group.php?group=php.gtk.general </bullet> <bullet> PHP-GTK internals: http://news.php.net/group.php?group=php.gtk.dev </bullet> <bullet> http://www.php.net/mailing-lists.php </bullet> </list> </slide> Index: presentations/slides/gtk/sensitivity.xml +++ presentations/slides/gtk/sensitivity.xml <slide title="Sensitivity" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> A disabled, or ~insensitive~, widget does not respond to input and has a different visual appearance in order to indicate such state. To enable or disable a widget: </blurb> <example fontsize="1.5ex"><![CDATA[<?php $button->set_sensitive($state); ?>]]></example> <blurb> where %$state% is %TRUE% or %FALSE%. If the widget is enabled, but its parent is not, then it is considered disabled as well. To test a widget's state: </blurb> <example fontsize="1.5ex"><![CDATA[<?php $state = $button->sensitive(); $state = $button->is_sensitive(); ?>]]></example> <blurb> The first method tests just the widget itself, while the second one takes into account its parent's state as well. </blurb> </slide> Index: presentations/slides/gtk/showing.xml +++ presentations/slides/gtk/showing.xml <slide title="Visibility" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb>Creating a widget is not enough. You also have to make it appear on the screen. In order to do this use the %show()% or %show_all()% methods. There is a difference between these methods if the widget is a container. </blurb> <blurb> This will display the window, but not any of its contained children: </blurb> <example fontsize="1.5ex"><![CDATA[<?php $window->show(); ?>]]></example> <blurb> This will display the window and all of its contained children: </blurb> <example fontsize="1.5ex"><![CDATA[<?php $window->show_all(); ?>]]></example> <blurb> If a widget is inside a container and you call %show()% on it, it will not appear on screen until the container itself has been shown. </blurb> <blurb> Corresponding functions for hiding a widget are %hide()% and %hide_all()%. </blurb> </slide> Index: presentations/slides/gtk/sizepos.xml +++ presentations/slides/gtk/sizepos.xml <slide title="Size/Position" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> In a majority of cases, it is not advisable to set the size or position of the widget explicitly. The reason is that this disregards any external constraints that might be imposed on a widget, such as user's preference for the font size, resizing of the dialog box, the length of the button label in another language. It is best to let the containers chooise the sizing and placement of their children. </blurb> <blurb> That said, a few widgets should have their size and position set manually. This includes *GtkWindow*, *GtkCTree*, *GtkCList*, and a couple of others. To accomplish this, use these methods: </blurb> <example fontsize="1.5ex"><![CDATA[<?php $window->set_usize($width, $height); $window->set_uposition($x, $y); ?>]]></example> </slide> Index: presentations/slides/gtk/tempconv-g.php +++ presentations/slides/gtk/tempconv-g.php <?php dl('php_gtk.so'); $interface =& new GladeXML(dirname(__FILE__).'/tempconv.glade'); $interface->signal_autoconnect(); /* start the main loop */ gtk::main(); function on_celsius_clicked($button) { global $interface; $t_entry = $interface->get_widget('input_temp'); $res_label = $interface->get_widget('result'); /* get contents of the entry field */ $chars = $t_entry->get_chars(0, -1); if (empty($chars) || !is_numeric($chars)) { /* if invalid contents, indicate so, reselect entry field and focus on it */ $res_label->set_text('Invalid input'); } else { /* if valid contents, perform conversion and output result */ $temp = (((int)$chars)-32)/1.8; $res_label->set_text(sprintf("$chars Fahrenheit is %.1f Celsius", $temp)); } $t_entry->select_region(0, -1); $t_entry->grab_focus(); } function on_fahr_clicked($button) { global $interface; $t_entry = $interface->get_widget('input_temp'); $res_label = $interface->get_widget('result'); $chars = $t_entry->get_chars(0, -1); if (empty($chars) || !is_numeric($chars)) { /* if invalid contents, indicate so, reselect entry field and focus on it */ $res_label->set_text('Invalid input'); } else { /* if valid contents, perform conversion and output result */ $temp = ((int)$chars)*1.8+32; $res_label->set_text(sprintf("$chars Celsius is %.1f Fahrenheit", $temp)); } $t_entry->select_region(0, -1); $t_entry->grab_focus(); } function on_exit_clicked($button) { /* exit the main loop */ gtk::main_quit(); } ?> Index: presentations/slides/gtk/tempconv.glade +++ presentations/slides/gtk/tempconv.glade <?xml version="1.0"?> <GTK-Interface> <project> <directory></directory> <source_directory>src</source_directory> <pixmaps_directory>pixmaps</pixmaps_directory> <language>C</language> <gnome_support>True</gnome_support> <gettext_support>True</gettext_support> </project> <widget> <class>GtkWindow</class> <name>window</name> <border_width>5</border_width> <title>Temperature Conversion</title> <type>GTK_WINDOW_TOPLEVEL</type> <position>GTK_WIN_POS_CENTER</position> <modal>False</modal> <allow_shrink>False</allow_shrink> <allow_grow>True</allow_grow> <auto_shrink>False</auto_shrink> <widget> <class>GtkVBox</class> <name>vbox</name> <homogeneous>False</homogeneous> <spacing>5</spacing> <widget> <class>GtkHBox</class> <name>hbox1</name> <homogeneous>False</homogeneous> <spacing>5</spacing> <child> <padding>0</padding> <expand>False</expand> <fill>False</fill> </child> <widget> <class>GtkLabel</class> <name>label1</name> <label>Enter temperature:</label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> <xalign>0.5</xalign> <yalign>0.5</yalign> <xpad>0</xpad> <ypad>0</ypad> <child> <padding>0</padding> <expand>False</expand> <fill>False</fill> </child> </widget> <widget> <class>GtkEntry</class> <name>input_temp</name> <can_focus>True</can_focus> <has_focus>True</has_focus> <editable>True</editable> <text_visible>True</text_visible> <text_max_length>0</text_max_length> <text></text> <child> <padding>0</padding> <expand>True</expand> <fill>True</fill> </child> </widget> </widget> <widget> <class>GtkLabel</class> <name>result</name> <label></label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> <xalign>0.5</xalign> <yalign>0.5</yalign> <xpad>0</xpad> <ypad>0</ypad> <child> <padding>0</padding> <expand>True</expand> <fill>True</fill> </child> </widget> <widget> <class>GtkHBox</class> <name>hbox2</name> <homogeneous>True</homogeneous> <spacing>5</spacing> <child> <padding>0</padding> <expand>False</expand> <fill>False</fill> </child> <widget> <class>GtkButton</class> <name>to_celsius</name> <can_focus>True</can_focus> <signal> <name>clicked</name> <handler>on_celsius_clicked</handler> <last_modification_time>Sun, 18 Jan 2004 22:47:40 GMT</last_modification_time> </signal> <label>To Celsius</label> <relief>GTK_RELIEF_NORMAL</relief> <child> <padding>0</padding> <expand>True</expand> <fill>True</fill> </child> </widget> <widget> <class>GtkButton</class> <name>to_fahr</name> <can_focus>True</can_focus> <signal> <name>clicked</name> <handler>on_fahr_clicked</handler> <last_modification_time>Sun, 18 Jan 2004 22:47:31 GMT</last_modification_time> </signal> <label>To Fahrenheit</label> <relief>GTK_RELIEF_NORMAL</relief> <child> <padding>0</padding> <expand>False</expand> <fill>True</fill> </child> </widget> <widget> <class>GtkButton</class> <name>exit</name> <can_focus>True</can_focus> <signal> <name>clicked</name> <handler>on_exit_clicked</handler> <last_modification_time>Sun, 18 Jan 2004 22:39:49 GMT</last_modification_time> </signal> <label>Exit</label> <relief>GTK_RELIEF_NORMAL</relief> <child> <padding>0</padding> <expand>False</expand> <fill>True</fill> </child> </widget> </widget> </widget> </widget> </GTK-Interface> Index: presentations/slides/gtk/tempconv.php +++ presentations/slides/gtk/tempconv.php <?php dl('php_gtk.so'); /* set up main window */ $window =& new GtkWindow(); $window->set_title('Temperature Conversion'); $window->set_policy(false, true, false); $window->set_border_width(5); $window->set_position(GTK_WIN_POS_CENTER); /* create main vertical box */ $vbox =& new GtkVBox(false, 5); /* create first row box */ $hbox =& new GtkHBox(false, 5); /* add label */ $hbox->pack_start(new GtkLabel('Enter temperature:'), false); /* add an entry field */ $t_entry =& new GtkEntry(); $hbox->pack_start($t_entry, true, true); /* put first row box into vertical one */ $vbox->pack_start($hbox, false); /* create an empty label and add to vertical box */ $res_label =& new GtkLabel(); $vbox->pack_start($res_label); /* create third row box */ $hbox =& new GtkHBox(true, 5); /* create buttons and connect signals */ $celsius_b =& new GtkButton('To Celcius'); $celsius_b->connect('clicked', 'on_celsius_clicked', $t_entry, $res_label); $fahr_b =& new GtkButton('To Fahrenheit'); $fahr_b->connect('clicked', 'on_fahr_clicked', $t_entry, $res_label); $exit_b =& new GtkButton('Exit'); $exit_b->connect('clicked', 'on_exit_clicked'); /* add buttons to third row box */ $hbox->pack_start($celsius_b); $hbox->pack_start($fahr_b); $hbox->pack_start($exit_b); /* add third row box to vertical one */ $vbox->pack_start($hbox, false); /* add vertical box to main window */ $window->add($vbox); /* show window and all contained widgets */ $window->show_all(); /* have entry field grab keyboard focus */ $t_entry->grab_focus(); /* start the main loop */ gtk::main(); function on_celsius_clicked($button, $t_entry, $res_label) { /* get contents of the entry field */ $chars = $t_entry->get_chars(0, -1); if (empty($chars) || !is_numeric($chars)) { /* if invalid contents, indicate so, reselect entry field and focus on it */ $res_label->set_text('Invalid input'); } else { /* if valid contents, perform conversion and output result */ $temp = (((int)$chars)-32)/1.8; $res_label->set_text(sprintf("$chars Fahrenheit is %.1f Celsius", $temp)); } $t_entry->select_region(0, -1); $t_entry->grab_focus(); } function on_fahr_clicked($button, $t_entry, $res_label) { $chars = $t_entry->get_chars(0, -1); if (empty($chars) || !is_numeric($chars)) { /* if invalid contents, indicate so, reselect entry field and focus on it */ $res_label->set_text('Invalid input'); } else { /* if valid contents, perform conversion and output result */ $temp = ((int)$chars)*1.8+32; $res_label->set_text(sprintf("$chars Celsius is %.1f Fahrenheit", $temp)); } $t_entry->select_region(0, -1); $t_entry->grab_focus(); } function on_exit_clicked($button) { /* exit the main loop */ gtk::main_quit(); } ?> Index: presentations/slides/gtk/tempconv.xml +++ presentations/slides/gtk/tempconv.xml <slide title="Small Example" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> "Hello, World" programs are boring. Let's do something a little more useful that also bridges the gap between cultures. </blurb> <link align="center" text="Temperature Conversion" href="presentations/slides/gtk/tempconv.php" /> <example fontsize="1ex" filename="tempconv.php" /> </slide> Index: presentations/slides/gtk/thankyou.xml +++ presentations/slides/gtk/thankyou.xml <slide title="Thank You!" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb align="center"> Questions? </blurb> </slide> Index: presentations/slides/gtk/widget-hierarchy.xml +++ presentations/slides/gtk/widget-hierarchy.xml <slide title="Widget Hierarchy" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> Gtk toolkit has an extensive widget class hierarchy. Each widget class inherits its parents methods, properties, signals, etc. </blurb> <example fontsize="1ex"><![CDATA[GtkObject +GtkWidget | +GtkMisc | | +GtkLabel | | | +GtkAccelLabel | | | `GtkTipsQuery | | +GtkArrow | | +GtkImage | | `GtkPixmap | +GtkContainer | | +GtkBin | | | +GtkAlignment | | | +GtkFrame | | | | `GtkAspectFrame | | | +GtkButton | | | | +GtkToggleButton | | | | | `GtkCheckButton | | | | | `GtkRadioButton | | | | `GtkOptionMenu | | | +GtkItem | | | | +GtkMenuItem | | | | | +GtkCheckMenuItem | | | | | | `GtkRadioMenuItem | | | | | `GtkTearoffMenuItem | | | | +GtkListItem | | | | `GtkTreeItem | | | +GtkWindow | | | | +GtkColorSelectionDialog | | | | +GtkDialog | | | | | `GtkInputDialog | | | | +GtkDrawWindow | | | | +GtkFileSelection | | | | +GtkFontSelectionDialog | | | | `GtkPlug | | | +GtkEventBox | | | +GtkHandleBox | | | +GtkScrolledWindow | | | `GtkViewport | | +GtkBox | | | +GtkButtonBox | | | | +GtkHButtonBox | | | | `GtkVButtonBox | | | +GtkVBox | | | | +GtkColorSelection | | | | `GtkGammaCurve | | | `GtkHBox | | | +GtkCombo | | | `GtkStatusbar | | +GtkCList | | | `GtkCTree | | +GtkFixed | | +GtkNotebook | | | `GtkFontSelection | | +GtkPaned | | | +GtkHPaned | | | `GtkVPaned | | +GtkLayout | | +GtkList | | +GtkMenuShell | | | +GtkMenuBar | | | `GtkMenu | | +GtkPacker | | +GtkSocket | | +GtkTable | | +GtkToolbar | | `GtkTree | +GtkCalendar | +GtkDrawingArea | | `GtkCurve | +GtkEditable | | +GtkEntry | | | `GtkSpinButton | | `GtkText | +GtkRuler | | +GtkHRuler | | `GtkVRuler | +GtkRange | | +GtkScale | | | +GtkHScale | | | `GtkVScale | | `GtkScrollbar | | +GtkHScrollbar | | `GtkVScrollbar | +GtkSeparator | | +GtkHSeparator | | `GtkVSeparator | +GtkPreview | `GtkProgress | `GtkProgressBar +GtkData | +GtkAdjustment | `GtkTooltips `GtkItemFactory ]]></example> </slide> Index: presentations/slides/gtk/windows.xml +++ presentations/slides/gtk/windows.xml <slide title="Windows" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb fontsize="2ex"> ~Windows~ are toplevel container widgets that are affected by the window manager parameters, e.g. dialog boxes, popups, application windows, etc. </blurb> <blurb fontsize="2ex"> To set a window's title: </blurb> <example fontsize="1ex"><![CDATA[<?php $window->set_title('My App'); ?>]]></example> <blurb fontsize="2ex"> To set the focus widget in the window: </blurb> <example fontsize="1ex"><![CDATA[<?php $window->set_focus($name_entry); ?>]]></example> <blurb fontsize="2ex"> To set the default widget in the window (note that the widget has to call %can_default()% first): </blurb> <example fontsize="1ex"><![CDATA[<?php $window->set_default($ok_button); ?>]]></example> <blurb fontsize="2ex"> To inhibit interaction with other windows in the same app, make it ~modal~, disallow lowering it below the parent window, and run a new main loop: </blurb> <example fontsize="1ex"><![CDATA[<?php $dialog->set_modal(true); $dialog->set_transient_for($parent); gtk::main(); ?>]]></example> </slide> Index: presentations/slides/gtk/windows2.xml +++ presentations/slides/gtk/windows2.xml <slide title="Windows" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb fontsize="2ex"> You can set a window's default size with: </blurb> <example fontsize="1ex"><![CDATA[<?php $window->set_default_size($width, $height); ?>]]></example> <blurb fontsize="2ex"> And to set a window's initial position: </blurb> <example fontsize="1ex"><![CDATA[<?php $window->set_position($position); ?>]]></example> <blurb fontsize="2ex"> Where %$position% can be %'center'% (center of screen), %'mouse'% (under the cursor), or %'none'% (let window manager place it). </blurb> <blurb fontsize="2ex"> If you want to make window respond to resizing in a certain way, you have to set its ~policy~. </blurb> <example fontsize="1ex"><![CDATA[<?php $window->set_policy($allow_shrink, $allow_grow, $auto_shrink); ?>]]></example> <blurb fontsize="2ex"> While each argument is a boolean, there are only two useful combinations of them: one to allow the window to be resized by a user, and one to disallow resizing. </blurb> <example fontsize="1ex"><![CDATA[<?php $window->set_policy(false, true, false); // allow user resizing $window->set_policy(false, false, true); // disallow user resizing ?>]]></example> </slide>
Index: presentations/slides/gtk/callbacks.xml diff -u presentations/slides/gtk/callbacks.xml:1.1 presentations/slides/gtk/callbacks.xml:1.2 --- presentations/slides/gtk/callbacks.xml:1.1 Wed Jan 7 18:49:18 2004 +++ presentations/slides/gtk/callbacks.xml Sun Jan 18 19:51:45 2004 @@ -2,14 +2,17 @@ <blurb>The user-defined signal handlers are called ~callbacks~.</blurb> - <blurb>The first parameter normally passed to callbacks is the widget that + <blurb>The first parameter the callback receives is the widget that emitted the signal. The rest are signal-dependent. For example, the callback - for 'switch_page' signal of GtkNotebook class would look like this:</blurb> + for %switch_page% signal of *GtkNotebook* class would look like this:</blurb> <example fontsize="1.5ex"><![CDATA[<?php function on_switch_page($notebook, $page, page_num) { } ?>]]></example> - <blurb>The low-level event callbacks receive an additional parameter object - describing the event. It has fields for event type, button number if it was a - mouse click, key code if it was a key press, etc.</blurb> + <blurb>where %$page% is the object representing the page that was switched to, + and %$page_num% is its page number.</blurb> + + <blurb>The low-level event callbacks receive an additional object describing + the event. It has properties for event type, button number if it was a mouse + click, key code if it was a key press, etc.</blurb> <blurb>It is possible to connect more than one callback to the same signal. They will be run in the order they are connected. It is also possible to Index: presentations/slides/gtk/creating.xml diff -u presentations/slides/gtk/creating.xml:1.1 presentations/slides/gtk/creating.xml:1.2 --- presentations/slides/gtk/creating.xml:1.1 Wed Jan 7 18:49:18 2004 +++ presentations/slides/gtk/creating.xml Sun Jan 18 19:51:45 2004 @@ -1,16 +1,22 @@ <slide title="Creating and Destroying" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> - To create a widget, use %&new% operator instead of %new%. Some - widgets take constructor parameters to initialize themselves to some - state. + To create a widget, use |0033aa|%&new%| operator instead of + |0033aa|%new%|. Some widgets take constructor parameters to initialize + themselves to some state. </blurb> + <example fontsize="1.5ex"><![CDATA[<?php $vbox =& new GtkVBox(false, 5); ?>]]></example> <blurb> - To destroy a widget, use %destroy()% method. This is rarely used because all + Some widgets may be created by factories or other static methods: + </blurb> + <example fontsize="1.5ex"><![CDATA[<?php list($pixmap, $mask) = gdk::pixmap_create_from_xpm(...); ?>]]></example> + <blurb> + To destroy a widget, call its %destroy()% method. This is rarely used because all widgets are destroyed automatically upon the application's exit. </blurb> <blurb> - Destroying a widget will not + Note that simply unsetting the widget variable will not work in PHP 4 due to + Zend Engine limitations. </blurb> </slide> Index: presentations/slides/gtk/gensteps.xml diff -u presentations/slides/gtk/gensteps.xml:1.1 presentations/slides/gtk/gensteps.xml:1.2 --- presentations/slides/gtk/gensteps.xml:1.1 Wed Jan 7 18:49:18 2004 +++ presentations/slides/gtk/gensteps.xml Sun Jan 18 19:51:45 2004 @@ -3,7 +3,7 @@ <list type="number" fontsize="2ex"> <bullet>Instantiate the widget object of the appropriate class</bullet> </list> - <example fontsize="1ex"><![CDATA[<?php $ok = &new GtkButton('OK'); ?>]]></example> + <example fontsize="1ex"><![CDATA[<?php $ok =& new GtkButton('OK'); ?>]]></example> <list type="number" num="2" fontsize="2ex"> <bullet>Connect the signals to callbacks</bullet> </list> Index: presentations/slides/gtk/signals.xml diff -u presentations/slides/gtk/signals.xml:1.1 presentations/slides/gtk/signals.xml:1.2 --- presentations/slides/gtk/signals.xml:1.1 Wed Jan 7 18:49:18 2004 +++ presentations/slides/gtk/signals.xml Sun Jan 18 19:51:45 2004 @@ -7,7 +7,9 @@ <blurb>The passing of control is implemented via ~signals~. When a widget experiences an event, it ~emits~ a signal. Every signal is uniquely identified by name, but two different widgets may have the signal of the - same name but different meaning.</blurb> + same name but different meaning. Signals are inherited by widgets from up the + widget hierarchy, i.e. *GtkButton* will have all the signals that *GtkWidget* + has.</blurb> <blurb>Signals present a way to customize application's behavior according to the developer's needs and user's actions. Each signal has a default Index: presentations/slides/gtk/boxes.xml +++ presentations/slides/gtk/boxes.xml <slide title="Boxes" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> A more sophisticated container is a ~box~. It allows you to place, or ~pack~, more than one widget inside a simple container. There are horizontal (*GtkHBox*) and vertical (*GtkVBox*) boxes that pack their widgets correspondingly. First, create a new box: </blurb> <example fontsize="1.3ex"><![CDATA[<?php $box =& new GtkHBox($homogenous = false, $spacing = 0); ?>]]></example> <blurb> </blurb> <blurb> Then place some widgets into it using either %pack_start()% method (packs left-to-right for HBox and top-to-bottom for VBox) or %pack_end()% method (vice versa). </blurb> <example fontsize="1.3ex"><![CDATA[<?php $box->pack_start($child, $expand = true, $fill = true, $padding = 0); ?>]]></example> <blurb> </blurb> <blurb> You can nest the boxes to any degree, thus creating complex containment patterns. </blurb> </slide> Index: presentations/slides/gtk/connecting.xml +++ presentations/slides/gtk/connecting.xml <slide title="Connecting Signals" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> The most basic way of connecting a signal to a callback with with %connect()% method. For example, to respond to a %'clicked'% signal on a *GtkButton* widget, you would do this: </blurb> <example fontsize="1ex"><![CDATA[<?php function on_ok_clicked($button) { } $ok_button->connect('clicked', 'on_ok_clicked'); ?>]]></example> <blurb> If you wanted to connect to a class method or an object method, you have to use a special syntax for denoting that: </blurb> <example fontsize="1ex"><![CDATA[<?php class A { function on_ok_clicked($button) { } } $ok_button->connect('clicked', array('A', 'on_ok_clicked')); // connect to a class method $a_obj = new A(); $ok_button->connect('clicked', array(&$a_obj, 'on_ok_clicked')); // connect to an instance method ?>]]></example> </slide> Index: presentations/slides/gtk/connecting2.xml +++ presentations/slides/gtk/connecting2.xml <slide title="Connecting Signals" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> Sometimes the callbacks needs access to program data or other information. To avoid messing with global variables, you can pass the additional data to the callback when you connect it. </blurb> <example fontsize="1.3ex"><![CDATA[<?php function on_ok_clicked($button, $window, $my_data) { } $ok_button->connect('clicked', 'on_ok_clicked', $window, 'some data'); ?>]]></example> <blurb>%connect()% returns an number that uniquely identifies the connection made. This can be useful if you want to disable or remove the callback during the execution. </blurb> <example fontsize="1.3ex"><![CDATA[<?php $conn_id = $ok_button->connect('clicked', 'on_ok_clicked'); $ok_button->signal_handler_block($conn_id); // disable callback $ok_button->signal_handler_unblock($conn_id); // re-enable callback $ok_button->disconnect($conn_id); // remove callback ?>]]></example> </slide> Index: presentations/slides/gtk/extensions.xml +++ presentations/slides/gtk/extensions.xml <slide title="Extensions" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> PHP-GTK is actually a mini-PHP: it provides the core functionality and API, and a set of extensions for additional features. The Glade support is implemented via an extension. Some other ones in the main distribution are: </blurb> <list fontsize="2.5ex"> <bullet> |d04a21|gdkpixbuf| - provides image loading and rendering functionality </bullet> <bullet> |d04a21|scintilla| - a source code editing widget with syntax highlighting, code completion, and much more </bullet> <bullet> |d04a21|gtkhtml| - makes HTML rendering and editing possible </bullet> <bullet> |d04a21|canvas| - antialiased vector graphics rendering and manipulation </bullet> <bullet> |d04a21|extra| - additional widgets for plotting, spreadsheets, etc </bullet> </list> <blurb> There are some other extensions created by users, such as GLArea (for OpenGL rendering). </blurb> </slide> Index: presentations/slides/gtk/focus.xml +++ presentations/slides/gtk/focus.xml <slide title="Focus" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> Widgets can grab the keyboard focus if needed, but it only makes sense for those that interact with keyboard with some way. So, *GtkEntry* will work for example, while *GtkArrow* won't. </blurb> <example fontsize="1.5ex"><![CDATA[<?php $entry->grab_focus(); ?>]]></example> <blurb> </blurb> <blurb> </blurb> <blurb> It is possible to specify which widget should be activated when the user presses the *Enter* key in a dialog box. Such a widget is called a ~default~ one. </blurb> <example fontsize="1.5ex"><![CDATA[<?php $ok_button->can_default(TRUE); $ok_button->grab_default(); ?>]]></example> </slide> Index: presentations/slides/gtk/gencontainer.xml +++ presentations/slides/gtk/gencontainer.xml <slide title="Containers Overview" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> Remember that containers are widgets that can contain other widgets. The simplest type of container is *GtkBin* - it can only hold one child widget. An example of this container is a regular button. </blurb> <blurb> To add to or remove a widget from a container: </blurb> <example fontsize="1ex"><![CDATA[<?php $container->add($widget); $container->remove($widget); ?>]]></example> <blurb> To obtain all the widgets in a container, use one of the following approaches. </blurb> <example fontsize="1ex"><![CDATA[<?php $child_widgets = $container->children(); $child_widgets = $container->children; ?>]]></example> <blurb> In either case %$child_widgets% will be an array of widgets, but the second approach lets you access a specific child directly, e.g. %$container->children[0]%. </blurb> </slide> Index: presentations/slides/gtk/glade.xml +++ presentations/slides/gtk/glade.xml <slide title="Glade" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> Building complicated interfaces by hand is tedious. Thankfully, there is Glade. You can visually drag-n-drop widgets, set properties, connect signals, and then just load the resulting XML file into PHP-GTK. </blurb> <link align="center" text="Temperature Conversion (Glade variant)" href="presentations/slides/gtk/tempconv-g.php" /> <example fontsize="1ex" filename="tempconv-g.php" /> </slide> Index: presentations/slides/gtk/mainloop.xml +++ presentations/slides/gtk/mainloop.xml <slide title="Main Loop" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> Once you set up your application, you have to give control over to Gtk's ~main loop~. This is where all the events are processed and dispatched. </blurb> <example fontsize="1.3ex"><![CDATA[<?php gtk::main(); // start the main loop gtk::main_quit() // end the main loop ?>]]></example> </slide> Index: presentations/slides/gtk/php-gtk-2.xml +++ presentations/slides/gtk/php-gtk-2.xml <slide title="PHP-GTK 2" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> PHP-GTK 2 (currently under development) is based on PHP 5 and Gtk+ 2. </blurb> <blurb> PHP 5 has a brand new object model that solves all the lingering technical issues and allows for much more powerful control of the Gtk+ 2 interface. </blurb> <list fontsize="2.5ex"> <bullet> objects are no longer glorified arrays - they are always passed by reference </bullet> <bullet> since objects have destructors, memory is properly cleaned up </bullet> <bullet> no problems with method invocation (even something like %$button->get_child()->set_text()% is possible) </bullet> </list> <blurb> PHP 5 also adds a number of features to aid OO programming: abstract classes, interface, private and protected methods and variables, exceptions, and much more. </blurb> </slide> Index: presentations/slides/gtk/php-gtk-2a.xml +++ presentations/slides/gtk/php-gtk-2a.xml <slide title="PHP-GTK 2" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> Gtk+ 2 is a substantial change from the first version. </blurb> <list fontsize="2.5ex"> <bullet> generalized type system </bullet> <bullet> fully internationalized, all text is UTF-8 </bullet> <bullet> Pango-based Text widget can render any text in any language in the same box, and provides enough visual and navigation features to make a reasonable code editor </bullet> <bullet> GdkPixbuf is integrated </bullet> <bullet> GDK is no longer an orphan child, as far as objects are concerned and has double-buffering for smoooooth rendering </bullet> <bullet> Powerful new tree widget based on model-view approach </bullet> <bullet> Accessibility support for disabled users </bullet> <bullet> lots of cleanup and simplification </bullet> </list> </slide> Index: presentations/slides/gtk/php-gtk-2b.xml +++ presentations/slides/gtk/php-gtk-2b.xml <slide title="PHP-GTK 2" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <example fontsize="1ex"><![CDATA[From: Benjamin Smith Subject: PHP5, PHP-GTK, and SQLite Groups: php.gtk.general Maybe I'm just a bit weird, but I just read about (and started playing with) SQLite on PHP5 beta. Wow. Combine SQLite and PHP-GTK, and you have an INCREDIBLE development environment for client-side or client-server development! Wow. I spent the last year putting together a 50,000 line software package, and did it all with data arrays because using SQL would be too "heavy" and a pain to write an installer for all the various releases of Windows, MacOS, Linux, etc. to be supported. So many loops, so many painful recursive functions... foreach($clients as $key => $client)... But, if SQLite is BUILT IN... select clients from clienttable... I could probably re-write this in 30k lines or less with SQL support. Wow. PHP-GTK2, Glade, SQLite. It's like LAMP all over again, only on Windows, OSX, Linux, Sparc, and god knows what else. This is truly a platform for quick, powerful, multi-platform, client-side GUI development under development... I CAN'T WAIT UNTIL PHP-GTK2 IS OUT!!!!!!! W00t! -Ben ]]></example> </slide> Index: presentations/slides/gtk/problems.xml +++ presentations/slides/gtk/problems.xml <slide title="What's bad?" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> Due to limitations of Zend Engine in PHP 4, PHP-GTK has some problematic issues. </blurb> <list fontsize="2.5ex"> <bullet> byref constructor (using %&new% instead of %new%, and not consistently at that) </bullet> <bullet> method invocation on properties (%$button->child->set_text()% will not work) </bullet> <bullet> memory deallocation (object destructors are never called) </bullet> <bullet> a couple of other minor ones </bullet> </list> <blurb> Since it is such a large codebase and API, the documentation is lagging. We only have one active person working on the English version of documentation and a couple of translators for other languages. </blurb> <blurb> The applications have to be distributed with their source code, which may be beneficial or disadvantageous depending on your point of view. Some attemps have been made to encode the source, but the solution is not quite there yet. </blurb> <blurb> Finally, it would be nice to have a better way to install PHP-GTK applications on the desktop. There are some custom installers but a standard, professional one is still needed. </blurb> </slide> Index: presentations/slides/gtk/resources.xml +++ presentations/slides/gtk/resources.xml <slide title="Resources" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb fontsize="2ex">|006699|Sites|</blurb> <list fontsize="1.8ex"> <bullet> http://gtk.php.net/ </bullet> <bullet> http://wiki.gtk.php.net/ </bullet> <bullet> http://www.gtk.org/ </bullet> <bullet> http://www.kromann.info/php4-gtk.php </bullet> <bullet> http://www.cweiske.de/phpgtk.htm </bullet> <bullet> http://binary.gamer.net.nz/ </bullet> <bullet> http://www.akbkhome.com/Projects/ </bullet> </list> <blurb fontsize="2ex">|006699|Documentation|</blurb> <list fontsize="1.8ex"> <bullet> http://gtk.php.net/manual </bullet> <bullet> http://www.gtk.org/api </bullet> <bullet> http://www.gtk.org/tutorial1.2/ </bullet> </list> <blurb fontsize="2ex">|006699|Articles|</blurb> <list fontsize="1.8ex"> <bullet> http://www.sitepoint.com/article/697 </bullet> <bullet> http://www.sitepoint.com/article/839 </bullet> </list> <blurb fontsize="2ex">|006699|Mailing Lists|</blurb> <list fontsize="1.8ex"> <bullet> General: http://news.php.net/group.php?group=php.gtk.general </bullet> <bullet> PHP-GTK internals: http://news.php.net/group.php?group=php.gtk.dev </bullet> <bullet> http://www.php.net/mailing-lists.php </bullet> </list> </slide> Index: presentations/slides/gtk/sensitivity.xml +++ presentations/slides/gtk/sensitivity.xml <slide title="Sensitivity" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> A disabled, or ~insensitive~, widget does not respond to input and has a different visual appearance in order to indicate such state. To enable or disable a widget: </blurb> <example fontsize="1.5ex"><![CDATA[<?php $button->set_sensitive($state); ?>]]></example> <blurb> where %$state% is %TRUE% or %FALSE%. If the widget is enabled, but its parent is not, then it is considered disabled as well. To test a widget's state: </blurb> <example fontsize="1.5ex"><![CDATA[<?php $state = $button->sensitive(); $state = $button->is_sensitive(); ?>]]></example> <blurb> The first method tests just the widget itself, while the second one takes into account its parent's state as well. </blurb> </slide> Index: presentations/slides/gtk/showing.xml +++ presentations/slides/gtk/showing.xml <slide title="Visibility" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb>Creating a widget is not enough. You also have to make it appear on the screen. In order to do this use the %show()% or %show_all()% methods. There is a difference between these methods if the widget is a container. </blurb> <blurb> This will display the window, but not any of its contained children: </blurb> <example fontsize="1.5ex"><![CDATA[<?php $window->show(); ?>]]></example> <blurb> This will display the window and all of its contained children: </blurb> <example fontsize="1.5ex"><![CDATA[<?php $window->show_all(); ?>]]></example> <blurb> If a widget is inside a container and you call %show()% on it, it will not appear on screen until the container itself has been shown. </blurb> <blurb> Corresponding functions for hiding a widget are %hide()% and %hide_all()%. </blurb> </slide> Index: presentations/slides/gtk/sizepos.xml +++ presentations/slides/gtk/sizepos.xml <slide title="Size/Position" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> In a majority of cases, it is not advisable to set the size or position of the widget explicitly. The reason is that this disregards any external constraints that might be imposed on a widget, such as user's preference for the font size, resizing of the dialog box, the length of the button label in another language. It is best to let the containers chooise the sizing and placement of their children. </blurb> <blurb> That said, a few widgets should have their size and position set manually. This includes *GtkWindow*, *GtkCTree*, *GtkCList*, and a couple of others. To accomplish this, use these methods: </blurb> <example fontsize="1.5ex"><![CDATA[<?php $window->set_usize($width, $height); $window->set_uposition($x, $y); ?>]]></example> </slide> Index: presentations/slides/gtk/tempconv-g.php +++ presentations/slides/gtk/tempconv-g.php <?php dl('php_gtk.so'); $interface =& new GladeXML(dirname(__FILE__).'/tempconv.glade'); $interface->signal_autoconnect(); /* start the main loop */ gtk::main(); function on_celsius_clicked($button) { global $interface; $t_entry = $interface->get_widget('input_temp'); $res_label = $interface->get_widget('result'); /* get contents of the entry field */ $chars = $t_entry->get_chars(0, -1); if (empty($chars) || !is_numeric($chars)) { /* if invalid contents, indicate so, reselect entry field and focus on it */ $res_label->set_text('Invalid input'); } else { /* if valid contents, perform conversion and output result */ $temp = (((int)$chars)-32)/1.8; $res_label->set_text(sprintf("$chars Fahrenheit is %.1f Celsius", $temp)); } $t_entry->select_region(0, -1); $t_entry->grab_focus(); } function on_fahr_clicked($button) { global $interface; $t_entry = $interface->get_widget('input_temp'); $res_label = $interface->get_widget('result'); $chars = $t_entry->get_chars(0, -1); if (empty($chars) || !is_numeric($chars)) { /* if invalid contents, indicate so, reselect entry field and focus on it */ $res_label->set_text('Invalid input'); } else { /* if valid contents, perform conversion and output result */ $temp = ((int)$chars)*1.8+32; $res_label->set_text(sprintf("$chars Celsius is %.1f Fahrenheit", $temp)); } $t_entry->select_region(0, -1); $t_entry->grab_focus(); } function on_exit_clicked($button) { /* exit the main loop */ gtk::main_quit(); } ?> Index: presentations/slides/gtk/tempconv.glade +++ presentations/slides/gtk/tempconv.glade <?xml version="1.0"?> <GTK-Interface> <project> <directory></directory> <source_directory>src</source_directory> <pixmaps_directory>pixmaps</pixmaps_directory> <language>C</language> <gnome_support>True</gnome_support> <gettext_support>True</gettext_support> </project> <widget> <class>GtkWindow</class> <name>window</name> <border_width>5</border_width> <title>Temperature Conversion</title> <type>GTK_WINDOW_TOPLEVEL</type> <position>GTK_WIN_POS_CENTER</position> <modal>False</modal> <allow_shrink>False</allow_shrink> <allow_grow>True</allow_grow> <auto_shrink>False</auto_shrink> <widget> <class>GtkVBox</class> <name>vbox</name> <homogeneous>False</homogeneous> <spacing>5</spacing> <widget> <class>GtkHBox</class> <name>hbox1</name> <homogeneous>False</homogeneous> <spacing>5</spacing> <child> <padding>0</padding> <expand>False</expand> <fill>False</fill> </child> <widget> <class>GtkLabel</class> <name>label1</name> <label>Enter temperature:</label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> <xalign>0.5</xalign> <yalign>0.5</yalign> <xpad>0</xpad> <ypad>0</ypad> <child> <padding>0</padding> <expand>False</expand> <fill>False</fill> </child> </widget> <widget> <class>GtkEntry</class> <name>input_temp</name> <can_focus>True</can_focus> <has_focus>True</has_focus> <editable>True</editable> <text_visible>True</text_visible> <text_max_length>0</text_max_length> <text></text> <child> <padding>0</padding> <expand>True</expand> <fill>True</fill> </child> </widget> </widget> <widget> <class>GtkLabel</class> <name>result</name> <label></label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> <xalign>0.5</xalign> <yalign>0.5</yalign> <xpad>0</xpad> <ypad>0</ypad> <child> <padding>0</padding> <expand>True</expand> <fill>True</fill> </child> </widget> <widget> <class>GtkHBox</class> <name>hbox2</name> <homogeneous>True</homogeneous> <spacing>5</spacing> <child> <padding>0</padding> <expand>False</expand> <fill>False</fill> </child> <widget> <class>GtkButton</class> <name>to_celsius</name> <can_focus>True</can_focus> <signal> <name>clicked</name> <handler>on_celsius_clicked</handler> <last_modification_time>Sun, 18 Jan 2004 22:47:40 GMT</last_modification_time> </signal> <label>To Celsius</label> <relief>GTK_RELIEF_NORMAL</relief> <child> <padding>0</padding> <expand>True</expand> <fill>True</fill> </child> </widget> <widget> <class>GtkButton</class> <name>to_fahr</name> <can_focus>True</can_focus> <signal> <name>clicked</name> <handler>on_fahr_clicked</handler> <last_modification_time>Sun, 18 Jan 2004 22:47:31 GMT</last_modification_time> </signal> <label>To Fahrenheit</label> <relief>GTK_RELIEF_NORMAL</relief> <child> <padding>0</padding> <expand>False</expand> <fill>True</fill> </child> </widget> <widget> <class>GtkButton</class> <name>exit</name> <can_focus>True</can_focus> <signal> <name>clicked</name> <handler>on_exit_clicked</handler> <last_modification_time>Sun, 18 Jan 2004 22:39:49 GMT</last_modification_time> </signal> <label>Exit</label> <relief>GTK_RELIEF_NORMAL</relief> <child> <padding>0</padding> <expand>False</expand> <fill>True</fill> </child> </widget> </widget> </widget> </widget> </GTK-Interface> Index: presentations/slides/gtk/tempconv.php +++ presentations/slides/gtk/tempconv.php <?php dl('php_gtk.so'); /* set up main window */ $window =& new GtkWindow(); $window->set_title('Temperature Conversion'); $window->set_policy(false, true, false); $window->set_border_width(5); $window->set_position(GTK_WIN_POS_CENTER); /* create main vertical box */ $vbox =& new GtkVBox(false, 5); /* create first row box */ $hbox =& new GtkHBox(false, 5); /* add label */ $hbox->pack_start(new GtkLabel('Enter temperature:'), false); /* add an entry field */ $t_entry =& new GtkEntry(); $hbox->pack_start($t_entry, true, true); /* put first row box into vertical one */ $vbox->pack_start($hbox, false); /* create an empty label and add to vertical box */ $res_label =& new GtkLabel(); $vbox->pack_start($res_label); /* create third row box */ $hbox =& new GtkHBox(true, 5); /* create buttons and connect signals */ $celsius_b =& new GtkButton('To Celcius'); $celsius_b->connect('clicked', 'on_celsius_clicked', $t_entry, $res_label); $fahr_b =& new GtkButton('To Fahrenheit'); $fahr_b->connect('clicked', 'on_fahr_clicked', $t_entry, $res_label); $exit_b =& new GtkButton('Exit'); $exit_b->connect('clicked', 'on_exit_clicked'); /* add buttons to third row box */ $hbox->pack_start($celsius_b); $hbox->pack_start($fahr_b); $hbox->pack_start($exit_b); /* add third row box to vertical one */ $vbox->pack_start($hbox, false); /* add vertical box to main window */ $window->add($vbox); /* show window and all contained widgets */ $window->show_all(); /* have entry field grab keyboard focus */ $t_entry->grab_focus(); /* start the main loop */ gtk::main(); function on_celsius_clicked($button, $t_entry, $res_label) { /* get contents of the entry field */ $chars = $t_entry->get_chars(0, -1); if (empty($chars) || !is_numeric($chars)) { /* if invalid contents, indicate so, reselect entry field and focus on it */ $res_label->set_text('Invalid input'); } else { /* if valid contents, perform conversion and output result */ $temp = (((int)$chars)-32)/1.8; $res_label->set_text(sprintf("$chars Fahrenheit is %.1f Celsius", $temp)); } $t_entry->select_region(0, -1); $t_entry->grab_focus(); } function on_fahr_clicked($button, $t_entry, $res_label) { $chars = $t_entry->get_chars(0, -1); if (empty($chars) || !is_numeric($chars)) { /* if invalid contents, indicate so, reselect entry field and focus on it */ $res_label->set_text('Invalid input'); } else { /* if valid contents, perform conversion and output result */ $temp = ((int)$chars)*1.8+32; $res_label->set_text(sprintf("$chars Celsius is %.1f Fahrenheit", $temp)); } $t_entry->select_region(0, -1); $t_entry->grab_focus(); } function on_exit_clicked($button) { /* exit the main loop */ gtk::main_quit(); } ?> Index: presentations/slides/gtk/tempconv.xml +++ presentations/slides/gtk/tempconv.xml <slide title="Small Example" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> "Hello, World" programs are boring. Let's do something a little more useful that also bridges the gap between cultures. </blurb> <link align="center" text="Temperature Conversion" href="presentations/slides/gtk/tempconv.php" /> <example fontsize="1ex" filename="tempconv.php" /> </slide> Index: presentations/slides/gtk/thankyou.xml +++ presentations/slides/gtk/thankyou.xml <slide title="Thank You!" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb align="center"> Questions? </blurb> </slide> Index: presentations/slides/gtk/widget-hierarchy.xml +++ presentations/slides/gtk/widget-hierarchy.xml <slide title="Widget Hierarchy" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb> Gtk toolkit has an extensive widget class hierarchy. Each widget class inherits its parents methods, properties, signals, etc. </blurb> <example fontsize="1ex"><![CDATA[GtkObject +GtkWidget | +GtkMisc | | +GtkLabel | | | +GtkAccelLabel | | | `GtkTipsQuery | | +GtkArrow | | +GtkImage | | `GtkPixmap | +GtkContainer | | +GtkBin | | | +GtkAlignment | | | +GtkFrame | | | | `GtkAspectFrame | | | +GtkButton | | | | +GtkToggleButton | | | | | `GtkCheckButton | | | | | `GtkRadioButton | | | | `GtkOptionMenu | | | +GtkItem | | | | +GtkMenuItem | | | | | +GtkCheckMenuItem | | | | | | `GtkRadioMenuItem | | | | | `GtkTearoffMenuItem | | | | +GtkListItem | | | | `GtkTreeItem | | | +GtkWindow | | | | +GtkColorSelectionDialog | | | | +GtkDialog | | | | | `GtkInputDialog | | | | +GtkDrawWindow | | | | +GtkFileSelection | | | | +GtkFontSelectionDialog | | | | `GtkPlug | | | +GtkEventBox | | | +GtkHandleBox | | | +GtkScrolledWindow | | | `GtkViewport | | +GtkBox | | | +GtkButtonBox | | | | +GtkHButtonBox | | | | `GtkVButtonBox | | | +GtkVBox | | | | +GtkColorSelection | | | | `GtkGammaCurve | | | `GtkHBox | | | +GtkCombo | | | `GtkStatusbar | | +GtkCList | | | `GtkCTree | | +GtkFixed | | +GtkNotebook | | | `GtkFontSelection | | +GtkPaned | | | +GtkHPaned | | | `GtkVPaned | | +GtkLayout | | +GtkList | | +GtkMenuShell | | | +GtkMenuBar | | | `GtkMenu | | +GtkPacker | | +GtkSocket | | +GtkTable | | +GtkToolbar | | `GtkTree | +GtkCalendar | +GtkDrawingArea | | `GtkCurve | +GtkEditable | | +GtkEntry | | | `GtkSpinButton | | `GtkText | +GtkRuler | | +GtkHRuler | | `GtkVRuler | +GtkRange | | +GtkScale | | | +GtkHScale | | | `GtkVScale | | `GtkScrollbar | | +GtkHScrollbar | | `GtkVScrollbar | +GtkSeparator | | +GtkHSeparator | | `GtkVSeparator | +GtkPreview | `GtkProgress | `GtkProgressBar +GtkData | +GtkAdjustment | `GtkTooltips `GtkItemFactory ]]></example> </slide> Index: presentations/slides/gtk/windows.xml +++ presentations/slides/gtk/windows.xml <slide title="Windows" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb fontsize="2ex"> ~Windows~ are toplevel container widgets that are affected by the window manager parameters, e.g. dialog boxes, popups, application windows, etc. </blurb> <blurb fontsize="2ex"> To set a window's title: </blurb> <example fontsize="1ex"><![CDATA[<?php $window->set_title('My App'); ?>]]></example> <blurb fontsize="2ex"> To set the focus widget in the window: </blurb> <example fontsize="1ex"><![CDATA[<?php $window->set_focus($name_entry); ?>]]></example> <blurb fontsize="2ex"> To set the default widget in the window (note that the widget has to call %can_default()% first): </blurb> <example fontsize="1ex"><![CDATA[<?php $window->set_default($ok_button); ?>]]></example> <blurb fontsize="2ex"> To inhibit interaction with other windows in the same app, make it ~modal~, disallow lowering it below the parent window, and run a new main loop: </blurb> <example fontsize="1ex"><![CDATA[<?php $dialog->set_modal(true); $dialog->set_transient_for($parent); gtk::main(); ?>]]></example> </slide> Index: presentations/slides/gtk/windows2.xml +++ presentations/slides/gtk/windows2.xml <slide title="Windows" logo1="images/php-gtk.gif" navColor="#b0c2d3" navsize="1.4em"> <blurb fontsize="2ex"> You can set a window's default size with: </blurb> <example fontsize="1ex"><![CDATA[<?php $window->set_default_size($width, $height); ?>]]></example> <blurb fontsize="2ex"> And to set a window's initial position: </blurb> <example fontsize="1ex"><![CDATA[<?php $window->set_position($position); ?>]]></example> <blurb fontsize="2ex"> Where %$position% can be %'center'% (center of screen), %'mouse'% (under the cursor), or %'none'% (let window manager place it). </blurb> <blurb fontsize="2ex"> If you want to make window respond to resizing in a certain way, you have to set its ~policy~. </blurb> <example fontsize="1ex"><![CDATA[<?php $window->set_policy($allow_shrink, $allow_grow, $auto_shrink); ?>]]></example> <blurb fontsize="2ex"> While each argument is a boolean, there are only two useful combinations of them: one to allow the window to be resized by a user, and one to disallow resizing. </blurb> <example fontsize="1ex"><![CDATA[<?php $window->set_policy(false, true, false); // allow user resizing $window->set_policy(false, false, true); // disallow user resizing ?>]]></example> </slide>