Re: Dual Drop on to GtkTreeView



Thanks for the tips. This almost works--if I manually add an item to the view, I can drag other items over it and then add them to the view. However, you can't drag the first item into the view, and you can't drag any item into the empty space at the bottom of the list. The code I have is:

static const GtkTargetEntry target_table [] =
{
        { "STRING",        0, TARGET_STRING },
        { "text/plain",    0, TARGET_STRING },
        { "text/uri-list", 0, TARGET_URL },
        { "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, 0 }
};


        view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));

        gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (view),
                                        GDK_BUTTON1_MASK,
                                        target_table,
                                        G_N_ELEMENTS (target_table),
                                        DK_ACTION_MOVE|GDK_ACTION_COPY);
        gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (view),
                                      target_table,
                                      G_N_ELEMENTS (target_table),
                                      GDK_ACTION_MOVE|GDK_ACTION_COPY);
        g_signal_connect (G_OBJECT (view), "drag_data_received",
                        G_CALLBACK (drag_audio_rcv_cb), store);

Ali Akcaagac wrote:
On Wed, 2003-06-25 at 16:58, Todd Kulesza wrote:

        view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));

gtk_drag_dest_set (view, GTK_DEST_DEFAULT_ALL, target_table,


remove that dest_set call...

gtk_tree_view_enable_model_drag_dest ()
gtk_tree_view_enable_model_drag_source ()

and use these instead.

gtk_tree_xx_drag_source (GTK_TREE_VIEW (view),
                                        GDK_BUTTON1_MASK,
                                        target_table,
                                        G_N_ELEMENTS (target_table),
                                        GDK_ACTION_MOVE|GDK_ACTION_COPY);

gtk_tree_xx_drag_dest (GTK_TREE_VIEW (view),
                                      target_table,
                                      G_N_ELEMENTS (target_table),
                                      GDK_ACTION_MOVE|GDK_ACTION_COPY);


this enables that you drag and drop stuff inside your view. now add the
'drag-data-received' signal to it, as you did, with that you should be
able to get the with gtk_tree_view_get_drag_dest_row so you can store
your drag from nautilus there. if you autoreorder things then you dont
need gtk_tree_view_get_drag_dest you can simply insert the new row in
your view and have it sorted automatically.

hope this helps. i assume your target_table is set up correctly. there
is no further stuff needed as in connecting a source or other dest.

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list





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