* src/MediaView.py: Pass parent to GlobalMediaProperties; typos.

* src/SelectObject.py: Typos.
* src/ImageSelect.py (LocalMediaProperties.__init__,
GlobalMediaProperties.__init__): Handle source tab.
* src/EventEdit.py: Handle gallery tab.
* src/WriteXML.py (dump_my_event): Write object references;
* src/gramps.glade: Add gallery tab to Event Editor; add source
tab to media property editor.
* src/RelLib.py (Event): Add media_list and related methods;
(ObjectRef): Inherit from SourceNote, remove unnecessary functions;
(GrampsDB.get_media_attribute_types): Add method.
* src/ReadXML.py (start_sourceref): Check for attribute before
the object. Objects may have attributes; (start_objref): Parse media
object references for Event records.


svn: r3199
This commit is contained in:
Alex Roitman 2004-06-03 05:35:30 +00:00
parent 6a25e86405
commit c5c4a151c2
9 changed files with 681 additions and 80 deletions

View File

@ -1,3 +1,20 @@
2004-06-02 Alex Roitman <shura@alex.neuro.umn.edu>
* src/MediaView.py: Pass parent to GlobalMediaProperties; typos.
* src/SelectObject.py: Typos.
* src/ImageSelect.py (LocalMediaProperties.__init__,
GlobalMediaProperties.__init__): Handle source tab.
* src/EventEdit.py: Handle gallery tab.
* src/WriteXML.py (dump_my_event): Write object references;
(write_photo_list): Write source references.
* src/gramps.glade: Add gallery tab to Event Editor; add source
tab to media property editor.
* src/RelLib.py (Event): Add media_list and related methods;
(ObjectRef): Inherit from SourceNote, remove unnecessary functions;
(GrampsDB.get_media_attribute_types): Add method.
* src/ReadXML.py (start_sourceref): Check for attribute before
the object. Objects may have attributes; (start_objref): Parse media
object references for Event records.
2004-06-02 Don Allingham <dallingham@users.sourceforge.net> 2004-06-02 Don Allingham <dallingham@users.sourceforge.net>
* src/DisplayModels.py: support for Spouse column * src/DisplayModels.py: support for Spouse column
* src/MediaView.py: fix try_to_find_object_from_id * src/MediaView.py: fix try_to_find_object_from_id

View File

@ -45,6 +45,7 @@ import AutoComp
import Calendar import Calendar
import RelLib import RelLib
import Date import Date
import ImageSelect
from DateEdit import DateEdit from DateEdit import DateEdit
from gettext import gettext as _ from gettext import gettext as _
@ -73,6 +74,7 @@ class EventEditor:
self.child_windows = {} self.child_windows = {}
self.trans = trans self.trans = trans
self.callback = cb self.callback = cb
self.path = self.db.get_save_path()
self.plist = [] self.plist = []
self.pmap = {} self.pmap = {}
@ -137,6 +139,7 @@ class EventEditor:
self.notes_label = self.top.get_widget("notesEvent") self.notes_label = self.top.get_widget("notesEvent")
self.flowed = self.top.get_widget("eventflowed") self.flowed = self.top.get_widget("eventflowed")
self.preform = self.top.get_widget("eventpreform") self.preform = self.top.get_widget("eventpreform")
self.gallery_label = self.top.get_widget("galleryEvent")
self.witnesses_label = self.top.get_widget("witnessesEvent") self.witnesses_label = self.top.get_widget("witnessesEvent")
if GrampsCfg.calendar: if GrampsCfg.calendar:
@ -188,6 +191,8 @@ class EventEditor:
self.preform.set_active(1) self.preform.set_active(1)
else: else:
self.flowed.set_active(1) self.flowed.set_active(1)
if event.get_media_list():
Utils.bold_label(self.gallery_label)
else: else:
if def_event: if def_event:
self.name_field.set_text(def_event) self.name_field.set_text(def_event)
@ -195,12 +200,23 @@ class EventEditor:
self.place_field.set_text(def_placename) self.place_field.set_text(def_placename)
self.date_check = DateEdit(self.date_field,self.top.get_widget("date_stat")) self.date_check = DateEdit(self.date_field,self.top.get_widget("date_stat"))
if not event:
event = RelLib.Event()
self.icon_list = self.top.get_widget("iconlist")
self.gallery = ImageSelect.Gallery(event, self.db.commit_event, self.path, self.icon_list,
self.db,self,self.window)
self.top.signal_autoconnect({ self.top.signal_autoconnect({
"on_switch_page" : self.on_switch_page, "on_switch_page" : self.on_switch_page,
"on_help_event_clicked" : self.on_help_clicked, "on_help_event_clicked" : self.on_help_clicked,
"on_ok_event_clicked" : self.on_event_edit_ok_clicked, "on_ok_event_clicked" : self.on_event_edit_ok_clicked,
"on_cancel_event_clicked" : self.close, "on_cancel_event_clicked" : self.close,
"on_event_edit_delete_event" : self.on_delete_event, "on_event_edit_delete_event" : self.on_delete_event,
"on_addphoto_clicked" : self.gallery.on_add_media_clicked,
"on_selectphoto_clicked" : self.gallery.on_select_media_clicked,
"on_deletephoto_clicked" : self.gallery.on_delete_media_clicked,
"on_edit_properties_clicked": self.gallery.popup_change_description,
"on_editphoto_clicked" : self.gallery.on_edit_media_clicked,
}) })
menu = gtk.Menu() menu = gtk.Menu()
@ -222,10 +238,12 @@ class EventEditor:
self.window.show() self.window.show()
def on_delete_event(self,obj,b): def on_delete_event(self,obj,b):
self.gallery.close(0)
self.close_child_windows() self.close_child_windows()
self.remove_itself_from_menu() self.remove_itself_from_menu()
def close(self,obj): def close(self,obj,ok=0):
self.gallery.close(ok)
self.close_child_windows() self.close_child_windows()
self.remove_itself_from_menu() self.remove_itself_from_menu()
self.window.destroy() self.window.destroy()
@ -318,7 +336,7 @@ class EventEditor:
self.db.add_transaction(trans,_("Edit Event")) self.db.add_transaction(trans,_("Edit Event"))
self.parent.redraw_event_list() self.parent.redraw_event_list()
self.callback(self.event) self.callback(self.event)
self.close(obj) self.close(obj,1)
def update_event(self,name,date,place,desc,note,format,priv,cause,trans): def update_event(self,name,date,place,desc,note,format,priv,cause,trans):
if place: if place:

View File

@ -53,6 +53,7 @@ import RelImage
import ListModel import ListModel
import SelectObject import SelectObject
import GrampsMime import GrampsMime
import Sources
from QuestionDialog import ErrorDialog from QuestionDialog import ErrorDialog
from gettext import gettext as _ from gettext import gettext as _
@ -167,9 +168,9 @@ class ImageSelect:
already_imported = None already_imported = None
trans = self.db.start_transactions() trans = self.db.start_transaction()
for o_id in self.db.get_object_keys(): for o_id in self.db.get_object_keys():
o = self.db.try_to_find_object_from_id(o_id,trans) o = self.db.try_to_find_object_from_id(o_id)
if o.get_path() == filename: if o.get_path() == filename:
already_imported = o already_imported = o
break break
@ -276,7 +277,7 @@ 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:
id = self.sel_obj.get_reference_id() id = self.sel_obj.get_reference_id()
obj = self.db.try_to_find_object_from_id(id,None) obj = self.db.try_to_find_object_from_id(id)
mtype = obj.get_mime_type() mtype = obj.get_mime_type()
name = Utils.thumb_path(self.db.get_save_path(),obj) name = Utils.thumb_path(self.db.get_save_path(),obj)
pix = gtk.gdk.pixbuf_new_from_file(name) pix = gtk.gdk.pixbuf_new_from_file(name)
@ -362,7 +363,7 @@ class Gallery(ImageSelect):
def savephoto(self, photo): def savephoto(self, photo):
"""Save the photo in the dataobj object. (Required function)""" """Save the photo in the dataobj object. (Required function)"""
self.db.add_object(photo) self.db.add_object(photo,None)
oref = RelLib.MediaRef() oref = RelLib.MediaRef()
oref.set_reference_id(photo.get_id()) oref.set_reference_id(photo.get_id())
self.dataobj.add_media_reference(oref) self.dataobj.add_media_reference(oref)
@ -370,7 +371,7 @@ class Gallery(ImageSelect):
def add_thumbnail(self, photo): def add_thumbnail(self, photo):
"""Scale the image and add it to the IconList.""" """Scale the image and add it to the IconList."""
oid = photo.get_reference_id() oid = photo.get_reference_id()
object = self.db.try_to_find_object_from_id(oid,None) object = self.db.try_to_find_object_from_id(oid)
if self.canvas_list.has_key(oid): if self.canvas_list.has_key(oid):
(grp,item,text,x,y) = self.canvas_list[oid] (grp,item,text,x,y) = self.canvas_list[oid]
if x != self.cx or y != self.cy: if x != self.cx or y != self.cy:
@ -465,7 +466,7 @@ class Gallery(ImageSelect):
return min(index,len(self.dataobj.get_media_list())) return min(index,len(self.dataobj.get_media_list()))
def on_photolist_drag_data_received(self,w, context, x, y, data, info, time): def on_photolist_drag_data_received(self,w, context, x, y, data, info, time):
if data and data.format == 8: if data and data.format == 8:
icon_index = self.get_index(w,x,y) icon_index = self.get_index(w,x,y)
d = string.strip(string.replace(data.data,'\0',' ')) d = string.strip(string.replace(data.data,'\0',' '))
protocol,site,file, j,k,l = urlparse.urlparse(d) protocol,site,file, j,k,l = urlparse.urlparse(d)
@ -484,7 +485,8 @@ class Gallery(ImageSelect):
photo.set_path(name) photo.set_path(name)
self.parent.lists_changed = 1 self.parent.lists_changed = 1
if GrampsCfg.globalprop: if GrampsCfg.globalprop:
GlobalMediaProperties(self.db,photo,None) GlobalMediaProperties(self.db,photo,None,
self,self.parent_window)
elif protocol != "": elif protocol != "":
import urllib import urllib
u = urllib.URLopener() u = urllib.URLopener()
@ -499,7 +501,7 @@ class Gallery(ImageSelect):
photo.set_mime_type(mime) photo.set_mime_type(mime)
photo.set_description(d) photo.set_description(d)
photo.set_path(tfile) photo.set_path(tfile)
self.db.add_object(photo) self.db.add_object(photo,None)
oref = RelLib.MediaRef() oref = RelLib.MediaRef()
oref.set_reference_id(photo.get_id()) oref.set_reference_id(photo.get_id())
self.dataobj.add_media_reference(oref) self.dataobj.add_media_reference(oref)
@ -513,7 +515,8 @@ class Gallery(ImageSelect):
self.add_thumbnail(oref) self.add_thumbnail(oref)
self.parent.lists_changed = 1 self.parent.lists_changed = 1
if GrampsCfg.globalprop: if GrampsCfg.globalprop:
GlobalMediaProperties(self.db,photo,None) GlobalMediaProperties(self.db,photo,None,
self,self.parent_window)
else: else:
if self.db.has_object_id(data.data): if self.db.has_object_id(data.data):
icon_index = self.get_index(w,x,y) icon_index = self.get_index(w,x,y)
@ -603,7 +606,7 @@ class Gallery(ImageSelect):
menu = gtk.Menu() menu = gtk.Menu()
menu.set_title(_("Media Object")) menu.set_title(_("Media Object"))
object = self.db.try_to_find_object_from_id(photo.get_reference_id(),None) object = self.db.try_to_find_object_from_id(photo.get_reference_id())
mtype = object.get_mime_type() mtype = object.get_mime_type()
progname = GrampsMime.get_application(mtype) progname = GrampsMime.get_application(mtype)
@ -620,21 +623,20 @@ class Gallery(ImageSelect):
def popup_view_photo(self, obj): def popup_view_photo(self, obj):
"""Open this picture in a picture viewer""" """Open this picture in a picture viewer"""
photo = obj.get_data('o') photo = obj.get_data('o')
Utils.view_photo(self.db.try_to_find_object_from_id(photo.get_reference_id(), Utils.view_photo(self.db.try_to_find_object_from_id(photo.get_reference_id()))
None))
def popup_edit_photo(self, obj): def popup_edit_photo(self, obj):
"""Open this picture in a picture editor""" """Open this picture in a picture editor"""
photo = obj.get_data('o') photo = obj.get_data('o')
if os.fork() == 0: if os.fork() == 0:
obj = self.db.try_to_find_object_from_id(photo.get_reference_id(),None) obj = self.db.try_to_find_object_from_id(photo.get_reference_id())
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): def popup_convert_to_private(self, obj):
"""Copy this picture into gramps private database instead of """Copy this picture into gramps private database instead of
leaving it as an external data object.""" leaving it as an external data object."""
photo = obj.get_data('o') photo = obj.get_data('o')
object = self.db.try_to_find_object_from_id(photo.get_reference_id(),None) object = self.db.try_to_find_object_from_id(photo.get_reference_id())
name = RelImage.import_media_object(object.get_path(),self.path, name = RelImage.import_media_object(object.get_path(),self.path,
object.get_id()) object.get_id())
object.set_path(name) object.set_path(name)
@ -665,8 +667,7 @@ class LocalMediaProperties:
self.child_windows = {} self.child_windows = {}
self.photo = photo self.photo = photo
self.db = parent.db self.db = parent.db
self.object = self.db.try_to_find_object_from_id(photo.get_reference_id(), self.object = self.db.try_to_find_object_from_id(photo.get_reference_id())
None)
self.alist = photo.get_attribute_list()[:] self.alist = photo.get_attribute_list()[:]
self.lists_changed = 0 self.lists_changed = 0
@ -674,7 +675,8 @@ class LocalMediaProperties:
self.change_dialog = gtk.glade.XML(const.imageselFile,"change_description","gramps") self.change_dialog = gtk.glade.XML(const.imageselFile,"change_description","gramps")
title = _('Media Reference Editor') title = _('Media Reference Editor')
Utils.set_titles(self.change_dialog.get_widget('change_description'), self.window = self.change_dialog.get_widget('change_description')
Utils.set_titles(self.window,
self.change_dialog.get_widget('title'), title) self.change_dialog.get_widget('title'), title)
descr_window = self.change_dialog.get_widget("description") descr_window = self.change_dialog.get_widget("description")
@ -695,6 +697,20 @@ class LocalMediaProperties:
self.on_attr_list_select_row, self.on_attr_list_select_row,
self.on_update_attr_clicked) self.on_update_attr_clicked)
self.slist = self.change_dialog.get_widget("src_slist")
self.sources_label = self.change_dialog.get_widget("source_label")
if self.object:
self.srcreflist = self.photo.get_source_references()
else:
self.srcreflist = []
self.sourcetab = Sources.SourceTab(self.srcreflist,self,
self.change_dialog,
self.window, self.slist,
self.change_dialog.get_widget('add_src'),
self.change_dialog.get_widget('edit_src'),
self.change_dialog.get_widget('del_src'))
descr_window.set_text(self.object.get_description()) descr_window.set_text(self.object.get_description())
mtype = self.object.get_mime_type() mtype = self.object.get_mime_type()
@ -730,7 +746,6 @@ class LocalMediaProperties:
"on_local_delete_event" : self.on_delete_event, "on_local_delete_event" : self.on_delete_event,
}) })
self.redraw_attr_list() self.redraw_attr_list()
self.window = self.change_dialog.get_widget('change_description')
if parent_window: if parent_window:
self.window.set_transient_for(parent_window) self.window.set_transient_for(parent_window)
self.add_itself_to_menu() self.add_itself_to_menu()
@ -864,7 +879,17 @@ class LocalMediaProperties:
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class GlobalMediaProperties: class GlobalMediaProperties:
def __init__(self,db,object,update): def __init__(self,db,object,update,parent,parent_window=None):
self.parent = parent
if object:
if self.parent.parent.child_windows.has_key(object.get_id()):
self.parent.parent.child_windows[object.get_id()].present(None)
return
else:
self.win_key = object.get_id()
else:
self.win_key = self
self.child_windows = {}
self.object = object self.object = object
self.alist = self.object.get_attribute_list()[:] self.alist = self.object.get_attribute_list()[:]
self.lists_changed = 0 self.lists_changed = 0
@ -875,9 +900,10 @@ class GlobalMediaProperties:
self.path = self.db.get_save_path() self.path = self.db.get_save_path()
self.change_dialog = gtk.glade.XML(const.imageselFile,"change_global","gramps") self.change_dialog = gtk.glade.XML(const.imageselFile,"change_global","gramps")
title = _('Change global media object properties') title = _('Media Properties Editor')
Utils.set_titles(self.change_dialog.get_widget('change_global'), self.window = self.change_dialog.get_widget('change_global')
Utils.set_titles(self.window,
self.change_dialog.get_widget('title'),title) self.change_dialog.get_widget('title'),title)
self.descr_window = self.change_dialog.get_widget("description") self.descr_window = self.change_dialog.get_widget("description")
@ -901,6 +927,20 @@ class GlobalMediaProperties:
self.on_attr_list_select_row, self.on_attr_list_select_row,
self.on_update_attr_clicked) self.on_update_attr_clicked)
self.slist = self.change_dialog.get_widget("src_list")
self.sources_label = self.change_dialog.get_widget("sourcesGlobal")
if self.object:
self.srcreflist = self.object.get_source_references()
else:
self.srcreflist = []
self.sourcetab = Sources.SourceTab(self.srcreflist,self,
self.change_dialog,
self.window, self.slist,
self.change_dialog.get_widget('gl_add_src'),
self.change_dialog.get_widget('gl_edit_src'),
self.change_dialog.get_widget('gl_del_src'))
self.descr_window.set_text(self.object.get_description()) self.descr_window.set_text(self.object.get_description())
mtype = self.object.get_mime_type() mtype = self.object.get_mime_type()
pb = gtk.gdk.pixbuf_new_from_file(Utils.thumb_path(self.path,self.object)) pb = gtk.gdk.pixbuf_new_from_file(Utils.thumb_path(self.path,self.object))
@ -921,7 +961,7 @@ class GlobalMediaProperties:
self.flowed.set_active(1) self.flowed.set_active(1)
self.change_dialog.signal_autoconnect({ self.change_dialog.signal_autoconnect({
"on_cancel_clicked" : Utils.destroy_passed_object, "on_cancel_clicked" : self.close,
"on_up_clicked" : self.on_up_clicked, "on_up_clicked" : self.on_up_clicked,
"on_down_clicked" : self.on_down_clicked, "on_down_clicked" : self.on_down_clicked,
"on_ok_clicked" : self.on_ok_clicked, "on_ok_clicked" : self.on_ok_clicked,
@ -930,11 +970,52 @@ class GlobalMediaProperties:
"on_notebook_switch_page": self.on_notebook_switch_page, "on_notebook_switch_page": self.on_notebook_switch_page,
"on_delete_attr_clicked" : self.on_delete_attr_clicked, "on_delete_attr_clicked" : self.on_delete_attr_clicked,
"on_update_attr_clicked" : self.on_update_attr_clicked, "on_update_attr_clicked" : self.on_update_attr_clicked,
"on_help_clicked" : self.on_help_clicked, "on_help_clicked" : self.on_help_clicked,
"on_global_delete_event" : self.on_delete_event,
}) })
self.redraw_attr_list() self.redraw_attr_list()
self.display_refs() self.display_refs()
if parent_window:
self.window.set_transient_for(parent_window)
self.add_itself_to_menu()
self.window.show()
def on_delete_event(self,obj,b):
self.close_child_windows()
self.remove_itself_from_menu()
def close(self,obj):
self.close_child_windows()
self.remove_itself_from_menu()
self.window.destroy()
def close_child_windows(self):
for child_window in self.child_windows.values():
child_window.close(None)
self.child_windows = {}
def add_itself_to_menu(self):
self.parent.parent.child_windows[self.win_key] = self
label = _('Media Object')
self.parent_menu_item = gtk.MenuItem(label)
self.parent_menu_item.set_submenu(gtk.Menu())
self.parent_menu_item.show()
self.parent.parent.winsmenu.append(self.parent_menu_item)
self.winsmenu = self.parent_menu_item.get_submenu()
self.menu_item = gtk.MenuItem(_('Properties Editor'))
self.menu_item.connect("activate",self.present)
self.menu_item.show()
self.winsmenu.append(self.menu_item)
def remove_itself_from_menu(self):
del self.parent.parent.child_windows[self.win_key]
self.menu_item.destroy()
self.winsmenu.destroy()
self.parent_menu_item.destroy()
def present(self,obj):
self.window.present()
def on_up_clicked(self,obj): def on_up_clicked(self,obj):
store,iter = self.atree.get_selected() store,iter = self.atree.get_selected()
@ -1119,7 +1200,7 @@ class DeleteMediaQuery:
self.db.commit_family(p,trans) self.db.commit_family(p,trans)
for key in self.db.get_source_keys(): for key in self.db.get_source_keys():
sid = self.db.try_to_find_source_from_id(key,trans) sid = self.db.try_to_find_source_from_id(key)
nl = [] nl = []
change = 0 change = 0
for photo in p.get_media_list(): for photo in p.get_media_list():

View File

@ -84,6 +84,7 @@ class MediaView:
self.mpath = glade.get_widget("mpath") self.mpath = glade.get_widget("mpath")
self.mdetails = glade.get_widget("mdetails") self.mdetails = glade.get_widget("mdetails")
self.preview = glade.get_widget("preview") self.preview = glade.get_widget("preview")
self.topWindow = glade.get_widget("gramps")
self.renderer = gtk.CellRendererText() self.renderer = gtk.CellRendererText()
if const.nosort_tree: if const.nosort_tree:
@ -225,7 +226,7 @@ class MediaView:
store,iter = self.selection.get_selected() store,iter = self.selection.get_selected()
if iter: if iter:
id = store.get_value(iter,1) id = store.get_value(iter,1)
object = self.db.try_to_find_object_from_id(id,None) object = self.db.try_to_find_object_from_id(id)
self.obj = object self.obj = object
mime_type = object.get_mime_type() mime_type = object.get_mime_type()
@ -273,7 +274,8 @@ class MediaView:
self.load_media() self.load_media()
def popup_change_description(self, obj): def popup_change_description(self, obj):
ImageSelect.GlobalMediaProperties(self.db,self.obj,self.load_media) ImageSelect.GlobalMediaProperties(self.db,self.obj,self.load_media,
self,self.topWindow)
def load_media(self): def load_media(self):
pass pass
@ -290,8 +292,9 @@ class MediaView:
list_store, iter = self.selection.get_selected() list_store, iter = self.selection.get_selected()
if iter: if iter:
id = list_store.get_value(iter,1) id = list_store.get_value(iter,1)
object = self.db.try_to_find_object_from_id(id,None) object = self.db.try_to_find_object_from_id(id)
ImageSelect.GlobalMediaProperties(self.db,object,self.load_media) ImageSelect.GlobalMediaProperties(self.db,object,self.load_media,
self,self.topWindow)
def on_delete_clicked(self,obj): def on_delete_clicked(self,obj):
store,iter = self.selection.get_selected() store,iter = self.selection.get_selected()
@ -299,7 +302,7 @@ class MediaView:
return return
id = store.get_value(iter,1) id = store.get_value(iter,1)
mobj = self.db.try_to_find_object_from_id(id,None) mobj = self.db.try_to_find_object_from_id(id)
if self.is_object_used(mobj): if self.is_object_used(mobj):
ans = ImageSelect.DeleteMediaQuery(mobj,self.db,self.build_tree) ans = ImageSelect.DeleteMediaQuery(mobj,self.db,self.build_tree)
QuestionDialog(_('Delete Media Object?'), QuestionDialog(_('Delete Media Object?'),
@ -343,7 +346,7 @@ class MediaView:
if not iter: if not iter:
return return
if (const.dnd_images): if (const.dnd_images):
object = self.db.try_to_find_object_from_id(store.get_value(iter,1),None) object = self.db.try_to_find_object_from_id(store.get_value(iter,1))
mtype = object.get_mime_type() mtype = object.get_mime_type()
name = Utils.thumb_path(self.db.get_save_path(),object) name = Utils.thumb_path(self.db.get_save_path(),object)
pix = gtk.gdk.pixbuf_new_from_file(name) pix = gtk.gdk.pixbuf_new_from_file(name)
@ -387,7 +390,8 @@ class MediaView:
self.db.add_transaction(trans,_("Add Media Object")) self.db.add_transaction(trans,_("Add Media Object"))
if GrampsCfg.globalprop: if GrampsCfg.globalprop:
ImageSelect.GlobalMediaProperties(self.db,photo,self.load_media) ImageSelect.GlobalMediaProperties(self.db,photo,self.load_media,
self,self.topWindow)
elif protocol != "": elif protocol != "":
import urllib import urllib
u = urllib.URLopener() u = urllib.URLopener()
@ -419,6 +423,7 @@ class MediaView:
self.db.add_transaction(trans,_("Add Media Object")) self.db.add_transaction(trans,_("Add Media Object"))
if GrampsCfg.globalprop: if GrampsCfg.globalprop:
ImageSelect.GlobalMediaProperties(self.db,photo,None) ImageSelect.GlobalMediaProperties(self.db,photo,None,
self,self.topWindow)

View File

@ -641,20 +641,24 @@ class GrampsParser:
self.photo.add_source_reference(self.source_ref) self.photo.add_source_reference(self.source_ref)
elif self.ord: elif self.ord:
self.ord.add_source_reference(self.source_ref) self.ord.add_source_reference(self.source_ref)
elif self.attribute:
self.attribute.add_source_reference(self.source_ref)
elif self.object: elif self.object:
self.object.add_source_reference(self.source_ref) self.object.add_source_reference(self.source_ref)
elif self.objref:
self.objref.add_source_reference(self.source_ref)
elif self.event: elif self.event:
self.event.add_source_reference(self.source_ref) self.event.add_source_reference(self.source_ref)
elif self.address: elif self.address:
self.address.add_source_reference(self.source_ref) self.address.add_source_reference(self.source_ref)
elif self.name: elif self.name:
self.name.add_source_reference(self.source_ref) self.name.add_source_reference(self.source_ref)
elif self.attribute:
self.attribute.add_source_reference(self.source_ref)
elif self.placeobj: elif self.placeobj:
self.placeobj.add_source_reference(self.source_ref) self.placeobj.add_source_reference(self.source_ref)
elif self.family: elif self.family:
self.family.add_source_reference(self.source_ref) self.family.add_source_reference(self.source_ref)
elif self.person:
self.person.add_source_reference(self.source_ref)
def start_source(self,attrs): def start_source(self,attrs):
self.source = self.db.find_source_no_conflicts(attrs["id"], self.source = self.db.find_source_no_conflicts(attrs["id"],
@ -667,7 +671,9 @@ class GrampsParser:
self.objref.set_reference_id(id) self.objref.set_reference_id(id)
if attrs.has_key('priv'): if attrs.has_key('priv'):
self.objref.set_privacy(int(attrs['priv'])) self.objref.set_privacy(int(attrs['priv']))
if self.family: if self.event:
self.event.add_media_reference(self.objref)
elif self.family:
self.family.add_media_reference(self.objref) self.family.add_media_reference(self.objref)
elif self.source: elif self.source:
self.source.add_media_reference(self.objref) self.source.add_media_reference(self.objref)

View File

@ -716,9 +716,12 @@ class MediaObject(SourceNote):
# MediaRef # MediaRef
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class MediaRef: class MediaRef(SourceNote):
"""Object reference class""" """Media reference class"""
def __init__(self,source=None): def __init__(self,source=None):
SourceNote.__init__(self,source)
self.attrlist = [] self.attrlist = []
if source: if source:
self.private = source.private self.private = source.private
@ -745,43 +748,6 @@ class MediaRef:
def get_reference_id(self): def get_reference_id(self):
return self.ref return self.ref
def set_note(self,text):
"""Set the note to the given text"""
if self.note == None:
self.note = Note()
self.note.set(text)
def get_note(self):
"""Return the current note"""
if self.note == None:
return ""
else:
return self.note.get()
def set_note_format(self,val):
"""Set the note's format to the given value"""
if self.note:
self.note.set_format(val)
def get_note_format(self):
"""Return the current note's format"""
if self.note == None:
return 0
else:
return self.note.get_format()
def set_note_object(self,obj):
"""Change the note object instance to obj"""
self.note = obj
def get_note_object(self):
"""Return in note instance, not just the text"""
return self.note
def unique_note(self):
"""Creates a unique instance of the current note"""
self.note = Note(self.note.get())
def add_attribute(self,attr): def add_attribute(self,attr):
"""Adds a propery to the MediaObject object. This is not used by gramps, """Adds a propery to the MediaObject object. This is not used by gramps,
but provides a means for XML users to attach other properties to but provides a means for XML users to attach other properties to
@ -1684,6 +1650,7 @@ class Event(DataObj):
self.name = source.name self.name = source.name
self.cause = source.cause self.cause = source.cause
self.id = source.id self.id = source.id
self.media_list = [MediaRef(media_id) for media_id in source.media_list]
try: try:
if source.witness: if source.witness:
self.witness = source.witness[:] self.witness = source.witness[:]
@ -1699,6 +1666,7 @@ class Event(DataObj):
self.cause = "" self.cause = ""
self.witness = None self.witness = None
self.id = None self.id = None
self.media_list = []
def clone(self,source): def clone(self,source):
self.place = source.place self.place = source.place
@ -1710,6 +1678,7 @@ class Event(DataObj):
self.private = source.private self.private = source.private
self.source_list = source.source_list[:] self.source_list = source.source_list[:]
self.note = source.note self.note = source.note
self.media_list = [MediaRef(media_id) for media_id in source.media_list]
try: try:
if source.witness: if source.witness:
self.witness = source.witness[:] self.witness = source.witness[:]
@ -1728,6 +1697,18 @@ class Event(DataObj):
self.place, self.cause, self.private, self.source_list, self.place, self.cause, self.private, self.source_list,
self.note, self.witness) = data self.note, self.witness) = data
def add_media_reference(self,media_id):
"""Adds a Photo object to the Event object's image list"""
self.media_list.append(media_id)
def get_media_list(self):
"""Returns the list of Photo objects"""
return self.media_list
def set_media_list(self,mlist):
"""Sets the list of Photo objects"""
self.media_list = mlist
def set_id(self,gid): def set_id(self,gid):
"""Sets the gramps ID for the place object""" """Sets the gramps ID for the place object"""
self.id = gid self.id = gid
@ -2883,6 +2864,16 @@ class GrampsDB:
# map[event.get_name()] = 1 # map[event.get_name()] = 1
return map.keys() return map.keys()
def get_media_attribute_types(self):
"""returns a list of all Attribute types assocated with Media
instances in the database"""
map = {}
# for media_id in self.media_map.keys():
# mobject = self.find_object_from_id(media_id)
# for attr in mobject.get_attribute_list():
# map[attr.get_type()] = 1
return map.keys()
def get_place_ids(self): def get_place_ids(self):
"""returns a list of Place instances""" """returns a list of Place instances"""
return self.place_map.keys() return self.place_map.keys()

View File

@ -100,7 +100,7 @@ class SelectObject:
self.object_model.new_model() self.object_model.new_model()
for key in self.db.get_object_keys(): for key in self.db.get_object_keys():
object = self.db.try_to_find_object_from_id(key,None) object = self.db.try_to_find_object_from_id(key)
title = object.get_description() title = object.get_description()
the_id = object.get_id() the_id = object.get_id()
the_type = Utils.get_mime_description(object.get_mime_type()) the_type = Utils.get_mime_description(object.get_mime_type())
@ -117,7 +117,7 @@ class SelectObject:
return return
data = self.object_model.get_data(iter,range(self.ncols)) data = self.object_model.get_data(iter,range(self.ncols))
the_id = data[4] the_id = data[4]
object = self.db.try_to_find_object_from_id(the_id,None) object = self.db.try_to_find_object_from_id(the_id)
the_type = Utils.get_mime_description(object.get_mime_type()) the_type = Utils.get_mime_description(object.get_mime_type())
path = object.get_path() path = object.get_path()
@ -150,7 +150,7 @@ class SelectObject:
if iter: if iter:
data = self.object_model.get_data(iter,range(self.ncols)) data = self.object_model.get_data(iter,range(self.ncols))
the_id = data[4] the_id = data[4]
return_value = self.db.try_to_find_object_from_id(the_id,None) return_value = self.db.try_to_find_object_from_id(the_id)
else: else:
return_value = None return_value = None
self.top.destroy() self.top.destroy()

View File

@ -467,6 +467,7 @@ class XmlWriter:
for s in event.get_source_references(): for s in event.get_source_references():
self.dump_source_ref(s,index+1) self.dump_source_ref(s,index+1)
self.write_media_list(event.get_media_list(),index+1)
self.g.write("%s</event>\n" % sp) self.g.write("%s</event>\n" % sp)
def dump_ordinance(self,name,ord,index=1): def dump_ordinance(self,name,ord,index=1):
@ -689,11 +690,15 @@ class XmlWriter:
if photo.get_privacy(): if photo.get_privacy():
self.g.write(' priv="1"') self.g.write(' priv="1"')
proplist = photo.get_attribute_list() proplist = photo.get_attribute_list()
if len(proplist) == 0 and photo.get_note() == "": refslist = photo.get_source_references()
if len(proplist) == 0 and len(refslist) == 0 \
and photo.get_note() == "":
self.g.write("/>\n") self.g.write("/>\n")
else: else:
self.g.write(">\n") self.g.write(">\n")
self.write_attribute_list(proplist,indent+1) self.write_attribute_list(proplist,indent+1)
for ref in refslist:
self.dump_source_ref(ref,indent+1)
self.write_note("note",photo.get_note_object(),indent+1) self.write_note("note",photo.get_note_object(),indent+1)
self.g.write('%s</objref>\n' % sp) self.g.write('%s</objref>\n' % sp)

View File

@ -24523,6 +24523,157 @@
<property name="type">tab</property> <property name="type">tab</property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkVBox" id="vbox84">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkHBox" id="hbox93">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow81">
<property name="visible">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="src_list">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox85">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkButton" id="add_src">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Add...</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="edit_src">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Edit...</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="del_src">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Delete</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox35">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_SPREAD</property>
<property name="spacing">30</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="source_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Sources</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
</widget> </widget>
<packing> <packing>
<property name="padding">10</property> <property name="padding">10</property>
@ -24558,6 +24709,7 @@
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="has_separator">False</property> <property name="has_separator">False</property>
<signal name="delete_event" handler="on_global_delete_event" last_modification_time="Thu, 03 Jun 2004 05:16:21 GMT"/>
<child internal-child="vbox"> <child internal-child="vbox">
<widget class="GtkVBox" id="vbox25"> <widget class="GtkVBox" id="vbox25">
@ -25453,6 +25605,157 @@
<property name="type">tab</property> <property name="type">tab</property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkVBox" id="vbox82">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkHBox" id="hbox92">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow80">
<property name="visible">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="src_list">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox83">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkButton" id="gl_add_src">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Add...</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="gl_edit_src">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Edit...</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="gl_del_src">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Delete</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox34">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_SPREAD</property>
<property name="spacing">30</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="sourcesGlobal">
<property name="visible">True</property>
<property name="label" translatable="yes">Sources</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>
@ -27631,6 +27934,181 @@
<property name="type">tab</property> <property name="type">tab</property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkVBox" id="vbox80">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkHBox" id="hbox91">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow79">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GnomeCanvas" id="iconlist">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="anti_aliased">False</property>
<property name="scroll_x1">0</property>
<property name="scroll_y1">0</property>
<property name="scroll_x2">100</property>
<property name="scroll_y2">100</property>
<property name="pixels_per_unit">1</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox81">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkButton" id="button170">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Add a new media object to the database and place it in this gallery</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Add from file...</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_addphoto_clicked" object="sourceEditor"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button171">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Select an existing media object from the database and place it in this gallery</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Add from _database...</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_selectphoto_clicked" object="sourceEditor" last_modification_time="Fri, 12 Dec 2003 05:21:39 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button172">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Edit the properties of the selected object</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Edit...</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_editphoto_clicked" object="sourceEditor" last_modification_time="Fri, 06 Feb 2004 20:06:09 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button173">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Remove selected object from this gallery only</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Remove</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_deletephoto_clicked" object="sourceEditor"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox33">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_SPREAD</property>
<property name="spacing">30</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="galleryEvent">
<property name="visible">True</property>
<property name="label" translatable="yes">Gallery</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>