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