Friday, February 25, 2005


Gtk2::Ex::RecordsFilter - A high level widget to browse reasonably large amounts of relational data and select a subset of records. This widget is inspired by the song browser of iTunes.

use Gtk2 -init;
use Gtk2::Ex::RecordsFilter;
# Create a recordset
my $recordset = [
# Create the recordsfilter object
my $recordsfilter = Gtk2::Ex::RecordsFilter->new;

# Specify the headers for the columns
my $headers = ['Category', 'Sub-Category', 'Brand', 'Model'];
# Inject data into the widget
# Get a ref to its widget
my $recordsfilter_widget = $recordsfilter->get_widget();
# Create the root window
my $window = Gtk2::Window->new;
$window->signal_connect(destroy => sub { Gtk2->main_quit; });
$window->set_default_size(500, 300);
# Add the widget to the root window


When working with large amounts of relational records (csv files, database records, music files index), a common task is to filter out a subset or records from a given set. For example, in a master-detail database design, the master recordset, which is typically smaller than the detail recordset, can be filtered out and the filtered subset of master records can then be used to perform additional tasks on the detail records that they point to.

A common example of this usage is the song browser in your own mp3 player application (for example, the iTunes application). This application will allow you to choose an mp3 file (the detail record) based on criteria such as Artist, Album, Song (the master record). Once the master record is choosen (i.e., the Artist, Album and Song) it then performs a task on the detail record (i.e., play the mp3 file).

This Gtk2::Ex::RecordsFilter widget is inspired by the iTunes song browser widget. But this widget carries certain functionality which is not present in the iTunes song browser. The iTunes song browser allows the user to choose one song (one master record) at a time and play it. However, a more general usage should allow the user to choose multiple master records at a time. One approach for such multiple selections is to enable the user to click on different records with the CTRL key pressed and then choose all the highlighted records in one shot. This widget takes a different approach, which I call the 'shopping cart' approach. This is explained in the next section.

The top half the widget shows all the master records. The records are shown in a hierarchical fashion similar to the iTunes song browser. Clicking on a parent node on the left-most box will cause all the boxes on its right to show only the child nodes.

The user can click on any entry in the top half and then click on the add to selection button and the record will show up in the bottom half. If the entry clicked is in one of the left boxes, then the widget automatically discovers all the child nodes and adds them to the selection. Upon adding to selection, the record is removed from the top half and shows up in the bottom half. The remove from selection button works in the reverse way.

The user can click on multiple records in the top half using the CTRL key.


my $recordsfilter = Gtk2::Ex::RecordsFilter->new;

The widget can be used to select a subset of these records (into a selection list). The methods get_selected_rows and get_unselected_rows can be used to view the selection ( or unselection) at any point.

'Selected' portion is referred to as the 'RIGHT' side (bottom). 'Unselected' portion is referred to as the 'LEFT' side (top)



The recordset is injected into the widget using this method. The widget will automatically create the HPaned children and the Selection buttons.


my $recordsfilter_widget = $recordsfilter->get_widget();

This method returns the widget of the filter object.


my $selected_rows = $recordsfilter->get_selected_rows();
print Dumper $selected_rows;

This method returns the selected_rows contained in the bottom half of filter widget. A common usage is to have an Apply button which, when clicked, will invoke this method and use the returned results. Check out the examples directory to see this in action.

$apply_button->signal_connect (clicked =>
sub {
my $selected_rows = $recordsfilter->get_selected_rows();
print Dumper $selected_rows;


my $selected_rows = $recordsfilter->get_unselected_rows();
print Dumper $selected_rows;

This method returns the unselected_rows contained in the top half of filter widget. This method too can be used with an Apply button like the one shown above.

Friday, February 11, 2005

Gtk2::Ex::TreeMaker - 0.07

This is the 0.07 release of this widget. See here for details on the widget including a screenshot


Tuesday, February 08, 2005

Gtk2::Ex::TreeMaker - 0.06

This is the 0.06 release of this widget. See here for details on the widget including a screenshot


Friday, February 04, 2005

Gtk2::Ex::TreeMaker - 0.05

This is the 0.05 release of this widget. See here for details on the widget including a screenshot


Wednesday, February 02, 2005


Gtk2::Ex::TreeMaker - A high level widget to represent a set of relational records in a hierarchical spreadsheet kinda display. This task is typical to most of the business application user interfaces.

Typically in business applications, users like to view data in a spreadsheet kind of display. (Columns represent timeline (typically) and rows represent measures like sales/inventory/blah/blah).

The data itself is typically stored internally as relational records. For example, here is some sales info (stored internally in a relational database)


Region, City, Product, Date, Quantity
Texas, Dallas, Fruits, Dec-2003, 300
Texas, Dallas, Veggies, Jan-2004, 120
Texas, Austin, Fruits, Nov-2003, 310
Texas, Austin, Veggies, Feb-2004, 20

The user will typically want to view the same data in a hierarchical (/spreadsheet) kinda display.


Prod / Date Nov-2003 Dec-2003 Jan-2004 Feb-2004
Fruits 300
Veggies 120
Fruits 310
Veggies 20

With web-based business apps, similar views are created in the browser using lots of html/jsp coding.

The Gtk2::TreeView is an excellent widget to display a similar presentation of data in a desktop app. But creating a (hierarchical) TreeView from flat relational data can require some recursive function coding. It would be great if all this recursive code could be abstracted out and packaged separately.

This high level widget is designed with that purpose in mind. This module will accept a relational feed of records and automatically convert it into a hierarchical treeview using the Gtk2::TreeView. The process involves invoking some recursive functions to build a TreeModel and populate it. Also, since the spreadsheet itself can be rather long horizontally, the widget also has a FreezePane capability.

The above screenshot was generated using the following relational data (csv)


Gmail accounts

Every one seems to be talking about gmail these days. I feel left out for not having one.

If any one wants to send me an invite, please send it to
ofey_aikon at yahoo dot com


Wow! Thank you for all the invites that you guys have sent me. I'm gonna play with gmail now.

This page is powered by Blogger. Isn't yours?