Dynamic Report and Tool menus

svn: r325
This commit is contained in:
Don Allingham 2001-08-11 21:43:34 +00:00
parent 43c22b8f3f
commit 0b5eaf9f8b
3 changed files with 121 additions and 3 deletions

View File

@ -276,6 +276,20 @@
</widget> </widget>
</widget> </widget>
<widget>
<class>GtkMenuItem</class>
<name>reports_menu</name>
<label>_Reports</label>
<right_justify>False</right_justify>
</widget>
<widget>
<class>GtkMenuItem</class>
<name>tools_menu</name>
<label>_Tools</label>
<right_justify>False</right_justify>
</widget>
<widget> <widget>
<class>GtkMenuItem</class> <class>GtkMenuItem</class>
<name>settings1</name> <name>settings1</name>

View File

@ -2492,6 +2492,106 @@ def bookmark_callback(obj,person):
def on_preferences_activate(obj): def on_preferences_activate(obj):
Config.display_preferences_box() Config.display_preferences_box()
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def build_report_menu(report_item):
report_menu = GtkMenu()
report_menu.show()
report_item.set_submenu(report_menu)
hash = {}
for report in Plugins.reports:
if report.__dict__.has_key("get_name"):
doc = report.get_name()
else:
doc = report.__doc__
info = string.split(doc,"/")
if hash.has_key(info[0]):
hash[info[0]].append((info[1],report.report))
else:
hash[info[0]] = [(info[1],report.report)]
catlist = hash.keys()
catlist.sort()
for key in catlist:
entry = GtkMenuItem(key)
entry.show()
report_menu.append(entry)
submenu = GtkMenu()
submenu.show()
entry.set_submenu(submenu)
list = hash[key]
list.sort()
for name in list:
subentry = GtkMenuItem(name[0])
subentry.show()
subentry.connect("activate",menu_report,name[1])
submenu.append(subentry)
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def menu_report(obj,task):
if active_person:
task(database,active_person)
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def build_tools_menu(report_item):
report_menu = GtkMenu()
report_menu.show()
report_item.set_submenu(report_menu)
hash = {}
for report in Plugins.tools:
if report.__dict__.has_key("get_name"):
doc = report.get_name()
else:
doc = report.__doc__
info = string.split(doc,"/")
if hash.has_key(info[0]):
hash[info[0]].append((info[1],report.runTool))
else:
hash[info[0]] = [(info[1],report.runTool)]
catlist = hash.keys()
catlist.sort()
for key in catlist:
entry = GtkMenuItem(key)
entry.show()
report_menu.append(entry)
submenu = GtkMenu()
submenu.show()
entry.set_submenu(submenu)
list = hash[key]
list.sort()
for name in list:
subentry = GtkMenuItem(name[0])
subentry.show()
subentry.connect("activate",menu_tools,name[1])
submenu.append(subentry)
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def menu_tools(obj,task):
if active_person:
task(database,active_person,update_display)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Main program # Main program
@ -2518,6 +2618,9 @@ def main(arg):
gtop = libglade.GladeXML(const.gladeFile, "gramps") gtop = libglade.GladeXML(const.gladeFile, "gramps")
build_report_menu(gtop.get_widget("reports_menu"))
build_tools_menu(gtop.get_widget("tools_menu"))
statusbar = gtop.get_widget("statusbar") statusbar = gtop.get_widget("statusbar")
topWindow = gtop.get_widget("gramps") topWindow = gtop.get_widget("gramps")
person_list = gtop.get_widget("person_list") person_list = gtop.get_widget("person_list")

View File

@ -18,7 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
"Database Processing/Check database integrity" "Database Processing/Check and repair database"
import RelLib import RelLib
import utils import utils
@ -86,6 +86,7 @@ class CheckIntegrity:
break break
else: else:
family.removeChild(child) family.removeChild(child)
utils.modified()
self.broken_links.append((child,family)) self.broken_links.append((child,family))
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -233,7 +234,7 @@ class CheckIntegrity:
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def get_description(): def get_description():
return _("Checks the database for any relationship errors") return _("Checks the database for integrity problems, fixing the problems that it can")
def get_name(): def get_name():
return _("Database Processing/Check database integrity") return _("Database Processing/Check and repair database")