From 582c56e11e53156778c3ccd75bfa1d78c981a62d Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Wed, 18 Jul 2007 04:17:30 +0000 Subject: [PATCH] 2007-07-17 Don Allingham * 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 --- ChangeLog | 14 ++++++++++++ TODO | 2 ++ src/DbManager.py | 31 +++++++++++++------------ src/DisplayModels/_PeopleModel.py | 3 ++- src/Editors/_EditRepoRef.py | 5 ++++ src/Editors/_EditSourceRef.py | 6 ++--- src/GrampsDbUtils/_GedcomLex.py | 6 ++--- src/GrampsDbUtils/_GedcomParse.py | 11 ++++++++- src/GrampsDbUtils/_ReadGedcom.py | 5 +++- src/GrampsDbUtils/_WriteGedcom.py | 31 ++++++++++++++++++------- src/Lru.py | 38 +++++++++++++++---------------- src/Selectors/_BaseSelector.py | 1 + src/glade/gramps.glade | 37 +++++++++++++++++++++++++++--- 13 files changed, 135 insertions(+), 55 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5e9398430..979cbead9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2007-07-17 Don Allingham + * 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 * src/RelLib/_SourceRef.py (unserialize): Minor change. * src/RelLib/_Source.py: Remove note. diff --git a/TODO b/TODO index 5c5de4fda..707dc692d 100644 --- a/TODO +++ b/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 diff --git a/src/DbManager.py b/src/DbManager.py index 625390a0c..7838747a6 100644 --- a/src/DbManager.py +++ b/src/DbManager.py @@ -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 diff --git a/src/DisplayModels/_PeopleModel.py b/src/DisplayModels/_PeopleModel.py index c47ec3be5..b5c675ece 100644 --- a/src/DisplayModels/_PeopleModel.py +++ b/src/DisplayModels/_PeopleModel.py @@ -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: diff --git a/src/Editors/_EditRepoRef.py b/src/Editors/_EditRepoRef.py index e91ca8d35..3291726e0 100644 --- a/src/Editors/_EditRepoRef.py +++ b/src/Editors/_EditRepoRef.py @@ -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, diff --git a/src/Editors/_EditSourceRef.py b/src/Editors/_EditSourceRef.py index eebdb3550..64fd947a5 100644 --- a/src/Editors/_EditSourceRef.py +++ b/src/Editors/_EditSourceRef.py @@ -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, diff --git a/src/GrampsDbUtils/_GedcomLex.py b/src/GrampsDbUtils/_GedcomLex.py index 47ffda9ae..dc2d0ba64 100644 --- a/src/GrampsDbUtils/_GedcomLex.py +++ b/src/GrampsDbUtils/_GedcomLex.py @@ -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: diff --git a/src/GrampsDbUtils/_GedcomParse.py b/src/GrampsDbUtils/_GedcomParse.py index 227f2aceb..cf8d6b60e 100644 --- a/src/GrampsDbUtils/_GedcomParse.py +++ b/src/GrampsDbUtils/_GedcomParse.py @@ -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) diff --git a/src/GrampsDbUtils/_ReadGedcom.py b/src/GrampsDbUtils/_ReadGedcom.py index ee8f37fc9..5a3c4287f 100644 --- a/src/GrampsDbUtils/_ReadGedcom.py +++ b/src/GrampsDbUtils/_ReadGedcom.py @@ -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) diff --git a/src/GrampsDbUtils/_WriteGedcom.py b/src/GrampsDbUtils/_WriteGedcom.py index 7346f99ce..df3221269 100644 --- a/src/GrampsDbUtils/_WriteGedcom.py +++ b/src/GrampsDbUtils/_WriteGedcom.py @@ -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() diff --git a/src/Lru.py b/src/Lru.py index 481a6710e..83c5f3dba 100644 --- a/src/Lru.py +++ b/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): """ diff --git a/src/Selectors/_BaseSelector.py b/src/Selectors/_BaseSelector.py index 0f2199068..38a3c429e 100644 --- a/src/Selectors/_BaseSelector.py +++ b/src/Selectors/_BaseSelector.py @@ -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): diff --git a/src/glade/gramps.glade b/src/glade/gramps.glade index f64ffd646..2b4ce5185 100644 --- a/src/glade/gramps.glade +++ b/src/glade/gramps.glade @@ -2360,7 +2360,7 @@ True False True - False + True False False @@ -12105,11 +12105,42 @@ Very High 1 + 2 + 0 + 1 + fill + + + + + + True + Indicates if the record is private + True + GTK_RELIEF_NONE + True + False + False + + + + True + 4 + gramps-unlock + 0.5 + 0.5 + 0 + 0 + + + + + 2 3 0 1 - fill - fill + shrink + shrink