Archive for the ‘New stuff’ Category

PHP-GTK 2.0.1 released!

Thursday, May 22nd, 2008

In case you’re not aware, PHP-GTK 2.0.1 has just been released!

I will try out some of the new features and let you know.

/kksou

http://www.kksou.com/php-gtk2
The place for php-gtk2 sample codes

p.s. I just tried the interactive search on treeview for the new version. Seems like it’s still not fixed yet for the windows version. Something’s different though. Last time in windows, you need to hit ctrl-F to start the interactive search. Now, like the linux version, you can just start typing. However, it stops at the first character and doesn’t receive any more keyboard input.

Glade3 v3.4.1 for windows - just released!

Wednesday, January 16th, 2008

Thanks to HervéJoncour who dropped me a note to inform me that the latest windows binary of Glade3 (v3.4.1) is now available at:

http://php-gtk.forumfree.net/?t=12897059&
view=getlastpost#lastpost

The links to the binary is:

http://www.idrometa.it/php-gtk/
glade3-3.4.1-win32-1.zip

Glade v3.4.1 contains quite a number of bug fix. For details of the main difference between v3.4.1 and v3.4.0, please refer to http://glade.gnome.org/.

Enjoy the latest version of Glade v3.4.1!

/kksou

http://www.kksou.com/php-gtk2
The place for php-gtk2 sample codes

p.s. In the event that you haven’t set up Glade3 yet (on windows) and are facing some problem setting it up, here’s a step-by-step instruction:

http://www.kksou.com/php-gtk2/articles/install-glade3-for-PHP-GTK2-on-windows.php

Finetune interactive search in GtkTreeView

Friday, September 28th, 2007

If you’re running PHP-GTK2 on windows, some of you might not be aware of the interactive search feature in GtkTreeView.

On linux, by default, when you start typing some characters in a treeview, you will automatically see a popup search box.

On window, you have to type a CTRL-F to see this popup interactive search box.

There are a quite a number of ways you can fine-tune this interactive search. Have just created 4 sample codes on the treeview interactive search:

/kksou

http://www.kksou.com/php-gtk2
The place for php-gtk2 sample codes

Remove nodes from a treestore

Tuesday, August 28th, 2007

In case you need to remove nodes from a GtkTreeStore, here are three sample codes:

How to remove nodes from GtkTreeView - Part 1?

How to remove nodes from GtkTreeView - Part 2 - highlight remains?

How to remove nodes from GtkTreeView - Part 3 - remove child nodes only?

Of particular interest is the use of the “additional GtkTreeModel functionality” implemented by Andrei Zmievski. If you have not tried this before, you should. It’s a technique that will be very useful in some applications.

/kksou

http://www.kksou.com/php-gtk2
The place for php-gtk2 sample codes

Radio buttons in GtkTreeView using GtkCellRendererToggle

Friday, August 17th, 2007

I think a lot of you have used GtkCellRendererToggle to display checkbox in a treeview.

However, do you know that GtkCellRendererToggle can be used to display radio buttons in a treeview too?

Have come out with 4 examples to illustrate this:

  1. How to set up radio buttons in GtkTreeView using GtkCellRendererToggle - Part 1 - one radio button? 08/17/2007
  2. How to set up radio buttons in GtkTreeView using GtkCellRendererToggle - Part 2 - three radio buttons? 08/17/2007
  3. How to set up radio buttons in GtkTreeView using GtkCellRendererToggle - Part 3 - process selections? 08/17/2007
  4. How to set up radio buttons in GtkTreeView using GtkCellRendererToggle - Part 4 - all radio buttons in one column? 08/17/2007

The last one is quite interesting, i.e. packing all the radio buttons and their corresponding labels into one treeview column. You could try this as an exercise. I learned a lot during the process of trying to get this to work.

/kksou

http://www.kksou.com/php-gtk2
The place for php-gtk2 sample codes

PHP-GTK Explorer

Sunday, July 22nd, 2007

There is a “secret weapon” that I’ve been using for a long time in learning and exploring php-gtk2.

Last weekend, I’ve got some time. Decided to polish this up a bit and share with the rest of you who are keen in using php-gtk2.

So here it is — the “PHP-GTK Explorer”. It’s like the Dev_Inspector (from gnope.org), but with a lot more functionalities added.

One of the most important keys in mastering php-gtk2 is to understand the object hierarchy of a widget, i.e. knowing who are its ancestors, its siblings and its children. The “PHP-GTK Explorer” have three different tabs to show you these three views.

View 1: The Object Hierarchy For GtkToggleButton

View 1: The Object Hierarchy For GtkToggleButton

View 2: GtkToggleButton and its siblings

View 2: GtkToggleButton and its siblings

 

View 3: GtkToggleButton and its children

View 3: GtkToggleButton and its children

There are a lot more exciting features of PHP-GTK Explorer that makes the learning of PHP-GTK2 more fun and easy.

You can find more details and download a copy here:

http://www.kksou.com/php-gtk2/products/php-gtk-explorer/

/kksou

http://www.kksou.com/php-gtk2
The place for php-gtk2 sample codes

GtkCellRendererAccel - it’s working!

Tuesday, July 10th, 2007

I decided to try out the new widget GtkCellRendererAccel (available in gtk+2.10) last weekend.

Just like GtkCellRendererSpin, the only information currently available on the net is the following:

http://developer.gnome.org/doc/API/2.0/gtk/GtkCellRendererAccel.html

I must have read this more than a hundred times, trying to figure out what it is trying to say and how everything fits together.

It looked simple. Supposedly, you create a new GtkCellRendererAcce, set the ‘accel-key’ with the key value, and then the ‘accel-mods’ with the modifier key. That’s it! The widget should automatically display the keyboard accelerator in the treeview.

But after going through at least 200+ different combinations and settings, IT JUST DOESN’T WORK!!!

After two night, I gave up. I thought this must be one of those features that are yet to be implemented.

I moved on to look at GtkCellRendererSpin. That’s the sample code you saw yesterday on GtkCellRendererSpin (please refer to the previous post).

Decided to give just one more night of try with GtkCellRendererAccel before really giving it up.

Am I glad I did! Just imagine my joy when I saw the Alt-A appearing in the treeview!

Turns out that I’ve “overly complicated” the widget. It’s actually a simple widget for displaying keyboard accelerator. Nothing more! All the handling of the keyboard accelerator has to be handled by yourself. That’s why you don’t see any methods or signals for handling the keyboard accelerators.

Also, it’s really that simple to use as the document above claimed. All you need is to create a new GtkCellRendererAcce, set the ‘accel-key’ with the key value, and then the ‘accel-mods’ with the modifier key. That’s it! The widget will automatically display the keyboard accelerator in the treeview.

I will be coming out with three sample codes to illustrate the use of GtkCellRendererAccel.

Here’s Part 1:

How to display keyboard accelerator in GtkTreeView with GtkCellRendererAccel - Part 1?

Part 2 and 3 will be posted in the next two days.

/kksou

http://www.kksou.com/php-gtk2
The place for php-gtk2 sample codes

Sample code for GtkCellRendererSpin

Tuesday, July 10th, 2007

Tried last night to decipher probably the only information (at least currently) available for GtkCellRendererSpin - one of the new widgets in gtk+2.10:

http://developer.gnome.org/doc/API/2.0/gtk/GtkCellRendererSpin.html

After some trials and errors, finally figured out what it is trying to say.

So here’s a sample code to illustrate how to use this new widget:

How to input or edit numbers in GtkTreeView with GtkCellRendererSpin?

/kksou

http://www.kksou.com/php-gtk2
The place for php-gtk2 sample codes

Two new classes: Wizard and Wizard_Page

Thursday, July 5th, 2007

If you wish to set up wizards in PHP-GTK2, and can’t wait for the “bugs” (as explained in “Some problems with GtkAssistant”) to be fixed, you might want to take a look at the following sample code:

How to set up wizards using GtkDialog - Part 2 - using OOP and classes?

This example gives the same result as How to set up wizards using GtkDialog - Part 1?

The only difference is that it’s re-written using OOP and classes.

The Wizard class is used almost similar to the GtkAssistant.

The Wizard_Page is used for setting up each page of the wizard. It helps to make the code cleaner and easier to maintain. All the signal handlers and processing functions can be nicely encapsulated into this class.

You will find that it’s now much easier to set up wizards, with the ability to set each page’s contents on-the-fly (using the prepare “signal”), and carry out appropriate actions based on user’s inputs (using the apply “signal”).

/kksou

http://www.kksou.com/php-gtk2
The place for php-gtk2 sample codes

Some problems with GtkAssistant

Monday, July 2nd, 2007

If you have tried the sample code in:

How to set up wizards using GtkAssistant - Part 2 - respond to forward button?

You will find that the signal ‘apply‘ doesn’t work yet in the beta release of php-gtk2. Have tried it on both windows and linux. Both just do not respond to the Forward button.

Fundamental to a GtkAssistant is to be able to know when the user clicks the Forward button. In the example above, when the user clicks the Forward button, we should get the contents of the two text entry fields and perform some action. Without the ‘apply’ signal, there’s no way you can get hold of the contents of the two GtkEntry!

Another important method that is missing from this beta release of php-gtk2 is the set_forward_page_func(). This method allows you to set your own self-defined handler that will be called when the usr clicks the Forward button. For example, if your wizard allows users to choose between Express, Complete and Custom setup. If the user chooses Express setup, you can jump from Page 2 direct to Page 6. Currently, this method is missing in the beta release of php-gtk2 - both windows and linux.

Without the ‘apply’ signal and the method set_forward_page_func(), it’s really difficult to come out with anything useful using GtkAssistant.

Hopefully the PHP-GTK2 development team will add these soon…

/kksou

http://www.kksou.com/php-gtk2
The place for php-gtk2 sample codes