Re: More on embedding combo models in a treestore



muppet wrote:

> (cc'ing gtk-devel-list to see if anybody can confirm whether this is 
> a bug in gtk+ or behaving as designed.)
>
> On Jul 8, 2005, at 12:22 AM, Daniel Kasak wrote:
>
>> If I edit a cell with a combo and then click into another row, 
>> however, things go screwy. The problem seems to be that by clicking 
>> in another row, I'm 'activating' it *before* my code catches the 
>> edit and figures out what to put back into the cell. ie when I get 
>> hold of the combo's model, I'm actually getting the model of the 
>> combo in the *new* row that I just clicked in, and not the model of 
>> the combo in the *current* (from my point of view anyway ) row.
>
>
> I can confirm this with the little test program i posted earlier  (
> http://mail.gnome.org/archives/gtk-perl-list/2005-July/ msg00065.html
> ), by adding these lines to the "edited" callback:
>
>     my ($combo_model) = $model->get ($model->get_iter_from_string 
> ($text_path), MODEL_COLUMN);
>     warn "NOT THE SAME\n" if $combo_model != $cell->get ('model');
>
> then clicking in a row, clicking again in that row to edit it, 
> choosing something else from the menu, then clicking in another row 
> to commit the edit instead of hitting the enter key.
>
<snipped>

>
> I'm assuming you have the combo models stored in a spare column of 
> the main tree model (as previously discussed); instead of getting the 
> combo model from the renderer, try getting it from the tree model 
> row, like so:
>
>     my $path = Gtk2::TreePath->new_from_string ($text_path);
>     my $model = $self->{treeview}->get_model;
>     my $iter = $model->get_iter ($path);
>     my $combo_model = $model->get ($iter, COMBO_MODEL_COLUMN);
>
>
> If this works, then it's a good bet my hypothesis is correct.  This 
> smells a bit like a bug, and if nothing else violates the principle 
> of least surprise, but it's up to the gtk+ developers to say whether 
> it's really wrong.
>
Yes this works. Thanks Muppet :)

-- 
Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: dkasak nusconsulting com au
website: http://www.nusconsulting.com.au



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]