PHP-GTK News #6

Development

GtkIconView::get_selected_items() Patch:
Christian supplied a patch for GtkIconView::get_selected_items(). GtkIconView is a widget for displaying a set of icons in a table like structure with columns and rows. There is an example in the /demos directory of PHP-GTK 2. get_selected_items() does just what its name implies. It returns the items that the user has selected.

More GtkAboutDialog Patches:
Anant supplied more patches for GtkAboutDialog this week. His latest patch fills out the class and implements the remaining methods. When this patch is applied (hopefully soon) get_artists, set_artists, get_documenters, set_documenters, get_authors, and set_authors will all be available.

Make sure you use the right PHP:
An interesting issue came up this week. Eddie Hixson was getting an interesting issue related to gd not being present even though he was not using any gd methods. It turns out that you can use php_gtk2.so with a version of PHP that it was not compiled against. This can cause PHP-GTK to rely on other extensions that may or may not be present. In short, make sure you compile PHP-GTK against the version of PHP you will be using.

GtkSourceView Updates:
Anant fixed up the source code highlighting in GtkSourceView. You can use GtkSourceView to display syntax highlighted colored text. It can be used to show not only PHP code but also xml, diffs or even make files.

$lm = new GtkSourceLanguagesManager();
$la = $lm->get_language_from_mime_type(”text/x-php-source”);
$buffer = GtkSourceBuffer::new_with_language($la);
$buffer->set_highlight(true);
$view = GtkSourceView::new_with_buffer($buffer);

Conclusion to Exceptions in Callbacks:
Andrei addes basic support for uncaught exceptions in callbacks. Instead of letting the application hang, when an exception is thrown inside of a callback and not caught, the current main loop will quit and code will continue executing. If the current loop is the outer most loop… Figure out what happens.

GType:
This week Andrei added a gtype field for all objects. This allows you to get teh GType of an object with $obj->gtype; The GType of an object is, “A numerical value which represents the unique identifier of a registered type.” Basically it is a numerical representation of the class name.

GtkWidget::set_visible():
Christian has requested a set_visible() method which will hide or show a widget based on the boolean value passed. It would functin similarly to set_sensitive(). This would make it easier to dynamically control the visibility of an object because you wouldn’t need to to and if/else check every time to decide which method, hide or show, to call.
Andrei isn’t necessarily opposed to this particular method but is weary of adding PHP-GTK specific functionality. He doesn’t want the API to get so far away from Gtk+2.0 that it becomes its own beast. This is a valid concern, but personally I don’t think that should prevent this method from being added. We aren’t asking for new widgets here, just a method that seems to have been forgotten by the Gtk+2.0 folks.

Documentation

Oh dear lord! There was a lot going on this week in the docs section but most of it relates to getting the new docs up and running on gtk.php.net. In addition, there was some class documentation:

IRC

Multiple windows:
cyberscorp asked about creating multiple windows in a an application. This is not a problem with PHP-GTK (2 or 1). By using set_transient_for, you can help the window manager keep track of what is going on.

Loading data when the application starts up:
mthompso asked how to load data when an application start up. This can be done buy connecting to a signal that is emitted during the start up process such as ‘expose-event’. Alternative you could connect to the realize signal which is emitted when the widget is realized.

Destroying windows:
habbe was having some trouble destroying a window in a callback. No matter what he did, the window would not go away. Of course calling destroy() on a window should kill it but habbe was not able to get rid of the window. In the end it was just a matter of assigning the window properly and references. His global declaration was not quite right when he created the window. This is just one more reason to use Object Oriented programming instead of procedural code.

PEAR

Proposed:
Structures_Form_Gtk2: A PHP-GTK 2 frontend for PEAR::Structures_Form. Structures_Form is an interface independant input form manager. What that means is you can organize form elements in one class and then display them however you like.

Accepted:
PEAR_PackageUpdate_Gtk2: The PHP-GTK 2 front end for PEAR_PackageUpdate (which was also accepted this week) has been added to PEAR. Along with its parent package, PEAR_PackageUpdate_Gtk2 allows PHP-GTK 2 packages to adde auto-update features.

Released:

Gtk2_IndexedComboBox-0.0.3

Gtk2_FileDrop-0.1.0

PEAR_PackageUpdate_Gtk2-0.3.0a1

PEAR_Frontend_Gtk2-0.1.0

Leave a Reply

You must be logged in to post a comment.