PHP-GTK News #14
Wednesday, May 24th, 2006What at first appeared to be a slow week actually generated a lot of news. There were an astounding 16 patches provided this week (all by one very hard working individual) as well as a few indepth discussions about using PHP-GTK. So without further delay, here is the PHP-GTK news for May 17th through May 24th…
Development
GtkListStore::remove() bug:
|Christian| (not Christian Weiske) from the PHP-GTK IRC channel (freenode #php-gtk) discovered a bug when working with GtkListStore when trying to use GtkListStore->remove($iter) in the callback for $liststore->foreach(). Apparently PHP-GTK frees the memory for the list row twice which causes the application to crash. Upon further investigation Christian Weiske discovered that the same issue occurs when using foreach($liststore as $row) { $liststore->remove($row->iter); }.
From what I can tell, the problem is that the call to remove() causes the underlying Gtk libraries to free the memory allocated for the row, but when the PHP variable is out of scope (either after executing the callback or the foreach loop moves to the next iteration) PHP tries to do the same thing. Of course, I don’t have the best understanding of the inner workings of PHP so my description of the problem may be wrong. Either way, it doesn’t work now and needs a patch to fix the problem.
Patch Fest ‘06:
Christian Weiske supplied 16 patches this week for missing or improperly implemented functionality. That must be a record. Most of the patches have been added as bug reports to make tracking them easier. Unfortunately they will probably not make it into the first alpha release (see below):
- GtkContainer::get_focus_chain()
- GtkContainer::set_focus_chain()
- GtkWindow::get_icon_list()
- GtkWindow::set_icon_list()
- GtkWindow::get_default_icon_list()
- GtkWindow::set_default_icon_list()
- GtkIconTheme::list_icons()
- GtkTreeSortable::set_sort_func()
- GtkTreeSortable::set_default_sort_func() and the marshaller
- GtkTextIter::get_tags()
- GtkTextIter::get_marks()
- GtkTextIter::get_toggled_tags()
- GtkTextTagTable::foreach()
- GtkAboutDialog::set_email_hook()
- GtkTreeView::get_columns()
Alpha Release Update:
The first official alpha release of PHP-GTK 2 has been pending for a while now, but the time frame has recently become more specific. The issues with the Windows build are still present, but Steph has agreed to do her best to get these straightened out while Andrei is out on a trip to Russia. By the time Andrei returns, all should be ready for the first release and it should be made available shortly thereafter.
Documentation
Call for Help:
I am putting out this unofficial “Call for Help”. The PHP-GTK doc team used to be a force to be reckoned with, but has lately dwindled. The efforts of all who have contributed to this point are not to go unappreciated, but more help is needed if PHP-GTK 2 is to really be taken seriously. One of the things that has made PHP what it is today is the shallow learning curve and this is due in great part to the online documentation. Also, writing documentation is a great way to learn about PHP-GTK 2. The more you experiment with the features and write about them, the more you will learn about how PHP-GTK 2 works. If you would like to get involved, please see the Doccing Tutorial or contact the php-gtk-doc mailing list. All help is appreciated.
Documentation Updates:
- GtkFileChooserButton (Scott)
- GtkLabel (Scott)
- GtkTreeView (Christian)
- GtkTreeViewColumn (Christian)
- GtkWidget (Scott)
- Doccing Tutorial (Scott)
General
Web Browser in an Application:
A French PHP-GTK user identified only as “CrazyCat” asked this week if it was possible to embed a web browser in an application. S/He wanted to provide a cross-platform way to display HTML without relying on any third party solutions (such as the user’s installed web browser). The MozEmbed extension, implemented by Anant, is desigend specifically to solve this issue. A demo of the extension at work can be found in the ext/mozembed/demos/ directory of the PHP-GTK 2 source.
Pixmap xpm:
A user named Martin was trying to recreate the XPM example from the wiki without success. The wiki example was written for PHP-GTK 1 and relies on the Gdk::pixmap_create_from_xpm_d() method. This method no longer exists in PHP-GTK 2. Instead the GdkPixbuf class provides the methods needed to work with images of varying types.
New Gnope dll:
Gnope.org released an updated version of the PHP-GTK 2 dll for Windows users this week. This version includes the GtkSourceView and MozEmbed extensions thanks to the work of the mysterious xxoes.
PHP|A A/R/T article:
PHP|Architect has released a new online service known as A/R/T. This service is a repository of free articles and tutorials devoted to PHP and related technologies. A/R/T provides more focused and indepth resources than the format and audience of their magazine allow. The current repository features an article titled “What is PHP-GTK?”. This article discusses the origins of and practicla uses for PHP-GTK.
Memory Leaks:
Andrew Buczacki asked the general mailing list for help resloving some memory issues this week. Memory usage is an issue that haunts some PHP-GTK applications (PHP-GTK 1 specifically, there have not yet been reported cases of PHP-GTK 2 memory leaks). This is due to the nature of PHP. It was originally designed to be used for quick running scripts that don’t have time to chew up memory, therefore memory usage is not normally a concern. PHP-GTK applications on the other hand are designed to run much longer.
Brian A. Stumm has successfully written an application which can run for days without leaking memory. His tips include using global variables for pretty much everything and realizing all of the widgets before starting the main loop.
IRC
Packing and Padding:
There was a discussion on the IRC channel this week about packing widgets into containers and padding. There seems to be a general confusion about the way widgets should be packed into container. There are three things to consider when packing widgets. First, do you want the widget to take up as much space as is available in the container, or do you simply want it to take up just as much as it needs? This is called expanding. When a widget is packed into a container you can tell it whether or not to expand. Second, do you want the widget to resize when the container is resized. This is known as filling. Widgets can be told whether or not to fill when they are packed. Finally, padding can be added around a widget. Different types of containers allow control of expand, fill, and padding in different directions (x => GtkHBox, y => GtkVBox, or both => GtkTable) depending on their nature. See the documentation for more details on packing widgets into specific container types.
