Dynamic ListStore column creation?

Hi,

I want to write a set of wrapper, like C++ Builder/Delphi VCL, for db
access with gtk widgets.
I need to create a class for data display and I choose the TreeView used
as listview.
I have created the DBListViewColumn class that contain the table field
name, title and other informations for data display.

The DBListView display 2 columns: the db field name, the data type,

the column title

and other things

column1 = DBListViewColumn.new(“customer_name” , String, “Name”, …)
column2 = DBListViewColumn.new(“customer_number” , Integer, “Cust.
Number”, …)
columns = Array.[](column1, column2)

The DBListView constructor receive 2 parameter the DBQuery used to

select data from db and the array contain the columns definitions

listview = DBListView.new(query, columns)

When the query is executed the DBListStore creates the columns and
display query data.
The Gtk::ListStore object is created in the DBListStore.queryExecuted()
method and the problem is: how I can pass my columns data types to the
Gtk::ListStore constructor?
In the ruby-gnome tutorials Gtk::ListStore is always created with a
fixed number of columns, but I have a variable quantity of them.

Can anyone help me?

Thanks in advance, Emiliano.

On Nov 30, 2007 8:12 AM, Emiliano C. [email protected] wrote:

The Gtk::ListStore object is created in the DBListStore.queryExecuted()
method and the problem is: how I can pass my columns data types to the
Gtk::ListStore constructor?
In the ruby-gnome tutorials Gtk::ListStore is always created with a
fixed number of columns, but I have a variable quantity of them.

If you want to create a Gtk::ListStore with a variable number of
column types, you can use an Array with the ‘splat’ operator: ‘*’.
For example:

types = [String, Integer, String]
listStore = Gtk:::ListStore.new(*types)

DonK/


karfai [AT] gmail.com
http://www.strangeware.ca
http://blog.strangeware.ca

Don Kelly wrote:

If you want to create a Gtk::ListStore with a variable number of
column types, you can use an Array with the ‘splat’ operator: ‘*’.
For example:

types = [String, Integer, String]
listStore = Gtk:::ListStore.new(*types)

DonK/

Many thanks for your help Don.

Emiliano.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs