* src/AddMedia.py: relative path support

* src/AddrEdit.py: add DisplayTab support
* src/DdTargets.py: repository references support
* src/DisplayTabs.py: repository reference support
* src/EditMedia.py: save support
* src/EditSource.py: save support
* src/ImageSelect.py: remove unused stuff
* src/Sources.py: use object instead of gobject.TYPE_PYOBJECT
* src/Utils.py: relative path calculator
* src/ViewManager.py: change cwd to directory of the file so that
relative paths work
* src/edit_person.glade: fix size
* src/gramps.glade: add relative path indicator
* src/GrampsDb/_ReadGedcom.py: remove useless compare


svn: r5883
This commit is contained in:
Don Allingham 2006-02-04 23:29:44 +00:00
parent 9393b15589
commit 388b3bad33
14 changed files with 214 additions and 1603 deletions

View File

@ -1,3 +1,19 @@
2006-02-04 Don Allingham <don@gramps-project.org>
* src/AddMedia.py: relative path support
* src/AddrEdit.py: add DisplayTab support
* src/DdTargets.py: repository references support
* src/DisplayTabs.py: repository reference support
* src/EditMedia.py: save support
* src/EditSource.py: save support
* src/ImageSelect.py: remove unused stuff
* src/Sources.py: use object instead of gobject.TYPE_PYOBJECT
* src/Utils.py: relative path calculator
* src/ViewManager.py: change cwd to directory of the file so that
relative paths work
* src/edit_person.glade: fix size
* src/gramps.glade: add relative path indicator
* src/GrampsDb/_ReadGedcom.py: remove useless compare
2006-02-03 Don Allingham <don@gramps-project.org> 2006-02-03 Don Allingham <don@gramps-project.org>
* src/AttrEdit.py: use DisplayTabs * src/AttrEdit.py: use DisplayTabs
* src/NameEdit.py: use DisplayTabs * src/NameEdit.py: use DisplayTabs

View File

@ -86,6 +86,7 @@ class AddMediaObject:
self.file_text = self.glade.get_widget("fname") self.file_text = self.glade.get_widget("fname")
self.internal = self.glade.get_widget('internal') self.internal = self.glade.get_widget('internal')
self.internal.connect('toggled',self.internal_toggled) self.internal.connect('toggled',self.internal_toggled)
self.relpath = self.glade.get_widget('relpath')
self.temp_name = "" self.temp_name = ""
self.object = None self.object = None
@ -118,6 +119,12 @@ class AddMediaObject:
mobj.set_mime_type(None) mobj.set_mime_type(None)
else: else:
filename = self.file_text.get_filename() filename = self.file_text.get_filename()
if self.relpath.get_active():
p = self.db.get_save_path()
if not os.path.isdir(p):
p = os.path.dirname(p)
filename = Utils.relative_path(filename,p)
if os.path.exists(filename) == 0: if os.path.exists(filename) == 0:
msgstr = _("Cannot import %s") msgstr = _("Cannot import %s")

View File

@ -31,7 +31,6 @@ mechanism for the user to edit address information.
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gettext import gettext as _ from gettext import gettext as _
import gc
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -56,6 +55,7 @@ import DisplayState
import Spell import Spell
from WindowUtils import GladeIf from WindowUtils import GladeIf
from DisplayTabs import *
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -103,26 +103,14 @@ class AddressEditor(DisplayState.ManagedWindow):
self.postal.set_editable(not self.db.readonly) self.postal.set_editable(not self.db.readonly)
self.phone = self.top.get_widget("phone") self.phone = self.top.get_widget("phone")
self.phone.set_editable(not self.db.readonly) 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 = self.top.get_widget("priv")
self.priv.set_sensitive(not self.db.readonly) self.priv.set_sensitive(not self.db.readonly)
self.slist = self.top.get_widget("slist")
self.sources_label = self.top.get_widget("sources_tab")
self.notes_label = self.top.get_widget("note_tab")
self.general_label = self.top.get_widget("general_tab")
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") title_label = self.top.get_widget("title")
Utils.set_titles(self.window,title_label,_('Address Editor')) Utils.set_titles(self.window,title_label,_('Address Editor'))
if self.addr: if self.addr:
self.srcreflist = self.addr.get_source_references()
self.addr_date_obj = RelLib.Date(self.addr.get_date_object()) self.addr_date_obj = RelLib.Date(self.addr.get_date_object())
self.addr_start.set_text(DateHandler.get_date(self.addr)) self.addr_start.set_text(DateHandler.get_date(self.addr))
self.street.set_text(self.addr.get_street()) self.street.set_text(self.addr.get_street())
@ -132,29 +120,9 @@ class AddressEditor(DisplayState.ManagedWindow):
self.postal.set_text(self.addr.get_postal_code()) self.postal.set_text(self.addr.get_postal_code())
self.phone.set_text(self.addr.get_phone()) self.phone.set_text(self.addr.get_phone())
self.priv.set_active(self.addr.get_privacy()) self.priv.set_active(self.addr.get_privacy())
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:
self.preform.set_active(1)
else:
self.flowed.set_active(1)
Utils.bold_label(self.general_label)
else:
Utils.unbold_label(self.sources_label)
Utils.bold_label(self.general_label)
else: else:
Utils.unbold_label(self.general_label)
self.addr_date_obj = RelLib.Date() self.addr_date_obj = RelLib.Date()
self.srcreflist = []
self.addr = RelLib.Address() self.addr = RelLib.Address()
self.switch_page()
self.sourcetab = Sources.SourceTab(
self.dbstate, self.uistate, self.track,
self.srcreflist, self, self.top, self.window, self.slist,
self.top.get_widget('add_src'), self.top.get_widget('edit_src'),
self.top.get_widget('del_src'), self.db.readonly)
date_stat = self.top.get_widget("date_stat") date_stat = self.top.get_widget("date_stat")
date_stat.set_sensitive(not self.db.readonly) date_stat.set_sensitive(not self.db.readonly)
@ -167,21 +135,45 @@ class AddressEditor(DisplayState.ManagedWindow):
okbtn = self.top.get_widget('button121') okbtn = self.top.get_widget('button121')
okbtn.set_sensitive(not self.db.readonly) okbtn.set_sensitive(not self.db.readonly)
self.gladeif.connect('button129','clicked',self.on_help_clicked) self.gladeif.connect('button129','clicked',self.on_help_clicked)
self.gladeif.connect('notebook2','switch_page',self.on_switch_page)
self.window.set_transient_for(self.parent_window) self._create_tabbed_pages()
self.window.show()
self.show()
def _add_page(self,page):
self.notebook.insert_page(page)
self.notebook.set_tab_label(page,page.get_tab_widget())
return page
def _create_tabbed_pages(self):
"""
Creates the notebook tabs and inserts them into the main
window.
"""
vbox = self.top.get_widget('vbox')
self.notebook = gtk.Notebook()
self.srcref_list = self._add_page(SourceEmbedList(
self.dbstate,self.uistate, self.track,
self.addr.source_list))
self.note_tab = self._add_page(NoteTab(
self.dbstate, self.uistate, self.track,
self.addr.get_note_object()))
self.notebook.show_all()
vbox.pack_start(self.notebook,True)
def on_delete_event(self,obj,b): def on_delete_event(self,obj,b):
self.gladeif.close() self.gladeif.close()
self.close() self.close()
gc.collect()
def close_window(self,obj): def close_window(self,obj):
self.gladeif.close() self.gladeif.close()
self.close()
self.window.destroy() self.window.destroy()
gc.collect() self.close()
def build_menu_names(self,obj): def build_menu_names(self,obj):
return (_('Address'),_('Address Editor')) return (_('Address'),_('Address Editor'))
@ -204,12 +196,11 @@ class AddressEditor(DisplayState.ManagedWindow):
postal = unicode(self.postal.get_text()) postal = unicode(self.postal.get_text())
b = self.note_field.get_buffer() b = self.note_field.get_buffer()
note = unicode(b.get_text(b.get_start_iter(),b.get_end_iter(),False)) note = unicode(b.get_text(b.get_start_iter(),b.get_end_iter(),False))
format = self.preform.get_active()
priv = self.priv.get_active() priv = self.priv.get_active()
self.addr.set_source_reference_list(self.srcreflist) self.addr.set_source_reference_list(self.srcreflist)
self.update(date_obj,street,city,state,country,postal,phone,note,format,priv) self.update(date_obj,street,city,state,country,postal,phone,priv)
self.callback(self.addr) self.callback(self.addr)
self.close_window(obj) self.close_window(obj)
@ -219,7 +210,7 @@ class AddressEditor(DisplayState.ManagedWindow):
if get() != data: if get() != data:
set(data) set(data)
def update(self,date_obj,street,city,state,country,postal,phone,note,format,priv): def update(self,date_obj,street,city,state,country,postal,phone,priv):
"""Compares the data items, and updates if necessary""" """Compares the data items, and updates if necessary"""
if not self.addr.get_date_object().is_equal(date_obj): if not self.addr.get_date_object().is_equal(date_obj):
@ -234,16 +225,3 @@ class AddressEditor(DisplayState.ManagedWindow):
self.check(self.addr.get_note,self.addr.set_note,note) self.check(self.addr.get_note,self.addr.set_note,note)
self.check(self.addr.get_note_format,self.addr.set_note_format,format) self.check(self.addr.get_note_format,self.addr.set_note_format,format)
self.check(self.addr.get_privacy,self.addr.set_privacy,priv) self.check(self.addr.get_privacy,self.addr.set_privacy,priv)
def on_switch_page(self,obj,a,page):
self.switch_page()
def switch_page(self):
buf = self.note_field.get_buffer()
start = buf.get_start_iter()
stop = buf.get_end_iter()
text = unicode(buf.get_text(start,stop,False))
if text:
Utils.bold_label(self.notes_label)
else:
Utils.unbold_label(self.notes_label)

View File

@ -103,6 +103,7 @@ class _DdTargets(object):
self.ATTRIBUTE = _DdType(self,'pattr') self.ATTRIBUTE = _DdType(self,'pattr')
self.ADDRESS = _DdType(self,'paddr') self.ADDRESS = _DdType(self,'paddr')
self.SOURCEREF = _DdType(self,'srcref') self.SOURCEREF = _DdType(self,'srcref')
self.REPOREF = _DdType(self,'reporef')
self.NAME = _DdType(self,'name') self.NAME = _DdType(self,'name')
self.MEDIAOBJ = _DdType(self,'mediaobj') self.MEDIAOBJ = _DdType(self,'mediaobj')
self.DATA = _DdType(self,'data_tuple') self.DATA = _DdType(self,'data_tuple')

View File

@ -537,7 +537,7 @@ class EventEmbedList(EmbeddedList):
_column_names = [ _column_names = [
(_('Type'),0,100), (_('Type'),0,100),
(_('Description'),1,200), (_('Description'),1,175),
(_('ID'),2, 60), (_('ID'),2, 60),
(_('Date'),3, 150), (_('Date'),3, 150),
(_('Place'),4, 140), (_('Place'),4, 140),
@ -1103,6 +1103,61 @@ class SourceEmbedList(EmbeddedList):
self.changed = True self.changed = True
self.rebuild() self.rebuild()
#-------------------------------------------------------------------------
#
# RepoEmbedList
#
#-------------------------------------------------------------------------
class RepoEmbedList(EmbeddedList):
_HANDLE_COL = 4
_DND_TYPE = DdTargets.REPOREF
_column_names = [
(_('ID'), 0, 75),
(_('Title'), 1, 200),
(_('Call Number'), 2, 125),
(_('Type'), 3, 100),
]
def __init__(self,dbstate,uistate,track,obj):
self.obj = obj
EmbeddedList.__init__(self, dbstate, uistate, track,
_('Repositories'), RepoRefModel)
def get_icon_name(self):
return 'gramps-repository'
def get_data(self):
return self.obj
def column_order(self):
return ((1,0),(1,1),(1,2),(1,3))
def add_button_clicked(self,obj):
from RepositoryRefEdit import RepositoryRefEdit
ref = RelLib.RepositoryRef()
RepositoryRefEdit.RepositoryRefEdit(
self.dbstate, self.uistate, self.track, ref, self.add_callback)
def add_callback(self,obj):
self.get_data().append(name)
self.changed = True
self.rebuild()
def edit_button_clicked(self,obj):
from RepositoryRefEdit import RepositoryRefEdit
ref = self.get_selected()
if ref:
RepositoryRefEdit.RepositoryRefEdit(
self.dbstate, self.uistate, self.track, ref, self.edit_callback)
def edit_callback(self,name):
self.changed = True
self.rebuild()
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# ChildModel # ChildModel
@ -1256,7 +1311,7 @@ class EventRefModel(gtk.ListStore):
if t == RelLib.EventRef.CUSTOM: if t == RelLib.EventRef.CUSTOM:
return v return v
else: else:
return Utils.event_roles[t] return Utils.event_roles.get(t,"error %d" % t)
def column_date(self,event_ref): def column_date(self,event_ref):
event = self.db.get_event_from_handle(event_ref.ref) event = self.db.get_event_from_handle(event_ref.ref)
@ -1378,7 +1433,7 @@ class DataModel(gtk.ListStore):
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# DataModel # SourceRefModel
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class SourceRefModel(gtk.ListStore): class SourceRefModel(gtk.ListStore):
@ -1393,7 +1448,30 @@ class SourceRefModel(gtk.ListStore):
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# SourceBacRefModel # RepoRefModel
#
#-------------------------------------------------------------------------
class RepoRefModel(gtk.ListStore):
def __init__(self,ref_list,db):
gtk.ListStore.__init__(self,str,str,str,str,object)
self.db = db
for ref in ref_list:
repo = self.db.get_repository_from_handle(ref.ref)
self.append(row=[repo.gramps_id, repo.name, ref.call_number,
self.type_of(repo), ref,])
def type_of(self,ref):
v,s = ref.get_type()
if v == RelLib.RepoRef.CUSTOM:
return unicode(s)
else:
return Utils.source_media_types.get(v,"error %s" % v)
#-------------------------------------------------------------------------
#
# SourceBackRefModel
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class SourceBackRefModel(gtk.ListStore): class SourceBackRefModel(gtk.ListStore):

View File

@ -196,11 +196,10 @@ class EditMedia(DisplayState.ManagedWindow):
self.change_dialog.get_widget("path").set_text(fname) self.change_dialog.get_widget("path").set_text(fname)
def on_apply_clicked(self, obj): def on_apply_clicked(self, obj):
t = self.notes.get_buffer()
text = unicode(t.get_text(t.get_start_iter(),t.get_end_iter(),False))
desc = unicode(self.descr_window.get_text()) desc = unicode(self.descr_window.get_text())
note = self.obj.get_note() note = self.obj.get_note()
path = self.change_dialog.get_widget('path').get_text() path = self.change_dialog.get_widget('path').get_text()
if path != self.obj.get_path(): if path != self.obj.get_path():
mime = GrampsMime.get_type(path) mime = GrampsMime.get_type(path)
self.obj.set_mime_type(mime) self.obj.set_mime_type(mime)
@ -209,15 +208,6 @@ class EditMedia(DisplayState.ManagedWindow):
if not self.date_object.is_equal(self.obj.get_date_object()): if not self.date_object.is_equal(self.obj.get_date_object()):
self.obj.set_date_object(self.date_object) self.obj.set_date_object(self.date_object)
format = self.preform.get_active()
if text != note or desc != self.obj.get_description():
self.obj.set_note(text)
self.obj.set_description(desc)
if format != self.obj.get_note_format():
self.obj.set_note_format(format)
if self.lists_changed:
self.obj.set_attribute_list(self.alist)
self.obj.set_source_reference_list(self.srcreflist)
trans = self.db.transaction_begin() trans = self.db.transaction_begin()
self.db.commit_media_object(self.obj,trans) self.db.commit_media_object(self.obj,trans)
self.db.transaction_commit(trans,_("Edit Media Object")) self.db.transaction_commit(trans,_("Edit Media Object"))

View File

@ -56,8 +56,7 @@ import Spell
import GrampsDisplay import GrampsDisplay
import DisplayState import DisplayState
from DisplayTabs import NoteTab, GalleryTab, DataEmbedList, SourceBackRefList from DisplayTabs import *
from WindowUtils import GladeIf from WindowUtils import GladeIf
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -207,6 +206,8 @@ class EditSource(DisplayState.ManagedWindow):
self.author = self.top_window.get_widget("author") self.author = self.top_window.get_widget("author")
self.pubinfo = self.top_window.get_widget("pubinfo") self.pubinfo = self.top_window.get_widget("pubinfo")
self.abbrev = self.top_window.get_widget("abbrev") self.abbrev = self.top_window.get_widget("abbrev")
self.cancel = self.top_window.get_widget('cancel')
self.ok = self.top_window.get_widget('ok')
self.vbox = self.top_window.get_widget('vbox') self.vbox = self.top_window.get_widget('vbox')
@ -222,8 +223,9 @@ class EditSource(DisplayState.ManagedWindow):
self.abbrev.set_text(source.get_abbreviation()) self.abbrev.set_text(source.get_abbreviation())
self.abbrev.set_editable(mode) self.abbrev.set_editable(mode)
self.top_window.get_widget('ok').set_sensitive(not self.db.readonly) self.ok.set_sensitive(not self.db.readonly)
self.top_window.get_widget('cancel').connect('clicked', self.close_window) self.cancel.connect('clicked', self.close_window)
self.ok.connect('clicked', self.apply_clicked)
self.notebook = gtk.Notebook() self.notebook = gtk.Notebook()
self.notebook.show() self.notebook.show()
@ -233,19 +235,18 @@ class EditSource(DisplayState.ManagedWindow):
self.show() self.show()
self.model = None # This will hold the model for backreferences once it is complete.
def load_data(self): def load_data(self):
self.note_tab = NoteTab(self.dbstate, self.uistate, self.track, self.note_tab = NoteTab(
self.source.get_note_object()) self.dbstate, self.uistate, self.track, self.source.get_note_object())
self.gallery_tab = GalleryTab(self.dbstate, self.uistate, self.track, self.gallery_tab = GalleryTab(
self.source.get_media_list()) self.dbstate, self.uistate, self.track, self.source.get_media_list())
self.data_tab = DataEmbedList(
self.data_tab = DataEmbedList(self.dbstate, self.uistate, self.track, self.dbstate, self.uistate, self.track, self.source)
self.source) self.repo_tab = RepoEmbedList(
self.dbstate, self.uistate, self.track, self.source.get_reporef_list())
self.backref_tab = SourceBackRefList(self.dbstate, self.uistate, self.track, self.backref_tab = SourceBackRefList(
self.db.find_backlink_handles(self.source.handle)) self.dbstate, self.uistate, self.track,
self.db.find_backlink_handles(self.source.handle))
self.notebook.insert_page(self.note_tab) self.notebook.insert_page(self.note_tab)
self.notebook.set_tab_label(self.note_tab,self.note_tab.get_tab_widget()) self.notebook.set_tab_label(self.note_tab,self.note_tab.get_tab_widget())
@ -256,6 +257,9 @@ class EditSource(DisplayState.ManagedWindow):
self.notebook.insert_page(self.gallery_tab) self.notebook.insert_page(self.gallery_tab)
self.notebook.set_tab_label(self.gallery_tab,self.gallery_tab.get_tab_widget()) self.notebook.set_tab_label(self.gallery_tab,self.gallery_tab.get_tab_widget())
self.notebook.insert_page(self.repo_tab)
self.notebook.set_tab_label(self.repo_tab,self.repo_tab.get_tab_widget())
self.notebook.insert_page(self.backref_tab) self.notebook.insert_page(self.backref_tab)
self.notebook.set_tab_label(self.backref_tab,self.backref_tab.get_tab_widget()) self.notebook.set_tab_label(self.backref_tab,self.backref_tab.get_tab_widget())
@ -287,17 +291,12 @@ class EditSource(DisplayState.ManagedWindow):
self.gladeif.close() self.gladeif.close()
self.close() self.close()
def on_source_apply_clicked(self,obj): def apply_clicked(self,obj):
title = unicode(self.title.get_text()) title = unicode(self.title.get_text())
author = unicode(self.author.get_text()) author = unicode(self.author.get_text())
pubinfo = unicode(self.pubinfo.get_text()) pubinfo = unicode(self.pubinfo.get_text())
abbrev = unicode(self.abbrev.get_text()) abbrev = unicode(self.abbrev.get_text())
note = unicode(
self.notes_buffer.get_text(self.notes_buffer.get_start_iter(),
self.notes_buffer.get_end_iter(),
False))
format = self.preform.get_active()
if author != self.source.get_author(): if author != self.source.get_author():
self.source.set_author(author) self.source.set_author(author)
@ -310,31 +309,7 @@ class EditSource(DisplayState.ManagedWindow):
if abbrev != self.source.get_abbreviation(): if abbrev != self.source.get_abbreviation():
self.source.set_abbreviation(abbrev) self.source.set_abbreviation(abbrev)
if note != self.source.get_note():
self.source.set_note(note)
if format != self.source.get_note_format():
self.source.set_note_format(format)
new_map = {}
for val in range(0,len(self.data_model)):
node = self.data_model.get_iter(val)
key = self.data_model.get_value(node,0)
value = self.data_model.get_value(node,1)
if key:
new_map[unicode(key)] = unicode(value)
if new_map != self.source.get_data_map():
self.source.set_data_map(new_map)
# update repository refs
repos_ref_list = []
for val in range(0,len(self.repos_ref_model)):
iter = self.repos_ref_model.get_iter(val)
repos_ref_list.append(self.repos_ref_model.get_value(iter,0))
self.source.set_reporef_list(repos_ref_list)
trans = self.db.transaction_begin() trans = self.db.transaction_begin()
if self.source.get_handle() == None: if self.source.get_handle() == None:
self.db.add_source(self.source,trans) self.db.add_source(self.source,trans)
@ -343,7 +318,6 @@ class EditSource(DisplayState.ManagedWindow):
self.db.transaction_commit(trans,_("Edit Source (%s)") % title) self.db.transaction_commit(trans,_("Edit Source (%s)") % title)
self.close(obj) self.close(obj)
class DelSrcQuery: class DelSrcQuery:
def __init__(self,source,db,the_lists): def __init__(self,source,db,the_lists):
self.source = source self.source = source

View File

@ -811,7 +811,7 @@ class GedcomParser:
self.parse_repository(self.repo) self.parse_repository(self.repo)
self.db.commit_repository(self.repo, self.trans) self.db.commit_repository(self.repo, self.trans)
del self.repo del self.repo
elif matches[2] in ["SUBM","SUBN","REPO"]: elif matches[2] in ("SUBM","SUBN"):
self.ignore_sub_junk(1) self.ignore_sub_junk(1)
elif matches[1] in (TOKEN_SUBM,TOKEN_SUBN,TOKEN_OBJE,TOKEN__EVENT_DEFN): elif matches[1] in (TOKEN_SUBM,TOKEN_SUBN,TOKEN_OBJE,TOKEN__EVENT_DEFN):
self.ignore_sub_junk(1) self.ignore_sub_junk(1)

File diff suppressed because it is too large Load Diff

View File

@ -36,7 +36,6 @@ import gc
import gtk import gtk
import gtk.glade import gtk.glade
from gtk.gdk import ACTION_COPY, BUTTON1_MASK, INTERP_BILINEAR, pixbuf_new_from_file from gtk.gdk import ACTION_COPY, BUTTON1_MASK, INTERP_BILINEAR, pixbuf_new_from_file
from gobject import TYPE_PYOBJECT
import cPickle as pickle import cPickle as pickle
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -217,7 +216,7 @@ class SourceTab:
self.window = window self.window = window
self.slist = clist self.slist = clist
self.selection = clist.get_selection() self.selection = clist.get_selection()
self.model = gtk.ListStore(str,str,TYPE_PYOBJECT) self.model = gtk.ListStore(str,str,object)
self.readonly = readonly self.readonly = readonly
add_btn.set_sensitive(not readonly) add_btn.set_sensitive(not readonly)

View File

@ -1118,6 +1118,23 @@ def get_type_converter_by_name(val_str):
return unicode return unicode
return unicode return unicode
def relative_path(original, base):
if not os.path.exists(original) or not os.path.isdir(base):
return original
base_list = (os.path.abspath(base)).split(os.sep)
target_list = (os.path.abspath(original)).split(os.sep)
# Starting from the filepath root, work out how much of the filepath is
# shared by base and target.
for i in range(min(len(base_list), len(target_list))):
if base_list[i] <> target_list[i]: break
else:
i+=1
rel_list = [os.pardir] * (len(base_list)-i) + target_list[i:]
return os.path.join(*rel_list)
class ProgressMeter: class ProgressMeter:
""" """
Progress meter class for GRAMPS. Progress meter class for GRAMPS.

View File

@ -715,6 +715,11 @@ class ViewManager:
_('You do not have write access ' _('You do not have write access '
'to the selected file.')) 'to the selected file.'))
try:
os.chdir(os.path.dirname(filename))
except:
print "could not change directory"
try: try:
if self.load_database(filename,callback,mode=mode): if self.load_database(filename,callback,mode=mode):
if filename[-1] == '/': if filename[-1] == '/':

View File

@ -9,7 +9,7 @@
<property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property> <property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property> <property name="modal">False</property>
<property name="default_height">600</property> <property name="default_height">500</property>
<property name="resizable">True</property> <property name="resizable">True</property>
<property name="destroy_with_parent">False</property> <property name="destroy_with_parent">False</property>
<property name="icon">gramps.png</property> <property name="icon">gramps.png</property>

View File

@ -1353,7 +1353,7 @@
<widget class="GtkEntry" id="gid"> <widget class="GtkEntry" id="gid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="editable">False</property> <property name="editable">True</property>
<property name="visibility">True</property> <property name="visibility">True</property>
<property name="max_length">0</property> <property name="max_length">0</property>
<property name="text" translatable="yes"></property> <property name="text" translatable="yes"></property>
@ -9668,7 +9668,7 @@ Very High</property>
<widget class="GtkTable" id="table51"> <widget class="GtkTable" id="table51">
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="n_rows">2</property> <property name="n_rows">3</property>
<property name="n_columns">2</property> <property name="n_columns">2</property>
<property name="homogeneous">False</property> <property name="homogeneous">False</property>
<property name="row_spacing">6</property> <property name="row_spacing">6</property>
@ -9736,6 +9736,28 @@ Very High</property>
<property name="inconsistent">False</property> <property name="inconsistent">False</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
</widget> </widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="relpath">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Convert to a relative path</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>
@ -14216,6 +14238,7 @@ Very High</property>
<property name="window_position">GTK_WIN_POS_NONE</property> <property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property> <property name="modal">False</property>
<property name="default_width">600</property> <property name="default_width">600</property>
<property name="default_height">450</property>
<property name="resizable">True</property> <property name="resizable">True</property>
<property name="destroy_with_parent">False</property> <property name="destroy_with_parent">False</property>
<property name="icon">gramps.png</property> <property name="icon">gramps.png</property>
@ -14293,7 +14316,7 @@ Very High</property>
</child> </child>
<child> <child>
<widget class="GtkVBox" id="vbox35"> <widget class="GtkVBox" id="vbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="homogeneous">False</property> <property name="homogeneous">False</property>
<property name="spacing">0</property> <property name="spacing">0</property>
@ -14735,427 +14758,7 @@ Very High</property>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>
<property name="expand">True</property> <property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkNotebook" id="notebook2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="show_tabs">True</property>
<property name="show_border">True</property>
<property name="tab_pos">GTK_POS_TOP</property>
<property name="scrollable">False</property>
<property name="enable_popup">False</property>
<signal name="switch_page" handler="on_switch_page" last_modification_time="Wed, 12 Nov 2003 18:09:04 GMT"/>
<child>
<widget class="GtkVBox" id="vbox40">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkHBox" id="hbox40">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow27">
<property name="visible">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="slist">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">False</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox48">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkButton" id="add_src">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<child>
<widget class="GtkImage" id="image2356">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="edit_src">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<child>
<widget class="GtkImage" id="image2357">
<property name="visible">True</property>
<property name="pixbuf">edit_sm.png</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="del_src">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<child>
<widget class="GtkImage" id="image2358">
<property name="visible">True</property>
<property name="stock">gtk-remove</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox3">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_SPREAD</property>
<property name="spacing">30</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="sources_tab">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkImage" id="image2581">
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="sourcesAddr">
<property name="visible">True</property>
<property name="label" translatable="yes">Sources</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox52">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow24">
<property name="height_request">350</property>
<property name="visible">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="addr_note">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkTable" id="table33">
<property name="border_width">12</property>
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">3</property>
<property name="homogeneous">False</property>
<property name="row_spacing">12</property>
<property name="column_spacing">24</property>
<child>
<widget class="GtkLabel" id="label302">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Format&lt;/b&gt;</property>
<property name="use_underline">True</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">3</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="addr_flowed">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Multiple spaces, tabs, and single line breaks are replaced with single spaces. Two consecutive line breaks mark a new paragraph.</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Flowed</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">True</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="addr_preform">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Formatting is preserved, except for the leading whitespace. Multiple spaces, tabs, and all line breaks are respected.</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Preformatted</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">addr_flowed</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="note_tab">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkImage" id="image2582">
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="noteAddr">
<property name="visible">True</property>
<property name="label" translatable="yes">Note</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
</packing> </packing>
</child> </child>