gnubbs has asked for the wisdom of the Perl Monks concerning the following question:
Solution Found!See Bottom of post
After being gently guided (Formatting Gtk Pages) into using Gtk2 instead of Gtk, I have one more question for everyone.
Looking at Gtk2, I quickly hone in on Gtk2::SimpleList as something that could greatly easy my GUI design. It is nearly exactly what I was attempting to do in Gtk. Nice.
I quickly throw together the code to build my SimpleList:
$slist = Gtk2::SimpleList->new ( 'Enabled' => 'bool', 'Scanner' => 'text', 'Media' => 'text', 'Description' => 'text' ); @{$slist->{data}} = ( ['1','test','CDR','Long Description'], ['0','test 2','CDR'], ['0','test 3','CDR'], );
And I have my basic interface. Next, I have to setup a callback so that anytime the checkbox in a row changes state something happens. This is where things start to fall apart. I try:
$slist->signal_connect( 'row-activated', sub { printDebugWindow("Click +ed!") });
But this is only called when the row is double clicked, not when someone simply clicks on the checkbox. I have looked through the signals for SimpleList and I can't seem to find one that I am looking for. I am thinking that since this is just a tied array, there might be some way to access the underlying objects. But, I have not worked much with tied vars and can't seem to figure it out. I tried:
$slist->{data}[0][0]->signal_connect( 'toggled', sub { printDebugWindo +w("Clicked!") });
But that definately doesn't work. (For some reason I expected it wouldn't since I was pretty much just making up syntax at that point.) Well, I am at a loss at this point. I have read all the documentation that I could find on the Perl-Gtk2 page, the Gtk2 page, and in the pods but I am missing something.
Please, monks, light this path for me.
gnubbs
A solution
Since SimpleList is just an interface to TreeModel, I was able to accomplish what I needed by delving down into the TreeModel itself.
my $tree_model = $slist->get_model(); $tree_model->signal_connect( row_changed => sub { printDebugWindow("Cl +icked") });
This works because the SimpleLists in this GUI only have one editible field -- the bool checkbox. So, this signal is only emitted when someone toggles the checkbox. Thanks again for everyone's help, and please let me know if the path I have found is not a good one.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Gtk2::SimpleList Checkboxes
by kvale (Monsignor) on Mar 15, 2005 at 17:53 UTC | |
by gnubbs (Beadle) on Mar 15, 2005 at 18:13 UTC | |
|
Re: Gtk2::SimpleList Checkboxes
by Anonymous Monk on Mar 30, 2005 at 02:44 UTC | |
by gnubbs (Beadle) on Apr 18, 2005 at 14:56 UTC |