Re: Copying GtkTreeStore rows



Murray,

The thought crossed my mind, but I've never used the DND api before, and at the time didn't feel like groking the gtk+ sources to figure it out.

But it is worth checking into I think.

Paul

On 9/28/06, Murray Cumming <murrayc murrayc com> wrote:
I'll reword this in case it helps to get a response.

The gtk_tree_store_move*() functions
http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeStore.html#gtk-tree-store-move-before
only work with rows at the same level in the tree.

But the default drag and drop behaviour of a GtkTreeStore can happily move
rows between different levels. So is there something that we can reuse in
order to efficiently move rows programatically between levels?

> Hey,
>
> I've been working with Gtkmm to create a Gtk::TreeStore that is capable of
> re-parenting rows.  As far as I can tell the C++ api (and the underlying C
> api) have no method for moving rows between different parent rows. Murray
> Cumming suggested I inquire here to see if I there's an easier way to
> accomplish what I want.
>
> I've really only got the C++ side of things to go on, so if this
> explanation
> is wrong, ask and I'll try and track down what parts of the C api I'm
> actually using.
>
> The basic idea is that instead of doing a real re-parent type of
> operation,
> I just copy from one node in a tree to a new node and delete the original
> node.
>
> In C++ this requires copying from one Gtk::TreeModel::iterator to another
> Gtk::TreeModel::iterator.
>
> The gtkmm api has two methods in the TreeModel that are:
>
> Gtk::TreeModel::get_value_impl( Gtk::TreeModel::iterator& iter, gint
> column,
> Glib::ValueBase& value )
> Gtk::TreeModel::set_value_impl( Gtk::TreeModel::iterator& iter, gint
> column,
> Glib::ValueBase& value )
>
> These two methods seem to be wrapping:
>
> gtk_tree_model_get_value( GtkTreeModel *tree_model, GtkTreeIter *iter,
> gint
> column, GValue *value ) ;
> gtk_tree_store_set_value( GtkTreeStore *tree_store, GtkTreeIter *iter,
> gint
> column, GValue *value ) ;
>
> So all I do is to iterate over the columns in a Gtk::TreeModel and copy
> one
> Glib::ValueBase to the other.
>
> And repeat the copy procedure recursively.
>
> So there are two main questions:
>
> Is there something in the API that I'm missing that would allow me to move
> an iterator from an arbitrary position in a GtkTreeStore to another
> position?
>
> Is there an easier way to copy the values from on iterator to another?
>
> If anyone can make sense of that, I'd like to hear if I'm doing something
> dumb.
>
> Thanks,
> Paul
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
>


Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com




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