2007-07-17 Don Allingham <don@gramps-project.org>
* src/Editors/_EditSourceRef.py: remove text tab * src/Editors/_EditRepoRef.py: Add privacy to reporef * src/Lru.py: pylint * src/Selectors/_BaseSelector.py: set sort column * src/DbManager.py: clean up of dnd * src/glade/gramps.glade: Add privacy to reporef * src/DisplayModels/_PeopleModel.py: try to speed up sorts using mapper values * src/GrampsDbUtils/_GedcomParse.py: handle source text citations * src/GrampsDbUtils/_ReadGedcom.py: type check * src/GrampsDbUtils/_GedcomLex.py: handle broken conc * src/GrampsDbUtils/_WriteGedcom.py: handle source text citations svn: r8734
This commit is contained in:
parent
8638e1d326
commit
582c56e11e
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
||||
2007-07-17 Don Allingham <don@gramps-project.org>
|
||||
* src/Editors/_EditSourceRef.py: remove text tab
|
||||
* src/Editors/_EditRepoRef.py: Add privacy to reporef
|
||||
* src/Lru.py: pylint
|
||||
* src/Selectors/_BaseSelector.py: set sort column
|
||||
* src/DbManager.py: clean up of dnd
|
||||
* src/glade/gramps.glade: Add privacy to reporef
|
||||
* src/DisplayModels/_PeopleModel.py: try to speed up sorts using
|
||||
mapper values
|
||||
* src/GrampsDbUtils/_GedcomParse.py: handle source text citations
|
||||
* src/GrampsDbUtils/_ReadGedcom.py: type check
|
||||
* src/GrampsDbUtils/_GedcomLex.py: handle broken conc
|
||||
* src/GrampsDbUtils/_WriteGedcom.py: handle source text citations
|
||||
|
||||
2007-07-17 Alex Roitman <shura@gramps-project.org>
|
||||
* src/RelLib/_SourceRef.py (unserialize): Minor change.
|
||||
* src/RelLib/_Source.py: Remove note.
|
||||
|
2
TODO
2
TODO
@ -1,3 +1,5 @@
|
||||
* Remove GCONF, provide up grade path
|
||||
|
||||
* Replace the LPRDoc interface (based on gnome-print) with a GTK based
|
||||
print routine. This would remove one of the last gnome-specific
|
||||
libraries, and make portability better. Even more important, the
|
||||
|
@ -134,6 +134,7 @@ class DbManager:
|
||||
self.active = None
|
||||
|
||||
self.selection = self.dblist.get_selection()
|
||||
self.dblist.set_rules_hint(True)
|
||||
|
||||
self.current_names = []
|
||||
|
||||
@ -155,6 +156,8 @@ class DbManager:
|
||||
self.selection.connect('changed', self.__selection_changed)
|
||||
self.dblist.connect('button-press-event', self.__button_press)
|
||||
self.top.connect('drag_data_received', self.__drag_data_received)
|
||||
self.top.connect('drag_motion', self.__drag_motion)
|
||||
self.top.connect('drag_drop', self.__drop_cb)
|
||||
|
||||
if RCS_FOUND:
|
||||
self.rcs.connect('clicked', self.__rcs)
|
||||
@ -646,29 +649,27 @@ class DbManager:
|
||||
start_editing=True)
|
||||
return new_path
|
||||
|
||||
def __drag_motion(self, wid, context, x, y, time):
|
||||
context.drag_status(gtk.gdk.ACTION_COPY, time)
|
||||
return True
|
||||
|
||||
def __drop_cb(self, wid, context, x, y, time):
|
||||
context.finish(True, False, time)
|
||||
return True
|
||||
|
||||
def __drag_data_received(self, widget, context, xpos, ypos, selection,
|
||||
info, rtime):
|
||||
"""
|
||||
Handle the reception of drag data
|
||||
"""
|
||||
|
||||
# The selection object contains the appropriate information.
|
||||
# Unfortunately, not all file managers work the same. Nautilus
|
||||
# stores the file name as the text item in selection, while
|
||||
# thunar holds it in uris.
|
||||
|
||||
# Check for Thunar
|
||||
uris = selection.get_uris()
|
||||
|
||||
if uris: # Thunar
|
||||
drag_value = uris[0]
|
||||
elif selection.get_text(): # Nautilus
|
||||
drag_value = selection.get_text().strip()
|
||||
else:
|
||||
return True
|
||||
drag_value = selection.data
|
||||
print drag_value
|
||||
|
||||
# we are only interested in this if it is a file:// URL.
|
||||
if drag_value[0:7] == "file://":
|
||||
if drag_value and drag_value[0:7] == "file://":
|
||||
|
||||
drag_value = drag_value.strip()
|
||||
|
||||
# deterimine the mime type. If it is one that we are interested in,
|
||||
# we process it
|
||||
|
@ -332,7 +332,6 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
self.displayed = 0
|
||||
|
||||
while node:
|
||||
#for node in self.db.get_person_cursor_iter():
|
||||
self.total += 1
|
||||
handle, d = node
|
||||
if not (handle in skip or (dfilter and not dfilter.match(handle))):
|
||||
@ -458,6 +457,8 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
# return values for 'data' row, calling a function
|
||||
# according to column_defs table
|
||||
try:
|
||||
if col == 0:
|
||||
return self.mapper.sortnames[node]
|
||||
try:
|
||||
data = self.lru_data[node]
|
||||
except:
|
||||
|
@ -96,6 +96,11 @@ class EditRepoRef(EditReference):
|
||||
self.source,
|
||||
self.db.readonly)
|
||||
|
||||
self.privacy = PrivacyButton(
|
||||
self.top.get_widget("private_ref"),
|
||||
self.source_ref,
|
||||
self.db.readonly)
|
||||
|
||||
self.title = MonitoredEntry(
|
||||
self.top.get_widget('repo_name'),
|
||||
self.source.set_name,
|
||||
|
@ -165,9 +165,9 @@ class EditSourceRef(EditReference):
|
||||
self.enable_warnbox
|
||||
))
|
||||
|
||||
self.text_tab = self._add_tab(
|
||||
notebook_ref,
|
||||
TextTab(self.dbstate, self.uistate, self.track,self.source_ref))
|
||||
# self.text_tab = self._add_tab(
|
||||
# notebook_ref,
|
||||
# TextTab(self.dbstate, self.uistate, self.track,self.source_ref))
|
||||
|
||||
self.comment_tab = self._add_tab(
|
||||
notebook_ref,
|
||||
|
@ -331,10 +331,8 @@ class Reader:
|
||||
}
|
||||
|
||||
def set_broken_conc(self, broken):
|
||||
self.func_map = {
|
||||
TOKEN_CONT : self.__fix_token_cont,
|
||||
TOKEN_CONC : self.__fix_token_broken_conc,
|
||||
}
|
||||
if broken:
|
||||
self.func_map[TOKEN_CONC] = self.__fix_token_broken_conc
|
||||
|
||||
def readline(self):
|
||||
if len(self.current_list) <= 1 and not self.eof:
|
||||
|
@ -303,6 +303,7 @@ class StageOne:
|
||||
else:
|
||||
self.famc[value] = [current]
|
||||
elif key == 'CHAR' and not self.enc:
|
||||
assert(type(value) == str or type(value) == unicode)
|
||||
self.enc = value
|
||||
|
||||
def get_famc_map(self):
|
||||
@ -315,6 +316,7 @@ class StageOne:
|
||||
return self.enc.upper()
|
||||
|
||||
def set_encoding(self, enc):
|
||||
assert(type(enc) == str or type(enc) == unicode)
|
||||
self.enc = enc
|
||||
|
||||
def get_person_count(self):
|
||||
@ -3474,7 +3476,14 @@ class GedcomParser(UpdateCallback):
|
||||
state.src_ref.set_date_object(line.data)
|
||||
|
||||
def __source_data_text(self, line, state):
|
||||
state.src_ref.set_text(line.data)
|
||||
note = RelLib.Note()
|
||||
note.set(line.data)
|
||||
gramps_id = self.dbase.find_next_note_gramps_id()
|
||||
note.set_gramps_id(gramps_id)
|
||||
note.set_type(RelLib.NoteType.SOURCE_TEXT)
|
||||
self.dbase.add_note(note, self.trans)
|
||||
|
||||
state.src_ref.add_note(note.get_handle())
|
||||
|
||||
def __source_data_note(self, line, state):
|
||||
self.__parse_note(line, state.src_ref, state.level)
|
||||
|
@ -63,12 +63,15 @@ def importData(database, filename, callback=None, use_trans=False):
|
||||
code_set = code.get_active()
|
||||
dialog.destroy()
|
||||
else:
|
||||
code_set = None
|
||||
code_set = ""
|
||||
|
||||
import2(database, filename, callback, code_set, use_trans)
|
||||
|
||||
def import2(database, filename, callback, code_set, use_trans):
|
||||
# add some checking here
|
||||
|
||||
assert(type(code_set) == str or type(code_set) == unicode)
|
||||
|
||||
try:
|
||||
ifile = open(filename,"rU")
|
||||
np = StageOne(ifile)
|
||||
|
@ -1396,6 +1396,8 @@ class GedcomWriter(UpdateCallback):
|
||||
|
||||
self.slist.add(src_handle)
|
||||
|
||||
already_printed = None
|
||||
|
||||
if self.source_refs:
|
||||
# Reference to the source
|
||||
self.writeln("%d SOUR @%s@" % (level,src.get_gramps_id()))
|
||||
@ -1409,13 +1411,25 @@ class GedcomWriter(UpdateCallback):
|
||||
if conf != RelLib.SourceRef.CONF_NORMAL and conf != -1:
|
||||
self.write_long_text("QUAY",level+1, str(quay_map[conf]))
|
||||
|
||||
ref_text = ref.get_text()
|
||||
if ref_text != "" or not ref.get_date_object().is_empty():
|
||||
self.writeln('%d DATA' % (level+1))
|
||||
if ref_text != "":
|
||||
self.write_long_text("TEXT",level+2,self.cnvtxt(ref_text))
|
||||
pfx = "%d DATE" % (level+2)
|
||||
self.print_date(pfx,ref.get_date_object())
|
||||
if len(ref.get_note_list()) > 0:
|
||||
|
||||
note_list = [ self.db.get_note_from_handle(h) for h in ref.get_note_list() ]
|
||||
note_list = [ n for n in note_list
|
||||
if n.get_type() == RelLib.NoteType.SOURCE_TEXT]
|
||||
|
||||
if note_list:
|
||||
ref_text = note_list[0].get()
|
||||
already_printed = note_list[0].get_handle()
|
||||
else:
|
||||
ref_text = ""
|
||||
|
||||
if ref_text != "" or not ref.get_date_object().is_empty():
|
||||
self.writeln('%d DATA' % (level+1))
|
||||
if ref_text != "":
|
||||
self.write_long_text("TEXT",level+2,self.cnvtxt(ref_text))
|
||||
pfx = "%d DATE" % (level+2)
|
||||
self.print_date(pfx,ref.get_date_object())
|
||||
|
||||
else:
|
||||
# Inline source
|
||||
|
||||
@ -1436,7 +1450,8 @@ class GedcomWriter(UpdateCallback):
|
||||
self.write_long_text("TEXT",level+1,self.cnvtxt(ref_text))
|
||||
|
||||
for notehandle in ref.get_note_list():
|
||||
self.write_note(level+1,notehandle)
|
||||
if notehandle != already_printed:
|
||||
self.write_note(level+1,notehandle)
|
||||
|
||||
def write_photo(self,photo,level):
|
||||
photo_obj_id = photo.get_reference_handle()
|
||||
|
38
src/Lru.py
38
src/Lru.py
@ -25,9 +25,9 @@ class Node:
|
||||
"""
|
||||
Node to be stored in the LRU structure
|
||||
"""
|
||||
def __init__(self, prev, me):
|
||||
def __init__(self, prev, value):
|
||||
self.prev = prev
|
||||
self.me = me
|
||||
self.value = value
|
||||
self.next = None
|
||||
|
||||
class LRU:
|
||||
@ -36,7 +36,7 @@ class LRU:
|
||||
"""
|
||||
def __init__(self, count):
|
||||
self.count = max(count, 2)
|
||||
self.d = {}
|
||||
self.data = {}
|
||||
self.first = None
|
||||
self.last = None
|
||||
|
||||
@ -44,19 +44,19 @@ class LRU:
|
||||
"""
|
||||
Returns True if the object is contained in the LRU
|
||||
"""
|
||||
return obj in self.d
|
||||
return obj in self.data
|
||||
|
||||
def __getitem__(self, obj):
|
||||
"""
|
||||
Returns item assocated with Obj
|
||||
"""
|
||||
return self.d[obj].me[1]
|
||||
return self.data[obj].value[1]
|
||||
|
||||
def __setitem__(self, obj, val):
|
||||
"""
|
||||
Sets the item in the LRU, removing an old entry if needed
|
||||
"""
|
||||
if obj in self.d:
|
||||
if obj in self.data:
|
||||
del self[obj]
|
||||
nobj = Node(self.last, (obj, val))
|
||||
if self.first is None:
|
||||
@ -64,24 +64,24 @@ class LRU:
|
||||
if self.last:
|
||||
self.last.next = nobj
|
||||
self.last = nobj
|
||||
self.d[obj] = nobj
|
||||
if len(self.d) > self.count:
|
||||
self.data[obj] = nobj
|
||||
if len(self.data) > self.count:
|
||||
if self.first == self.last:
|
||||
self.first = None
|
||||
self.last = None
|
||||
return
|
||||
a = self.first
|
||||
a.next.prev = None
|
||||
self.first = a.next
|
||||
a.next = None
|
||||
del self.d[a.me[0]]
|
||||
del a
|
||||
lnk = self.first
|
||||
lnk.next.prev = None
|
||||
self.first = lnk.next
|
||||
lnk.next = None
|
||||
del self.data[lnk.value[0]]
|
||||
del lnk
|
||||
|
||||
def __delitem__(self, obj):
|
||||
"""
|
||||
Delete the object from the LRU
|
||||
"""
|
||||
nobj = self.d[obj]
|
||||
nobj = self.data[obj]
|
||||
if nobj.prev:
|
||||
nobj.prev.next = nobj.next
|
||||
else:
|
||||
@ -90,7 +90,7 @@ class LRU:
|
||||
nobj.next.prev = nobj.prev
|
||||
else:
|
||||
self.last = nobj.prev
|
||||
del self.d[obj]
|
||||
del self.data[obj]
|
||||
|
||||
def __iter__(self):
|
||||
"""
|
||||
@ -99,7 +99,7 @@ class LRU:
|
||||
cur = self.first
|
||||
while cur != None:
|
||||
cur2 = cur.next
|
||||
yield cur.me[1]
|
||||
yield cur.value[1]
|
||||
cur = cur2
|
||||
raise StopIteration
|
||||
|
||||
@ -110,7 +110,7 @@ class LRU:
|
||||
cur = self.first
|
||||
while cur != None:
|
||||
cur2 = cur.next
|
||||
yield cur.me
|
||||
yield cur.value
|
||||
cur = cur2
|
||||
raise StopIteration
|
||||
|
||||
@ -118,7 +118,7 @@ class LRU:
|
||||
"""
|
||||
Return keys in the LRU using a generator
|
||||
"""
|
||||
return iter(self.d)
|
||||
return iter(self.data)
|
||||
|
||||
def itervalues(self):
|
||||
"""
|
||||
|
@ -86,6 +86,7 @@ class BaseSelector(ManagedWindow.ManagedWindow):
|
||||
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
|
||||
column.set_fixed_width(item[1])
|
||||
column.set_resizable(True)
|
||||
column.set_sort_column_id(ix)
|
||||
tree.append_column(column)
|
||||
|
||||
def build_menu_names(self,obj):
|
||||
|
@ -2360,7 +2360,7 @@
|
||||
<property name="rules_hint">True</property>
|
||||
<property name="reorderable">False</property>
|
||||
<property name="enable_search">True</property>
|
||||
<property name="fixed_height_mode">False</property>
|
||||
<property name="fixed_height_mode">True</property>
|
||||
<property name="hover_selection">False</property>
|
||||
<property name="hover_expand">False</property>
|
||||
</widget>
|
||||
@ -12105,11 +12105,42 @@ Very High</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="bottom_attach">1</property>
|
||||
<property name="y_options">fill</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkToggleButton" id="private_ref">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Indicates if the record is private</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NONE</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image2720">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon_size">4</property>
|
||||
<property name="icon_name">gramps-unlock</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="bottom_attach">1</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options">fill</property>
|
||||
<property name="x_options">shrink</property>
|
||||
<property name="y_options">shrink</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user