Added editing media object properites

svn: r473
This commit is contained in:
Don Allingham 2001-10-15 00:53:55 +00:00
parent 51c9da428e
commit 9959f0592f
7 changed files with 456 additions and 326 deletions

View File

@ -85,7 +85,6 @@ class GrampsParser(handler.ContentHandler):
self.pref = None
self.use_p = 0
self.in_note = 0
self.in_old_attr = 0
self.in_stext = 0
self.in_scomments = 0
self.db = database
@ -231,10 +230,9 @@ class GrampsParser(handler.ContentHandler):
if attrs.has_key("priv"):
self.attribute.privacy = int(attrs["priv"])
if attrs.has_key('type'):
self.in_old_attr = 1
self.attribute.setType(u2l(attrs["type"]))
else:
self.in_old_attr = 0
if attrs.has_key('value'):
self.attribute.setValue(u2l(attrs["value"]))
if self.photo:
self.photo.addAttribute(self.attribute)
elif self.object:
@ -540,9 +538,6 @@ class GrampsParser(handler.ContentHandler):
#
#---------------------------------------------------------------------
def stop_attribute(self,tag):
if self.in_old_attr:
self.attribute.setValue(u2l(tag))
self.in_old_attr = 0
self.attribute = None
#---------------------------------------------------------------------
@ -857,14 +852,14 @@ class GrampsParser(handler.ContentHandler):
if self.address:
self.address.setNote(note)
elif self.attribute:
self.attribute.setNote(note)
elif self.object:
self.object.setNote(note)
elif self.objref:
self.objref.setNote(note)
elif self.photo:
self.photo.setNote(note)
elif self.attribute:
self.attribute.setNote(note)
elif self.name:
self.name.setNote(note)
elif self.source:

View File

@ -417,8 +417,6 @@ class LocalMediaProperties:
self.change_dialog.get_widget("path").set_text(fname)
self.change_dialog.get_widget("type").set_text(utils.get_mime_description(mtype))
self.change_dialog.get_widget("notes").insert_defaults(photo.getNote())
window.set_data("p",photo)
window.set_data("t",self.change_dialog)
self.change_dialog.signal_autoconnect({
"on_cancel_clicked" : utils.destroy_passed_object,
"on_ok_clicked" : self.on_ok_clicked,
@ -472,6 +470,92 @@ class LocalMediaProperties:
import AttrEdit
AttrEdit.AttributeEditor(self,None,"Media Object",[])
class GlobalMediaProperties:
def __init__(self,object,path):
self.object = object
self.alist = self.object.getAttributeList()[:]
self.lists_changed = 0
fname = self.object.getPath()
self.change_dialog = libglade.GladeXML(const.imageselFile,"change_global")
window = self.change_dialog.get_widget("change_global")
descr_window = self.change_dialog.get_widget("description")
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")
self.attr_details = self.change_dialog.get_widget("attr_details")
self.attr_list = self.change_dialog.get_widget("attr_list")
descr_window.set_text(self.object.getDescription())
mtype = self.object.getMimeType()
if mtype[0:5] == "image":
thumb = "%s/.thumb/%s" % (path,self.object.getId())
RelImage.check_thumb(fname,thumb,const.thumbScale)
pixmap.load_file(thumb)
else:
pixmap.load_file(utils.find_icon(mtype))
self.change_dialog.get_widget("gid").set_text(self.object.getId())
if self.object.getLocal():
self.change_dialog.get_widget("path").set_text("<local>")
else:
self.change_dialog.get_widget("path").set_text(fname)
self.change_dialog.get_widget("type").set_text(utils.get_mime_description(mtype))
self.change_dialog.get_widget("notes").insert_defaults(object.getNote())
self.change_dialog.signal_autoconnect({
"on_cancel_clicked" : utils.destroy_passed_object,
"on_ok_clicked" : self.on_ok_clicked,
"on_apply_clicked" : self.on_apply_clicked,
"on_attr_list_select_row" : self.on_attr_list_select_row,
"on_add_attr_clicked": self.on_add_attr_clicked,
"on_delete_attr_clicked" : self.on_delete_attr_clicked,
"on_update_attr_clicked" : self.on_update_attr_clicked,
})
self.redraw_attr_list()
def redraw_attr_list(self):
utils.redraw_list(self.alist,self.attr_list,disp_attr)
def on_apply_clicked(self, obj):
text = self.change_dialog.get_widget("notes").get_chars(0,-1)
desc = self.change_dialog.get_widget("description").get_text()
note = self.object.getNote()
if text != note or desc != self.object.getDescription():
self.object.setNote(text)
utils.modified()
if self.lists_changed:
self.object.setAttributeList(self.alist)
utils.modified()
def on_ok_clicked(self, obj):
self.on_apply_clicked(obj)
utils.destroy_passed_object(obj)
def on_attr_list_select_row(self,obj,row,b,c):
attr = obj.get_row_data(row)
self.attr_type.set_label(attr.getType())
self.attr_value.set_text(attr.getValue())
self.attr_details.set_text(utils.get_detail_text(attr))
def on_update_attr_clicked(self,obj):
import AttrEdit
if len(obj.selection) > 0:
row = obj.selection[0]
attr = obj.get_row_data(row)
AttrEdit.AttributeEditor(self,attr,"Media Object",[])
def on_delete_attr_clicked(self,obj):
if utils.delete_selected(obj,self.alist):
self.lists_changed = 1
self.redraw_attr_list()
def on_add_attr_clicked(self,obj):
import AttrEdit
AttrEdit.AttributeEditor(self,None,"Media Object",[])
#-------------------------------------------------------------------------
#
#

View File

@ -407,6 +407,9 @@ class Photo(SourceNote):
"""returns the property list associated with the image"""
return self.attrlist
def setAttributeList(self,list):
self.attrlist = list
class ObjectRef:
def __init__(self,source=None):

View File

@ -280,6 +280,7 @@ def write_attribute_list(g, list, indent=3):
if note == "" and len(slist) == 0:
g.write('/>\n')
else:
g.write('>\n')
for s in attr.getSourceRefList():
dump_source_ref(g,s,indent+1)
write_note(g,"note",attr.getNote(),4)

View File

@ -3113,6 +3113,11 @@
<name>button143</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_edit_media_clicked</handler>
<last_modification_time>Sun, 14 Oct 2001 21:50:44 GMT</last_modification_time>
</signal>
<label>Edit Media Object</label>
<relief>GTK_RELIEF_NORMAL</relief>
</widget>
@ -3120,8 +3125,14 @@
<widget>
<class>GtkButton</class>
<name>button144</name>
<sensitive>False</sensitive>
<can_default>True</can_default>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_delete_media_clicked</handler>
<last_modification_time>Sun, 14 Oct 2001 21:50:57 GMT</last_modification_time>
</signal>
<label>Delete Media Object</label>
<relief>GTK_RELIEF_NORMAL</relief>
</widget>

View File

@ -69,6 +69,7 @@ import Marriage
import Find
import VersionControl
import RelImage
import ImageSelect
#-------------------------------------------------------------------------
#
@ -3522,6 +3523,7 @@ def main(arg):
"on_edit_active_person" : load_active_person,
"on_edit_bookmarks_activate" : on_edit_bookmarks_activate,
"on_edit_father_clicked" : on_edit_father_clicked,
"on_edit_media_clicked" : on_edit_media_clicked,
"on_edit_mother_clicked" : on_edit_mother_clicked,
"on_edit_place_clicked" : on_edit_place_clicked,
"on_edit_source_clicked" : on_edit_source_clicked,
@ -3663,6 +3665,12 @@ def on_name_changed(obj):
else:
glade.get_widget("image").load_file(utils.find_icon(type))
def on_edit_media_clicked(obj):
if len(media_list.selection) <= 0:
return
object = media_list.get_row_data(media_list.selection[0])
ImageSelect.GlobalMediaProperties(object,database.getSavePath())
def on_media_list_drag_data_received(w, context, x, y, data, info, time):
if data and data.format == 8:
d = string.strip(string.replace(data.data,'\0',' '))

View File

@ -1232,7 +1232,7 @@
<title>Gramps - Change Global Medial Object Properties</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>True</modal>
<modal>False</modal>
<allow_shrink>False</allow_shrink>
<allow_grow>True</allow_grow>
<auto_shrink>False</auto_shrink>
@ -1277,7 +1277,7 @@
<signal>
<name>clicked</name>
<handler>on_ok_clicked</handler>
<object>change_description</object>
<object>change_global</object>
<last_modification_time>Thu, 19 Apr 2001 00:00:19 GMT</last_modification_time>
</signal>
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
@ -1305,7 +1305,7 @@
<signal>
<name>clicked</name>
<handler>on_cancel_clicked</handler>
<object>change_description</object>
<object>change_global</object>
<last_modification_time>Thu, 19 Apr 2001 00:00:43 GMT</last_modification_time>
</signal>
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
@ -1379,35 +1379,16 @@
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<padding>10</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>Placeholder</class>
</widget>
<widget>
<class>GnomePixmap</class>
<name>pixmap1</name>
<name>pixmap</name>
<width>100</width>
<height>100</height>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
</child>
</widget>
<widget>
<class>Placeholder</class>
</widget>
</widget>
<widget>
<class>GtkHSeparator</class>
<name>hseparator12</name>
<child>
<padding>10</padding>
<expand>False</expand>
@ -1416,13 +1397,11 @@
</widget>
<widget>
<class>GtkTable</class>
<name>table4</name>
<rows>4</rows>
<columns>4</columns>
<homogeneous>False</homogeneous>
<row_spacing>0</row_spacing>
<column_spacing>0</column_spacing>
<class>GtkFrame</class>
<name>frame5</name>
<label>General Information</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>True</expand>
@ -1430,156 +1409,13 @@
</child>
<widget>
<class>GtkLabel</class>
<name>label148</name>
<label>Description</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>5</xpad>
<ypad>5</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label149</name>
<label>:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label150</name>
<label>Path</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>5</xpad>
<ypad>5</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label151</name>
<label>:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label153</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>5</xpad>
<ypad>5</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkButton</class>
<name>button92</name>
<can_focus>True</can_focus>
<label>Make Local Copy</label>
<relief>GTK_RELIEF_NORMAL</relief>
<child>
<left_attach>3</left_attach>
<right_attach>4</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>5</xpad>
<ypad>5</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<class>GtkTable</class>
<name>table6</name>
<rows>3</rows>
<columns>4</columns>
<homogeneous>False</homogeneous>
<row_spacing>0</row_spacing>
<column_spacing>0</column_spacing>
<widget>
<class>GtkLabel</class>
@ -1633,6 +1469,110 @@
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>gid</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>2</left_attach>
<right_attach>4</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label150</name>
<label>Path</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>5</xpad>
<ypad>5</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label151</name>
<label>:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>path</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>2</left_attach>
<right_attach>4</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label156</name>
@ -1646,8 +1586,8 @@
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
@ -1672,8 +1612,8 @@
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
@ -1687,7 +1627,7 @@
<widget>
<class>GtkLabel</class>
<name>label158</name>
<name>type</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
@ -1698,10 +1638,10 @@
<child>
<left_attach>2</left_attach>
<right_attach>4</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<xpad>5</xpad>
<ypad>5</ypad>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
@ -1710,11 +1650,52 @@
<yfill>False</yfill>
</child>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GtkHSeparator</class>
<name>hseparator12</name>
<child>
<padding>10</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
<widget>
<class>GtkHBox</class>
<name>hbox4</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label159</name>
<label></label>
<name>label148</name>
<label>Description</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>5</xpad>
<ypad>5</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label149</name>
<label>:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
@ -1722,18 +1703,9 @@
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>2</left_attach>
<right_attach>4</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>5</xpad>
<ypad>5</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
@ -1746,18 +1718,73 @@
<text_max_length>0</text_max_length>
<text></text>
<child>
<left_attach>2</left_attach>
<right_attach>4</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>5</xpad>
<ypad>5</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
<padding>2</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
</widget>
<widget>
<class>GtkHBox</class>
<name>hbox5</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label172</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
<widget>
<class>GtkButton</class>
<name>button92</name>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_make_local_clicked</handler>
<last_modification_time>Mon, 15 Oct 2001 00:44:21 GMT</last_modification_time>
</signal>
<label>Make Local Copy</label>
<relief>GTK_RELIEF_NORMAL</relief>
<child>
<padding>5</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label173</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
</widget>
@ -1784,7 +1811,7 @@
<widget>
<class>GtkFrame</class>
<name>frame3</name>
<name>attr_type</name>
<border_width>5</border_width>
<label>No Attributes</label>
<label_xalign>0</label_xalign>
@ -1832,7 +1859,7 @@
<widget>
<class>GtkLabel</class>
<name>label162</name>
<name>attr_value</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
@ -1884,7 +1911,7 @@
<widget>
<class>GtkLabel</class>
<name>label164</name>
<name>attr_details</name>
<label></label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
@ -1979,7 +2006,8 @@
<widget>
<class>GtkCList</class>
<name>clist2</name>
<name>attr_list</name>
<height>100</height>
<can_focus>True</can_focus>
<signal>
<name>select_row</name>
@ -2121,7 +2149,7 @@
<widget>
<class>GtkText</class>
<name>text2</name>
<name>notes</name>
<can_focus>True</can_focus>
<editable>False</editable>
<text></text>