Better imaging handling per Brian Hefferan's requests

svn: r594
This commit is contained in:
Don Allingham 2001-11-29 16:58:51 +00:00
parent c9859c44f9
commit f297268824
9 changed files with 1271 additions and 1027 deletions

View File

@ -1,4 +1,4 @@
%define ver 0.7.0pre
define ver 0.7.0pre
%define rel 1
%define prefix /usr

View File

@ -114,6 +114,9 @@ db_dir = "./"
id_visible = 0
id_edit = 0
index_visible = 0
mediaref = 1
globalprop = 1
localprop = 1
#-------------------------------------------------------------------------
#
@ -189,6 +192,9 @@ def loadConfig(call):
_callback = call
lastfile = get_string("/gramps/data/LastFile")
usetabs = get_bool("/gramps/config/UseTabs")
mediaref = get_bool("/gramps/config/MakeReference")
globalprop = get_bool("/gramps/config/DisplayGlobal")
localprop = get_bool("/gramps/config/DisplayLocal")
calendar = get_bool("/gramps/config/ShowCalendar")
usevc = get_bool("/gramps/config/UseVersionControl")
vc_comment = get_bool("/gramps/config/UseComment")
@ -280,6 +286,12 @@ def loadConfig(call):
if autoload == None:
autoload = 1
if mediaref == None:
mediaref = 1
if globalprop == None:
globalprop = 1
if localprop == None:
localprop =1
if usetabs == None:
usetabs = 0
if calendar == None:
@ -395,6 +407,9 @@ def on_propertybox_apply(obj,page):
global nameof
global owner
global usetabs
global mediaref
global globalprop
global localprop
global calendar
global usevc
global iprefix
@ -426,6 +441,9 @@ def on_propertybox_apply(obj,page):
display_attr = prefsTop.get_widget("attr_display").get_active()
attr_name = string.strip(prefsTop.get_widget("attr_name").get_text())
usetabs = prefsTop.get_widget("usetabs").get_active()
mediaref = prefsTop.get_widget("mediaref").get_active()
localprop = prefsTop.get_widget("localprop").get_active()
globalprop = prefsTop.get_widget("globalprop").get_active()
calendar = prefsTop.get_widget("calendar").get_active()
usevc = prefsTop.get_widget("use_vc").get_active()
vc_comment = prefsTop.get_widget("vc_comment").get_active()
@ -476,6 +494,9 @@ def on_propertybox_apply(obj,page):
output_preference = output_obj.get_data(DATA)
set_bool("/gramps/config/UseTabs",usetabs)
set_bool("/gramps/config/MakeReference",makeref)
set_bool("/gramps/config/DisplayGlobal",globalprop)
set_bool("/gramps/config/DisplayLocal",localprop)
set_bool("/gramps/config/ShowCalendar",calendar)
set_bool("/gramps/config/UseVersionControl",usevc)
set_bool("/gramps/config/UseComment",vc_comment)
@ -639,6 +660,9 @@ def display_preferences_box(db):
idedit = prefsTop.get_widget("gid_edit")
index_vis = prefsTop.get_widget("show_child_id")
tabs = prefsTop.get_widget("usetabs")
mr = prefsTop.get_widget("mediaref")
dg = prefsTop.get_widget("globalprop")
dl = prefsTop.get_widget("localprop")
cal = prefsTop.get_widget("calendar")
vc = prefsTop.get_widget("use_vc")
vcom = prefsTop.get_widget("vc_comment")
@ -649,6 +673,9 @@ def display_preferences_box(db):
auto.set_active(autoload)
detail.set_active(show_detail)
tabs.set_active(usetabs)
mr.set_active(mediaref)
dg.set_active(globalprop)
dl.set_active(localprop)
cal.set_active(calendar)
vc.set_active(usevc)
vcom.set_active(vc_comment)

View File

@ -64,7 +64,7 @@ class EditPerson:
# window.
#
#---------------------------------------------------------------------
def __init__(self,person,db,callback):
def __init__(self,person,db,callback=None):
self.person = person
self.db = db
self.callback = callback
@ -779,7 +779,8 @@ class EditPerson:
utils.modified()
self.update_lists()
self.callback(self)
if self.callback:
self.callback(self)
utils.destroy_passed_object(obj)
def on_primary_name_source_clicked(self,obj):

View File

@ -47,7 +47,7 @@ _ = gettext
#-------------------------------------------------------------------------
class EditPlace:
def __init__(self,place,db,func):
def __init__(self,place,db,func=None):
self.place = place
self.db = db
self.callback = func
@ -227,7 +227,8 @@ class EditPlace:
self.update_lists()
utils.destroy_passed_object(self.top)
self.callback(self.place)
if self.callback:
self.callback(self.place)
def on_switch_page(self,obj,a,page):
if page == 3 and self.not_loaded:

View File

@ -48,7 +48,7 @@ _ = gettext
class EditSource:
def __init__(self,source,db,func):
def __init__(self,source,db,func=None):
self.source = source
self.db = db
self.callback = func
@ -211,7 +211,8 @@ class EditSource:
utils.modified()
utils.destroy_passed_object(self.top)
self.callback(self.source)
if self.callback:
self.callback(self.source)
def on_switch_page(self,obj,a,page):
if page == 2 and self.not_loaded:

View File

@ -48,6 +48,11 @@ import Config
from RelLib import *
import RelImage
import EditPerson
import Marriage
import EditPlace
import EditSource
from intl import gettext
_ = gettext
@ -274,6 +279,15 @@ class Gallery(ImageSelect):
(root,ext) = os.path.splitext(basename)
photo.setDescription(root)
self.savephoto(photo)
if Config.mediaref == 0:
name = RelImage.import_media_object(name,
self.path,
photo.getId())
photo.setPath(name)
photo.setLocal(1)
utils.modified()
if Config.globalprop:
GlobalMediaProperties(self.db,photo,None)
elif protocol != "":
import urllib
u = urllib.URLopener()
@ -305,6 +319,8 @@ class Gallery(ImageSelect):
return
self.add_thumbnail(oref)
utils.modified()
if Config.globalprop:
GlobalMediaProperties(self.db,photo,None)
else:
if self.db.getObjectMap().has_key(data.data):
index = 0
@ -332,6 +348,8 @@ class Gallery(ImageSelect):
oref.setReference(self.db.findObjectNoMap(data.data))
self.dataobj.addPhoto(oref)
self.add_thumbnail(oref)
if Config.globalprop:
LocalMediaProperties(oref,self.path)
utils.modified()
w.drag_finish(context, 1, 0, time)
else:
@ -597,29 +615,47 @@ class GlobalMediaProperties:
self.object.setPath(name)
self.object.setLocal(1)
self.update_info()
self.update()
if self.update != None:
self.update()
def redraw_attr_list(self):
utils.redraw_list(self.alist,self.attr_list,disp_attr)
def button_press(self,obj,event):
if len(obj.selection) <= 0:
return
data = obj.get_row_data(obj.selection[0])
if data != None:
data[0](data[1],data[2])
def display_refs(self):
index = 0
ref = self.change_dialog.get_widget("refinfo")
ref.connect('button-press-event',self.button_press)
for p in self.db.getPersonMap().values():
for o in p.getPhotoList():
if o.getReference() == self.object:
ref.append([_("Person"),p.getId(),Config.nameof(p)])
ref.set_row_data(index,(EditPerson.EditPerson,p,self.db))
index = index + 1
for p in self.db.getFamilyMap().values():
for o in p.getPhotoList():
if o.getReference() == self.object:
ref.append([_("Family"),p.getId(),utils.family_name(p)])
ref.set_row_data(index,(Marriage.Marriage,p,self.db))
index = index + 1
for p in self.db.getSourceMap().values():
for o in p.getPhotoList():
if o.getReference() == self.object:
ref.append([_("Source"),p.getId(),p.getTitle()])
ref.set_row_data(index,(EditSource.EditSource,p,self.db))
index = index + 1
for p in self.db.getPlaceMap().values():
for o in p.getPhotoList():
if o.getReference() == self.object:
ref.append([_("Place"),p.getId(),p.get_title()])
ref.set_row_data(index,(EditPlace.EditPlace,p,self.db))
index = index + 1
def on_notebook_switch_page(self,obj,junk,page):
if page == 3:
@ -636,7 +672,8 @@ class GlobalMediaProperties:
if self.lists_changed:
self.object.setAttributeList(self.alist)
utils.modified()
self.update()
if self.update != None:
self.update()
def on_ok_clicked(self, obj):
self.on_apply_clicked(obj)
@ -731,7 +768,8 @@ class DeleteMediaQuery:
change = 1
if change:
p.setPhotoList(nl)
self.update(0)
if self.update:
self.update(0)

View File

@ -20,6 +20,7 @@
import GTK
import GDK
import gtk
import gnome.ui
import string
import ImageSelect
@ -139,12 +140,42 @@ class MediaView:
self.mdetails.set_text(utils.get_detail_text(mobj,0))
def on_button_press_event(self,obj,event):
if event.button != 1 or event.type != GDK._2BUTTON_PRESS:
return
if len(self.media_list.selection) <= 0:
return
object = self.media_list.get_row_data(self.media_list.selection[0])
ImageSelect.GlobalMediaProperties(self.db,object,self.load_media)
if event.button == 1 and event.type == GDK._2BUTTON_PRESS:
ImageSelect.GlobalMediaProperties(self.db,object,self.load_media)
elif event.button == 3:
menu = gtk.GtkMenu()
item = gtk.GtkTearoffMenuItem()
item.show()
menu.append(item)
self.obj = object
utils.add_menuitem(menu,_("View in the default viewer"),None,self.popup_view_photo)
if object.getMimeType()[0:5] == "image":
utils.add_menuitem(menu,_("Edit with the GIMP"),\
None,self.popup_edit_photo)
utils.add_menuitem(menu,_("Edit Object Properties"),None,
self.popup_change_description)
if object.getLocal() == 0:
utils.add_menuitem(menu,_("Convert to local copy"),None,
self.popup_convert_to_private)
menu.popup(None,None,None,0,0)
def popup_view_photo(self, obj):
utils.view_photo(self.obj)
def popup_edit_photo(self, obj):
if os.fork() == 0:
os.execvp(const.editor,[const.editor, self.obj.getPath()])
def popup_convert_to_private(self, obj):
name = RelImage.import_media_object(self.obj.getPath(),self.path,self.obj.getId())
self.obj.setPath(name)
self.obj.setLocal(1)
def popup_change_description(self, obj):
ImageSelect.GlobalMediaProperties(self.db,self.obj,self.load_media)
def load_media(self):

File diff suppressed because it is too large Load Diff

View File

@ -61,17 +61,21 @@ _ALT_EVENT_AKA = 4
_CAL_NO = 0
_CAL_YES = 1
_EVEN_NONE = 0
_EVEN_GED = 1
_EVEN_FTW = 2
targets = [
("Standard GEDCOM 5.5", "GEDCOM 5.5", _ADOPT_EVENT_EXT, _CONC_OK, _ALT_STD, _CAL_YES),
("Brother's Keeper", "BROSKEEP", _ADOPT_NONE, _CONC_BROKEN, _ALT_NONE, _CAL_NO),
("Family Origins", "FamilyOrigins", _ADOPT_EVENT, _CONC_BROKEN, _ALT_EVENT_AKA, _CAL_NO),
("Family Tree Maker", "FTW", _ADOPT_FTW, _CONC_BROKEN, _ALT_ALIAS, _CAL_NO),
("Ftree", "", _ADOPT_NONE, _CONC_BROKEN, _ALT_NONE, _CAL_NO),
("GeneWeb", "", _ADOPT_NONE, _CONC_OK, _ALT_NONE, _CAL_YES),
("Legacy", "Legacy", _ADOPT_LEGACY, _CONC_BROKEN, _ALT_STD, _CAL_NO),
("Personal Ancestral File", "PAF", _ADOPT_PEDI, _CONC_OK, _ALT_AKA, _CAL_NO),
("Reunion", "REUNION", _ADOPT_NONE, _CONC_BROKEN, _ALT_NONE, _CAL_NO),
("Visual Genealogie", "", _ADOPT_NONE, _CONC_BROKEN, _ALT_NONE, _CAL_NO),
("Standard GEDCOM 5.5", "GEDCOM 5.5", _ADOPT_EVENT_EXT, _CONC_OK, _ALT_STD, _CAL_YES, _EVEN_GED),
("Brother's Keeper", "BROSKEEP", _ADOPT_NONE, _CONC_OK, _ALT_NONE, _CAL_NO, _EVEN_GED),
("Family Origins", "FamilyOrigins", _ADOPT_EVENT, _CONC_BROKEN, _ALT_EVENT_AKA, _CAL_NO, _EVEN_GED),
("Family Tree Maker", "FTW", _ADOPT_FTW, _CONC_BROKEN, _ALT_ALIAS, _CAL_NO, _EVEN_FTW),
("Ftree", "", _ADOPT_NONE, _CONC_BROKEN, _ALT_NONE, _CAL_NO, _EVEN_GED),
("GeneWeb", "", _ADOPT_EVENT_EXT, _CONC_OK, _ALT_NONE, _CAL_YES, _EVEN_GED),
("Legacy", "Legacy", _ADOPT_LEGACY, _CONC_BROKEN, _ALT_STD, _CAL_NO, _EVEN_GED),
("Personal Ancestral File", "PAF", _ADOPT_PEDI, _CONC_OK, _ALT_AKA, _CAL_NO, _EVEN_GED),
("Reunion", "REUNION", _ADOPT_NONE, _CONC_BROKEN, _ALT_NONE, _CAL_NO, _EVEN_GED),
("Visual Genealogie", "", _ADOPT_NONE, _CONC_BROKEN, _ALT_NONE, _CAL_NO, _EVEN_GED),
]
#-------------------------------------------------------------------------
@ -447,10 +451,10 @@ class GedcomWriter:
target_obj = self.topDialog.get_widget("target")
myMenu = gtk.GtkMenu()
for (name,dest,adopt,conc,alt,cal) in targets:
for (name,dest,adopt,conc,alt,cal,even) in targets:
menuitem = gtk.GtkMenuItem(name)
myMenu.append(menuitem)
menuitem.set_data("data",(dest,adopt,conc,alt,cal))
menuitem.set_data("data",(dest,adopt,conc,alt,cal,even))
menuitem.show()
target_obj.set_menu(myMenu)
@ -465,7 +469,7 @@ class GedcomWriter:
filter = self.filter_menu.get_active().get_data("filter")
act_tgt = self.target_menu.get_active()
(self.dest,self.adopt,self.conc,self.altname,self.cal) = act_tgt.get_data("data")
(self.dest,self.adopt,self.conc,self.altname,self.cal,self.even) = act_tgt.get_data("data")
if self.topDialog.get_widget("ansel").get_active():
self.cnvtxt = latin_to_ansel
@ -600,13 +604,19 @@ class GedcomWriter:
if const.familyConstantEvents.has_key(name):
val = const.familyConstantEvents[name]
if val[0] == '_' and self.even != _EVEN_FTW:
val = ''
else:
val = ""
if val != "":
self.g.write("1 %s\n" % const.familyConstantEvents[name])
else:
self.g.write("1 EVEN\n")
self.g.write("2 TYPE %s\n" % self.cnvtxt(name))
if val != "":
if self.even == _EVEN_NONE:
continue
self.g.write("1 %s %s\n" % (self.cnvtxt(val),
self.cnvtxt(event.getDescription())))
else:
self.g.write("1 EVEN %s\n" % self.cnvtxt(event.getDescription()))
self.g.write("2 TYPE %s\n" % self.cnvtxt(name))
self.dump_event_stats(event)
@ -696,8 +706,11 @@ class GedcomWriter:
name = event.getName()
if const.personalConstantEvents.has_key(name):
val = const.personalConstantEvents[name]
if val[0] == '_' and self.even != _EVEN_FTW:
val = ''
else:
val = ""
if self.adopt == _ADOPT_EVENT and val == "ADOP":
ad = 1
self.g.write('1 ADOP\n')
@ -717,6 +730,8 @@ class GedcomWriter:
else:
self.g.write('3 ADOP HUSB\n')
elif val != "" :
if self.even == _EVEN_NONE:
continue
self.g.write("1 %s %s\n" % (self.cnvtxt(val),\
self.cnvtxt(event.getDescription())))
else: