More general code clean up
svn: r478
This commit is contained in:
@@ -155,7 +155,7 @@ class EditPerson:
|
|||||||
self.window.editable_enters(self.ddate);
|
self.window.editable_enters(self.ddate);
|
||||||
self.window.editable_enters(self.dplace);
|
self.window.editable_enters(self.dplace);
|
||||||
|
|
||||||
self.top.signal_autoconnect({
|
id = self.top.signal_autoconnect({
|
||||||
"destroy_passed_object" : self.on_cancel_edit,
|
"destroy_passed_object" : self.on_cancel_edit,
|
||||||
"on_add_address_clicked" : self.on_add_addr_clicked,
|
"on_add_address_clicked" : self.on_add_addr_clicked,
|
||||||
"on_add_aka_clicked" : self.on_add_aka_clicked,
|
"on_add_aka_clicked" : self.on_add_aka_clicked,
|
||||||
@@ -260,6 +260,7 @@ class EditPerson:
|
|||||||
self.redraw_addr_list()
|
self.redraw_addr_list()
|
||||||
self.redraw_name_list()
|
self.redraw_name_list()
|
||||||
self.redraw_url_list()
|
self.redraw_url_list()
|
||||||
|
self.window.show()
|
||||||
|
|
||||||
def get_widget(self,str):
|
def get_widget(self,str):
|
||||||
"""returns the widget related to the passed string"""
|
"""returns the widget related to the passed string"""
|
||||||
@@ -370,17 +371,24 @@ class EditPerson:
|
|||||||
gnome.url.show(text)
|
gnome.url.show(text)
|
||||||
|
|
||||||
def on_cancel_edit(self,obj):
|
def on_cancel_edit(self,obj):
|
||||||
global quit
|
|
||||||
|
|
||||||
if self.did_data_change():
|
if self.did_data_change():
|
||||||
q = _("Data was modified. Are you sure you want to abandon your changes?")
|
q = _("Are you sure you want to abandon your changes?")
|
||||||
quit = obj
|
GnomeQuestionDialog(q,self.cancel_callback)
|
||||||
GnomeQuestionDialog(q,cancel_callback)
|
|
||||||
else:
|
else:
|
||||||
utils.destroy_passed_object(obj)
|
utils.destroy_passed_object(obj)
|
||||||
|
|
||||||
def on_delete_event(self,obj,b):
|
def on_delete_event(self,obj,b):
|
||||||
self.on_cancel_edit(obj)
|
if self.did_data_change():
|
||||||
|
q = _("Are you sure you want to abandon your changes?")
|
||||||
|
GnomeQuestionDialog(q,self.cancel_callback)
|
||||||
|
return TRUE
|
||||||
|
else:
|
||||||
|
utils.destroy_passed_object(obj)
|
||||||
|
return FALSE
|
||||||
|
|
||||||
|
def cancel_callback(self,a):
|
||||||
|
if a==0:
|
||||||
|
utils.destroy_passed_object(self.window)
|
||||||
|
|
||||||
def did_data_change(self):
|
def did_data_change(self):
|
||||||
|
|
||||||
@@ -695,6 +703,7 @@ class EditPerson:
|
|||||||
|
|
||||||
self.update_lists()
|
self.update_lists()
|
||||||
self.callback(self)
|
self.callback(self)
|
||||||
|
self.window.hide()
|
||||||
utils.destroy_passed_object(obj)
|
utils.destroy_passed_object(obj)
|
||||||
|
|
||||||
def on_primary_name_source_clicked(self,obj):
|
def on_primary_name_source_clicked(self,obj):
|
||||||
@@ -794,19 +803,9 @@ def disp_event(event):
|
|||||||
return [const.display_pevent(event.getName()),
|
return [const.display_pevent(event.getName()),
|
||||||
event.getQuoteDate(),event.getPlaceName(),attr]
|
event.getQuoteDate(),event.getPlaceName(),attr]
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
def cancel_callback(a):
|
|
||||||
if a==0:
|
|
||||||
utils.destroy_passed_object(quit)
|
|
||||||
|
|
||||||
def src_changed(parent):
|
def src_changed(parent):
|
||||||
parent.lists_changed = 1
|
parent.lists_changed = 1
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# birth_dates_in_order
|
# birth_dates_in_order
|
||||||
|
|||||||
@@ -129,14 +129,7 @@ class ImageSelect:
|
|||||||
self.savephoto(mobj)
|
self.savephoto(mobj)
|
||||||
|
|
||||||
if type[0:5] == "image":
|
if type[0:5] == "image":
|
||||||
if self.external.get_active() == 1:
|
if self.external.get_active() == 0:
|
||||||
if os.path.isfile(filename):
|
|
||||||
name = filename
|
|
||||||
thumb = "%s/.thumb/%s.jpg" % (self.path,mobj.getId())
|
|
||||||
RelImage.mk_thumb(filename,thumb,const.thumbScale)
|
|
||||||
else:
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
name = RelImage.import_media_object(filename,self.path,mobj.getId())
|
name = RelImage.import_media_object(filename,self.path,mobj.getId())
|
||||||
else:
|
else:
|
||||||
if self.external.get_active() == 1:
|
if self.external.get_active() == 1:
|
||||||
@@ -217,11 +210,7 @@ class Gallery(ImageSelect):
|
|||||||
def add_thumbnail(self, photo):
|
def add_thumbnail(self, photo):
|
||||||
object = photo.getReference()
|
object = photo.getReference()
|
||||||
path = object.getPath()
|
path = object.getPath()
|
||||||
if object.getMimeType()[0:5] == "image":
|
thumb = utils.thumb_path(self.db.getSavePath(),object)
|
||||||
thumb = "%s/.thumb/%s.jpg" % (self.path,object.getId())
|
|
||||||
RelImage.check_thumb(path,thumb,const.thumbScale)
|
|
||||||
else:
|
|
||||||
thumb = utils.find_icon(object.getMimeType())
|
|
||||||
self.icon_list.append(thumb,object.getDescription())
|
self.icon_list.append(thumb,object.getDescription())
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@@ -401,12 +390,7 @@ class LocalMediaProperties:
|
|||||||
|
|
||||||
descr_window.set_text(self.object.getDescription())
|
descr_window.set_text(self.object.getDescription())
|
||||||
mtype = self.object.getMimeType()
|
mtype = self.object.getMimeType()
|
||||||
if mtype[0:5] == "image":
|
pixmap.load_file(utils.thumb_path(path,self.object))
|
||||||
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("private").set_active(photo.getPrivacy())
|
self.change_dialog.get_widget("private").set_active(photo.getPrivacy())
|
||||||
self.change_dialog.get_widget("gid").set_text(self.object.getId())
|
self.change_dialog.get_widget("gid").set_text(self.object.getId())
|
||||||
@@ -489,12 +473,7 @@ class GlobalMediaProperties:
|
|||||||
|
|
||||||
descr_window.set_text(self.object.getDescription())
|
descr_window.set_text(self.object.getDescription())
|
||||||
mtype = self.object.getMimeType()
|
mtype = self.object.getMimeType()
|
||||||
if mtype[0:5] == "image":
|
pixmap.load_file(utils.thumb_path(path,self.object))
|
||||||
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())
|
self.change_dialog.get_widget("gid").set_text(self.object.getId())
|
||||||
|
|
||||||
|
|||||||
@@ -178,9 +178,9 @@ class RcsVersionControl(VersionControl):
|
|||||||
ofile.close()
|
ofile.close()
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
os.link("%s/%s" %(self.wd,name),self.tfile)
|
os.link(name,self.tfile)
|
||||||
except OSError:
|
except OSError:
|
||||||
shutil.copyfile("%s/%s" %(self.wd,name),self.tfile)
|
shutil.copyfile(name,self.tfile)
|
||||||
|
|
||||||
proc = popen2.Popen3("ci -u %s" % self.tfile,1)
|
proc = popen2.Popen3("ci -u %s" % self.tfile,1)
|
||||||
proc.tochild.write(comment)
|
proc.tochild.write(comment)
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ def sortById(first,second):
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def fix(line):
|
def fix(line):
|
||||||
l = string.stripline(line)
|
l = string.strip(line)
|
||||||
l = string.replace(l,'&','&')
|
l = string.replace(l,'&','&')
|
||||||
l = string.replace(l,'>','>')
|
l = string.replace(l,'>','>')
|
||||||
l = string.replace(l,'<','<')
|
l = string.replace(l,'<','<')
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ useExceptions= 0
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
picWidth = 275.0
|
picWidth = 275.0
|
||||||
thumbScale = 100.0
|
thumbScale = 96.0
|
||||||
indexFile = "data.gramps"
|
indexFile = "data.gramps"
|
||||||
male = _("male")
|
male = _("male")
|
||||||
female = _("female")
|
female = _("female")
|
||||||
|
|||||||
1792
src/gramps_main.py
1792
src/gramps_main.py
File diff suppressed because it is too large
Load Diff
10
src/utils.py
10
src/utils.py
@@ -24,6 +24,7 @@ from gnome.ui import *
|
|||||||
import string
|
import string
|
||||||
import os
|
import os
|
||||||
import const
|
import const
|
||||||
|
import RelImage
|
||||||
import intl
|
import intl
|
||||||
|
|
||||||
_ = intl.gettext
|
_ = intl.gettext
|
||||||
@@ -378,3 +379,12 @@ def birthday(person):
|
|||||||
return person.getBirth().getQuoteDate()
|
return person.getBirth().getQuoteDate()
|
||||||
else:
|
else:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
def thumb_path(dir,mobj):
|
||||||
|
type = mobj.getMimeType()
|
||||||
|
if type[0:5] == "image":
|
||||||
|
thumb = "%s/.thumb/%s.jpg" % (dir,mobj.getId())
|
||||||
|
RelImage.check_thumb(mobj.getPath(),thumb,const.thumbScale)
|
||||||
|
return thumb
|
||||||
|
else:
|
||||||
|
return find_icon(type)
|
||||||
|
|||||||
Reference in New Issue
Block a user