CTree feature request

I am interested in using the ctree's drag and drop functions
to reorder items.

For reference, the program is gmenu from GNOME.

I see that the "tree_move" signal passes the new parent and sibling,
but how do I get the old parent and sibling (where it came from).

May I propose the signal as follows:

  void (*tree_move)         (GtkCTree     *ctree,
                             GtkCTreeNode *node,
                             GtkCTreeNode *new_parent,
                             GtkCTreeNode *new_sibling,
new part starts here ->      GtkCTreeNode *old_parent,
                             GtkCTreeNode *old_sibling);

Or maybe I'm just missing something obvious, to be honest I haven't tried
anything yet, but only read the source.

Also it would be nice to be able to specify a function callback to test if
a position could be dropped onto. I would need such a function to not allow users
to drag parts from one subtree to another subtree. (for example to drag a system
item into a user item subtree) The compare callback could return true or false
to specify if the drop should be allowed, if not, change the curser to show it's
not droppable there. The compare function would be called every time the drop
target changes.

Here is how I envision the calls:

to set or enable the compare function:

  gtk_ctree_set_reorder_compare_func  (GtkCTree *ctree,
                                       GtkCompFunc *func,
                                       gpointer data);
in use for the following example:

  gtk_ctree_set_reorder_compare_func (GTK_CTREE(ctree),

the example callback:

  gint test_reorder_cb  (GtkCTree *ctree,
                         GtkCTreeNode *source_node,  /* node being dragged */
                         GtkCTreeNode *drop_parent,  /* possible new parent */
                         GtkCTreeNode *drop_sibling, /* possible new sibling */
                         gpointer data)
    if (source_node->parent != drop_parent)
      return FALSE;
      return TRUE;

In this example nodes would not be allowed to be dragged out of their subtree,
but only within that same parent. (very simple example)

I feel these would be useful additions to the gtkctree (clist too?). I really
won't be able to easily use the reorderability of the ctree without similar
functions. I would make the additions myself, but I don't know if I would
implement them properly (and my first suggestion breaks compatibility).

BTW: Would this be better posted to gtk-devel? I'm not subscribed to that
list, yet :)

John Ellis <johne@bellatlantic.net>

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