diff --git a/ChangeLog b/ChangeLog index 499abaf1a..c31bd204d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-12-30 Brian Matherly + * src/PluginUtils/__init__.py: + * src/PluginUtils/MenuOptions.py: + * src/ReportBase/_BareReportDialog.py: + * src/ReportBase/_ReportDialog.py: + * src/plugins/AncestorChart.py: + Proof of concept: adding a center person option instead of + using active person + 2007-12-30 Brian Matherly * src/Bookmarks: Set dialog to modal. diff --git a/src/PluginUtils/_MenuOptions.py b/src/PluginUtils/_MenuOptions.py index c5e59cc86..8f56de881 100644 --- a/src/PluginUtils/_MenuOptions.py +++ b/src/PluginUtils/_MenuOptions.py @@ -585,6 +585,63 @@ class FilterListOption(Option): """ self.__value = int(self.combo.get_active()) return self.__value + +#------------------------------------------------------------------------- +# +# PersonOption class +# +#------------------------------------------------------------------------- +class PersonOption(Option): + """ + This class describes an option that allows a person from the + database to be selected. + """ + def __init__(self, label, value, dbstate): + """ + @param label: A friendly label to be applied to this option. + Example: "Center Person" + @type label: string + @param value: A default Gramps ID of a person for this option. + Example: "p11" + @type value: string + @param dbstate: The database state for the database to be used.. + @type value: DbState + @return: nothing + """ + self.dbstate = dbstate + self.db = dbstate.get_database() + Option.__init__(self,label,value) + + def make_gui_obj(self, gtk, dialog): + self.dialog = dialog + self.gobj = gtk.HBox() + + person = self.db.get_person_from_gramps_id(self.get_value()) + if not person: + person = self.dbstate.get_active_person() + name = _nd.display(person) + gid = person.get_gramps_id() + self.person_label = gtk.Label( "%s (%s)" % (name,gid) ) + self.person_label.set_alignment(0.0,0.5) + self.change_button = gtk.Button("%s..." % _('C_hange') ) + self.change_button.connect('clicked',self.on_change_clicked) + self.gobj.pack_start(self.person_label, False) + self.gobj.pack_end(self.change_button, False) + + def parse(self): + return self.get_value() + + def on_change_clicked(self, obj): + SelectPerson = selector_factory('Person') + sel = SelectPerson(self.dbstate, self.dialog.uistate, + self.dialog.track) + person = sel.run() + if person: + name = _nd.display(person) + gid = person.get_gramps_id() + self.person_label.set_text( "%s (%s)" % (name,gid) ) + self.set_value(gid) + #------------------------------------------------------------------------- # diff --git a/src/PluginUtils/__init__.py b/src/PluginUtils/__init__.py index 34b76e16d..61ce369b9 100644 --- a/src/PluginUtils/__init__.py +++ b/src/PluginUtils/__init__.py @@ -30,7 +30,7 @@ from _MenuOptions import MenuOptions, \ NumberOption, FloatOption, BooleanOption, TextOption, \ EnumeratedListOption, FilterListOption, StringOption, ColourButtonOption, \ - PersonListOption + PersonOption, PersonListOption from _PluginMgr import \ register_export, register_import, \ register_tool, register_report, \ diff --git a/src/ReportBase/_BareReportDialog.py b/src/ReportBase/_BareReportDialog.py index ddde9f8d1..1b4c2bd62 100644 --- a/src/ReportBase/_BareReportDialog.py +++ b/src/ReportBase/_BareReportDialog.py @@ -103,7 +103,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow): return (_("Configuration"),self.report_name) def init_interface(self): - self.extra_menu = None self.widgets = [] self.frame_names = [] self.frames = {} @@ -115,6 +114,7 @@ class BareReportDialog(ManagedWindow.ManagedWindow): window = gtk.Dialog('GRAMPS') self.set_window(window,None,self.get_title()) self.window.set_has_separator(False) + self.window.set_modal(True) if self.HELP_TOPIC: self.help = self.window.add_button(gtk.STOCK_HELP, gtk.RESPONSE_HELP) @@ -145,6 +145,7 @@ class BareReportDialog(ManagedWindow.ManagedWindow): # frame and to create other frames self.add_user_options() + self.setup_main_options() self.setup_center_person() self.setup_target_frame() self.setup_format_frame() @@ -158,7 +159,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow): self.setup_other_frames() self.notebook.set_current_page(0) self.show() - #self.window.show_all() def get_title(self): """The window title for this dialog""" @@ -397,6 +397,8 @@ class BareReportDialog(ManagedWindow.ManagedWindow): def setup_other_frames(self): for key in self.frame_names: + if key == "": + continue flist = self.frames[key] table = gtk.Table(3,len(flist)) table.set_col_spacings(12) @@ -419,6 +421,22 @@ class BareReportDialog(ManagedWindow.ManagedWindow): table.attach(widget, 2, 3, row, row+1, yoptions=gtk.SHRINK) row = row + 1 + + def setup_main_options(self): + if self.frames.has_key(""): + flist = self.frames[""] + for (text,widget) in flist: + label = gtk.Label("%s" % text) + label.set_use_markup(True) + label.set_alignment(0.0,0.5) + + self.tbl.set_border_width(12) + self.tbl.attach(label,0,4,self.col,self.col+1) + self.col += 1 + + self.tbl.attach(widget,2,4,self.col,self.col+1) + self.col += 1 + #------------------------------------------------------------------------ # diff --git a/src/ReportBase/_ReportDialog.py b/src/ReportBase/_ReportDialog.py index 7c917595a..99a50a132 100644 --- a/src/ReportBase/_ReportDialog.py +++ b/src/ReportBase/_ReportDialog.py @@ -101,13 +101,7 @@ class ReportDialog(BareReportDialog): """The header line to put at the top of the contents of the dialog box. By default this will just be the name of the report for the selected person. """ - if name.strip(): - return _("%(report_name)s for %(person_name)s") % { - 'report_name' : self.report_name, - 'person_name' : name} - else: - # No need to translate report_name, it is already translated - return self.report_name + return self.report_name #------------------------------------------------------------------------ # diff --git a/src/plugins/AncestorChart.py b/src/plugins/AncestorChart.py index 8f42df833..e07db4f7b 100644 --- a/src/plugins/AncestorChart.py +++ b/src/plugins/AncestorChart.py @@ -39,7 +39,7 @@ from gettext import gettext as _ import BaseDoc from SubstKeywords import SubstKeywords from PluginUtils import register_report, \ - NumberOption, BooleanOption, TextOption + NumberOption, BooleanOption, TextOption, PersonOption from ReportBase import Report, ReportUtils, CATEGORY_DRAW, MenuReportOptions,\ MODE_GUI, MODE_BKI, MODE_CLI from BasicUtils import name_displayer @@ -186,7 +186,10 @@ class AncestorChart(Report): self.incblank = options_class.handler.options_dict['incblank'] self.compress = options_class.handler.options_dict['compress'] - name = name_displayer.display_formal(person) + pid = options_class.handler.options_dict['pid'] + center_person = database.get_person_from_gramps_id(pid) + + name = name_displayer.display_formal(center_person) self.title = _("Ancestor Graph for %s") % name self.map = {} @@ -197,7 +200,7 @@ class AncestorChart(Report): self.lines = 0 self.scale = 1 - self.apply_filter(self.start_person.get_handle(),1) + self.apply_filter(center_person.get_handle(),1) keys = self.map.keys() keys.sort() @@ -448,6 +451,14 @@ class AncestorChartOptions(MenuReportOptions): MenuReportOptions.__init__(self,name,dbstate) def add_menu_options(self,menu,dbstate): + + id = "" + if dbstate: + id = dbstate.get_active_person().get_gramps_id() + pid = PersonOption(_("Center Person"),id,dbstate) + pid.set_help(_("The center person for thereport")) + menu.add_option("","pid",pid) + category_name = _("Report Options") max_gen = NumberOption(_("Generations"),10,1,15)