#!/usr/bin/python2

from gi.repository import Gdk
from gi.repository import Gtk

Gtk.init()


class CustomStore(Gtk.ListStore):
    def __init__(self, *args):
        Gtk.ListStore.__init__(self, *args)

    def do_drag_data_get(self, path, selection_data):
        print "do_drag_data_get called for storemodel = %s" % self


storemodel = Gtk.ListStore(str)
print "storemodel = %s" % storemodel
for i in range(4):
    storemodel.append(["(ListStore) " + ("%s" % i) * 4])



namecell = Gtk.CellRendererText()
namecol = Gtk.TreeViewColumn("NAME")
namecol.pack_start(namecell, True)
namecol.add_attribute(namecell, "text", 0)
treeview = Gtk.TreeView(model=storemodel)
treeview.append_column(namecol)

EFFECT_TARGET_ENTRY = Gtk.TargetEntry.new("myapp/dragtype", 0, 1001)
treeview.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK, [EFFECT_TARGET_ENTRY], Gdk.DragAction.COPY)
treeview.enable_model_drag_dest([EFFECT_TARGET_ENTRY], Gdk.DragAction.COPY)


win = Gtk.Window()
win.add(treeview)
win.show_all()


win.connect("delete-event", Gtk.main_quit)
Gtk.main()
