diff --git a/gramps2/src/DataViews/_PersonView.py b/gramps2/src/DataViews/_PersonView.py index 164cb69a4..38f9b4db1 100644 --- a/gramps2/src/DataViews/_PersonView.py +++ b/gramps2/src/DataViews/_PersonView.py @@ -622,9 +622,12 @@ class PersonView(PageView.PersonNavView): selected_ids = self.get_selected_objects() if not self.inactive: try: - handle = selected_ids[0] - person = self.dbstate.db.get_person_from_handle(handle) - self.dbstate.change_active_person(person) + if len(selected_ids) == 0: + self.dbstate.change_active_person(None) + else: + handle = selected_ids[0] + person = self.dbstate.db.get_person_from_handle(handle) + self.dbstate.change_active_person(person) except: pass diff --git a/gramps2/src/DisplayState.py b/gramps2/src/DisplayState.py index 0daf83fb9..13df45235 100644 --- a/gramps2/src/DisplayState.py +++ b/gramps2/src/DisplayState.py @@ -321,7 +321,7 @@ class DisplayState(GrampsDb.GrampsDBCallback): self.status.push(self.status_id,"") else: person = self.dbstate.get_active_person() - if not person: + if person: pname = NameDisplay.displayer.display(person) name = "[%s] %s" % (person.get_gramps_id(),pname) else: diff --git a/gramps2/src/PluginUtils/_PluginMgr.py b/gramps2/src/PluginUtils/_PluginMgr.py index 37dd660c8..f03906abb 100644 --- a/gramps2/src/PluginUtils/_PluginMgr.py +++ b/gramps2/src/PluginUtils/_PluginMgr.py @@ -185,7 +185,8 @@ def register_tool( description=_unavailable, author_name=_("Unknown"), author_email=_("Unknown"), - unsupported=False + unsupported=False, + require_active=True, ): """ Register a tool with the plugin system. @@ -202,7 +203,8 @@ def register_tool( if gui_task: _register_gui_tool(tool_class,options_class,translated_name, name,category,description, - status,author_name,author_email,unsupported) + status,author_name,author_email,unsupported, + require_active) (junk,cli_task) = divmod(modes-gui_task,2**_Tool.MODE_CLI) if cli_task: @@ -215,7 +217,8 @@ def _register_gui_tool(tool_class,options_class,translated_name, status=_("Unknown"), author_name=_("Unknown"), author_email=_("Unknown"), - unsupported=False): + unsupported=False, + require_active=True): del_index = -1 for i in range(0,len(tool_list)): val = tool_list[i] @@ -226,7 +229,7 @@ def _register_gui_tool(tool_class,options_class,translated_name, mod2text[tool_class.__module__] = description tool_list.append((tool_class,options_class,translated_name, category,name,description,status, - author_name,author_email,unsupported)) + author_name,author_email,unsupported, require_active)) def _register_cli_tool(name,category,tool_class,options_class, translated_name,unsupported=False): @@ -238,7 +241,7 @@ def _register_cli_tool(name,category,tool_class,options_class, if del_index != -1: del cli_tool_list[del_index] cli_tool_list.append((name,category,tool_class,options_class, - translated_name,unsupported)) + translated_name,unsupported, None)) #------------------------------------------------------------------------- # @@ -256,7 +259,8 @@ def register_report( description=_unavailable, author_name=_("Unknown"), author_email=_("Unknown"), - unsupported=False + unsupported=False, + require_active=True, ): """ Registers report for all possible flavors. @@ -269,14 +273,16 @@ def register_report( (junk,standalone_task) = divmod(modes,2**MODE_GUI) if standalone_task: _register_standalone(report_class,options_class,translated_name, - name,category,description, - status,author_name,author_email,unsupported) + name,category,description, + status,author_name,author_email,unsupported, + require_active) (junk,book_item_task) = divmod(modes-standalone_task,2**MODE_BKI) if book_item_task: book_item_category = book_categories[category] register_book_item(translated_name,book_item_category, - report_class,options_class,name,unsupported) + report_class,options_class,name,unsupported, + require_active) (junk,command_line_task) = divmod(modes-standalone_task-book_item_task, 2**MODE_CLI) @@ -284,13 +290,17 @@ def register_report( _register_cl_report(name,category,report_class,options_class, translated_name,unsupported) -def _register_standalone(report_class, options_class, translated_name, - name, category, +def _register_standalone(report_class, + options_class, + translated_name, + name, + category, description=_unavailable, status=_("Unknown"), author_name=_("Unknown"), author_email=_("Unknown"), - unsupported=False + unsupported=False, + require_active=True, ): """Register a report with the plugin system""" @@ -304,11 +314,12 @@ def _register_standalone(report_class, options_class, translated_name, report_list.append((report_class, options_class, translated_name, category, name, description, status, - author_name, author_email, unsupported)) + author_name, author_email, unsupported, + require_active)) mod2text[report_class.__module__] = description def register_book_item(translated_name, category, report_class, - option_class, name, unsupported): + option_class, name, unsupported, require_active): """Register a book item""" del_index = -1 @@ -320,10 +331,10 @@ def register_book_item(translated_name, category, report_class, del bkitems_list[del_index] bkitems_list.append((translated_name, category, report_class, - option_class, name, unsupported)) + option_class, name, unsupported, require_active)) def _register_cl_report(name,category,report_class,options_class, - translated_name,unsupported): + translated_name,unsupported, require_active): del_index = -1 for i in range(0,len(cl_list)): val = cl_list[i] @@ -332,7 +343,7 @@ def _register_cl_report(name,category,report_class,options_class, if del_index != -1: del cl_list[del_index] cl_list.append((name,category,report_class,options_class, - translated_name,unsupported)) + translated_name,unsupported, require_active)) #------------------------------------------------------------------------- # diff --git a/gramps2/src/ReportBase/_ReportDialog.py b/gramps2/src/ReportBase/_ReportDialog.py index 635132460..86599cb1d 100644 --- a/gramps2/src/ReportBase/_ReportDialog.py +++ b/gramps2/src/ReportBase/_ReportDialog.py @@ -606,13 +606,20 @@ class ReportDialog(BareReportDialog): # #------------------------------------------------------------------------ def report(dbstate,uistate,person,report_class,options_class, - trans_name,name,category): + trans_name,name,category, require_active): """ report - task starts the report. The plugin system requires that the task be in the format of task that takes a database and a person as its arguments. """ + if require_active and not person: + ErrorDialog( + _('Active person has not been set'), + _('You must select an active person for this report to work ' + 'properly.')) + return + if category == CATEGORY_TEXT: from _TextReportDialog import TextReportDialog dialog_class = TextReportDialog diff --git a/gramps2/src/ViewManager.py b/gramps2/src/ViewManager.py index 8add7a62f..254712cc8 100644 --- a/gramps2/src/ViewManager.py +++ b/gramps2/src/ViewManager.py @@ -921,10 +921,10 @@ class ViewManager: category = categories[item[3]] if hash_data.has_key(category): hash_data[category].append( - (item[0], item[1], item[2], item[4], item[3])) + (item[0], item[1], item[2], item[4], item[3], item[10])) else: hash_data[category] = [ - (item[0], item[1], item[2], item[4], item[3])] + (item[0], item[1], item[2], item[4], item[3], item[10])] # Sort categories, skipping the unsupported catlist = [item for item in hash_data.keys() @@ -967,7 +967,7 @@ def by_menu_name(a, b): def make_report_callback(lst, dbstate, uistate): return lambda x: report(dbstate, uistate, dbstate.get_active_person(), - lst[0], lst[1], lst[2], lst[3], lst[4]) + lst[0], lst[1], lst[2], lst[3], lst[4], lst[5]) def make_tool_callback(lst, dbstate, uistate): return lambda x: Tool.gui_tool(dbstate, uistate, diff --git a/gramps2/src/plugins/StatisticsChart.py b/gramps2/src/plugins/StatisticsChart.py index 6d88e36d3..17c53c2e7 100644 --- a/gramps2/src/plugins/StatisticsChart.py +++ b/gramps2/src/plugins/StatisticsChart.py @@ -981,5 +981,6 @@ register_report( status = (_("Stable")), author_name="Eero Tamminen", author_email="", - description= _("Generates statistical bar and pie charts of the people in the database.") + description= _("Generates statistical bar and pie charts of the people in the database."), + require_active=False, ) diff --git a/gramps2/src/plugins/Summary.py b/gramps2/src/plugins/Summary.py index ebfdc2979..027f12748 100644 --- a/gramps2/src/plugins/Summary.py +++ b/gramps2/src/plugins/Summary.py @@ -179,4 +179,5 @@ register_report( translated_name = _("Summary of the database"), status = _("Beta"), description= _("Provides a summary of the current database"), + require_active=False, )