* src/GrampsDbBase.py: remove thumbnailing routines, add

id creation. Removes gtk and Utils dependencies, making the
database routines independent of gtk and gnome.
* src/ImgManip.py: add thumbnailing routines.
* various: thumbnailing changes and pychecker fixes


svn: r3888
This commit is contained in:
Don Allingham
2005-01-09 02:18:49 +00:00
parent 65b6bb34af
commit 8ad3ba7456
23 changed files with 86 additions and 149 deletions

View File

@ -1,3 +1,10 @@
2005-01-08 Don Allingham <dallingham@users.sourceforge.net>
* src/GrampsDbBase.py: remove thumbnailing routines, add
id creation. Removes gtk and Utils dependencies, making the
database routines independent of gtk and gnome.
* src/ImgManip.py: add thumbnailing routines.
* various: thumbnailing changes and pychecker fixes
2005-01-08 Alex Roitman <shura@alex.neuro.umn.edu> 2005-01-08 Alex Roitman <shura@alex.neuro.umn.edu>
* src/Report.py (CommandLineReport.parse_option_str): * src/Report.py (CommandLineReport.parse_option_str):
Fix PluginMgr lists. Fix PluginMgr lists.

View File

@ -51,7 +51,6 @@ import Date
import RelLib import RelLib
import Sources import Sources
import DateEdit import DateEdit
import NameDisplay
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -83,11 +82,6 @@ class AddressEditor:
self.addr = addr self.addr = addr
self.callback = callback self.callback = callback
self.child_windows = {} self.child_windows = {}
name = NameDisplay.displayer.display(person)
if name == ", ":
text = _("Address Editor")
else:
text = _("Address Editor for %s") % name
# Get the important widgets from the glade description # Get the important widgets from the glade description
self.top = gtk.glade.XML(const.dialogFile, "addr_edit","gramps") self.top = gtk.glade.XML(const.dialogFile, "addr_edit","gramps")

View File

@ -529,7 +529,6 @@ class ArgHandler:
print "Report name not given. Please use name=reportname" print "Report name not given. Please use name=reportname"
os._exit(1) os._exit(1)
found = False
for item in PluginMgr.cl_list: for item in PluginMgr.cl_list:
if name == item[0]: if name == item[0]:
category = item[1] category = item[1]
@ -541,11 +540,10 @@ class ArgHandler:
else: else:
Report.cl_report(self.parent.db,name,category, Report.cl_report(self.parent.db,name,category,
report_class,options_class,options_str_dict) report_class,options_class,options_str_dict)
found = True
return return
print "Unknown report name. Available names are:" print "Unknown report name. Available names are:"
for item in Plugins._cl: for item in PluginMgr.cl_list:
print " %s" % item[0] print " %s" % item[0]
else: else:
print "Unknown action: %s." % action print "Unknown action: %s." % action

View File

@ -76,9 +76,9 @@ def get_date_formats():
except: except:
return DateDisplay.DateDisplay.formats return DateDisplay.DateDisplay.formats
def set_format(val): def set_format(value):
try: try:
_lang_to_display[_lang].set_format(val) _lang_to_display[_lang].set_format(value)
except: except:
pass pass

View File

@ -183,7 +183,7 @@ class ExistingDbPrompter:
# The above native formats did not work, so we need to # The above native formats did not work, so we need to
# look up the importer for this format # look up the importer for this format
# and create an empty native database to import data in # and create an empty native database to import data in
for (importData,mime_filter,mime_type,native_format) in Plugin.import_list: for (importData,mime_filter,mime_type,native_format) in PluginMgr.import_list:
if filetype == mime_type or the_file == mime_type: if filetype == mime_type or the_file == mime_type:
QuestionDialog.OkDialog( QuestionDialog.OkDialog(
_("Opening non-native format"), _("Opening non-native format"),

View File

@ -49,7 +49,6 @@ from gtk.gdk import ACTION_COPY, BUTTON1_MASK, INTERP_BILINEAR, pixbuf_new_from_
import const import const
import Utils import Utils
import GrampsKeys import GrampsKeys
import GrampsCfg
import GrampsMime import GrampsMime
import ImageSelect import ImageSelect
import AutoComp import AutoComp

View File

@ -44,7 +44,6 @@ import gnome
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import const import const
import Utils import Utils
import GrampsCfg
import Sources import Sources
import ImageSelect import ImageSelect
import NameDisplay import NameDisplay

View File

@ -35,7 +35,6 @@ import gnome
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import const import const
import Utils import Utils
import GrampsCfg
import ImageSelect import ImageSelect
import ListModel import ListModel
import RelLib import RelLib
@ -183,8 +182,8 @@ class EditSource:
model.remove(node) model.remove(node)
def edit_cb(self, cell, path, new_text, data): def edit_cb(self, cell, path, new_text, data):
iter = self.data_model.get_iter(path) node = self.data_model.get_iter(path)
self.data_model.set_value(iter,data,new_text) self.data_model.set_value(node,data,new_text)
def on_delete_event(self,obj,b): def on_delete_event(self,obj,b):
self.close_child_windows() self.close_child_windows()

View File

@ -37,7 +37,6 @@ from gtk.gdk import ACTION_COPY, BUTTON1_MASK
import const import const
import Utils import Utils
import GrampsKeys import GrampsKeys
import GrampsCfg
import AddSpouse import AddSpouse
import SelectChild import SelectChild
import DisplayTrace import DisplayTrace
@ -842,9 +841,9 @@ class FamilyView:
mother_id = self.family.get_mother_handle() mother_id = self.family.get_mother_handle()
father_id = self.family.get_father_handle() father_id = self.family.get_father_handle()
for id in [father_id, mother_id]: for handle in [father_id, mother_id]:
if id: if handle:
p = self.db.find_person_from_handle(id) p = self.parent.db.find_person_from_handle(handle)
p.remove_family_handle(self.family.get_handle()) p.remove_family_handle(self.family.get_handle())
self.parent.db.commit_person(p,trans) self.parent.db.commit_person(p,trans)
@ -1059,7 +1058,7 @@ class FamilyView:
self.family = self.parent.db.get_family_from_handle(flist[0]) self.family = self.parent.db.get_family_from_handle(flist[0])
else: else:
self.family = None self.family = None
n = NameDisplay.display.displayer(person) n = NameDisplay.displayer.display(person)
self.parent.db.transaction_commit(trans,_("Remove from family (%s)") % n) self.parent.db.transaction_commit(trans,_("Remove from family (%s)") % n)
def display_marriage(self,family): def display_marriage(self,family):

View File

@ -30,19 +30,20 @@ from this class.
# libraries # libraries
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from RelLib import *
import cPickle import cPickle
import time import time
import random
import locale import locale
import re import re
from gettext import gettext as _ from gettext import gettext as _
import os
import md5
import gtk
#-------------------------------------------------------------------------
#
# GRAMPS libraries
#
#-------------------------------------------------------------------------
from RelLib import *
import GrampsKeys import GrampsKeys
import Utils
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -116,6 +117,7 @@ class GrampsDbBase:
be created. be created.
""" """
self.rand = random.Random(time.time())
self.smap_index = 0 self.smap_index = 0
self.emap_index = 0 self.emap_index = 0
self.pmap_index = 0 self.pmap_index = 0
@ -162,6 +164,20 @@ class GrampsDbBase:
self.place2title = {} self.place2title = {}
self.name_groups = {} self.name_groups = {}
def create_id(self):
s = ""
for val in [ int(time.time()*10000) & 0x7fffffff,
self.rand.randint(0,0x7fffffff),
self.rand.randint(0,0x7fffffff)]:
while val != 0:
rem = val % 36
if rem <= 9:
s += chr(48+rem)
else:
s += chr(rem+55)
val = int(val/36)
return s
def get_person_cursor(self): def get_person_cursor(self):
assert False, "Needs to be overridden in the derived class" assert False, "Needs to be overridden in the derived class"
@ -556,7 +572,7 @@ class GrampsDbBase:
if not person.get_gramps_id(): if not person.get_gramps_id():
person.set_gramps_id(self.find_next_person_gramps_id()) person.set_gramps_id(self.find_next_person_gramps_id())
if not person.get_handle(): if not person.get_handle():
person.set_handle(Utils.create_id()) person.set_handle(self.create_id())
self.commit_person(person,transaction) self.commit_person(person,transaction)
self.genderStats.count_person (person, self) self.genderStats.count_person (person, self)
return person.get_handle() return person.get_handle()
@ -569,7 +585,7 @@ class GrampsDbBase:
if family.get_gramps_id() == None: if family.get_gramps_id() == None:
family.set_gramps_id(self.find_next_family_gramps_id()) family.set_gramps_id(self.find_next_family_gramps_id())
if family.get_handle() == None: if family.get_handle() == None:
family.set_handle(Utils.create_id()) family.set_handle(self.create_id())
self.commit_family(family,transaction) self.commit_family(family,transaction)
return family.get_handle() return family.get_handle()
@ -579,7 +595,7 @@ class GrampsDbBase:
not already been defined. not already been defined.
""" """
if source.get_handle() == None: if source.get_handle() == None:
source.set_handle(Utils.create_id()) source.set_handle(self.create_id())
if source.get_gramps_id() == None: if source.get_gramps_id() == None:
source.set_gramps_id(self.find_next_source_gramps_id()) source.set_gramps_id(self.find_next_source_gramps_id())
self.commit_source(source,transaction) self.commit_source(source,transaction)
@ -591,7 +607,7 @@ class GrampsDbBase:
not already been defined. not already been defined.
""" """
if event.get_handle() == None: if event.get_handle() == None:
event.set_handle(Utils.create_id()) event.set_handle(self.create_id())
if event.get_gramps_id() == None: if event.get_gramps_id() == None:
event.set_gramps_id(self.find_next_event_gramps_id()) event.set_gramps_id(self.find_next_event_gramps_id())
self.commit_event(event,transaction) self.commit_event(event,transaction)
@ -603,7 +619,7 @@ class GrampsDbBase:
not already been defined. not already been defined.
""" """
if place.get_handle() == None: if place.get_handle() == None:
index = Utils.create_id() index = self.create_id()
place.set_handle(index) place.set_handle(index)
if place.get_gramps_id() == None: if place.get_gramps_id() == None:
place.set_gramps_id(self.find_next_place_gramps_id()) place.set_gramps_id(self.find_next_place_gramps_id())
@ -617,7 +633,7 @@ class GrampsDbBase:
""" """
index = obj.get_handle() index = obj.get_handle()
if index == None: if index == None:
index = Utils.create_id() index = self.create_id()
obj.set_handle(index) obj.set_handle(index)
if obj.get_gramps_id() == None: if obj.get_gramps_id() == None:
obj.set_gramps_id(self.find_next_object_gramps_id()) obj.set_gramps_id(self.find_next_object_gramps_id())
@ -1220,36 +1236,6 @@ class GrampsDbBase:
else: else:
return cols return cols
def _build_thumb_path(self,path):
base = os.path.expanduser('~/.gramps/thumb')
m = md5.md5(path)
return os.path.join(base,m.hexdigest()+'.jpg')
def get_thumbnail_image(self,handle):
data = self.media_map.get(handle)
if data:
filename = self._build_thumb_path(data[2])
if not os.path.isfile(filename):
self.set_thumbnail_image(handle,data[2])
return gtk.gdk.pixbuf_new_from_file(filename)
else:
return None
def set_thumbnail_image(self,handle,path):
try:
pixbuf = gtk.gdk.pixbuf_new_from_file(path)
w = pixbuf.get_width()
h = pixbuf.get_height()
scale = 96.0 / (float(max(w,h)))
pw = int(w*scale)
ph = int(h*scale)
pixbuf = pixbuf.scale_simple(pw,ph,gtk.gdk.INTERP_BILINEAR)
pixbuf.save(self._build_thumb_path(path),"jpeg")
except:
print "Could not create thumbnail for",path
class Transaction: class Transaction:
""" """
Defines a group of database commits that define a single logical Defines a group of database commits that define a single logical

View File

@ -60,6 +60,7 @@ import Sources
import DateEdit import DateEdit
import DateHandler import DateHandler
import Date import Date
import ImgManip
from QuestionDialog import ErrorDialog from QuestionDialog import ErrorDialog
_IMAGEX = 140 _IMAGEX = 140
@ -270,7 +271,8 @@ class Gallery(ImageSelect):
def on_drag_begin(self,obj,context): def on_drag_begin(self,obj,context):
if const.dnd_images: if const.dnd_images:
handle = self.sel_obj.get_reference_handle() handle = self.sel_obj.get_reference_handle()
pix = self.db.get_thumbnail_image(handle) media_obj = self.db.get_object_from_handle(handle)
pix = self.db.get_thumbnail_image(media_obj.get_path())
context.set_icon_pixbuf(pix,0,0) context.set_icon_pixbuf(pix,0,0)
def item_event(self, widget, event=None): def item_event(self, widget, event=None):
@ -356,7 +358,6 @@ class Gallery(ImageSelect):
self.db.add_object(photo,None) self.db.add_object(photo,None)
oref = RelLib.MediaRef() oref = RelLib.MediaRef()
oref.set_reference_handle(photo.get_handle()) oref.set_reference_handle(photo.get_handle())
self.db.set_thumbnail_image(photo.get_handle(),photo.get_path())
self.dataobj.add_media_reference(oref) self.dataobj.add_media_reference(oref)
def add_thumbnail(self, photo): def add_thumbnail(self, photo):
@ -375,9 +376,8 @@ class Gallery(ImageSelect):
description = "%s..." % description[0:20] description = "%s..." % description[0:20]
try: try:
image = self.db.get_thumbnail_image(oid) media_obj = self.db.get_object_from_handle(oid)
if not image: image = ImgManip.get_thumbnail_image(media_obj.get_path())
image = gtk.gdk.pixbuf_new_from_file(const.icon)
except gobject.GError,msg: except gobject.GError,msg:
ErrorDialog(str(msg)) ErrorDialog(str(msg))
image = gtk.gdk.pixbuf_new_from_file(const.icon) image = gtk.gdk.pixbuf_new_from_file(const.icon)
@ -471,8 +471,6 @@ class Gallery(ImageSelect):
photo.set_description(root) photo.set_description(root)
self.savephoto(photo) self.savephoto(photo)
if GrampsKeys.get_media_reference() == 0: if GrampsKeys.get_media_reference() == 0:
self.db.set_thumbnail_image(photo.get_handle(),
self.path)
photo.set_path(name) photo.set_path(name)
self.parent.lists_changed = 1 self.parent.lists_changed = 1
if GrampsKeys.get_media_global(): if GrampsKeys.get_media_global():
@ -497,8 +495,6 @@ class Gallery(ImageSelect):
oref.set_reference_handle(photo.get_handle()) oref.set_reference_handle(photo.get_handle())
self.dataobj.add_media_reference(oref) self.dataobj.add_media_reference(oref)
try: try:
handle = photo.get_handle()
self.db.set_thumbnail_image(handle,self.path)
photo.set_path(name) photo.set_path(name)
except: except:
photo.set_path(tfile) photo.set_path(tfile)
@ -623,13 +619,6 @@ class Gallery(ImageSelect):
obj = self.db.get_object_from_handle(photo.get_reference_handle()) obj = self.db.get_object_from_handle(photo.get_reference_handle())
os.execvp(const.editor,[const.editor, obj.get_path()]) os.execvp(const.editor,[const.editor, obj.get_path()])
def popup_convert_to_private(self, obj):
"""Copy this picture into gramps private database instead of
leaving it as an external data object."""
photo = obj.get_data('o')
obj = self.db.get_object_from_handle(photo.get_reference_handle())
self.db.set_thumbnail_image(obj.get_handle(),obj.get_path())
def popup_change_description(self, obj): def popup_change_description(self, obj):
"""Bring up a window allowing the user to edit the description """Bring up a window allowing the user to edit the description
of a picture.""" of a picture."""
@ -703,7 +692,7 @@ class LocalMediaProperties:
descr_window.set_text(self.obj.get_description()) descr_window.set_text(self.obj.get_description())
mtype = self.obj.get_mime_type() mtype = self.obj.get_mime_type()
self.pix = self.db.get_thumbnail_image(self.obj.get_handle()) self.pix = ImgManip.get_thumbnail_image(self.obj.get_path())
self.pixmap.set_from_pixbuf(self.pix) self.pixmap.set_from_pixbuf(self.pix)
self.change_dialog.get_widget("private").set_active(photo.get_privacy()) self.change_dialog.get_widget("private").set_active(photo.get_privacy())
@ -970,7 +959,7 @@ class GlobalMediaProperties:
self.descr_window.set_text(self.obj.get_description()) self.descr_window.set_text(self.obj.get_description())
mtype = self.obj.get_mime_type() mtype = self.obj.get_mime_type()
pb = self.db.get_thumbnail_image(self.obj.get_handle()) pb = ImgManip.get_thumbnail_image(self.obj.get_path())
self.pixmap.set_from_pixbuf(pb) self.pixmap.set_from_pixbuf(pb)
self.change_dialog.get_widget("gid").set_text(self.obj.get_gramps_id()) self.change_dialog.get_widget("gid").set_text(self.obj.get_gramps_id())

View File

@ -46,6 +46,7 @@ import Utils
import GrampsKeys import GrampsKeys
import const import const
import ImageSelect import ImageSelect
import ImgManip
import RelImage import RelImage
import DisplayModels import DisplayModels
import GrampsMime import GrampsMime
@ -178,7 +179,7 @@ class MediaView:
mtype = mobj.get_mime_type() mtype = mobj.get_mime_type()
path = mobj.get_path() path = mobj.get_path()
type_name = Utils.get_mime_description(mtype) type_name = Utils.get_mime_description(mtype)
image = self.db.get_thumbnail_image(mobj.get_handle()) image = ImgManip.get_thumbnail_image(path)
if image != None: if image != None:
self.preview.set_from_pixbuf(image) self.preview.set_from_pixbuf(image)
else: else:
@ -258,13 +259,6 @@ class MediaView:
if os.fork() == 0: if os.fork() == 0:
os.execvp(const.editor,[const.editor, self.obj.get_path()]) os.execvp(const.editor,[const.editor, self.obj.get_path()])
def popup_convert_to_private(self, obj):
path = self.db.get_save_path()
handle = self.obj.get_handle()
self.db.set_thumbnail_image(handle,path)
if name:
self.obj.set_path(name)
def popup_change_description(self, obj): def popup_change_description(self, obj):
ImageSelect.GlobalMediaProperties(self.db,self.obj, ImageSelect.GlobalMediaProperties(self.db,self.obj,
self.update_display, self.update_display,
@ -360,7 +354,7 @@ class MediaView:
if (const.dnd_images): if (const.dnd_images):
handle = store.get_value(node,5) handle = store.get_value(node,5)
obj = self.db.get_object_from_handle(handle) obj = self.db.get_object_from_handle(handle)
image = self.db.get_thumbnail_image(obj.get_handle()) image = ImgManip.get_thumbnail_image(obj.get_path())
context.set_icon_pixbuf(image,0,0) context.set_icon_pixbuf(image,0,0)
def on_drag_data_get(self, w, context, selection_data, info, time): def on_drag_data_get(self, w, context, selection_data, info, time):
@ -389,8 +383,6 @@ class MediaView:
photo.set_description(description) photo.set_description(description)
trans = self.db.transaction_begin() trans = self.db.transaction_begin()
self.db.add_object(photo,trans) self.db.add_object(photo,trans)
if GrampsKeys.get_media_reference() == 0:
self.db.set_thumbnail_image(photo.get_handle(),name)
self.db.commit_media_object(photo,trans) self.db.commit_media_object(photo,trans)
self.db.transaction_commit(trans,_("Add Media Object")) self.db.transaction_commit(trans,_("Add Media Object"))
@ -416,13 +408,6 @@ class MediaView:
self.db.add_object(photo,trans) self.db.add_object(photo,trans)
oref = RelLib.MediaRef() oref = RelLib.MediaRef()
oref.set_reference_handle(photo.get_handle()) oref.set_reference_handle(photo.get_handle())
try:
handle = photo.get_handle()
path = self.db.get_save_path()
self.db.set_thumbnail_image(handle,path)
except:
photo.set_path(tfile)
return
self.db.commit_media_object(photo,trans) self.db.commit_media_object(photo,trans)
self.db.transaction_commit(trans,_("Add Media Object")) self.db.transaction_commit(trans,_("Add Media Object"))

View File

@ -46,7 +46,7 @@ class NameDisplay:
displayed in upper case. displayed in upper case.
@type use_upper: bool @type use_upper: bool
""" """
self.use_upper = use_upper self.force_upper = use_upper
def use_upper(self,upper): def use_upper(self,upper):
""" """
@ -57,7 +57,7 @@ class NameDisplay:
displayed in upper case. displayed in upper case.
@type upper: bool @type upper: bool
""" """
self.use_upper = upper self.force_upper = upper
def sorted(self,person): def sorted(self,person):
""" """
@ -139,7 +139,7 @@ class NameDisplay:
else: else:
first = name.first_name first = name.first_name
if self.use_upper: if self.force_upper:
last = name.surname.upper() last = name.surname.upper()
else: else:
last = name.surname last = name.surname
@ -167,7 +167,7 @@ class NameDisplay:
else: else:
first = name.first_name first = name.first_name
if self.use_upper: if self.force_upper:
last = name.surname.upper() last = name.surname.upper()
else: else:
last = name.surname last = name.surname

View File

@ -163,7 +163,7 @@ class PeopleView:
hc = self.parent.history.count(del_id) hc = self.parent.history.count(del_id)
for c in range(hc): for c in range(hc):
self.parent.history.remove(del_id) self.parent.history.remove(del_id)
self.parent.hindex = self.parent.hindex - 1 self.parent.hindex -= 1
mhc = self.parent.mhistory.count(del_id) mhc = self.parent.mhistory.count(del_id)
for c in range(mhc): for c in range(mhc):

View File

@ -184,8 +184,6 @@ class PlaceView:
mlist = [] mlist = []
self.selection.selected_foreach(self.blist,mlist) self.selection.selected_foreach(self.blist,mlist)
trans = self.parent.db.transaction_begin()
for place_handle in mlist: for place_handle in mlist:
used = 0 used = 0
for key in self.parent.db.get_person_handles(sort_handles=False): for key in self.parent.db.get_person_handles(sort_handles=False):

View File

@ -36,7 +36,7 @@ importers, exporters, and document generators.
import os import os
import sys import sys
import string import string
from re import compile import re
from gettext import gettext as _ from gettext import gettext as _
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -45,7 +45,6 @@ from gettext import gettext as _
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import const import const
import GrampsKeys
import Errors import Errors
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -111,7 +110,7 @@ def load_plugins(direct):
# add the directory to the python search path # add the directory to the python search path
sys.path.append(direct) sys.path.append(direct)
pymod = compile(r"^(.*)\.py$") pymod = re.compile(r"^(.*)\.py$")
# loop through each file in the directory, looking for files that # loop through each file in the directory, looking for files that
# have a .py extention, and attempt to load the file. If it succeeds, # have a .py extention, and attempt to load the file. If it succeeds,
@ -133,8 +132,10 @@ def load_plugins(direct):
except: except:
failmsg_list.append((filename,sys.exc_info())) failmsg_list.append((filename,sys.exc_info()))
if GrampsKeys.get_pop_plugin_status() and len(expect_list)+len(failmsg_list): if len(expect_list)+len(failmsg_list):
PluginStatus() return False
else:
return True
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -199,13 +200,10 @@ def reload_plugins(obj=None,junk1=None,junk2=None,junk3=None):
except: except:
failmsg_list.append((filename,sys.exc_info())) failmsg_list.append((filename,sys.exc_info()))
if GrampsKeys.get_pop_plugin_status(): global status_up
global status_up if not len(failmsg_list):
if len(failmsg_list): status_up.close(None)
PluginStatus() status_up = None
elif status_up:
status_up.close(None)
status_up = None
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #

View File

@ -50,6 +50,7 @@ import Errors
import RelLib import RelLib
import Date import Date
import DateParser import DateParser
import DisplayTrace
from ansel_utf8 import ansel_to_utf8 from ansel_utf8 import ansel_to_utf8
import latin_utf8 import latin_utf8
import Utils import Utils
@ -1935,14 +1936,6 @@ class GedcomParser:
def invert_year(self,subdate): def invert_year(self,subdate):
return (subdate[0],subdate[1],-subdate[2],subdate[3]) return (subdate[0],subdate[1],-subdate[2],subdate[3])
def parse(self,text):
"""
Parses the text, returning a Date object.
"""
new_date = Date.Date()
self.set_date(new_date,text)
return new_date
def extract_temple(matches): def extract_temple(matches):
try: try:
if const.lds_temple_to_abrev.has_key(matches[2]): if const.lds_temple_to_abrev.has_key(matches[2]):

View File

@ -265,12 +265,7 @@ class SelectChild:
ddate = "" ddate = ""
rdata = [name,person.get_gramps_id(),gender,bdate,ddate] rdata = [name,person.get_gramps_id(),gender,bdate,ddate]
new_node = self.refmodel.add(rdata) node = self.refmodel.add(rdata)
names = dinfo[0].split(',')
if len(names):
ln = names[0].upper()
if self.default_name and ln == self.default_name and not node:
node = new_node
self.refmodel.connect_model() self.refmodel.connect_model()

View File

@ -57,6 +57,7 @@ import gtk.gdk
import const import const
import Utils import Utils
import ListModel import ListModel
import ImgManip
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -106,8 +107,6 @@ class SelectObject:
self.object_model.connect_model() self.object_model.connect_model()
def on_select_row(self,obj): def on_select_row(self,obj):
fexists = 1
store,node = self.object_model.get_selected() store,node = self.object_model.get_selected()
if not node: if not node:
return return
@ -117,19 +116,17 @@ class SelectObject:
the_type = Utils.get_mime_description(obj.get_mime_type()) the_type = Utils.get_mime_description(obj.get_mime_type())
path = obj.get_path() path = obj.get_path()
image = self.db.get_thumbnail_image(obj.get_handle()) image = ImgManip.get_thumbnail_image(obj.get_path())
if image: if image:
self.preview.set_from_pixbuf(image) self.preview.set_from_pixbuf(image)
else: else:
icon_image = gtk.gdk.pixbuf_new_from_file(Utils.find_icon(the_type)) icon_image = gtk.gdk.pixbuf_new_from_file(Utils.find_icon(the_type))
self.preview.set_from_pixbuf(icon_image) self.preview.set_from_pixbuf(icon_image)
if not pexists:
fexists = 0
self.object_handle.set_text(obj.get_gramps_id()) self.object_handle.set_text(obj.get_gramps_id())
self.object_type.set_text(the_type) self.object_type.set_text(the_type)
self.object_desc.set_text(obj.get_description()) self.object_desc.set_text(obj.get_description())
if len(path) == 0 or fexists == 0: if len(path) == 0:
self.object_path.set_text(_("The file no longer exists")) self.object_path.set_text(_("The file no longer exists"))
elif path[0] == "/": elif path[0] == "/":
self.object_path.set_text(path) self.object_path.set_text(path)

View File

@ -88,7 +88,7 @@ class StyleListDisplay:
self.redraw() self.redraw()
if parent_window: if parent_window:
self.window.set_transient_for(parent_window) self.window.set_transient_for(parent_window)
response = self.window.run() self.window.run()
self.window.destroy() self.window.destroy()
def redraw(self): def redraw(self):

View File

@ -69,10 +69,9 @@ def history_broken():
# force_unicode # force_unicode
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
_t = type(u'')
def force_unicode(n): def force_unicode(n):
if type(n) != _t: if type(n) != unicode:
return (unicode(n).lower(),unicode(n)) return (unicode(n).lower(),unicode(n))
else: else:
return (n.lower(),n) return (n.lower(),n)

View File

@ -832,12 +832,14 @@ class Gramps:
self.report_menu.set_sensitive(0) self.report_menu.set_sensitive(0)
self.tools_menu.set_sensitive(0) self.tools_menu.set_sensitive(0)
PluginMgr.load_plugins(const.docgenDir)
PluginMgr.load_plugins(os.path.expanduser("~/.gramps/docgen"))
PluginMgr.load_plugins(const.pluginsDir)
PluginMgr.load_plugins(os.path.expanduser("~/.gramps/plugins"))
error = PluginMgr.load_plugins(const.docgenDir)
error |= PluginMgr.load_plugins(os.path.expanduser("~/.gramps/docgen"))
error |= PluginMgr.load_plugins(const.pluginsDir)
error |= PluginMgr.load_plugins(os.path.expanduser("~/.gramps/plugins"))
if GrampsKeys.get_pop_plugin_status() and error:
Plugins.PluginStatus()
Plugins.build_report_menu(self.report_menu,self.menu_report) Plugins.build_report_menu(self.report_menu,self.menu_report)
Plugins.build_tools_menu(self.tools_menu,self.menu_tools) Plugins.build_tools_menu(self.tools_menu,self.menu_tools)
@ -1191,7 +1193,6 @@ class Gramps:
if os.path.isfile(name): if os.path.isfile(name):
obj = self.db.get_object_from_handle(ObjectId) obj = self.db.get_object_from_handle(ObjectId)
obj.set_path(name) obj.set_path(name)
self.db.set_thumbnail_image(ObjectId,name)
choose.destroy() choose.destroy()
#------------------------------------------------------------------------- #-------------------------------------------------------------------------

View File

@ -47,6 +47,7 @@ import Utils
import AddMedia import AddMedia
import const import const
import ReportOptions import ReportOptions
import ImgManip
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -248,7 +249,7 @@ class SimpleBookTitleOptions(ReportOptions.ReportOptions):
return return
self.options_dict['imgid'] = the_object.get_gramps_id() self.options_dict['imgid'] = the_object.get_gramps_id()
self.obj_title.set_text(the_object.get_description()) self.obj_title.set_text(the_object.get_description())
icon_image = database.get_thumbnail_image(the_object.get_handle()) icon_image = ImgManip.get_thumbnail_image(the_object.get_path())
self.preview.set_from_pixbuf(icon_image) self.preview.set_from_pixbuf(icon_image)
self.remove_obj_button.set_sensitive(gtk.TRUE) self.remove_obj_button.set_sensitive(gtk.TRUE)
self.size.set_sensitive(gtk.TRUE) self.size.set_sensitive(gtk.TRUE)