* src/ReportBase/_ReportDialog.py (report): Use new report modules

for oddball reports.
	* src/plugins/GraphViz.py: Use new report modules.
	* src/plugins/NarrativeWeb.py: Use new report modules.
	* src/plugins/CountAncestors.py: Use wm and new report modules.
	* src/plugins/Summary.py: Use wm and new report modules.


svn: r6842
This commit is contained in:
Alex Roitman 2006-06-02 00:40:54 +00:00
parent 51f42ca315
commit c1c7e1359a
6 changed files with 68 additions and 50 deletions

View File

@ -1,4 +1,10 @@
2006-06-01 Alex Roitman <shura@gramps-project.org>
* src/ReportBase/_ReportDialog.py (report): Use new report modules
for oddball reports.
* src/plugins/GraphViz.py: Use new report modules.
* src/plugins/NarrativeWeb.py: Use new report modules.
* src/plugins/CountAncestors.py: Use wm and new report modules.
* src/plugins/Summary.py: Use wm and new report modules.
* src/ReportBase/_BareReportDialog.py: import FilterComboBox.
2006-06-01 Don Allingham <don@gramps-project.org>

View File

@ -26,6 +26,8 @@
#
#-------------------------------------------------------------------------
import os
import logging
log = logging.getLogger(".")
#-------------------------------------------------------------------------
#
@ -617,15 +619,12 @@ def report(dbstate,uistate,person,report_class,options_class,
elif category == CATEGORY_DRAW:
from _DrawReportDialog import DrawReportDialog
dialog_class = DrawReportDialog
elif category == CATEGORY_BOOK:
elif category in (CATEGORY_BOOK,CATEGORY_CODE,CATEGORY_VIEW,CATEGORY_WEB):
try:
report_class(dbstate,uistate,person)
except Errors.WindowActiveError:
pass
return
elif category in (CATEGORY_VIEW,CATEGORY_CODE,CATEGORY_WEB):
report_class(dbstate.db,person)
return
else:
dialog_class = ReportDialog

View File

@ -30,8 +30,11 @@
#------------------------------------------------------------------------
import os
from gettext import gettext as _
from sets import Set
from math import pow
try:
set()
except NameError:
from sets import Set as set
#------------------------------------------------------------------------
#
@ -45,38 +48,40 @@ import gtk.glade
# GRAMPS modules
#
#------------------------------------------------------------------------
import Utils
from PluginUtils import register_report
from ReportBase import Report, CATEGORY_VIEW, MODE_GUI
from ManagedWindow import set_titles
from ReportBase import CATEGORY_VIEW, MODE_GUI
import ManagedWindow
#------------------------------------------------------------------------
#
#
#
#------------------------------------------------------------------------
class CountAncestors:
class CountAncestors(ManagedWindow.ManagedWindow):
def __init__(self,database,person):
def __init__(self,dbstate,uistate,person):
self.title = _('Ancestors of "%s"') \
% person.get_primary_name().get_name()
ManagedWindow.ManagedWindow.__init__(self,uistate,[],self.__class__)
database = dbstate.db
text = ""
glade_file = "%s/summary.glade" % os.path.dirname(__file__)
topDialog = gtk.glade.XML(glade_file,"summary","gramps")
topDialog.signal_autoconnect({
"destroy_passed_object" : Utils.destroy_passed_object,
"destroy_passed_object" : self.close,
})
thisgen = Set()
all = Set()
thisgen = set()
all = set()
allgen = 0
total_theoretical = 0
thisgen.add(person.get_handle())
title_text = _('Ancestors of "%s"') \
% person.get_primary_name().get_name()
top = topDialog.get_widget("summary")
window = topDialog.get_widget("summary")
title = topDialog.get_widget("title")
set_titles(top,title,title_text)
self.set_window(window,title,self.title)
thisgensize = 1
gen = 0
@ -89,11 +94,13 @@ class CountAncestors:
total_theoretical += theoretical
percent = ( thisgensize / theoretical ) * 100
if thisgensize == 1 :
text += _("Generation %d has 1 individual. (%3.2f%%)\n") % (gen,percent)
text += _("Generation %d has 1 individual. (%3.2f%%)\n") \
% (gen,percent)
else:
text += _("Generation %d has %d individuals. (%3.2f%%)\n") % (gen,thisgensize,percent)
text += _("Generation %d has %d individuals. (%3.2f%%)\n")\
% (gen,thisgensize,percent)
temp = thisgen
thisgen = Set()
thisgen = set()
for person_handle in temp:
person = database.get_person_from_handle(person_handle)
family_handle = person.get_main_parents_family_handle()
@ -114,11 +121,15 @@ class CountAncestors:
else:
percent = 0
text += _("Total ancestors in generations 2 to %d is %d. (%3.2f%%)\n") % (gen,allgen,percent)
text += _("Total ancestors in generations 2 to %d is %d. (%3.2f%%)\n")\
% (gen,allgen,percent)
textwindow = topDialog.get_widget("textwindow")
textwindow.get_buffer().set_text(text)
top.show()
self.show()
def build_menu_names(self,obj):
return (self.title,None)
#-------------------------------------------------------------------------
#
@ -132,6 +143,6 @@ register_report(
options_class = None,
modes = MODE_GUI,
translated_name = _("Number of ancestors"),
status = _("Beta"),
status = _("Stable"),
description= _("Counts number of ancestors of selected person")
)

View File

@ -928,22 +928,22 @@ class GraphVizOptions(ReportOptions):
#------------------------------------------------------------------------
class GraphVizDialog(ReportDialog):
def __init__(self,database,person):
self.database = database
def __init__(self,dbstate,uistate,person):
self.database = dbstate.db
self.person = person
name = "rel_graph"
translated_name = _("Relationship Graph")
self.options_class = GraphVizOptions(name)
self.category = CATEGORY_CODE
ReportDialog.__init__(self,database,person,self.options_class,
name,translated_name)
ReportDialog.__init__(self,dbstate,uistate,person,self.options_class,
name,translated_name)
response = self.window.run()
if response == gtk.RESPONSE_OK:
try:
self.make_report()
except (IOError,OSError),msg:
ErrorDialog(str(msg))
self.window.destroy()
self.close()
def make_doc_menu(self,active=None):
"""Build a one item menu of document types that are

View File

@ -2591,21 +2591,21 @@ class WebReportOptions(ReportOptions):
#------------------------------------------------------------------------
class WebReportDialog(ReportDialog):
def __init__(self,database,person):
self.database = database
def __init__(self,dbstate,uistate,person):
self.database = dbstate.db
self.person = person
name = "navwebpage"
translated_name = _("Generate Web Site")
self.options = WebReportOptions(name,database)
self.options = WebReportOptions(name,self.database)
self.category = CATEGORY_WEB
ReportDialog.__init__(self,database,person,self.options,
name,translated_name)
ReportDialog.__init__(self,dbstate,uistate,person,self.options,
name,translated_name)
self.style_name = None
response = self.window.run()
if response == gtk.RESPONSE_OK:
self.make_report()
self.window.destroy()
self.close()
def setup_style_frame(self):
"""The style frame is not used in this dialog."""
@ -2747,7 +2747,7 @@ def sort_people(db,handle_list):
def cl_report(database,name,category,options_str_dict):
clr = CommandLineReport(database,name,category,WebReportOptions,
options_str_dict)
options_str_dict)
# Exit here if show option was given
if clr.show:

View File

@ -43,12 +43,11 @@ import gtk.glade
# GRAMPS modules
#
#------------------------------------------------------------------------
import Utils
import RelLib
from PluginUtils import register_report
from ReportBase import Report, CATEGORY_VIEW, MODE_GUI
from ReportBase import CATEGORY_VIEW, MODE_GUI
import DateHandler
from ManagedWindow import set_titles
import ManagedWindow
#------------------------------------------------------------------------
#
@ -141,8 +140,12 @@ def build_report(database,person):
# Output report in a window
#
#------------------------------------------------------------------------
class SummaryReport:
def __init__(self,database,person):
class SummaryReport(ManagedWindow.ManagedWindow):
def __init__(self,dbstate,uistate,person):
self.title = _('Database summary')
ManagedWindow.ManagedWindow.__init__(self,uistate,[],self.__class__)
database = dbstate.db
text = build_report(database,person)
base = os.path.dirname(__file__)
@ -150,19 +153,18 @@ class SummaryReport:
topDialog = gtk.glade.XML(glade_file,"summary","gramps")
topDialog.signal_autoconnect({
"destroy_passed_object" : Utils.destroy_passed_object,
"destroy_passed_object" : self.close,
})
set_titles(topDialog.get_widget('summary'),
topDialog.get_widget('title'),
_('Database summary'))
top = topDialog.get_widget("summary")
window = topDialog.get_widget("summary")
self.set_window(window,topDialog.get_widget('title'),self.title)
textwindow = topDialog.get_widget("textwindow")
textwindow.get_buffer().set_text(text)
top.show()
self.show()
def build_menu_names(self,obj):
return (self.title,None)
#-------------------------------------------------------------------------
#
#