Re: ComboBox with TreeStore, how to hide titles in sub-menus



Hello,

On Sat, 12 Apr 2008 16:14:03 +0200
Tian <tian-ml c-sait net> wrote:
So I tried to use a TreeStore instead of a ListStore as the model for
ComboBox. And it works as expected. The problem is that in the sub-menus,
there is a title that is the name of the group. I attach a small script that
uses that so you may have an idea of what I mean.

It would be nice if there would be a way to hide this title. But the most
important, is that I don't want the user to able to select them.


I almost forgot that. But while I was having another look to gtk-demo, I found
the solution ! It's in 'Combo boxes' and it can be easily adapted to
Gtk2-Perl. Here is the code I needed:


$combo->set_cell_data_func($renderer, sub {
    my ($layout, $cell, $model, $iter) = @_;
    my $sensitive = !$model->iter_has_child($iter);
    $cell->set('sensitive', $sensitive);
});


I can't tell you why it also hide the title, but it works just as I expected.

I posted this solution to have it in the archives if someone else needs to do
the same.

Tian.




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