From e32cc098dc4145610c5f92fe3a88e73df095c64f Mon Sep 17 00:00:00 2001 From: Martin Hawlisch Date: Fri, 15 Dec 2006 12:39:28 +0000 Subject: [PATCH] * src/Editors/_EditSourceRef.py, * src/Editors/_EditRepoRef.py, * src/Editors/_EditUrl.py, * src/Editors/_EditMediaRef.py, * src/Editors/_EditEventRef.py, * src/Editors/_EditFamily.py, * src/DisplayTabs/_NameEmbedList.py, * src/DisplayTabs/_EmbeddedList.py, * src/DisplayTabs/_GalleryTab.py, * src/DisplayTabs/_DataEmbedList.py: Disable some more controls when readonly svn: r7804 --- gramps2/ChangeLog | 13 +++++++++++++ gramps2/src/DisplayTabs/_DataEmbedList.py | 2 +- gramps2/src/DisplayTabs/_EmbeddedList.py | 21 ++++++++++++--------- gramps2/src/DisplayTabs/_GalleryTab.py | 16 +++++++++------- gramps2/src/DisplayTabs/_NameEmbedList.py | 8 ++++---- gramps2/src/Editors/_EditEventRef.py | 1 + gramps2/src/Editors/_EditFamily.py | 10 +++++----- gramps2/src/Editors/_EditMediaRef.py | 5 +++++ gramps2/src/Editors/_EditRepoRef.py | 11 ++++++----- gramps2/src/Editors/_EditSourceRef.py | 15 ++++++++------- gramps2/src/Editors/_EditUrl.py | 2 +- 11 files changed, 65 insertions(+), 39 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index ac96cf555..130bb8cce 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,16 @@ +2006-12-15 Martin Hawlisch + * src/Editors/_EditSourceRef.py, + * src/Editors/_EditRepoRef.py, + * src/Editors/_EditUrl.py, + * src/Editors/_EditMediaRef.py, + * src/Editors/_EditEventRef.py, + * src/Editors/_EditFamily.py, + * src/DisplayTabs/_NameEmbedList.py, + * src/DisplayTabs/_EmbeddedList.py, + * src/DisplayTabs/_GalleryTab.py, + * src/DisplayTabs/_DataEmbedList.py: Disable some more controls when + readonly + 2006-12-14 Alex Roitman * src/plugins/ChangeNames.py (toggled): Add method; (display): Connect renderer to the handling method. diff --git a/gramps2/src/DisplayTabs/_DataEmbedList.py b/gramps2/src/DisplayTabs/_DataEmbedList.py index e7a0f39bb..3243303e7 100644 --- a/gramps2/src/DisplayTabs/_DataEmbedList.py +++ b/gramps2/src/DisplayTabs/_DataEmbedList.py @@ -63,7 +63,7 @@ class DataEmbedList(EmbeddedList): # and connect renderers to the 'edited' signal for colno in range(len(self.columns)): for renderer in self.columns[colno].get_cell_renderers(): - renderer.set_property('editable',True) + renderer.set_property('editable',not self.dbstate.db.readonly) renderer.connect('edited',self.edit_inline,colno) def get_data(self): diff --git a/gramps2/src/DisplayTabs/_EmbeddedList.py b/gramps2/src/DisplayTabs/_EmbeddedList.py index 4ac9be545..8e26f368c 100644 --- a/gramps2/src/DisplayTabs/_EmbeddedList.py +++ b/gramps2/src/DisplayTabs/_EmbeddedList.py @@ -98,28 +98,30 @@ class EmbeddedList(ButtonTab): def get_popup_menu_items(self): if self.share_btn: itemlist = [ - (True, gtk.STOCK_ADD, self.add_button_clicked), - (False, _('Share'), self.edit_button_clicked), - (True, gtk.STOCK_EDIT, self.edit_button_clicked), - (True, gtk.STOCK_REMOVE, self.del_button_clicked), + (True, True, gtk.STOCK_ADD, self.add_button_clicked), + (True, False, _('Share'), self.edit_button_clicked), + (False,True, gtk.STOCK_EDIT, self.edit_button_clicked), + (True, True, gtk.STOCK_REMOVE, self.del_button_clicked), ] else: itemlist = [ - (True, gtk.STOCK_ADD, self.add_button_clicked), - (True, gtk.STOCK_EDIT, self.edit_button_clicked), - (True, gtk.STOCK_REMOVE, self.del_button_clicked), + (True, True, gtk.STOCK_ADD, self.add_button_clicked), + (False,True, gtk.STOCK_EDIT, self.edit_button_clicked), + (True, True, gtk.STOCK_REMOVE, self.del_button_clicked), ] return itemlist def right_click(self, obj, event): menu = gtk.Menu() - for (image, title, func) in self.get_popup_menu_items(): + for (needs_write_access, image, title, func) in self.get_popup_menu_items(): if image: item = gtk.ImageMenuItem(stock_id=title) else: item = gtk.MenuItem(title) item.connect('activate', func) + if needs_write_access and self.dbstate.db.readonly: + item.set_sensitive(False) item.show() menu.append(item) menu.popup(None, None, None, event.button, event.time) @@ -148,7 +150,8 @@ class EmbeddedList(ButtonTab): [self._DND_TYPE.target()], gtk.gdk.ACTION_COPY) self.tree.connect('drag_data_get', self.drag_data_get) - self.tree.connect('drag_data_received', self.drag_data_received) + if not self.dbstate.db.readonly: + self.tree.connect('drag_data_received', self.drag_data_received) def drag_data_get(self, widget, context, sel_data, info, time): """ diff --git a/gramps2/src/DisplayTabs/_GalleryTab.py b/gramps2/src/DisplayTabs/_GalleryTab.py index 2d13396c6..0a77f4d42 100644 --- a/gramps2/src/DisplayTabs/_GalleryTab.py +++ b/gramps2/src/DisplayTabs/_GalleryTab.py @@ -93,10 +93,10 @@ class GalleryTab(ButtonTab): def right_click(self, obj, event): itemlist = [ - (True, gtk.STOCK_ADD, self.add_button_clicked), - (False, _('Share'), self.edit_button_clicked), - (True, gtk.STOCK_EDIT, self.edit_button_clicked), - (True, gtk.STOCK_REMOVE, self.del_button_clicked), + (True, True, gtk.STOCK_ADD, self.add_button_clicked), + (True, False, _('Share'), self.edit_button_clicked), + (False,True, gtk.STOCK_EDIT, self.edit_button_clicked), + (True, True, gtk.STOCK_REMOVE, self.del_button_clicked), ] menu = gtk.Menu() @@ -115,12 +115,14 @@ class GalleryTab(ButtonTab): item.show() menu.append(item) - for (image, title, func) in itemlist: + for (needs_write_access, image, title, func) in itemlist: if image: item = gtk.ImageMenuItem(stock_id=title) else: item = gtk.MenuItem(title) item.connect('activate', func) + if needs_write_access and self.dbstate.db.readonly: + item.set_sensitive(False) item.show() menu.append(item) menu.popup(None, None, None, event.button, event.time) @@ -284,7 +286,8 @@ class GalleryTab(ButtonTab): [self._DND_TYPE.target()], gtk.gdk.ACTION_COPY) self.iconlist.connect('drag_data_get', self.drag_data_get) - self.iconlist.connect('drag_data_received', self.drag_data_received) + if not self.dbstate.db.readonly: + self.iconlist.connect('drag_data_received', self.drag_data_received) def drag_data_get(self, widget, context, sel_data, info, time): """ @@ -435,4 +438,3 @@ class GalleryTab(ButtonTab): returns the index of the object within the associated data """ return self.get_data().index(obj) - diff --git a/gramps2/src/DisplayTabs/_NameEmbedList.py b/gramps2/src/DisplayTabs/_NameEmbedList.py index 1d44ff254..4fcb308ac 100644 --- a/gramps2/src/DisplayTabs/_NameEmbedList.py +++ b/gramps2/src/DisplayTabs/_NameEmbedList.py @@ -76,10 +76,10 @@ class NameEmbedList(EmbeddedList): def get_popup_menu_items(self): return [ - (True, gtk.STOCK_ADD, self.add_button_clicked), - (True, gtk.STOCK_EDIT, self.edit_button_clicked), - (True, gtk.STOCK_REMOVE, self.del_button_clicked), - (False, _('Set as default name'), self.name_button_clicked), + (True, True, gtk.STOCK_ADD, self.add_button_clicked), + (False,True, gtk.STOCK_EDIT, self.edit_button_clicked), + (True, True, gtk.STOCK_REMOVE, self.del_button_clicked), + (True, False, _('Set as default name'), self.name_button_clicked), ] def name_button_clicked(self, obj): diff --git a/gramps2/src/Editors/_EditEventRef.py b/gramps2/src/Editors/_EditEventRef.py index 7027271c9..756187e21 100644 --- a/gramps2/src/Editors/_EditEventRef.py +++ b/gramps2/src/Editors/_EditEventRef.py @@ -134,6 +134,7 @@ class EditEventRef(EditReference): self.top.get_widget("eer_type_combo"), self.source.set_type, self.source.get_type, + self.db.readonly, custom_values=self.get_custom_events()) date_entry = self.top.get_widget("eer_date") diff --git a/gramps2/src/Editors/_EditFamily.py b/gramps2/src/Editors/_EditFamily.py index c60307b21..34f1fc0a5 100644 --- a/gramps2/src/Editors/_EditFamily.py +++ b/gramps2/src/Editors/_EditFamily.py @@ -118,11 +118,11 @@ class ChildEmbedList(EmbeddedList): def get_popup_menu_items(self): return [ - (True, gtk.STOCK_ADD, self.add_button_clicked), - (False, _('Share'), self.edit_button_clicked), - (True, _('Edit relationship'), self.edit_button_clicked), - (True, _('Edit child'), self.edit_child_button_clicked), - (True, gtk.STOCK_REMOVE, self.del_button_clicked), + (True, True, gtk.STOCK_ADD, self.add_button_clicked), + (True, False, _('Share'), self.edit_button_clicked), + (False,True, _('Edit relationship'), self.edit_button_clicked), + (False,True, _('Edit child'), self.edit_child_button_clicked), + (True, True, gtk.STOCK_REMOVE, self.del_button_clicked), ] def find_index(self,obj): diff --git a/gramps2/src/Editors/_EditMediaRef.py b/gramps2/src/Editors/_EditMediaRef.py index ce51eafd6..0e59f1fe5 100644 --- a/gramps2/src/Editors/_EditMediaRef.py +++ b/gramps2/src/Editors/_EditMediaRef.py @@ -92,6 +92,11 @@ class EditMediaRef(EditReference): self.top.get_widget("uppery").set_value(coord[1]) self.top.get_widget("lowerx").set_value(coord[2]) self.top.get_widget("lowery").set_value(coord[3]) + if self.dbstate.db.readonly: + self.top.get_widget("upperx").set_sensitive(False) + self.top.get_widget("uppery").set_sensitive(False) + self.top.get_widget("lowerx").set_sensitive(False) + self.top.get_widget("lowery").set_sensitive(False) self.descr_window = MonitoredEntry( self.top.get_widget("description"), diff --git a/gramps2/src/Editors/_EditRepoRef.py b/gramps2/src/Editors/_EditRepoRef.py index 7d8c589ea..035a49d89 100644 --- a/gramps2/src/Editors/_EditRepoRef.py +++ b/gramps2/src/Editors/_EditRepoRef.py @@ -78,14 +78,16 @@ class EditRepoRef(EditReference): def _setup_fields(self): self.callno = MonitoredEntry( - self.top.get_widget("call_number"), self.source_ref.set_call_number, - self.source_ref.get_call_number, False) + self.top.get_widget("call_number"), + self.source_ref.set_call_number, + self.source_ref.get_call_number, + self.db.readonly) self.gid = MonitoredEntry( self.top.get_widget('gid'), self.source.set_gramps_id, self.source.get_gramps_id, - False) + self.db.readonly) self.privacy = PrivacyButton( self.top.get_widget("private"), @@ -96,7 +98,7 @@ class EditRepoRef(EditReference): self.top.get_widget('repo_name'), self.source.set_name, self.source.get_name, - False) + self.db.readonly) self.type_selector = MonitoredDataType( self.top.get_widget("media_type"), @@ -172,4 +174,3 @@ class EditRepoRef(EditReference): self.update((self.source_ref,self.source)) self.close() - diff --git a/gramps2/src/Editors/_EditSourceRef.py b/gramps2/src/Editors/_EditSourceRef.py index 130b421f1..3240e22aa 100644 --- a/gramps2/src/Editors/_EditSourceRef.py +++ b/gramps2/src/Editors/_EditSourceRef.py @@ -89,11 +89,11 @@ class EditSourceRef(EditReference): self.volume = MonitoredEntry( self.top.get_widget("volume"), self.source_ref.set_page, - self.source_ref.get_page, False) + self.source_ref.get_page, self.db.readonly) self.gid = MonitoredEntry( self.top.get_widget('gid'), self.source.set_gramps_id, - self.source.get_gramps_id,False) + self.source.get_gramps_id,self.db.readonly) self.source_privacy = PrivacyButton( self.top.get_widget("private"), @@ -101,19 +101,19 @@ class EditSourceRef(EditReference): self.title = MonitoredEntry( self.top.get_widget('title'), self.source.set_title, - self.source.get_title,False) + self.source.get_title,self.db.readonly) self.abbrev = MonitoredEntry( self.top.get_widget('abbrev'), self.source.set_abbreviation, - self.source.get_abbreviation,False) + self.source.get_abbreviation,self.db.readonly) self.author = MonitoredEntry( self.top.get_widget('author'), self.source.set_author, - self.source.get_author,False) + self.source.get_author,self.db.readonly) self.pubinfo = MonitoredEntry( self.top.get_widget('pub_info'), self.source.set_publication_info, - self.source.get_publication_info,False) + self.source.get_publication_info,self.db.readonly) self.type_mon = MonitoredMenu( self.top.get_widget('confidence'), @@ -123,7 +123,8 @@ class EditSourceRef(EditReference): (_('Low'), RelLib.SourceRef.CONF_LOW), (_('Normal'), RelLib.SourceRef.CONF_NORMAL), (_('High'), RelLib.SourceRef.CONF_HIGH), - (_('Very High'), RelLib.SourceRef.CONF_VERY_HIGH)]) + (_('Very High'), RelLib.SourceRef.CONF_VERY_HIGH)], + self.db.readonly) self.date = MonitoredDate( self.top.get_widget("date"), diff --git a/gramps2/src/Editors/_EditUrl.py b/gramps2/src/Editors/_EditUrl.py index 24e7f07db..a9bed25bc 100644 --- a/gramps2/src/Editors/_EditUrl.py +++ b/gramps2/src/Editors/_EditUrl.py @@ -92,7 +92,7 @@ class EditUrl(EditSecondary): self.top.get_widget("type"), self.obj.set_type, self.obj.get_type, - ) + self.db.readonly) def build_menu_names(self,obj): etitle =_('Internet Address Editor')