PHP-GTK News #3

Development Updates

More patches by xxoes:

xxoes supplied five more patches this week:

  • GtkFileSelection::get_selections() - This patch fixes the generated implementation. Sometimes the auto generated implementations of methods don’t work right because the “c way” is not always compatible with the “PHP way”. After reviewing and modifying the patch Andrei applied it to CVS. We now have a working get_selections() method.
  • GtkCalendar::get_date() - This patch fixes the generated implementation of GtkCalendar::get_date(). The generated method just doesn’t work. This patch has not yet been applied.
  • GdkPixbuf::get_pixel() - A new function that returns one pixel from a GdkPixbuf
  • GdkPixbuf::put_pixel() - A new function that writes one pixel to a GkdPixbuf
  • GdkPixbuf::fill_area() - A new function that fills a rectangle of a GdkPixbuf with a given color.

GtkWidget::get_sensitive():

Christian asked why there wasn’t a get_sensitive method to determine if a widget is sensitive or not. (Sensitivity of a widget can be changed using set_sensitive())

Andrei’s simple answer: because it isn’t implemented in Gtk+. To check for sensitivity, you need to check the widget’s flags.

function printFlags($flags) {
for ($i = 31; $i >= 0 ; --$i) {
if ($flags & 1 < < $i) {
echo 1;
} else {
echo 0;
}
}
echo "n";
}
$button = new GtkButton();

$button->set_sensitive(true);
var_dump($button->flags());
printFlags($button->flags());

$button->set_sensitive(false);
var_dump($button->flags());
printFlags($button->flags());

Window build issues:

To be honest, I don’t understand any of it. All I know is it works for some and not for others. If you use MSVS 6.0 you should not have any trouble building PHP-GTK 2 on windows. Eventually Steph moved some changes that xxoes had implemented on his local version into CVS. These changes make it much easier to compile PHP-GTK 2 on Windows.

Other extensions:

Anant, in an effort to contribute, did some work on extensions this week. He added the GtkSourceview extension which is a modified version of GtkTextView. GtkSourceview provides line numbers, syntax highlighting and other features common to source code editors. He also did some work to get Scintilla compiling. It may not work perfectly but should at least compile.

Unfortunately, Anant was a little over zealous in his bid to help. He committed a few too many files without getting some peer review first. He didn’t do any damage, but receive a stern email from Andrei. Let this serve as a reminder for all that you really should let people know what your are doing before jumping in with a bunch of CVS commits.
Documentation

It has recently been brought to my attention that there are two types of properties in PHP-GTK. The first which are called “fields” are what you might normally think of as a property. You can access them using $widget->fieldName; The other type, called “properties”, can only be accessed by using get_property() or set_property(). This leads to a documentation problem in that everything in the documentation to this point that has been marked as a property is really a field. Christian, who understands the structure of the docs far better than I do, has rearranged things so that we now have separate fields and properties sections. This should make things much clearer.

Christian has updated his doc search tool to include the new fields section and also to return classes when searching for a substring of the name, such as ‘tree’ => GtkTreeViewColumn.

Updates:

General

GtkTreeView Iteractive Search Widget:

Marion Denault asked how to override the default interactive search widget for GtkTreeView. Marion wanted to initate an interactive search with a GtkEntry in another part of the application. When the user types in the GtkEntry, Marion wants the GtkTreeView to scroll to the matching row.

Unfortunately the GtkEntry that pops up when a user starts an interactive search is not easily accessible so you can’t just move it to another part of the application. You have to create your own GtkEntry and use it to manipulate the GtkTreeView. I am not sure if or how Marion got this to work, but here is how I would go about it:

GtkTreeView Row Color:

Eduardo used to change the color of a selected row in PHP-GTK 1 using styles. In PHP-GTK 2 that doesn’t work anymore. He asked the mailing list how to change the row color of a GtkTreeView in PHP-GTK 2. Christian told him to set the color of the GtkCellRenderer.

$cellRenderer->set_property('cell-background', '#FF0000');

IRC

MySQL and PHP-GTK 2 on Windows:

cyberscorp needed help getting MySQL working with his/her PHP-GTK 2 installation on Windows. You need to have php_mysql.dll in the ext/ directory and libmysql.dll in the same directory as php.exe. Thanks to Christian for setting things straight.

Scrolling a GtkScrolledWindow

DuNaMiS asked about how to scroll to a particular point in a Scrolled Window. He wanted to scroll to the focused widget, such as a GtkEntry. The problem is that GtkScrolledWindow is a bin and can only contain one child widget. The other widgets are actually children of the scrolled window’s child.

Moving a scrolled window to a particular spot is pretty easy. All you need to do is change the value of the adjustment for the direction you want to scroll. For example:

$vadj = $scrolledWindow->get_vadjustment();
$vadj->set_value($value);

Figuring out the right value is the tricky part.

PEAR

I’ve added a new section for PEAR this week. I am not going to report on all of the news in PEAR but just the PHP-GTK stuff.

Three new Gtk2 proposals:

  • Gtk2_IndexedComboBox - Indexed Gtk2 combo box similar to the HTML select box. Lets you not only store values as the normal GtkComboBox, but associated key/value pairs as well. The active key can be easily received with get_active_key().
  • Gtk2_InputDialog - Gtk2 message box with text entry field.
  • PEAR_PackageUpdate_Gtk2 - PEAR_PackgeUpdate_Gtk2 is a PHP-GTK 2 front end for PEAR_PackageUpdate (also in proposal state). It is designed to be used by PHP-GTK 2 packages and applications that want to include auto-updating features.

Make sure to check them out and cast a vote if you can!

New releases:

If there is something I missed, or you want to submit your own news to be included here please drop me an email.

4 Responses to “PHP-GTK News #3”

  1. Christian Weiske Says:

    You’re really making good work and invest some time. Respect.

  2. Anant Narayanan Says:

    Like Christian mentions, you’re doing a wonderful job! Why not think of adding a link to here on the official PHP-Gtk website so that more people remain informed?

    You forgot to mention that the GtkMozEmbed extension also works (which is what I got fired for in the first place ;))

    Keep up the great work!

  3. scott Says:

    Thanks Christian and Anant.

    Sorry for leaving that one out Anant. It’s hard to keep track of everything but I will try harder next time. There is at least one link the article itself but that probably isn’t prominent enough. I have added another link on the right to the PHP-GTK site. Also, from now on I will add something like “Don’t forget to check out the PHP-GTK homepage for more information…” to each week’s news item.

    Thanks again,
    Scott

  4. scott Says:

    Sorry again Anant.

    I misread your comment (Christian set me straight). I want to hold off a bit before putting something up on the offical site. I need to make sure that I can keep up with everything. I don’t want to add a link and then have work pick up and realize that I can’t get news out in a timely manner. Maybe after I get a few more weeks under my belt.

    Thanks,
    Scott

Leave a Reply