Re: GtkTreeView drag and drop



On Thu, 20 Jun 2002 13:20:44 -0700
Lunatics <lunatics zenlunatics com> wrote:

I'd like to use the default drag on drop handlers for GtkTreeView with 
gtk_tree_view_enable_model_drag_dest(). The motion handler draws boxes 
around nodes in the view but also lines in between nodes. I'd like to 
set it so that it only draws the boxes and not the lines. In other words 
I'd like to restrict drop targets to existing nodes and not allow 
dropping in between nodes. Is this possible and if so, what do I need to do?

Probably getting the draw to do what you want is difficult, but you
can resrict the drop target to nodes/levels you want if you intercept
the row_drop_possible in the destination drag interface (don't know if
this is considered private data?):

static gboolean (*default_row_drop_possible)();

static gboolean
row_drop_possible(GtkTreeDragDest *drag_dest, GtkTreePath *path,
            GtkSelectionData *selection_data)
    {
    gint    *indices, depth;

    indices = gtk_tree_path_get_indices(path);
    depth = gtk_tree_path_get_depth(path);
    if (/* Whatever indices/depth criteria for dissallowing the drop */ )
        {
        return FALSE;
        }
    return (*default_row_drop_possible)(drag_dest, path, selection_data);
    }


and when you create the model, set it up:

    GtkTreeDragDestIface *dest_iface;

    model = create_model();
    dest_iface = GTK_TREE_DRAG_DEST_GET_IFACE(GTK_TREE_DRAG_DEST(model));
    default_row_drop_possible = dest_iface->row_drop_possible;
    dest_iface->row_drop_possible = row_drop_possible;
    treeview = GTK_TREE_VIEW(gtk_tree_view_new_with_model(model));

Bill




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