Source Code for PHP-GTK Explorer
The program "PHP-GTK Explorer" is written entirely in PHP-GTK2.
It is a good example of how everything fits together. It employs many tips and techniques that will be very useful to many other applications. Below are some highlights.
Custom combobox with auto-completion
- As you have probably noticed, I didn't use the standard GtkEntryCompletion for the search box. The problem with the standard GtkEntryCompletion is that it doesn't show the entire list in a pulldown menu.
- With the new class ComboBox_with_Typeahead that I've written, you can easily create a combobox with typeahead (or auto-completion) with a one-liner:
$combobox = new ComboBox_with_Typeahead($options)!
- If you're keen to learn more, you can explore the code to see how the auto-completion is being implemented through the use of the 'key-press-event'.
The TreeView with the underlying TreeStore (the left panel)
- Generation of the list of classes and methods on-the-fly
- Mapping of the object hierarchy of all the PHP-GTK2 classes to the GtkTreeModel.
- Finding the siblings and children of a particular widget.
- Finding the methods of a particular class, and all its inherited widgets.
- Automatic scrolling of the treeview to the searched text. Believe me, this is a really tricky one! The main reason is that we need to auto-scroll four views in the four tabs all at the same time. I originally started with one underlying model shared by all the four views, and used GtkTreeModelFilter to present the four different views. The views were ok. But the scrolling part didn't work. You will see how I achieve the auto-scrolling in the four views in the code.
NoteBook
- How to effectively setup and manage all the tabs of notebook?
- How to link the left pane (the treeview) and the right pane (the notebook).
- Switching between the tabs.
- Popup of menus on right mouse click.
- Updating of all tabs at one go.
Signal Handling
- Registering 'key-press-event' on different widgets and propagating the 'key-press-event' signal across the widgets.
- Responding to left, right and middle mouse clicks on different widgets.
- Responding to popup context-sensitive menu on right-mouse button across different widgets.
Selections using Dialog Box with Treeview
new in v1.03
- I made extensive use of dialog box with treeview to allow users to make easy selections through a huge list of options. You see this in the search for methods/signals and in history browsing.
- The popup dialog box allows users to select with single click, double click or click on OK button. It also allows users to move around using just the keyboard — up arrow, down arrow, Home, End, PgUp, PgDn, etc.
- Using the same GtkEntry as search field for both methods and signals.
Progress Bar
new in v1.03
- There are many ways to implement the progress bar. In this application, I found some space behind the search field on the right. So I decide to put the progress bar there.
- Learn how to display the progress bar with seconds with one decimal place.
- Starting and stopping the progress bar.
How much does this cost?
If you're starting on php-gtk2, you will find many of the tips and techniques in this application an "eye-opener" of how different widgets are used in real-life.
An hour of studying the source code will give you a lot of new ideas and insights that you've never imagined before. Not to mention the many useful classes, methods, and functions that you can use directly in your own applications.
The price of the source code? Just $12.95!
For $12.95, you will be on your way to learning and deploying the many PHP-GTK tips and techniques used in "PHP-GTK Explorer".
2Checkout.com, Inc. is an authorized reseller of kksou.com
p.s. The program is written entirely using OOP (object-oriented programming). So please make sure you do have some knowledge about PHP's OOP and classes in order to understand and make use of the codes in this application.
|
|