From 59d53915b98df05840b7aa1310db9370dc731c24 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Fri, 31 Aug 2001 03:40:23 +0000 Subject: [PATCH] Elimination of redundant code, new registering method for plugins svn: r367 --- src/Bookmarks.py | 89 +-- src/Config.py | 3 +- src/EditPerson.py | 938 ++++++++++--------------------- src/EditPlace.py | 257 ++------- src/EditSource.py | 89 +-- src/Filter.py | 72 ++- src/FindDoc.py | 2 +- src/FontScale.py | 432 +++++++------- src/GrampsParser.py | 1 - src/LaTeXDoc.py | 28 +- src/Marriage.py | 335 +++-------- src/Plugins.py | 379 +++++++------ src/ReadXML.py | 13 +- src/RelImage.py | 8 +- src/RelLib.py | 64 ++- src/StyleEditor.py | 27 +- src/WriteXML.py | 7 - src/filters/After.py | 25 +- src/filters/AltFam.py | 9 +- src/filters/Before.py | 20 +- src/filters/Disconnected.py | 15 +- src/filters/EventPlace.py | 16 +- src/filters/EventType.py | 16 +- src/filters/Females.py | 16 +- src/filters/HavePhotos.py | 15 +- src/filters/IncompleteNames.py | 16 +- src/filters/Males.py | 15 +- src/filters/MatchSndEx.py | 16 +- src/filters/MatchSndEx2.py | 16 +- src/filters/MutlipleMarriages.py | 16 +- src/filters/NeverMarried.py | 15 +- src/filters/NoBirthdate.py | 17 +- src/filters/NoChildren.py | 16 +- src/filters/RegExMatch.py | 19 +- src/filters/SubString.py | 15 +- src/gramps_main.py | 727 ++++++++++-------------- src/plugins/AncestorChart.py | 38 +- src/plugins/AncestorReport.py | 27 +- src/plugins/ChangeTypes.py | 17 +- src/plugins/Check.py | 24 +- src/plugins/Desbrowser.py | 22 +- src/plugins/DescendReport.py | 32 +- src/plugins/EventCmp.py | 28 +- src/plugins/FamilyGroup.py | 27 +- src/plugins/GraphViz.py | 16 +- src/plugins/HtmlReport.py | 13 +- src/plugins/IndivSummary.py | 11 +- src/plugins/Merge.py | 26 +- src/plugins/PatchNames.py | 25 +- src/plugins/ReadGedcom.py | 26 +- src/plugins/ReadNative.py | 12 +- src/plugins/RelCalc.py | 13 +- src/plugins/ReorderIds.py | 12 +- src/plugins/Summary.py | 11 +- src/plugins/WebPage.py | 23 +- src/plugins/WriteGedcom.py | 10 +- src/plugins/count_anc.py | 11 +- src/plugins/soundgen.py | 18 +- src/utils.py | 184 +++++- 59 files changed, 1872 insertions(+), 2518 deletions(-) diff --git a/src/Bookmarks.py b/src/Bookmarks.py index 314cb5785..1fd063253 100644 --- a/src/Bookmarks.py +++ b/src/Bookmarks.py @@ -49,7 +49,8 @@ NAMEINST = "namelist" #------------------------------------------------------------------------- # -# +# Interface to gramps' bookmarks. Handles building the bookmarks menu +# for the main window, and provides the bookmark editor. # #------------------------------------------------------------------------- class Bookmarks : @@ -59,9 +60,13 @@ class Bookmarks : # # __init__ - Creates a the bookmark editor # + # arguments are: + # bookmarks - list of People + # menu - parent menu to attach users + # callback - task to connect to the menu item as a callback + # #--------------------------------------------------------------------- - def __init__(self,bookmarks,map,menu,callback): - self.map = map + def __init__(self,bookmarks,menu,callback): self.menu = menu self.bookmarks = bookmarks self.callback = callback @@ -69,17 +74,14 @@ class Bookmarks : #--------------------------------------------------------------------- # - # + # redraw - (re)create the pulldown menu # #--------------------------------------------------------------------- def redraw(self): if len(self.bookmarks) > 0: self.myMenu = gtk.GtkMenu() for person in self.bookmarks: - item = gtk.GtkMenuItem(person.getPrimaryName().getName()) - item.show() - item.connect("activate", self.callback , person) - self.myMenu.append(item) + self.add_to_menu(person) self.menu.set_submenu(self.myMenu) self.menu.set_sensitive(1) else: @@ -88,33 +90,43 @@ class Bookmarks : #--------------------------------------------------------------------- # - # + # add - adds the person to the bookmarks, appended to the botom # #--------------------------------------------------------------------- def add(self,person): if person not in self.bookmarks: utils.modified() self.bookmarks.append(person) - item = gtk.GtkMenuItem(person.getPrimaryName().getName()) - item.show() - item.connect("activate", self.callback, person) - self.redraw() + self.add_to_menu(person) #--------------------------------------------------------------------- # + # add_to_menu - adds a person's name to the drop down menu # + #--------------------------------------------------------------------- + def add_to_menu(person): + item = gtk.GtkMenuItem(person.getPrimaryName().getName()) + item.connect("activate", self.callback, person) + item.show() + self.myMenu.append(item) + + #--------------------------------------------------------------------- + # + # edit - display the bookmark editor. + # + # The current bookmarked people are inserted into the namelist, + # attaching the person object to the corresponding row. The currently + # selected row is attached to the name list. This is either 0 if the + # list is not empty, or -1 if it is. # #--------------------------------------------------------------------- def edit(self): - top = libglade.GladeXML(const.bookFile,TOPINST) namelist = top.get_widget(NAMEINST) - - namelist.clear() self.index = 0 - for val in self.bookmarks: - namelist.append([val.getPrimaryName().getName()]) - namelist.set_row_data(self.index,val) + for person in self.bookmarks: + namelist.append([person.getPrimaryName().getName()]) + namelist.set_row_data(self.index,person) self.index = self.index + 1 if self.index > 0: @@ -137,11 +149,11 @@ class Bookmarks : topBox.set_data(OBJECT,self) topBox.set_data(NAMEINST,namelist) topBox.show() - self.redraw() #------------------------------------------------------------------------- # -# +# on_namelist_select_row - changes the selected row stored on the namelist +# to the row that was just selected. # #------------------------------------------------------------------------- def on_namelist_select_row(obj,row,junk,junk2): @@ -149,7 +161,10 @@ def on_namelist_select_row(obj,row,junk,junk2): #------------------------------------------------------------------------- # -# +# on_delete_clicked - gets the selected row and number of rows that have +# been attached to the namelist. If the selected row is greater than 0, +# then the row is deleted from the list. The number of rows is then +# decremented. # #------------------------------------------------------------------------- def on_delete_clicked(obj): @@ -165,7 +180,7 @@ def on_delete_clicked(obj): #------------------------------------------------------------------------- # -# +# on_up_clicked - swap rows if the selected row is greater than 0 # #------------------------------------------------------------------------- def on_up_clicked(obj): @@ -176,7 +191,7 @@ def on_up_clicked(obj): #------------------------------------------------------------------------- # -# +# on_down_clicked - swap rows if the selected index is not the last index # #------------------------------------------------------------------------- def on_down_clicked(obj): @@ -188,31 +203,27 @@ def on_down_clicked(obj): #------------------------------------------------------------------------- # -# +# on_ok_clicked - loop through the name list, extracting the attached +# person from list, and building up the new bookmark list. The menu is +# then redrawn. # #------------------------------------------------------------------------- def on_ok_clicked(obj): - bmobj = obj.get_data(OBJECT) + bkmarks = obj.get_data(OBJECT) namelist = obj.get_data(NAMEINST) - del bmobj.bookmarks[0:] + del bkmarks.bookmarks[0:] - bmobj.myMenu = gtk.GtkMenu() - for index in range(0,bmobj.index): + for index in range(0,bkmarks.index): person = namelist.get_row_data(index) - if person == None: - break - bmobj.bookmarks.append(person) - item = gtk.GtkMenuItem(person.getPrimaryName().getName()) - item.show() - item.connect("activate", bmobj.callback , person) - bmobj.myMenu.append(item) - bmobj.menu.set_submenu(bmobj.myMenu) - bmobj.redraw() + if person: + bkmarks.bookmarks.append(person) + + bkmarks.redraw() obj.destroy() #------------------------------------------------------------------------- # -# +# on_cancel_clicked - destroy the bookmark editor # #------------------------------------------------------------------------- def on_cancel_clicked(obj): diff --git a/src/Config.py b/src/Config.py index bf8655d94..93e2d5a83 100644 --- a/src/Config.py +++ b/src/Config.py @@ -48,7 +48,6 @@ import libglade from RelLib import * from Date import * -import Researcher import const import utils import ListColors @@ -89,7 +88,7 @@ _name_format_list = [ # #------------------------------------------------------------------------- -owner = Researcher.Researcher() +owner = Researcher() prefsTop = None autoload = 0 usetabs = 0 diff --git a/src/EditPerson.py b/src/EditPerson.py index e4e8e3140..502f233aa 100644 --- a/src/EditPerson.py +++ b/src/EditPerson.py @@ -33,8 +33,8 @@ import string #------------------------------------------------------------------------- from gtk import * from gnome.ui import * -import gnome.mime import libglade +import GdkImlib #------------------------------------------------------------------------- # @@ -53,11 +53,23 @@ _ = intl.gettext #------------------------------------------------------------------------- # -# Constants +# Constants - quite frequently, data needs to be attached to a widget. +# this is done to prevent the use of globals, and to allow data to be +# passed with a widget (especially critical, since more that one window +# can be opened at a time). Data is attached to an widget using a string +# as the key. To avoid a lot of hard coded text strings floating around +# everywhere, values are defined here as constants with more meaningful +# names. # #------------------------------------------------------------------------- INDEX = "i" EDITPERSON = "p" +OBJECT = "o" +MENUVAL = "a" +PHOTO = "p" +TEXT = "t" +NOTEOBJ = "n" +TEXTOBJ = "w" #------------------------------------------------------------------------- # @@ -78,11 +90,7 @@ class EditPerson: self.callback = callback self.path = db.getSavePath() self.not_loaded = 1 - self.events_changed = 0 - self.urls_changed = 0 - self.addr_changed = 0 - self.names_changed = 0 - self.attr_changed = 0 + self.lists_changed = 0 self.top_window = libglade.GladeXML(const.editPersonFile, "editPerson") @@ -103,14 +111,14 @@ class EditPerson: self.web_list = self.get_widget("web_list") self.web_url = self.get_widget("web_url") self.web_description = self.get_widget("url_des") - self.address_label = self.get_widget("address_label") - self.address_list = self.get_widget("address_list") - self.address_start = self.get_widget("address_start") - self.address_street = self.get_widget("street") - self.address_city = self.get_widget("city") - self.address_state = self.get_widget("state") - self.address_country = self.get_widget("country") - self.address_postal = self.get_widget("postal") + self.addr_label = self.get_widget("address_label") + self.addr_list = self.get_widget("address_list") + self.addr_start = self.get_widget("address_start") + self.addr_street = self.get_widget("street") + self.addr_city = self.get_widget("city") + self.addr_state = self.get_widget("state") + self.addr_country = self.get_widget("country") + self.addr_postal = self.get_widget("postal") self.event_list = self.get_widget("eventList") self.edit_person = self.get_widget("editPerson") self.name_list = self.get_widget("nameList") @@ -147,46 +155,44 @@ class EditPerson: self.death = Event(person.getDeath()) self.birth = Event(person.getBirth()) self.pname = Name(person.getPrimaryName()) - - self.selectedIcon = -1 + self.selected_icon = -1 self.top_window.signal_autoconnect({ - "destroy_passed_object" : on_cancel_edit, - "on_add_address_clicked" : on_add_address_clicked, - "on_add_aka_clicked" : on_add_aka_clicked, - "on_add_attr_clicked" : on_add_attr_clicked, - "on_add_url_clicked" : on_add_url_clicked, - "on_addphoto_clicked" : on_add_photo_clicked, - "on_address_list_select_row" : on_address_list_select_row, - "on_aka_delete_clicked" : on_aka_delete_clicked, - "on_aka_update_clicked" : on_aka_update_clicked, - "on_apply_person_clicked" : on_apply_person_clicked, - "on_attr_list_select_row" : on_attr_list_select_row, - "on_birth_note_clicked" : on_birth_note_clicked, - "on_birth_source_clicked" : on_birth_source_clicked, - "on_browse_clicked": on_browse_clicked, - "on_death_note_clicked" : on_death_note_clicked, - "on_death_source_clicked" : on_death_source_clicked, - "on_delete_address_clicked" : on_delete_address_clicked, - "on_delete_attr_clicked" : on_delete_attr_clicked, - "on_delete_event" : on_delete_event, - "on_delete_url_clicked" : on_delete_url_clicked, - "on_deletephoto_clicked" : on_delete_photo_clicked, + "destroy_passed_object" : on_cancel_edit, + "on_add_address_clicked" : on_add_addr_clicked, + "on_add_aka_clicked" : on_add_aka_clicked, + "on_add_attr_clicked" : on_add_attr_clicked, + "on_add_url_clicked" : on_add_url_clicked, + "on_addphoto_clicked" : on_add_photo_clicked, + "on_address_list_select_row": on_addr_list_select_row, + "on_aka_delete_clicked" : on_aka_delete_clicked, + "on_aka_update_clicked" : on_aka_update_clicked, + "on_apply_person_clicked" : on_apply_person_clicked, + "on_attr_list_select_row" : on_attr_list_select_row, + "on_birth_note_clicked" : on_birth_note_clicked, + "on_birth_source_clicked" : on_birth_source_clicked, + "on_death_note_clicked" : on_death_note_clicked, + "on_death_source_clicked" : on_death_source_clicked, + "on_delete_address_clicked" : on_delete_addr_clicked, + "on_delete_attr_clicked" : on_delete_attr_clicked, + "on_delete_event" : on_delete_event, + "on_delete_url_clicked" : on_delete_url_clicked, + "on_deletephoto_clicked" : on_delete_photo_clicked, "on_editperson_switch_page" : on_switch_page, - "on_event_add_clicked" : on_event_add_clicked, - "on_event_delete_clicked" : on_event_delete_clicked, - "on_event_select_row" : on_event_select_row, - "on_event_update_clicked" : on_event_update_clicked, - "on_makeprimary_clicked" : on_primary_photo_clicked, - "on_name_list_select_row" : on_name_list_select_row, - "on_name_note_clicked" : on_name_note_clicked, - "on_name_source_clicked" : on_primary_name_source_clicked, - "on_photolist_button_press_event" : on_photolist_button_press_event, - "on_photolist_select_icon" : on_photo_select_icon, - "on_update_address_clicked" : on_update_address_clicked, - "on_update_attr_clicked" : on_update_attr_clicked, - "on_update_url_clicked" : on_update_url_clicked, - "on_web_list_select_row" : on_web_list_select_row, + "on_event_add_clicked" : on_event_add_clicked, + "on_event_delete_clicked" : on_event_delete_clicked, + "on_event_select_row" : on_event_select_row, + "on_event_update_clicked" : on_event_update_clicked, + "on_makeprimary_clicked" : on_primary_photo_clicked, + "on_name_list_select_row" : on_name_list_select_row, + "on_name_note_clicked" : on_name_note_clicked, + "on_name_source_clicked" : on_primary_name_source_clicked, + "on_photolist_button_press_event" : on_photolist_button_press, + "on_photolist_select_icon" : on_photo_select_icon, + "on_update_address_clicked" : on_update_addr_clicked, + "on_update_attr_clicked" : on_update_attr_clicked, + "on_update_url_clicked" : on_update_url_clicked, + "on_web_list_select_row" : on_web_list_select_row, }) if len(const.surnames) > 0: @@ -197,12 +203,12 @@ class EditPerson: self.event_list.set_column_visibility(3,Config.show_detail) self.name_list.set_column_visibility(1,Config.show_detail) self.attr_list.set_column_visibility(2,Config.show_detail) - self.address_list.set_column_visibility(2,Config.show_detail) + self.addr_list.set_column_visibility(2,Config.show_detail) plist = self.db.getPlaceMap().values() if len(plist) > 0: - attach_places(plist,self.dpcombo,self.death.getPlace()) - attach_places(plist,self.bpcombo,self.birth.getPlace()) + utils.attach_places(plist,self.dpcombo,self.death.getPlace()) + utils.attach_places(plist,self.bpcombo,self.birth.getPlace()) if Config.display_attr: self.get_widget("user_label").set_text(Config.attr_name) @@ -233,18 +239,9 @@ class EditPerson: self.nick.set_text(person.getNickName()) self.title.set_text(self.pname.getTitle()) self.bdate.set_text(self.birth.getDate()) - p = self.birth.getPlace() - if p: - self.bplace.set_text(p.get_title()) - else: - self.bplace.set_text("") + self.bplace.set_text(self.birth.getPlaceName()) self.ddate.set_text(self.death.getDate()) - - p = self.death.getPlace() - if p: - self.dplace.set_text(p.get_title()) - else: - self.dplace.set_text("") + self.dplace.set_text(self.death.getPlaceName()) # load photos into the photo window photo_list = person.getPhotoList() @@ -266,13 +263,13 @@ class EditPerson: self.web_list.set_data(INDEX,-1) self.attr_list.set_data(EDITPERSON,self) self.attr_list.set_data(INDEX,-1) - self.address_list.set_data(EDITPERSON,self) - self.address_list.set_data(INDEX,-1) + self.addr_list.set_data(EDITPERSON,self) + self.addr_list.set_data(INDEX,-1) # draw lists self.redraw_event_list() self.redraw_attr_list() - self.redraw_address_list() + self.redraw_addr_list() self.redraw_name_list() self.redraw_url_list() @@ -290,27 +287,7 @@ class EditPerson: # #--------------------------------------------------------------------- def redraw_name_list(self): - self.name_list.freeze() - self.name_list.clear() - - self.name_index = 0 - for name in self.nlist: - attr = get_detail_flags(name) - self.name_list.append([name.getName(),attr]) - self.name_list.set_row_data(self.name_index,name) - self.name_index = self.name_index + 1 - - current_row = self.name_list.get_data(INDEX) - - if self.name_index > 0: - if current_row <= 0: - current_row = 0 - elif self.name_index <= current_row: - current_row = current_row - 1 - self.name_list.select_row(current_row,0) - self.name_list.moveto(current_row,0) - self.name_list.set_data(INDEX,current_row) - self.name_list.thaw() + utils.redraw_list(self.nlist,self.name_list,disp_name) #--------------------------------------------------------------------- # @@ -318,31 +295,13 @@ class EditPerson: # #--------------------------------------------------------------------- def redraw_url_list(self): - self.web_list.freeze() - self.web_list.clear() - - self.web_index = 0 - for url in self.ulist: - self.web_list.append([url.get_path(),url.get_description()]) - self.web_list.set_row_data(self.web_index,url) - self.web_index = self.web_index + 1 - - current_row = self.web_list.get_data(INDEX) - - if self.web_index > 0: - if current_row <= 0: - current_row = 0 - elif self.web_index <= current_row: - current_row = current_row - 1 - self.web_list.select_row(current_row,0) - self.web_list.moveto(current_row,0) + length = utils.redraw_list(self.ulist,self.web_list,disp_url) + if length > 0: self.web_url.set_sensitive(1) else: self.web_url.set_sensitive(0) self.web_url.set_label("") self.web_description.set_text("") - self.web_list.set_data(INDEX,current_row) - self.web_list.thaw() #--------------------------------------------------------------------- # @@ -350,58 +309,15 @@ class EditPerson: # #--------------------------------------------------------------------- def redraw_attr_list(self): - self.attr_list.freeze() - self.attr_list.clear() - - self.attr_index = 0 - for attr in self.alist: - detail = get_detail_flags(attr) - self.attr_list.append([const.display_pattr(attr.getType()),\ - attr.getValue(),detail]) - self.attr_list.set_row_data(self.attr_index,attr) - self.attr_index = self.attr_index + 1 - - current_row = self.attr_list.get_data(INDEX) - - if self.attr_index > 0: - if current_row <= 0: - current_row = 0 - elif self.attr_index <= current_row: - current_row = current_row - 1 - self.attr_list.select_row(current_row,0) - self.attr_list.moveto(current_row,0) - self.attr_list.set_data(INDEX,current_row) - self.attr_list.thaw() + utils.redraw_list(self.alist,self.attr_list,disp_attr) #--------------------------------------------------------------------- # - # redraw_address_list - redraws the address list for the person + # redraw_addr_list - redraws the address list for the person # #--------------------------------------------------------------------- - def redraw_address_list(self): - self.address_list.freeze() - self.address_list.clear() - - self.address_index = 0 - for address in self.plist: - detail = get_detail_flags(address) - location = address.getCity() + " " + address.getState() + " " + \ - address.getCountry() - self.address_list.append([address.getDate(),location,detail]) - self.address_list.set_row_data(self.address_index,address) - self.address_index = self.address_index + 1 - - current_row = self.address_list.get_data(INDEX) - - if self.address_index > 0: - if current_row <= 0: - current_row = 0 - elif self.address_index <= current_row: - current_row = current_row - 1 - self.address_list.select_row(current_row,0) - self.address_list.moveto(current_row,0) - self.address_list.set_data(INDEX,current_row) - self.address_list.thaw() + def redraw_addr_list(self): + utils.redraw_list(self.plist,self.addr_list,disp_addr) #--------------------------------------------------------------------- # @@ -409,34 +325,7 @@ class EditPerson: # #--------------------------------------------------------------------- def redraw_event_list(self): - - self.event_list.freeze() - self.event_list.clear() - - self.event_index = 0 - for event in self.elist: - attr = get_detail_flags(event) - if event.getPlace(): - p = event.getPlace().get_title() - else: - p = "" - self.event_list.append([const.display_pevent(event.getName()),\ - event.getQuoteDate(),p,attr]) - self.event_list.set_row_data(self.event_index,event) - self.event_index = self.event_index + 1 - - current_row = self.event_list.get_data(INDEX) - - if self.event_index > 0: - if current_row <= 0: - current_row = 0 - elif self.event_index <= current_row: - current_row = current_row - 1 - self.event_list.select_row(current_row,0) - self.event_list.moveto(current_row,0) - - self.event_list.set_data(INDEX,current_row) - self.event_list.thaw() + utils.redraw_list(self.elist,self.event_list,disp_event) #------------------------------------------------------------------------- # @@ -444,11 +333,9 @@ class EditPerson: # #------------------------------------------------------------------------- def add_thumbnail(self,photo): - src = photo.getPath() - thumb = "%s%s.thumb%s%s" % (self.path,os.sep,os.sep,os.path.basename(src)) - + src = os.path.basename(photo.getPath()) + thumb = "%s%s.thumb%s%s" % (self.path,os.sep,os.sep,src) RelImage.check_thumb(src,thumb,const.thumbScale) - self.photo_list.append(thumb,photo.getDescription()) #------------------------------------------------------------------------- @@ -458,8 +345,6 @@ class EditPerson: # #------------------------------------------------------------------------- def load_images(self): - if len(self.person.getPhotoList()) == 0: - return self.photo_list.freeze() self.photo_list.clear() for photo in self.person.getPhotoList(): @@ -474,8 +359,6 @@ class EditPerson: # #------------------------------------------------------------------------- def load_photo(self,photo): - import GdkImlib - i = GdkImlib.Image(photo) scale = float(const.picWidth)/float(max(i.rgb_height,i.rgb_width)) x = int(scale*(i.rgb_width)) @@ -485,44 +368,62 @@ class EditPerson: #------------------------------------------------------------------------- # - # + # update_lists - Updates the person's list with the new lists, and sets + # the modified flag the if the lists have changed # #------------------------------------------------------------------------- - def update_events(self): - self.person.setEventList(self.elist) + def update_lists(self): + if self.lists_changed: + self.person.setEventList(self.elist) + self.person.setAlternateNames(self.nlist) + self.person.setUrlList(self.ulist) + self.person.setAttributeList(epo.alist) + self.person.setAddressList(self.plist) + utils.modified() - #------------------------------------------------------------------------- - # - # - # - #------------------------------------------------------------------------- - def update_names(self): - self.person.setAlternateNames(self.nlist) +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def disp_name(name): + return [name.getName(),utils.get_detail_flags(name)] - #------------------------------------------------------------------------- - # - # - # - #------------------------------------------------------------------------- - def update_urls(self): - self.person.setUrlList(self.ulist) +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def disp_url(url): + return [url.get_path(),url.get_description()] - #------------------------------------------------------------------------- - # - # - # - #------------------------------------------------------------------------- - def update_attributes(self): - self.person.setAttributeList(self.alist) +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def disp_attr(attr): + detail = utils.get_detail_flags(attr) + return [const.display_pattr(attr.getType()),attr.getValue(),detail] - #------------------------------------------------------------------------- - # - # - # - #------------------------------------------------------------------------- - def update_addresses(self): - self.person.setAddressList(self.plist) +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def disp_addr(addr): + location = "%s %s %s" % (addr.getCity(),addr.getState(),addr.getCountry()) + return [addr.getDate(),location,utils.get_detail_flags(addr)] +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def disp_event(event): + attr = utils.get_detail_flags(event) + return [const.display_pevent(event.getName()), + event.getQuoteDate(),event.getPlaceName(),attr] #------------------------------------------------------------------------- # @@ -562,7 +463,7 @@ def did_data_change(obj): epo.birth.setDate(bdate) - bplace_obj = get_place_from_list(epo.bpcombo) + bplace_obj = utils.get_place_from_list(epo.bpcombo) if bplace_obj == None and bplace != "": changed = 1 epo.birth.setPlace(bplace_obj) @@ -571,7 +472,7 @@ def did_data_change(obj): changed = 1 epo.death.setDate(ddate) - dplace_obj = get_place_from_list(epo.dpcombo) + dplace_obj = utils.get_place_from_list(epo.dpcombo) if dplace_obj == None and dplace != "": changed = 1 epo.death.setPlace(dplace_obj) @@ -583,10 +484,7 @@ def did_data_change(obj): changed = 1 if not gender and person.getGender() == Person.male: changed = 1 - if text != person.getNote() or epo.events_changed: - changed = 1 - if epo.names_changed or epo.urls_changed or \ - epo.attr_changed or epo.addr_changed: + if text != person.getNote() or epo.lists_changed: changed = 1 return changed @@ -597,9 +495,9 @@ def did_data_change(obj): # #------------------------------------------------------------------------- def on_cancel_edit(obj): + global quit if did_data_change(obj): - global quit q = _("Data was modified. Are you sure you want to abandon your changes?") quit = obj GnomeQuestionDialog(q,cancel_callback) @@ -621,9 +519,9 @@ def cancel_callback(a): # #------------------------------------------------------------------------- def on_delete_event(obj,b): + global quit if did_data_change(obj): - global quit q = _("Data was modified. Are you sure you want to abandon your changes?") quit = obj GnomeQuestionDialog(q,cancel_callback) @@ -649,7 +547,7 @@ def on_name_list_select_row(obj,row,b,c): epo.alt_given_field.set_text(name.getFirstName()) epo.alt_last_field.set_text(name.getSurname()) epo.alt_suffix_field.set_text(name.getSuffix()) - epo.name_details_field.set_text(get_detail_text(name)) + epo.name_details_field.set_text(utils.get_detail_text(name)) #------------------------------------------------------------------------- # @@ -684,7 +582,7 @@ def on_attr_list_select_row(obj,row,b,c): epo.attr_type.set_label(const.display_pattr(attr.getType())) epo.attr_value.set_text(attr.getValue()) - epo.attr_details_field.set_text(get_detail_text(attr)) + epo.attr_details_field.set_text(utils.get_detail_text(attr)) #------------------------------------------------------------------------- # @@ -693,21 +591,21 @@ def on_attr_list_select_row(obj,row,b,c): # the row. # #------------------------------------------------------------------------- -def on_address_list_select_row(obj,row,b,c): +def on_addr_list_select_row(obj,row,b,c): obj.set_data(INDEX,row) epo = obj.get_data(EDITPERSON) a = obj.get_row_data(row) - epo.address_label.set_label("%s %s %s" % \ - (a.getCity(),a.getState(),a.getCountry())) - epo.address_start.set_text(a.getDate()) - epo.address_street.set_text(a.getStreet()) - epo.address_city.set_text(a.getCity()) - epo.address_state.set_text(a.getState()) - epo.address_country.set_text(a.getCountry()) - epo.address_postal.set_text(a.getPostal()) - epo.addr_details_field.set_text(get_detail_text(a)) + label = "%s %s %s" % (a.getCity(),a.getState(),a.getCountry()) + epo.addr_label.set_label(label) + epo.addr_start.set_text(a.getDate()) + epo.addr_street.set_text(a.getStreet()) + epo.addr_city.set_text(a.getCity()) + epo.addr_state.set_text(a.getState()) + epo.addr_country.set_text(a.getCountry()) + epo.addr_postal.set_text(a.getPostal()) + epo.addr_details_field.set_text(utils.get_detail_text(a)) #------------------------------------------------------------------------- # @@ -716,10 +614,8 @@ def on_address_list_select_row(obj,row,b,c): #------------------------------------------------------------------------- def on_aka_update_clicked(obj): row = obj.get_data(INDEX) - if row < 0: - return - - NameEditor(obj.get_data(EDITPERSON),obj.get_row_data(row)) + if row >= 0: + NameEditor(obj.get_data(EDITPERSON),obj.get_row_data(row)) #------------------------------------------------------------------------- # @@ -728,10 +624,8 @@ def on_aka_update_clicked(obj): #------------------------------------------------------------------------- def on_update_url_clicked(obj): row = obj.get_data(INDEX) - if row < 0: - return - - UrlEditor(obj.get_data(EDITPERSON),obj.get_row_data(row)) + if row >= 0: + UrlEditor(obj.get_data(EDITPERSON),obj.get_row_data(row)) #------------------------------------------------------------------------- # @@ -740,21 +634,18 @@ def on_update_url_clicked(obj): #------------------------------------------------------------------------- def on_update_attr_clicked(obj): row = obj.get_data(INDEX) - if row < 0: - return - - AttributeEditor(obj.get_data(EDITPERSON),obj.get_row_data(row)) + if row >= 0: + AttributeEditor(obj.get_data(EDITPERSON),obj.get_row_data(row)) #------------------------------------------------------------------------- # # # #------------------------------------------------------------------------- -def on_update_address_clicked(obj): +def on_update_addr_clicked(obj): row = obj.get_data(INDEX) - if row < 0: - return - AddressEditor(obj.get_data(EDITPERSON),obj.get_row_data(row)) + if row >= 0: + AddressEditor(obj.get_data(EDITPERSON),obj.get_row_data(row)) #------------------------------------------------------------------------- # @@ -762,18 +653,10 @@ def on_update_address_clicked(obj): # #------------------------------------------------------------------------- def on_aka_delete_clicked(obj): - row = obj.get_data(INDEX) epo = obj.get_data(EDITPERSON) - if row < 0: - return - - del epo.nlist[row] - - if row > len(epo.nlist)-1: - obj.set_data(INDEX,row-1) - - epo.redraw_name_list() - utils.modified() + if utils.delete_selected(obj,epo.nlist): + epo.lists_changed = 1 + epo.redraw_name_list() #------------------------------------------------------------------------- # @@ -781,18 +664,10 @@ def on_aka_delete_clicked(obj): # #------------------------------------------------------------------------- def on_delete_url_clicked(obj): - row = obj.get_data(INDEX) - if row < 0: - return - epo = obj.get_data(EDITPERSON) - del epo.ulist[row] - - if row > len(epo.ulist)-1: - obj.set_data(INDEX,row-1) - - epo.redraw_url_list() - utils.modified() + if utils.delete_selected(obj,epo.ulist): + epo.lists_changed = 1 + epo.redraw_url_list() #------------------------------------------------------------------------- # @@ -800,43 +675,36 @@ def on_delete_url_clicked(obj): # #------------------------------------------------------------------------- def on_delete_attr_clicked(obj): - row = obj.get_data(INDEX) - if row < 0: - return - epo = obj.get_data(EDITPERSON) - del epo.alist[row] - - if row > len(epo.alist)-1: - obj.set_data(INDEX,row-1) - - epo.redraw_attr_list() - epo.attr_changed = 1 - utils.modified() + if utils.delete_selected(obj,epo.alist): + epo.lists_changed = 1 + epo.redraw_attr_list() #------------------------------------------------------------------------- # # # #------------------------------------------------------------------------- -def on_delete_address_clicked(obj): - row = obj.get_data(INDEX) - if row < 0: - return - - row = obj.get_data(INDEX) - if row < 0: - return - +def on_delete_addr_clicked(obj): epo = obj.get_data(EDITPERSON) - del epo.plist[row] + if utils.delete_selected(obj,epo.plist): + epo.lists_changed = 1 + epo.redraw_addr_list() - if row > len(epo.plist)-1: - obj.set_data(INDEX,row-1) - - epo.redraw_address_list() - epo.addr_changed = 1 - utils.modified() +#------------------------------------------------------------------------- +# +# on_event_delete_clicked +# +# Called from the edit_person window, to update the values on the selected +# event. The EditPerson object and the selected row are attached to the +# passed object. +# +#------------------------------------------------------------------------- +def on_event_delete_clicked(obj): + epo = obj.get_data(EDITPERSON) + if utils.delete_selected(obj,epo.elist): + epo.lists_changed = 1 + epo.redraw_event_list() #------------------------------------------------------------------------- # @@ -844,8 +712,7 @@ def on_delete_address_clicked(obj): # #------------------------------------------------------------------------- def on_add_aka_clicked(obj): - epo = obj.get_data(EDITPERSON) - NameEditor(epo,None) + NameEditor(obj.get_data(EDITPERSON),None) #------------------------------------------------------------------------- # @@ -853,8 +720,7 @@ def on_add_aka_clicked(obj): # #------------------------------------------------------------------------- def on_add_url_clicked(obj): - epo = obj.get_data(EDITPERSON) - UrlEditor(epo,None) + UrlEditor(obj.get_data(EDITPERSON),None) #------------------------------------------------------------------------- # @@ -869,7 +735,7 @@ def on_add_attr_clicked(obj): # # #------------------------------------------------------------------------- -def on_add_address_clicked(obj): +def on_add_addr_clicked(obj): AddressEditor(obj.get_data(EDITPERSON),None) #------------------------------------------------------------------------- @@ -884,29 +750,6 @@ def on_add_address_clicked(obj): def on_event_add_clicked(obj): EventEditor(obj.get_data(EDITPERSON),None) -#------------------------------------------------------------------------- -# -# on_event_delete_clicked -# -# Called from the edit_person window, to update the values on the selected -# event. The EditPerson object and the selected row are attached to the -# passed object. -# -#------------------------------------------------------------------------- -def on_event_delete_clicked(obj): - epo = obj.get_data(EDITPERSON) - row = obj.get_data(INDEX) - if row < 0: - return - - del epo.elist[row] - - if row > len(epo.elist)-1: - obj.set_data(INDEX,row-1) - - epo.redraw_event_list() - epo.events_changed = 1 - #------------------------------------------------------------------------- # # on_event_update_clicked @@ -918,9 +761,8 @@ def on_event_delete_clicked(obj): #------------------------------------------------------------------------- def on_event_update_clicked(obj): row = obj.get_data(INDEX) - if row < 0: - return - EventEditor(obj.get_data(EDITPERSON),obj.get_row_data(row)) + if row >= 0: + EventEditor(obj.get_data(EDITPERSON),obj.get_row_data(row)) #------------------------------------------------------------------------- # @@ -935,13 +777,10 @@ def on_event_select_row(obj,row,b,c): epo = obj.get_data(EDITPERSON) epo.event_date_field.set_text(event.getDate()) - if event.getPlace(): - epo.event_place_field.set_text(event.getPlace().get_title()) - else: - epo.event_place_field.set_text("") + epo.event_place_field.set_text(event.getPlaceName()) epo.event_name_field.set_label(const.display_pevent(event.getName())) epo.event_descr_field.set_text(event.getDescription()) - epo.event_details_field.set_text(get_detail_text(event)) + epo.event_details_field.set_text(utils.get_detail_text(event)) #------------------------------------------------------------------------- # @@ -960,7 +799,7 @@ def on_switch_page(obj,a,page): # #------------------------------------------------------------------------- def on_photo_select_icon(obj,iconNumber,event): - obj.get_data(EDITPERSON).selectedIcon = iconNumber + obj.get_data(EDITPERSON).selected_icon = iconNumber #------------------------------------------------------------------------- # @@ -969,14 +808,11 @@ def on_photo_select_icon(obj,iconNumber,event): #------------------------------------------------------------------------- def on_delete_photo_clicked(obj): epo = obj.get_data(EDITPERSON) - icon = epo.selectedIcon + icon = epo.selected_icon - if icon == -1: - return - - photolist = epo.person.getPhotoList() - epo.photo_list.remove(icon) - del photolist[epo.selectedIcon] + if icon != -1: + epo.photo_list.remove(icon) + del epo.person.getPhotoList()[icon] #------------------------------------------------------------------------- # @@ -985,15 +821,14 @@ def on_delete_photo_clicked(obj): #------------------------------------------------------------------------- def on_primary_photo_clicked(obj): epo = obj.get_data(EDITPERSON) - if epo.selectedIcon == None or \ - epo.selectedIcon == 0: + if epo.selected_icon == None or epo.selected_icon == 0: return photolist = epo.person.getPhotoList() - selectedIcon = epo.selectedIcon - savePhoto = photolist[selectedIcon] - for i in range(0,selectedIcon): - photolist[selectedIcon-i] = photolist[selectedIcon-i-1] + selected_icon = epo.selected_icon + savePhoto = photolist[selected_icon] + for i in range(0,selected_icon): + photolist[selected_icon-i] = photolist[selected_icon-i-1] photolist[0] = savePhoto epo.load_photo(savePhoto.getPath()) @@ -1203,9 +1038,7 @@ def update_name(name,first,last,suffix,note,priv,conf): def on_add_photo_clicked(obj): edit_person = obj.get_data(EDITPERSON) - image_select = libglade.GladeXML(const.imageselFile,"imageSelect") - edit_person.isel = image_select image_select.signal_autoconnect({ @@ -1286,7 +1119,7 @@ def save_person(obj): epo.birth.setDate(epo.bdate.get_text()) - p1 = get_place_from_list(epo.bpcombo) + p1 = utils.get_place_from_list(epo.bpcombo) if p1 == None and bplace != "": p1 = Place() p1.set_title(bplace) @@ -1297,7 +1130,7 @@ def save_person(obj): epo.death.setDate(epo.ddate.get_text()) - p2 = get_place_from_list(epo.dpcombo) + p2 = utils.get_place_from_list(epo.dpcombo) if p2 == None and dplace != "": p2 = Place() p2.set_title(dplace) @@ -1339,26 +1172,7 @@ def save_person(obj): person.setNote(text) utils.modified() - epo.update_events() - if epo.events_changed: - utils.modified() - - epo.update_names() - if epo.names_changed: - utils.modified() - - epo.update_urls() - if epo.urls_changed: - utils.modified() - - epo.update_attributes() - if epo.attr_changed: - utils.modified() - - epo.update_addresses() - if epo.addr_changed: - utils.modified() - + epo.update_lists() epo.callback(epo) #------------------------------------------------------------------------- @@ -1403,8 +1217,8 @@ def on_savephoto_clicked(obj): # #------------------------------------------------------------------------- def on_save_note_clicked(obj): - textbox = obj.get_data("w") - data = obj.get_data("n") + textbox = obj.get_data(TEXTOBJ) + data = obj.get_data(NOTEOBJ) text = textbox.get_chars(0,-1) if text != data.getNote(): @@ -1418,46 +1232,39 @@ def on_save_note_clicked(obj): # # #------------------------------------------------------------------------- -def on_birth_note_clicked(obj): - epo = obj.get_data(EDITPERSON) +def display_note(obj,data): editnote = libglade.GladeXML(const.editnoteFile,"editnote") - data = epo.birth textobj = editnote.get_widget("notetext") en_obj = editnote.get_widget("editnote") - en_obj.set_data("n",data) - en_obj.set_data("w",textobj) + en_obj.set_data(NOTEOBJ,data) + en_obj.set_data(TEXTOBJ,textobj) textobj.set_point(0) textobj.insert_defaults(data.getNote()) textobj.set_word_wrap(1) editnote.signal_autoconnect({ - "on_save_note_clicked" : on_save_note_clicked, + "on_save_note_clicked" : on_save_note_clicked, "destroy_passed_object" : utils.destroy_passed_object }) + +#------------------------------------------------------------------------- +# +# Display the note editor for the birth event +# +#------------------------------------------------------------------------- +def on_birth_note_clicked(obj): + epo = obj.get_data(EDITPERSON) + display_note(obj,epo.birth) #------------------------------------------------------------------------- # -# +# Display the note editor for the name event # #------------------------------------------------------------------------- def on_name_note_clicked(obj): epo = obj.get_data(EDITPERSON) - editnote = libglade.GladeXML(const.editnoteFile,"editnote") - data = epo.pname - textobj = editnote.get_widget("notetext") - en_obj = editnote.get_widget("editnote") - en_obj.set_data("n",data) - en_obj.set_data("w",textobj) - - textobj.set_point(0) - textobj.insert_defaults(data.getNote()) - textobj.set_word_wrap(1) - - editnote.signal_autoconnect({ - "on_save_note_clicked" : on_save_note_clicked, - "destroy_passed_object" : utils.destroy_passed_object - }) + display_note(obj,epo.pname) #------------------------------------------------------------------------- # @@ -1466,21 +1273,7 @@ def on_name_note_clicked(obj): #------------------------------------------------------------------------- def on_death_note_clicked(obj): epo = obj.get_data(EDITPERSON) - editnote = libglade.GladeXML(const.editnoteFile,"editnote") - textobj = editnote.get_widget("notetext") - data = epo.death - en_obj = editnote.get_widget("editnote") - en_obj.set_data("n",data) - en_obj.set_data("w",textobj) - - textobj.set_point(0) - textobj.insert_defaults(data.getNote()) - textobj.set_word_wrap(1) - - editnote.signal_autoconnect({ - "on_save_note_clicked" : on_save_note_clicked, - "destroy_passed_object" : utils.destroy_passed_object - }) + display_note(obj,epo.death) #------------------------------------------------------------------------- # @@ -1514,10 +1307,9 @@ def on_birth_source_clicked(obj): # # #------------------------------------------------------------------------- -def on_photolist_button_press_event(obj,event): - +def on_photolist_button_press(obj,event): myobj = obj.get_data(EDITPERSON) - icon = myobj.selectedIcon + icon = myobj.selected_icon if icon == -1: return @@ -1526,28 +1318,14 @@ def on_photolist_button_press_event(obj,event): menu = GtkMenu() item = GtkTearoffMenuItem() item.show() - view = GtkMenuItem(_("View Image")) - view.set_data("m",myobj) - view.connect("activate",on_view_photo) - view.show() - edit = GtkMenuItem(_("Edit Image")) - edit.set_data("m",myobj) - edit.connect("activate",on_edit_photo) - edit.show() - change = GtkMenuItem(_("Edit Description")) - change.set_data("m",myobj) - change.connect("activate",on_change_description) - change.show() menu.append(item) - menu.append(view) - menu.append(edit) - menu.append(change) + utils.add_menuitem(menu,_("View Image"),myobj,on_view_photo) + utils.add_menuitem(menu,_("Edit Image"),myobj,on_edit_photo) + utils.add_menuitem(menu,_("Edit Description"),myobj, + on_change_description) if photo.getPrivate() == 0: - private = GtkMenuItem(_("Convert to private copy")) - private.set_data("m",myobj) - private.connect("activate",on_convert_to_private) - private.show() - menu.append(private) + utils.add_menuitem(menu,_("Convert to private copy"), + myobj, on_convert_to_private) menu.popup(None,None,None,0,0) #------------------------------------------------------------------------- @@ -1556,8 +1334,8 @@ def on_photolist_button_press_event(obj,event): # #------------------------------------------------------------------------- def on_convert_to_private(obj): - epo = obj.get_data("m") - photo = epo.person.getPhotoList()[epo.selectedIcon] + epo = obj.get_data(OBJECT) + photo = epo.person.getPhotoList()[epo.selected_icon] prefix = "i%s" % epo.person.getId() name = RelImage.import_photo(photo.getPath(),epo.path,prefix) @@ -1571,20 +1349,9 @@ def on_convert_to_private(obj): # #------------------------------------------------------------------------- def on_view_photo(obj): - myobj = obj.get_data("m") - photo = myobj.person.getPhotoList()[myobj.selectedIcon] - type = gnome.mime.type(photo.getPath()) - - prog = string.split(gnome.mime.get_value(type,'view')) - args = [] - for val in prog: - if val == "%f": - args.append(photo.getPath()) - else: - args.append(val) - - if os.fork() == 0: - os.execvp(args[0],args) + myobj = obj.get_data(OBJECT) + photo = myobj.person.getPhotoList()[myobj.selected_icon] + utils.view_photo(photo) #------------------------------------------------------------------------- # @@ -1592,8 +1359,8 @@ def on_view_photo(obj): # #------------------------------------------------------------------------- def on_edit_photo(obj): - myobj = obj.get_data("m") - photo = myobj.person.getPhotoList()[myobj.selectedIcon] + myobj = obj.get_data(OBJECT) + photo = myobj.person.getPhotoList()[myobj.selected_icon] if os.fork() == 0: os.execvp(const.editor,[const.editor, photo.getPath()]) @@ -1603,8 +1370,8 @@ def on_edit_photo(obj): # #------------------------------------------------------------------------- def on_change_description(obj): - myobj = obj.get_data("m") - photo = myobj.person.getPhotoList()[myobj.selectedIcon] + myobj = obj.get_data(OBJECT) + photo = myobj.person.getPhotoList()[myobj.selected_icon] window = libglade.GladeXML(const.imageselFile,"dialog1") text = window.get_widget("text") @@ -1612,13 +1379,13 @@ def on_change_description(obj): image2 = RelImage.scale_image(photo.getPath(),200.0) window.get_widget("photo").load_imlib(image2) - window.get_widget("dialog1").set_data("p",photo) - window.get_widget("dialog1").set_data("t",text) - window.get_widget("dialog1").set_data("m",obj.get_data("m")) + window.get_widget("dialog1").set_data(PHOTO,photo) + window.get_widget("dialog1").set_data(TEXT,text) + window.get_widget("dialog1").set_data(OBJECT,obj.get_data(OBJECT)) window.signal_autoconnect({ "on_cancel_clicked" : utils.destroy_passed_object, - "on_ok_clicked" : on_ok_clicked, - "on_apply_clicked" : on_apply_clicked + "on_ok_clicked" : on_ok_clicked, + "on_apply_clicked" : on_apply_clicked }) #------------------------------------------------------------------------- @@ -1627,12 +1394,11 @@ def on_change_description(obj): # #------------------------------------------------------------------------- def on_apply_clicked(obj): - photo = obj.get_data("p") - text = obj.get_data("t").get_text() + photo = obj.get_data(PHOTO) + text = obj.get_data(TEXT).get_text() if text != photo.getDescription(): photo.setDescription(text) - edit_window = obj.get_data("m") - edit_window.load_images() + obj.get_data(OBJECT).load_images() utils.modified() #------------------------------------------------------------------------- @@ -1644,18 +1410,6 @@ def on_ok_clicked(obj): on_apply_clicked(obj) utils.destroy_passed_object(obj) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_browse_clicked(obj): - import gnome.url - - path = obj.get()[2:] - if path != "": - gnome.url.show(path) - #------------------------------------------------------------------------- # # EventEditor class @@ -1684,31 +1438,18 @@ class EventEditor: self.priv = self.top.get_widget("priv") name = parent.person.getPrimaryName().getName() - - self.top.get_widget("eventTitle").set_text(_("Event Editor for %s") % name) + title = _("Event Editor for %s") % name + self.top.get_widget("eventTitle").set_text(title) self.event_menu.set_popdown_strings(const.personalEvents) - myMenu = GtkMenu() - index = 0 - for name in const.confidence: - item = GtkMenuItem(name) - item.set_data("a",index) - item.show() - myMenu.append(item) - index = index + 1 - - self.conf_menu.set_menu(myMenu) + utils.build_confidence_menu(self.conf_menu) values = self.parent.db.getPlaceMap().values() if event != None: self.name_field.set_text(event.getName()) - attach_places(values,self.place_combo,event.getPlace()) - if event.getPlace(): - self.place_field.set_text(event.getPlace().get_title()) - else: - self.place_field.set_text('') - + utils.attach_places(values,self.place_combo,event.getPlace()) + self.place_field.set_text(event.getPlaceName()) self.date_field.set_text(event.getDate()) self.descr_field.set_text(event.getDescription()) self.conf_menu.set_history(event.getConfidence()) @@ -1725,14 +1466,14 @@ class EventEditor: self.note_field.insert_defaults(event.getNote()) self.note_field.set_word_wrap(1) else: - attach_places(values,self.place_combo,None) + utuils.attach_places(values,self.place_combo,None) self.conf_menu.set_history(2) - self.window.set_data("o",self) + self.window.set_data(OBJECT,self) self.top.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : utils.destroy_passed_object, "on_event_edit_ok_clicked" : on_event_edit_ok_clicked, - "on_source_clicked" : on_edit_source_clicked + "on_source_clicked" : on_edit_source_clicked }) #------------------------------------------------------------------------- @@ -1741,7 +1482,7 @@ class EventEditor: # #------------------------------------------------------------------------- def on_edit_source_clicked(obj): - ee = obj.get_data("o") + ee = obj.get_data(OBJECT) Sources.SourceEditor(ee.srcref,ee.parent.db,ee.source_field) #------------------------------------------------------------------------- @@ -1750,7 +1491,7 @@ def on_edit_source_clicked(obj): # #------------------------------------------------------------------------- def on_event_edit_ok_clicked(obj): - ee = obj.get_data("o") + ee = obj.get_data(OBJECT) event = ee.event ename = ee.name_field.get_text() @@ -1760,7 +1501,7 @@ def on_event_edit_ok_clicked(obj): enote = ee.note_field.get_chars(0,-1) edesc = ee.descr_field.get_text() epriv = ee.priv.get_active() - econf = ee.conf_menu.get_menu().get_active().get_data("a") + econf = ee.conf_menu.get_menu().get_active().get_data(MENUVAL) if event == None: event = Event() @@ -1814,7 +1555,7 @@ class AttributeEditor: index = 0 for name in const.confidence: item = GtkMenuItem(name) - item.set_data("a",index) + item.set_data(MENUVAL,index) item.show() myMenu.append(item) index = index + 1 @@ -1839,7 +1580,7 @@ class AttributeEditor: else: self.conf_menu.set_history(2) - self.window.set_data("o",self) + self.window.set_data(OBJECT,self) self.top.signal_autoconnect({ "destroy_passed_object" : utils.destroy_passed_object, "on_attr_edit_ok_clicked" : on_attrib_edit_ok_clicked, @@ -1852,7 +1593,7 @@ class AttributeEditor: # #------------------------------------------------------------------------- def on_attrib_source_clicked(obj): - ee = obj.get_data("o") + ee = obj.get_data(OBJECT) Sources.SourceEditor(ee.srcref,ee.parent.db,ee.source_field) #------------------------------------------------------------------------- @@ -1861,14 +1602,14 @@ def on_attrib_source_clicked(obj): # #------------------------------------------------------------------------- def on_attrib_edit_ok_clicked(obj): - ee = obj.get_data("o") + ee = obj.get_data(OBJECT) attrib = ee.attrib type = ee.type_field.get_text() value = ee.value_field.get_text() note = ee.note_field.get_chars(0,-1) priv = ee.priv.get_active() - conf = ee.conf_menu.get_menu().get_active().get_data("a") + conf = ee.conf_menu.get_menu().get_active().get_data(MENUVAL) if attrib == None: attrib = Attribute() @@ -1914,16 +1655,7 @@ class NameEditor: self.top.get_widget("altTitle").set_text( _("Alternate Name Editor for %s") % full_name) - myMenu = GtkMenu() - index = 0 - for val in const.confidence: - item = GtkMenuItem(val) - item.set_data("a",index) - item.show() - myMenu.append(item) - index = index + 1 - - self.conf_menu.set_menu(myMenu) + utils.build_confidence_menu(self.conf_menu) if name != None: self.given_field.set_text(name.getFirstName()) @@ -1934,22 +1666,19 @@ class NameEditor: self.source_field.set_text(srcref_base.getTitle()) else: self.source_field.set_text("") - self.conf_menu.set_history(name.getConfidence()) - self.priv.set_active(name.getPrivacy()) - self.note_field.set_point(0) self.note_field.insert_defaults(name.getNote()) self.note_field.set_word_wrap(1) else: self.conf_menu.set_history(2) - self.window.set_data("o",self) + self.window.set_data(OBJECT,self) self.top.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : utils.destroy_passed_object, "on_name_edit_ok_clicked" : on_name_edit_ok_clicked, - "on_source_clicked" : on_name_source_clicked + "on_source_clicked" : on_name_source_clicked }) #------------------------------------------------------------------------- @@ -1958,7 +1687,7 @@ class NameEditor: # #------------------------------------------------------------------------- def on_name_source_clicked(obj): - ee = obj.get_data("o") + ee = obj.get_data(OBJECT) Sources.SourceEditor(ee.srcref,ee.parent.db,ee.source_field) #------------------------------------------------------------------------- @@ -1967,7 +1696,7 @@ def on_name_source_clicked(obj): # #------------------------------------------------------------------------- def on_name_edit_ok_clicked(obj): - ee = obj.get_data("o") + ee = obj.get_data(OBJECT) name = ee.name first = ee.given_field.get_text() @@ -1975,23 +1704,22 @@ def on_name_edit_ok_clicked(obj): suffix = ee.suffix_field.get_text() note = ee.note_field.get_chars(0,-1) priv = ee.priv.get_active() - conf = ee.conf_menu.get_menu().get_active().get_data("a") + conf = ee.conf_menu.get_menu().get_active().get_data(MENUVAL) if name == None: name = Name() ee.parent.nlist.append(name) if update_name(name,first,last,suffix,note,priv,conf): - ee.parent.name_changed = 1 + ee.parent.lists_changed = 1 if not name.getSourceRef().are_equal(ee.srcref): name.setSourceRef(ee.srcref) - ee.parent.name_changed = 1 + ee.parent.lists_changed = 1 ee.parent.redraw_name_list() utils.destroy_passed_object(obj) - #------------------------------------------------------------------------- # # AddressEditor class @@ -2004,7 +1732,7 @@ class AddressEditor: self.addr = addr self.top = libglade.GladeXML(const.editPersonFile, "addr_edit") self.window = self.top.get_widget("addr_edit") - self.address_start = self.top.get_widget("address_start") + self.addr_start = self.top.get_widget("address_start") self.street = self.top.get_widget("street") self.city = self.top.get_widget("city") self.state = self.top.get_widget("state") @@ -2023,16 +1751,7 @@ class AddressEditor: text = _("Address Editor for %s") % name self.top.get_widget("addrTitle").set_text(text) - myMenu = GtkMenu() - index = 0 - for val in const.confidence: - item = GtkMenuItem(val) - item.set_data("a",index) - item.show() - myMenu.append(item) - index = index + 1 - - self.conf_menu.set_menu(myMenu) + utils.build_confidence_menu(self.conf_menu) if addr != None: self.street.set_text(addr.getStreet()) @@ -2047,20 +1766,18 @@ class AddressEditor: self.source_field.set_text("") self.conf_menu.set_history(addr.getConfidence()) - self.priv.set_active(addr.getPrivacy()) - self.note_field.set_point(0) self.note_field.insert_defaults(addr.getNote()) self.note_field.set_word_wrap(1) else: self.conf_menu.set_history(2) - self.window.set_data("o",self) + self.window.set_data(OBJECT,self) self.top.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : utils.destroy_passed_object, "on_addr_edit_ok_clicked" : on_addr_edit_ok_clicked, - "on_source_clicked" : on_addr_source_clicked + "on_source_clicked" : on_addr_source_clicked }) #------------------------------------------------------------------------- @@ -2069,7 +1786,7 @@ class AddressEditor: # #------------------------------------------------------------------------- def on_addr_source_clicked(obj): - ee = obj.get_data("o") + ee = obj.get_data(OBJECT) Sources.SourceEditor(ee.srcref,ee.parent.db,ee.source_field) #------------------------------------------------------------------------- @@ -2078,10 +1795,10 @@ def on_addr_source_clicked(obj): # #------------------------------------------------------------------------- def on_addr_edit_ok_clicked(obj): - ee = obj.get_data("o") + ee = obj.get_data(OBJECT) addr = ee.addr - date = ee.address_start.get_text() + date = ee.addr_start.get_text() street = ee.street.get_text() city = ee.city.get_text() state = ee.state.get_text() @@ -2089,20 +1806,20 @@ def on_addr_edit_ok_clicked(obj): postal = ee.postal.get_text() note = ee.note_field.get_chars(0,-1) priv = ee.priv.get_active() - conf = ee.conf_menu.get_menu().get_active().get_data("a") + conf = ee.conf_menu.get_menu().get_active().get_data(MENUVAL) if addr == None: addr = Address() ee.parent.plist.append(addr) if update_address(addr,date,street,city,state,country,postal,note,priv,conf): - ee.parent.addr_changed = 1 + ee.parent.lists_changed = 1 if not addr.getSourceRef().are_equal(ee.srcref): addr.setSourceRef(ee.srcref) - ee.parent.addr_changed = 1 + ee.parent.lists_changed = 1 - ee.parent.redraw_address_list() + ee.parent.redraw_addr_list() utils.destroy_passed_object(obj) #------------------------------------------------------------------------- @@ -2122,17 +1839,17 @@ class UrlEditor: self.priv = self.top.get_widget("priv") name = parent.person.getPrimaryName().getName() - - self.top.get_widget("urlTitle").set_text(_("Internet Address Editor for %s") % name) + title = _("Internet Address Editor for %s") % name + self.top.get_widget("urlTitle").set_text(title) if url != None: self.des.set_text(url.get_description()) self.addr.set_text(url.get_path()) self.priv.set_active(url.getPrivacy()) - self.window.set_data("o",self) + self.window.set_data(OBJECT,self) self.top.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, + "destroy_passed_object" : utils.destroy_passed_object, "on_url_edit_ok_clicked" : on_url_edit_ok_clicked }) @@ -2142,7 +1859,7 @@ class UrlEditor: # #------------------------------------------------------------------------- def on_url_edit_ok_clicked(obj): - ee = obj.get_data("o") + ee = obj.get_data(OBJECT) url = ee.url des = ee.des.get_text() @@ -2154,93 +1871,8 @@ def on_url_edit_ok_clicked(obj): ee.parent.ulist.append(url) if update_url(url,des,addr,priv): - ee.parent.urls_changed = 1 + ee.parent.lists_changed = 1 ee.parent.redraw_url_list() utils.destroy_passed_object(obj) - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def get_detail_flags(obj): - detail = "" - if Config.show_detail: - if obj.getNote() != "": - detail = "N" - if obj.getSourceRef().getBase(): - detail = detail + "S" - if obj.getPrivacy(): - detail = detail + "P" - return detail - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def get_detail_text(obj): - if obj.getNote() != "": - details = "%s" % _("Note") - else: - details = "" - if obj.getSourceRef().getBase() != None: - if details == "": - details = _("Source") - else: - details = "%s, %s" % (details,_("Source")) - if obj.getPrivacy() == 1: - if details == "": - details = _("Private") - else: - details = "%s, %s" % (details,_("Private")) - return details - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def attach_places(values,combo,place): - l = GtkLabel("") - l.show() - l.set_alignment(0,0.5) - c = GtkListItem() - c.add(l) - c.set_data("s",None) - c.show() - sel_child = c - list = [c] - mymap = {} - for src in values: - l = GtkLabel("%s [%s]" % (src.get_title(),src.getId())) - l.show() - l.set_alignment(0,0.5) - c = GtkListItem() - c.add(l) - c.set_data("s",src) - c.show() - list.append(c) - if src == place: - sel_child = c - mymap[src] = c - - combo.list.append_items(list) - combo.list.select_child(sel_child) - - for v in mymap.keys(): - combo.set_item_string(mymap[v],v.get_title()) - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def get_place_from_list(obj): - select = obj.list.get_selection() - if len(select) == 0: - return None - else: - return select[0].get_data("s") diff --git a/src/EditPlace.py b/src/EditPlace.py index a9f27352b..7f4fa0ab7 100644 --- a/src/EditPlace.py +++ b/src/EditPlace.py @@ -1,4 +1,3 @@ -#! /usr/bin/python -O # # Gramps - a GTK+/GNOME based genealogy program # @@ -34,7 +33,6 @@ import string #------------------------------------------------------------------------- from gtk import * from gnome.ui import * -import gnome.mime import libglade @@ -93,10 +91,9 @@ class EditPlace: self.loc_state = self.top_window.get_widget("loc_state") self.loc_country = self.top_window.get_widget("loc_country") + self.lists_changed = 0 self.ulist = place.getUrlList()[:] - self.urls_changed = 0 self.llist = place.get_alternate_locations()[:] - self.locations_changed = 0 self.title.set_text(place.get_title()) mloc = place.get_main_location() @@ -124,7 +121,6 @@ class EditPlace: "on_photolist_button_press_event" : on_photolist_button_press_event, "on_switch_page" : on_switch_page, "on_addphoto_clicked" : on_add_photo_clicked, - "on_browse_clicked": on_browse_clicked, "on_deletephoto_clicked" : on_delete_photo_clicked, "on_add_url_clicked" : on_add_url_clicked, "on_delete_url_clicked" : on_delete_url_clicked, @@ -157,49 +153,25 @@ class EditPlace: # # #------------------------------------------------------------------------- - def update_urls(self): + def update_lists(self): self.place.setUrlList(self.ulist) - - #------------------------------------------------------------------------- - # - # - # - #------------------------------------------------------------------------- - def update_locations(self): self.place.set_alternate_locations(self.llist) - + if self.lists_changed: + utils.modified() + #--------------------------------------------------------------------- # # redraw_url_list - redraws the altername name list for the person # #--------------------------------------------------------------------- def redraw_url_list(self): - self.web_list.freeze() - self.web_list.clear() - - self.web_index = 0 - for url in self.ulist: - self.web_list.append([url.get_path(),url.get_description()]) - self.web_list.set_row_data(self.web_index,url) - self.web_index = self.web_index + 1 - - current_row = self.web_list.get_data(INDEX) - - if self.web_index > 0: - if current_row <= 0: - current_row = 0 - elif self.web_index <= current_row: - current_row = current_row - 1 - self.web_list.select_row(current_row,0) - self.web_list.moveto(current_row,0) + length = utils.redraw_list(self.ulist,self.web_list,disp_url) + if length > 0: self.web_url.set_sensitive(1) else: - self.web_url.set_label("") self.web_url.set_sensitive(0) + self.web_url.set_label("") self.web_description.set_text("") - - self.web_list.set_data(INDEX,current_row) - self.web_list.thaw() #--------------------------------------------------------------------- # @@ -207,27 +179,7 @@ class EditPlace: # #--------------------------------------------------------------------- def redraw_location_list(self): - self.loc_list.freeze() - self.loc_list.clear() - - self.loc_index = 0 - for loc in self.llist: - self.loc_list.append([loc.get_city(),loc.get_county(), - loc.get_state(),loc.get_country()]) - self.loc_list.set_row_data(self.loc_index,loc) - self.loc_index = self.loc_index + 1 - - current_row = self.loc_list.get_data(INDEX) - - if self.loc_index > 0: - if current_row <= 0: - current_row = 0 - elif self.loc_index <= current_row: - current_row = current_row - 1 - self.loc_list.select_row(current_row,0) - self.loc_list.moveto(current_row,0) - self.loc_list.set_data(INDEX,current_row) - self.loc_list.thaw() + utils.redraw_list(self.llist,self.loc_list,disp_loc) #------------------------------------------------------------------------- # @@ -235,12 +187,9 @@ class EditPlace: # #------------------------------------------------------------------------- def add_thumbnail(self,photo): - src = photo.getPath() - thumb = self.db.getSavePath() + os.sep + ".thumb" + os.sep + \ - os.path.basename(src) - + src = os.path.basename(photo.getPath()) + thumb = "%s%s.thumb%s%s" % (self.path,os.sep,os.sep,src) RelImage.check_thumb(src,thumb,const.thumbScale) - self.photo_list.append(thumb,photo.getDescription()) #------------------------------------------------------------------------- @@ -251,8 +200,6 @@ class EditPlace: # #------------------------------------------------------------------------- def load_images(self): - if len(self.place.getPhotoList()) == 0: - return self.photo_list.freeze() self.photo_list.clear() for photo in self.place.getPhotoList(): @@ -313,13 +260,7 @@ def on_place_apply_clicked(obj): edit.place.setNote(note) utils.modified() - edit.update_urls() - if edit.urls_changed: - utils.modified() - - edit.update_locations() - if edit.locations_changed: - utils.modified() + edit.update_lists() utils.destroy_passed_object(edit.top) edit.callback(edit.place) @@ -349,15 +290,12 @@ def on_photo_select_icon(obj,iconNumber,event): # #------------------------------------------------------------------------- def on_delete_photo_clicked(obj): - edit_place_obj = obj.get_data(PLACE) - icon = edit_place_obj.selectedIcon + epo = obj.get_data(PLACE) + icon = epo.selectedIcon - if icon == -1: - return - - photolist = edit_place_obj.place.getPhotoList() - edit_place_obj.photo_list.remove(icon) - del photolist[edit_place_obj.selectedIcon] + if icon != -1: + epo.photo_list.remove(icon) + del epo.place.getPhotoList()[icon] #------------------------------------------------------------------------- # @@ -367,9 +305,7 @@ def on_delete_photo_clicked(obj): def on_add_photo_clicked(obj): edit_place = obj.get_data(PLACE) - image_select = libglade.GladeXML(const.imageselFile,"imageSelect") - edit_place.isel = image_select image_select.signal_autoconnect({ @@ -399,7 +335,7 @@ def on_savephoto_clicked(obj): if os.path.exists(filename) == 0: return - prefix = "s%s" % edit_place_obj.place.getId() + prefix = "p%s" % edit_place_obj.place.getId() if edit_place_obj.external.get_active() == 1: if os.path.isfile(filename): name = filename @@ -437,28 +373,14 @@ def on_photolist_button_press_event(obj,event): menu = GtkMenu() item = GtkTearoffMenuItem() item.show() - view = GtkMenuItem(_("View Image")) - view.set_data("m",myobj) - view.connect("activate",on_view_photo) - view.show() - edit = GtkMenuItem(_("Edit Image")) - edit.set_data("m",myobj) - edit.connect("activate",on_edit_photo) - edit.show() - change = GtkMenuItem(_("Edit Description")) - change.set_data("m",myobj) - change.connect("activate",on_change_description) - change.show() menu.append(item) - menu.append(view) - menu.append(edit) - menu.append(change) + utils.add_menuitem(menu,_("View Image"),myobj,on_view_photo) + utils.add_menuitem(menu,_("Edit Image"),myobj,on_edit_photo) + utils.add_menuitem(menu,_("Edit Description"),myobj, + on_change_description) if photo.getPrivate() == 0: - private = GtkMenuItem(_("Convert to private copy")) - private.set_data("m",myobj) - private.connect("activate",on_convert_to_private) - private.show() - menu.append(private) + utils.add_menuitem(menu,_("Convert to private copy"),myobj, + on_convert_to_private) menu.popup(None,None,None,0,0) #------------------------------------------------------------------------- @@ -470,7 +392,7 @@ def on_convert_to_private(obj): edit_place_obj = obj.get_data("m") photo = edit_place_obj.place.getPhotoList()[edit_place_obj.selectedIcon] - prefix = "i%s" % edit_place_obj.place.getId() + prefix = "p%s" % edit_place_obj.place.getId() name = RelImage.import_photo(photo.getPath(),edit_place_obj.path,prefix) photo.setPath(name) @@ -484,18 +406,8 @@ def on_convert_to_private(obj): def on_view_photo(obj): myobj = obj.get_data("m") photo = myobj.place.getPhotoList()[myobj.selectedIcon] - type = gnome.mime.type(photo.getPath()) - - prog = string.split(gnome.mime.get_value(type,'view')) - args = [] - for val in prog: - if val == "%f": - args.append(photo.getPath()) - else: - args.append(val) - - if os.fork() == 0: - os.execvp(args[0],args) + + utils.view_photo(photo) #------------------------------------------------------------------------- # @@ -574,10 +486,8 @@ def on_name_changed(obj): #------------------------------------------------------------------------- def on_update_url_clicked(obj): row = obj.get_data(INDEX) - if row < 0: - return - - UrlEditor(obj.get_data(PLACE),obj.get_row_data(row)) + if row >= 0: + UrlEditor(obj.get_data(PLACE),obj.get_row_data(row)) #------------------------------------------------------------------------- # @@ -586,10 +496,8 @@ def on_update_url_clicked(obj): #------------------------------------------------------------------------- def on_update_loc_clicked(obj): row = obj.get_data(INDEX) - if row < 0: - return - - LocationEditor(obj.get_data(PLACE),obj.get_row_data(row)) + if row >= 0: + LocationEditor(obj.get_data(PLACE),obj.get_row_data(row)) #------------------------------------------------------------------------- # @@ -597,18 +505,10 @@ def on_update_loc_clicked(obj): # #------------------------------------------------------------------------- def on_delete_url_clicked(obj): - row = obj.get_data(INDEX) - if row < 0: - return - epo = obj.get_data(PLACE) - del epo.ulist[row] - - if row > len(epo.ulist)-1: - obj.set_data(INDEX,row-1) - - epo.redraw_url_list() - utils.modified() + if utils.delete_selected(obj,epo.ulist): + epo.lists_changed = 1 + epo.redraw_url_list() #------------------------------------------------------------------------- # @@ -616,18 +516,10 @@ def on_delete_url_clicked(obj): # #------------------------------------------------------------------------- def on_delete_loc_clicked(obj): - row = obj.get_data(INDEX) - if row < 0: - return - epo = obj.get_data(PLACE) - del epo.llist[row] - - if row > len(epo.llist)-1: - obj.set_data(INDEX,row-1) - - epo.redraw_location_list() - utils.modified() + if utils.delete_selected(obj,epo.llist): + epo.lists_changed = 1 + epo.redraw_location_list() #------------------------------------------------------------------------- # @@ -635,7 +527,6 @@ def on_delete_loc_clicked(obj): # #------------------------------------------------------------------------- def on_add_url_clicked(obj): - epo = obj.get_data(PLACE) UrlEditor(obj.get_data(PLACE),None) #------------------------------------------------------------------------- @@ -644,7 +535,6 @@ def on_add_url_clicked(obj): # #------------------------------------------------------------------------- def on_add_loc_clicked(obj): - epo = obj.get_data(PLACE) LocationEditor(obj.get_data(PLACE),None) #------------------------------------------------------------------------- @@ -708,14 +598,14 @@ def on_url_edit_ok_clicked(obj): ee.parent.ulist.append(url) if update_url(url,des,addr,priv): - ee.parent.urls_changed = 1 + ee.parent.lists_changed = 1 ee.parent.redraw_url_list() utils.destroy_passed_object(obj) #------------------------------------------------------------------------- # -# on_name_list_select_row - sets the row object attached to the passed +# on_web_list_select_row - sets the row object attached to the passed # object, and then updates the display with the data corresponding to # the row. # @@ -732,7 +622,7 @@ def on_web_list_select_row(obj,row,b,c): #------------------------------------------------------------------------- # -# on_name_list_select_row - sets the row object attached to the passed +# on_loclist_select_row - sets the row object attached to the passed # object, and then updates the display with the data corresponding to # the row. # @@ -750,7 +640,7 @@ def on_loc_list_select_row(obj,row,b,c): #------------------------------------------------------------------------- # -# update_attrib +# update_url # # Updates the specified event with the specified date. Compares against # the previous value, so the that modified flag is not set if nothing has @@ -776,7 +666,7 @@ def update_url(url,des,addr,priv): #------------------------------------------------------------------------- # -# update_attrib +# update_location # # Updates the specified event with the specified date. Compares against # the previous value, so the that modified flag is not set if nothing has @@ -801,21 +691,8 @@ def update_location(loc,city,county,state,country): if loc.get_country() != country: loc.set_country(country) changed = 1 - return changed -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_browse_clicked(obj): - import gnome.url - - path = obj.get()[2:] - if path != "": - gnome.url.show(path) - #------------------------------------------------------------------------- # # LocationEditor class @@ -871,60 +748,24 @@ def on_location_edit_ok_clicked(obj): ee.parent.llist.append(loc) if update_location(loc,city,county,state,country): - ee.parent.locations_changed = 1 + ee.parent.lists_changed = 1 ee.parent.redraw_location_list() utils.destroy_passed_object(obj) #------------------------------------------------------------------------- # -# on_name_list_select_row - sets the row object attached to the passed -# object, and then updates the display with the data corresponding to -# the row. +# # #------------------------------------------------------------------------- -def on_location_list_select_row(obj,row,b,c): - obj.set_data(INDEX,row) - - epo = obj.get_data(PLACE) - loc = obj.get_row_data(row) +def disp_url(url): + return [url.get_path(),url.get_description()] #------------------------------------------------------------------------- # -# +# # #------------------------------------------------------------------------- -def get_detail_flags(obj): - detail = "" - if Config.show_detail: - if obj.getNote() != "": - detail = "N" - if obj.getSourceRef().getBase(): - detail = detail + "S" - if obj.getPrivacy(): - detail = detail + "P" - return detail - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def get_detail_text(obj): - if obj.getNote() != "": - details = "%s" % _("Note") - else: - details = "" - if obj.getSourceRef().getBase() != None: - if details == "": - details = _("Source") - else: - details = "%s, %s" % (details,_("Source")) - if obj.getPrivacy() == 1: - if details == "": - details = _("Private") - else: - details = "%s, %s" % (details,_("Private")) - return details - +def disp_loc(loc): + return [loc.get_city(),loc.get_county(),loc.get_state(),loc.get_country()] diff --git a/src/EditSource.py b/src/EditSource.py index e03a04e2e..06f2ea3b4 100644 --- a/src/EditSource.py +++ b/src/EditSource.py @@ -25,7 +25,6 @@ # #------------------------------------------------------------------------- import os -import string #------------------------------------------------------------------------- # @@ -34,8 +33,6 @@ import string #------------------------------------------------------------------------- from gtk import * from gnome.ui import * -import gnome.mime - import libglade #------------------------------------------------------------------------- @@ -109,12 +106,9 @@ class EditSource: # #------------------------------------------------------------------------- def add_thumbnail(self,photo): - src = photo.getPath() - thumb = self.db.getSavePath() + os.sep + ".thumb" + os.sep + \ - os.path.basename(src) - + src = os.path.basename(photo.getPath()) + thumb = "%s%s.thumb%s%s" % (self.path,os.sep,os.sep,src) RelImage.check_thumb(src,thumb,const.thumbScale) - self.photo_list.append(thumb,photo.getDescription()) #------------------------------------------------------------------------- @@ -125,8 +119,6 @@ class EditSource: # #------------------------------------------------------------------------- def load_images(self): - if len(self.source.getPhotoList()) == 0: - return self.photo_list.freeze() self.photo_list.clear() for photo in self.source.getPhotoList(): @@ -190,15 +182,12 @@ def on_photo_select_icon(obj,iconNumber,event): # #------------------------------------------------------------------------- def on_delete_photo_clicked(obj): - edit_source_obj = obj.get_data(SOURCE) - icon = edit_source_obj.selectedIcon + eso = obj.get_data(SOURCE) + icon = eso.selectedIcon - if icon == -1: - return - - photolist = edit_source_obj.source.getPhotoList() - edit_source_obj.photo_list.remove(icon) - del photolist[edit_source_obj.selectedIcon] + if icon != -1: + eso.photo_list.remove(icon) + del eso.source.getPhotoList()[icon] #------------------------------------------------------------------------- # @@ -208,9 +197,7 @@ def on_delete_photo_clicked(obj): def on_add_photo_clicked(obj): edit_source = obj.get_data(SOURCE) - image_select = libglade.GladeXML(const.imageselFile,"imageSelect") - edit_source.isel = image_select image_select.signal_autoconnect({ @@ -231,8 +218,8 @@ def on_add_photo_clicked(obj): # #------------------------------------------------------------------------- def on_savephoto_clicked(obj): - edit_source_obj = obj.get_data(SOURCE) - image_select = edit_source_obj.isel + eso = obj.get_data(SOURCE) + image_select = eso.isel filename = image_select.get_widget("photosel").get_full_path(0) description = image_select.get_widget("photoDescription").get_text() @@ -240,14 +227,14 @@ def on_savephoto_clicked(obj): if os.path.exists(filename) == 0: return - prefix = "s%s" % edit_source_obj.source.getId() - if edit_source_obj.external.get_active() == 1: + prefix = "s%s" % eso.source.getId() + if eso.external.get_active() == 1: if os.path.isfile(filename): name = filename else: return else: - name = RelImage.import_photo(filename,edit_source_obj.path,prefix) + name = RelImage.import_photo(filename,eso.path,prefix) if name == None: return @@ -255,8 +242,8 @@ def on_savephoto_clicked(obj): photo.setPath(name) photo.setDescription(description) - edit_source_obj.source.addPhoto(photo) - edit_source_obj.add_thumbnail(photo) + eso.source.addPhoto(photo) + eso.add_thumbnail(photo) utils.modified() utils.destroy_passed_object(obj) @@ -278,28 +265,14 @@ def on_photolist_button_press_event(obj,event): menu = GtkMenu() item = GtkTearoffMenuItem() item.show() - view = GtkMenuItem(_("View Image")) - view.set_data("m",myobj) - view.connect("activate",on_view_photo) - view.show() - edit = GtkMenuItem(_("Edit Image")) - edit.set_data("m",myobj) - edit.connect("activate",on_edit_photo) - edit.show() - change = GtkMenuItem(_("Edit Description")) - change.set_data("m",myobj) - change.connect("activate",on_change_description) - change.show() menu.append(item) - menu.append(view) - menu.append(edit) - menu.append(change) + utils.add_menuitem(menu,_("View Image"),myobj,on_view_photo) + utils.add_menuitem(menu,_("Edit Image"),myobj,on_edit_photo) + utils.add_menuitem(menu,_("Edit Description"),myobj, + on_change_description) if photo.getPrivate() == 0: - private = GtkMenuItem(_("Convert to private copy")) - private.set_data("m",myobj) - private.connect("activate",on_convert_to_private) - private.show() - menu.append(private) + utils.add_menuitem(menu,_("Convert to private copy"),myobj, + on_convert_to_private) menu.popup(None,None,None,0,0) #------------------------------------------------------------------------- @@ -308,11 +281,11 @@ def on_photolist_button_press_event(obj,event): # #------------------------------------------------------------------------- def on_convert_to_private(obj): - edit_source_obj = obj.get_data("m") - photo = edit_source_obj.source.getPhotoList()[edit_source_obj.selectedIcon] + eso = obj.get_data("m") + photo = eso.source.getPhotoList()[eso.selectedIcon] - prefix = "i%s" % edit_source_obj.source.getId() - name = RelImage.import_photo(photo.getPath(),edit_source_obj.path,prefix) + prefix = "s%s" % eso.source.getId() + name = RelImage.import_photo(photo.getPath(),eso.path,prefix) photo.setPath(name) photo.setPrivate(1) @@ -325,18 +298,8 @@ def on_convert_to_private(obj): def on_view_photo(obj): myobj = obj.get_data("m") photo = myobj.source.getPhotoList()[myobj.selectedIcon] - type = gnome.mime.type(photo.getPath()) - - prog = string.split(gnome.mime.get_value(type,'view')) - args = [] - for val in prog: - if val == "%f": - args.append(photo.getPath()) - else: - args.append(val) - - if os.fork() == 0: - os.execvp(args[0],args) + + utils.view_photo(photo) #------------------------------------------------------------------------- # diff --git a/src/Filter.py b/src/Filter.py index 7df2f4812..015c193cf 100644 --- a/src/Filter.py +++ b/src/Filter.py @@ -27,6 +27,7 @@ import re import os import sys import intl +import gtk _ = intl.gettext @@ -85,32 +86,21 @@ class Filter: #------------------------------------------------------------------------- # -# create - creates a new filter object from the passed data. Eliminates -# the need to know the name of the class. +# # #------------------------------------------------------------------------- -def create(text): - return Filter(text) + +_filter_list = [(Filter, _("All people"), 0)] + +def register_filter(class_name, description=None, qualifier=0): + if description == None: + description = _("No description") + _filter_list.append((class_name,description,qualifier)) #------------------------------------------------------------------------- # -# need_qualifier - indicates if another parameter is needed. Used to -# enable or disable the qualifier field on the display -# -#------------------------------------------------------------------------- -def need_qualifier(): - return 0 - -filterList = [ _("All people") ] -filterMap = { _("All people") : create } -filterEnb = { _("All people") : need_qualifier } - -#------------------------------------------------------------------------- -# -# load_filters - loads all filters in the specfied directory. Looks for -# a task named "create". The create and need_qualifer tasks are loaded in -# hash tables so that the filter description can be used to retrieve the -# create and need_qualifier functions +# load_filters - loads all filters in the specfied directory. Assumes +# that the filters will register themselves # #------------------------------------------------------------------------- def load_filters(dir): @@ -123,23 +113,29 @@ def load_filters(dir): for file in os.listdir(dir): name = os.path.split(file) match = pymod.match(name[1]) - if match == None: - continue - groups = match.groups() - try: - plugin = __import__(groups[0]) - except: - continue + if match: + groups = match.groups() + try: + plugin = __import__(groups[0]) + except: + print _("Failed to load the module: %s") % groups[0] + import traceback + traceback.print_exc() - if plugin.__dict__.has_key("get_name"): - name = plugin.get_name() - else: - name = plugin.__doc__ +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def build_filter_menu(callback): + myMenu = gtk.GtkMenu() + for filter in _filter_list: + menuitem = gtk.GtkMenuItem(filter[1]) + myMenu.append(menuitem) + menuitem.set_data("filter",filter[0]) + menuitem.set_data("qual",filter[2]) + menuitem.connect("activate",callback) + menuitem.show() + return myMenu - if plugin.__dict__.has_key("create"): - filterMap[name] = plugin.create - filterList.append(name) - if plugin.__dict__.has_key("need_qualifier"): - filterEnb[name] = plugin.need_qualifier - diff --git a/src/FindDoc.py b/src/FindDoc.py index ba917fec6..42a614f95 100644 --- a/src/FindDoc.py +++ b/src/FindDoc.py @@ -110,7 +110,7 @@ except: try: import LaTeXDoc - _textdoc.append((_LATEX, _has_tables, _paper, _no_styles)) + _textdoc.append((_LATEX, _no_tables, _paper, _no_styles)) except: pass diff --git a/src/FontScale.py b/src/FontScale.py index 0ea43ffc9..b6de44cdd 100644 --- a/src/FontScale.py +++ b/src/FontScale.py @@ -1,222 +1,254 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2001 Donald N. Allingham +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# _swiss = [ -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.278, 0.278, 0.355, 0.556, 0.556, 0.889, 0.667, 0.191, -0.333, 0.333, 0.389, 0.584, 0.278, 0.333, 0.278, 0.278, 0.556, 0.556, -0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.278, 0.278, -0.584, 0.584, 0.584, 0.556, 1.015, 0.667, 0.667, 0.722, 0.722, 0.667, -0.611, 0.778, 0.722, 0.278, 0.500, 0.667, 0.556, 0.833, 0.722, 0.778, -0.667, 0.778, 0.722, 0.667, 0.611, 0.722, 0.667, 0.944, 0.667, 0.667, -0.611, 0.278, 0.278, 0.278, 0.469, 0.556, 0.333, 0.556, 0.556, 0.500, -0.556, 0.556, 0.278, 0.556, 0.556, 0.222, 0.222, 0.500, 0.222, 0.833, -0.556, 0.556, 0.556, 0.556, 0.333, 0.500, 0.278, 0.556, 0.500, 0.722, -0.500, 0.500, 0.500, 0.334, 0.260, 0.334, 0.584, 0.350, 0.556, 0.350, -0.222, 0.556, 0.333, 1.000, 0.556, 0.556, 0.333, 1.000, 0.667, 0.333, -1.000, 0.350, 0.611, 0.350, 0.350, 0.222, 0.222, 0.333, 0.333, 0.350, -0.556, 1.000, 0.333, 1.000, 0.500, 0.333, 0.944, 0.350, 0.500, 0.667, -0.278, 0.333, 0.556, 0.556, 0.556, 0.556, 0.260, 0.556, 0.333, 0.737, -0.370, 0.556, 0.584, 0.333, 0.737, 0.333, 0.400, 0.584, 0.333, 0.333, -0.333, 0.556, 0.537, 0.278, 0.333, 0.333, 0.365, 0.556, 0.834, 0.834, -0.834, 0.611, 0.667, 0.667, 0.667, 0.667, 0.667, 0.667, 1.000, 0.722, -0.667, 0.667, 0.667, 0.667, 0.278, 0.278, 0.278, 0.278, 0.722, 0.722, -0.778, 0.778, 0.778, 0.778, 0.778, 0.584, 0.778, 0.722, 0.722, 0.722, -0.722, 0.667, 0.667, 0.611, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, -0.889, 0.500, 0.556, 0.556, 0.556, 0.556, 0.278, 0.278, 0.278, 0.278, -0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.584, 0.611, 0.556, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.278, 0.278, 0.355, 0.556, 0.556, 0.889, 0.667, 0.191, +0.333, 0.333, 0.389, 0.584, 0.278, 0.333, 0.278, 0.278, 0.556, 0.556, +0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.278, 0.278, +0.584, 0.584, 0.584, 0.556, 1.015, 0.667, 0.667, 0.722, 0.722, 0.667, +0.611, 0.778, 0.722, 0.278, 0.500, 0.667, 0.556, 0.833, 0.722, 0.778, +0.667, 0.778, 0.722, 0.667, 0.611, 0.722, 0.667, 0.944, 0.667, 0.667, +0.611, 0.278, 0.278, 0.278, 0.469, 0.556, 0.333, 0.556, 0.556, 0.500, +0.556, 0.556, 0.278, 0.556, 0.556, 0.222, 0.222, 0.500, 0.222, 0.833, +0.556, 0.556, 0.556, 0.556, 0.333, 0.500, 0.278, 0.556, 0.500, 0.722, +0.500, 0.500, 0.500, 0.334, 0.260, 0.334, 0.584, 0.350, 0.556, 0.350, +0.222, 0.556, 0.333, 1.000, 0.556, 0.556, 0.333, 1.000, 0.667, 0.333, +1.000, 0.350, 0.611, 0.350, 0.350, 0.222, 0.222, 0.333, 0.333, 0.350, +0.556, 1.000, 0.333, 1.000, 0.500, 0.333, 0.944, 0.350, 0.500, 0.667, +0.278, 0.333, 0.556, 0.556, 0.556, 0.556, 0.260, 0.556, 0.333, 0.737, +0.370, 0.556, 0.584, 0.333, 0.737, 0.333, 0.400, 0.584, 0.333, 0.333, +0.333, 0.556, 0.537, 0.278, 0.333, 0.333, 0.365, 0.556, 0.834, 0.834, +0.834, 0.611, 0.667, 0.667, 0.667, 0.667, 0.667, 0.667, 1.000, 0.722, +0.667, 0.667, 0.667, 0.667, 0.278, 0.278, 0.278, 0.278, 0.722, 0.722, +0.778, 0.778, 0.778, 0.778, 0.778, 0.584, 0.778, 0.722, 0.722, 0.722, +0.722, 0.667, 0.667, 0.611, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, +0.889, 0.500, 0.556, 0.556, 0.556, 0.556, 0.278, 0.278, 0.278, 0.278, +0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.584, 0.611, 0.556, 0.556, 0.556, 0.556, 0.500, 0.556, 0.500] + _swiss_b = [ -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.278, 0.333, 0.474, 0.556, 0.556, 0.889, 0.722, 0.238, -0.333, 0.333, 0.389, 0.584, 0.278, 0.333, 0.278, 0.278, 0.556, 0.556, -0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.333, 0.333, -0.584, 0.584, 0.584, 0.611, 0.975, 0.722, 0.722, 0.722, 0.722, 0.667, -0.611, 0.778, 0.722, 0.278, 0.556, 0.722, 0.611, 0.833, 0.722, 0.778, -0.667, 0.778, 0.722, 0.667, 0.611, 0.722, 0.667, 0.944, 0.667, 0.667, -0.611, 0.333, 0.278, 0.333, 0.584, 0.556, 0.333, 0.556, 0.611, 0.556, -0.611, 0.556, 0.333, 0.611, 0.611, 0.278, 0.278, 0.556, 0.278, 0.889, -0.611, 0.611, 0.611, 0.611, 0.389, 0.556, 0.333, 0.611, 0.556, 0.778, -0.556, 0.556, 0.500, 0.389, 0.280, 0.389, 0.584, 0.350, 0.556, 0.350, -0.278, 0.556, 0.500, 1.000, 0.556, 0.556, 0.333, 1.000, 0.667, 0.333, -1.000, 0.350, 0.611, 0.350, 0.350, 0.278, 0.278, 0.500, 0.500, 0.350, -0.556, 1.000, 0.333, 1.000, 0.556, 0.333, 0.944, 0.350, 0.500, 0.667, -0.278, 0.333, 0.556, 0.556, 0.556, 0.556, 0.280, 0.556, 0.333, 0.737, -0.370, 0.556, 0.584, 0.333, 0.737, 0.333, 0.400, 0.584, 0.333, 0.333, -0.333, 0.611, 0.556, 0.278, 0.333, 0.333, 0.365, 0.556, 0.834, 0.834, -0.834, 0.611, 0.722, 0.722, 0.722, 0.722, 0.722, 0.722, 1.000, 0.722, -0.667, 0.667, 0.667, 0.667, 0.278, 0.278, 0.278, 0.278, 0.722, 0.722, -0.778, 0.778, 0.778, 0.778, 0.778, 0.584, 0.778, 0.722, 0.722, 0.722, -0.722, 0.667, 0.667, 0.611, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, -0.889, 0.556, 0.556, 0.556, 0.556, 0.556, 0.278, 0.278, 0.278, 0.278, -0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.584, 0.611, 0.611, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.278, 0.333, 0.474, 0.556, 0.556, 0.889, 0.722, 0.238, +0.333, 0.333, 0.389, 0.584, 0.278, 0.333, 0.278, 0.278, 0.556, 0.556, +0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.333, 0.333, +0.584, 0.584, 0.584, 0.611, 0.975, 0.722, 0.722, 0.722, 0.722, 0.667, +0.611, 0.778, 0.722, 0.278, 0.556, 0.722, 0.611, 0.833, 0.722, 0.778, +0.667, 0.778, 0.722, 0.667, 0.611, 0.722, 0.667, 0.944, 0.667, 0.667, +0.611, 0.333, 0.278, 0.333, 0.584, 0.556, 0.333, 0.556, 0.611, 0.556, +0.611, 0.556, 0.333, 0.611, 0.611, 0.278, 0.278, 0.556, 0.278, 0.889, +0.611, 0.611, 0.611, 0.611, 0.389, 0.556, 0.333, 0.611, 0.556, 0.778, +0.556, 0.556, 0.500, 0.389, 0.280, 0.389, 0.584, 0.350, 0.556, 0.350, +0.278, 0.556, 0.500, 1.000, 0.556, 0.556, 0.333, 1.000, 0.667, 0.333, +1.000, 0.350, 0.611, 0.350, 0.350, 0.278, 0.278, 0.500, 0.500, 0.350, +0.556, 1.000, 0.333, 1.000, 0.556, 0.333, 0.944, 0.350, 0.500, 0.667, +0.278, 0.333, 0.556, 0.556, 0.556, 0.556, 0.280, 0.556, 0.333, 0.737, +0.370, 0.556, 0.584, 0.333, 0.737, 0.333, 0.400, 0.584, 0.333, 0.333, +0.333, 0.611, 0.556, 0.278, 0.333, 0.333, 0.365, 0.556, 0.834, 0.834, +0.834, 0.611, 0.722, 0.722, 0.722, 0.722, 0.722, 0.722, 1.000, 0.722, +0.667, 0.667, 0.667, 0.667, 0.278, 0.278, 0.278, 0.278, 0.722, 0.722, +0.778, 0.778, 0.778, 0.778, 0.778, 0.584, 0.778, 0.722, 0.722, 0.722, +0.722, 0.667, 0.667, 0.611, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, +0.889, 0.556, 0.556, 0.556, 0.556, 0.556, 0.278, 0.278, 0.278, 0.278, +0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.584, 0.611, 0.611, 0.611, 0.611, 0.611, 0.556, 0.611, 0.556] + _swiss_i = [ -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.278, 0.278, 0.355, 0.556, 0.556, 0.889, 0.667, 0.191, -0.333, 0.333, 0.389, 0.584, 0.278, 0.333, 0.278, 0.278, 0.556, 0.556, -0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.278, 0.278, -0.584, 0.584, 0.584, 0.556, 1.015, 0.667, 0.667, 0.722, 0.722, 0.667, -0.611, 0.778, 0.722, 0.278, 0.500, 0.667, 0.556, 0.833, 0.722, 0.778, -0.667, 0.778, 0.722, 0.667, 0.611, 0.722, 0.667, 0.944, 0.667, 0.667, -0.611, 0.278, 0.278, 0.278, 0.469, 0.556, 0.333, 0.556, 0.556, 0.500, -0.556, 0.556, 0.278, 0.556, 0.556, 0.222, 0.222, 0.500, 0.222, 0.833, -0.556, 0.556, 0.556, 0.556, 0.333, 0.500, 0.278, 0.556, 0.500, 0.722, -0.500, 0.500, 0.500, 0.334, 0.260, 0.334, 0.584, 0.350, 0.556, 0.350, -0.222, 0.556, 0.333, 1.000, 0.556, 0.556, 0.333, 1.000, 0.667, 0.333, -1.000, 0.350, 0.611, 0.350, 0.350, 0.222, 0.222, 0.333, 0.333, 0.350, -0.556, 1.000, 0.333, 1.000, 0.500, 0.333, 0.944, 0.350, 0.500, 0.667, -0.278, 0.333, 0.556, 0.556, 0.556, 0.556, 0.260, 0.556, 0.333, 0.737, -0.370, 0.556, 0.584, 0.333, 0.737, 0.333, 0.400, 0.584, 0.333, 0.333, -0.333, 0.556, 0.537, 0.278, 0.333, 0.333, 0.365, 0.556, 0.834, 0.834, -0.834, 0.611, 0.667, 0.667, 0.667, 0.667, 0.667, 0.667, 1.000, 0.722, -0.667, 0.667, 0.667, 0.667, 0.278, 0.278, 0.278, 0.278, 0.722, 0.722, -0.778, 0.778, 0.778, 0.778, 0.778, 0.584, 0.778, 0.722, 0.722, 0.722, -0.722, 0.667, 0.667, 0.611, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, -0.889, 0.500, 0.556, 0.556, 0.556, 0.556, 0.278, 0.278, 0.278, 0.278, -0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.584, 0.611, 0.556, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.278, 0.278, 0.355, 0.556, 0.556, 0.889, 0.667, 0.191, +0.333, 0.333, 0.389, 0.584, 0.278, 0.333, 0.278, 0.278, 0.556, 0.556, +0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.278, 0.278, +0.584, 0.584, 0.584, 0.556, 1.015, 0.667, 0.667, 0.722, 0.722, 0.667, +0.611, 0.778, 0.722, 0.278, 0.500, 0.667, 0.556, 0.833, 0.722, 0.778, +0.667, 0.778, 0.722, 0.667, 0.611, 0.722, 0.667, 0.944, 0.667, 0.667, +0.611, 0.278, 0.278, 0.278, 0.469, 0.556, 0.333, 0.556, 0.556, 0.500, +0.556, 0.556, 0.278, 0.556, 0.556, 0.222, 0.222, 0.500, 0.222, 0.833, +0.556, 0.556, 0.556, 0.556, 0.333, 0.500, 0.278, 0.556, 0.500, 0.722, +0.500, 0.500, 0.500, 0.334, 0.260, 0.334, 0.584, 0.350, 0.556, 0.350, +0.222, 0.556, 0.333, 1.000, 0.556, 0.556, 0.333, 1.000, 0.667, 0.333, +1.000, 0.350, 0.611, 0.350, 0.350, 0.222, 0.222, 0.333, 0.333, 0.350, +0.556, 1.000, 0.333, 1.000, 0.500, 0.333, 0.944, 0.350, 0.500, 0.667, +0.278, 0.333, 0.556, 0.556, 0.556, 0.556, 0.260, 0.556, 0.333, 0.737, +0.370, 0.556, 0.584, 0.333, 0.737, 0.333, 0.400, 0.584, 0.333, 0.333, +0.333, 0.556, 0.537, 0.278, 0.333, 0.333, 0.365, 0.556, 0.834, 0.834, +0.834, 0.611, 0.667, 0.667, 0.667, 0.667, 0.667, 0.667, 1.000, 0.722, +0.667, 0.667, 0.667, 0.667, 0.278, 0.278, 0.278, 0.278, 0.722, 0.722, +0.778, 0.778, 0.778, 0.778, 0.778, 0.584, 0.778, 0.722, 0.722, 0.722, +0.722, 0.667, 0.667, 0.611, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, +0.889, 0.500, 0.556, 0.556, 0.556, 0.556, 0.278, 0.278, 0.278, 0.278, +0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.584, 0.611, 0.556, 0.556, 0.556, 0.556, 0.500, 0.556, 0.500] + _swiss_bi = [ -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.278, 0.333, 0.474, 0.556, 0.556, 0.889, 0.722, 0.238, -0.333, 0.333, 0.389, 0.584, 0.278, 0.333, 0.278, 0.278, 0.556, 0.556, -0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.333, 0.333, -0.584, 0.584, 0.584, 0.611, 0.975, 0.722, 0.722, 0.722, 0.722, 0.667, -0.611, 0.778, 0.722, 0.278, 0.556, 0.722, 0.611, 0.833, 0.722, 0.778, -0.667, 0.778, 0.722, 0.667, 0.611, 0.722, 0.667, 0.944, 0.667, 0.667, -0.611, 0.333, 0.278, 0.333, 0.584, 0.556, 0.333, 0.556, 0.611, 0.556, -0.611, 0.556, 0.333, 0.611, 0.611, 0.278, 0.278, 0.556, 0.278, 0.889, -0.611, 0.611, 0.611, 0.611, 0.389, 0.556, 0.333, 0.611, 0.556, 0.778, -0.556, 0.556, 0.500, 0.389, 0.280, 0.389, 0.584, 0.350, 0.556, 0.350, -0.278, 0.556, 0.500, 1.000, 0.556, 0.556, 0.333, 1.000, 0.667, 0.333, -1.000, 0.350, 0.611, 0.350, 0.350, 0.278, 0.278, 0.500, 0.500, 0.350, -0.556, 1.000, 0.333, 1.000, 0.556, 0.333, 0.944, 0.350, 0.500, 0.667, -0.278, 0.333, 0.556, 0.556, 0.556, 0.556, 0.280, 0.556, 0.333, 0.737, -0.370, 0.556, 0.584, 0.333, 0.737, 0.333, 0.400, 0.584, 0.333, 0.333, -0.333, 0.611, 0.556, 0.278, 0.333, 0.333, 0.365, 0.556, 0.834, 0.834, -0.834, 0.611, 0.722, 0.722, 0.722, 0.722, 0.722, 0.722, 1.000, 0.722, -0.667, 0.667, 0.667, 0.667, 0.278, 0.278, 0.278, 0.278, 0.722, 0.722, -0.778, 0.778, 0.778, 0.778, 0.778, 0.584, 0.778, 0.722, 0.722, 0.722, -0.722, 0.667, 0.667, 0.611, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, -0.889, 0.556, 0.556, 0.556, 0.556, 0.556, 0.278, 0.278, 0.278, 0.278, -0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.584, 0.611, 0.611, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.278, 0.333, 0.474, 0.556, 0.556, 0.889, 0.722, 0.238, +0.333, 0.333, 0.389, 0.584, 0.278, 0.333, 0.278, 0.278, 0.556, 0.556, +0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, 0.333, 0.333, +0.584, 0.584, 0.584, 0.611, 0.975, 0.722, 0.722, 0.722, 0.722, 0.667, +0.611, 0.778, 0.722, 0.278, 0.556, 0.722, 0.611, 0.833, 0.722, 0.778, +0.667, 0.778, 0.722, 0.667, 0.611, 0.722, 0.667, 0.944, 0.667, 0.667, +0.611, 0.333, 0.278, 0.333, 0.584, 0.556, 0.333, 0.556, 0.611, 0.556, +0.611, 0.556, 0.333, 0.611, 0.611, 0.278, 0.278, 0.556, 0.278, 0.889, +0.611, 0.611, 0.611, 0.611, 0.389, 0.556, 0.333, 0.611, 0.556, 0.778, +0.556, 0.556, 0.500, 0.389, 0.280, 0.389, 0.584, 0.350, 0.556, 0.350, +0.278, 0.556, 0.500, 1.000, 0.556, 0.556, 0.333, 1.000, 0.667, 0.333, +1.000, 0.350, 0.611, 0.350, 0.350, 0.278, 0.278, 0.500, 0.500, 0.350, +0.556, 1.000, 0.333, 1.000, 0.556, 0.333, 0.944, 0.350, 0.500, 0.667, +0.278, 0.333, 0.556, 0.556, 0.556, 0.556, 0.280, 0.556, 0.333, 0.737, +0.370, 0.556, 0.584, 0.333, 0.737, 0.333, 0.400, 0.584, 0.333, 0.333, +0.333, 0.611, 0.556, 0.278, 0.333, 0.333, 0.365, 0.556, 0.834, 0.834, +0.834, 0.611, 0.722, 0.722, 0.722, 0.722, 0.722, 0.722, 1.000, 0.722, +0.667, 0.667, 0.667, 0.667, 0.278, 0.278, 0.278, 0.278, 0.722, 0.722, +0.778, 0.778, 0.778, 0.778, 0.778, 0.584, 0.778, 0.722, 0.722, 0.722, +0.722, 0.667, 0.667, 0.611, 0.556, 0.556, 0.556, 0.556, 0.556, 0.556, +0.889, 0.556, 0.556, 0.556, 0.556, 0.556, 0.278, 0.278, 0.278, 0.278, +0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.584, 0.611, 0.611, 0.611, 0.611, 0.611, 0.556, 0.611, 0.556] + _roman = [ -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.250, 0.333, 0.408, 0.500, 0.500, 0.833, 0.778, 0.180, -0.333, 0.333, 0.500, 0.564, 0.250, 0.333, 0.250, 0.278, 0.500, 0.500, -0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.278, 0.278, -0.564, 0.564, 0.564, 0.444, 0.921, 0.722, 0.667, 0.667, 0.722, 0.611, -0.556, 0.722, 0.722, 0.333, 0.389, 0.722, 0.611, 0.889, 0.722, 0.722, -0.556, 0.722, 0.667, 0.556, 0.611, 0.722, 0.722, 0.944, 0.722, 0.722, -0.611, 0.333, 0.278, 0.333, 0.469, 0.500, 0.333, 0.444, 0.500, 0.444, -0.500, 0.444, 0.333, 0.500, 0.500, 0.278, 0.278, 0.500, 0.278, 0.778, -0.500, 0.500, 0.500, 0.500, 0.333, 0.389, 0.278, 0.500, 0.500, 0.722, -0.500, 0.500, 0.444, 0.480, 0.200, 0.480, 0.541, 0.350, 0.500, 0.350, -0.333, 0.500, 0.444, 1.000, 0.500, 0.500, 0.333, 1.000, 0.556, 0.333, -0.889, 0.350, 0.611, 0.350, 0.350, 0.333, 0.333, 0.444, 0.444, 0.350, -0.500, 1.000, 0.333, 0.980, 0.389, 0.333, 0.722, 0.350, 0.444, 0.722, -0.250, 0.333, 0.500, 0.500, 0.500, 0.500, 0.200, 0.500, 0.333, 0.760, -0.276, 0.500, 0.564, 0.333, 0.760, 0.333, 0.400, 0.564, 0.300, 0.300, -0.333, 0.500, 0.453, 0.250, 0.333, 0.300, 0.310, 0.500, 0.750, 0.750, -0.750, 0.444, 0.722, 0.722, 0.722, 0.722, 0.722, 0.722, 0.889, 0.667, -0.611, 0.611, 0.611, 0.611, 0.333, 0.333, 0.333, 0.333, 0.722, 0.722, -0.722, 0.722, 0.722, 0.722, 0.722, 0.564, 0.722, 0.722, 0.722, 0.722, -0.722, 0.722, 0.556, 0.500, 0.444, 0.444, 0.444, 0.444, 0.444, 0.444, -0.667, 0.444, 0.444, 0.444, 0.444, 0.444, 0.278, 0.278, 0.278, 0.278, -0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.564, 0.500, 0.500, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.250, 0.333, 0.408, 0.500, 0.500, 0.833, 0.778, 0.180, +0.333, 0.333, 0.500, 0.564, 0.250, 0.333, 0.250, 0.278, 0.500, 0.500, +0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.278, 0.278, +0.564, 0.564, 0.564, 0.444, 0.921, 0.722, 0.667, 0.667, 0.722, 0.611, +0.556, 0.722, 0.722, 0.333, 0.389, 0.722, 0.611, 0.889, 0.722, 0.722, +0.556, 0.722, 0.667, 0.556, 0.611, 0.722, 0.722, 0.944, 0.722, 0.722, +0.611, 0.333, 0.278, 0.333, 0.469, 0.500, 0.333, 0.444, 0.500, 0.444, +0.500, 0.444, 0.333, 0.500, 0.500, 0.278, 0.278, 0.500, 0.278, 0.778, +0.500, 0.500, 0.500, 0.500, 0.333, 0.389, 0.278, 0.500, 0.500, 0.722, +0.500, 0.500, 0.444, 0.480, 0.200, 0.480, 0.541, 0.350, 0.500, 0.350, +0.333, 0.500, 0.444, 1.000, 0.500, 0.500, 0.333, 1.000, 0.556, 0.333, +0.889, 0.350, 0.611, 0.350, 0.350, 0.333, 0.333, 0.444, 0.444, 0.350, +0.500, 1.000, 0.333, 0.980, 0.389, 0.333, 0.722, 0.350, 0.444, 0.722, +0.250, 0.333, 0.500, 0.500, 0.500, 0.500, 0.200, 0.500, 0.333, 0.760, +0.276, 0.500, 0.564, 0.333, 0.760, 0.333, 0.400, 0.564, 0.300, 0.300, +0.333, 0.500, 0.453, 0.250, 0.333, 0.300, 0.310, 0.500, 0.750, 0.750, +0.750, 0.444, 0.722, 0.722, 0.722, 0.722, 0.722, 0.722, 0.889, 0.667, +0.611, 0.611, 0.611, 0.611, 0.333, 0.333, 0.333, 0.333, 0.722, 0.722, +0.722, 0.722, 0.722, 0.722, 0.722, 0.564, 0.722, 0.722, 0.722, 0.722, +0.722, 0.722, 0.556, 0.500, 0.444, 0.444, 0.444, 0.444, 0.444, 0.444, +0.667, 0.444, 0.444, 0.444, 0.444, 0.444, 0.278, 0.278, 0.278, 0.278, +0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.564, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500] + _roman_b = [ -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.250, 0.333, 0.555, 0.500, 0.500, 1.000, 0.833, 0.278, -0.333, 0.333, 0.500, 0.570, 0.250, 0.333, 0.250, 0.278, 0.500, 0.500, -0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.333, 0.333, -0.570, 0.570, 0.570, 0.500, 0.930, 0.722, 0.667, 0.722, 0.722, 0.667, -0.611, 0.778, 0.778, 0.389, 0.500, 0.778, 0.667, 0.944, 0.722, 0.778, -0.611, 0.778, 0.722, 0.556, 0.667, 0.722, 0.722, 1.000, 0.722, 0.722, -0.667, 0.333, 0.278, 0.333, 0.581, 0.500, 0.333, 0.500, 0.556, 0.444, -0.556, 0.444, 0.333, 0.500, 0.556, 0.278, 0.333, 0.556, 0.278, 0.833, -0.556, 0.500, 0.556, 0.556, 0.444, 0.389, 0.333, 0.556, 0.500, 0.722, -0.500, 0.500, 0.444, 0.394, 0.220, 0.394, 0.520, 0.350, 0.500, 0.350, -0.333, 0.500, 0.500, 1.000, 0.500, 0.500, 0.333, 1.000, 0.556, 0.333, -1.000, 0.350, 0.667, 0.350, 0.350, 0.333, 0.333, 0.500, 0.500, 0.350, -0.500, 1.000, 0.333, 1.000, 0.389, 0.333, 0.722, 0.350, 0.444, 0.722, -0.250, 0.333, 0.500, 0.500, 0.500, 0.500, 0.220, 0.500, 0.333, 0.747, -0.300, 0.500, 0.570, 0.333, 0.747, 0.333, 0.400, 0.570, 0.300, 0.300, -0.333, 0.556, 0.540, 0.250, 0.333, 0.300, 0.330, 0.500, 0.750, 0.750, -0.750, 0.500, 0.722, 0.722, 0.722, 0.722, 0.722, 0.722, 1.000, 0.722, -0.667, 0.667, 0.667, 0.667, 0.389, 0.389, 0.389, 0.389, 0.722, 0.722, -0.778, 0.778, 0.778, 0.778, 0.778, 0.570, 0.778, 0.722, 0.722, 0.722, -0.722, 0.722, 0.611, 0.556, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, -0.722, 0.444, 0.444, 0.444, 0.444, 0.444, 0.278, 0.278, 0.278, 0.278, -0.500, 0.556, 0.500, 0.500, 0.500, 0.500, 0.500, 0.570, 0.500, 0.556, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.250, 0.333, 0.555, 0.500, 0.500, 1.000, 0.833, 0.278, +0.333, 0.333, 0.500, 0.570, 0.250, 0.333, 0.250, 0.278, 0.500, 0.500, +0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.333, 0.333, +0.570, 0.570, 0.570, 0.500, 0.930, 0.722, 0.667, 0.722, 0.722, 0.667, +0.611, 0.778, 0.778, 0.389, 0.500, 0.778, 0.667, 0.944, 0.722, 0.778, +0.611, 0.778, 0.722, 0.556, 0.667, 0.722, 0.722, 1.000, 0.722, 0.722, +0.667, 0.333, 0.278, 0.333, 0.581, 0.500, 0.333, 0.500, 0.556, 0.444, +0.556, 0.444, 0.333, 0.500, 0.556, 0.278, 0.333, 0.556, 0.278, 0.833, +0.556, 0.500, 0.556, 0.556, 0.444, 0.389, 0.333, 0.556, 0.500, 0.722, +0.500, 0.500, 0.444, 0.394, 0.220, 0.394, 0.520, 0.350, 0.500, 0.350, +0.333, 0.500, 0.500, 1.000, 0.500, 0.500, 0.333, 1.000, 0.556, 0.333, +1.000, 0.350, 0.667, 0.350, 0.350, 0.333, 0.333, 0.500, 0.500, 0.350, +0.500, 1.000, 0.333, 1.000, 0.389, 0.333, 0.722, 0.350, 0.444, 0.722, +0.250, 0.333, 0.500, 0.500, 0.500, 0.500, 0.220, 0.500, 0.333, 0.747, +0.300, 0.500, 0.570, 0.333, 0.747, 0.333, 0.400, 0.570, 0.300, 0.300, +0.333, 0.556, 0.540, 0.250, 0.333, 0.300, 0.330, 0.500, 0.750, 0.750, +0.750, 0.500, 0.722, 0.722, 0.722, 0.722, 0.722, 0.722, 1.000, 0.722, +0.667, 0.667, 0.667, 0.667, 0.389, 0.389, 0.389, 0.389, 0.722, 0.722, +0.778, 0.778, 0.778, 0.778, 0.778, 0.570, 0.778, 0.722, 0.722, 0.722, +0.722, 0.722, 0.611, 0.556, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, +0.722, 0.444, 0.444, 0.444, 0.444, 0.444, 0.278, 0.278, 0.278, 0.278, +0.500, 0.556, 0.500, 0.500, 0.500, 0.500, 0.500, 0.570, 0.500, 0.556, 0.556, 0.556, 0.556, 0.500, 0.556, 0.500] + _roman_i = [ -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.250, 0.333, 0.420, 0.500, 0.500, 0.833, 0.778, 0.214, -0.333, 0.333, 0.500, 0.675, 0.250, 0.333, 0.250, 0.278, 0.500, 0.500, -0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.333, 0.333, -0.675, 0.675, 0.675, 0.500, 0.920, 0.611, 0.611, 0.667, 0.722, 0.611, -0.611, 0.722, 0.722, 0.333, 0.444, 0.667, 0.556, 0.833, 0.667, 0.722, -0.611, 0.722, 0.611, 0.500, 0.556, 0.722, 0.611, 0.833, 0.611, 0.556, -0.556, 0.389, 0.278, 0.389, 0.422, 0.500, 0.333, 0.500, 0.500, 0.444, -0.500, 0.444, 0.278, 0.500, 0.500, 0.278, 0.278, 0.444, 0.278, 0.722, -0.500, 0.500, 0.500, 0.500, 0.389, 0.389, 0.278, 0.500, 0.444, 0.667, -0.444, 0.444, 0.389, 0.400, 0.275, 0.400, 0.541, 0.350, 0.500, 0.350, -0.333, 0.500, 0.556, 0.889, 0.500, 0.500, 0.333, 1.000, 0.500, 0.333, -0.944, 0.350, 0.556, 0.350, 0.350, 0.333, 0.333, 0.556, 0.556, 0.350, -0.500, 0.889, 0.333, 0.980, 0.389, 0.333, 0.667, 0.350, 0.389, 0.556, -0.250, 0.389, 0.500, 0.500, 0.500, 0.500, 0.275, 0.500, 0.333, 0.760, -0.276, 0.500, 0.675, 0.333, 0.760, 0.333, 0.400, 0.675, 0.300, 0.300, -0.333, 0.500, 0.523, 0.250, 0.333, 0.300, 0.310, 0.500, 0.750, 0.750, -0.750, 0.500, 0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.889, 0.667, -0.611, 0.611, 0.611, 0.611, 0.333, 0.333, 0.333, 0.333, 0.722, 0.667, -0.722, 0.722, 0.722, 0.722, 0.722, 0.675, 0.722, 0.722, 0.722, 0.722, -0.722, 0.556, 0.611, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, -0.667, 0.444, 0.444, 0.444, 0.444, 0.444, 0.278, 0.278, 0.278, 0.278, -0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.675, 0.500, 0.500, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.250, 0.333, 0.420, 0.500, 0.500, 0.833, 0.778, 0.214, +0.333, 0.333, 0.500, 0.675, 0.250, 0.333, 0.250, 0.278, 0.500, 0.500, +0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.333, 0.333, +0.675, 0.675, 0.675, 0.500, 0.920, 0.611, 0.611, 0.667, 0.722, 0.611, +0.611, 0.722, 0.722, 0.333, 0.444, 0.667, 0.556, 0.833, 0.667, 0.722, +0.611, 0.722, 0.611, 0.500, 0.556, 0.722, 0.611, 0.833, 0.611, 0.556, +0.556, 0.389, 0.278, 0.389, 0.422, 0.500, 0.333, 0.500, 0.500, 0.444, +0.500, 0.444, 0.278, 0.500, 0.500, 0.278, 0.278, 0.444, 0.278, 0.722, +0.500, 0.500, 0.500, 0.500, 0.389, 0.389, 0.278, 0.500, 0.444, 0.667, +0.444, 0.444, 0.389, 0.400, 0.275, 0.400, 0.541, 0.350, 0.500, 0.350, +0.333, 0.500, 0.556, 0.889, 0.500, 0.500, 0.333, 1.000, 0.500, 0.333, +0.944, 0.350, 0.556, 0.350, 0.350, 0.333, 0.333, 0.556, 0.556, 0.350, +0.500, 0.889, 0.333, 0.980, 0.389, 0.333, 0.667, 0.350, 0.389, 0.556, +0.250, 0.389, 0.500, 0.500, 0.500, 0.500, 0.275, 0.500, 0.333, 0.760, +0.276, 0.500, 0.675, 0.333, 0.760, 0.333, 0.400, 0.675, 0.300, 0.300, +0.333, 0.500, 0.523, 0.250, 0.333, 0.300, 0.310, 0.500, 0.750, 0.750, +0.750, 0.500, 0.611, 0.611, 0.611, 0.611, 0.611, 0.611, 0.889, 0.667, +0.611, 0.611, 0.611, 0.611, 0.333, 0.333, 0.333, 0.333, 0.722, 0.667, +0.722, 0.722, 0.722, 0.722, 0.722, 0.675, 0.722, 0.722, 0.722, 0.722, +0.722, 0.556, 0.611, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, +0.667, 0.444, 0.444, 0.444, 0.444, 0.444, 0.278, 0.278, 0.278, 0.278, +0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.675, 0.500, 0.500, 0.500, 0.500, 0.500, 0.444, 0.500, 0.444] + _roman_bi = [ -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, -0.000, 0.000, 0.250, 0.389, 0.555, 0.500, 0.500, 0.833, 0.778, 0.278, -0.333, 0.333, 0.500, 0.570, 0.250, 0.333, 0.250, 0.278, 0.500, 0.500, -0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.333, 0.333, -0.570, 0.570, 0.570, 0.500, 0.832, 0.667, 0.667, 0.667, 0.722, 0.667, -0.667, 0.722, 0.778, 0.389, 0.500, 0.667, 0.611, 0.889, 0.722, 0.722, -0.611, 0.722, 0.667, 0.556, 0.611, 0.722, 0.667, 0.889, 0.667, 0.611, -0.611, 0.333, 0.278, 0.333, 0.570, 0.500, 0.333, 0.500, 0.500, 0.444, -0.500, 0.444, 0.333, 0.500, 0.556, 0.278, 0.278, 0.500, 0.278, 0.778, -0.556, 0.500, 0.500, 0.500, 0.389, 0.389, 0.278, 0.556, 0.444, 0.667, -0.500, 0.444, 0.389, 0.348, 0.220, 0.348, 0.570, 0.350, 0.500, 0.350, -0.333, 0.500, 0.500, 1.000, 0.500, 0.500, 0.333, 1.000, 0.556, 0.333, -0.944, 0.350, 0.611, 0.350, 0.350, 0.333, 0.333, 0.500, 0.500, 0.350, -0.500, 1.000, 0.333, 1.000, 0.389, 0.333, 0.722, 0.350, 0.389, 0.611, -0.250, 0.389, 0.500, 0.500, 0.500, 0.500, 0.220, 0.500, 0.333, 0.747, -0.266, 0.500, 0.606, 0.333, 0.747, 0.333, 0.400, 0.570, 0.300, 0.300, -0.333, 0.576, 0.500, 0.250, 0.333, 0.300, 0.300, 0.500, 0.750, 0.750, -0.750, 0.500, 0.667, 0.667, 0.667, 0.667, 0.667, 0.667, 0.944, 0.667, -0.667, 0.667, 0.667, 0.667, 0.389, 0.389, 0.389, 0.389, 0.722, 0.722, -0.722, 0.722, 0.722, 0.722, 0.722, 0.570, 0.722, 0.722, 0.722, 0.722, -0.722, 0.611, 0.611, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, -0.722, 0.444, 0.444, 0.444, 0.444, 0.444, 0.278, 0.278, 0.278, 0.278, -0.500, 0.556, 0.500, 0.500, 0.500, 0.500, 0.500, 0.570, 0.500, 0.556, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, +0.000, 0.000, 0.250, 0.389, 0.555, 0.500, 0.500, 0.833, 0.778, 0.278, +0.333, 0.333, 0.500, 0.570, 0.250, 0.333, 0.250, 0.278, 0.500, 0.500, +0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.333, 0.333, +0.570, 0.570, 0.570, 0.500, 0.832, 0.667, 0.667, 0.667, 0.722, 0.667, +0.667, 0.722, 0.778, 0.389, 0.500, 0.667, 0.611, 0.889, 0.722, 0.722, +0.611, 0.722, 0.667, 0.556, 0.611, 0.722, 0.667, 0.889, 0.667, 0.611, +0.611, 0.333, 0.278, 0.333, 0.570, 0.500, 0.333, 0.500, 0.500, 0.444, +0.500, 0.444, 0.333, 0.500, 0.556, 0.278, 0.278, 0.500, 0.278, 0.778, +0.556, 0.500, 0.500, 0.500, 0.389, 0.389, 0.278, 0.556, 0.444, 0.667, +0.500, 0.444, 0.389, 0.348, 0.220, 0.348, 0.570, 0.350, 0.500, 0.350, +0.333, 0.500, 0.500, 1.000, 0.500, 0.500, 0.333, 1.000, 0.556, 0.333, +0.944, 0.350, 0.611, 0.350, 0.350, 0.333, 0.333, 0.500, 0.500, 0.350, +0.500, 1.000, 0.333, 1.000, 0.389, 0.333, 0.722, 0.350, 0.389, 0.611, +0.250, 0.389, 0.500, 0.500, 0.500, 0.500, 0.220, 0.500, 0.333, 0.747, +0.266, 0.500, 0.606, 0.333, 0.747, 0.333, 0.400, 0.570, 0.300, 0.300, +0.333, 0.576, 0.500, 0.250, 0.333, 0.300, 0.300, 0.500, 0.750, 0.750, +0.750, 0.500, 0.667, 0.667, 0.667, 0.667, 0.667, 0.667, 0.944, 0.667, +0.667, 0.667, 0.667, 0.667, 0.389, 0.389, 0.389, 0.389, 0.722, 0.722, +0.722, 0.722, 0.722, 0.722, 0.722, 0.570, 0.722, 0.722, 0.722, 0.722, +0.722, 0.611, 0.611, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, +0.722, 0.444, 0.444, 0.444, 0.444, 0.444, 0.278, 0.278, 0.278, 0.278, +0.500, 0.556, 0.500, 0.500, 0.500, 0.500, 0.500, 0.570, 0.500, 0.556, 0.556, 0.556, 0.556, 0.444, 0.500, 0.444] + _font_array = [ [_swiss, _swiss_b, _swiss_i, _swiss_bi ], [_roman, _roman_b, _roman_i, _roman_bi ] ] +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- def string_width(font,text): i = font.get_type_face() j = font.get_bold() + font.get_italic()*2 diff --git a/src/GrampsParser.py b/src/GrampsParser.py index 03667eb9a..75b210163 100644 --- a/src/GrampsParser.py +++ b/src/GrampsParser.py @@ -19,7 +19,6 @@ # from RelLib import * -from Researcher import Researcher import string import os diff --git a/src/LaTeXDoc.py b/src/LaTeXDoc.py index 54fec2f24..71482be20 100644 --- a/src/LaTeXDoc.py +++ b/src/LaTeXDoc.py @@ -60,9 +60,6 @@ class LaTeXDoc(TextDoc): self.f.write("\\title{}\n") self.f.write("\\author{}\n") self.in_list = 0 - self.in_table = 0 - self.cell_number = 1 - self.columns = 0 def close(self): if self.in_list: @@ -99,10 +96,8 @@ class LaTeXDoc(TextDoc): def end_paragraph(self): if self.level > 0: self.f.write('}\n') - elif not self.in_list and not self.in_table: + elif not self.in_list: self.f.write('\n\\par\\noindent\n') - elif self.in_table: - pass else: self.f.write('\n') @@ -115,38 +110,18 @@ class LaTeXDoc(TextDoc): pass def start_table(self,name,style_name): - self.f.write('\n\\par\\noindent\n') - self.f.write("\\medskip\n"); - self.f.write("\\begin{tabular}{"); - tbl = self.table_styles[style_name] - self.columns = tbl.get_columns() - for i in range(0, self.columns ): - self.f.write("l"); - self.f.write("}\n"); - self.in_table = 1 - self.cell_number = 0 pass def end_table(self): - # self.f.write("\\hline\n"); - self.f.write("\\end{tabular}\n"); pass def start_row(self): - # self.f.write("\\hline\n"); - self.cell_number = 0 pass def end_row(self): - for i in range( self.cell_number, self.columns ): - self.f.write(" & "); - self.f.write("\\\\\n") pass def start_cell(self,style_name,span=1): - if self.cell_number > 0: - self.f.write(" & "); - self.cell_number = self.cell_number +1 pass def end_cell(self): @@ -161,3 +136,4 @@ class LaTeXDoc(TextDoc): def write_text(self,text): self.f.write(text) + diff --git a/src/Marriage.py b/src/Marriage.py index c6066d0bc..c2064d022 100644 --- a/src/Marriage.py +++ b/src/Marriage.py @@ -26,7 +26,6 @@ from gtk import * from gnome.ui import * -import gnome.mime import libglade import os import intl @@ -94,8 +93,9 @@ class Marriage: top_window = self.get_widget("marriageEditor") text_win = self.get_widget("marriageTitle") - text_win.set_text(Config.nameof(family.getFather()) + " and " + \ - Config.nameof(family.getMother())) + title = _("%s and %s") % (Config.nameof(family.getFather()), + Config.nameof(family.getMother())) + text_win.set_text(title) self.event_list = self.get_widget("marriageEventList") self.photo_list = self.get_widget("photolist") @@ -118,14 +118,14 @@ class Marriage: self.elist = family.getEventList()[:] self.alist = family.getAttributeList()[:] - self.events_changed = 0 - self.attr_changed = 0 + self.lists_changed = 0 # set initial data self.load_images() self.type_field.set_popdown_strings(const.familyRelations) - self.type_field.entry.set_text(const.display_frel(family.getRelationship())) + frel = const.display_frel(family.getRelationship()) + self.type_field.entry.set_text(frel) # stored object data top_window.set_data(MARRIAGE,self) @@ -148,15 +148,8 @@ class Marriage: # # #------------------------------------------------------------------------- - def update_events(self): + def update_lists(self): self.family.setEventList(self.elist) - - #------------------------------------------------------------------------- - # - # - # - #------------------------------------------------------------------------- - def update_attributes(self): self.family.setAttributeList(self.alist) #--------------------------------------------------------------------- @@ -165,46 +158,7 @@ class Marriage: # #--------------------------------------------------------------------- def redraw_attr_list(self): - self.attr_list.freeze() - self.attr_list.clear() - - self.attr_index = 0 - for attr in self.alist: - details = get_detail_flags(attr) - self.attr_list.append([const.display_fattr(attr.getType()),\ - attr.getValue(),details]) - self.attr_list.set_row_data(self.attr_index,attr) - self.attr_index = self.attr_index + 1 - - current_row = self.attr_list.get_data(INDEX) - - if self.attr_index > 0: - if current_row <= 0: - current_row = 0 - elif self.attr_index <= current_row: - current_row = current_row - 1 - self.attr_list.select_row(current_row,0) - self.attr_list.moveto(current_row,0) - self.attr_list.set_data(INDEX,current_row) - self.attr_list.thaw() - - #------------------------------------------------------------------------- - # - # add_event - adds the event to the window, attaching the event structure - # to each row. - # - #------------------------------------------------------------------------- - def add_event(self,text,event): - if not event: - return - detail = get_detail_flags(event) - if event.getPlace(): - p = event.getPlace().get_title() - else: - p = "" - self.event_list.append([text,event.getQuoteDate(),p,detail]) - self.event_list.set_row_data(self.lines,event) - self.lines = self.lines + 1 + utils.redraw_list(self.alist,self.attr_list,disp_attr) #------------------------------------------------------------------------- # @@ -215,13 +169,9 @@ class Marriage: # #------------------------------------------------------------------------- def add_thumbnail(self,photo): - - src = photo.getPath() - thumb = self.db.getSavePath() + os.sep + ".thumb" + os.sep + \ - os.path.basename(src) - + src = os.path.basename(photo.getPath()) + thumb = "%s%s.thumb%s%s" % (self.path,os.sep,os.sep,src) RelImage.check_thumb(src,thumb,const.thumbScale) - self.photo_list.append(thumb,photo.getDescription()) #------------------------------------------------------------------------- @@ -232,9 +182,6 @@ class Marriage: # #------------------------------------------------------------------------- def load_images(self): - - if len(self.family.getPhotoList()) == 0: - return self.photo_list.freeze() self.photo_list.clear() for photo in self.family.getPhotoList(): @@ -248,26 +195,7 @@ class Marriage: # #------------------------------------------------------------------------- def redraw_events(self): - self.lines = 0 - self.event_list.freeze() - self.event_list.clear() - - for event in self.elist: - self.add_event(const.display_fevent(event.getName()),event) - - current_row = self.event_list.get_data(INDEX) - if current_row == None: - current_row = -1 - - if self.lines >= 0: - if current_row < 0: - current_row = 0 - elif self.lines < current_row: - current_row = current_row - 1 - self.event_list.select_row(current_row,0) - self.event_list.moveto(current_row,0) - self.event_list.set_data(INDEX,current_row) - self.event_list.thaw() + utils.redraw_list(self.elist,self.event_list,disp_event) #------------------------------------------------------------------------- # @@ -294,10 +222,7 @@ def did_data_change(obj): if text != family_obj.family.getNote(): changed = 1 - if family_obj.events_changed: - changed = 1 - - if family_obj.events_changed: + if family_obj.lists_changed: changed = 1 return changed @@ -332,9 +257,9 @@ def cancel_callback(a): # #------------------------------------------------------------------------- def on_delete_event(obj,b): + global quit if did_data_change(obj): - global quit q = _("Data was modified. Are you sure you want to abandon your changes?") quit = obj GnomeQuestionDialog(q,cancel_callback) @@ -375,12 +300,8 @@ def on_close_marriage_editor(obj): utils.destroy_passed_object(family_obj.get_widget("marriageEditor")) - family_obj.update_events() - if family_obj.events_changed: - utils.modified() - - family_obj.update_attributes() - if family_obj.attr_changed: + family_obj.update_lists() + if family_obj.lists_changed: utils.modified() #------------------------------------------------------------------------- @@ -401,9 +322,8 @@ def on_add_clicked(obj): #------------------------------------------------------------------------- def on_update_clicked(obj): row = obj.get_data(INDEX) - if row < 0: - return - EventEditor(obj.get_data(MARRIAGE),obj.get_row_data(row)) + if row >= 0: + EventEditor(obj.get_data(MARRIAGE),obj.get_row_data(row)) #------------------------------------------------------------------------- # @@ -414,18 +334,9 @@ def on_update_clicked(obj): #------------------------------------------------------------------------- def on_delete_clicked(obj): family_obj = obj.get_data(MARRIAGE) - row = obj.get_data(INDEX) - if row < 0: - return - - del family_obj.elist[row] - - if row > len(family_obj.elist)-1: - obj.set_data(INDEX,row-1) - - family_obj.redraw_events() - family_obj.events_changed = 1 - utils.modified() + if utils.delete_selected(obj,family_obj.elist): + family_obj.lists_changed = 1 + family_obj.redraw_events() #------------------------------------------------------------------------- # @@ -439,9 +350,9 @@ def on_select_row(obj,row,b,c): event = obj.get_row_data(row) family_obj.date_field.set_text(event.getDate()) - family_obj.place_field.set_text(event.getPlace().get_title()) + family_obj.place_field.set_text(event.getPlaceName()) family_obj.name_field.set_label(const.display_fevent(event.getName())) - family_obj.event_details.set_text(get_detail_text(event)) + family_obj.event_details.set_text(utils.get_detail_text(event)) family_obj.descr_field.set_text(event.getDescription()) #------------------------------------------------------------------------- @@ -525,27 +436,24 @@ def update_event(event,name,date,place,desc,note,priv,conf): # #------------------------------------------------------------------------- def on_photolist_button_press_event(obj,event): + myobj = obj.get_data(MARRIAGE) + icon = myobj.selectedIcon + if icon == -1: + return + if event.button == 3: - myobj = obj.get_data(MARRIAGE) + photo = myobj.family.getPhotoList()[icon] menu = GtkMenu() item = GtkTearoffMenuItem() item.show() - view = GtkMenuItem(_("View Image")) - view.set_data("m",myobj) - view.connect("activate",on_view_photo) - view.show() - edit = GtkMenuItem(_("Edit Image")) - edit.set_data("m",myobj) - edit.connect("activate",on_edit_photo) - edit.show() - change = GtkMenuItem(_("Edit Description")) - change.set_data("m",myobj) - change.connect("activate",on_change_description) - change.show() menu.append(item) - menu.append(view) - menu.append(edit) - menu.append(change) + utils.add_menuitem(menu,_("View Image"),myobj,on_view_photo) + utils.add_menuitem(menu,_("Edit Image"),myobj,on_edit_photo) + utils.add_menuitem(menu,_("Edit Description"),myobj, + on_change_description) + if photo.getPrivate() == 0: + utils.add_menuitem(menu,_("Convert to private copy"),myobj, + on_convert_to_private) menu.popup(None,None,None,0,0) #------------------------------------------------------------------------- @@ -556,18 +464,7 @@ def on_photolist_button_press_event(obj,event): def on_view_photo(obj): myobj = obj.get_data("m") photo = myobj.family.getPhotoList()[myobj.selectedIcon] - type = gnome.mime.type(photo.getPath()) - - prog = string.split(gnome.mime.get_value(type,'view')) - args = [] - for val in prog: - if val == "%f": - args.append(photo.getPath()) - else: - args.append(val) - - if os.fork() == 0: - os.execvp(args[0],args) + utils.view_photo(photo) #------------------------------------------------------------------------- # @@ -595,10 +492,11 @@ def on_photo_select_icon(obj,iconNumber,event): #------------------------------------------------------------------------- def on_delete_photo_clicked(obj): marriage_obj = obj.get_data(MARRIAGE) + icon = marriage_obj.selectedIcon - photolist = marriage_obj.family.getPhotoList() - marriage_obj.photo_list.remove(marriage_obj.selectedIcon) - del photolist[marriage_obj.selectedIcon] + if icon != -1: + marriage_obj.photo_list.remove(icon) + del marriage_obj.family.getPhotoList()[icon] #------------------------------------------------------------------------- # @@ -713,7 +611,7 @@ def on_attr_list_select_row(obj,row,b,c): family_obj.attr_type.set_label(const.display_fattr(attr.getType())) family_obj.attr_value.set_text(attr.getValue()) - family_obj.attr_details_field.set_text(get_detail_text(attr)) + family_obj.attr_details_field.set_text(utils.get_detail_text(attr)) #------------------------------------------------------------------------- # @@ -722,9 +620,8 @@ def on_attr_list_select_row(obj,row,b,c): #------------------------------------------------------------------------- def on_update_attr_clicked(obj): row = obj.get_data(INDEX) - if row < 0: - return - AttributeEditor(obj.get_data(MARRIAGE),obj.get_row_data(row)) + if row >= 0: + AttributeEditor(obj.get_data(MARRIAGE),obj.get_row_data(row)) #------------------------------------------------------------------------- # @@ -732,18 +629,10 @@ def on_update_attr_clicked(obj): # #------------------------------------------------------------------------- def on_delete_attr_clicked(obj): - row = obj.get_data(INDEX) - if row < 0: - return - family_obj = obj.get_data(MARRIAGE) - del family_obj.alist[row] - - if row > len(family_obj.alist)-1: - obj.set_data(INDEX,row-1) - - family_obj.redraw_attr_list() - utils.modified() + if utils.delete_selected(obj,family_obj.alist): + family_obj.lists_changed = 1 + family_obj.redraw_attr_list() #------------------------------------------------------------------------- # @@ -793,27 +682,14 @@ class EventEditor: self.top.get_widget("eventTitle").set_text(name) self.event_menu.set_popdown_strings(const.marriageEvents) - myMenu = GtkMenu() - index = 0 - for name in const.confidence: - item = GtkMenuItem(name) - item.set_data("a",index) - item.show() - myMenu.append(item) - index = index + 1 - - self.conf_menu.set_menu(myMenu) + build_confidence_menu(self.conf_menu) values = self.parent.db.getPlaceMap().values() if event != None: self.name_field.set_text(event.getName()) - attach_places(values,self.place_combo,event.getPlace()) - if event.getPlace(): - self.place_field.set_text(event.getPlace().get_title()) - else: - self.place_field.set_text('') - + utils.attach_places(values,self.place_combo,event.getPlace()) + self.place_field.set_text(event.getPlaceName()) self.date_field.set_text(event.getDate()) self.descr_field.set_text(event.getDescription()) self.conf_menu.set_history(event.getConfidence()) @@ -830,7 +706,7 @@ class EventEditor: self.note_field.insert_defaults(event.getNote()) self.note_field.set_word_wrap(1) else: - attach_places(values,self.place_combo,None) + utils.attach_places(values,self.place_combo,None) self.conf_menu.set_history(2) self.window.set_data("o",self) @@ -861,7 +737,7 @@ def on_event_edit_ok_clicked(obj): ename = ee.name_field.get_text() edate = ee.date_field.get_text() eplace = string.strip(ee.place_field.get_text()) - eplace_obj = get_place_from_list(ee.place_combo) + eplace_obj = utils.get_place_from_list(ee.place_combo) enote = ee.note_field.get_chars(0,-1) edesc = ee.descr_field.get_text() epriv = ee.priv.get_active() @@ -877,17 +753,15 @@ def on_event_edit_ok_clicked(obj): ee.parent.db.addPlace(eplace_obj) if update_event(event,ename,edate,eplace_obj,edesc,enote,epriv,econf): - ee.parent.events_changed = 1 + ee.parent.lists_changed = 1 if not source_refs_equal(event.getSourceRef(),ee.srcref): event.setSourceRef(ee.srcref) - ee.parent.events_changed = 1 + ee.parent.lists_changed = 1 ee.parent.redraw_events() - utils.destroy_passed_object(obj) - #------------------------------------------------------------------------- # # AttributeEditor class @@ -921,20 +795,13 @@ class AttributeEditor: name = father.getPrimaryName().getName() else: name = mother.getPrimaryName().getName() - - self.top.get_widget("attrTitle").set_text(_("Attribute Editor for %s") % name) + + title = _("Attribute Editor for %s") % name + self.top.get_widget("attrTitle").set_text(title) if len(const.familyAttributes) > 0: self.attrib_menu.set_popdown_strings(const.familyAttributes) - myMenu = GtkMenu() - index = 0 - for name in const.confidence: - item = GtkMenuItem(name) - item.set_data("a",index) - item.show() - myMenu.append(item) - index = index + 1 - self.conf_menu.set_menu(myMenu) + build_confidence_menu(self.conf_menu) if attrib != None: self.type_field.set_text(attrib.getType()) @@ -946,7 +813,6 @@ class AttributeEditor: self.source_field.set_text("") self.conf_menu.set_history(attrib.getConfidence()) - self.priv.set_active(attrib.getPrivacy()) self.note_field.set_point(0) @@ -991,53 +857,15 @@ def on_attrib_edit_ok_clicked(obj): ee.parent.alist.append(attrib) if update_attrib(attrib,type,value,note,priv,conf): - ee.parent.attr_changed = 1 + ee.parent.lists_changed = 1 if not source_refs_equal(attrib.getSourceRef(),ee.srcref): attrib.setSourceRef(ee.srcref) - ee.parent.attr_changed = 1 + ee.parent.lists_changed = 1 ee.parent.redraw_attr_list() utils.destroy_passed_object(obj) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def get_detail_flags(obj): - detail = "" - if Config.show_detail: - if obj.getNote() != "": - detail = "N" - if obj.getSourceRef().getBase(): - detail = detail + "S" - if obj.getPrivacy(): - detail = detail + "P" - return detail - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def get_detail_text(obj): - if obj.getNote() != "": - details = _("Note") - else: - details = "" - if obj.getSourceRef().getBase() != None: - if details == "": - details = _("Source") - else: - details = "%s, %s" % (details,_("Source")) - if obj.getPrivacy() == 1: - if details == "": - details = _("Private") - else: - details = "%s, %s" % (details,_("Private")) - return details - #------------------------------------------------------------------------- # # @@ -1060,47 +888,18 @@ def source_refs_equal(one,two): #------------------------------------------------------------------------- # -# +# # #------------------------------------------------------------------------- -def attach_places(values,combo,place): - l = GtkLabel("") - l.show() - l.set_alignment(0,0.5) - c = GtkListItem() - c.add(l) - c.set_data("s",None) - c.show() - sel_child = c - list = [c] - mymap = {} - for src in values: - l = GtkLabel("%s [%s]" % (src.get_title(),src.getId())) - l.show() - l.set_alignment(0,0.5) - c = GtkListItem() - c.add(l) - c.set_data("s",src) - c.show() - list.append(c) - if src == place: - sel_child = c - mymap[src] = c +def disp_attr(attr): + detail = utils.get_detail_flags(attr) + return [const.display_pattr(attr.getType()),attr.getValue(),detail] - combo.list.append_items(list) - combo.list.select_child(sel_child) - - for v in mymap.keys(): - combo.set_item_string(mymap[v],v.get_title()) - #------------------------------------------------------------------------- # -# +# # #------------------------------------------------------------------------- -def get_place_from_list(obj): - select = obj.list.get_selection() - if len(select) == 0: - return None - else: - return select[0].get_data("s") +def disp_event(event): + return [const.display_fevent(event.getName()), event.getQuoteDate(), + event.getPlaceName(), utils.get_detail_flags(event)] diff --git a/src/Plugins.py b/src/Plugins.py index 3f9db1022..c1f1565d5 100644 --- a/src/Plugins.py +++ b/src/Plugins.py @@ -30,8 +30,6 @@ import intl _ = intl.gettext -names = {} - #------------------------------------------------------------------------- # # @@ -55,10 +53,21 @@ import utils # # #------------------------------------------------------------------------- -reports = [] -imports = [] -exports = [] -tools = [] +_reports = [] +_tools = [] +_imports = [] +_exports = [] + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +OBJECT = "o" +DOCSTRING = "d" +IMAGE = "i" +TASK = "f" +TITLE = "t" #------------------------------------------------------------------------- # @@ -71,64 +80,19 @@ class ReportPlugins: self.db = db self.active = active - self.plugins_dialog = libglade.GladeXML(const.pluginsFile,"report") - self.plugins_dialog.signal_autoconnect({ + self.dialog = libglade.GladeXML(const.pluginsFile,"report") + self.dialog.signal_autoconnect({ "on_report_apply_clicked" : on_report_apply_clicked, - "on_report_ok_clicked" : on_report_ok_clicked, - "destroy_passed_object" : utils.destroy_passed_object + "on_report_ok_clicked" : on_report_apply_clicked, + "destroy_passed_object" : utils.destroy_passed_object }) - top = self.plugins_dialog.get_widget("report") - top.set_data("o",self) - tree = self.plugins_dialog.get_widget("tree1") + top = self.dialog.get_widget("report") + top.set_data(OBJECT,self) + tree = self.dialog.get_widget("tree1") self.run_tool = None - - item_hash = {} - for report in reports: - if report.__dict__.has_key("get_name"): - doc = report.get_name() - else: - doc = report.__doc__ - - info = string.split(doc,"/") - if len(info) == 1: - category = _("Uncategorized") - name = info[0] - else: - category = info[0] - name = info[1] - item = GtkTreeItem(name) - item.set_data("o",self) - item.set_data("c",report.report) - if "get_description" in report.__dict__.keys(): - item.set_data("d",report.get_description) - else: - item.set_data("d",no_description) - if "get_xpm_image" in report.__dict__.keys(): - item.set_data("i",report.get_xpm_image) - else: - item.set_data("i",no_image) - item.set_data("t",doc) - item.connect("select",on_report_node_selected) - if item_hash.has_key(category): - item_hash[category].append(item) - else: - item_hash[category] = [item] - - key_list = item_hash.keys() - key_list.sort() - for key in key_list: - top_item = GtkTreeItem(key) - top_item.show() - tree.append(top_item) - subtree = GtkTree() - subtree.show() - top_item.set_subtree(subtree) - subtree.show() - for item in item_hash[key]: - item.show() - subtree.append(item) - + build_tree(tree,_reports,on_report_node_selected) + #------------------------------------------------------------------------- # # @@ -140,50 +104,53 @@ class ToolPlugins: self.active = active self.update = update - self.plugins_dialog = libglade.GladeXML(const.pluginsFile,"pluginsel") - self.plugins_dialog.signal_autoconnect({ - "on_apply_clicked" : on_apply_clicked, - "on_ok_clicked" : on_ok_clicked, + self.dialog = libglade.GladeXML(const.pluginsFile,"pluginsel") + self.dialog.signal_autoconnect({ + "on_apply_clicked" : on_apply_clicked, + "on_ok_clicked" : on_ok_clicked, "destroy_passed_object" : utils.destroy_passed_object }) - top = self.plugins_dialog.get_widget("pluginsel") - top.set_data("o",self) - tree = self.plugins_dialog.get_widget("tree") + top = self.dialog.get_widget("pluginsel") + top.set_data(OBJECT,self) + tree = self.dialog.get_widget("tree") self.run_tool = None + build_tree(tree,_tools,on_node_selected) - item_hash = {} - for report in tools: - if report.__dict__.has_key("get_name"): - doc = report.get_name() - else: - doc = report.__doc__ +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def build_tree(tree,list,task): + item_hash = {} + for report in list: + item = GtkTreeItem(report[2]) + item.connect("select",task) + item.set_data(OBJECT,self) + item.set_data(TASK,report[0]) + item.set_data(TITLE,report[2]) + item.set_data(DOCSTRING,report[3]) + item.set_data(IMAGE,report[4]) - info = string.split(doc,"/") - item = GtkTreeItem(info[1]) - item.set_data("o",self) - item.set_data("c",report.runTool) - item.set_data("d",report.get_description) - item.set_data("t",doc) - item.connect("select",on_node_selected) - if item_hash.has_key(info[0]): - item_hash[info[0]].append(item) - else: - item_hash[info[0]] = [item] + if item_hash.has_key(report[1]): + item_hash[report[1]].append(item) + else: + item_hash[report[1]] = [item] - key_list = item_hash.keys() - key_list.sort() - for key in key_list: - top_item = GtkTreeItem(key) - top_item.show() - tree.append(top_item) - subtree = GtkTree() - subtree.show() - top_item.set_subtree(subtree) - subtree.show() - for item in item_hash[key]: - item.show() - subtree.append(item) + key_list = item_hash.keys() + key_list.sort() + for key in key_list: + top_item = GtkTreeItem(key) + top_item.show() + tree.append(top_item) + subtree = GtkTree() + subtree.show() + top_item.set_subtree(subtree) + subtree.show() + for item in item_hash[key]: + item.show() + subtree.append(item) #------------------------------------------------------------------------- # @@ -191,13 +158,13 @@ class ToolPlugins: # #------------------------------------------------------------------------- def on_node_selected(obj): - myobj = obj.get_data("o") - doc = obj.get_data("d") - title = string.split(obj.get_data("t"),"/") + myobj = obj.get_data(OBJECT) + doc = obj.get_data(DOCSTRING) + title = obj.get_data(TITLE) - myobj.plugins_dialog.get_widget("description").set_text(doc()) - myobj.plugins_dialog.get_widget("pluginTitle").set_text(title[1]) - myobj.run_tool = obj.get_data("c") + myobj.dialog.get_widget("description").set_text(doc) + myobj.dialog.get_widget("pluginTitle").set_text(title) + myobj.run_tool = obj.get_data(TASK) #------------------------------------------------------------------------- # @@ -205,31 +172,19 @@ def on_node_selected(obj): # #------------------------------------------------------------------------- def on_report_node_selected(obj): - myobj = obj.get_data("o") - doc = obj.get_data("d") - xpm_func = obj.get_data("i") + myobj = obj.get_data(OBJECT) + doc = obj.get_data(DOCSTRING) + xpm = obj.get_data(IMAGE) + title = obj.get_data(TITLE) + img = myobj.dialog.get_widget("image") - title = string.split(obj.get_data("t"),"/") - img = myobj.plugins_dialog.get_widget("image") - - myobj.plugins_dialog.get_widget("description").set_text(doc()) + myobj.dialog.get_widget("description").set_text(DOC) - i,m = create_pixmap_from_xpm_d(GtkWindow(),None,xpm_func()) + i,m = create_pixmap_from_xpm_d(GtkWindow(),None,xpm) img.set(i,m) - if len(title) == 1: - myobj.plugins_dialog.get_widget("report_title").set_text(title[0]) - else: - myobj.plugins_dialog.get_widget("report_title").set_text(title[1]) - myobj.run_tool = obj.get_data("c") - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def by_doc(a,b): - return cmp(names[a],names[b]) + myobj.dialog.get_widget("report_title").set_text(title) + myobj.run_tool = obj.get_data(TASK) #------------------------------------------------------------------------- # @@ -237,9 +192,9 @@ def by_doc(a,b): # #------------------------------------------------------------------------- def on_apply_clicked(obj): - myobj = obj.get_data("o") + myobj = obj.get_data(OBJECT) utils.destroy_passed_object(obj) - if myobj.run_tool != None: + if myobj.run_tool: myobj.run_tool(myobj.db,myobj.active,myobj.update) #------------------------------------------------------------------------- @@ -248,9 +203,9 @@ def on_apply_clicked(obj): # #------------------------------------------------------------------------- def on_report_apply_clicked(obj): - myobj = obj.get_data("o") + myobj = obj.get_data(OBJECT) utils.destroy_passed_object(obj) - if myobj.run_tool != None: + if myobj.run_tool: myobj.run_tool(myobj.db,myobj.active) #------------------------------------------------------------------------- @@ -261,14 +216,6 @@ def on_report_apply_clicked(obj): def on_ok_clicked(obj): on_apply_clicked(obj) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_report_ok_clicked(obj): - on_report_apply_clicked(obj) - #------------------------------------------------------------------------- # # @@ -289,76 +236,146 @@ def load_plugins(dir): groups = match.groups() try: plugin = __import__(groups[0]) - try: - names[plugin] = plugin.get_name() - except: - names[plugin] = plugin.__doc__ except: print _("Failed to load the module: %s") % groups[0] import traceback traceback.print_exc() - continue - if plugin.__dict__.has_key("report"): - reports.append(plugin) - elif plugin.__dict__.has_key("writeData"): - exports.append(plugin) - elif plugin.__dict__.has_key("runTool"): - tools.append(plugin) - elif plugin.__dict__.has_key("readData"): - imports.append(plugin) - - tools.sort(by_doc) - imports.sort(by_doc) - exports.sort(by_doc) - reports.sort(by_doc) #------------------------------------------------------------------------- # # # #------------------------------------------------------------------------- -def export_menu(callback): +def build_export_menu(top_menu,callback): myMenu = GtkMenu() - for report in exports: - try: - text = report.get_name() - except: - text = report.__doc__ - item = GtkMenuItem(text) + for report in _exports: + item = GtkMenuItem(report[1]) + item.connect("activate", callback ,report[0]) + item.show() + myMenu.append(item) + top_menu.set_submenu(myMenu) + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def build_import_menu(top_menu,callback): + myMenu = GtkMenu() + + for report in _imports: + item = GtkMenuItem(report[1]) + item.connect("activate", callback ,report[0]) + item.show() + myMenu.append(item) + top_menu.set_submenu(myMenu) + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def register_export(task, name): + _exports.append((task, name)) + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def register_import(task, name): + _imports.append((task, name)) + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def register_report(task, name, category=None, description=None, xpm=None): + if xpm == None: + xpm_data = no_image() + elif type(xpm) == type([]): + xpm_data = xpm + else: + xpm_data = xpm + + if category == None: + category = _("Uncategorized") + if description == None: + description = _("No description was provided") - item.show() - item.connect("activate", callback ,report.writeData) - myMenu.append(item) - return myMenu + _reports.append((task, category, name, description, xpm_data)) #------------------------------------------------------------------------- # # # #------------------------------------------------------------------------- -def import_menu(callback): - myMenu = GtkMenu() +def register_tool(task, name, category=None, description=None, xpm=None): + if xpm == None: + xpm_data = no_image() + elif type(xpm) == type([]): + xpm_data = xpm + else: + xpm_data = xpm - for report in imports: - try: - text = report.get_name() - except: - text = report.__doc__ - item = GtkMenuItem(text) - - item.show() - item.connect("activate", callback ,report.readData) - myMenu.append(item) - return myMenu + if category == None: + category = _("Uncategorized") + if description == None: + description = _("No description was provided") + + _tools.append((task, category, name, description, xpm_data)) #------------------------------------------------------------------------- # -# +# # #------------------------------------------------------------------------- -def no_description(): - return _("No description was provided") +def build_menu(top_menu,list,callback): + report_menu = GtkMenu() + report_menu.show() + + hash = {} + for report in list: + if hash.has_key(report[1]): + hash[report[1]].append((report[2],report[0])) + else: + hash[report[1]] = [(report[2],report[0])] + + catlist = hash.keys() + catlist.sort() + for key in catlist: + entry = GtkMenuItem(key) + entry.show() + report_menu.append(entry) + submenu = GtkMenu() + submenu.show() + entry.set_submenu(submenu) + list = hash[key] + list.sort() + for name in list: + subentry = GtkMenuItem(name[0]) + subentry.show() + subentry.connect("activate",callback,name[1]) + submenu.append(subentry) + top_menu.set_submenu(report_menu) + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def build_report_menu(top_menu,callback): + build_menu(top_menu,_reports,callback) + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def build_tools_menu(top_menu,callback): + build_menu(top_menu,_tools,callback) #------------------------------------------------------------------------- # diff --git a/src/ReadXML.py b/src/ReadXML.py index 71a8907fa..03854dff0 100644 --- a/src/ReadXML.py +++ b/src/ReadXML.py @@ -20,18 +20,23 @@ from RelLib import * from GrampsParser import * -import intl -_ = intl.gettext +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- import string import time import gzip import os from gnome.ui import * - import sys +import intl +_ = intl.gettext + #------------------------------------------------------------------------- # # Try to abstract SAX1 from SAX2 @@ -165,8 +170,6 @@ def loadData(database, filename, callback=None): if __name__ == "__main__": - import sys - import time import profile database = RelDataBase() diff --git a/src/RelImage.py b/src/RelImage.py index f8e831d6a..22eaf5eb0 100644 --- a/src/RelImage.py +++ b/src/RelImage.py @@ -51,12 +51,11 @@ def import_photo(filename,path,prefix): return None for index in range(0,1000): - base = "%s_%d.jpg" % (prefix,index) - name = path + os.sep + base + name = "%s%s%s_%d.jpg" % (path,os.sep,prefix,index) if os.path.exists(name) == 0: break - thumb = path+os.sep+".thumb" + thumb = "%s%s.thumb" % (path,os.sep) try: if not os.path.exists(thumb): @@ -67,7 +66,7 @@ def import_photo(filename,path,prefix): GnomeErrorDialog(_("Could not create %s") % thumb) try: - path = thumb + os.sep + base + path = "%s%s%s" % (thumb,os.sep,base) mk_thumb(filename,path,const.thumbScale) @@ -81,7 +80,6 @@ def import_photo(filename,path,prefix): PIL.Image.open(filename).save(name) except: return None - return name #------------------------------------------------------------------------- diff --git a/src/RelLib.py b/src/RelLib.py index 9150a97d1..0e69406f6 100644 --- a/src/RelLib.py +++ b/src/RelLib.py @@ -19,7 +19,6 @@ # from Date import * -from Researcher import * class Place: def __init__(self,source=None): @@ -138,6 +137,56 @@ class Place: def getPhotoList(self): return self.photoList +#------------------------------------------------------------------------- +# +# Researcher +# +#------------------------------------------------------------------------- +class Researcher: + def __init__(self): + self.name = "" + self.addr = "" + self.city = "" + self.state = "" + self.country = "" + self.postal = "" + self.phone = "" + self.email = "" + + def getName(self): + return self.name + + def getAddress(self): + return self.addr + + def getCity(self): + return self.city + + def getState(self): + return self.state + + def getCountry(self): + return self.country + + def getPostalCode(self): + return self.postal + + def getPhone(self): + return self.phone + + def getEmail(self): + return self.email + + def set(self,name,addr,city,state,country,postal,phone,email): + self.name = string.strip(name) + self.addr = string.strip(addr) + self.city = string.strip(city) + self.state = string.strip(state) + self.country = string.strip(country) + self.postal = string.strip(postal) + self.phone = string.strip(phone) + self.email = string.strip(email) + #------------------------------------------------------------------------- # # Location @@ -895,6 +944,12 @@ class Event: def getPlace(self) : return self.place + def getPlaceName(self) : + if self.place: + return self.place.get_title() + else: + return "" + def setNote(self,note) : if self.note == None: self.note = Note() @@ -954,6 +1009,13 @@ class Family: self.photoList = [] self.note = Note() self.attributeList = [] + self.position = None + + def setPosition(self,pos): + self.position = pos + + def getPosition(self): + return self.position def addAttribute(self,attribute) : self.attributeList.append(attribute) diff --git a/src/StyleEditor.py b/src/StyleEditor.py index 7bf10e410..5b7ec31ce 100644 --- a/src/StyleEditor.py +++ b/src/StyleEditor.py @@ -26,7 +26,13 @@ import const from TextDoc import * +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ class StyleListDisplay: + def __init__(self,stylesheetlist,callback,object): self.object = object self.callback = callback @@ -46,17 +52,24 @@ class StyleListDisplay: self.dialog.set_data("o",self) self.redraw() + #-------------------------------------------------------------------- + # + # + # + #-------------------------------------------------------------------- def redraw(self): self.list.clear() self.list.set_data("i",0) box = ListColors.ColorList(self.list,1) - box.add_with_data(["default"],("default",self.sheetlist.get_style_sheet("default"))) + sheet = self.sheetlist.get_style_sheet("default") + box.add_with_data(["default"],("default",sheet)) for style in self.sheetlist.get_style_names(): if style == "default": continue - box.add_with_data([style],(style,self.sheetlist.get_style_sheet(style))) + sheet = self.sheetlist.get_style_sheet(style) + box.add_with_data([style],(style,sheet)) #------------------------------------------------------------------------ # @@ -153,6 +166,11 @@ class StyleEditor: myMenu.append(menuitem) self.pnames.set_menu(myMenu) + #-------------------------------------------------------------------- + # + # + # + #-------------------------------------------------------------------- def draw(self,p): self.current_p = p font = p.get_font() @@ -184,6 +202,11 @@ class StyleEditor: c = p.get_background_color() self.top.get_widget("bgcolor").set_i8(c[0],c[1],c[2],0) + #-------------------------------------------------------------------- + # + # + # + #-------------------------------------------------------------------- def save_paragraph(self,p): font = p.get_font() font.set_size(int(self.top.get_widget("size").get_value())) diff --git a/src/WriteXML.py b/src/WriteXML.py index fb5f54a86..f73dd71ca 100644 --- a/src/WriteXML.py +++ b/src/WriteXML.py @@ -19,7 +19,6 @@ # from RelLib import * -from Researcher import * import const import string @@ -504,9 +503,3 @@ def exportData(database, filename, callback): g.write("\n") g.close() - - - - - - diff --git a/src/filters/After.py b/src/filters/After.py index 31a4682c5..c806c3d99 100644 --- a/src/filters/After.py +++ b/src/filters/After.py @@ -62,26 +62,7 @@ class EventAfter(Filter.Filter): break return val -#------------------------------------------------------------------------ -# -# -# -#------------------------------------------------------------------------ -def get_name(): - return _("People with an event after ...") +Filter.register_filter(EventAfter, + description=_("People with an event after ..."), + qualifier=1) -#------------------------------------------------------------------------ -# -# -# -#------------------------------------------------------------------------ -def create(text): - return EventAfter(text) - -#------------------------------------------------------------------------ -# -# -# -#------------------------------------------------------------------------ -def need_qualifier(): - return 1 diff --git a/src/filters/AltFam.py b/src/filters/AltFam.py index c907bf8c9..65e6c3c7d 100644 --- a/src/filters/AltFam.py +++ b/src/filters/AltFam.py @@ -33,11 +33,8 @@ class HaveAltFamilies(Filter.Filter): def match(self,person): return len(person.getAltFamilyList()) > 0 -def create(text): - return HaveAltFamilies(text) -def need_qualifier(): - return 0 +Filter.register_filter(HaveAltFamilies, + description=_("People who were adopted"), + qualifier=0) -def get_name(): - return _("People who were adopted") diff --git a/src/filters/Before.py b/src/filters/Before.py index 7e8e1a12b..f6fbda5ea 100644 --- a/src/filters/Before.py +++ b/src/filters/Before.py @@ -68,21 +68,7 @@ class EventBefore(Filter.Filter): # # #------------------------------------------------------------------------ -def create(text): - return EventBefore(text) +Filter.register_filter(EventBefore, + description=_("People with an event before ..."), + qualifier=1) -#------------------------------------------------------------------------ -# -# -# -#------------------------------------------------------------------------ -def need_qualifier(): - return 1 - -#------------------------------------------------------------------------ -# -# -# -#------------------------------------------------------------------------ -def get_name(): - return _("People with an event before ...") diff --git a/src/filters/Disconnected.py b/src/filters/Disconnected.py index 0ff3c9932..4850cb8fe 100644 --- a/src/filters/Disconnected.py +++ b/src/filters/Disconnected.py @@ -31,11 +31,12 @@ class Disconnected(Filter.Filter): def match(self,person): return person.getMainFamily() == None and len(person.getFamilyList()) == 0 -def create(text): - return Disconnected(text) +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +Filter.register_filter(Disconnected, + description= _("Disconnected individuals"), + qualifier=0) -def need_qualifier(): - return 0 - -def get_name(): - return _("Disconnected individuals") diff --git a/src/filters/EventPlace.py b/src/filters/EventPlace.py index d01fb6775..675735745 100644 --- a/src/filters/EventPlace.py +++ b/src/filters/EventPlace.py @@ -49,11 +49,11 @@ class EventPlace(Filter.Filter): break return val -def create(text): - return EventPlace(text) - -def need_qualifier(): - return 1 - -def get_name(): - return _("People with an event location of ...") +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +Filter.register_filter(EventPlace, + description=_("People with an event location of ..."), + qualifier=1) diff --git a/src/filters/EventType.py b/src/filters/EventType.py index 03e33a34e..8f8d50d50 100644 --- a/src/filters/EventType.py +++ b/src/filters/EventType.py @@ -33,11 +33,11 @@ class EventType(Filter.Filter): return 1 return 0 -def create(text): - return EventType(text) - -def need_qualifier(): - return 1 - -def get_name(): - return _("People who have an event type of ...") +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +Filter.register_filter(EventType, + description=_("People who have an event type of ..."), + qualifier=1) diff --git a/src/filters/Females.py b/src/filters/Females.py index a2f2d0b86..0e604d6bd 100644 --- a/src/filters/Females.py +++ b/src/filters/Females.py @@ -33,11 +33,11 @@ class Females(Filter.Filter): def match(self,person): return person.getGender() == Person.female -def create(text): - return Females(text) - -def need_qualifier(): - return 0 - -def get_name(): - return _("Females") +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +Filter.register_filter(Females, + description=_("Females"), + qualifier=0) diff --git a/src/filters/HavePhotos.py b/src/filters/HavePhotos.py index b862fb1df..26ad8f0f6 100644 --- a/src/filters/HavePhotos.py +++ b/src/filters/HavePhotos.py @@ -32,11 +32,12 @@ class HavePhotos(Filter.Filter): def match(self,person): return len(person.getPhotoList()) > 0 -def create(text): - return HavePhotos(text) +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +Filter.register_filter(HavePhotos, + description=_("People who have images"), + qualifier=0) -def need_qualifier(): - return 0 - -def get_name(): - return _("People who have images") diff --git a/src/filters/IncompleteNames.py b/src/filters/IncompleteNames.py index 0fcbff091..93d34ab80 100644 --- a/src/filters/IncompleteNames.py +++ b/src/filters/IncompleteNames.py @@ -32,11 +32,11 @@ class IncompleteNames(Filter.Filter): name = person.getPrimaryName() return name.getFirstName() == "" or name.getSurname() == "" -def create(text): - return IncompleteNames(text) - -def need_qualifier(): - return 0 - -def get_name(): - return _("People with incomplete names") +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +Filter.register_filter(IncompleteNames, + description=_("People with incomplete names"), + qualifier=0) diff --git a/src/filters/Males.py b/src/filters/Males.py index b69e2e5d9..0751d75d2 100644 --- a/src/filters/Males.py +++ b/src/filters/Males.py @@ -33,11 +33,12 @@ class Males(Filter.Filter): def match(self,person): return person.getGender() == Person.male -def create(text): - return Males(text) +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +Filter.register_filter(Males, + description=_("Males"), + qualifier=0) -def need_qualifier(): - return 0 - -def get_name(): - return _("Males") diff --git a/src/filters/MatchSndEx.py b/src/filters/MatchSndEx.py index 85e4003b4..98cb93035 100644 --- a/src/filters/MatchSndEx.py +++ b/src/filters/MatchSndEx.py @@ -36,11 +36,11 @@ class MatchSndEx(Filter.Filter): def match(self,person): return self.sndex == soundex.soundex(person.getPrimaryName().getSurname()) -def create(text): - return MatchSndEx(text) - -def need_qualifier(): - return 1 - -def get_name(): - return _("Names with same SoundEx code as ...") +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +Filter.register_filter(MatchSndEx, + description=_("Names with same SoundEx code as ..."), + qualifier=1) diff --git a/src/filters/MatchSndEx2.py b/src/filters/MatchSndEx2.py index 67dcb429a..2b6d84b4d 100644 --- a/src/filters/MatchSndEx2.py +++ b/src/filters/MatchSndEx2.py @@ -32,11 +32,11 @@ class MatchSndEx2(Filter.Filter): def match(self,person): return self.text == soundex.soundex(person.getPrimaryName().getSurname()) -def create(text): - return MatchSndEx2(text) - -def need_qualifier(): - return 1 - -def get_name(): - return _("Names with the specified SoundEx code") +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +Filter.register_filter(MatchSndEx2, + description=_("Names with the specified SoundEx code"), + qualifier=1) diff --git a/src/filters/MutlipleMarriages.py b/src/filters/MutlipleMarriages.py index 33734bf22..4e99e8df9 100644 --- a/src/filters/MutlipleMarriages.py +++ b/src/filters/MutlipleMarriages.py @@ -32,11 +32,11 @@ class MultipleMarriages(Filter.Filter): def match(self,person): return len(person.getFamilyList()) > 1 -def create(text): - return MultipleMarriages(text) - -def need_qualifier(): - return 0 - -def get_name(): - return _("People with multiple marriage records") +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +Filter.register_filter(MultipleMarriages, + description=_("People with multiple marriage records"), + qualifier=0) diff --git a/src/filters/NeverMarried.py b/src/filters/NeverMarried.py index 4c6b49296..d08fed611 100644 --- a/src/filters/NeverMarried.py +++ b/src/filters/NeverMarried.py @@ -32,11 +32,12 @@ class NeverMarried(Filter.Filter): def match(self,person): return len(person.getFamilyList()) == 0 -def create(text): - return NeverMarried(text) +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +Filter.register_filter(NeverMarried, + description=_("People with no marriage records"), + qualifier=0) -def need_qualifier(): - return 0 - -def get_name(): - return _("People with no marriage records") diff --git a/src/filters/NoBirthdate.py b/src/filters/NoBirthdate.py index b1d9b532a..7249774fc 100644 --- a/src/filters/NoBirthdate.py +++ b/src/filters/NoBirthdate.py @@ -32,13 +32,12 @@ class NoBirthdate(Filter.Filter): def match(self,person): return person.getBirth().getDate() == "" -def create(text): - return NoBirthdate(text) - -def need_qualifier(): - return 0 - -def get_name(): - return _("People without a birth date") - +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +Filter.register_filter(NoBirthdate, + description=_("People without a birth date"), + qualifier=0) diff --git a/src/filters/NoChildren.py b/src/filters/NoChildren.py index 04fe32171..c8a4607a5 100644 --- a/src/filters/NoChildren.py +++ b/src/filters/NoChildren.py @@ -37,12 +37,12 @@ class HaveChildren(Filter.Filter): break return val +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +Filter.register_filter(HaveChildren, + description=_("People with children"), + qualifier=0) -def create(text): - return HaveChildren(text) - -def need_qualifier(): - return 0 - -def get_name(): - return _("People with children") diff --git a/src/filters/RegExMatch.py b/src/filters/RegExMatch.py index eb68238a7..1a12896d4 100644 --- a/src/filters/RegExMatch.py +++ b/src/filters/RegExMatch.py @@ -43,11 +43,18 @@ class RegExMatch(Filter.Filter): else: return self.regexp.search(utils.phonebook_name(person)) -def create(text): - return RegExMatch(text) +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +Filter.register_filter(RegExMatch, + description=_("Names that match a regular expression"), + qualifier=1) + + + + + -def need_qualifier(): - return 1 -def get_name(): - return _("Names that match a regular expression") diff --git a/src/filters/SubString.py b/src/filters/SubString.py index 23eaff9fd..6f445a4d2 100644 --- a/src/filters/SubString.py +++ b/src/filters/SubString.py @@ -32,11 +32,12 @@ class SubString(Filter.Filter): def match(self,person): return string.find(utils.phonebook_name(person),self.text) >= 0 -def create(text): - return SubString(text) +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +Filter.register_filter(SubString, + description=_("Names that contain a substring"), + qualifier=1) -def need_qualifier(): - return 1 - -def get_name(): - return _("Names that contain a substring") diff --git a/src/gramps_main.py b/src/gramps_main.py index 6f71b4af5..599b69eee 100755 --- a/src/gramps_main.py +++ b/src/gramps_main.py @@ -53,6 +53,7 @@ import libglade #------------------------------------------------------------------------- from RelLib import * +import ReadXML import Filter import const import Plugins @@ -76,7 +77,6 @@ import Marriage # #------------------------------------------------------------------------- -active_event = None active_person = None active_father = None active_family = None @@ -90,8 +90,8 @@ select_spouse = None select_mother = None select_child_list = {} childWindow = None -newChildWindow= None -addChildList = None +new_child_win = None +add_child_win = None bookmarks = None id2col = {} @@ -100,6 +100,7 @@ alt2col = {} topWindow = None statusbar = None gtop = None +notebook = None person_list = None source_list = None place_list = None @@ -108,7 +109,7 @@ family_window = None pv = {} sort_column = 5 sort_direct = SORT_ASCENDING -DataFilter = Filter.create("") +DataFilter = Filter.Filter("") #------------------------------------------------------------------------- # @@ -116,16 +117,18 @@ DataFilter = Filter.create("") # #------------------------------------------------------------------------- -NOTEBOOK = "notebook1" -FILESEL = "fileselection" -FILTERNAME = "filter_list" -ODDFGCOLOR = "oddForeground" -ODDBGCOLOR = "oddBackground" -EVENFGCOLOR= "evenForeground" -EVENBGCOLOR= "evenBackground" -GIVEN = "g" -SURNAME = "s" -RELTYPE = "d" +NOTEBOOK = "notebook1" +FILESEL = "fileselection" +FILTERNAME = "filter_list" +ODDFGCOLOR = "oddForeground" +ODDBGCOLOR = "oddBackground" +EVENFGCOLOR = "evenForeground" +EVENBGCOLOR = "evenBackground" +GIVEN = "g" +SURNAME = "s" +RELTYPE = "d" +PAD = 3 + #------------------------------------------------------------------------- # # Short hand function to return either the person's birthday, or an empty @@ -215,8 +218,6 @@ def on_contents_activate(obj): # #------------------------------------------------------------------------- def on_remove_child_clicked(obj): - global active_family - if not active_family or not active_child: return @@ -224,52 +225,53 @@ def on_remove_child_clicked(obj): active_child.setMainFamily(None) if len(active_family.getChildList()) == 0: if active_family.getFather() == None: - p = active_family.getMother() - p.removeFamily(active_family) - database.deleteFamily(active_family) - flist = active_person.getFamilyList() - if len(flist) > 0: - active_family = flist[0] - else: - active_family = None + delete_family_from(active_family.getMother()) elif active_family.getMother() == None: - p = active_family.getFather() - p.removeFamily(active_family) - database.deleteFamily(active_family) - flist = active_person.getFamilyList() - if len(flist) > 0: - active_family = flist[0] - else: - active_family = None + delete_family_from(active_family.getFather()) utils.modified() load_family() +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def delete_family_from(person): + global active_family + + person.removeFamily(active_family) + database.deleteFamily(active_family) + flist = active_person.getFamilyList() + if len(flist) > 0: + active_family = flist[0] + else: + active_family = None + #------------------------------------------------------------------------- # # # #------------------------------------------------------------------------- def on_add_sp_clicked(obj): - spouseDialog = libglade.GladeXML(const.gladeFile, "spouseDialog") - - spouseList = spouseDialog.get_widget("spouseList") - spouseDialog.get_widget("rel_combo").set_popdown_strings(const.familyRelations) - rel_type = spouseDialog.get_widget("rel_type") - rel_type.set_data("d",spouseList) - rel_type.set_data("x",spouseDialog.get_widget("reldef")) + dialog = libglade.GladeXML(const.gladeFile, "spouseDialog") + dialog.get_widget("rel_combo").set_popdown_strings(const.familyRelations) - top = spouseDialog.get_widget("spouseDialog") + rel_type = dialog.get_widget("rel_type") + rel_type.set_data("d", dialog.get_widget("spouseList")) + rel_type.set_data("x", dialog.get_widget("reldef")) + + top = dialog.get_widget("spouseDialog") top.set_data(RELTYPE,rel_type) - top.set_data(GIVEN,spouseDialog.get_widget("given")) - top.set_data(SURNAME,spouseDialog.get_widget("surname")) + top.set_data(GIVEN,dialog.get_widget("given")) + top.set_data(SURNAME,dialog.get_widget("surname")) - spouseDialog.signal_autoconnect({ - "on_spouseList_select_row" : on_spouseList_select_row, + dialog.signal_autoconnect({ + "on_spouseList_select_row" : on_spouse_list_select_row, "on_select_spouse_clicked" : on_select_spouse_clicked, - "on_new_spouse_clicked" : on_new_spouse_clicked, - "on_rel_type_changed" : on_rel_type_changed, - "destroy_passed_object" : utils.destroy_passed_object + "on_new_spouse_clicked" : on_new_spouse_clicked, + "on_rel_type_changed" : on_rel_type_changed, + "destroy_passed_object" : utils.destroy_passed_object }) rel_type.set_text(_("Married")) @@ -280,7 +282,7 @@ def on_add_sp_clicked(obj): # #------------------------------------------------------------------------- def on_edit_sp_clicked(obj): - marriage_edit(active_family) + Marriage.Marriage(active_family,database) #------------------------------------------------------------------------- # @@ -317,34 +319,36 @@ def on_delete_sp_clicked(obj): # #------------------------------------------------------------------------- def on_add_child_clicked(obj): - global addChildList + global add_child_win global childWindow global select_child_list childWindow = libglade.GladeXML(const.gladeFile,"selectChild") childWindow.signal_autoconnect({ - "on_save_child_clicked" : on_save_child_clicked, - "on_addChild_select_row" : on_addChild_select_row, - "on_addChild_unselect_row" : on_addChild_unselect_row, - "on_show_toggled" : on_show_toggled, - "destroy_passed_object" : utils.destroy_passed_object + "on_save_child_clicked" : on_save_child_clicked, + "on_addChild_select_row" : on_add_child_select_row, + "on_addChild_unselect_row" : on_add_child_unselect_row, + "on_show_toggled" : on_show_toggled, + "destroy_passed_object" : utils.destroy_passed_object }) select_child_list = {} selectChild = childWindow.get_widget("selectChild") - addChildList = childWindow.get_widget("addChild") - addChildList.set_column_visibility(1,Config.id_visible) + add_child_win = childWindow.get_widget("addChild") + add_child_win.set_column_visibility(1,Config.id_visible) father = active_family.getFather() if father != None: fname = father.getPrimaryName().getName() - childWindow.get_widget("flabel").set_text(_("Relationship to %s") % fname) + ftitle = _("Relationship to %s") % fname + childWindow.get_widget("flabel").set_text(ftitle) mother = active_family.getMother() if mother != None: mname = mother.getPrimaryName().getName() - childWindow.get_widget("mlabel").set_text(_("Relationship to %s") % mname) + mtitle = _("Relationship to %s") % mname + childWindow.get_widget("mlabel").set_text(mtitle) childWindow.get_widget("mrel").set_text(_("Birth")) childWindow.get_widget("frel").set_text(_("Birth")) @@ -360,8 +364,8 @@ def on_add_child_clicked(obj): def redraw_child_list(filter): person_list = database.getPersonMap().values() person_list.sort(sort.by_last_name) - addChildList.freeze() - addChildList.clear() + add_child_win.freeze() + add_child_win.clear() index = 0 bday = active_person.getBirth().getDateObj() @@ -420,12 +424,11 @@ def redraw_child_list(filter): if pbday.getLowYear() > dday.getHighYear() + 150: continue - addChildList.append([utils.phonebook_name(person),birthday(person),\ - person.getId()]) - addChildList.set_row_data(index,person) + add_child_win.append([utils.phonebook_name(person),birthday(person),\ + person.getId()]) + add_child_win.set_row_data(index,person) index = index + 1 - - addChildList.thaw() + add_child_win.thaw() #------------------------------------------------------------------------- # @@ -441,10 +444,10 @@ def on_show_toggled(obj): # #------------------------------------------------------------------------- def on_add_new_child_clicked(obj): - global newChildWindow + global new_child_win - newChildWindow = libglade.GladeXML(const.gladeFile,"addChild") - newChildWindow.signal_autoconnect({ + new_child_win = libglade.GladeXML(const.gladeFile,"addChild") + new_child_win.signal_autoconnect({ "on_addchild_ok_clicked" : on_addchild_ok_clicked, "destroy_passed_object" : utils.destroy_passed_object }) @@ -461,27 +464,27 @@ def on_add_new_child_clicked(obj): if father != None: fname = father.getPrimaryName().getName() label = _("Relationship to %s") % fname - newChildWindow.get_widget("flabel").set_text(label) + new_child_win.get_widget("flabel").set_text(label) mother = active_family.getMother() if mother != None: mname = mother.getPrimaryName().getName() label = _("Relationship to %s") % mname - newChildWindow.get_widget("mlabel").set_text(label) + new_child_win.get_widget("mlabel").set_text(label) else: fname = active_person.getPrimaryName().getName() label = _("Relationship to %s") % fname if active_person.getGender() == Person.male: - newChildWindow.get_widget("flabel").set_text(label) - newChildWindow.get_widget("mcombo").set_sensitive(0) + new_child_win.get_widget("flabel").set_text(label) + new_child_win.get_widget("mcombo").set_sensitive(0) else: - newChildWindow.get_widget("mlabel").set_text(label) - newChildWindow.get_widget("fcombo").set_sensitive(0) + new_child_win.get_widget("mlabel").set_text(label) + new_child_win.get_widget("fcombo").set_sensitive(0) - newChildWindow.get_widget("childSurname").set_text(surname) - newChildWindow.get_widget("addChild").show() - newChildWindow.get_widget("mrel").set_text(_("Birth")) - newChildWindow.get_widget("frel").set_text(_("Birth")) + new_child_win.get_widget("childSurname").set_text(surname) + new_child_win.get_widget("addChild").show() + new_child_win.get_widget("mrel").set_text(_("Birth")) + new_child_win.get_widget("frel").set_text(_("Birth")) #------------------------------------------------------------------------- # @@ -491,19 +494,18 @@ def on_add_new_child_clicked(obj): def on_addchild_ok_clicked(obj): global active_family - surname = newChildWindow.get_widget("childSurname").get_text() - given = newChildWindow.get_widget("childGiven").get_text() + surname = new_child_win.get_widget("childSurname").get_text() + given = new_child_win.get_widget("childGiven").get_text() person = Person() database.addPerson(person) name = Name() - name.setSurname(surname) name.setFirstName(given) person.setPrimaryName(name) - if newChildWindow.get_widget("childGender").get_active(): + if new_child_win.get_widget("childGender").get_active(): person.setGender(Person.male) else: person.setGender(Person.female) @@ -516,8 +518,8 @@ def on_addchild_ok_clicked(obj): active_family.setMother(active_person) active_person.addFamily(active_family) - mrel = const.childRelations[newChildWindow.get_widget("mrel").get_text()] - frel = const.childRelations[newChildWindow.get_widget("frel").get_text()] + mrel = const.childRelations[new_child_win.get_widget("mrel").get_text()] + frel = const.childRelations[new_child_win.get_widget("frel").get_text()] if mrel == "Birth" and frel == "Birth": person.setMainFamily(active_family) @@ -579,20 +581,6 @@ def on_save_child_clicked(obj): utils.destroy_passed_object(obj) load_family() -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def get_option_index(obj): - active_item = obj.get_active() - index = 0 - for item in obj.children(): - if item == active_item: - break - index = index + 1 - return index - #------------------------------------------------------------------------- # # @@ -633,8 +621,8 @@ def on_choose_parents_clicked(obj): fcombo.set_popdown_strings(const.familyRelations) family_window.signal_autoconnect({ - "on_motherList_select_row" : on_motherList_select_row, - "on_fatherList_select_row" : on_fatherList_select_row, + "on_motherList_select_row" : on_mother_list_select_row, + "on_fatherList_select_row" : on_father_list_select_row, "on_save_parents_clicked" : on_save_parents_clicked, "on_prel_changed" : on_prel_changed, "destroy_passed_object" : utils.destroy_passed_object @@ -663,21 +651,21 @@ def on_prel_changed(obj): motherName = family_window.get_widget("motherName") motherName.set_text(Config.nameof(select_mother)) - fatherList = family_window.get_widget("fatherList") - motherList = family_window.get_widget("motherList") + father_list = family_window.get_widget("fatherList") + mother_list = family_window.get_widget("motherList") - fatherList.freeze() - motherList.freeze() - fatherList.clear() - motherList.clear() + father_list.freeze() + mother_list.freeze() + father_list.clear() + mother_list.clear() - fatherList.append(["Unknown",""]) - fatherList.set_row_data(0,None) - fatherList.set_data("father_text",fatherName) + father_list.append(["Unknown",""]) + father_list.set_row_data(0,None) + father_list.set_data("father_text",fatherName) - motherList.append(["Unknown",""]) - motherList.set_row_data(0,None) - motherList.set_data("mother_text",motherName) + mother_list.append(["Unknown",""]) + mother_list.set_row_data(0,None) + mother_list.set_data("mother_text",motherName) people = database.getPersonMap().values() people.sort(sort.by_last_name) @@ -687,19 +675,19 @@ def on_prel_changed(obj): if person == active_person: continue elif type == "Partners": - fatherList.append([utils.phonebook_name(person),birthday(person)]) - fatherList.set_row_data(father_index,person) + father_list.append([utils.phonebook_name(person),birthday(person)]) + father_list.set_row_data(father_index,person) father_index = father_index + 1 - motherList.append([utils.phonebook_name(person),birthday(person)]) - motherList.set_row_data(mother_index,person) + mother_list.append([utils.phonebook_name(person),birthday(person)]) + mother_list.set_row_data(mother_index,person) mother_index = mother_index + 1 elif person.getGender() == Person.male: - fatherList.append([utils.phonebook_name(person),birthday(person)]) - fatherList.set_row_data(father_index,person) + father_list.append([utils.phonebook_name(person),birthday(person)]) + father_list.set_row_data(father_index,person) father_index = father_index + 1 else: - motherList.append([utils.phonebook_name(person),birthday(person)]) - motherList.set_row_data(mother_index,person) + mother_list.append([utils.phonebook_name(person),birthday(person)]) + mother_list.set_row_data(mother_index,person) mother_index = mother_index + 1 if type == "Partners": @@ -709,8 +697,8 @@ def on_prel_changed(obj): family_window.get_widget("mlabel").set_text(_("Mother")) family_window.get_widget("flabel").set_text(_("Father")) - motherList.thaw() - fatherList.thaw() + mother_list.thaw() + father_list.thaw() #------------------------------------------------------------------------- # @@ -760,14 +748,6 @@ def new_database_response(val): load_sources() load_places() -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def marriage_edit(family): - Marriage.Marriage(family,database) - #------------------------------------------------------------------------- # # @@ -775,6 +755,7 @@ def marriage_edit(family): #------------------------------------------------------------------------- def tool_callback(val): if val: + utils.modified() full_update() #------------------------------------------------------------------------- @@ -789,7 +770,7 @@ def full_update(): id2col = {} alt2col = {} person_list.clear() - gtop.get_widget(NOTEBOOK).set_show_tabs(Config.usetabs) + notebook.set_show_tabs(Config.usetabs) clist = gtop.get_widget("child_list") clist.set_column_visibility(4,Config.show_detail) clist.set_column_visibility(1,Config.id_visible) @@ -805,7 +786,7 @@ def full_update(): # #------------------------------------------------------------------------- def update_display(changed): - page = gtop.get_widget(NOTEBOOK).get_current_page() + page = notebook.get_current_page() if page == 0: if changed: apply_filter() @@ -853,14 +834,12 @@ def load_sources(): # # #------------------------------------------------------------------------- -def on_source_list_button_press_event(obj,event): +def on_src_list_button_press_event(obj,event): if event.button == 1 and event.type == GDK._2BUTTON_PRESS: index = obj.get_data("i") - if index == -1: - return - - source = obj.get_row_data(index) - EditSource.EditSource(source,database,update_source_after_edit) + if index >= 0: + source = obj.get_row_data(index) + EditSource.EditSource(source,database,update_after_edit) #------------------------------------------------------------------------- # @@ -870,26 +849,16 @@ def on_source_list_button_press_event(obj,event): def on_place_list_button_press_event(obj,event): if event.button == 1 and event.type == GDK._2BUTTON_PRESS: index = obj.get_data("i") - if index == -1: - return - - place = obj.get_row_data(index) - EditPlace.EditPlace(place,database,update_place_after_edit) + if index >= 0: + place = obj.get_row_data(index) + EditPlace.EditPlace(place,database,update_after_edit) #------------------------------------------------------------------------- # # # #------------------------------------------------------------------------- -def on_source_list_select_row(obj,a,b,c): - obj.set_data("i",a) - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_place_list_select_row(obj,a,b,c): +def on_list_select_row(obj,a,b,c): obj.set_data("i",a) #------------------------------------------------------------------------- @@ -984,7 +953,6 @@ def on_delete_place_clicked(obj): msg = t % (fname,e[0].getId(),e[1].getName()) textbox.insert_defaults(msg) - #------------------------------------------------------------------------- # # @@ -1012,7 +980,7 @@ def on_edit_source_clicked(obj): index = obj.get_data("i") if index != -1: source = obj.get_row_data(index) - EditSource.EditSource(source,database,update_source_after_edit) + EditSource.EditSource(source,database,update_after_edit) #------------------------------------------------------------------------- # @@ -1023,7 +991,7 @@ def on_edit_place_clicked(obj): index = obj.get_data("i") if index != -1: place = obj.get_row_data(index) - EditPlace.EditPlace(place,database,update_place_after_edit) + EditPlace.EditPlace(place,database,update_after_edit) #------------------------------------------------------------------------- # @@ -1048,17 +1016,9 @@ def new_place_after_edit(place): # # #------------------------------------------------------------------------- -def update_source_after_edit(source): +def update_after_edit(source): update_display(0) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def update_place_after_edit(source): - update_display(0) - #------------------------------------------------------------------------- # # @@ -1534,7 +1494,6 @@ def on_rel_type_changed(obj): spouse_list.clear() spouse_list.freeze() deftxt = obj.get_data("x") - text = obj.get_text() deftxt.set_text(const.relationship_def(text)) @@ -1548,7 +1507,6 @@ def on_rel_type_changed(obj): index = 0 for person in nameList: - if person.getGender() == gender: continue spouse_list.append([person.getPrimaryName().getName(),birthday(person)]) @@ -1566,7 +1524,6 @@ def on_delete_parents_clicked(obj): return active_parents.removeChild(active_person) - if active_parents == active_person.getMainFamily(): active_person.setMainFamily(None) else: @@ -1594,66 +1551,47 @@ def on_person_list_select_row(obj,a,b,c): # #------------------------------------------------------------------------- def on_person_list_click_column(obj,column): - global sort_column - global sort_direct - - nameArrow = gtop.get_widget("nameSort") - dateArrow = gtop.get_widget("dateSort") - deathArrow= gtop.get_widget("deathSort") - if column == 0: - dateArrow.hide() - deathArrow.hide() - nameArrow.show() - if sort_column == 5: - if sort_direct == SORT_DESCENDING: - sort_direct = SORT_ASCENDING - nameArrow.set(GTK.ARROW_DOWN,2) - else: - sort_direct = SORT_DESCENDING - nameArrow.set(GTK.ARROW_UP,2) - else: - sort_direct = SORT_DESCENDING - sort_column = 5 + change_sort(5,gtop.get_widget("nameSort")) elif column == 3: - nameArrow.hide() - deathArrow.hide() - dateArrow.show() - if sort_column == 6: - if sort_direct == SORT_ASCENDING: - sort_direct = SORT_DESCENDING - dateArrow.set(GTK.ARROW_UP,2) - else: - sort_direct = SORT_ASCENDING - dateArrow.set(GTK.ARROW_DOWN,2) - else: - sort_direct = SORT_ASCENDING - sort_column = 6 + change_sort(6,gtop.get_widget("dateSort")) elif column == 4: - nameArrow.hide() - deathArrow.show() - dateArrow.hide() - if sort_column == 7: - if sort_direct == SORT_ASCENDING: - sort_direct = SORT_DESCENDING - deathArrow.set(GTK.ARROW_UP,2) - else: - sort_direct = SORT_ASCENDING - deathArrow.set(GTK.ARROW_DOWN,2) - else: - sort_direct = SORT_ASCENDING - sort_column = 7 + change_sort(7,gtop.get_widget("deathSort")) else: return - person_list.set_sort_type(sort_direct) - person_list.set_sort_column(sort_column) sort_person_list() - if id2col.has_key(active_person): row = person_list.find_row_from_data(id2col[active_person]) person_list.moveto(row) +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def change_sort(column,arrow): + global sort_direct + global sort_column + + nameArrow.hide() + deathArrow.hide() + dateArrow.hide() + arrow.show() + + if sort_column == column: + if sort_direct == SORT_DESCENDING: + sort_direct = SORT_ASCENDING + arrow.set(GTK.ARROW_DOWN,2) + else: + sort_direct = SORT_DESCENDING + arrow.set(GTK.ARROW_UP,2) + else: + sort_direct = SORT_ASCENDING + sort_column = column + person_list.set_sort_type(sort_direct) + person_list.set_sort_column(sort_column) + #------------------------------------------------------------------------- # # @@ -1685,7 +1623,7 @@ def sort_person_list(): # # #------------------------------------------------------------------------- -def on_fatherList_select_row(obj,a,b,c): +def on_father_list_select_row(obj,a,b,c): global select_father select_father = obj.get_row_data(a) @@ -1696,23 +1634,23 @@ def on_fatherList_select_row(obj,a,b,c): # # #------------------------------------------------------------------------- -def on_addChild_select_row(obj,a,b,c): - select_child_list[obj.get_row_data(a)] = 1 +def on_add_child_select_row(obj,row,b,c): + select_child_list[obj.get_row_data(row)] = 1 #------------------------------------------------------------------------- # # # #------------------------------------------------------------------------- -def on_addChild_unselect_row(obj,a,b,c): - del select_child_list[obj.get_row_data(a)] +def on_add_child_unselect_row(obj,row,b,c): + del select_child_list[obj.get_row_data(row)] #------------------------------------------------------------------------- # # # #------------------------------------------------------------------------- -def on_motherList_select_row(obj,a,b,c): +def on_mother_list_select_row(obj,a,b,c): global select_mother select_mother = obj.get_row_data(a) @@ -1774,18 +1712,18 @@ def modify_statusbar(): # # #------------------------------------------------------------------------- -def on_child_list_select_row(obj,a,b,c): +def on_child_list_select_row(obj,row,b,c): global active_child - active_child = obj.get_row_data(a) + active_child = obj.get_row_data(row) #------------------------------------------------------------------------- # # # #------------------------------------------------------------------------- -def on_spouseList_select_row(obj,a,b,c): +def on_spouse_list_select_row(obj,row,b,c): global select_spouse - select_spouse = obj.get_row_data(a) + select_spouse = obj.get_row_data(row) #------------------------------------------------------------------------- # @@ -1845,6 +1783,7 @@ def on_save_as_activate(obj): "on_ok_button1_clicked": on_ok_button2_clicked, "destroy_passed_object": utils.destroy_passed_object }) + fileSelector = wFs.get_widget(FILESEL) fileSelector.show() @@ -1865,24 +1804,19 @@ def on_save_activate(obj): # #------------------------------------------------------------------------- def on_person_list1_activate(obj): - notebk = gtop.get_widget(NOTEBOOK) - notebk.set_page(0) + notebook.set_page(0) def on_family1_activate(obj): - notebk = gtop.get_widget(NOTEBOOK) - notebk.set_page(1) + notebook.set_page(1) def on_pedegree1_activate(obj): - notebk = gtop.get_widget(NOTEBOOK) - notebk.set_page(2) + notebook.set_page(2) def on_sources_activate(obj): - notebk = gtop.get_widget(NOTEBOOK) - notebk.set_page(3) + notebook.set_page(3) def on_places_activate(obj): - notebk = gtop.get_widget(NOTEBOOK) - notebk.set_page(4) + notebook.set_page(4) #------------------------------------------------------------------------- # @@ -2001,10 +1935,9 @@ def on_arrow_left_clicked(obj): #------------------------------------------------------------------------- def on_childmenu_changed(obj): person = obj.get_data("person") - if person == None: - return - change_active_person(person) - load_tree() + if person: + change_active_person(person) + load_tree() #------------------------------------------------------------------------- # @@ -2078,8 +2011,8 @@ def on_apply_filter_clicked(obj): invert_filter = gtop.get_widget("invert").get_active() qualifer = gtop.get_widget("filter").get_text() menu = gtop.get_widget(FILTERNAME).get_menu() - function = menu.get_active().get_data("filter") - DataFilter = function(qualifer) + class_init = menu.get_active().get_data("filter") + DataFilter = class_init(qualifer) DataFilter.set_invert(invert_filter) apply_filter() @@ -2089,8 +2022,7 @@ def on_apply_filter_clicked(obj): # #------------------------------------------------------------------------- def on_filter_name_changed(obj): - function = obj.get_data("function") - gtop.get_widget("filter").set_sensitive(function()) + gtop.get_widget("filter").set_sensitive(obj.get_data("qual")) #------------------------------------------------------------------------- # @@ -2380,17 +2312,17 @@ def load_canvas(): w = 0 style = canvas['style'] - font = canvas['style'].font + font = style.font list = [None]*31 find_tree(active_person,0,1,list) for t in list: if t: n = t.getPrimaryName().getName() - h = max(h,font.height(n)+6) - w = max(w,font.width(n)+6) - w = max(w,font.width("d. %s" % t.getDeath().getDate())+6) - w = max(w,font.width("b. %s" % t.getBirth().getDate())+6) + h = max(h,font.height(n)+2*PAD) + w = max(w,font.width(n)+2*PAD) + w = max(w,font.width("d. %s" % t.getDeath().getDate())+2*PAD) + w = max(w,font.width("b. %s" % t.getBirth().getDate())+2*PAD) if 5*w < cx2 and 24*h < cy2: gen = 31 @@ -2410,16 +2342,13 @@ def load_canvas(): xincr = cx2/xdiv yincr = cy2/32 - xfactor = [0] + [xincr]*2 + [xincr*2]*4 + [xincr*3] * 8 + [xincr*4] * 16 + xfactor = [0] + [xincr]*2 + [xincr*2]*4 + [xincr*3]*8 + [xincr*4]*16 yfactor = [ yincr*16, yincr*8,yincr*24,yincr*4,yincr*12,yincr*20, yincr*28, yincr*2, yincr*6,yincr*10,yincr*14,yincr*18,yincr*22,yincr*26, yincr*30, yincr, yincr*3, yincr*5, yincr*7, yincr*9, yincr*11, yincr*13, yincr*15, yincr*17, yincr*19, yincr*21, yincr*23, yincr*25, yincr*27, yincr*29, yincr*31] - for i in range(31): - yfactor[i]=yfactor[i] - for i in range(gen): if list[i]: if i < int(gen/2): @@ -2428,13 +2357,17 @@ def load_canvas(): pts = [startx,yfactor[i], startx,yfactor[(i*2)+1]+(h/2), xfactor[(i*2)+1],yfactor[(i*2)+1]+(h/2)] - item = root.add("line",points=pts,fill_color_gdk=style.black) + item = root.add("line", + points=pts, + fill_color_gdk=style.black) canvas_items.append(item) if list[(2*i)+2]: pts = [startx,yfactor[i]+h, startx,yfactor[(i*2)+2]+(h/2), xfactor[(i*2)+2],yfactor[(i*2)+2]+(h/2)] - item = root.add("line",points=pts,fill_color_gdk=style.black) + item = root.add("line", + points=pts, + fill_color_gdk=style.black) canvas_items.append(item) add_box(root,xfactor[i],yfactor[i],w,h,list[i],style) @@ -2448,8 +2381,8 @@ def load_canvas(): # #------------------------------------------------------------------------- def add_box(root,x,y,bwidth,bheight,person,style): - shadow = 3 - xpad = 3 + shadow = PAD + xpad = PAD name = person.getPrimaryName().getName() group = root.add("group",x=x,y=y) @@ -2467,7 +2400,7 @@ def add_box(root,x,y,bwidth,bheight,person,style): y1=0, x2=bwidth, y2=bheight, - outline_color_gdk=style.white, + outline_color_gdk=style.fg[STATE_NORMAL], fill_color_gdk=style.white) canvas_items.append(item) item = group.add("text", @@ -2499,21 +2432,21 @@ def box_event(obj,event): outline_color_gdk=canvas['style'].black) box2 = obj.children()[0] x,y,w,h1 = box2.get_bounds() - box2.set(x1=x,y1=y,x2=w,y2=(3*h)+3) + box2.set(x1=x,y1=y,x2=w,y2=(3*h)+PAD) person = obj.get_data('p') obj.add("text", font_gdk=canvas['style'].font, fill_color_gdk=canvas['style'].text[STATE_NORMAL], text="b. %s" % person.getBirth().getDate(), anchor=ANCHOR_WEST, - x=3, + x=PAD, y=h+(h/2)) obj.add("text", font_gdk=canvas['style'].font, fill_color_gdk=canvas['style'].text[STATE_NORMAL], text="d. %s" % person.getDeath().getDate(), anchor=ANCHOR_WEST, - x=3, + x=PAD, y=2*h+(h/2)) elif event.type == GDK.LEAVE_NOTIFY: @@ -2521,10 +2454,10 @@ def box_event(obj,event): box = obj.children()[1] x,y,w,h = box.get_bounds() box.set(x1=x,y1=y,x2=w,y2=h/3, - outline_color_gdk=canvas['style'].white) + outline_color_gdk=canvas['style'].fg[STATE_NORMAL]) box2 = obj.children()[0] x,y,w,h1 = box2.get_bounds() - box2.set(x1=x,y1=y,x2=w,y2=(h/3)+3) + box2.set(x1=x,y1=y,x2=w,y2=(h/3)+PAD) obj.children()[4].destroy() obj.children()[3].destroy() canvas.update_now() @@ -2682,8 +2615,6 @@ def load_progress(value): # #------------------------------------------------------------------------- def load_database(name): - import ReadXML - global active_person filename = name + os.sep + const.indexFile @@ -2743,11 +2674,9 @@ def load_database(name): #------------------------------------------------------------------------- def setup_bookmarks(): global bookmarks - - menu = gtop.get_widget("jump_to") - person_map = database.getPersonMap() - bookmarks = Bookmarks.Bookmarks(database.getBookmarks(),person_map,\ - menu,bookmark_callback) + bookmarks = Bookmarks.Bookmarks(database.getBookmarks(), + gtop.get_widget("jump_to"), + bookmark_callback) #------------------------------------------------------------------------- # @@ -2768,7 +2697,6 @@ def apply_filter(): global alt2col person_list.freeze() - datacomp = DataFilter.compare gname = utils.phonebook_from_name @@ -2777,7 +2705,6 @@ def apply_filter(): for person in database.getPersonMap().values(): if datacomp(person): - if id2col.has_key(person): new_alt2col[person] = alt2col[person] continue @@ -2797,10 +2724,11 @@ def apply_filter(): qbday = bday.getQuoteDate() qdday = dday.getQuoteDate() pid = person.getId() + bsn = sort.build_sort_name name = person.getPrimaryName() - person_list.insert(0,[gname(name,0),pid, gender,qbday,qdday, - sort.build_sort_name(name),sort_bday,sort_dday]) + person_list.insert(0,[gname(name,0), pid, gender, qbday, qdday, + bsn(name), sort_bday, sort_dday]) person_list.set_row_data(0,pos) if Config.hide_altnames: @@ -2810,8 +2738,8 @@ def apply_filter(): pos = (person,1) new_alt2col[person].append(pos) - person_list.insert(0,[gname(name,1),pid,gender,qbday,qdday, - sort.build_sort_name(name),sort_bday,sort_dday]) + person_list.insert(0,[gname(name,1), pid, gender, qbday, qdday, + bsn(name), sort_bday, sort_dday]) person_list.set_row_data(0,pos) else: @@ -2883,8 +2811,8 @@ def on_edit_bookmarks_activate(obj): def on_default_person_activate(obj): if active_person: name = active_person.getPrimaryName().getRegularName() - topWindow.question(_("Do you wish to set %s as the home person?") % name, \ - set_person) + msg = _("Do you wish to set %s as the home person?") % name + topWindow.question(msg,set_person) #------------------------------------------------------------------------- # @@ -2942,45 +2870,6 @@ def bookmark_callback(obj,person): def on_preferences_activate(obj): Config.display_preferences_box() -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def build_report_menu(): - - report_menu = GtkMenu() - report_menu.show() - - hash = {} - for report in Plugins.reports: - if report.__dict__.has_key("get_name"): - info = string.split(report.get_name(),'/') - else: - info = string.split(report.__doc__,'/') - if hash.has_key(info[0]): - hash[info[0]].append((info[1],report.report)) - else: - hash[info[0]] = [(info[1],report.report)] - - catlist = hash.keys() - catlist.sort() - for key in catlist: - entry = GtkMenuItem(key) - entry.show() - report_menu.append(entry) - submenu = GtkMenu() - submenu.show() - entry.set_submenu(submenu) - list = hash[key] - list.sort() - for name in list: - subentry = GtkMenuItem(name[0]) - subentry.show() - subentry.connect("activate",menu_report,name[1]) - submenu.append(subentry) - return report_menu - #------------------------------------------------------------------------- # # @@ -2990,45 +2879,6 @@ def menu_report(obj,task): if active_person: task(database,active_person) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def build_tools_menu(): - - report_menu = GtkMenu() - report_menu.show() - - hash = {} - for report in Plugins.tools: - if report.__dict__.has_key("get_name"): - info = string.split(report.get_name(),'/') - else: - info = string.split(report.__doc__,'/') - if hash.has_key(info[0]): - hash[info[0]].append((info[1],report.runTool)) - else: - hash[info[0]] = [(info[1],report.runTool)] - - catlist = hash.keys() - catlist.sort() - for key in catlist: - entry = GtkMenuItem(key) - entry.show() - report_menu.append(entry) - submenu = GtkMenu() - submenu.show() - entry.set_submenu(submenu) - list = hash[key] - list.sort() - for name in list: - subentry = GtkMenuItem(name[0]) - subentry.show() - subentry.connect("activate",menu_tools,name[1]) - submenu.append(subentry) - return report_menu - #------------------------------------------------------------------------- # # @@ -3046,28 +2896,23 @@ def menu_tools(obj,task): def main(arg): global database, gtop - global statusbar + global statusbar,notebook global person_list, source_list, place_list,pv global topWindow - import ReadXML - rc_parse(const.gtkrcFile) + Plugins.load_plugins(const.pluginsDir) + Plugins.load_plugins(os.path.expanduser("~/.gramps/plugins")) Filter.load_filters(const.filtersDir) - path = os.path.expanduser("~/.gramps/plugins") - if os.path.isdir(path): - Plugins.load_plugins(path) - path = os.path.expanduser("~/.gramps/filters") - if os.path.isdir(path): - Filter.load_filters(path) + Filter.load_filters(os.path.expanduser("~/.gramps/filters")) gtop = libglade.GladeXML(const.gladeFile, "gramps") - gtop.get_widget("reports_menu").set_submenu(build_report_menu()) - gtop.get_widget("tools_menu").set_submenu(build_tools_menu()) - gtop.get_widget("export1").set_submenu(Plugins.export_menu(export_callback)) - gtop.get_widget("import1").set_submenu(Plugins.import_menu(import_callback)) + Plugins.build_report_menu(gtop.get_widget("reports_menu"),menu_report) + Plugins.build_tools_menu(gtop.get_widget("tools_menu"),menu_tools) + Plugins.build_export_menu(gtop.get_widget("export1"),export_callback) + Plugins.build_import_menu(gtop.get_widget("import1"),import_callback) statusbar = gtop.get_widget("statusbar") topWindow = gtop.get_widget("gramps") @@ -3075,22 +2920,15 @@ def main(arg): source_list = gtop.get_widget("source_list") place_list = gtop.get_widget("place_list") filter_list = gtop.get_widget("filter_list") + notebook = gtop.get_widget(NOTEBOOK) person_list.set_column_visibility(5,0) person_list.set_column_visibility(6,0) person_list.set_column_visibility(7,0) person_list.set_sort_column(sort_column) person_list.set_sort_type(sort_direct) - - myMenu = GtkMenu() - for filter in Filter.filterList: - menuitem = GtkMenuItem(filter) - myMenu.append(menuitem) - menuitem.set_data("filter",Filter.filterMap[filter]) - menuitem.set_data("function",Filter.filterEnb[filter]) - menuitem.connect("activate",on_filter_name_changed) - menuitem.show() - filter_list.set_menu(myMenu) + + filter_list.set_menu(Filter.build_filter_menu(on_filter_name_changed)) gtop.get_widget("filter").set_sensitive(0) @@ -3103,76 +2941,77 @@ def main(arg): pv[box] = gtop.get_widget("pv%d" % box) gtop.signal_autoconnect({ - "on_about_activate": on_about_activate, - "on_reports_clicked" : on_reports_clicked, - "on_person_list1_activate": on_person_list1_activate, - "on_family1_activate" : on_family1_activate, - "on_sources_activate" : on_sources_activate, - "on_places_activate" : on_places_activate, - "on_pedegree1_activate" : on_pedegree1_activate, - "on_notebook1_switch_page": on_notebook1_switch_page, - "on_ok_button1_clicked": on_ok_button1_clicked, - "on_father_next_clicked": on_father_next_clicked, - "on_mother_next_clicked": on_mother_next_clicked, - "on_person_list_select_row": on_person_list_select_row, - "on_person_list_click_column": on_person_list_click_column, - "on_person_list_button_press": on_person_list_button_press, - "destroy_passed_object": utils.destroy_passed_object, - "on_swap_clicked" : on_swap_clicked, - "on_child_list_button_press_event" : on_child_list_button_press_event, - "on_child_list_select_row" : on_child_list_select_row, - "on_fv_prev_clicked" : on_fv_prev_clicked, - "on_delete_parents_clicked" : on_delete_parents_clicked, - "on_contents_activate" : on_contents_activate, - "on_choose_parents_clicked" : on_choose_parents_clicked, - "on_spouselist_changed" : on_spouselist_changed, - "on_home_clicked" : on_home_clicked, - "on_default_person_activate" : on_default_person_activate, - "on_pv_n0_clicked" : on_pv_n0_clicked, - "on_pv_n1_clicked" : on_pv_n1_clicked, - "on_apply_filter_clicked": on_apply_filter_clicked, - "on_save_as_activate" : on_save_as_activate, - "on_add_new_child_clicked" : on_add_new_child_clicked, - "on_tools_clicked" : on_tools_clicked, - "on_save_activate" : on_save_activate, - "on_revert_activate" : on_revert_activate, - "on_add_child_clicked" : on_add_child_clicked, - "on_edit_sp_clicked" : on_edit_sp_clicked, - "on_add_sp_clicked" : on_add_sp_clicked, - "on_delete_sp_clicked" : on_delete_sp_clicked, - "on_remove_child_clicked" : on_remove_child_clicked, - "on_new_clicked" : on_new_clicked, - "on_add_bookmark_activate" : on_add_bookmark_activate, - "on_arrow_left_clicked" : on_arrow_left_clicked, - "on_addperson_clicked" : load_new_person, - "on_delete_person_clicked" : on_delete_person_clicked, - "on_preferences_activate" : on_preferences_activate, - "on_pv_button_press_event" : on_pv_button_press_event, - "on_edit_bookmarks_activate" : on_edit_bookmarks_activate, - "on_edit_active_person" : load_active_person, - "on_edit_spouse_clicked" : on_edit_spouse_clicked, - "on_edit_father_clicked" : on_edit_father_clicked, - "on_edit_mother_clicked" : on_edit_mother_clicked, - "on_exit_activate" : on_exit_activate, - "on_add_source_clicked" : on_add_source_clicked, - "on_add_place_clicked" : on_add_place_clicked, - "on_source_list_button_press_event" : on_source_list_button_press_event, - "on_source_list_select_row": on_source_list_select_row, - "on_place_list_button_press_event" : on_place_list_button_press_event, - "on_place_list_select_row": on_place_list_select_row, - "on_delete_source_clicked" : on_delete_source_clicked, - "on_delete_place_clicked" : on_delete_place_clicked, - "on_edit_source_clicked" : on_edit_source_clicked, - "on_edit_place_clicked" : on_edit_place_clicked, - "delete_event" : delete_event, - "on_canvas1_size_request": on_canvas1_size_request, - "on_open_activate" : on_open_activate + "delete_event" : delete_event, + "destroy_passed_object" : utils.destroy_passed_object, + "on_about_activate" : on_about_activate, + "on_add_bookmark_activate" : on_add_bookmark_activate, + "on_add_child_clicked" : on_add_child_clicked, + "on_add_new_child_clicked" : on_add_new_child_clicked, + "on_add_place_clicked" : on_add_place_clicked, + "on_add_source_clicked" : on_add_source_clicked, + "on_add_sp_clicked" : on_add_sp_clicked, + "on_addperson_clicked" : load_new_person, + "on_apply_filter_clicked" : on_apply_filter_clicked, + "on_arrow_left_clicked" : on_arrow_left_clicked, + "on_canvas1_size_request" : on_canvas1_size_request, + "on_child_list_button_press_event" : on_child_list_button_press_event, + "on_child_list_select_row" : on_child_list_select_row, + "on_choose_parents_clicked" : on_choose_parents_clicked, + "on_contents_activate" : on_contents_activate, + "on_default_person_activate" : on_default_person_activate, + "on_delete_parents_clicked" : on_delete_parents_clicked, + "on_delete_person_clicked" : on_delete_person_clicked, + "on_delete_place_clicked" : on_delete_place_clicked, + "on_delete_source_clicked" : on_delete_source_clicked, + "on_delete_sp_clicked" : on_delete_sp_clicked, + "on_edit_active_person" : load_active_person, + "on_edit_bookmarks_activate" : on_edit_bookmarks_activate, + "on_edit_father_clicked" : on_edit_father_clicked, + "on_edit_mother_clicked" : on_edit_mother_clicked, + "on_edit_place_clicked" : on_edit_place_clicked, + "on_edit_source_clicked" : on_edit_source_clicked, + "on_edit_sp_clicked" : on_edit_sp_clicked, + "on_edit_spouse_clicked" : on_edit_spouse_clicked, + "on_exit_activate" : on_exit_activate, + "on_family1_activate" : on_family1_activate, + "on_father_next_clicked" : on_father_next_clicked, + "on_fv_prev_clicked" : on_fv_prev_clicked, + "on_home_clicked" : on_home_clicked, + "on_mother_next_clicked" : on_mother_next_clicked, + "on_new_clicked" : on_new_clicked, + "on_notebook1_switch_page" : on_notebook1_switch_page, + "on_ok_button1_clicked" : on_ok_button1_clicked, + "on_open_activate" : on_open_activate, + "on_pedegree1_activate" : on_pedegree1_activate, + "on_person_list1_activate" : on_person_list1_activate, + "on_person_list_button_press" : on_person_list_button_press, + "on_person_list_click_column" : on_person_list_click_column, + "on_person_list_select_row" : on_person_list_select_row, + "on_place_list_button_press_event" : on_place_list_button_press_event, + "on_place_list_select_row" : on_list_select_row, + "on_places_activate" : on_places_activate, + "on_preferences_activate" : on_preferences_activate, + "on_pv_button_press_event" : on_pv_button_press_event, + "on_pv_n0_clicked" : on_pv_n0_clicked, + "on_pv_n1_clicked" : on_pv_n1_clicked, + "on_remove_child_clicked" : on_remove_child_clicked, + "on_reports_clicked" : on_reports_clicked, + "on_revert_activate" : on_revert_activate, + "on_save_activate" : on_save_activate, + "on_save_as_activate" : on_save_as_activate, + "on_source_list_button_press_event" : on_src_list_button_press_event, + "on_source_list_select_row" : on_list_select_row, + "on_sources_activate" : on_sources_activate, + "on_spouselist_changed" : on_spouselist_changed, + "on_swap_clicked" : on_swap_clicked, + "on_tools_clicked" : on_tools_clicked, }) database = RelDataBase() Config.loadConfig(full_update) person_list.set_column_visibility(1,Config.id_visible) - gtop.get_widget(NOTEBOOK).set_show_tabs(Config.usetabs) + + notebook.set_show_tabs(Config.usetabs) gtop.get_widget("child_list").set_column_visibility(4,Config.show_detail) if arg != None: diff --git a/src/plugins/AncestorChart.py b/src/plugins/AncestorChart.py index c16538825..374cf3314 100644 --- a/src/plugins/AncestorChart.py +++ b/src/plugins/AncestorChart.py @@ -302,7 +302,7 @@ def report(database,person): topDialog.signal_autoconnect({ "destroy_passed_object" : utils.destroy_passed_object, "on_style_edit_clicked" : on_style_edit_clicked, - "on_save_clicked" : on_save_clicked + "on_save_clicked" : on_save_clicked }) #------------------------------------------------------------------------ @@ -364,27 +364,10 @@ def on_save_clicked(obj): doc = FindDoc.make_draw_doc(styles,format,paper,orien) MyReport = AncestorReport(db,text,active_person,outputName,doc,max_gen) - MyReport.write_report() utils.destroy_passed_object(obj) -#------------------------------------------------------------------------ -# -# -# -#------------------------------------------------------------------------ -def get_description(): - return _("Produces a graphical ancestral tree graph") - -#------------------------------------------------------------------------ -# -# -# -#------------------------------------------------------------------------ -def get_name(): - return _("Generate files/Ancestor Chart") - #------------------------------------------------------------------------ # # @@ -446,11 +429,18 @@ def get_xpm_image(): " ", " "] +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +from Plugins import register_report - - - - - - +register_report( + report, + _("Ancestor Chart"), + category=_("Generate Files"), + description=_("Produces a graphical ancestral tree graph"), + xpm=get_xpm_image() + ) diff --git a/src/plugins/AncestorReport.py b/src/plugins/AncestorReport.py index 28af41090..8511d0463 100644 --- a/src/plugins/AncestorReport.py +++ b/src/plugins/AncestorReport.py @@ -401,17 +401,6 @@ def on_save_clicked(obj): utils.destroy_passed_object(obj) -#------------------------------------------------------------------------ -# -# -# -#------------------------------------------------------------------------ -def get_description(): - return _("Produces a textual ancestral report") - -def get_name(): - return _("Generate files/Ahnentafel Report") - #------------------------------------------------------------------------ # # @@ -472,3 +461,19 @@ def get_xpm_image(): " ", " ", " "] + +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +from Plugins import register_report + +register_report( + report, + _("Ahnentafel Report"), + category=_("Generate Files"), + description= _("Produces a textual ancestral report"), + xpm=get_xpm_image() + ) + diff --git a/src/plugins/ChangeTypes.py b/src/plugins/ChangeTypes.py index 3e5536806..3967f37bf 100644 --- a/src/plugins/ChangeTypes.py +++ b/src/plugins/ChangeTypes.py @@ -87,13 +87,16 @@ def runTool(database,person,callback): "on_apply_clicked" : on_apply_clicked }) -#------------------------------------------------------------------------- +#------------------------------------------------------------------------ # +# # -# -#------------------------------------------------------------------------- -def get_description(): - return _("Allows all the events of a certain name to be renamed to a new name") +#------------------------------------------------------------------------ +from Plugins import register_tool -def get_name(): - return _("Database Processing/Rename personal event types") +register_tool( + runTool, + _("Rename personal event types"), + category=_("Database Processing"), + description=_("Allows all the events of a certain name to be renamed to a new name") + ) diff --git a/src/plugins/Check.py b/src/plugins/Check.py index de921e85c..9b3793c3d 100644 --- a/src/plugins/Check.py +++ b/src/plugins/Check.py @@ -226,14 +226,18 @@ class CheckIntegrity: topDialog.get_widget("summaryTitle").set_text(title) textwindow.show_string(text) top.show() - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def get_description(): - return _("Checks the database for integrity problems, fixing the problems that it can") -def get_name(): - return _("Database Processing/Check and repair database") +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +from Plugins import register_tool + +register_tool( + runTool, + _("Check and repair database"), + category=_("Database Processing"), + description=_("Checks the database for integrity problems, fixing the problems that it can") + ) + diff --git a/src/plugins/Desbrowser.py b/src/plugins/Desbrowser.py index efa9b7b29..ff038d2ee 100644 --- a/src/plugins/Desbrowser.py +++ b/src/plugins/Desbrowser.py @@ -79,19 +79,17 @@ def add_to_tree(tree,person): item.set_subtree(subtree) add_to_tree(subtree,child) -#------------------------------------------------------------------------- +#------------------------------------------------------------------------ # +# # -# -#------------------------------------------------------------------------- -def get_name(): - return _("Analysis and Exploration/Interactive descendant browser") +#------------------------------------------------------------------------ +from Plugins import register_tool -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def get_description(): - return _("Provides a browsable hierarchy based on the active person") +register_tool( + runTool, + _("Interactive descendant browser"), + category=_("Analysis and Exploration"), + description=_("Provides a browsable hierarchy based on the active person") + ) diff --git a/src/plugins/DescendReport.py b/src/plugins/DescendReport.py index 5c52a7a4a..4958e9b54 100644 --- a/src/plugins/DescendReport.py +++ b/src/plugins/DescendReport.py @@ -259,22 +259,6 @@ def on_save_clicked(obj): utils.destroy_passed_object(obj) -#------------------------------------------------------------------------ -# -# -# -#------------------------------------------------------------------------ -def get_description(): - return _("Generates a list of descendants of the active person") - -#------------------------------------------------------------------------ -# -# -# -#------------------------------------------------------------------------ -def get_name(): - return _("Generate files/Descendant Report") - #------------------------------------------------------------------------ # # @@ -335,3 +319,19 @@ def get_xpm_image(): " ", " ", " "] + +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +from Plugins import register_report + +register_report( + report, + _("Descendant Report"), + category=_("Generate Files"), + description=_("Generates a list of descendants of the active person"), + xpm=get_xpm_image() + ) + diff --git a/src/plugins/EventCmp.py b/src/plugins/EventCmp.py index c767f62b1..a76aabc4d 100644 --- a/src/plugins/EventCmp.py +++ b/src/plugins/EventCmp.py @@ -199,7 +199,7 @@ class EventComparison: self.filter_list = [] myMenu = GtkMenu() - for filter in Filter.filterList: + for filter in Filter.filterMap.keys(): menuitem = GtkMenuItem(filter) myMenu.append(menuitem) menuitem.set_data(FILTER,Filter.filterMap[filter]) @@ -449,17 +449,6 @@ class EventComparison: def runTool(database,person,callback): EventComparison(database) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def get_description(): - return _("Aids in the analysis of data by allowing the development of custom filters that can be applied to the database to find similar events") - -def get_name(): - return _("Analysis and Exploration/Compare individual events") - #------------------------------------------------------------------------- # # @@ -608,3 +597,18 @@ def fix(line): l = string.replace(l,'>','>') l = string.replace(l,'<','<') return string.replace(l,'"','"') + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +from Plugins import register_tool + +register_tool( + runTool, + _("Compare individual events"), + category=_("Analysis and Exploration"), + description=_("Aids in the analysis of data by allowing the development of custom filters that can be applied to the database to find similar events") + ) + diff --git a/src/plugins/FamilyGroup.py b/src/plugins/FamilyGroup.py index 20d4d595e..e65550cd9 100644 --- a/src/plugins/FamilyGroup.py +++ b/src/plugins/FamilyGroup.py @@ -164,10 +164,7 @@ class FamilyGroup: self.doc.end_cell() self.doc.start_cell("TextContentsEnd") self.doc.start_paragraph('Normal') - if birth.getPlace() != None: - self.doc.write_text(birth.getPlace().get_title()) - else: - self.doc.write_text("") + self.doc.write_text(birth.getPlace().get_title()) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() @@ -185,10 +182,7 @@ class FamilyGroup: self.doc.end_cell() self.doc.start_cell("TextContentsEnd") self.doc.start_paragraph('Normal') - if death.getPlace() != None: - self.doc.write_text(death.getPlace().get_title()) - else: - self.doc.write_text("") + self.doc.write_text(death.getPlace().get_title()) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() @@ -234,10 +228,7 @@ class FamilyGroup: def dump_child_event(self,text,name,event): if event: date = event.getDate() - if event.getPlace() != None: - place = event.getPlace().get_title() - else: - place = "" + place = event.getPlace().get_title() else: date = "" place = "" @@ -526,8 +517,12 @@ def on_save_clicked(obj): # # #------------------------------------------------------------------------ -def get_description(): - return _("Creates a family group report, showing information on a set of parents and their children.") +from Plugins import register_report + +register_report( + report, + _("Family Group Report"), + category=_("Generate Files"), + description=_("Creates a family group report, showing information on a set of parents and their children.") + ) -def get_name(): - return _("Generate files/Family Group Report") diff --git a/src/plugins/GraphViz.py b/src/plugins/GraphViz.py index f89121239..b0545f1bf 100644 --- a/src/plugins/GraphViz.py +++ b/src/plugins/GraphViz.py @@ -244,5 +244,17 @@ def get_description(): " " + \ _("For more information or to get a copy of GraphViz, goto http://www.graphviz.org") -def get_name(): - return _("Generate files/Relationship graph") +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +from Plugins import register_report + +register_report( + report, + _("Relationship graph"), + category=_("Generate Files"), + description=get_description() + ) + diff --git a/src/plugins/HtmlReport.py b/src/plugins/HtmlReport.py index 73e5ab9eb..8995cc00e 100644 --- a/src/plugins/HtmlReport.py +++ b/src/plugins/HtmlReport.py @@ -545,13 +545,18 @@ def dump_index(person_list,filename,prefix,templateTop,templateBottom,targetDir) html.write(line) html.close() + #------------------------------------------------------------------------ # # # #------------------------------------------------------------------------ -def get_description(): - return _("Generates web (HTML) pages for individuals, or a set of individuals.") +from Plugins import register_report + +register_report( + report, + _("Individual web pages"), + category=_("Generate Files"), + description=_("Generates web (HTML) pages for individuals, or a set of individuals.") + ) -def get_name(): - return _("Generate files/Individual web pages") diff --git a/src/plugins/IndivSummary.py b/src/plugins/IndivSummary.py index 6da9c66a6..a0e1126ea 100644 --- a/src/plugins/IndivSummary.py +++ b/src/plugins/IndivSummary.py @@ -474,11 +474,14 @@ def on_save_clicked(obj): # # #------------------------------------------------------------------------ -def get_description(): - return _("Produces a detailed report on the selected person.") +from Plugins import register_report -def get_name(): - return _("Generate files/Individual Summary") +register_report( + report, + _("Individual Summary"), + category=_("Generate Files"), + description=_("Produces a detailed report on the selected person.") + ) diff --git a/src/plugins/Merge.py b/src/plugins/Merge.py index fe2788f51..3044f8b12 100644 --- a/src/plugins/Merge.py +++ b/src/plugins/Merge.py @@ -905,17 +905,6 @@ class Merge: def runTool(database,active_person,callback): mergeObj = Merge(database,callback) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def get_description(): - return _("Searches the entire database, looking for individual entries that may represent the same person.") - -def get_name(): - return _("Database Processing/Merge people") - #------------------------------------------------------------------------- # # @@ -950,3 +939,18 @@ def on_merge_clicked(obj): #------------------------------------------------------------------------- def by_id(p1,p2): return cmp(p1.getId(),p2.getId()) + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +from Plugins import register_tool + +register_tool( + runTool, + _("Merge people"), + category=_("Database Processing"), + description=_("Searches the entire database, looking for individual entries that may represent the same person.") + ) + diff --git a/src/plugins/PatchNames.py b/src/plugins/PatchNames.py index af8a53d86..b80e3fae5 100644 --- a/src/plugins/PatchNames.py +++ b/src/plugins/PatchNames.py @@ -113,24 +113,19 @@ def on_ok_clicked(obj): utils.destroy_passed_object(obj) cb(1) -#------------------------------------------------------------------------- +#------------------------------------------------------------------------ # +# # -# -#------------------------------------------------------------------------- -def get_description(): - return _("Searches the entire database and attempts to extract titles and nicknames that may be embedded in a person's given name field.") - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def get_name(): - return _("Database Processing/Extract information from names") - - +#------------------------------------------------------------------------ +from Plugins import register_tool +register_tool( + runTool, + _("Extract information from names"), + category=_("Database Processing"), + description=_("Searches the entire database and attempts to extract titles and nicknames that may be embedded in a person's given name field.") + ) diff --git a/src/plugins/ReadGedcom.py b/src/plugins/ReadGedcom.py index cbdc3105f..2e17f39a6 100644 --- a/src/plugins/ReadGedcom.py +++ b/src/plugins/ReadGedcom.py @@ -1550,28 +1550,6 @@ def readData(database,active_person,cb): # # #------------------------------------------------------------------------- -def get_name(): - return _("Import from GEDCOM") - -if __name__ == "__main__": - - import sys - - db = RelDataBase() - if len(sys.argv) == 1: - g = GedcomParser(db,"test.ged") - else: - g = GedcomParser(db,sys.argv[1]) - g.parse_gedcom_file() - - - - - - - - - - - +from Plugins import register_import +register_import(readData,"Import from GEDCOM") diff --git a/src/plugins/ReadNative.py b/src/plugins/ReadNative.py index 4424d0919..a743f183c 100644 --- a/src/plugins/ReadNative.py +++ b/src/plugins/ReadNative.py @@ -82,10 +82,12 @@ def on_ok_clicked(obj): importData(db,name,progress) callback(1) -#------------------------------------------------------------------------- +#------------------------------------------------------------------------ # +# # -# -#------------------------------------------------------------------------- -def get_name(): - return _("Import from Gramps") +#------------------------------------------------------------------------ +from Plugins import register_import + +register_import(readData,_("Import from Gramps")) + diff --git a/src/plugins/RelCalc.py b/src/plugins/RelCalc.py index 933601287..1bea5f2d7 100644 --- a/src/plugins/RelCalc.py +++ b/src/plugins/RelCalc.py @@ -259,8 +259,11 @@ def runTool(database,person,callback): # # #------------------------------------------------------------------------- -def get_description(): - return _("Calculates the relationship between two people") - -def get_name(): - return _("Utilities/Relationship calculator") +from Plugins import register_tool + +register_tool( + runTool, + _("Relationship calculator"), + category=_("Utilities"), + description=_("Calculates the relationship between two people") + ) diff --git a/src/plugins/ReorderIds.py b/src/plugins/ReorderIds.py index 23b80c84e..6c9ad14fb 100644 --- a/src/plugins/ReorderIds.py +++ b/src/plugins/ReorderIds.py @@ -73,8 +73,12 @@ def runTool(database,active_person,callback): # # #------------------------------------------------------------------------- -def get_description(): - return _("Reorders the gramps IDs according to gramps' default rules.") +from Plugins import register_tool + +register_tool( + runTool, + _("Reorder gramps IDs"), + category=_("Database Processing"), + description=_("Reorders the gramps IDs according to gramps' default rules.") + ) -def get_name(): - return _("Database Processing/Reorder gramps IDs") diff --git a/src/plugins/Summary.py b/src/plugins/Summary.py index 2149f59b2..67f736f08 100644 --- a/src/plugins/Summary.py +++ b/src/plugins/Summary.py @@ -115,9 +115,12 @@ def report(database,person): # # #------------------------------------------------------------------------- -def get_description(): - return _("Provides a summary of the current database") +from Plugins import register_report +register_report( + report, + _("Summary of the database"), + category=_("View"), + description=_("Provides a summary of the current database") + ) -def get_name(): - return _("View/Summary of the database") diff --git a/src/plugins/WebPage.py b/src/plugins/WebPage.py index f239a05c4..1c70d8374 100644 --- a/src/plugins/WebPage.py +++ b/src/plugins/WebPage.py @@ -776,18 +776,17 @@ def dump_index(person_list,styles,template,html_dir): doc.newline() doc.close() -#------------------------------------------------------------------------ +#------------------------------------------------------------------------- # -# # -#------------------------------------------------------------------------ -def get_description(): - return _("Generates web (HTML) pages for individuals, or a set of individuals.") +# +#------------------------------------------------------------------------- +from Plugins import register_report + +register_report( + report, + _("Generate Web Site"), + category=_("Web Page"), + description=_("Generates web (HTML) pages for individuals, or a set of individuals.") + ) -#------------------------------------------------------------------------ -# -# -# -#------------------------------------------------------------------------ -def get_name(): - return _("Web Site/Generate Web Site") diff --git a/src/plugins/WriteGedcom.py b/src/plugins/WriteGedcom.py index 376e567fa..02efe5402 100644 --- a/src/plugins/WriteGedcom.py +++ b/src/plugins/WriteGedcom.py @@ -686,5 +686,11 @@ def writeData(database,person): topDialog.get_widget("gedcomExport").show() -def get_name(): - return _("Export to GEDCOM") +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +from Plugins import register_export + +register_export(writeData,_("Export to GEDCOM")) diff --git a/src/plugins/count_anc.py b/src/plugins/count_anc.py index d171f5673..e4174a2d4 100644 --- a/src/plugins/count_anc.py +++ b/src/plugins/count_anc.py @@ -84,9 +84,12 @@ def report(database,person): # # #------------------------------------------------------------------------- -def get_description(): - return _("Counts number of ancestors of selected person") +from Plugins import register_report +register_report( + report, + _("Number of ancestors"), + category=_("View"), + description=_("Counts number of ancestors of selected person") + ) -def get_name(): - return _("View/Number of ancestors") diff --git a/src/plugins/soundgen.py b/src/plugins/soundgen.py index d3a93cd83..da5a3c1e6 100644 --- a/src/plugins/soundgen.py +++ b/src/plugins/soundgen.py @@ -76,13 +76,13 @@ def runTool(database,active_person,callback): # # #------------------------------------------------------------------------- -def get_description(): - return _("Generates SoundEx codes for names") +from Plugins import register_tool + +register_tool( + runTool, + _("Generate SoundEx codes"), + category=_("Utilities"), + description=_("Generates SoundEx codes for names") + ) + -#------------------------------------------------------------------------ -# -# -# -#------------------------------------------------------------------------ -def get_name(): - return _("Utilities/Generate SoundEx codes") diff --git a/src/utils.py b/src/utils.py index 865a3d676..c1faa760e 100644 --- a/src/utils.py +++ b/src/utils.py @@ -19,9 +19,15 @@ # import gtk - +import gnome.mime +import string +import os +import const _modifiedFlag = 0 +LISTOBJ = "s" +INDEX = "i" + #------------------------------------------------------------------------- # # Sets the modified flag, which is used to determine if the database @@ -102,7 +108,6 @@ def destroy_passed_object(obj): # point numbers # #------------------------------------------------------------------------- -import string if string.find("%.3f" % 1.2, ",") == -1: _use_comma = 0 @@ -127,3 +132,178 @@ def txt2fl(st): #------------------------------------------------------------------------- def fl2txt(fmt,val): return string.replace(fmt % val, ',', '.') + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def get_detail_flags(obj): + import Config + + detail = "" + if Config.show_detail: + if obj.getNote() != "": + detail = "N" + if obj.getSourceRef().getBase(): + detail = detail + "S" + if obj.getPrivacy(): + detail = detail + "P" + return detail + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def get_detail_text(obj): + if obj.getNote() != "": + details = "%s" % _("Note") + else: + details = "" + if obj.getSourceRef().getBase() != None: + if details == "": + details = _("Source") + else: + details = "%s, %s" % (details,_("Source")) + if obj.getPrivacy() == 1: + if details == "": + details = _("Private") + else: + details = "%s, %s" % (details,_("Private")) + return details + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def build_confidence_menu(menu): + myMenu = gtk.GtkMenu() + index = 0 + for name in const.confidence: + item = gtk.GtkMenuItem(name) + item.set_data("a",index) + item.show() + myMenu.append(item) + index = index + 1 + menu.set_menu(myMenu) + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def redraw_list(dlist,clist,func): + clist.freeze() + clist.clear() + + index = 0 + for object in dlist: + clist.append(func(object)) + clist.set_row_data(index,object) + index = index + 1 + + current_row = clist.get_data(INDEX) + if index > 0: + if current_row <= 0: + current_row = 0 + elif index <= current_row: + current_row = current_row - 1 + clist.select_row(current_row,0) + clist.moveto(current_row,0) + clist.set_data(INDEX,current_row) + clist.thaw() + return index + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def delete_selected(obj,list): + row = obj.get_data(INDEX) + if row < 0: + return 0 + del list[row] + if row > len(list)-1: + obj.set_data(INDEX,row-1) + return 1 + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def add_menuitem(menu,msg,obj,func): + item = gtk.GtkMenuItem(msg) + item.set_data("m",obj) + item.connect("activate",func) + item.show() + menu.append(item) + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def view_photo(photo): + type = gnome.mime.type(photo.getPath()) + prog = string.split(gnome.mime.get_value(type,'view')) + args = [] + for val in prog: + if val == "%f": + args.append(photo.getPath()) + else: + args.append(val) + + if os.fork() == 0: + os.execvp(args[0],args) + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def attach_places(values,combo,place): + l = gtk.GtkLabel("") + l.show() + l.set_alignment(0,0.5) + c = gtk.GtkListItem() + c.add(l) + c.set_data(LISTOBJ,None) + c.show() + sel_child = c + list = [c] + mymap = {} + for src in values: + l = gtk.GtkLabel("%s [%s]" % (src.get_title(),src.getId())) + l.show() + l.set_alignment(0,0.5) + c = gtk.GtkListItem() + c.add(l) + c.set_data(LISTOBJ,src) + c.show() + list.append(c) + if src == place: + sel_child = c + mymap[src] = c + + combo.list.append_items(list) + combo.list.select_child(sel_child) + + for v in mymap.keys(): + combo.set_item_string(mymap[v],v.get_title()) + + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def get_place_from_list(obj): + select = obj.list.get_selection() + if len(select) == 0: + return None + else: + return select[0].get_data(LISTOBJ)