Re: editable cells in GtkListView
- From: tom roth <tom tomroth de>
- To: Guillaume Cottenceau <gc mandrakesoft com>
- Cc: gtk-perl-list gnome org
- Subject: Re: editable cells in GtkListView
- Date: Sun, 16 Feb 2003 00:14:04 +0100
On 14 Feb 2003 17:30:10 +0100
Guillaume Cottenceau <gc mandrakesoft com> wrote:
tom roth <tom tomroth de> writes:
with the help of misc-examples/treeview.pl i was able to produce a Listview.
Now i would like to make some of the cells editable.
Is there any codefragments, docu or tutorial ?
usually it's nice to try to follow c code examples or api doc.
that requires a knowledges of c syntax that i do not comand.
I am at a loss translating the c code documentation to perl syntax.
why? we try to follow th c api quite closely, it should be ok..
what's your problem exactly, do you have examples?
i think my problem is, that i am more of a dummie than you might assume.
And i think i need to read more documentation before i should bother you with concrete and probably stupid
questions.
my sources of documentation so far is the misc-examples folder (most usefull to me),
gtk+-2.0.9/docs/reference/gtk/html/ and gtk-demo where i found the editable cell example.
Now what is my problem exactly ?
for example, i guess that here in the c code example some of the editable cell magic happens:
add_items (void)
{
Item foo;
g_return_if_fail (articles != NULL);
foo.number = 3;
foo.product = g_strdup ("bottles of coke");
foo.editable = TRUE;
g_array_append_vals (articles, &foo, 1);
....
now my problem is: what is this foo.editable business exactly ? I know very little about c.
so my wild guess is, foo is a hash (?) and a pointer of that hash then is appended to an array ???
If i could have this example code (Tree View/Editable Cells of the gtk-demo example)
in perl syntax, things would be way easier for me. If i could read the c code easily, i would probably write
my code in c.
Anyway this is what i have so far
# define a model
my $model = Gtk2::ListStore->new(Gtk2::GType->INT, Gtk2::GType->STRING, Gtk2::GType->STRING,
Gtk2::GType->STRING, Gtk2::GType->STRING, Gtk2::GType->STRING,);
# define an iterator
my $iter = Gtk2::TreeIter->new;
# fill the model with data
my $i = 1;
foreach my $name ( keys %names ) {
$model->append($iter);
$model->set($iter, [0 => $i++, 1 => "$name", 2 => $names{$name}{start}, 3 => $names{$name}{end}, 4
=> $names{$name}{ogg_comment}, 5 => $names{$name}{ogg_artist} ]);
}
$iter->free();
# here i build some parent widgets
.....
# now build the treeview widget
$widgets->{'treeview1'} = new Gtk2::TreeView;
$widgets->{'treeview1'}->set_headers_visible('1');
$forms->{'dialog1'}{'scrolledwindow2'}->add_with_viewport($widgets->{'treeview1'});
my $cell = Gtk2::CellRendererText->new;
my $column = Gtk2::TreeViewColumn->new_with_attributes("No", $cell, 'text' => 0);
$widgets->{'treeview1'}->append_column($column);
my $column1 = Gtk2::TreeViewColumn->new_with_attributes("Name", $cell, 'text' => 1);
$widgets->{'treeview1'}->append_column($column1);
my $column2 = Gtk2::TreeViewColumn->new_with_attributes("Start", $cell, 'text' => 2);
...
$widgets->{'treeview1'}->set_model($model);
$widgets->{'treeview1'}->show;
i am guessing the new_with_attributes is where it is happening, but what is the ciorrect syntax ?
Thanks a lot
tom
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]