PHP-GTK News #12 & #13

The news is back with a double shot covering the last two weeks. Issues in this news update appear to go a little deeper than in previous weeks. The developement items dive into segfaults and the differences between C code and PHP code. The General userland issues get into the details of working with GtkTreeView and GtkTreeStore, two of the more complex objects in PHP-GTK 2.

Developement

GtkWidget::size_request() Patch:
Christian added a fix to GtkWidget::size_request() that make the method return a GtkRequisition object instead of modifying an existing one. This makes the method PHP-ish instead of Gtk-ish. size_request() can be used to get the size a child widget will request when shown on the screen. The actual size may be different because of restrictions set by the widget’s parent container or other factors.

Drag-and-drop bugs:
Christian reported several drag-and-drop bugs over the last two weeks. Three of the four bug reports highlight segfaults that occur when dragging data or working with dragged information. The other bug report deals with a corrupted double-linked list. The issues appear at first glance to be related to the MIME type of the data that is being moved around. The three segfault issues do not occur when the data is text/plain.

Patch for gtk_selection_data_set_uris/gtk_selection_data_get_uris:
Christian supplied a patch via the bugs system that implements gtk_selection_data_set_uris and gtk_selection_data_get_uris. These two functions are used for drag-and-drop operations.

E_STRICT and PHP-GTK 2:
PHP-GTK 2 builds off of Gtk+2.0 which is a C library. In Gtk+2.0, functions are overridden from one class to another without necessarily keeping the same signature. PHP doesn’t really appreciate this when error reporting is set to E_STRICT. PHP will report errors about mismatching method signatures in widgets. For example, GtkToolbar::set_style() has a different signature than GtkWidget::set_style(). GtkToolbar::set_style() determines whether or not icons, text, or both will appear in the toolbar where as GtkWidget::set_style() sets a GtkStyle object for a widget. Eventhough, GtkToolbar is a descendant of GtkWidget, there is no need for setting a GtkStyle object on a GtkToolbar, because GtkToolbar is a container and styles have no impact on containers. Understanding this subtlety is obviously too much to expect from PHP (the language not the developers or community). At the moment, it looks like something that we will have to live with.

Documentation

Translating Docs:
A few individuals have come forward offering to help translate the PHP-GTK 2 docs. For anyone else interested in helping with the translations, here are the steps to follow:

  1. Read the “PHP-GTK 2 Documentation” tutorial
  2. Translate the following files (if needed):
    • preface.xml
    • bookinfo.xml
    • language-defs.ent
  3. Update stylesheets/common/.xml (if needed).
  4. If the above has already been done for your language, translate some other XML file.
  5. Send your translated files to the documenation mailing list
  6. Someone will review your files to make sure that they are well-formed and valid. If all is good, they will be committed to CVS (after we are sure the build system will still work).
  7. Translates some other files and send them to the list. After a few rounds, someone will petition the powers that be for some CVS karma and you will be able to commit the files yourself

Documentation updates:

General

Setting Data for a GtkTreeViewColumn:
Michale Crowl experienced some confusion trying to work with GtkTreeViewColumns. No matter how he set up his view, all of the columns were appearing the same. This was due to the fact that he was accidently setting all columns to use the same cell of each row in the model. The last argument to the GtkTreeViewColumn constructor tells the column which cell in the row to grab its value from. Passing 0 as the column number tells the GtkTreeViewColumn to look in the first cell fo the row. Passing 2 will tell the column to grab its value from the third cell in the row.

GtkTreeView::scroll_to_cell():
Benjamin is trying to convert his PHP-GTK 1 applications to PHP-GTK 2. One of the features he relied on in PHP-GTK 1 was GtkCTree and the GtkCTree::moveto method. When porting his application to PHP-GTK 2 he moved to using GtkTreeView because GtkCList is deprecated. The replacement for GtkCList::moveto is GtkTreeView::scroll_to_cell. This brings the given cell in the GtkTreeView into view. It can be used, as Benjamin is trying to do, to implement a more powerful search than the one that is built into GtkTreeView.

Image in a GtkTreeView:
Ron Tarrant had a question about adding an image to a GtkTreeView (it seems everyone has tree view questions these days). He was able to set up the model correctly using GdkPixbuf::gtype as the column type, but wasn’t sure what to pass as the image. As Christian pointed out, the data to be passed should be a GdkPixbuf. A GdkPixbuf can be obtained pretty easily by calling GdkPixbuf::new_from_file().

PEAR

New Releases:
Gtk2_FileDrop-0.1.1 - The latest version of this package fixes a MIME_Type warning. This package can be used to quickly and easily add drag-and-drop capabilities to your applications.
PEAR_Frontend_Gtk2-0.1.2 - This version of the PHP-GTK 2 front end for the PEAR installer fixes a bug when running “pear -G” from the commandline.

Leave a Reply

You must be logged in to post a comment.