Exemplo n.º 1
0
    def display (self, iterator):

        # clear the access table
        self.access = []

        Utils.set_cursor (self.w, 'clock')
        
        self.model.clear ()

        for entry in iterator:
            row = []

            i = 0

            for f in self.fields:
                row.append (i)
                i = i + 1
                
                if f == '-key-':
                    row.append ((str (entry.key.key)).decode ('latin-1'))
                    
                elif f == '-type-':
                    row.append (str (entry.type.name)) ## ascii
                    
                elif f == '-author/editor-':
                    row.append (userformat.author_editor_format
				(entry).decode ('latin-1'))

                elif f == '-author/title-':
                    row.append (userformat.author_title_format
				(entry).decode ('latin-1'))
                    
                elif entry.has_key (f):
                    
                    if Types.get_field (f).type == Fields.AuthorGroup:
                        text = join (map (lambda a: str (a.last), entry [f]), ', ')
                    else:
                        text = str (entry [f])
                        
                    row.append (text.decode ('latin-1'))
                else:
                    row.append ('')

	    if True:
		row.append (i)
		if Resource.is_viewable (entry):
		    row.append (self.gvpixbuf)
		else:
		    row.append (None)
	    
            iter = self.model.append  ()

            apply (self.model.set, [iter] + row)
            
            self.access.append (entry)

            entry = iterator.next ()
            
        Utils.set_cursor (self.w, 'normal')
        return
Exemplo n.º 2
0
    def update_viewables (self, entry):

	if self.viewables:
	    for item in self.viewables_id:
		self.uim.remove_ui (item)
	    self.uim.remove_action_group (self.viewables)

	self.viewables_id = []
	self.viewables = gtk.ActionGroup ('Viewables')
	self.uim.insert_action_group (self.viewables, 1)
	
	viewables = Resource.get_viewables (entry)
	for key, url, value in viewables:
## 	    text = u'<span foreground="BLUE" weight="bold">%s</span>   %s' %(
## 		key.upper (), value)
	    text = u"%s   %s" % (key.upper (), value)
	    mergeid = self.uim.new_merge_id ()
	    self.viewables_id.append (mergeid)
	    action = gtk.Action (str(mergeid), text, None, None)
	    self.viewables.add_action (action)
	    action.connect ('activate', self.view_entry, (entry, key, url, value))

	    self.uim.add_ui (mergeid, '/Menubar/ViewMenu/ViewResource', str(mergeid), 
			     str(mergeid), gtk.UI_MANAGER_MENUITEM, False)
	    self.uim.add_ui (mergeid, '/Popup/ViewResource', str(mergeid), 
			     str(mergeid), gtk.UI_MANAGER_MENUITEM, False)
	return