Re: Using the same model in two treeview and prevent selecting the same item?
On Wed, Aug 24, 2011 at 03:50:46PM +0200, Michal Suchanek wrote: > I have a list which I want to display in two treeviews and prevent > selecting the same item in both. > > The idea is that the user selects an item in the first list, then the > second list is shown, and it should not contain the item selected in > the first list (or the item should be inactive or whatever). > > I tried using a model filter to this end. It has an option to set > custom filter callback and in this callback I fetch the selection of > the first list (if any) and return false if the filtered item is the > same as selected. I would just render the item as inactive using cell renderer's "sensitive" property and prevent it from being selected using gtk_tree_selection_set_select_function(). You need to remember the current selection but otherwise it is pretty cheap: if the selected row changes only two rows have to receive "row-changed" to update the other treeview: the previously selected one (becomes selectable) and the newly selected one (becomes unselectable). Also, depending on the application this might be visually preferrable to appearing and disappearing rows. Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Using the same model in two treeview and prevent selecting the same item?
Hello, I have a list which I want to display in two treeviews and prevent selecting the same item in both. The idea is that the user selects an item in the first list, then the second list is shown, and it should not contain the item selected in the first list (or the item should be inactive or whatever). I tried using a model filter to this end. It has an option to set custom filter callback and in this callback I fetch the selection of the first list (if any) and return false if the filtered item is the same as selected. The problem is that I have to call refilter whenever the selection changes in the first list. Otherwise, the second list contains everything from the model. Since the second list is hidden in my application I could call refilter on showing it but a more dynamic solution that allows showing both lists would be welcome. O course, my list of about dozen items can be refiltered on every selection change just fine but it does not look like the right solution. I could possibly use a filter column in the list but setting it would be tedious. AFAIK the selection change signal only gives current selection so I would have to save the previous selection so that I could flip the filter column on both. I am not sure that it would resolve the automatic update issue either. Thanks Michal ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list