Delete media objects added, revision control shows who the committer is.

svn: r503
This commit is contained in:
Don Allingham 2001-10-20 20:42:38 +00:00
parent 5870c5b1c2
commit ea59f17e89
7 changed files with 252 additions and 46 deletions

View File

@ -511,11 +511,13 @@ class LocalMediaProperties:
class GlobalMediaProperties:
def __init__(self,object,path):
def __init__(self,db,object):
self.object = object
self.alist = self.object.getAttributeList()[:]
self.lists_changed = 0
self.db = db
path = self.db.getSavePath()
fname = self.object.getPath()
self.change_dialog = libglade.GladeXML(const.imageselFile,"change_global")
window = self.change_dialog.get_widget("change_global")
@ -544,6 +546,7 @@ class GlobalMediaProperties:
"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_notebook_switch_page": self.on_notebook_switch_page,
"on_delete_attr_clicked" : self.on_delete_attr_clicked,
"on_update_attr_clicked" : self.on_update_attr_clicked,
})
@ -552,6 +555,29 @@ class GlobalMediaProperties:
def redraw_attr_list(self):
utils.redraw_list(self.alist,self.attr_list,disp_attr)
def display_refs(self):
ref = self.change_dialog.get_widget("refinfo")
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)])
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)])
for p in self.db.getSourceMap().values():
for o in p.getPhotoList():
if o.getReference() == self.object:
ref.append([_("Source"),p.getId(),p.getTitle()])
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()])
def on_notebook_switch_page(self,obj,junk,page):
if page == 3:
self.display_refs()
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()
@ -598,3 +624,65 @@ class GlobalMediaProperties:
def disp_attr(attr):
detail = utils.get_detail_flags(attr)
return [const.display_pattr(attr.getType()),attr.getValue(),detail]
class DeleteMediaQuery:
def __init__(self,media,db,update):
self.db = db
self.media = media
self.update = update
def query_response(self,ans):
if ans == 1:
return
del self.db.getObjectMap()[self.media.getId()]
utils.modified()
for p in self.db.getPersonMap().values():
nl = []
change = 0
for photo in p.getPhotoList():
if photo.getReference() != self.media:
nl.append(photo)
else:
change = 1
if change:
p.setPhotoList(nl)
for p in self.db.getFamilyMap().values():
nl = []
change = 0
for photo in p.getPhotoList():
if photo.getReference() != self.media:
nl.append(photo)
else:
change = 1
if change:
p.setPhotoList(nl)
for p in self.db.getSourceMap().values():
nl = []
change = 0
for photo in p.getPhotoList():
if photo.getReference() != self.media:
nl.append(photo)
else:
change = 1
if change:
p.setPhotoList(nl)
for p in self.db.getPlaceMap().values():
nl = []
change = 0
for photo in p.getPhotoList():
if photo.getReference() != self.media:
nl.append(photo)
else:
change = 1
if change:
p.setPhotoList(nl)
self.update(0)

View File

@ -43,13 +43,6 @@ import utils
from RelLib import *
import ImageSelect
#-------------------------------------------------------------------------
#
# Constants
#
#-------------------------------------------------------------------------
MARRIAGE = "m"
#-------------------------------------------------------------------------
#
# Marriage class
@ -130,11 +123,6 @@ class Marriage:
self.gid.set_text(family.getId())
self.gid.set_editable(Config.id_edit)
# stored object data
top_window.set_data(MARRIAGE,self)
self.event_list.set_data(MARRIAGE,self)
self.attr_list.set_data(MARRIAGE,self)
# set notes data
self.notes_field.set_point(0)
self.notes_field.insert_defaults(family.getNote())
@ -244,15 +232,7 @@ class Marriage:
def on_add_clicked(self,obj):
import EventEdit
father = self.family.getFather()
mother = self.family.getMother()
if father and mother:
name = _("%s and %s") % (father.getPrimaryName().getName(),
mother.getPrimaryName().getName())
elif father:
name = father.getPrimaryName().getName()
else:
name = mother.getPrimaryName().getName()
name = utils.family_name(self.family)
EventEdit.EventEditor(self,name,const.marriageEvents,const.save_pevent,None,None,0)
def on_update_clicked(self,obj):
@ -261,15 +241,7 @@ class Marriage:
return
event = obj.get_row_data(obj.selection[0])
father = self.family.getFather()
mother = self.family.getMother()
if father and mother:
name = _("%s and %s") % (father.getPrimaryName().getName(),
mother.getPrimaryName().getName())
elif father:
name = father.getPrimaryName().getName()
else:
name = mother.getPrimaryName().getName()
name = utils.family_name(self.family)
EventEdit.EventEditor(self,name,const.marriageEvents,const.save_pevent,event,None,0)
def on_delete_clicked(self,obj):

View File

@ -37,7 +37,7 @@ except:
_gzip_ok = 0
_revision_re = re.compile("revision\s+([\d\.]+)")
_date_re = re.compile("date:\s+([^;]+);")
_date_re = re.compile("date:\s+([^;]+);\s+author:\s([^;]+);")
_sep = '-' * 10
_end = "=" * 10
@ -77,10 +77,9 @@ class RevisionSelect:
self.revlist = dialog.get_widget("revlist")
l = self.vc.revision_list()
l.reverse()
index = 0
for f in l:
self.revlist.append([f[0],f[1],f[2]])
self.revlist.append([f[0],f[1],f[3],f[2]])
self.revlist.set_row_data(index,f[0])
index = index + 1
@ -166,7 +165,7 @@ class RcsVersionControl(VersionControl):
if slog:
if line[0:10] == _sep or line[0:10] == _end:
slog = 0
rlist.append(v,d,string.join(l,'\n'))
rlist.append((v,d,string.join(l,'\n'),o))
else:
l.append(line)
continue
@ -177,6 +176,7 @@ class RcsVersionControl(VersionControl):
g = _date_re.match(line)
if g:
d = g.group(1)
o = g.group(2)
slog = 1
l = []

View File

@ -3130,12 +3130,12 @@
<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>
<object>media_list</object>
<last_modification_time>Sun, 14 Oct 2001 21:50:57 GMT</last_modification_time>
</signal>
<label>Delete Media Object</label>
@ -7130,11 +7130,11 @@ Unknown
<widget>
<class>GtkCList</class>
<name>revlist</name>
<width>500</width>
<width>600</width>
<height>200</height>
<can_focus>True</can_focus>
<columns>3</columns>
<column_widths>77,128,80</column_widths>
<columns>4</columns>
<column_widths>53,128,69,80</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
<show_titles>True</show_titles>
<shadow_type>GTK_SHADOW_IN</shadow_type>
@ -7165,6 +7165,19 @@ Unknown
<ypad>0</ypad>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
<name>label251a</name>
<label>Changed by</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>CList:title</child_name>

View File

@ -169,8 +169,9 @@ def on_exit_activate(obj):
def save_query(value):
"""Catch the reponse to the save on exit question"""
if value == 0:
on_save_activate(None)
mainquit(gtop)
on_save_activate_quit()
else:
mainquit(gtop)
#-------------------------------------------------------------------------
#
@ -528,8 +529,6 @@ def on_delete_place_clicked(obj):
#
#
#-------------------------------------------------------------------------
def on_delete_source_clicked(obj):
import EditSource
@ -540,10 +539,10 @@ def on_delete_source_clicked(obj):
source = obj.get_row_data(index)
ans = EditSource.DelSrcQuery(source,database,update_display)
if is_source_used(source):
msg = _("This source is currently being used. Delete anyway?")
ans = EditSource.DelSrcQuery(source,database,update_display)
GnomeQuestionDialog(msg,ans.query_response)
else:
map = database.getSourceMap()
@ -1238,6 +1237,16 @@ def on_save_activate(obj):
else:
save_file(database.getSavePath(),_("No Comment Provided"))
def on_save_activate_quit():
"""Saves the file, first prompting for a comment if revision control needs it"""
if not database.getSavePath():
on_save_as_activate(obj)
else:
if Config.usevc and Config.vc_comment:
display_comment_box(database.getSavePath())
else:
save_file(database.getSavePath(),_("No Comment Provided"))
def display_comment_box(filename):
"""Displays a dialog box, prompting for a revison control comment"""
import VersionControl
@ -2083,7 +2092,42 @@ 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())
ImageSelect.GlobalMediaProperties(database,object)
def on_delete_media_clicked(obj):
if len(media_list.selection) <= 0:
return
else:
index = media_list.selection[0]
mobj = media_list.get_row_data(index)
if is_media_object_used(mobj):
import ImageSelect
ans = ImageSelect.DeleteMediaQuery(mobj,database,update_display)
msg = _("This media object is currently being used. Delete anyway?")
GnomeQuestionDialog(msg,ans.query_response)
else:
map = database.getObjectMap()
del map[mobj.getId()]
utils.modified()
update_display(0)
def is_media_object_used(mobj):
for p in database.getFamilyMap().values():
for o in p.getPhotoList():
if o.getReference() == mobj:
return 1
for p in database.getPersonMap().values():
for o in p.getPhotoList():
if o.getReference() == mobj:
return 1
for p in database.getSourceMap().values():
for o in p.getPhotoList():
if o.getReference() == mobj:
return 1
for p in database.getPlaceMap().values():
for o in p.getPhotoList():
if o.getReference() == mobj:
return 1
#-------------------------------------------------------------------------
#
@ -2574,6 +2618,7 @@ def main(arg):
"on_delete_person_clicked" : on_delete_person_clicked,
"on_delete_place_clicked" : on_delete_place_clicked,
"on_delete_source_clicked" : on_delete_source_clicked,
"on_delete_media_clicked" : on_delete_media_clicked,
"on_delete_sp_clicked" : on_delete_sp_clicked,
"on_edit_active_person" : load_active_person,
"on_edit_bookmarks_activate" : on_edit_bookmarks_activate,

View File

@ -1354,6 +1354,11 @@
<class>GtkNotebook</class>
<name>notebook2</name>
<can_focus>True</can_focus>
<signal>
<name>switch_page</name>
<handler>on_notebook_switch_page</handler>
<last_modification_time>Sat, 20 Oct 2001 16:10:32 GMT</last_modification_time>
</signal>
<show_tabs>True</show_tabs>
<show_border>True</show_border>
<tab_pos>GTK_POS_TOP</tab_pos>
@ -2168,6 +2173,78 @@
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
<widget>
<class>GtkScrolledWindow</class>
<name>scrolledwindow5</name>
<hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy>
<vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy>
<hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
<vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
<widget>
<class>GtkCList</class>
<name>refinfo</name>
<can_focus>True</can_focus>
<columns>3</columns>
<column_widths>80,80,80</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
<show_titles>True</show_titles>
<shadow_type>GTK_SHADOW_IN</shadow_type>
<widget>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
<name>label178</name>
<label>Type</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
<name>label179</name>
<label>ID</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
<name>label180</name>
<label>Title</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>Notebook:tab</child_name>
<name>label174</name>
<label>References</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
</widget>
</widget>
</widget>

View File

@ -75,6 +75,17 @@ def phonebook_name(person):
else:
return ""
def family_name(family):
father = family.getFather()
mother = family.getMother()
if father and mother:
name = _("%s and %s") % (father.getPrimaryName().getName(),mother.getPrimaryName().getName())
elif father:
name = father.getPrimaryName().getName()
else:
name = mother.getPrimaryName().getName()
return name
#-------------------------------------------------------------------------
#
# Short hand function to return either the person's name, or an empty