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.


In reply to Gtk2::SimpleList Checkboxes by gnubbs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.