Ejemplo n.º 1
0
class  BrowserPanel(gtk.HBox): 
    def __init__(self,parent):
        gtk.HBox.__init__(self)

        self.chartview = None
        hbox = gtk.HBox()

        vbox = gtk.VBox()        
        # tables
        liststore = gtk.ListStore(str)
        self.tables = gtk.ComboBoxEntry(liststore)
        self.tables.set_size_request(228,-1)
        self.tables.get_children()[0].set_editable(False)
        cell = gtk.CellRendererText()

        self.tables.pack_start(cell)
        self.tables.connect('changed',self.on_tables_changed)
        tablelist = curr.datab.get_databases()
        
        for c in tablelist:
            liststore.append([c])
        index = 0
        for i,r in enumerate(liststore):
            if r[0] == curr.database:
                index = i
                break 
        self.tables.set_active(index) 

        but = gtk.Button()
        img = gtk.Image()
        appath = boss.app.appath
        imgfile = path.joinpath(appath,"astronex/resources/refresh-18.png")
        img.set_from_file(str(imgfile))
        but.set_image(img)
        but.connect('clicked',self.on_refresh_clicked,self.tables)
        hhbox = gtk.HBox()
        hhbox.pack_start(self.tables,False,False)
        hhbox.pack_start(but,False,False) 
        vbox.pack_start(hhbox,False,False)
        
        #vbox.pack_start(self.tables,False,False)
        
        # chart list
        self.chartmodel = gtk.ListStore(str,int)
        #self.chartview = gtk.TreeView(self.chartmodel)
        self.chartview = SearchView(self.chartmodel)
        selection = self.chartview.get_selection()
        selection.set_mode(gtk.SELECTION_SINGLE)
        chartlist = curr.datab.get_chartlist(self.tables.get_active_text())

        for c in chartlist:
            glue = ", "
            if c[2] == '':  glue = ''
            self.chartmodel.append([c[2]+glue+c[1] , int(c[0]) ])
        
        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn(None,cell,text=0)
        self.chartview.append_column(column) 
        self.chartview.set_headers_visible(False)
        self.chartview.connect('row_activated',self.on_chart_activated)
        sel = self.chartview.get_selection()
        sel.set_mode(gtk.SELECTION_SINGLE)
        sel.connect('changed',self.on_sel_changed)
        sel.select_path(0,)
        self.chartview.grab_focus()
        
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.add(self.chartview) 
        vbox.pack_start(sw,True,True)
        
        # drawer
        hbox.pack_start(vbox,False,False)
        hbox.pack_start(gtk.VSeparator(),False,False)
        self.chsnap = ChartSnapshot(parent.boss)
        self.chsnap.set_size_request(400,400) 
        hbox.pack_start(self.chsnap)
        frame = gtk.Frame()
        frame.set_border_width(6)
        frame.add(hbox)
        self.add(frame)

    def on_refresh_clicked(self,but,combo):
        combo.emit('changed')
    
    def findchart(self,first,last):
        model = self.chartview.get_model()
        iter = model.get_iter_root()
        while iter:
            tfirst,__,tlast = model.get_value(iter,0).partition(',')
            if first == tfirst and last == tlast:
                self.chartview.get_selection().select_path(model.get_path(iter)) 
                break
            iter = model.iter_next(iter)

    def on_tables_changed(self,combo): 
        if combo.get_active() == -1: return
        if not self.chartview is None:
            chartmodel = gtk.ListStore(str,int)
            chartlist = curr.datab.get_chartlist(self.tables.get_active_text()) 
            for c in chartlist:
                glue = ", "
                if c[2] == '':  glue = ''
                chartmodel.append([c[2]+glue+c[1] , int(c[0]) ])
            self.chartview.set_model(chartmodel)
            self.chartview.get_selection().select_path(0,)
    
    def on_sel_changed(self,sel):
        model, iter = sel.get_selected()
        if not iter:
            sel.select_path(0,)
            model, iter = sel.get_selected()
        id = model.get_value(iter,1)
        table = self.tables.get_active_text()
        curr.datab.load_chart(table,id,chart)
        try:
            self.chsnap.redraw()
        except AttributeError:
            pass

    def on_chart_activated(self,view,path,col):
        model,iter = view.get_selection().get_selected()
        id = model.get_value(iter,1)
        chart = curr.charts[Slot.storage]
        table = self.tables.get_active_text()
        curr.datab.load_chart(table,id,chart)
        curr.add_to_pool(copy(chart),Slot.overwrite)
        MainPanel.actualize_pool(Slot.storage,chart) 

    def relist(self):
        liststore = gtk.ListStore(str)
        tablelist = curr.datab.get_databases() 
        for c in tablelist:
            liststore.append([c])
        self.tables.set_model(liststore)
Ejemplo n.º 2
0
class ChartBrowser(gtk.VBox):
    def __init__(self,ap_path,font):
        gtk.VBox.__init__(self)
        self.chartview = None
        self.font = font
        appath = path.joinpath(ap_path,'astronex')
        
        liststore = gtk.ListStore(str)
        self.tables = gtk.ComboBoxEntry(liststore)
        self.entry = self.tables.get_children()[0]
        self.entry.set_editable(False)
        self.entry.connect('activate',self.on_search_activated)
        cell = gtk.CellRendererText()

        self.tables.pack_start(cell)
        self.tables.connect('changed',self.on_tables_changed)
        self.tables.set_size_request(120,-1)
        tablelist = curr.datab.get_databases()
        liststore.append([_('(Buscar)')]) 

        for c in tablelist:
            liststore.append([c])
        index = 0
        for i,r in enumerate(liststore):
            if r[0] == curr.database:
                index = i
                break 
        self.tables.set_active(index)
        
        hbox = gtk.HBox()
        hbox.pack_start(self.tables)
        
        opbut = gtk.Button()
        img = gtk.Image()
        imgfile = path.joinpath(appath,"resources/folder-convert24.png")
        img.set_from_file(imgfile)
        opbut.set_image(img) 
        opbut.set_tooltip_text(_('Explorador/Tablas'))
        opbut.connect('clicked',self.on_opbut_clicked)
        hbox.pack_start(opbut,False,False) 

        opbut = gtk.Button()
        img = gtk.Image()
        imgfile = path.joinpath(appath,"resources/pgram.png")
        img.set_from_file(imgfile)
        opbut.set_image(img) 
        opbut.set_tooltip_text(_('Planetograma'))
        opbut.connect('clicked',self.on_plagram_clicked)
        hbox.pack_start(opbut,False,False) 
        self.pack_start(hbox,False,False)
        
        self.chartmodel = gtk.ListStore(str,int)
        #self.chartview = gtk.TreeView(self.chartmodel)
        self.chartview = SearchView(self.chartmodel)
        selection = self.chartview.get_selection()
        selection.set_mode(gtk.SELECTION_SINGLE)
        chartlist = curr.datab.get_chartlist(self.tables.get_active_text())

        for c in chartlist:
            glue = ", "
            if c[2] == '':  glue = ''
            self.chartmodel.append([c[2]+glue+c[1],int(c[0])])
        
        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn(None,cell,text=0)
        self.chartview.append_column(column) 
        self.chartview.set_headers_visible(False)
        self.chartview.connect('row_activated',self.on_chart_activated)
        
        self.menu = gtk.Menu()
        for buf in (_('Copiar'),_('Cortar'),_('Pegar')):
            menu_items = gtk.MenuItem(buf)
            self.menu.append(menu_items)
            menu_items.connect("activate", self.on_menuitem_activate, buf)
            menu_items.show()
        self.chartview.connect('button_press_event',self.on_view_clicked)

        self.clip = None

        sw = gtk.ScrolledWindow()
        #sw.set_size_request(-1,160)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.add(self.chartview) 
        self.pack_start(sw,True,True)

    def on_opbut_clicked(self,but):
        boss.mainwin.launch_chartbrowser_from_mpanel() 
    
    def on_plagram_clicked(self,but):
        boss.mainwin.launch_plagram(None,None,None,None) 

    def relist(self,new):
        liststore = gtk.ListStore(str)
        tablelist = curr.datab.get_databases() 
        for c in tablelist:
            liststore.append([c])
        if not new:
            new = self.tables.get_active_text() 
        index = 0
        for i,r in enumerate(liststore):
            if r[0] == new:
                index = i
                break 
        self.tables.set_model(liststore)
        self.tables.set_active(index)

    def on_view_clicked(self,view,event):
        if event.type == gtk.gdk.BUTTON_PRESS and event.button == 2:
            path = view.get_path_at_pos(int(event.x),int(event.y))[0]
            view.get_selection().select_path(path)
            model,iter = view.get_selection().get_selected()
            if not iter:
                return True
            id = model.get_value(iter,1)
            try:
                table = model.get_value(iter,2)
            except ValueError:
                table = self.tables.get_active_text()
            chart = curr.newchart()
            curr.datab.load_chart(table,id,chart)
            boss.mainwin.launch_aux_from_browser(chart)
            return True
        elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
            x = int(event.x)
            y = int(event.y)
            pthinfo = view.get_path_at_pos(x, y)
            if pthinfo is not None:
                path, col, cellx, celly = pthinfo
                view.grab_focus()
                view.set_cursor(path,col,0)
                if  self.clip is None:
                    self.menu.get_children()[2].set_sensitive(False)
                self.menu.popup(None, None, None, event.button, event.time)
            return True
        return False

    def on_menuitem_activate(self,menuitem,item): 
        model,iter = self.chartview.get_selection().get_selected()
        id = model.get_value(iter,1)
        table = self.tables.get_active_text()
        if item == _('Copiar') or item == _('Cortar'): 
            chart = curr.newchart()
            curr.datab.load_chart(table,id,chart)
            self.clip = chart
            menuitem.parent.get_children()[2].set_sensitive(True)
            if item == _('Cortar'):
                if not curr.safe_delete_chart(table,id):
                    msg = _('No puedo eliminar una carta con pareja!' )
                    dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
                            gtk.MESSAGE_WARNING,
                            gtk.BUTTONS_OK, msg);
                    result = dialog.run()
                    dialog.destroy()
                    return
                curr.datab.delete_chart(table,id)
                self.tables.emit('changed')
        else: # paste
            self.new_chart(self.clip)

    def on_search_activated(self,entry):
        if self.tables.get_active() > 0:
            return 
        searchlist = curr.datab.search_by_name_all_tables(entry.get_text())
        if not self.chartview is None:
            chartmodel = gtk.ListStore(str,int,str)
            for c in searchlist :
                glue = ", "
                if c[3] == '':  glue = ''
                chartmodel.append([c[3]+glue+c[2] , int(c[1]), c[0]])
            self.chartview.set_model(chartmodel)

    def on_tables_changed(self,combo): 
        if combo.get_active() == -1: return
        if combo.get_active() == 0: 
            self.entry.set_editable(True)
            self.entry.select_region(0,-1)
            self.entry.grab_focus()
            return
        else:
            if self.entry.get_editable():
                self.entry.set_editable(False)

        if not self.chartview is None:
            chartmodel = gtk.ListStore(str,int)
            chartlist = curr.datab.get_chartlist(self.tables.get_active_text()) 
            i = 0; r = 0
            for c in chartlist:
                glue = ", "
                if c[2] == '':  glue = ''
                chartmodel.append([c[2]+glue+c[1] , int(c[0]) ])
                if curr.curr_chart.first == c[1] and curr.curr_chart.last == c[2]:
                    r = i
                i += 1
            self.chartview.set_model(chartmodel)
            self.chartview.get_selection().select_path(r)
            self.chartview.scroll_to_cell(r)
            #self.chartview.row_activated(r,self.chartview.get_column(0))
    

    def on_chart_activated(self,view,path,col):
        model,iter = view.get_selection().get_selected()
        id = model.get_value(iter,1)
        try:
            table = model.get_value(iter,2)
        except ValueError:
            table = self.tables.get_active_text()
        chart = curr.charts[self.slot]
        curr.datab.load_chart(table,id,chart)
        curr.add_to_pool(copy(chart),Slot.overwrite)
        MainPanel.actualize_pool(self.slot,chart) 
        

    def constrainterror_dlg(self,fi,la):
        msg = _("Una carta con este nombre: %s %s existe. Sobrescribir?") % (fi,la)
        dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
                gtk.MESSAGE_WARNING,
                gtk.BUTTONS_OK_CANCEL, msg);
        result = dialog.run()
        dialog.destroy()
        return result
    
    def new_chart(self,chart):
        from sqlite3 import DatabaseError
        table = self.tables.get_active_text()
        try:
            lastrow = curr.datab.store_chart(table, chart) 
        except DatabaseError:
            result = self.constrainterror_dlg(chart.first,chart.last)
            if result != gtk.RESPONSE_OK:
                return None,None
            curr.datab.delete_chart_from_name(table,chart.first,chart.last)
            lastrow = curr.datab.store_chart(table, chart) 
            curr.fix_couples(table,chart.first,chart.last,lastrow)
        self.tables.emit('changed')
        return lastrow,table
Ejemplo n.º 3
0
class LocWidget(gtk.VBox):
    def __init__(self,default=False):
        gtk.VBox.__init__(self)
        self.set_homogeneous(False)

        if not default:
            if curr.usa:
                x,c = curr.loc.region.split('(')
                c = curr.datab.get_usacode_from_name(c[:-1])
                country_code = c
            else:
                country_code = curr.loc.country_code
            region = curr.loc.region_code
            city = curr.loc.city 
        else:
            curr.usa = {'false':False,'true':True}[boss.opts.usa]
            country_code = boss.opts.country
            region = boss.opts.region
            city = boss.opts.locality
            curr.country = country_code

        self.countries = curr.datab.get_states_tuple(curr.usa)
        self.sortlist = sorted(self.countries) 

        compl = gtk.EntryCompletion()
        # country label and check btns 
        hbox = gtk.HBox()
        l = [_('Pais'),_('Estado')][curr.usa]
        label = gtk.Label(l)
        hbox.pack_start(label,False,False)
        self.check = gtk.CheckButton(_("Usa"))
        self.check.set_active(curr.usa)
        self.check.connect('toggled',self.on_usa_toggled,compl,label)
        hbox.pack_start(self.check,True,False)
        
        self.filtcheck = gtk.CheckButton(_("Filtro"))
        self.filtcheck.connect('toggled',self.on_filter_toggled)
        hbox.pack_start(self.filtcheck,True,False) 
        label = gtk.Label(_('Region'))
        hbox.pack_end(label,True,False)
        hbox.set_border_width(3) 
        hbox.set_homogeneous(True) 
        self.pack_start(hbox,False,False)

        # country combo
        hbox = gtk.HBox()
        liststore = gtk.ListStore(str,str)
        self.country_combo = gtk.ComboBoxEntry(liststore)
        cell = gtk.CellRendererText()
        self.country_combo.pack_start(cell)
        
        for n,c in self.sortlist:
            liststore.append([n,c])

        for r in self.country_combo.get_model():
            if r[1] == country_code:
                self.country_combo.set_active_iter(r.iter)
                break
        
        compl.set_text_column(0)
        compl.set_model(self.country_combo.get_model())
        self.country_combo.child.set_completion(compl)#entry
        compl.connect('match_selected', self.on_count_match)

        self.country_combo.set_wrap_width(4)
        self.country_combo.connect('changed',self.on_count_selected) 
        hbox.pack_start(self.country_combo,False,False)

        
        # region combo
        liststore = gtk.ListStore(str,str)
        self.reg_combo = gtk.ComboBoxEntry(liststore)
        cell = gtk.CellRendererText()
        self.reg_combo.pack_start(cell)
        self.reg_combo.connect('changed',self.on_reg_selected)
        rlist = curr.datab.list_regions(country_code,curr.usa)
        if country_code == u"SP" and boss.opts.lang == 'ca':
            temp = []
            for r in rlist:
                temp.append((cata_reg[r[0]],r[1]))
            rlist = temp

        i = 0
        for n,r in enumerate(rlist):
            liststore.append(r)
            if region == r[1]:
                i = n

        self.reg_combo.set_active(i)
        hbox.pack_end(self.reg_combo,False,False)
        self.pack_start(hbox,False,False)

        # locality view
        self.locmodel = gtk.ListStore(str,str,str)
        #self.locview = gtk.TreeView(self.locmodel)
        self.locview = SearchView(self.locmodel)
        selection = self.locview.get_selection()
        selection.connect('changed',self.on_sel_changed)
        selection.set_mode(gtk.SELECTION_SINGLE)
        loclist = curr.datab.fetch_all_from_country(country_code,curr.usa)
        i = 0
        for n,c in enumerate(loclist):
            self.locmodel.append(c)
            if city == c[0]:
                i = n

        cell = gtk.CellRendererText()
        cell.set_property('width-chars',38)
        cell.set_property('foreground','blue')
        cellgeo = gtk.CellRendererText()
        column = gtk.TreeViewColumn(None)
        column.pack_start(cell,False)
        column.pack_start(cellgeo,False)
        column.set_attributes(cell,text=0)
        column.set_attributes(cellgeo,text=2)
        column.set_widget(gtk.HSeparator())
        self.locview.append_column(column) 
        self.locview.set_headers_visible(False)
        #self.locview.set_enable_search(True)
        self.locview.set_cursor(i,column)
        self.locview.scroll_to_cell(i)
        self.locview.connect('row-activated',self.on_row_activate)

        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.add(self.locview) 
        self.pack_start(sw)


    def on_reg_selected(self,combo):
        model = combo.get_model()
        active = combo.get_active()
        if active < 0: 
            return
        self.reg_code = model[active][1]
        if self.filtcheck.get_active():
            filtmodel = self.locmodel.filter_new()
            filtmodel.set_visible_func(filter_region, self.reg_code)
            self.locview.set_model(filtmodel)

    def on_count_selected(self,combo):
        iter = combo.get_active_iter()
        if not iter: return
        model = combo.get_model()
        code = unicode(model.get_value(iter,1),"utf-8")
        liststore = gtk.ListStore(str,str)
        rlist = curr.datab.list_regions(code,curr.usa)
        for r in rlist:
            liststore.append(r)
        self.reg_combo.set_model(liststore)
        self.reg_combo.set_active(0) 
        liststore = gtk.ListStore(str,str,str)
        loclist = curr.datab.fetch_all_from_country(code,curr.usa)
        for c in loclist:
            liststore.append(c)
        self.locview.set_model(liststore)
        self.locmodel = liststore
        self.set_country_code(code)

    def set_country_code(self,code):
        curr.country = code 

    def on_count_match(self,compl,model,iter):
        sel = unicode(model.get_value(iter,0),"utf-8")
        for r in self.country_combo.get_model():
            if r[0] == sel:
                self.country_combo.set_active_iter(r.iter)
                break

    def on_usa_toggled(self,check,cpl,lbl):
        if check.get_active():
            curr.usa = True
            lbl.set_text(_("Estado"))
        else:
            curr.usa = False
            lbl.set_text(_("Pais"))
        self.countries = curr.datab.get_states_tuple(curr.usa)
        self.sortlist = sorted(self.countries)
        model = gtk.ListStore(str,str)
        for n,c in self.sortlist:
            model.append([n,c])
        self.country_combo.set_model(model)
        cpl.set_model(model)
        for r in model:
            if r[1] == boss.opts.country:
                self.country_combo.set_active_iter(r.iter)
                break
        else:
            self.country_combo.set_active(0)

    def on_filter_toggled(self,check):
        if check.get_active():
            filtmodel = self.locmodel.filter_new()
            filtmodel.set_visible_func(filter_region, self.reg_code)
            self.locview.set_model(filtmodel)
        else:
            self.locview.set_model(self.locmodel)
        self.locview.get_selection().select_path("0")

    def on_row_activate(self,tree,path,col):
        model,iter = tree.get_selection().get_selected()
        city,code= model.get(iter,0,1)
        self.actualize_if_needed(city,code)

    def on_sel_changed(self,sel):
        model,iter = sel.get_selected()
        if not iter: return
        city,code= model.get(iter,0,1)
        for r in self.reg_combo.get_model():
            if code== r[1]:
                self.reg_combo.set_active_iter(r.iter)
                break
        self.actualize_if_needed(city,code)
        
    def actualize_if_needed(self,city,code):
        curr.setloc(city,code)
        if curr.curr_chart == curr.now:
            curr.set_now()
        if curr.curr_op == 'draw_local' or boss.mainwin.locselflag: 
            boss.da.redraw()
        else:
            active = boss.mpanel.active_slot
            curr.setchart()
            curr.act_pool(active,curr.calc)

    def set_default_local(self): 
        usa = boss.opts.usa
        usa = {'false':False,'true':True}[boss.opts.usa]
        if usa != self.check.get_active():
            self.check.set_active(usa)
            return
        self.countries = curr.datab.get_states_tuple(usa)
        self.sortlist = sorted(self.countries)
        model = gtk.ListStore(str,str)
        for n,c in self.sortlist:
            model.append([n,c])
        self.country_combo.set_model(model)
        
        for r in model:
            if r[1] == boss.opts.country:
                self.country_combo.set_active_iter(r.iter)
                break
        else:
            self.country_combo.set_active(0)
        
        liststore = gtk.ListStore(str,str,str)
        loclist = curr.datab.fetch_all_from_country(boss.opts.country,usa)
        i = 0
        for n,c in enumerate(loclist):
            liststore.append(c)
            if boss.opts.locality == c[0]:
                i = n
        self.locview.set_model(liststore)
        self.locmodel = liststore
        self.locview.set_cursor(i)
        self.locview.scroll_to_cell(i)
Ejemplo n.º 4
0
    def make_tables_selector(self): 
        vbox = gtk.VBox()        
        liststore = gtk.ListStore(str)
        tables = gtk.ComboBoxEntry(liststore)
        tables.set_size_request(182,-1)
        tables.get_children()[0].set_editable(False)
        cell = gtk.CellRendererText()

        tables.pack_start(cell)
        tablelist = curr.datab.get_databases()
        
        for c in tablelist:
            liststore.append([c])
        index = 0
        for i,r in enumerate(liststore):
            if r[0] == curr.database:
                index = i
                break 
        tables.set_active(index) 
        
        but = gtk.Button()
        img = gtk.Image()
        appath = boss.app.appath
        imgfile = path.joinpath(appath,"astronex/resources/refresh-18.png")
        img.set_from_file(str(imgfile))
        but.set_image(img)
        but.connect('clicked',self.on_refresh_clicked,tables)
        hbox = gtk.HBox()
        hbox.pack_start(tables,False,False)
        hbox.pack_start(but,False,False) 
        vbox.pack_start(hbox,False,False)

        chartmodel = gtk.ListStore(str,int)
        #chartview = gtk.TreeView(chartmodel)
        chartview = SearchView(chartmodel)
        selection = chartview.get_selection()
        selection.set_mode(gtk.SELECTION_SINGLE)
        chartlist = curr.datab.get_chartlist(tables.get_active_text())

        for c in chartlist:
            glue = ", "
            if c[2] == '':  glue = ''
            chartmodel.append([c[2]+glue+c[1],int(c[0])])
        
        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn(None,cell,text=0)
        chartview.append_column(column) 
        chartview.set_headers_visible(False)
        sel = chartview.get_selection()
        sel.set_mode(gtk.SELECTION_SINGLE)
        #sel.connect('changed',self.on_sel_changed)
        sel.select_path(0,)
        
        menu = gtk.Menu()
        menu_item = gtk.MenuItem(_('Eliminar'))
        menu.append(menu_item)
        menu_item.set_data('op','delete')
        menu_item.connect("activate", self.on_menuitem_activate,chartview)
        menu_item.show()
        menu_item = gtk.MenuItem(_('Deshacer'))
        menu.append(menu_item)
        menu_item.set_data('op','undo')
        menu_item.connect("activate", self.on_menuitem_activate,chartview)
        menu_item.show()
        chartview.connect("button_press_event", self.on_view_clicked,menu)

        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.add(chartview) 
        vbox.pack_start(sw,True,True) 
        tables.connect('changed',self.on_tables_changed,chartview)
        vbox.set_size_request(210,-1)
        
        chartview.enable_model_drag_source( gtk.gdk.BUTTON1_MASK,
                                                self.TARGETS,
                                                gtk.gdk.ACTION_COPY)
        chartview.enable_model_drag_dest(self.TARGETS, gtk.gdk.ACTION_DEFAULT)

        chartview.connect("drag_data_get", self.drag_data_get_data)
        chartview.connect("drag_data_received", self.drag_data_received_data)
        chartview.connect("row-activated", self.on_row_activated)
        self.views[chartview] = tables

        return vbox