Archive for September, 2007

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

PHP-GTK Explorer v1.03 - Three New Exciting Features Added!

Tuesday, September 18th, 2007

Have just added three new exciting features to PHP-GTK Explorer v1.03:

  • Search for methods
  • For example, type in set_size_request, you will find it belongs to GtkWidget. If you’re not sure of the complete spelling, you can even typing in set_size or just size!

    Search for Method

  • Search for signals
  • For example, type in clicked, all the widgets containing the signal ‘clicked’ will be listed. Do you know there are three widgets all with the signals ‘clicked’?

    Search for Signals

  • Browse history
  • Just press the F8, and you will be able to browse all the widgets that you have explorerd. Click on the history item, and you will be taken directly back to that widget!

    Browse History

Click here to download!

Some Implementation Details

  • For the searching of methods, I actually loop through all the widgets (using the reflection classes). For each widget, I retrieve all the methods and match it against the method you have entered in the search field. The entire process usually takes between 1 to 5 seconds. Just for “fun”, I added a progress bar when searching for the methods so that you won’t feel too bored while waiting for the dialog box to appear.
  • In the popup dialog box that lists all the methods that match the criteria, if you use single click, you will see immediate update of the parent window with the selected widget and method. To close the dialog, use double-click, click the OK button, or press the Return key. Alternatively, you can also use the keyboard arrow key, Home or End to quickly to move the selection bar.
  • To improve the user experience, when you have selected a method e.g. GtkWidget::set_size_request(), the method is listed in the 133th position. You will find that the right pane will automatically scroll to that method, with a yellow highlight.
  • Press F10 to search for widget. F11 to search for methods. And F12 to search for signals.
  • Press F8 to browse the history.


/kksou

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

new book: PHP-GTK2 Cookbook Vol.2 - Advanced Recipes

Sunday, September 16th, 2007

Looking for new insights and ideas?

Want to sharpen your PHP-GTK2 skills?

Then you’ll want this book…

Highlights of the book:

  • Advanced tips and techniques on PHP-GTK2
  • Sharpen your PHP-GTK2 skills
  • Get new insights and ideas

More information here:
http://www.kksou.com/php-gtk2/ebooks/ebook03//

/kksou

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

Today kksou.com turns 1 year old!

Wednesday, September 12th, 2007

birthday cakeIt’s amazing how time flies. kksou.com is one year old today!

I started kksou.com one year ago, on September 12, 2006. I could only do this in my spare time - after my work, after playing with my kids and after they go to bed. I would then make a cup of coffee and start writing the recipe for the day.

I set a goal that time to write one PHP-GTK2 recipe a day. I’m really glad that I reached the goal - with 327 recipes and 49 advanced recipes - a total of 376 recipes to date! (See, I even worked on Saturdays and Sundays!)

Moving forward, I have a lot of things I would like to add to the site. For example, add more features to PHP-GTK2 Explorer; add sample codes for Glade; add sample codes for integration with MySQL; add more sample applications, etc.

If you are in the mood to commemorate this joyous occasion, here are some suggestions:

  • Write a birthday message in the guestbook.
  • Send me suggestions via the feedback form - any areas for improvement, any wish list for this site, etc.
  • Take a look at the top 30 most viewed articles over the past one year.
  • Take a look at the php-gtk2 friends that have visited this site — a total of 166 countries around the world! (have just updated the statistics)
  • Tell your friends about this site!

By the way, from now till the end of this month (i.e. from Sep 12 - Sep 30), to thank you for the support and encouragement you have given me over the past one year, you will enjoy a straight 30% discount for all ebooks available on this site! If you have been thinking getting a copy of the book, don’t miss this once-a-year anniversary offer!

/kksou

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

Laying out widgets using GtkHTML

Tuesday, September 11th, 2007

When I first started using PHP-GTK2, I find the most confusing (and at that time frustrating) part in learning PHP-GTK2 is the layout of widgets.

In HTML, I can easily use tables, or CSS, to position and align any text, graphics or input elements I want.

Of course, once you have learned how to use hbox’s, vbox’s and the expand parameters, this will become an easy task. (Note: even if you intend to use Glade, you still need to understand these concepts.)

I believe those who have used PHP-GTK2 would fully agree with me that this is such a powerful tool that should deserve much more attention.

And I always think the one big factor that deters people, especially those from the PHP web programming world, is this laying out of widgets.

That’s why when I started playing with GtkHTML, I thought “wow! this could be it!”

This widget literally allows you to layout and align widgets using the good old HTML you’re so familiar with!

I’ve come out with three examples to illustrate this:

How to align GtkEntry fields - Part 3 - using gtkhtml?
How to layout widgets using gtkhtml - Example 2?
How to layout widgets using gtkhtml - Example 3?

As pointed out in the example, I’m still trying to figure out how to retrieve the object ID in the signal handler. In the meantime, I did a workaround so that you can see how things work.

If the PHP-GTK2 development team could put the above missing link in place (i.e. retrieving the object ID from the signal handler), I truly believe we will see a huge wave of PHP web programmers embracing PHP-GTK2.

The concept is similar to Glade. But instead of using Glade, we can actually use web tools such as Dreamweaver to design the layout, output in HTML, and load into GtkHTML. This will be so much more intuitive and easier for PHP web programmers.

Don’t you think so?

/kksou

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

Creating your own HTML Editor using GtkHTML

Wednesday, September 5th, 2007

If you’re impressed with how well GtkHTML renders HTML, you will be impressed too with its editing capabilities.

Take a look at the following sample output:

an image editor using GtkHTML

And the complete sample code:

How to create an html editor using gtkhtml - Part 2?

Almost all the most commonly used HTML tags are supported by GtkHTML’s internal editing command.

However, as I’ve mentioned in the article above, I still couldn’t find the way to save the edited text as HTML!

Looking at the C code, I think it’s there. But guess it’s not yet wrapped in PHP-GTK2 yet.

Anybody has any clue?

/kksou

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

Let’s have some fun with GtkHTML!

Saturday, September 1st, 2007

Finally found some time last week to really sit down and explore GtkHTML.

The GtkHTML has been quite “neglected” in the past because it has never been available in the Gnope version or alpha release. However, with the recent beta release of PHP-GTK2, GtkHTML comes pre-built in the windows binary. So if you are already running the beta release, this widget is right there waiting for you!

Although this widget has been around for quite some time (I’ve seen some articles as early as 2001), I was really surprised with the little amount of information that can be found on the Internet. Although it has been “shielded” from PHP-GTK in the past, I would assume that it should be quite popular in the gtk world. However, just do a quick google and you will see that there are literally less than 2 or 3 useful articles or posts about GtkHTML!

I’ve spent at least the past 7 nights doing numerous trials and errors - trying to figure out what each method and signal does, and how to get something as simple as loading an image work.

Of course, some worked. And some didn’t. And with the little amount of documentation, I really don’t know whether it’s a feature not implemented yet in GtkHTML, or not wrapped in PHP-GTK yet.

Through the many testing, I must say that I was quite impressed with how accurately GtkHTML seems to render the HTML. The HTML tags that it recognizes also seems to be quite complete. Just try loading web sites such as google.com or yahoo.com using GtkHTML and you will know what I mean. That’s why I feel if we can get GtkHTML working correctly, this will definitely interest many PHP web programmers to start using PHP-GTK2 too!

In any case, below are two sample codes that I’ve just released.

I will be releasing more sample codes in the next few days. They will cover how to respond to clicks on links, how to embed Gtk widgets within HTML code, etc. So if you’re interested in using GtkHTML, do stay tuned, ok?

/kksou

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