* src/AddrEdit.py,

* src/AttrEdit.py,
* src/EditPerson.py,
* src/EditPlace.py,
* src/EventEdit.py,
* src/FamilyView.py,
* src/MediaView.py,
* src/NameEdit.py,
* src/Sources.py: Better support for readonly DB;
* src/ImageSelect.py: Better support for readonly DB; dont crash if mimetype could not get retrieved
* src/Marriage.py: Better support for readonly DB; Avoid Traceback on DnD in empty list


svn: r5413
This commit is contained in:
Martin Hawlisch 2005-11-22 11:21:24 +00:00
parent 1db9fea574
commit ed60e469f4
12 changed files with 133 additions and 23 deletions

View File

@ -1,3 +1,18 @@
2005-11-22 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/AddrEdit.py,
* src/AttrEdit.py,
* src/EditPerson.py,
* src/EditPlace.py,
* src/EventEdit.py,
* src/FamilyView.py,
* src/MediaView.py,
* src/NameEdit.py,
* src/Sources.py: Better support for readonly DB;
* src/ImageSelect.py: Better support for readonly DB;
dont crash if mimetype could not get retrieved
* src/Marriage.py: Better support for readonly DB;
Avoid Traceback on DnD in empty list
2005-11-21 Don Allingham <don@gramps-project.org>
* src/ReadGedcom.py: Properly handle TEXT field in SOUR instances when
undefined or unhandled fields are present

View File

@ -93,20 +93,31 @@ class AddressEditor:
self.window = self.top.get_widget("addr_edit")
self.addr_start = self.top.get_widget("address_start")
self.addr_start.set_editable(not self.db.readonly)
self.street = self.top.get_widget("street")
self.street.set_editable(not self.db.readonly)
self.city = self.top.get_widget("city")
self.city.set_editable(not self.db.readonly)
self.state = self.top.get_widget("state")
self.state.set_editable(not self.db.readonly)
self.country = self.top.get_widget("country")
self.country.set_editable(not self.db.readonly)
self.postal = self.top.get_widget("postal")
self.postal.set_editable(not self.db.readonly)
self.phone = self.top.get_widget("phone")
self.phone.set_editable(not self.db.readonly)
self.note_field = self.top.get_widget("addr_note")
self.note_field.set_editable(not self.db.readonly)
self.spell = Spell.Spell(self.note_field)
self.priv = self.top.get_widget("priv")
self.priv.set_sensitive(not self.db.readonly)
self.slist = self.top.get_widget("slist")
self.sources_label = self.top.get_widget("sourcesAddr")
self.notes_label = self.top.get_widget("noteAddr")
self.flowed = self.top.get_widget("addr_flowed")
self.flowed.set_sensitive(not self.db.readonly)
self.preform = self.top.get_widget("addr_preform")
self.preform.set_sensitive(not self.db.readonly)
title_label = self.top.get_widget("title")
@ -126,9 +137,9 @@ class AddressEditor:
if self.addr.get_note():
self.note_field.get_buffer().set_text(self.addr.get_note())
Utils.bold_label(self.notes_label)
if addr.get_note_format() == 1:
if addr.get_note_format() == 1:
self.preform.set_active(1)
else:
else:
self.flowed.set_active(1)
else:
self.addr_date_obj = Date.Date()
@ -140,12 +151,15 @@ class AddressEditor:
self.top.get_widget('del_src'), self.db.readonly)
date_stat = self.top.get_widget("date_stat")
date_stat.set_sensitive(not self.db.readonly)
self.date_check = DateEdit.DateEdit(
self.addr_date_obj, self.addr_start, date_stat, self.window)
self.gladeif.connect('addr_edit','delete_event',self.on_delete_event)
self.gladeif.connect('button122','clicked',self.close)
self.gladeif.connect('button121','clicked',self.ok_clicked)
okbtn = self.top.get_widget('button121')
okbtn.set_sensitive(not self.db.readonly)
self.gladeif.connect('button129','clicked',self.on_help_clicked)
self.gladeif.connect('notebook2','switch_page',self.on_switch_page)

View File

@ -138,9 +138,9 @@ class AttributeEditor:
if attrib.get_note():
self.note_field.get_buffer().set_text(attrib.get_note())
Utils.bold_label(self.notes_label)
if attrib.get_note_format() == 1:
if attrib.get_note_format() == 1:
self.preform.set_active(1)
else:
else:
self.flowed.set_active(1)
self.gladeif = GladeIf(self.top)
@ -150,6 +150,16 @@ class AttributeEditor:
self.gladeif.connect('button127', 'clicked', self.on_help_clicked)
self.gladeif.connect('notebook', 'switch_page', self.on_switch_page)
if self.db.readonly:
w = self.top.get_widget("button115")
w.set_sensitive(False)
self.value_field.set_editable(False)
self.note_field.set_editable(False)
self.attrib_menu.set_sensitive(False)
self.priv.set_sensitive(False)
self.flowed.set_sensitive(False)
self.preform.set_sensitive(False)
if parent_window:
self.window.set_transient_for(parent_window)
self.add_itself_to_menu()

View File

@ -513,7 +513,8 @@ class EditPerson:
ACTION_COPY)
obj.connect('drag_data_get', get)
obj.connect('drag_begin', begin)
obj.connect('drag_data_received', receive)
if not self.db.readonly:
obj.connect('drag_data_received', receive)
def build_pdmap(self):
self.pdmap.clear()
@ -832,6 +833,9 @@ class EditPerson:
t.drag_source_set_icon(t.get_colormap(),icon,mask)
def name_drag_data_received(self,widget,context,x,y,sel_data,info,time):
if self.db.readonly: # no DnD on readonly database
return
row = self.ntree.get_row_at(x,y)
if sel_data and sel_data.data:
@ -855,6 +859,9 @@ class EditPerson:
self.redraw_name_list()
def ev_drag_data_received(self,widget,context,x,y,sel_data,info,time):
if self.db.readonly: # no DnD on readonly database
return
row = self.etree.get_row_at(x,y)
if sel_data and sel_data.data:
@ -905,6 +912,9 @@ class EditPerson:
t.drag_source_set_icon(t.get_colormap(),icon,mask)
def url_drag_data_received(self,widget,context,x,y,sel_data,info,time):
if self.db.readonly: # no DnD on readonly database
return
row = self.wtree.get_row_at(x,y)
if sel_data and sel_data.data:
@ -934,6 +944,9 @@ class EditPerson:
sel_data.set(sel_data.target, bits_per, data)
def at_drag_data_received(self,widget,context,x,y,sel_data,info,time):
if self.db.readonly: # no DnD on readonly database
return
row = self.atree.get_row_at(x,y)
if sel_data and sel_data.data:
@ -968,6 +981,9 @@ class EditPerson:
sel_data.set(sel_data.target, bits_per, data)
def ad_drag_data_received(self,widget,context,x,y,sel_data,info,time):
if self.db.readonly: # no DnD on readonly database
return
row = self.ptree.get_row_at(x,y)
if sel_data and sel_data.data:
@ -1247,7 +1263,7 @@ class EditPerson:
"""If the data has changed, give the user a chance to cancel
the close window"""
if self.did_data_change() and not GrampsKeys.get_dont_ask():
if not self.db.readonly and self.did_data_change() and not GrampsKeys.get_dont_ask():
n = "<i>%s</i>" % escape(self.nd.display(self.person))
SaveDialog(_('Save changes to %s?') % n,
_('If you close without saving, the changes you '
@ -1263,7 +1279,7 @@ class EditPerson:
def on_delete_event(self,obj,b):
"""If the data has changed, give the user a chance to cancel
the close window"""
if self.did_data_change() and not GrampsKeys.get_dont_ask():
if not self.db.readonly and self.did_data_change() and not GrampsKeys.get_dont_ask():
n = "<i>%s</i>" % escape(self.nd.display(self.person))
SaveDialog(_('Save Changes to %s?') % n,
_('If you close without saving, the changes you '

View File

@ -235,7 +235,8 @@ class EditPlace:
gtk.gdk.ACTION_COPY)
self.web_list.connect('drag_data_get',
self.url_source_drag_data_get)
self.web_list.connect('drag_data_received',
if not self.db.readonly:
self.web_list.connect('drag_data_received',
self.url_dest_drag_data_received)
for name in ['del_name','add_name','sel_photo','add_url','del_url']:

View File

@ -213,9 +213,11 @@ class EventEditor:
self.event_menu.child.set_text(def_event)
if def_placename:
self.place_field.set_text(def_placename)
date_stat = self.top.get_widget("date_stat")
date_stat.set_sensitive(not self.db.readonly)
self.date_check = DateEdit.DateEdit(self.date,
self.date_field,
self.top.get_widget("date_stat"),
date_stat,
self.window)
if not event:

View File

@ -207,7 +207,8 @@ class FamilyView:
ACTION_COPY)
self.spouse_list.connect('drag_data_get',
self.sp_drag_data_get)
self.spouse_list.connect('drag_data_received',
if not self.parent.db.readonly:
self.spouse_list.connect('drag_data_received',
self.sp_drag_data_received)
def init_interface(self):
@ -263,7 +264,8 @@ class FamilyView:
[DdTargets.CHILD.target()],
ACTION_COPY)
self.child_list.connect('drag_data_get', self.drag_data_get)
self.child_list.connect('drag_data_received',self.drag_data_received)
if not self.parent.db.readonly:
self.child_list.connect('drag_data_received',self.drag_data_received)
if not already_init:
self.child_list.connect('button-press-event',
@ -1417,6 +1419,8 @@ class FamilyView:
self.load_family()
def drag_data_received(self,widget,context,x,y,sel_data,info,time):
if self.parent.db.readonly: # no DnD on readonly database
return
if DdTargets.PERSON_LINK.drag_type in context.targets:
drop_person_handle = sel_data.data
@ -1494,6 +1498,8 @@ class FamilyView:
self.load_family(self.family)
def sp_drag_data_received(self,widget,context,x,y,sel_data,info,time):
if self.parent.db.readonly: # no DnD on readonly database
return
self.in_drag = True
path = self.spouse_list.get_path_at_pos(x,y)
if path == None:

View File

@ -249,7 +249,8 @@ class Gallery(ImageSelect):
[DdTargets.MEDIAOBJ.target()]+_drag_targets,
gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE)
icon_list.connect('event',self.item_event)
icon_list.connect("drag_data_received",
if not db.readonly:
icon_list.connect("drag_data_received",
self.on_photolist_drag_data_received)
icon_list.connect("drag_data_get",
self.on_photolist_drag_data_get)
@ -757,7 +758,10 @@ class LocalMediaProperties:
self.change_dialog.get_widget("path").set_text(fname)
mt = Utils.get_mime_description(mtype)
self.change_dialog.get_widget("type").set_text(mt)
if mt:
self.change_dialog.get_widget("type").set_text(mt)
else:
self.change_dialog.get_widget("type").set_text("")
self.notes = self.change_dialog.get_widget("notes")
self.spell = Spell.Spell(self.notes)
if self.photo.get_note():

View File

@ -285,7 +285,8 @@ class Marriage:
gtk.gdk.ACTION_COPY)
self.event_list.connect('drag_data_get',
self.ev_source_drag_data_get)
self.event_list.connect('drag_data_received',
if not self.db.readonly:
self.event_list.connect('drag_data_received',
self.ev_dest_drag_data_received)
self.event_list.connect('drag_begin', self.ev_drag_begin)
@ -297,7 +298,8 @@ class Marriage:
gtk.gdk.ACTION_COPY)
self.attr_list.connect('drag_data_get',
self.at_source_drag_data_get)
self.attr_list.connect('drag_data_received',
if not self.db.readonly:
self.attr_list.connect('drag_data_received',
self.at_dest_drag_data_received)
self.attr_list.connect('drag_begin', self.at_drag_begin)
@ -425,6 +427,8 @@ class Marriage:
NoteEdit.NoteEditor(lds_ord,self,self.window,readonly=self.db.readonly)
def ev_dest_drag_data_received(self,widget,context,x,y,selection_data,info,time):
if self.db.readonly: # no DnD on readonly database
return
row = self.etree.get_row_at(x,y)
if selection_data and selection_data.data:
exec 'data = %s' % selection_data.data
@ -456,6 +460,8 @@ class Marriage:
def ev_source_drag_data_get(self,widget, context, selection_data, info, time):
ev = self.etree.get_selected_objects()
if not ev:
return
bits_per = 8; # we're going to pass a string
pickled = pickle.dumps(ev[0]);
@ -464,6 +470,8 @@ class Marriage:
selection_data.set(selection_data.target, bits_per, data)
def at_dest_drag_data_received(self,widget,context,x,y,selection_data,info,time):
if self.db.readonly: # no DnD on readonly database
return
row = self.atree.get_row_at(x,y)
if selection_data and selection_data.data:
exec 'data = %s' % selection_data.data
@ -491,6 +499,8 @@ class Marriage:
def at_source_drag_data_get(self,widget, context, selection_data, info, time):
ev = self.atree.get_selected_objects()
if not ev:
return
bits_per = 8; # we're going to pass a string
pickled = pickle.dumps(ev[0]);
@ -609,7 +619,7 @@ class Marriage:
self.on_close(None)
def on_delete_event(self,obj,b):
if self.did_data_change() and not GrampsKeys.get_dont_ask():
if not self.db.readonly and self.did_data_change() and not GrampsKeys.get_dont_ask():
SaveDialog(_('Save Changes?'),
_('If you close without saving, the changes you '
'have made will be lost'),

View File

@ -116,8 +116,8 @@ class MediaView:
DND_TARGETS,
gtk.gdk.ACTION_COPY|gtk.gdk.ACTION_MOVE
)
self.list.connect("drag-data-received", self.on_drag_data_received)
if not self.db.readonly:
self.list.connect("drag-data-received", self.on_drag_data_received)
self.list.connect("drag-data-get", self.on_drag_data_get)
self.list.connect("drag-begin", self.on_drag_begin)
self.list.connect("drag-drop", self.on_drag_drop)

View File

@ -81,14 +81,22 @@ class NameEditor:
self.gladeif = GladeIf(self.top)
self.window = self.top.get_widget("name_edit")
self.given_field = self.top.get_widget("alt_given")
self.given_field.set_editable(not self.db.readonly)
self.sort_as = self.top.get_widget("sort_as")
self.sort_as.set_sensitive(not self.db.readonly)
self.display_as = self.top.get_widget("display_as")
self.display_as.set_sensitive(not self.db.readonly)
self.group_as = self.top.get_widget("group_as")
self.title_field = self.top.get_widget("alt_title")
self.title_field.set_editable(not self.db.readonly)
self.suffix_field = self.top.get_widget("alt_suffix")
self.suffix_field.set_editable(not self.db.readonly)
self.patronymic_field = self.top.get_widget("patronymic")
self.patronymic_field.set_editable(not self.db.readonly)
self.combo = self.top.get_widget("alt_surname_list")
self.combo.set_sensitive(not self.db.readonly)
self.date = self.top.get_widget('date')
self.date.set_editable(not self.db.readonly)
if self.name:
self.srcreflist = self.name.get_source_references()
@ -99,25 +107,34 @@ class NameEditor:
self.date.set_text(DateHandler.displayer.display(self.date_obj))
date_stat = self.top.get_widget("date_stat")
date_stat.set_sensitive(not self.db.readonly)
self.date_check = DateEdit.DateEdit(
self.date_obj, self.date,
self.top.get_widget("date_stat"), self.window)
date_stat, self.window)
AutoComp.fill_combo(self.combo,self.parent.db.get_surname_list())
self.surname_field = self.combo.get_child()
self.prefix_field = self.top.get_widget("alt_prefix")
self.prefix_field.set_editable(not self.db.readonly)
self.type_combo = self.top.get_widget("name_type")
self.type_combo.set_sensitive(not self.db.readonly)
self.note_field = self.top.get_widget("alt_note")
self.note_field.set_editable(not self.db.readonly)
self.spell = Spell.Spell(self.note_field)
self.slist = self.top.get_widget('slist')
self.priv = self.top.get_widget("priv")
self.priv.set_sensitive(not self.db.readonly)
self.sources_label = self.top.get_widget("sourcesName")
self.notes_label = self.top.get_widget("noteName")
self.flowed = self.top.get_widget("alt_flowed")
self.flowed.set_sensitive(not self.db.readonly)
self.preform = self.top.get_widget("alt_preform")
self.preform.set_sensitive(not self.db.readonly)
self.group_over = self.top.get_widget('group_over')
self.group_over.set_sensitive(not self.db.readonly)
types = const.NameTypesMap.get_values()
types.sort()
@ -145,6 +162,8 @@ class NameEditor:
self.gladeif.connect('name_edit','delete_event',self.on_delete_event)
self.gladeif.connect('button119','clicked',self.close)
self.gladeif.connect('button118','clicked',self.on_name_edit_ok_clicked)
okbtn = self.top.get_widget('button118')
okbtn.set_sensitive(not self.db.readonly)
self.gladeif.connect('button131','clicked',self.on_help_clicked)
self.gladeif.connect('notebook3','switch_page',self.on_switch_page)
self.gladeif.connect('group_over','toggled',self.on_group_over_toggled)

View File

@ -241,6 +241,7 @@ class SourceTab:
self.slist = clist
self.selection = clist.get_selection()
self.model = gtk.ListStore(str,str,TYPE_PYOBJECT)
self.readonly = readonly
add_btn.set_sensitive(not readonly)
del_btn.set_sensitive(not readonly)
@ -274,9 +275,13 @@ class SourceTab:
ACTION_COPY)
self.slist.connect('drag_data_get', self.drag_data_get)
self.slist.connect('drag_begin', self.drag_begin)
self.slist.connect('drag_data_received',self.drag_data_received)
if not self.readonly:
self.slist.connect('drag_data_received',self.drag_data_received)
def drag_data_received(self,widget,context,x,y,sel_data,info,time):
if self.db.readonly or self.readonly: # no DnD on readonly database
return
if sel_data and sel_data.data:
exec 'data = %s' % sel_data.data
exec 'mytype = "%s"' % data[0]
@ -390,6 +395,8 @@ class SourceEditor:
self.gladeif.connect('ok','clicked',self.on_sourceok_clicked)
self.gladeif.connect('button144','clicked', self.on_help_clicked)
self.gladeif.connect('button143','clicked',self.add_src_clicked)
addbtn = self.get_widget('button143')
addbtn.set_sensitive(not self.db.readonly)
self.source_field = self.get_widget("sourceList")
@ -400,7 +407,9 @@ class SourceEditor:
self.title_menu.add_attribute(cell,'text',0)
self.title_menu.connect('changed',self.on_source_changed)
self.conf_menu = self.get_widget("conf")
self.conf_menu.set_sensitive(not self.db.readonly)
self.private = self.get_widget("priv")
self.private.set_sensitive(not self.db.readonly)
self.ok = self.get_widget("ok")
self.conf_menu.set_active(srcref.get_confidence_level())
@ -408,6 +417,7 @@ class SourceEditor:
self.pub_field = self.get_widget("spubinfo")
self.date_entry_field = self.get_widget("sdate")
self.date_entry_field.set_editable(not self.db.readonly)
if self.source_ref:
handle = self.source_ref.get_base_handle()
@ -421,14 +431,18 @@ class SourceEditor:
self.active_source = None
date_stat = self.get_widget("date_stat")
date_stat.set_sensitive(not self.db.readonly)
self.date_check = DateEdit.DateEdit(
self.date_obj, self.date_entry_field,
date_stat, self.sourceDisplay)
self.spage = self.get_widget("spage")
self.spage.set_editable(not self.db.readonly)
self.scom = self.get_widget("scomment")
self.scom.set_editable(not self.db.readonly)
self.spell1 = Spell.Spell(self.scom)
self.stext = self.get_widget("stext")
self.stext.set_editable(not self.db.readonly)
self.spell2 = Spell.Spell(self.stext)
self.draw(self.active_source,fresh=True)
@ -494,7 +508,7 @@ class SourceEditor:
def set_button(self):
if self.active_source:
self.ok.set_sensitive(True)
self.ok.set_sensitive(not self.db.readonly)
else:
self.ok.set_sensitive(False)
@ -549,7 +563,7 @@ class SourceEditor:
self.title_menu.set_model(store)
if index > 0:
self.title_menu.set_sensitive(1)
self.title_menu.set_sensitive(not self.db.readonly)
self.title_menu.set_active(sel_index)
else:
self.title_menu.set_sensitive(0)
@ -597,4 +611,3 @@ class SourceEditor:
def add_src_clicked(self,obj):
import EditSource
EditSource.EditSource(RelLib.Source(),self.db, self)