From 3c737466656ce633660de5946c732722b4148b42 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Tue, 19 Dec 2006 02:29:47 +0000 Subject: [PATCH] * src/DataViews/_EventView.py: disable items with readonly db (bug #771) * src/DataViews/_PersonView.py: disable items with readonly db (bug #771) * src/DataViews/_RelationView.py: disable items with readonly db (bug #771) * src/ViewManager.py: disable items with readonly db (bug #771) * src/PageView.py: disable items with readonly db (bug #771) svn: r7816 --- gramps2/ChangeLog | 6 ++- gramps2/src/DataViews/_EventView.py | 3 -- gramps2/src/DataViews/_PersonView.py | 57 +++++++++++++++----------- gramps2/src/DataViews/_RelationView.py | 4 ++ gramps2/src/PageView.py | 31 ++++++++++---- gramps2/src/ViewManager.py | 31 +++++++++----- 6 files changed, 86 insertions(+), 46 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 952759c89..59dc38106 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,5 +1,9 @@ 2006-12-18 Don Allingham - + * src/DataViews/_EventView.py: disable items with readonly db (bug #771) + * src/DataViews/_PersonView.py: disable items with readonly db (bug #771) + * src/DataViews/_RelationView.py: disable items with readonly db (bug #771) + * src/ViewManager.py: disable items with readonly db (bug #771) + * src/PageView.py: disable items with readonly db (bug #771) * src/plugins/Desbrowser.py (DesBrowse.button_press_event): fix typo (from bmcage) diff --git a/gramps2/src/DataViews/_EventView.py b/gramps2/src/DataViews/_EventView.py index 10d0c6dab..27c686089 100644 --- a/gramps2/src/DataViews/_EventView.py +++ b/gramps2/src/DataViews/_EventView.py @@ -136,9 +136,6 @@ class EventView(PageView.ListView): def define_actions(self): PageView.ListView.define_actions(self) - self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES, - _('_Column Editor'), callback=self.column_editor) - self.add_action('FilterEdit', None, _('Event Filter Editor'), callback=self.filter_editor,) diff --git a/gramps2/src/DataViews/_PersonView.py b/gramps2/src/DataViews/_PersonView.py index 3f1171df0..3de61a977 100644 --- a/gramps2/src/DataViews/_PersonView.py +++ b/gramps2/src/DataViews/_PersonView.py @@ -75,8 +75,6 @@ column_names = [ _('Spouse'), _('Last Change'), ] - - class PersonView(PageView.PersonNavView): @@ -99,7 +97,9 @@ class PersonView(PageView.PersonNavView): self.filter_toggle) def change_page(self): - pass + PageView.PersonNavView.change_page(self) + self.edit_action.set_visible(True) + self.edit_action.set_sensitive(not self.dbstate.db.readonly) def set_active(self): PageView.PersonNavView.set_active(self) @@ -127,28 +127,39 @@ class PersonView(PageView.PersonNavView): """ PageView.PersonNavView.define_actions(self) + + self.all_action = gtk.ActionGroup(self.title + "/PersonAll") + self.edit_action = gtk.ActionGroup(self.title + "/PersonEdit") + + self.all_action.add_actions([ + ('OpenAllNodes', None, _("Expand all nodes"), None, None, self.open_all_nodes), + ('Edit', gtk.STOCK_EDIT, _("_Edit"), None, _("Edit the selected person"), self.edit), + ('CloseAllNodes', None, _("Collapse all nodes"), None, None, self.close_all_nodes), + ('Jump', None, _("_Jump"),"j", None, self.jumpto), + ]) + + self.edit_action.add_actions([ + ('Add', gtk.STOCK_ADD, _("_Add"), None, _("Add a new person"), self.add), + ('Remove', gtk.STOCK_REMOVE, _("_Remove"), None, _("Remove the selected person"), self.remove), + ('ColumnEdit', gtk.STOCK_PROPERTIES, _('_Column Editor'), None, None, self.column_editor), + ('CmpMerge', None, _('_Compare and merge'), None, None, self.cmp_merge), + ('FastMerge', None, _('_Fast merge'), None, None, self.fast_merge), + ]) + + self.add_action_group(self.edit_action) + self.add_action_group(self.all_action) + + def enable_action_group(self, obj): + PageView.PersonNavView.enable_action_group(self, obj) + self.all_action.set_visible(True) + self.edit_action.set_visible(False) + self.edit_action.set_sensitive(not self.dbstate.db.readonly) - self.add_action('Add', gtk.STOCK_ADD, _("_Add"), - tip=_("Add a new person"), callback=self.add) - self.add_action('Edit', gtk.STOCK_EDIT, _("_Edit"), - tip=_("Edit the selected person"), callback=self.edit) - self.add_action('Remove', gtk.STOCK_REMOVE, _("_Remove"), - tip=_("Remove the selected person"), - callback=self.remove) - self.add_action('OpenAllNodes', None, _("Expand all nodes"), - callback=self.open_all_nodes) - self.add_action('CloseAllNodes', None, _("Collapse all nodes"), - callback=self.close_all_nodes) - self.add_action('Jump', None, _("_Jump"), - accel="j",callback=self.jumpto) + def disable_action_group(self, obj): + PageView.PersonNavView.disable_action_group(self, obj) - self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES, - _('_Column Editor'), callback=self.column_editor,) - - self.add_action('CmpMerge', None, _('_Compare and merge'), - callback=self.cmp_merge) - self.add_action('FastMerge', None, _('_Fast merge'), - callback=self.fast_merge) + self.all_action.set_visible(False) + self.edit_action.set_visible(False) def cmp_merge(self, obj): mlist = self.get_selected_objects() diff --git a/gramps2/src/DataViews/_RelationView.py b/gramps2/src/DataViews/_RelationView.py index a1d686e31..d05e48228 100644 --- a/gramps2/src/DataViews/_RelationView.py +++ b/gramps2/src/DataViews/_RelationView.py @@ -324,6 +324,10 @@ class RelationshipView(PageView.PersonNavView): self.order_action.set_sensitive(self.reorder_sensitive) + def change_page(self): + self.family_action.set_sensitive(not self.dbstate.db.readonly) + self.order_action.set_sensitive(not self.dbstate.db.readonly) + def siblings_toggle(self, obj): self.show_siblings = obj.get_active() self.change_person(self.dbstate.active.handle) diff --git a/gramps2/src/PageView.py b/gramps2/src/PageView.py index 9082e6e69..d2a8377be 100644 --- a/gramps2/src/PageView.py +++ b/gramps2/src/PageView.py @@ -293,13 +293,17 @@ class PersonNavView(BookMarkView): self.add_action('HomePerson', gtk.STOCK_HOME, _("_Home"), tip=_("Go to the default person"), callback=self.home) - self.add_action('SetActive', gtk.STOCK_HOME, _("Set _Home Person"), - callback=self.set_default_person) - self.add_action('FilterEdit', None, _('Person Filter Editor'), - callback=self.filter_editor,) + self.add_action('FilterEdit', None, _('Person Filter Editor'), + callback=self.filter_editor) + + self.other_action = gtk.ActionGroup(self.title + '/PersonOther') + self.other_action.add_actions([ + ('SetActive', gtk.STOCK_HOME, _("Set _Home Person"), None, None, self.set_default_person), + ]) self.add_action_group(self.back_action) self.add_action_group(self.fwd_action) + self.add_action_group(self.other_action) def disable_action_group(self): """ @@ -431,6 +435,7 @@ class PersonNavView(BookMarkView): hobj = self.uistate.phistory self.fwd_action.set_sensitive(not hobj.at_end()) self.back_action.set_sensitive(not hobj.at_front()) + self.other_action.set_sensitive(not self.dbstate.db.readonly) #---------------------------------------------------------------- # @@ -745,16 +750,24 @@ class ListView(BookMarkView): BookMarkView.define_actions(self) - self.add_action('Add', gtk.STOCK_ADD, _("_Add"), tip=self.ADD_MSG, - callback=self.add) + self.edit_action = gtk.ActionGroup(self.title + '/ChangeOrder') + self.edit_action.add_actions([ + ('Add', gtk.STOCK_ADD, _("_Add"), None, self.ADD_MSG, self.add), + ('Remove', gtk.STOCK_REMOVE, _("_Remove"), None, self.DEL_MSG, self.remove), + ('ColumnEdit', gtk.STOCK_PROPERTIES, _('_Column Editor'), None, None, self.column_editor), + ]) + + self.add_action_group(self.edit_action) + self.add_action('Edit', gtk.STOCK_EDIT,_("_Edit"), tip=self.EDIT_MSG, callback=self.edit) - self.add_action('Remove',gtk.STOCK_REMOVE,_("_Remove"), - tip=self.DEL_MSG, callback=self.remove) self.add_toggle_action('Filter', None, _('_Filter'), callback=self.filter_toggle) + def column_editor(self,obj): + pass + def button_press(self,obj,event): if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: self.edit(obj) @@ -776,4 +789,6 @@ class ListView(BookMarkView): def double_click(self,obj,event): return False + def change_page(self): + self.edit_action.set_sensitive(not self.dbstate.db.readonly) diff --git a/gramps2/src/ViewManager.py b/gramps2/src/ViewManager.py index 7c3d0bb34..4ed2d9222 100644 --- a/gramps2/src/ViewManager.py +++ b/gramps2/src/ViewManager.py @@ -341,27 +341,17 @@ class ViewManager: self.tip_of_day_activate), ] - self._action_action_list = [ + self._readonly_action_list = [ ('SaveAs', gtk.STOCK_SAVE_AS, _('_Save As'),"s", None, self.save_as_activate), ('Export', 'gramps-export', _('_Export'), "e", None, self.export_data), ('Abandon', gtk.STOCK_REVERT_TO_SAVED, _('_Abandon changes and quit'), None, None, self.abort), - ('ScratchPad', gtk.STOCK_PASTE, _('_ScratchPad'), "", - _("Open the ScratchPad dialog"), self.scratchpad), - ('Import', gtk.STOCK_CONVERT, _('_Import'), "i", None, - self.import_data), ('Reports', 'gramps-reports', _('_Reports'), None, _("Open the reports dialog"), self.reports_clicked), - ('Tools', 'gramps-tools', _('_Tools'), None, - _("Open the tools dialog"), self.tools_clicked), - ('EditMenu', None, _('_Edit')), - ('ColumnEdit', gtk.STOCK_PROPERTIES, _('_Column Editor')), ('GoMenu', None, _('_Go')), - ('BookMenu', None, _('_Bookmarks')), ('ReportsMenu', None, _('_Reports')), - ('ToolsMenu', None, _('_Tools')), ('WindowsMenu', None, _('_Windows')), ('F2', None, 'F2', "F2", None, self.keypress), ('F3', None, 'F3', "F3", None, self.keypress), @@ -375,6 +365,19 @@ class ViewManager: ('F12', None, 'F12', "F12", None, self.keypress), ] + self._action_action_list = [ + ('ScratchPad', gtk.STOCK_PASTE, _('_ScratchPad'), "", + _("Open the ScratchPad dialog"), self.scratchpad), + ('Import', gtk.STOCK_CONVERT, _('_Import'), "i", None, + self.import_data), + ('Tools', 'gramps-tools', _('_Tools'), None, + _("Open the tools dialog"), self.tools_clicked), + ('EditMenu', None, _('_Edit')), + ('ColumnEdit', gtk.STOCK_PROPERTIES, _('_Column Editor')), + ('BookMenu', None, _('_Bookmarks')), + ('ToolsMenu', None, _('_Tools')), + ] + self._file_toggle_action_list = [ ('Sidebar', None, _('_Sidebar'), None, None, self.sidebar_toggle, self.show_sidebar ), @@ -417,6 +420,7 @@ class ViewManager: self.create_pages() if not self.file_loaded: self.actiongroup.set_visible(False) + self.readonlygroup.set_visible(False) self.fileactions.set_sensitive(False) self.build_tools_menu() self.build_report_menu() @@ -525,6 +529,7 @@ class ViewManager: self.window.add_accel_group(accelgroup) self.actiongroup = gtk.ActionGroup('MainWindow') + self.readonlygroup = gtk.ActionGroup('AllMainWindow') self.fileactions = gtk.ActionGroup('FileWindow') self.undoactions = gtk.ActionGroup('Undo') self.redoactions = gtk.ActionGroup('Redo') @@ -532,6 +537,7 @@ class ViewManager: self.fileactions.add_actions(self._file_action_list) self.actiongroup.add_actions(self._action_action_list) + self.readonlygroup.add_actions(self._readonly_action_list) self.fileactions.add_toggle_actions(self._file_toggle_action_list) self.undoactions.add_actions(self._undo_action_list) @@ -546,6 +552,7 @@ class ViewManager: self.uimanager.insert_action_group(self.fileactions, 1) self.uimanager.insert_action_group(self.actiongroup, 1) + self.uimanager.insert_action_group(self.readonlygroup, 1) self.uimanager.insert_action_group(self.undoactions, 1) self.uimanager.insert_action_group(self.redoactions, 1) self.uimanager.insert_action_group(self.undohistoryactions, 1) @@ -863,9 +870,11 @@ class ViewManager: if self.state.db.readonly: msg = "%s (%s) - GRAMPS" % (name, _('Read Only')) self.uistate.window.set_title(msg) + self.actiongroup.set_sensitive(False) else: msg = "%s - GRAMPS" % name self.uistate.window.set_title(msg) + self.actiongroup.set_sensitive(True) res = self.state.db.get_researcher() owner = GrampsCfg.get_researcher()