* src/Report.py: use filechooser for report dialog
* src/ReportUtils.py: use a single photo for image display svn: r5383
This commit is contained in:
parent
229ff2f01c
commit
aaaed40342
@ -1,3 +1,7 @@
|
||||
2005-11-09 Don Allingham <don@gramps-project.org>
|
||||
* src/Report.py: use filechooser for report dialog
|
||||
* src/ReportUtils.py: use a single photo for image display
|
||||
|
||||
2005-11-09 Alex Roitman <shura@gramps-project.org>
|
||||
* src/docgen/LPRDoc.py: Use paragraph padding correctly.
|
||||
|
||||
|
@ -40,7 +40,64 @@ from types import ClassType, InstanceType
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
from gnome.ui import FileEntry
|
||||
|
||||
|
||||
class FileEntry(gtk.HBox):
|
||||
def __init__(self,defname,title):
|
||||
gtk.HBox.__init__(self)
|
||||
|
||||
self.title = title
|
||||
self.dir = False
|
||||
self.entry = gtk.Entry()
|
||||
self.entry.set_text(defname)
|
||||
self.set_filename(defname)
|
||||
self.set_spacing(6)
|
||||
self.set_homogeneous(False)
|
||||
self.button = gtk.Button()
|
||||
im = gtk.Image()
|
||||
im.set_from_stock(gtk.STOCK_OPEN,gtk.ICON_SIZE_BUTTON)
|
||||
self.button.add(im)
|
||||
self.button.connect('clicked',self.select_file)
|
||||
self.pack_start(self.entry,True,True)
|
||||
self.pack_end(self.button,False,False)
|
||||
|
||||
def select_file(self,obj):
|
||||
f = gtk.FileChooserDialog(self.title,
|
||||
action=gtk.FILE_CHOOSER_ACTION_SAVE,
|
||||
buttons=(gtk.STOCK_CANCEL,
|
||||
gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_OPEN,
|
||||
gtk.RESPONSE_OK))
|
||||
|
||||
f.set_current_name(self.entry.get_text())
|
||||
f.set_current_folder(self.spath)
|
||||
status = f.run()
|
||||
if status == gtk.RESPONSE_OK:
|
||||
self.set_filename(f.get_filename())
|
||||
f.destroy()
|
||||
|
||||
def set_filename(self,path):
|
||||
if os.path.dirname(path):
|
||||
self.spath = os.path.dirname(path)
|
||||
self.defname = os.path.basename(path)
|
||||
|
||||
else:
|
||||
self.spath = os.getcwd()
|
||||
self.defname = path
|
||||
self.entry.set_text(self.defname)
|
||||
|
||||
def gtk_entry(self):
|
||||
return self.entry
|
||||
|
||||
def get_full_path(self,val):
|
||||
return self.entry.get_text()
|
||||
|
||||
def set_directory_entry(self,opt):
|
||||
self.dir = False
|
||||
|
||||
|
||||
|
||||
#from gnome.ui import FileEntry
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -1118,7 +1175,6 @@ class ReportDialog(BareReportDialog):
|
||||
if hid[-4:]==".xml":
|
||||
hid = hid[0:-4]
|
||||
self.target_fileentry = FileEntry(hid,_("Save As"))
|
||||
self.target_fileentry.set_modal(True)
|
||||
|
||||
if self.get_target_is_directory():
|
||||
self.target_fileentry.set_directory_entry(1)
|
||||
@ -1135,7 +1191,6 @@ class ReportDialog(BareReportDialog):
|
||||
|
||||
spath = self.get_default_directory()
|
||||
|
||||
self.target_fileentry.set_default_path(spath)
|
||||
self.target_fileentry.set_filename(spath)
|
||||
self.target_fileentry.gtk_entry().set_position(len(spath))
|
||||
|
||||
@ -1322,7 +1377,6 @@ class ReportDialog(BareReportDialog):
|
||||
self.html_table.attach(label, 1, 2, 2, 3, gtk.SHRINK|gtk.FILL)
|
||||
self.html_fileentry = FileEntry("HTML_Template",
|
||||
_("Choose File"))
|
||||
self.html_fileentry.set_modal(True)
|
||||
if template_name and not active_index:
|
||||
active_index = template_index
|
||||
user_template = template_name
|
||||
|
@ -1268,23 +1268,21 @@ def place_name(db,place_handle):
|
||||
# Functions commonly used in reports
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def insert_images(database, doc, person, w_cm=4.0, h_cm=4.0):
|
||||
def insert_image(database, doc, photo, w_cm=4.0, h_cm=4.0):
|
||||
"""
|
||||
Insert pictures of a person into the document.
|
||||
"""
|
||||
|
||||
photos = person.get_media_list()
|
||||
for photo in photos :
|
||||
object_handle = photo.get_reference_handle()
|
||||
media_object = database.get_object_from_handle(object_handle)
|
||||
mime_type = media_object.get_mime_type()
|
||||
if mime_type and mime_type.startswith("image"):
|
||||
filename = media_object.get_path()
|
||||
if os.path.exists(filename):
|
||||
doc.add_media_object(filename,"row",w_cm,h_cm)
|
||||
else:
|
||||
WarningDialog(_("Could not add photo to page"),
|
||||
"%s: %s" % (filename, _('File does not exist')))
|
||||
object_handle = photo.get_reference_handle()
|
||||
media_object = database.get_object_from_handle(object_handle)
|
||||
mime_type = media_object.get_mime_type()
|
||||
if mime_type and mime_type.startswith("image"):
|
||||
filename = media_object.get_path()
|
||||
if os.path.exists(filename):
|
||||
doc.add_media_object(filename,"right",w_cm,h_cm)
|
||||
else:
|
||||
WarningDialog(_("Could not add photo to page"),
|
||||
"%s: %s" % (filename, _('File does not exist')))
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -969,5 +969,6 @@ PluginMgr.register_report(
|
||||
status = _("Beta"),
|
||||
description= _("Produces a detailed ancestral report."),
|
||||
author_name="Tim Waugh",
|
||||
author_email="twaugh@redhat.com"
|
||||
author_email="twaugh@redhat.com",
|
||||
unsupported=True
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user