* src/ImageSelect.py: Add date/place property to media objects
* src/ReadXML.py: Add date/place property to media objects * src/RelLib.py: Add date/place property to media objects * src/WriteXML.py: Add date/place property to media objects * src/gramps.glade: Add date/place property to media objects * src/SelectObject.py: display gramps id instead of internal handle svn: r3707
This commit is contained in:
parent
02c1c5c99a
commit
9f86c80af1
@ -1,3 +1,11 @@
|
||||
2004-11-05 Don Allingham <dallingham@users.sourceforge.net>
|
||||
* src/ImageSelect.py: Add date/place property to media objects
|
||||
* src/ReadXML.py: Add date/place property to media objects
|
||||
* src/RelLib.py: Add date/place property to media objects
|
||||
* src/WriteXML.py: Add date/place property to media objects
|
||||
* src/gramps.glade: Add date/place property to media objects
|
||||
* src/SelectObject.py: display gramps id instead of internal handle
|
||||
|
||||
2004-11-05 Tim Waugh <twaugh@redhat.com>
|
||||
* src/plugins/Ancestors.py: Include non-marriage relationships.
|
||||
|
||||
|
@ -57,6 +57,9 @@ import ListModel
|
||||
import SelectObject
|
||||
import GrampsMime
|
||||
import Sources
|
||||
import DateEdit
|
||||
import DateHandler
|
||||
import Date
|
||||
from QuestionDialog import ErrorDialog
|
||||
|
||||
_IMAGEX = 140
|
||||
@ -870,6 +873,8 @@ class GlobalMediaProperties:
|
||||
|
||||
def __init__(self,db,obj,update,parent,parent_window=None):
|
||||
self.parent = parent
|
||||
self.dp = DateHandler.create_parser()
|
||||
self.dd = DateHandler.create_display()
|
||||
if obj:
|
||||
if self.parent.parent.child_windows.has_key(obj.get_handle()):
|
||||
self.parent.parent.child_windows[obj.get_handle()].present(None)
|
||||
@ -885,18 +890,48 @@ class GlobalMediaProperties:
|
||||
self.db = db
|
||||
self.update = update
|
||||
self.refs = 0
|
||||
|
||||
if obj:
|
||||
self.date_object = Date.Date(self.obj.get_date_object())
|
||||
else:
|
||||
self.date_object = Date.Date()
|
||||
|
||||
self.path = self.db.get_save_path()
|
||||
self.change_dialog = gtk.glade.XML(const.imageselFile,"change_global","gramps")
|
||||
|
||||
title = _('Media Properties Editor')
|
||||
|
||||
self.window = self.change_dialog.get_widget('change_global')
|
||||
self.date_entry = self.change_dialog.get_widget('date')
|
||||
|
||||
self.pdmap = {}
|
||||
self.add_places = []
|
||||
for key in self.db.get_place_handles():
|
||||
p = db.get_place_from_handle(key).get_display_info()
|
||||
self.pdmap[p[0]] = key
|
||||
|
||||
self.place = self.change_dialog.get_widget('place')
|
||||
self.place_list = self.pdmap.keys()
|
||||
self.place_list.sort()
|
||||
build_dropdown(self.place,self.place_list)
|
||||
|
||||
if self.obj:
|
||||
handle = self.obj.get_place_handle()
|
||||
pobj = self.db.get_place_from_handle(handle)
|
||||
if pobj:
|
||||
self.place.set_text(pobj.get_title())
|
||||
|
||||
self.date_entry.set_text(self.dd.display(self.date_object))
|
||||
|
||||
Utils.set_titles(self.window,
|
||||
self.change_dialog.get_widget('title'),title)
|
||||
|
||||
self.descr_window = self.change_dialog.get_widget("description")
|
||||
self.notes = self.change_dialog.get_widget("notes")
|
||||
self.date_check = DateEdit.DateEdit(self.date_object,
|
||||
self.date_entry,
|
||||
self.change_dialog.get_widget("date_edit"),
|
||||
self.window)
|
||||
|
||||
self.pixmap = self.change_dialog.get_widget("pixmap")
|
||||
self.attr_type = self.change_dialog.get_widget("attr_type")
|
||||
self.attr_value = self.change_dialog.get_widget("attr_value")
|
||||
@ -1089,11 +1124,38 @@ class GlobalMediaProperties:
|
||||
else:
|
||||
Utils.unbold_label(self.notes_label)
|
||||
|
||||
def get_place(self,field,makenew=0):
|
||||
text = unicode(field.get_text().strip())
|
||||
if text:
|
||||
if self.pdmap.has_key(text):
|
||||
return self.pdmap[text]
|
||||
elif makenew:
|
||||
place = RelLib.Place()
|
||||
place.set_title(text)
|
||||
trans = self.db.transaction_begin()
|
||||
self.db.add_place(place,trans)
|
||||
self.db.transaction_commit(trans,_('Add Place (%s)' % text))
|
||||
self.pdmap[text] = place.get_handle()
|
||||
self.add_places.append(place)
|
||||
return place.get_handle()
|
||||
else:
|
||||
return None
|
||||
else:
|
||||
return None
|
||||
|
||||
def on_apply_clicked(self, obj):
|
||||
t = self.notes.get_buffer()
|
||||
text = unicode(t.get_text(t.get_start_iter(),t.get_end_iter(),gtk.FALSE))
|
||||
desc = unicode(self.descr_window.get_text())
|
||||
note = self.obj.get_note()
|
||||
|
||||
if not self.date_object.is_equal(self.obj.get_date_object()):
|
||||
self.obj.set_date_object(self.date_object)
|
||||
|
||||
p = self.get_place(self.place)
|
||||
if p:
|
||||
self.obj.set_place_handle(p)
|
||||
|
||||
format = self.preform.get_active()
|
||||
if text != note or desc != self.obj.get_description():
|
||||
self.obj.set_note(text)
|
||||
@ -1219,3 +1281,13 @@ class DeleteMediaQuery:
|
||||
self.db.transaction_commit(trans,_("Remove Media Object"))
|
||||
if self.update:
|
||||
self.update()
|
||||
|
||||
def build_dropdown(entry,strings):
|
||||
store = gtk.ListStore(str)
|
||||
for value in strings:
|
||||
node = store.append()
|
||||
store.set(node,0,value)
|
||||
completion = gtk.EntryCompletion()
|
||||
completion.set_text_column(0)
|
||||
completion.set_model(store)
|
||||
entry.set_completion(completion)
|
||||
|
@ -967,6 +967,8 @@ class GrampsParser:
|
||||
dv = self.source_ref.get_date()
|
||||
elif self.ord:
|
||||
dv = self.ord.get_date_object()
|
||||
elif self.object:
|
||||
dv = self.object.get_date_object()
|
||||
elif self.address:
|
||||
dv = self.address.get_date_object()
|
||||
else:
|
||||
@ -1017,6 +1019,8 @@ class GrampsParser:
|
||||
dv = self.source_ref.get_date()
|
||||
elif self.ord:
|
||||
dv = self.ord.get_date_object()
|
||||
elif self.object:
|
||||
dv = self.object.get_date_object()
|
||||
elif self.address:
|
||||
dv = self.address.get_date_object()
|
||||
else:
|
||||
@ -1067,6 +1071,8 @@ class GrampsParser:
|
||||
dv = self.source_ref.get_date()
|
||||
elif self.ord:
|
||||
dv = self.ord.get_date_object()
|
||||
elif self.object:
|
||||
dv = self.object.get_date_object()
|
||||
elif self.address:
|
||||
dv = self.address.get_date_object()
|
||||
else:
|
||||
@ -1171,6 +1177,8 @@ class GrampsParser:
|
||||
self.placeobj.set_title(tag)
|
||||
if self.ord:
|
||||
self.ord.set_place_handle(self.placeobj.get_handle())
|
||||
elif self.object:
|
||||
self.object.set_place_handle(self.placeobj.get_handle())
|
||||
else:
|
||||
self.event.set_place_handle(self.placeobj.get_handle())
|
||||
self.db.commit_place(self.placeobj,self.trans,self.change)
|
||||
|
@ -1075,12 +1075,16 @@ class MediaObject(PrimaryObject,SourceNote):
|
||||
self.mime = source.mime
|
||||
self.desc = source.desc
|
||||
self.thumb = source.thumb
|
||||
self.date = Date.Date(source.date)
|
||||
self.place = source.place
|
||||
for attr in source.attrlist:
|
||||
self.attrlist.append(Attribute(attr))
|
||||
else:
|
||||
self.path = ""
|
||||
self.mime = ""
|
||||
self.desc = ""
|
||||
self.date = None
|
||||
self.place = u""
|
||||
self.thumb = None
|
||||
|
||||
def serialize(self):
|
||||
@ -1097,7 +1101,7 @@ class MediaObject(PrimaryObject,SourceNote):
|
||||
"""
|
||||
return (self.handle, self.gramps_id, self.path, self.mime,
|
||||
self.desc, self.attrlist, self.source_list, self.note,
|
||||
self.change)
|
||||
self.change, self.date, self.place)
|
||||
|
||||
def unserialize(self,data):
|
||||
"""
|
||||
@ -1105,8 +1109,37 @@ class MediaObject(PrimaryObject,SourceNote):
|
||||
back into the data in an Event structure.
|
||||
"""
|
||||
(self.handle, self.gramps_id, self.path, self.mime, self.desc,
|
||||
self.attrlist, self.source_list, self.note, self.change) = data
|
||||
self.attrlist, self.source_list, self.note, self.change,
|
||||
self.date, self.place) = data
|
||||
|
||||
def set_place_handle(self,place):
|
||||
"""sets the Place instance of the Event"""
|
||||
self.place = place
|
||||
|
||||
def get_place_handle(self):
|
||||
"""returns the Place instance of the Event"""
|
||||
return self.place
|
||||
|
||||
def get_date(self) :
|
||||
"""returns a string representation of the date of the Event instance"""
|
||||
if self.date:
|
||||
return display.display(self.date)
|
||||
return u""
|
||||
|
||||
def get_date_object(self):
|
||||
"""returns the Date object associated with the Event"""
|
||||
if not self.date:
|
||||
self.date = Date.Date()
|
||||
return self.date
|
||||
|
||||
def set_date(self, date) :
|
||||
"""attempts to sets the date of the Event instance"""
|
||||
self.date = parser.parse(date)
|
||||
|
||||
def set_date_object(self,date):
|
||||
"""sets the Date object associated with the Event"""
|
||||
self.date = date
|
||||
|
||||
def set_mime_type(self,type):
|
||||
self.mime = type
|
||||
|
||||
@ -1548,10 +1581,12 @@ class MediaRef(SourceNote):
|
||||
self.note = Note(source.note)
|
||||
for attr in source.attrlist:
|
||||
self.attrlist.append(Attribute(attr))
|
||||
self.rect = source.rect
|
||||
else:
|
||||
self.private = 0
|
||||
self.ref = None
|
||||
self.note = None
|
||||
self.rect = None
|
||||
|
||||
def set_privacy(self,val):
|
||||
"""Sets or clears the privacy flag of the data"""
|
||||
@ -1561,6 +1596,14 @@ class MediaRef(SourceNote):
|
||||
"""Returns the privacy level of the data"""
|
||||
return self.private
|
||||
|
||||
def set_rectangle(self,coord):
|
||||
"""Sets subection of an image"""
|
||||
self.rect = coord
|
||||
|
||||
def get_rectangle(self):
|
||||
"""Returns the subsection of an image"""
|
||||
return self.rect
|
||||
|
||||
def set_reference_handle(self,obj_id):
|
||||
self.ref = obj_id
|
||||
|
||||
|
@ -72,7 +72,7 @@ class SelectObject:
|
||||
self.top = self.glade.get_widget('select_object')
|
||||
title_label = self.glade.get_widget('object_title')
|
||||
self.object_tree = self.glade.get_widget('object_tree')
|
||||
self.object_handle = self.glade.get_widget('object_handle')
|
||||
self.object_handle = self.glade.get_widget('object_id')
|
||||
self.object_type = self.glade.get_widget('object_type')
|
||||
self.object_desc = self.glade.get_widget('object_desc')
|
||||
self.object_path = self.glade.get_widget('object_path')
|
||||
@ -126,7 +126,7 @@ class SelectObject:
|
||||
if not pexists:
|
||||
fexists = 0
|
||||
|
||||
self.object_handle.set_text(obj.get_handle())
|
||||
self.object_handle.set_text(obj.get_gramps_id())
|
||||
self.object_type.set_text(the_type)
|
||||
self.object_desc.set_text(obj.get_description())
|
||||
if len(path) == 0 or fexists == 0:
|
||||
|
@ -832,14 +832,21 @@ class XmlWriter:
|
||||
self.g.write(' description="%s"' % self.fix(obj.get_description()))
|
||||
alist = obj.get_attribute_list()
|
||||
note = obj.get_note()
|
||||
phandle = obj.get_place_handle()
|
||||
dval = obj.get_date_object()
|
||||
slist = obj.get_source_references()
|
||||
if len(alist) == 0 and len(slist) == 0 and note == "":
|
||||
if len(alist) == 0 and len(slist) == 0 and note == "" and \
|
||||
phandle == "" and not dval.is_empty():
|
||||
self.g.write('/>\n')
|
||||
else:
|
||||
self.g.write('>\n')
|
||||
self.write_attribute_list(alist)
|
||||
if note != "":
|
||||
self.write_note("note",obj.get_note_object(),3)
|
||||
if phandle:
|
||||
self.g.write(' <place ref="%s"/>\n' % phandle)
|
||||
if not dval.is_empty():
|
||||
self.write_date(dval,3)
|
||||
for s in slist:
|
||||
self.dump_source_ref(s,3)
|
||||
self.g.write(" </object>\n")
|
||||
|
@ -23559,11 +23559,14 @@ Other</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox4">
|
||||
<widget class="GtkTable" id="table49">
|
||||
<property name="border_width">12</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">3</property>
|
||||
<property name="n_columns">3</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
<property name="row_spacing">6</property>
|
||||
<property name="column_spacing">6</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label148">
|
||||
@ -23571,19 +23574,22 @@ Other</property>
|
||||
<property name="label" translatable="yes">_Title:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_CENTER</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">5</property>
|
||||
<property name="ypad">5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="mnemonic_widget">description</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="bottom_attach">1</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
@ -23600,9 +23606,141 @@ Other</property>
|
||||
<property name="activates_default">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="bottom_attach">1</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label422">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Date:</property>
|
||||
<property name="use_underline">True</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</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label423">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Place:</property>
|
||||
<property name="use_underline">True</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</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="mnemonic_widget">place</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="place">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char" translatable="yes">*</property>
|
||||
<property name="activates_default">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox99">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="date">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char" translatable="yes">*</property>
|
||||
<property name="activates_default">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="date_edit">
|
||||
<property name="visible">True</property>
|
||||
<property name="tooltip" translatable="yes">Invoke date editor</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">GTK_RELIEF_NONE</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image2264">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options">fill</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
|
Loading…
Reference in New Issue
Block a user