Merge changes from gramps20 made since 2.0.5
svn: r5105
This commit is contained in:
68
src/Utils.py
68
src/Utils.py
@ -481,8 +481,8 @@ def view_photo(photo):
|
||||
_icon_theme = gtk.icon_theme_get_default()
|
||||
|
||||
def find_mime_type_pixbuf(mime_type):
|
||||
icontmp = mime_type.replace('/','-')
|
||||
try:
|
||||
icontmp = mime_type.replace('/','-')
|
||||
newicon = "gnome-mime-%s" % icontmp
|
||||
try:
|
||||
return _icon_theme.load_icon(newicon,48,0)
|
||||
@ -715,7 +715,7 @@ def probably_alive(person,db,current_year=None):
|
||||
death = db.get_event_from_handle(person.death_ref.ref)
|
||||
if death.get_date_object().get_start_date() != Date.EMPTY:
|
||||
death_year = death.get_date_object().get_year()
|
||||
if death.get_date_object().get_year() < current_year:
|
||||
if death_year < current_year:
|
||||
return False
|
||||
|
||||
# Look for Cause Of Death, Burial or Cremation events.
|
||||
@ -1051,3 +1051,67 @@ def strip_context(msgid,sep='|'):
|
||||
if msgval == msgid and sep_idx != -1:
|
||||
msgval = msgid[sep_idx+1:]
|
||||
return msgval
|
||||
|
||||
class ProgressMeter:
|
||||
"""
|
||||
Progress meter class for GRAMPS.
|
||||
"""
|
||||
def __init__(self,title,header=''):
|
||||
"""
|
||||
Specify the title and the current pass header.
|
||||
"""
|
||||
self.ptop = gtk.Dialog()
|
||||
self.ptop.set_has_separator(False)
|
||||
self.ptop.set_title(title)
|
||||
self.ptop.set_border_width(12)
|
||||
self.ptop.vbox.set_spacing(10)
|
||||
lbl = gtk.Label('<span size="larger" weight="bold">%s</span>' % title)
|
||||
lbl.set_use_markup(True)
|
||||
self.lbl = gtk.Label(header)
|
||||
self.lbl.set_use_markup(True)
|
||||
self.ptop.vbox.add(lbl)
|
||||
self.ptop.vbox.add(self.lbl)
|
||||
self.ptop.vbox.set_border_width(24)
|
||||
self.pbar = gtk.ProgressBar()
|
||||
|
||||
self.ptop.set_size_request(350,125)
|
||||
self.ptop.vbox.add(self.pbar)
|
||||
self.ptop.show_all()
|
||||
if header == '':
|
||||
self.lbl.hide()
|
||||
|
||||
def set_pass(self,header,total):
|
||||
"""
|
||||
Reset for another pass. Provide a new header and define number
|
||||
of steps to be used.
|
||||
"""
|
||||
if header == '':
|
||||
self.lbl.hide()
|
||||
else:
|
||||
self.lbl.show()
|
||||
self.pbar_max = total
|
||||
self.pbar_index = 0.0
|
||||
self.lbl.set_text(header)
|
||||
self.pbar.set_fraction(0.0)
|
||||
while gtk.events_pending():
|
||||
gtk.main_iteration()
|
||||
|
||||
def step(self):
|
||||
"""Click the progress bar over to the next value. Be paranoid
|
||||
and insure that it doesn't go over 100%."""
|
||||
self.pbar_index = self.pbar_index + 1.0
|
||||
if (self.pbar_index > self.pbar_max):
|
||||
self.pbar_index = self.pbar_max
|
||||
|
||||
val = self.pbar_index/self.pbar_max
|
||||
|
||||
self.pbar.set_text("%d of %d (%.1f%%)" % (self.pbar_index,self.pbar_max,(val*100)))
|
||||
self.pbar.set_fraction(val)
|
||||
while gtk.events_pending():
|
||||
gtk.main_iteration()
|
||||
|
||||
def close(self):
|
||||
"""
|
||||
Close the progress meter
|
||||
"""
|
||||
self.ptop.destroy()
|
||||
|
Reference in New Issue
Block a user