Q: finely tuned drag-n-drop



Good morning,

  GTK+-2.0 documentation for GtkTreeView::gtk_tree_view_set_reorderable
reads "This function does not give you any degree of control over the
order -- any reorderering is allowed. If more control is needed, you should
probably handle drag and
drop manually."

  That's what I'm trying to do :-)

  I'm trying to limit the order in which a user can place my GtkTreeView
rows.  My GtkTreeModel has "above" and "below" gint columns for which
adjoining rows must match.  e.g.,

     rowname  above   below
      row_a    15      20
      row_b    20      20
      row_c    20      15

Note that:

  row_a's "below" must match row_b's "above"
  row_b's "below" must match row_c's "above"

  I want to support reordering such that someone *could*

   o   move row_c on top of row_a (because then row_c's "below" would
       match row_a's "above")

but could *not*

   o   move row_a below row_b (because even though row_c's "above" would
       match row_a's "below", row_b's "below" would not match row_a's
"above").

  If I tie in to the "drag_drop" signal, I can do:

     GtkTreeSelection *sel =
gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
     gtk_tree_model_get(model, &iter,
                        ABOVE_COLUMN, &above,
                        BELOW_COLUMN, &below,
                        -1);

which tells me the above/below for the current selection which is the one
being moved.  (My selection type is "SINGLE".)

But this doesn't seem to be the right signal to tie in to since I want to
find out *where* in the GtkTreeView (i.e., what row) the current selection
is trying to be dropped, whereupon I could then make an "accept" or "reject"
decision.

I'd certainly appreciate some tips.

Regards,
James




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