* src/Bookmarks.py: pylint fixes
* src/ColumnOrder.py: pylint fixes * src/DateEdit.py: pylint fixes * src/DbLoader.py: pylint fixes * src/ManagedWindow.py: pylint fixes 2007-05-19 Don Allingham <don@gramps-project.org> svn: r8498
This commit is contained in:
123
src/Bookmarks.py
123
src/Bookmarks.py
@@ -89,18 +89,34 @@ class Bookmarks :
|
||||
self.dbstate.connect('database-changed', self.db_changed)
|
||||
|
||||
def db_changed(self, data):
|
||||
"""
|
||||
Reconnect the signals on a database changed.
|
||||
"""
|
||||
self.connect_signals()
|
||||
|
||||
def connect_signals(self):
|
||||
"""
|
||||
Connect the person-delete signal
|
||||
"""
|
||||
self.dbstate.db.connect('person-delete', self.remove_handles)
|
||||
|
||||
def update_bookmarks(self, bookmarks):
|
||||
"""
|
||||
Assign bookmarks
|
||||
"""
|
||||
self.bookmarks = bookmarks
|
||||
|
||||
def display(self):
|
||||
"""
|
||||
|
||||
Redraw teh display
|
||||
"""
|
||||
self.redraw()
|
||||
|
||||
def undisplay(self):
|
||||
"""
|
||||
Update the uimanager
|
||||
"""
|
||||
if self.active != DISABLED:
|
||||
self.uistate.uimanager.remove_ui(self.active)
|
||||
self.uistate.uimanager.remove_action_group(self.action_group)
|
||||
@@ -108,8 +124,8 @@ class Bookmarks :
|
||||
|
||||
def redraw(self):
|
||||
"""Create the pulldown menu"""
|
||||
f = StringIO()
|
||||
f.write(_top)
|
||||
text = StringIO()
|
||||
text.write(_top)
|
||||
|
||||
self.undisplay()
|
||||
|
||||
@@ -117,7 +133,7 @@ class Bookmarks :
|
||||
count = 0
|
||||
|
||||
if len(self.bookmarks.get()) > 0:
|
||||
f.write('<placeholder name="GoToBook">')
|
||||
text.write('<placeholder name="GoToBook">')
|
||||
|
||||
new_list = []
|
||||
for item in self.bookmarks.get():
|
||||
@@ -125,26 +141,26 @@ class Bookmarks :
|
||||
label, obj = self.make_label(item)
|
||||
func = self.callback(item)
|
||||
action_id = "BM:%s" % item
|
||||
actions.append((action_id,None,label,None,None,func))
|
||||
f.write('<menuitem action="%s"/>' % action_id)
|
||||
count +=1
|
||||
actions.append((action_id, None, label, None, None, func))
|
||||
text.write('<menuitem action="%s"/>' % action_id)
|
||||
count += 1
|
||||
new_list.append(item)
|
||||
except AttributeError:
|
||||
pass
|
||||
f.write('</placeholder>')
|
||||
text.write('</placeholder>')
|
||||
self.bookmarks.set(new_list)
|
||||
|
||||
f.write(_btm)
|
||||
text.write(_btm)
|
||||
self.action_group.add_actions(actions)
|
||||
self.uistate.uimanager.insert_action_group(self.action_group,1)
|
||||
self.active = self.uistate.uimanager.add_ui_from_string(f.getvalue())
|
||||
self.uistate.uimanager.insert_action_group(self.action_group, 1)
|
||||
self.active = self.uistate.uimanager.add_ui_from_string(text.getvalue())
|
||||
self.uistate.uimanager.ensure_update()
|
||||
f.close()
|
||||
text.close()
|
||||
|
||||
def make_label(self,handle):
|
||||
def make_label(self, handle):
|
||||
person = self.dbstate.db.get_person_from_handle(handle)
|
||||
name = NameDisplay.displayer.display(person)
|
||||
return ("%s [%s]" % (name,person.gramps_id), person)
|
||||
return ("%s [%s]" % (name, person.gramps_id), person)
|
||||
|
||||
def callback(self, handle):
|
||||
return make_callback(handle, self.dbstate.change_active_handle)
|
||||
@@ -175,25 +191,25 @@ class Bookmarks :
|
||||
"""Draws the bookmark dialog box"""
|
||||
title = "%s - GRAMPS" % _("Edit Bookmarks")
|
||||
self.top = gtk.Dialog(title)
|
||||
self.top.set_default_size(400,350)
|
||||
self.top.set_default_size(400, 350)
|
||||
self.top.set_has_separator(False)
|
||||
self.top.vbox.set_spacing(5)
|
||||
label = gtk.Label('<span size="larger" weight="bold">%s</span>'
|
||||
% _("Edit Bookmarks"))
|
||||
label.set_use_markup(True)
|
||||
self.top.vbox.pack_start(label,0,0,5)
|
||||
self.top.vbox.pack_start(label, 0, 0, 5)
|
||||
box = gtk.HBox()
|
||||
self.top.vbox.pack_start(box,1,1,5)
|
||||
self.top.vbox.pack_start(box, 1, 1, 5)
|
||||
|
||||
name_titles = [(_('Name'),-1,200),(_('ID'),-1,50),('',-1,0)]
|
||||
name_titles = [(_('Name'), -1, 200), (_('ID'), -1, 50), ('', -1, 0)]
|
||||
self.namelist = gtk.TreeView()
|
||||
self.namemodel = ListModel.ListModel(self.namelist,name_titles)
|
||||
self.namemodel = ListModel.ListModel(self.namelist, name_titles)
|
||||
self.namemodel_cols = len(name_titles)
|
||||
|
||||
slist = gtk.ScrolledWindow()
|
||||
slist.add_with_viewport(self.namelist)
|
||||
slist.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
box.pack_start(slist,1,1,5)
|
||||
box.pack_start(slist, 1, 1, 5)
|
||||
bbox = gtk.VButtonBox()
|
||||
bbox.set_layout(gtk.BUTTONBOX_START)
|
||||
bbox.set_spacing(6)
|
||||
@@ -201,14 +217,14 @@ class Bookmarks :
|
||||
down = gtk.Button(stock=gtk.STOCK_GO_DOWN)
|
||||
delete = gtk.Button(stock=gtk.STOCK_REMOVE)
|
||||
up.connect('clicked', self.up_clicked)
|
||||
down.connect('clicked',self.down_clicked)
|
||||
delete.connect('clicked',self.delete_clicked)
|
||||
self.top.add_button(gtk.STOCK_CLOSE,gtk.RESPONSE_CLOSE)
|
||||
self.top.add_button(gtk.STOCK_HELP,gtk.RESPONSE_HELP)
|
||||
down.connect('clicked', self.down_clicked)
|
||||
delete.connect('clicked', self.delete_clicked)
|
||||
self.top.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
|
||||
self.top.add_button(gtk.STOCK_HELP, gtk.RESPONSE_HELP)
|
||||
bbox.add(up)
|
||||
bbox.add(down)
|
||||
bbox.add(delete)
|
||||
box.pack_start(bbox,0,0,5)
|
||||
box.pack_start(bbox, 0, 0, 5)
|
||||
self.top.show_all()
|
||||
|
||||
def edit(self):
|
||||
@@ -225,7 +241,7 @@ class Bookmarks :
|
||||
name, obj = self.make_label(handle)
|
||||
if obj:
|
||||
gramps_id = obj.get_gramps_id()
|
||||
self.namemodel.add([name,gramps_id,handle])
|
||||
self.namemodel.add([name, gramps_id, handle])
|
||||
self.namemodel.connect_model()
|
||||
|
||||
self.modified = False
|
||||
@@ -236,9 +252,9 @@ class Bookmarks :
|
||||
self.redraw()
|
||||
self.top.destroy()
|
||||
|
||||
def delete_clicked(self,obj):
|
||||
def delete_clicked(self, obj):
|
||||
"""Removes the current selection from the list"""
|
||||
store,the_iter = self.namemodel.get_selected()
|
||||
store, the_iter = self.namemodel.get_selected()
|
||||
if not the_iter:
|
||||
return
|
||||
row = self.namemodel.get_selected_row()
|
||||
@@ -246,30 +262,30 @@ class Bookmarks :
|
||||
self.namemodel.remove(the_iter)
|
||||
self.modified = True
|
||||
|
||||
def up_clicked(self,obj):
|
||||
def up_clicked(self, obj):
|
||||
"""Moves the current selection up one row"""
|
||||
row = self.namemodel.get_selected_row()
|
||||
if not row or row == -1:
|
||||
return
|
||||
store,the_iter = self.namemodel.get_selected()
|
||||
data = self.namemodel.get_data(the_iter,range(self.namemodel_cols))
|
||||
store, the_iter = self.namemodel.get_selected()
|
||||
data = self.namemodel.get_data(the_iter, range(self.namemodel_cols))
|
||||
self.namemodel.remove(the_iter)
|
||||
self.namemodel.insert(row-1,data,None,1)
|
||||
self.namemodel.insert(row-1, data, None, 1)
|
||||
handle = self.bookmarks.pop(row)
|
||||
self.bookmarks.insert(row-1,handle)
|
||||
self.bookmarks.insert(row-1, handle)
|
||||
self.modified = True
|
||||
|
||||
def down_clicked(self,obj):
|
||||
def down_clicked(self, obj):
|
||||
"""Moves the current selection down one row"""
|
||||
row = self.namemodel.get_selected_row()
|
||||
if row + 1 >= self.namemodel.count or row == -1:
|
||||
return
|
||||
store,the_iter = self.namemodel.get_selected()
|
||||
data = self.namemodel.get_data(the_iter,range(self.namemodel_cols))
|
||||
store, the_iter = self.namemodel.get_selected()
|
||||
data = self.namemodel.get_data(the_iter, range(self.namemodel_cols))
|
||||
self.namemodel.remove(the_iter)
|
||||
self.namemodel.insert(row+1,data,None,1)
|
||||
self.namemodel.insert(row+1, data, None, 1)
|
||||
handle = self.bookmarks.pop(row)
|
||||
self.bookmarks.insert(row+1,handle)
|
||||
self.bookmarks.insert(row+1, handle)
|
||||
self.modified = True
|
||||
|
||||
def help_clicked(self):
|
||||
@@ -279,7 +295,7 @@ class Bookmarks :
|
||||
|
||||
class ListBookmarks(Bookmarks):
|
||||
|
||||
def __init__(self,dbstate,uistate,bookmarks, goto_handle):
|
||||
def __init__(self, dbstate, uistate, bookmarks, goto_handle):
|
||||
self.goto_handle = goto_handle
|
||||
Bookmarks.__init__(self, dbstate, uistate, bookmarks)
|
||||
|
||||
@@ -289,15 +305,14 @@ class ListBookmarks(Bookmarks):
|
||||
def do_callback(self, handle):
|
||||
self.goto_handle(handle)
|
||||
|
||||
|
||||
class FamilyBookmarks(ListBookmarks) :
|
||||
"Handle the bookmarks interface for Gramps"
|
||||
|
||||
def __init__(self,dbstate,uistate,bookmarks, goto_handle):
|
||||
def __init__(self, dbstate, uistate, bookmarks, goto_handle):
|
||||
ListBookmarks.__init__(self, dbstate, uistate, bookmarks,
|
||||
goto_handle)
|
||||
|
||||
def make_label(self,handle):
|
||||
def make_label(self, handle):
|
||||
obj = self.dbstate.db.get_family_from_handle(handle)
|
||||
name = Utils.family_name(obj, self.dbstate.db)
|
||||
return ("%s [%s]" % (name, obj.gramps_id), obj)
|
||||
@@ -308,11 +323,11 @@ class FamilyBookmarks(ListBookmarks) :
|
||||
class EventBookmarks(ListBookmarks) :
|
||||
"Handle the bookmarks interface for Gramps"
|
||||
|
||||
def __init__(self,dbstate,uistate,bookmarks, goto_handle):
|
||||
def __init__(self, dbstate, uistate, bookmarks, goto_handle):
|
||||
ListBookmarks.__init__(self, dbstate, uistate, bookmarks,
|
||||
goto_handle)
|
||||
|
||||
def make_label(self,handle):
|
||||
def make_label(self, handle):
|
||||
obj = self.dbstate.db.get_event_from_handle(handle)
|
||||
if obj.get_description() == "":
|
||||
name = str(obj.get_type())
|
||||
@@ -325,11 +340,11 @@ class EventBookmarks(ListBookmarks) :
|
||||
|
||||
class SourceBookmarks(ListBookmarks) :
|
||||
"Handle the bookmarks interface for Gramps"
|
||||
def __init__(self,dbstate,uistate,bookmarks, goto_handle):
|
||||
def __init__(self, dbstate, uistate, bookmarks, goto_handle):
|
||||
ListBookmarks.__init__(self, dbstate, uistate, bookmarks,
|
||||
goto_handle)
|
||||
|
||||
def make_label(self,handle):
|
||||
def make_label(self, handle):
|
||||
obj = self.dbstate.db.get_source_from_handle(handle)
|
||||
name = obj.get_title()
|
||||
return ("%s [%s]" % (name, obj.gramps_id), obj)
|
||||
@@ -340,11 +355,11 @@ class SourceBookmarks(ListBookmarks) :
|
||||
class MediaBookmarks(ListBookmarks) :
|
||||
"Handle the bookmarks interface for Gramps"
|
||||
|
||||
def __init__(self,dbstate,uistate,bookmarks, goto_handle):
|
||||
def __init__(self, dbstate, uistate, bookmarks, goto_handle):
|
||||
ListBookmarks.__init__(self, dbstate, uistate, bookmarks,
|
||||
goto_handle)
|
||||
|
||||
def make_label(self,handle):
|
||||
def make_label(self, handle):
|
||||
obj = self.dbstate.db.get_object_from_handle(handle)
|
||||
name = obj.get_description()
|
||||
return ("%s [%s]" % (name, obj.gramps_id), obj)
|
||||
@@ -355,11 +370,11 @@ class MediaBookmarks(ListBookmarks) :
|
||||
class RepoBookmarks(ListBookmarks) :
|
||||
"Handle the bookmarks interface for Gramps"
|
||||
|
||||
def __init__(self,dbstate,uistate,bookmarks, goto_handle):
|
||||
def __init__(self, dbstate, uistate, bookmarks, goto_handle):
|
||||
ListBookmarks.__init__(self, dbstate, uistate, bookmarks,
|
||||
goto_handle)
|
||||
|
||||
def make_label(self,handle):
|
||||
def make_label(self, handle):
|
||||
obj = self.dbstate.db.get_repository_from_handle(handle)
|
||||
name = obj.get_name()
|
||||
return ("%s [%s]" % (name, obj.gramps_id), obj)
|
||||
@@ -370,11 +385,11 @@ class RepoBookmarks(ListBookmarks) :
|
||||
class PlaceBookmarks(ListBookmarks) :
|
||||
"Handle the bookmarks interface for Gramps"
|
||||
|
||||
def __init__(self,dbstate,uistate,bookmarks, goto_handle):
|
||||
def __init__(self, dbstate, uistate, bookmarks, goto_handle):
|
||||
ListBookmarks.__init__(self, dbstate, uistate, bookmarks,
|
||||
goto_handle)
|
||||
|
||||
def make_label(self,handle):
|
||||
def make_label(self, handle):
|
||||
obj = self.dbstate.db.get_place_from_handle(handle)
|
||||
name = obj.get_title()
|
||||
return ("%s [%s]" % (name, obj.gramps_id), obj)
|
||||
@@ -385,11 +400,11 @@ class PlaceBookmarks(ListBookmarks) :
|
||||
class NoteBookmarks(ListBookmarks) :
|
||||
"Handle the bookmarks interface for Gramps"
|
||||
|
||||
def __init__(self,dbstate,uistate,bookmarks, goto_handle):
|
||||
def __init__(self, dbstate, uistate, bookmarks, goto_handle):
|
||||
ListBookmarks.__init__(self, dbstate, uistate, bookmarks,
|
||||
goto_handle)
|
||||
|
||||
def make_label(self,handle):
|
||||
def make_label(self, handle):
|
||||
obj = self.dbstate.db.get_note_from_handle(handle)
|
||||
name = obj.get().replace('\n', ' ')
|
||||
if len(name) > 40:
|
||||
@@ -399,5 +414,5 @@ class NoteBookmarks(ListBookmarks) :
|
||||
def connect_signals(self):
|
||||
self.dbstate.db.connect('note-delete', self.remove_handles)
|
||||
|
||||
def make_callback(n,f):
|
||||
def make_callback(n, f):
|
||||
return lambda x: f(n)
|
||||
|
Reference in New Issue
Block a user