Re: Using a TreeStore with a ComboBox



Yeah erm, i'm sorry my example was totally blown, i actually meant a check for a toplevel node, but i somehow had a braino or sth and put a check for the first node instead.

But, what is being proposed would still solve your problem: The nodes that aren't meant to be selected, wouldn't be shown in the first place (applying the visible_func to the TreeModel of the ComboBox).

That is, the procedure would be like this (sorry for not putting any code here, i didn't quite follow the entire code in this thread);

- Create a TreeModel for the combobox
- Wrap it in a TreeModelFilter, and set that as the model for the combobox
- Have a visible_func for the TreeModelFilter, which will dependent on where this combobox is particularily located in the model show only the nodes which are meant to be selected (could be a rather complex algo to determine that depending on what you're doing, also including data, most likely actually, which doesn't get passed into the visible_func directly).

HTH, sorry for the short reply
Milosz

On 6/23/07, Jef Driesen <jefdriesen hotmail com> wrote:
Milosz Derezynski wrote:
> Well, if it's really *just* that:
>
> On 6/23/07, Jef Driesen < jefdriesen hotmail com
> <mailto:jefdriesen hotmail com>> wrote:
>
>     After refilter, the combobox contains no items anymore, just like when I
>     populate the model before using set_visible_func. This is what I
>     expected, because in my model all toplevel nodes have children. Of
>     course this is not the solution I need.
>
>
> and the grander scheme isn't something bigger, then you can just alter
> the function to:
>
> bool
> Example::on_model_visible (const Gtk:TreeModel::const_iterator& iter)
> {
>   return (iter != store->children().begin && iter->children().empty());
> }

This doesn't make any difference. This change only affects the very
first node, which also has children in my example model, and thus
doesn't change anything.

I think a TreeModelFilter is not the solution for my problem, because it
  can only hide nodes from the main model. What I need is the
possibility to prevent certain nodes from being selected in the
combobox. That is a change in the presentation of the model, not the
model itself (e.g. something similar to the set_select_func from the
treemodel).

_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list



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