2008-02-08 Raphael Ackermann <raphael.ackermann@gmail.com>
* src/Editors/_EditEvent.py: * src/Editors/_EditFamily.py: * src/Editors/_EditMedia.py: * src/Editors/_EditNote.py: * src/Editors/_EditPlace.py: * src/Editors/_EditPrimary.py: * src/Editors/_EditRepository.py: * src/Editors/_EditSource.py: pylint fixes svn: r10005
This commit is contained in:
13
ChangeLog
13
ChangeLog
@ -1,4 +1,15 @@
|
|||||||
2008-02-07 Raphael Ackermann <raphael.ackermann@gmail.com>
|
2008-02-08 Raphael Ackermann <raphael.ackermann@gmail.com>
|
||||||
|
* src/Editors/_EditEvent.py:
|
||||||
|
* src/Editors/_EditFamily.py:
|
||||||
|
* src/Editors/_EditMedia.py:
|
||||||
|
* src/Editors/_EditNote.py:
|
||||||
|
* src/Editors/_EditPlace.py:
|
||||||
|
* src/Editors/_EditPrimary.py:
|
||||||
|
* src/Editors/_EditRepository.py:
|
||||||
|
* src/Editors/_EditSource.py:
|
||||||
|
pylint fixes
|
||||||
|
|
||||||
|
2008-02-08 Raphael Ackermann <raphael.ackermann@gmail.com>
|
||||||
* src/Editors/_EditEvent.py:
|
* src/Editors/_EditEvent.py:
|
||||||
* src/Editors/_EditFamily.py:
|
* src/Editors/_EditFamily.py:
|
||||||
* src/Editors/_EditMedia.py:
|
* src/Editors/_EditMedia.py:
|
||||||
|
@ -33,6 +33,7 @@ from gettext import gettext as _
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gtk
|
import gtk
|
||||||
|
from gtk import glade
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -43,11 +44,13 @@ import const
|
|||||||
import Config
|
import Config
|
||||||
import gen.lib
|
import gen.lib
|
||||||
import GrampsDisplay
|
import GrampsDisplay
|
||||||
from _EditPrimary import EditPrimary
|
from Editors import EditPrimary
|
||||||
|
|
||||||
from QuestionDialog import ErrorDialog
|
from QuestionDialog import ErrorDialog
|
||||||
from DisplayTabs import SourceEmbedList, NoteTab, GalleryTab, EventBackRefList, AttrEmbedList
|
from DisplayTabs import (SourceEmbedList, NoteTab, GalleryTab,
|
||||||
from GrampsWidgets import *
|
EventBackRefList, AttrEmbedList)
|
||||||
|
from GrampsWidgets import (MonitoredEntry, PlaceEntry, PrivacyButton,
|
||||||
|
MonitoredDataType, MonitoredDate)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -62,7 +65,7 @@ from GrampsWidgets import *
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class EditEvent(EditPrimary):
|
class EditEvent(EditPrimary):
|
||||||
|
|
||||||
def __init__(self,dbstate,uistate,track,event,callback=None):
|
def __init__(self, dbstate, uistate, track, event, callback=None):
|
||||||
|
|
||||||
EditPrimary.__init__(self, dbstate, uistate, track,
|
EditPrimary.__init__(self, dbstate, uistate, track,
|
||||||
event, dbstate.db.get_event_from_handle)
|
event, dbstate.db.get_event_from_handle)
|
||||||
@ -90,7 +93,7 @@ class EditEvent(EditPrimary):
|
|||||||
self.dbstate.db.get_family_event_types()
|
self.dbstate.db.get_family_event_types()
|
||||||
|
|
||||||
def _local_init(self):
|
def _local_init(self):
|
||||||
self.top = gtk.glade.XML(const.GLADE_FILE, "event_edit","gramps")
|
self.top = glade.XML(const.GLADE_FILE, "event_edit","gramps")
|
||||||
self.set_window(self.top.get_widget("event_edit"), None,
|
self.set_window(self.top.get_widget("event_edit"), None,
|
||||||
self.get_menu_title())
|
self.get_menu_title())
|
||||||
|
|
||||||
@ -103,12 +106,12 @@ class EditEvent(EditPrimary):
|
|||||||
self.window.resize(width, height)
|
self.window.resize(width, height)
|
||||||
|
|
||||||
def _connect_signals(self):
|
def _connect_signals(self):
|
||||||
self.top.get_widget('button111').connect('clicked',self.close)
|
self.top.get_widget('button111').connect('clicked', self.close)
|
||||||
self.top.get_widget('button126').connect('clicked',self.help_clicked)
|
self.top.get_widget('button126').connect('clicked', self.help_clicked)
|
||||||
|
|
||||||
self.ok_button = self.top.get_widget('ok')
|
self.ok_button = self.top.get_widget('ok')
|
||||||
self.ok_button.set_sensitive(not self.db.readonly)
|
self.ok_button.set_sensitive(not self.db.readonly)
|
||||||
self.ok_button.connect('clicked',self.save)
|
self.ok_button.connect('clicked', self.save)
|
||||||
|
|
||||||
def _setup_fields(self):
|
def _setup_fields(self):
|
||||||
|
|
||||||
@ -187,7 +190,7 @@ class EditEvent(EditPrimary):
|
|||||||
self._setup_notebook_tabs( notebook)
|
self._setup_notebook_tabs( notebook)
|
||||||
|
|
||||||
notebook.show_all()
|
notebook.show_all()
|
||||||
self.top.get_widget('vbox').pack_start(notebook,True)
|
self.top.get_widget('vbox').pack_start(notebook, True)
|
||||||
|
|
||||||
def _cleanup_on_exit(self):
|
def _cleanup_on_exit(self):
|
||||||
self.backref_tab.close()
|
self.backref_tab.close()
|
||||||
@ -196,14 +199,14 @@ class EditEvent(EditPrimary):
|
|||||||
Config.set(Config.EVENT_HEIGHT, height)
|
Config.set(Config.EVENT_HEIGHT, height)
|
||||||
Config.sync()
|
Config.sync()
|
||||||
|
|
||||||
def build_menu_names(self,event):
|
def build_menu_names(self, event):
|
||||||
return (_('Edit Event'), self.get_menu_title())
|
return (_('Edit Event'), self.get_menu_title())
|
||||||
|
|
||||||
def help_clicked(self,obj):
|
def help_clicked(self, obj):
|
||||||
"""Display the relevant portion of GRAMPS manual"""
|
"""Display the relevant portion of GRAMPS manual"""
|
||||||
GrampsDisplay.help('adv-ev')
|
GrampsDisplay.help('adv-ev')
|
||||||
|
|
||||||
def save(self,*obj):
|
def save(self, *obj):
|
||||||
self.ok_button.set_sensitive(False)
|
self.ok_button.set_sensitive(False)
|
||||||
if self.object_is_empty():
|
if self.object_is_empty():
|
||||||
ErrorDialog(_("Cannot save event"),
|
ErrorDialog(_("Cannot save event"),
|
||||||
@ -226,12 +229,12 @@ class EditEvent(EditPrimary):
|
|||||||
self.db.transaction_commit(trans, _("Add Event"))
|
self.db.transaction_commit(trans, _("Add Event"))
|
||||||
else:
|
else:
|
||||||
orig = self.get_from_handle(self.obj.handle)
|
orig = self.get_from_handle(self.obj.handle)
|
||||||
if cmp(self.obj.serialize(),orig.serialize()):
|
if cmp(self.obj.serialize(), orig.serialize()):
|
||||||
trans = self.db.transaction_begin()
|
trans = self.db.transaction_begin()
|
||||||
if not self.obj.get_gramps_id():
|
if not self.obj.get_gramps_id():
|
||||||
self.obj.set_gramps_id(self.db.find_next_event_gramps_id())
|
self.obj.set_gramps_id(self.db.find_next_event_gramps_id())
|
||||||
self.commit_event(self.obj,trans)
|
self.commit_event(self.obj, trans)
|
||||||
self.db.transaction_commit(trans,_("Edit Event"))
|
self.db.transaction_commit(trans, _("Edit Event"))
|
||||||
|
|
||||||
if self.callback:
|
if self.callback:
|
||||||
self.callback(self.obj)
|
self.callback(self.obj)
|
||||||
@ -289,7 +292,7 @@ class EditFamilyEvent(EditEvent):
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class DelEventQuery:
|
class DelEventQuery:
|
||||||
def __init__(self,dbstate,uistate,event,person_list,family_list):
|
def __init__(self, dbstate, uistate, event, person_list, family_list):
|
||||||
self.event = event
|
self.event = event
|
||||||
self.db = dbstate.db
|
self.db = dbstate.db
|
||||||
self.uistate = uistate
|
self.uistate = uistate
|
||||||
@ -304,15 +307,15 @@ class DelEventQuery:
|
|||||||
|
|
||||||
for handle in self.person_list:
|
for handle in self.person_list:
|
||||||
person = self.db.get_person_from_handle(handle)
|
person = self.db.get_person_from_handle(handle)
|
||||||
person.remove_handle_references('Event',ev_handle_list)
|
person.remove_handle_references('Event', ev_handle_list)
|
||||||
self.db.commit_person(person,trans)
|
self.db.commit_person(person, trans)
|
||||||
|
|
||||||
for handle in self.family_list:
|
for handle in self.family_list:
|
||||||
family = self.db.get_family_from_handle(handle)
|
family = self.db.get_family_from_handle(handle)
|
||||||
family.remove_handle_references('Event',ev_handle_list)
|
family.remove_handle_references('Event', ev_handle_list)
|
||||||
self.db.commit_family(family,trans)
|
self.db.commit_family(family, trans)
|
||||||
|
|
||||||
self.db.enable_signals()
|
self.db.enable_signals()
|
||||||
self.db.remove_event(self.event.get_handle(),trans)
|
self.db.remove_event(self.event.get_handle(), trans)
|
||||||
self.db.transaction_commit(
|
self.db.transaction_commit(
|
||||||
trans,_("Delete Event (%s)") % self.event.get_gramps_id())
|
trans,_("Delete Event (%s)") % self.event.get_gramps_id())
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from bsddb import db as bsddb_db
|
from bsddb import db as bsddb_db
|
||||||
|
from gettext import gettext as _
|
||||||
|
from DdTargets import DdTargets
|
||||||
|
import pickle
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# enable logging for error handling
|
# enable logging for error handling
|
||||||
@ -39,7 +42,9 @@ log = logging.getLogger(".")
|
|||||||
# GTK/Gnome modules
|
# GTK/Gnome modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
import gtk
|
||||||
from gtk import glade
|
from gtk import glade
|
||||||
|
from gtk import gdk
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -47,26 +52,27 @@ from gtk import glade
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import Utils
|
import Utils
|
||||||
|
import const
|
||||||
|
import Config
|
||||||
from BasicUtils import name_displayer
|
from BasicUtils import name_displayer
|
||||||
import gen.lib
|
import gen.lib
|
||||||
import Errors
|
import Errors
|
||||||
|
|
||||||
from _EditPrimary import EditPrimary
|
from Editors import EditPrimary
|
||||||
from ReportBase import ReportUtils
|
from ReportBase import ReportUtils
|
||||||
from DisplayTabs import \
|
from DisplayTabs import (EmbeddedList, EventEmbedList, SourceEmbedList,
|
||||||
EmbeddedList,EventEmbedList,SourceEmbedList,FamilyAttrEmbedList,\
|
FamilyAttrEmbedList, NoteTab, GalleryTab,
|
||||||
NoteTab,GalleryTab,FamilyLdsEmbedList, ChildModel
|
FamilyLdsEmbedList, ChildModel)
|
||||||
from GrampsWidgets import *
|
from GrampsWidgets import (PrivacyButton, MonitoredEntry, MonitoredDataType,
|
||||||
|
IconButton, LinkBox, BasicLabel)
|
||||||
from ReportBase import CATEGORY_QR_FAMILY
|
from ReportBase import CATEGORY_QR_FAMILY
|
||||||
import QuestionDialog
|
import QuestionDialog
|
||||||
|
|
||||||
#from ObjectSelector import PersonSelector,PersonFilterSpec
|
|
||||||
|
|
||||||
from Selectors import selector_factory
|
from Selectors import selector_factory
|
||||||
SelectPerson = selector_factory('Person')
|
SelectPerson = selector_factory('Person')
|
||||||
|
|
||||||
_RETURN = gtk.gdk.keyval_from_name("Return")
|
_RETURN = gdk.keyval_from_name("Return")
|
||||||
_KP_ENTER = gtk.gdk.keyval_from_name("KP_Enter")
|
_KP_ENTER = gdk.keyval_from_name("KP_Enter")
|
||||||
|
|
||||||
class ChildEmbedList(EmbeddedList):
|
class ChildEmbedList(EmbeddedList):
|
||||||
"""
|
"""
|
||||||
@ -116,33 +122,33 @@ class ChildEmbedList(EmbeddedList):
|
|||||||
(True, True, gtk.STOCK_REMOVE, self.del_button_clicked),
|
(True, True, gtk.STOCK_REMOVE, self.del_button_clicked),
|
||||||
]
|
]
|
||||||
|
|
||||||
def find_index(self,obj):
|
def find_index(self, obj):
|
||||||
"""
|
"""
|
||||||
returns the index of the object within the associated data
|
returns the index of the object within the associated data
|
||||||
"""
|
"""
|
||||||
reflist = [ref.ref for ref in self.family.get_child_ref_list()]
|
reflist = [ref.ref for ref in self.family.get_child_ref_list()]
|
||||||
return reflist.index(obj)
|
return reflist.index(obj)
|
||||||
|
|
||||||
def _find_row(self,x,y):
|
def _find_row(self, x, y):
|
||||||
row = self.tree.get_path_at_pos(x,y)
|
row = self.tree.get_path_at_pos(x, y)
|
||||||
if row == None:
|
if row == None:
|
||||||
return len(self.family.get_child_ref_list())
|
return len(self.family.get_child_ref_list())
|
||||||
else:
|
else:
|
||||||
return row[0][0]
|
return row[0][0]
|
||||||
|
|
||||||
def _handle_drag(self, row, obj):
|
def _handle_drag(self, row, obj):
|
||||||
self.family.get_child_ref_list().insert(row,obj)
|
self.family.get_child_ref_list().insert(row, obj)
|
||||||
self.changed = True
|
self.changed = True
|
||||||
self.rebuild()
|
self.rebuild()
|
||||||
|
|
||||||
def _move(self, row_from, row_to, obj):
|
def _move(self, row_from, row_to, obj):
|
||||||
dlist = self.family.get_child_ref_list()
|
dlist = self.family.get_child_ref_list()
|
||||||
if row_from < row_to:
|
if row_from < row_to:
|
||||||
dlist.insert(row_to,obj)
|
dlist.insert(row_to, obj)
|
||||||
del dlist[row_from]
|
del dlist[row_from]
|
||||||
else:
|
else:
|
||||||
del dlist[row_from]
|
del dlist[row_from]
|
||||||
dlist.insert(row_to-1,obj)
|
dlist.insert(row_to-1, obj)
|
||||||
self.changed = True
|
self.changed = True
|
||||||
self.rebuild()
|
self.rebuild()
|
||||||
|
|
||||||
@ -187,9 +193,10 @@ class ChildEmbedList(EmbeddedList):
|
|||||||
return self.family
|
return self.family
|
||||||
|
|
||||||
def column_order(self):
|
def column_order(self):
|
||||||
return [(1,0),(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(0,8),(0,9)]
|
return [(1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6),
|
||||||
|
(0, 8), (0, 9)]
|
||||||
|
|
||||||
def add_button_clicked(self,obj):
|
def add_button_clicked(self, obj):
|
||||||
from Editors import EditPerson
|
from Editors import EditPerson
|
||||||
person = gen.lib.Person()
|
person = gen.lib.Person()
|
||||||
autoname = Config.get(Config.SURNAME_GUESSING)
|
autoname = Config.get(Config.SURNAME_GUESSING)
|
||||||
@ -206,7 +213,7 @@ class ChildEmbedList(EmbeddedList):
|
|||||||
person.get_primary_name().set_surname(name[1])
|
person.get_primary_name().set_surname(name[1])
|
||||||
person.get_primary_name().set_surname_prefix(name[0])
|
person.get_primary_name().set_surname_prefix(name[0])
|
||||||
|
|
||||||
EditPerson(self.dbstate, self.uistate, self.track,person,
|
EditPerson(self.dbstate, self.uistate, self.track, person,
|
||||||
self.new_child_added)
|
self.new_child_added)
|
||||||
|
|
||||||
def new_child_added(self, person):
|
def new_child_added(self, person):
|
||||||
@ -219,7 +226,7 @@ class ChildEmbedList(EmbeddedList):
|
|||||||
def child_ref_edited(self, person):
|
def child_ref_edited(self, person):
|
||||||
self.rebuild()
|
self.rebuild()
|
||||||
|
|
||||||
def share_button_clicked(self,obj):
|
def share_button_clicked(self, obj):
|
||||||
# it only makes sense to skip those who are already in the family
|
# it only makes sense to skip those who are already in the family
|
||||||
|
|
||||||
skip_list = [self.family.get_father_handle(), \
|
skip_list = [self.family.get_father_handle(), \
|
||||||
@ -237,12 +244,12 @@ class ChildEmbedList(EmbeddedList):
|
|||||||
self.rebuild()
|
self.rebuild()
|
||||||
self.call_edit_childref(ref.ref)
|
self.call_edit_childref(ref.ref)
|
||||||
|
|
||||||
def run(self,skip):
|
def run(self, skip):
|
||||||
skip_list = [ x for x in skip if x]
|
skip_list = [ x for x in skip if x]
|
||||||
SelectPerson(self.dbstate, self.uistate, self.track,
|
SelectPerson(self.dbstate, self.uistate, self.track,
|
||||||
_("Select Child"), skip=skip_list)
|
_("Select Child"), skip=skip_list)
|
||||||
|
|
||||||
def del_button_clicked(self,obj):
|
def del_button_clicked(self, obj):
|
||||||
handle = self.get_selected()
|
handle = self.get_selected()
|
||||||
if handle:
|
if handle:
|
||||||
for ref in self.family.get_child_ref_list():
|
for ref in self.family.get_child_ref_list():
|
||||||
@ -250,7 +257,7 @@ class ChildEmbedList(EmbeddedList):
|
|||||||
self.family.remove_child_ref(ref)
|
self.family.remove_child_ref(ref)
|
||||||
self.rebuild()
|
self.rebuild()
|
||||||
|
|
||||||
def edit_button_clicked(self,obj):
|
def edit_button_clicked(self, obj):
|
||||||
handle = self.get_selected()
|
handle = self.get_selected()
|
||||||
if handle:
|
if handle:
|
||||||
self.call_edit_childref(handle)
|
self.call_edit_childref(handle)
|
||||||
@ -289,16 +296,16 @@ class ChildEmbedList(EmbeddedList):
|
|||||||
if handle:
|
if handle:
|
||||||
pos = self.find_index(handle)
|
pos = self.find_index(handle)
|
||||||
if pos > 0 :
|
if pos > 0 :
|
||||||
self._move_up(pos,self.family.get_child_ref_list()[pos]
|
self._move_up(pos,self.family.get_child_ref_list()[pos],
|
||||||
,selmethod=self.family.get_child_ref_list)
|
selmethod=self.family.get_child_ref_list)
|
||||||
|
|
||||||
def down_button_clicked(self, obj):
|
def down_button_clicked(self, obj):
|
||||||
ref = self.get_selected()
|
ref = self.get_selected()
|
||||||
if ref:
|
if ref:
|
||||||
pos = self.find_index(ref)
|
pos = self.find_index(ref)
|
||||||
if pos >=0 and pos < len(self.family.get_child_ref_list())-1:
|
if pos >=0 and pos < len(self.family.get_child_ref_list())-1:
|
||||||
self._move_down(pos,self.family.get_child_ref_list()[pos]
|
self._move_down(pos,self.family.get_child_ref_list()[pos],
|
||||||
,selmethod=self.family.get_child_ref_list)
|
selmethod=self.family.get_child_ref_list)
|
||||||
|
|
||||||
|
|
||||||
def drag_data_received(self, widget, context, x, y, sel_data, info, time):
|
def drag_data_received(self, widget, context, x, y, sel_data, info, time):
|
||||||
@ -337,7 +344,7 @@ class ChildEmbedList(EmbeddedList):
|
|||||||
if father_handle:
|
if father_handle:
|
||||||
father = self.dbstate.db.get_person_from_handle(father_handle)
|
father = self.dbstate.db.get_person_from_handle(father_handle)
|
||||||
pname = father.get_primary_name()
|
pname = father.get_primary_name()
|
||||||
return (pname.get_surname_prefix(),pname.get_surname())
|
return (pname.get_surname_prefix(), pname.get_surname())
|
||||||
return ("","")
|
return ("","")
|
||||||
|
|
||||||
def no_name(self):
|
def no_name(self):
|
||||||
@ -356,27 +363,27 @@ class ChildEmbedList(EmbeddedList):
|
|||||||
fsn = father.get_primary_name().get_surname()
|
fsn = father.get_primary_name().get_surname()
|
||||||
msn = mother.get_primary_name().get_surname()
|
msn = mother.get_primary_name().get_surname()
|
||||||
try:
|
try:
|
||||||
return ("","%s %s" % (fsn.split()[0],msn.split()[0]))
|
return ("", "%s %s" % (fsn.split()[0], msn.split()[0]))
|
||||||
except:
|
except:
|
||||||
return ("","")
|
return ("", "")
|
||||||
else:
|
else:
|
||||||
return ("","")
|
return ("", "")
|
||||||
|
|
||||||
class FastMaleFilter:
|
class FastMaleFilter:
|
||||||
|
|
||||||
def __init__(self,db):
|
def __init__(self, db):
|
||||||
self.db = db
|
self.db = db
|
||||||
|
|
||||||
def match(self, handle,db):
|
def match(self, handle, db):
|
||||||
value = self.db.get_raw_person_data(handle)
|
value = self.db.get_raw_person_data(handle)
|
||||||
return value[2] == gen.lib.Person.MALE
|
return value[2] == gen.lib.Person.MALE
|
||||||
|
|
||||||
class FastFemaleFilter:
|
class FastFemaleFilter:
|
||||||
|
|
||||||
def __init__(self,db):
|
def __init__(self, db):
|
||||||
self.db = db
|
self.db = db
|
||||||
|
|
||||||
def match(self, handle,db):
|
def match(self, handle, db):
|
||||||
value = self.db.get_raw_person_data(handle)
|
value = self.db.get_raw_person_data(handle)
|
||||||
return value[2] == gen.lib.Person.FEMALE
|
return value[2] == gen.lib.Person.FEMALE
|
||||||
|
|
||||||
@ -389,7 +396,7 @@ class EditFamily(EditPrimary):
|
|||||||
|
|
||||||
QR_CATEGORY = CATEGORY_QR_FAMILY
|
QR_CATEGORY = CATEGORY_QR_FAMILY
|
||||||
|
|
||||||
def __init__(self,dbstate, uistate, track, family):
|
def __init__(self, dbstate, uistate, track, family):
|
||||||
|
|
||||||
self.tooltips = gtk.Tooltips()
|
self.tooltips = gtk.Tooltips()
|
||||||
EditPrimary.__init__(self, dbstate, uistate, track,
|
EditPrimary.__init__(self, dbstate, uistate, track,
|
||||||
@ -482,12 +489,12 @@ class EditFamily(EditPrimary):
|
|||||||
dialog_title = _("New Family")
|
dialog_title = _("New Family")
|
||||||
return dialog_title
|
return dialog_title
|
||||||
|
|
||||||
def build_menu_names(self,family):
|
def build_menu_names(self, family):
|
||||||
return (_('Edit Family'), self.get_menu_title())
|
return (_('Edit Family'), self.get_menu_title())
|
||||||
|
|
||||||
def build_interface(self):
|
def build_interface(self):
|
||||||
|
|
||||||
self.top = glade.XML(const.GLADE_FILE,"family_editor","gramps")
|
self.top = glade.XML(const.GLADE_FILE, "family_editor", "gramps")
|
||||||
|
|
||||||
self.set_window(self.top.get_widget("family_editor"), None, self.get_menu_title())
|
self.set_window(self.top.get_widget("family_editor"), None, self.get_menu_title())
|
||||||
|
|
||||||
@ -503,9 +510,9 @@ class EditFamily(EditPrimary):
|
|||||||
self.mdeath = self.top.get_widget('mdeath')
|
self.mdeath = self.top.get_widget('mdeath')
|
||||||
|
|
||||||
self.mbutton = self.top.get_widget('mbutton')
|
self.mbutton = self.top.get_widget('mbutton')
|
||||||
self.mbutton2= self.top.get_widget('mbutton2')
|
self.mbutton2 = self.top.get_widget('mbutton2')
|
||||||
self.fbutton = self.top.get_widget('fbutton')
|
self.fbutton = self.top.get_widget('fbutton')
|
||||||
self.fbutton2= self.top.get_widget('fbutton2')
|
self.fbutton2 = self.top.get_widget('fbutton2')
|
||||||
|
|
||||||
self.tooltips.set_tip(self.mbutton2,
|
self.tooltips.set_tip(self.mbutton2,
|
||||||
_("Add a new person as the mother"))
|
_("Add a new person as the mother"))
|
||||||
@ -527,7 +534,7 @@ class EditFamily(EditPrimary):
|
|||||||
|
|
||||||
def _setup_fields(self):
|
def _setup_fields(self):
|
||||||
|
|
||||||
self.private= PrivacyButton(
|
self.private = PrivacyButton(
|
||||||
self.top.get_widget('private'),
|
self.top.get_widget('private'),
|
||||||
self.obj,
|
self.obj,
|
||||||
self.db.readonly)
|
self.db.readonly)
|
||||||
@ -566,10 +573,10 @@ class EditFamily(EditPrimary):
|
|||||||
|
|
||||||
self.phandles = [handle for handle in self.phandles if handle]
|
self.phandles = [handle for handle in self.phandles if handle]
|
||||||
|
|
||||||
self.mbutton.connect('clicked',self.mother_clicked)
|
self.mbutton.connect('clicked', self.mother_clicked)
|
||||||
self.mbutton2.connect('clicked',self.add_mother_clicked)
|
self.mbutton2.connect('clicked', self.add_mother_clicked)
|
||||||
self.fbutton.connect('clicked',self.father_clicked)
|
self.fbutton.connect('clicked', self.father_clicked)
|
||||||
self.fbutton2.connect('clicked',self.add_father_clicked)
|
self.fbutton2.connect('clicked', self.add_father_clicked)
|
||||||
|
|
||||||
def _create_tabbed_pages(self):
|
def _create_tabbed_pages(self):
|
||||||
|
|
||||||
@ -579,13 +586,16 @@ class EditFamily(EditPrimary):
|
|||||||
notebook,
|
notebook,
|
||||||
ChildEmbedList(self.dbstate,self.uistate, self.track, self.obj))
|
ChildEmbedList(self.dbstate,self.uistate, self.track, self.obj))
|
||||||
|
|
||||||
self.event_embed = EventEmbedList(self.dbstate,self.uistate, self.track,self.obj)
|
self.event_embed = EventEmbedList(self.dbstate, self.uistate,
|
||||||
|
self.track,self.obj)
|
||||||
self.event_list = self._add_tab(notebook, self.event_embed)
|
self.event_list = self._add_tab(notebook, self.event_embed)
|
||||||
|
|
||||||
self.source_embed = SourceEmbedList(self.dbstate,self.uistate,self.track,self.obj)
|
self.source_embed = SourceEmbedList(self.dbstate, self.uistate,
|
||||||
|
self.track, self.obj)
|
||||||
self.src_list = self._add_tab(notebook, self.source_embed)
|
self.src_list = self._add_tab(notebook, self.source_embed)
|
||||||
|
|
||||||
self.attr_embed = FamilyAttrEmbedList(self.dbstate, self.uistate, self.track,
|
self.attr_embed = FamilyAttrEmbedList(self.dbstate, self.uistate,
|
||||||
|
self.track,
|
||||||
self.obj.get_attribute_list())
|
self.obj.get_attribute_list())
|
||||||
self.attr_list = self._add_tab(notebook, self.attr_embed)
|
self.attr_list = self._add_tab(notebook, self.attr_embed)
|
||||||
|
|
||||||
@ -600,7 +610,8 @@ class EditFamily(EditPrimary):
|
|||||||
GalleryTab(self.dbstate, self.uistate, self.track,
|
GalleryTab(self.dbstate, self.uistate, self.track,
|
||||||
self.obj.get_media_list()))
|
self.obj.get_media_list()))
|
||||||
|
|
||||||
self.lds_embed = FamilyLdsEmbedList(self.dbstate, self.uistate, self.track,
|
self.lds_embed = FamilyLdsEmbedList(self.dbstate, self.uistate,
|
||||||
|
self.track,
|
||||||
self.obj.get_lds_ord_list())
|
self.obj.get_lds_ord_list())
|
||||||
self.lds_list = self._add_tab(notebook, self.lds_embed)
|
self.lds_list = self._add_tab(notebook, self.lds_embed)
|
||||||
|
|
||||||
@ -608,15 +619,15 @@ class EditFamily(EditPrimary):
|
|||||||
notebook.show_all()
|
notebook.show_all()
|
||||||
|
|
||||||
self.hidden = (notebook, self.top.get_widget('info'))
|
self.hidden = (notebook, self.top.get_widget('info'))
|
||||||
self.top.get_widget('vbox').pack_start(notebook,True)
|
self.top.get_widget('vbox').pack_start(notebook, True)
|
||||||
|
|
||||||
def update_father(self,handle):
|
def update_father(self, handle):
|
||||||
self.load_parent(handle, self.fbox, self.fbirth,
|
self.load_parent(handle, self.fbox, self.fbirth,
|
||||||
self.fdeath, self.fbutton, self.fbutton2,
|
self.fdeath, self.fbutton, self.fbutton2,
|
||||||
_("Select a person as the father"),
|
_("Select a person as the father"),
|
||||||
_("Remove the person as the father"))
|
_("Remove the person as the father"))
|
||||||
|
|
||||||
def update_mother(self,handle):
|
def update_mother(self, handle):
|
||||||
self.load_parent(handle, self.mbox, self.mbirth,
|
self.load_parent(handle, self.mbox, self.mbirth,
|
||||||
self.mdeath, self.mbutton, self.mbutton2,
|
self.mdeath, self.mbutton, self.mbutton2,
|
||||||
_("Select a person as the mother"),
|
_("Select a person as the mother"),
|
||||||
@ -762,7 +773,7 @@ class EditFamily(EditPrimary):
|
|||||||
'you cancel the editing of this window, and '
|
'you cancel the editing of this window, and '
|
||||||
'select the existing family'))
|
'select the existing family'))
|
||||||
|
|
||||||
def edit_person(self,obj,event,handle):
|
def edit_person(self, obj, event, handle):
|
||||||
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1 \
|
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1 \
|
||||||
or event.keyval in (_RETURN, _KP_ENTER):
|
or event.keyval in (_RETURN, _KP_ENTER):
|
||||||
from _EditPerson import EditPerson
|
from _EditPerson import EditPerson
|
||||||
@ -792,17 +803,17 @@ class EditFamily(EditPrimary):
|
|||||||
person = db.get_person_from_handle(handle)
|
person = db.get_person_from_handle(handle)
|
||||||
name = "%s [%s]" % (name_displayer.display(person),
|
name = "%s [%s]" % (name_displayer.display(person),
|
||||||
person.gramps_id)
|
person.gramps_id)
|
||||||
data = ReportUtils.get_birth_death_strings(db,person)
|
data = ReportUtils.get_birth_death_strings(db, person)
|
||||||
birth = data[0]
|
birth = data[0]
|
||||||
death = data[4]
|
death = data[4]
|
||||||
|
|
||||||
del_image = gtk.Image()
|
del_image = gtk.Image()
|
||||||
del_image.show()
|
del_image.show()
|
||||||
del_image.set_from_stock(gtk.STOCK_REMOVE,gtk.ICON_SIZE_BUTTON)
|
del_image.set_from_stock(gtk.STOCK_REMOVE, gtk.ICON_SIZE_BUTTON)
|
||||||
self.tooltips.set_tip(btn_obj, del_msg)
|
self.tooltips.set_tip(btn_obj, del_msg)
|
||||||
btn_obj.add(del_image)
|
btn_obj.add(del_image)
|
||||||
|
|
||||||
edit_btn = IconButton(self.edit_person,person.handle)
|
edit_btn = IconButton(self.edit_person, person.handle)
|
||||||
self.tooltips.set_tip(edit_btn, _('Edit %s') % name)
|
self.tooltips.set_tip(edit_btn, _('Edit %s') % name)
|
||||||
|
|
||||||
box.pack_start(LinkBox(
|
box.pack_start(LinkBox(
|
||||||
@ -817,31 +828,31 @@ class EditFamily(EditPrimary):
|
|||||||
|
|
||||||
add_image = gtk.Image()
|
add_image = gtk.Image()
|
||||||
add_image.show()
|
add_image.show()
|
||||||
add_image.set_from_stock(gtk.STOCK_INDEX,gtk.ICON_SIZE_BUTTON)
|
add_image.set_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON)
|
||||||
self.tooltips.set_tip(btn_obj, add_msg)
|
self.tooltips.set_tip(btn_obj, add_msg)
|
||||||
btn_obj.add(add_image)
|
btn_obj.add(add_image)
|
||||||
|
|
||||||
birth_obj.set_text(birth)
|
birth_obj.set_text(birth)
|
||||||
death_obj.set_text(death)
|
death_obj.set_text(death)
|
||||||
|
|
||||||
def fix_parent_handles(self,orig_handle, new_handle, trans):
|
def fix_parent_handles(self, orig_handle, new_handle, trans):
|
||||||
if orig_handle != new_handle:
|
if orig_handle != new_handle:
|
||||||
if orig_handle:
|
if orig_handle:
|
||||||
person = self.db.get_person_from_handle(orig_handle)
|
person = self.db.get_person_from_handle(orig_handle)
|
||||||
person.family_list.remove(self.obj.handle)
|
person.family_list.remove(self.obj.handle)
|
||||||
self.db.commit_person(person,trans)
|
self.db.commit_person(person, trans)
|
||||||
if new_handle:
|
if new_handle:
|
||||||
person = self.db.get_person_from_handle(new_handle)
|
person = self.db.get_person_from_handle(new_handle)
|
||||||
if self.obj.handle not in person.family_list:
|
if self.obj.handle not in person.family_list:
|
||||||
person.family_list.append(self.obj.handle)
|
person.family_list.append(self.obj.handle)
|
||||||
self.db.commit_person(person,trans)
|
self.db.commit_person(person, trans)
|
||||||
|
|
||||||
def object_is_empty(self):
|
def object_is_empty(self):
|
||||||
return self.obj.get_father_handle() == None and \
|
return self.obj.get_father_handle() == None and \
|
||||||
self.obj.get_mother_handle() == None and \
|
self.obj.get_mother_handle() == None and \
|
||||||
len(self.obj.get_child_ref_list()) == 0
|
len(self.obj.get_child_ref_list()) == 0
|
||||||
|
|
||||||
def save(self,*obj):
|
def save(self, *obj):
|
||||||
try:
|
try:
|
||||||
self.__do_save()
|
self.__do_save()
|
||||||
except bsddb_db.DBRunRecoveryError, msg:
|
except bsddb_db.DBRunRecoveryError, msg:
|
||||||
@ -903,36 +914,36 @@ class EditFamily(EditPrimary):
|
|||||||
if handle:
|
if handle:
|
||||||
parent = self.db.get_person_from_handle(handle)
|
parent = self.db.get_person_from_handle(handle)
|
||||||
parent.add_family_handle(self.obj.handle)
|
parent.add_family_handle(self.obj.handle)
|
||||||
self.db.commit_person(parent,trans)
|
self.db.commit_person(parent, trans)
|
||||||
|
|
||||||
# find the mother, add the family handle to the mother
|
# find the mother, add the family handle to the mother
|
||||||
handle = self.obj.get_mother_handle()
|
handle = self.obj.get_mother_handle()
|
||||||
if handle:
|
if handle:
|
||||||
parent = self.db.get_person_from_handle(handle)
|
parent = self.db.get_person_from_handle(handle)
|
||||||
parent.add_family_handle(self.obj.handle)
|
parent.add_family_handle(self.obj.handle)
|
||||||
self.db.commit_person(parent,trans)
|
self.db.commit_person(parent, trans)
|
||||||
|
|
||||||
# for each child, add the family handle to the child
|
# for each child, add the family handle to the child
|
||||||
for ref in self.obj.get_child_ref_list():
|
for ref in self.obj.get_child_ref_list():
|
||||||
child = self.db.get_person_from_handle(ref.ref)
|
child = self.db.get_person_from_handle(ref.ref)
|
||||||
# fix - relationships need to be extracted from the list
|
# fix - relationships need to be extracted from the list
|
||||||
child.add_parent_family_handle(self.obj.handle)
|
child.add_parent_family_handle(self.obj.handle)
|
||||||
self.db.commit_person(child,trans)
|
self.db.commit_person(child, trans)
|
||||||
|
|
||||||
self.db.add_family(self.obj,trans)
|
self.db.add_family(self.obj, trans)
|
||||||
self.db.transaction_commit(trans,_("Add Family"))
|
self.db.transaction_commit(trans, _("Add Family"))
|
||||||
elif original and self.object_is_empty():
|
elif original and self.object_is_empty():
|
||||||
trans = self.db.transaction_begin()
|
trans = self.db.transaction_begin()
|
||||||
self.db.remove_family(self.obj.handle,trans)
|
self.db.remove_family(self.obj.handle, trans)
|
||||||
self.db.transaction_commit(trans,_("Remove Family"))
|
self.db.transaction_commit(trans, _("Remove Family"))
|
||||||
elif cmp(original.serialize(),self.obj.serialize()):
|
elif cmp(original.serialize(),self.obj.serialize()):
|
||||||
|
|
||||||
trans = self.db.transaction_begin()
|
trans = self.db.transaction_begin()
|
||||||
|
|
||||||
self.fix_parent_handles(original.get_father_handle(),
|
self.fix_parent_handles(original.get_father_handle(),
|
||||||
self.obj.get_father_handle(),trans)
|
self.obj.get_father_handle(), trans)
|
||||||
self.fix_parent_handles(original.get_mother_handle(),
|
self.fix_parent_handles(original.get_mother_handle(),
|
||||||
self.obj.get_mother_handle(),trans)
|
self.obj.get_mother_handle(), trans)
|
||||||
|
|
||||||
orig_set = set(original.get_child_ref_list())
|
orig_set = set(original.get_child_ref_list())
|
||||||
new_set = set(self.obj.get_child_ref_list())
|
new_set = set(self.obj.get_child_ref_list())
|
||||||
@ -941,21 +952,21 @@ class EditFamily(EditPrimary):
|
|||||||
for ref in orig_set.difference(new_set):
|
for ref in orig_set.difference(new_set):
|
||||||
person = self.db.get_person_from_handle(ref.ref)
|
person = self.db.get_person_from_handle(ref.ref)
|
||||||
person.remove_parent_family_handle(self.obj.handle)
|
person.remove_parent_family_handle(self.obj.handle)
|
||||||
self.db.commit_person(person,trans)
|
self.db.commit_person(person, trans)
|
||||||
|
|
||||||
# add the family to children which have been added
|
# add the family to children which have been added
|
||||||
for ref in new_set.difference(orig_set):
|
for ref in new_set.difference(orig_set):
|
||||||
person = self.db.get_person_from_handle(ref.ref)
|
person = self.db.get_person_from_handle(ref.ref)
|
||||||
person.add_parent_family_handle(self.obj.handle)
|
person.add_parent_family_handle(self.obj.handle)
|
||||||
self.db.commit_person(person,trans)
|
self.db.commit_person(person, trans)
|
||||||
|
|
||||||
if self.object_is_empty():
|
if self.object_is_empty():
|
||||||
self.db.remove_family(self.obj.handle,trans)
|
self.db.remove_family(self.obj.handle, trans)
|
||||||
else:
|
else:
|
||||||
if not self.obj.get_gramps_id():
|
if not self.obj.get_gramps_id():
|
||||||
self.obj.set_gramps_id(self.db.find_next_family_gramps_id())
|
self.obj.set_gramps_id(self.db.find_next_family_gramps_id())
|
||||||
self.db.commit_family(self.obj,trans)
|
self.db.commit_family(self.obj, trans)
|
||||||
self.db.transaction_commit(trans,_("Edit Family"))
|
self.db.transaction_commit(trans, _("Edit Family"))
|
||||||
|
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
@ -981,8 +992,8 @@ class EditFamily(EditPrimary):
|
|||||||
child = self.db.get_person_from_handle(ref.ref)
|
child = self.db.get_person_from_handle(ref.ref)
|
||||||
if child:
|
if child:
|
||||||
pname = child.get_primary_name()
|
pname = child.get_primary_name()
|
||||||
return (pname.get_surname_prefix(),pname.get_surname())
|
return (pname.get_surname_prefix(), pname.get_surname())
|
||||||
return ("","")
|
return ("", "")
|
||||||
|
|
||||||
def latin_american_child(self, parent):
|
def latin_american_child(self, parent):
|
||||||
"""
|
"""
|
||||||
@ -1003,9 +1014,9 @@ class EditFamily(EditPrimary):
|
|||||||
else:
|
else:
|
||||||
fsn, msn = surname, surname
|
fsn, msn = surname, surname
|
||||||
if parent == "father":
|
if parent == "father":
|
||||||
return prefix,fsn
|
return prefix, fsn
|
||||||
elif parent == "mother":
|
elif parent == "mother":
|
||||||
return prefix,msn
|
return prefix, msn
|
||||||
else:
|
else:
|
||||||
return ("","")
|
return ("", "")
|
||||||
return ("","")
|
return ("", "")
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -35,6 +34,7 @@ import sys
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gtk
|
import gtk
|
||||||
|
from gtk import glade
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -47,12 +47,11 @@ import gen.lib
|
|||||||
import Mime
|
import Mime
|
||||||
import ThumbNails
|
import ThumbNails
|
||||||
import Utils
|
import Utils
|
||||||
from _EditPrimary import EditPrimary
|
from Editors import EditPrimary
|
||||||
from AddMedia import AddMediaObject
|
from GrampsWidgets import MonitoredDate, MonitoredEntry, PrivacyButton
|
||||||
|
from DisplayTabs import (SourceEmbedList, AttrEmbedList, NoteTab,
|
||||||
from GrampsWidgets import *
|
MediaBackRefList)
|
||||||
from DisplayTabs import SourceEmbedList,AttrEmbedList,NoteTab,MediaBackRefList
|
from Editors.AddMedia import AddMediaObject
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# EditMedia
|
# EditMedia
|
||||||
@ -88,7 +87,7 @@ class EditMedia(EditPrimary):
|
|||||||
|
|
||||||
def _local_init(self):
|
def _local_init(self):
|
||||||
assert(self.obj)
|
assert(self.obj)
|
||||||
self.glade = gtk.glade.XML(const.GLADE_FILE,
|
self.glade = glade.XML(const.GLADE_FILE,
|
||||||
"change_global","gramps")
|
"change_global","gramps")
|
||||||
|
|
||||||
self.set_window(self.glade.get_widget('change_global'),
|
self.set_window(self.glade.get_widget('change_global'),
|
||||||
@ -183,13 +182,13 @@ class EditMedia(EditPrimary):
|
|||||||
|
|
||||||
self._setup_notebook_tabs( notebook)
|
self._setup_notebook_tabs( notebook)
|
||||||
notebook.show_all()
|
notebook.show_all()
|
||||||
self.glade.get_widget('vbox').pack_start(notebook,True)
|
self.glade.get_widget('vbox').pack_start(notebook, True)
|
||||||
|
|
||||||
def build_menu_names(self,person):
|
def build_menu_names(self, person):
|
||||||
return (_('Edit Media Object'), self.get_menu_title())
|
return (_('Edit Media Object'), self.get_menu_title())
|
||||||
|
|
||||||
def button_press_event(self, obj, event):
|
def button_press_event(self, obj, event):
|
||||||
if event.button==1 and event.type == gtk.gdk._2BUTTON_PRESS:
|
if event.button == 1 and event.type == gtk.gdk._2BUTTON_PRESS:
|
||||||
self.view_media(obj)
|
self.view_media(obj)
|
||||||
|
|
||||||
def view_media(self, obj):
|
def view_media(self, obj):
|
||||||
@ -197,8 +196,7 @@ class EditMedia(EditPrimary):
|
|||||||
mime_type = ref_obj.get_mime_type()
|
mime_type = ref_obj.get_mime_type()
|
||||||
app = Mime.get_application(mime_type)
|
app = Mime.get_application(mime_type)
|
||||||
if app:
|
if app:
|
||||||
import Utils
|
Utils.launch(app[0], ref_obj.get_path())
|
||||||
Utils.launch(app[0],ref_obj.get_path())
|
|
||||||
|
|
||||||
def select_file(self, val):
|
def select_file(self, val):
|
||||||
AddMediaObject(self.dbstate, self.uistate, self.track, self.obj,
|
AddMediaObject(self.dbstate, self.uistate, self.track, self.obj,
|
||||||
@ -251,7 +249,7 @@ class EditMedia(EditPrimary):
|
|||||||
|
|
||||||
class DeleteMediaQuery:
|
class DeleteMediaQuery:
|
||||||
|
|
||||||
def __init__(self,dbstate,uistate,media_handle,the_lists):
|
def __init__(self, dbstate, uistate, media_handle, the_lists):
|
||||||
self.db = dbstate.db
|
self.db = dbstate.db
|
||||||
self.uistate = uistate
|
self.uistate = uistate
|
||||||
self.media_handle = media_handle
|
self.media_handle = media_handle
|
||||||
@ -261,7 +259,7 @@ class DeleteMediaQuery:
|
|||||||
trans = self.db.transaction_begin()
|
trans = self.db.transaction_begin()
|
||||||
self.db.disable_signals()
|
self.db.disable_signals()
|
||||||
|
|
||||||
(person_list,family_list,event_list,
|
(person_list, family_list, event_list,
|
||||||
place_list,source_list) = self.the_lists
|
place_list,source_list) = self.the_lists
|
||||||
|
|
||||||
for handle in person_list:
|
for handle in person_list:
|
||||||
@ -269,36 +267,36 @@ class DeleteMediaQuery:
|
|||||||
new_list = [ photo for photo in person.get_media_list() \
|
new_list = [ photo for photo in person.get_media_list() \
|
||||||
if photo.get_reference_handle() != self.media_handle ]
|
if photo.get_reference_handle() != self.media_handle ]
|
||||||
person.set_media_list(new_list)
|
person.set_media_list(new_list)
|
||||||
self.db.commit_person(person,trans)
|
self.db.commit_person(person, trans)
|
||||||
|
|
||||||
for handle in family_list:
|
for handle in family_list:
|
||||||
family = self.db.get_family_from_handle(handle)
|
family = self.db.get_family_from_handle(handle)
|
||||||
new_list = [ photo for photo in family.get_media_list() \
|
new_list = [ photo for photo in family.get_media_list() \
|
||||||
if photo.get_reference_handle() != self.media_handle ]
|
if photo.get_reference_handle() != self.media_handle ]
|
||||||
family.set_media_list(new_list)
|
family.set_media_list(new_list)
|
||||||
self.db.commit_family(family,trans)
|
self.db.commit_family(family, trans)
|
||||||
|
|
||||||
for handle in event_list:
|
for handle in event_list:
|
||||||
event = self.db.get_event_from_handle(handle)
|
event = self.db.get_event_from_handle(handle)
|
||||||
new_list = [ photo for photo in event.get_media_list() \
|
new_list = [ photo for photo in event.get_media_list() \
|
||||||
if photo.get_reference_handle() != self.media_handle ]
|
if photo.get_reference_handle() != self.media_handle ]
|
||||||
event.set_media_list(new_list)
|
event.set_media_list(new_list)
|
||||||
self.db.commit_event(event,trans)
|
self.db.commit_event(event, trans)
|
||||||
|
|
||||||
for handle in place_list:
|
for handle in place_list:
|
||||||
place = self.db.get_place_from_handle(handle)
|
place = self.db.get_place_from_handle(handle)
|
||||||
new_list = [ photo for photo in place.get_media_list() \
|
new_list = [ photo for photo in place.get_media_list() \
|
||||||
if photo.get_reference_handle() != self.media_handle ]
|
if photo.get_reference_handle() != self.media_handle ]
|
||||||
place.set_media_list(new_list)
|
place.set_media_list(new_list)
|
||||||
self.db.commit_place(place,trans)
|
self.db.commit_place(place, trans)
|
||||||
|
|
||||||
for handle in source_list:
|
for handle in source_list:
|
||||||
source = self.db.get_source_from_handle(handle)
|
source = self.db.get_source_from_handle(handle)
|
||||||
new_list = [ photo for photo in source.get_media_list() \
|
new_list = [ photo for photo in source.get_media_list() \
|
||||||
if photo.get_reference_handle() != self.media_handle ]
|
if photo.get_reference_handle() != self.media_handle ]
|
||||||
source.set_media_list(new_list)
|
source.set_media_list(new_list)
|
||||||
self.db.commit_source(source,trans)
|
self.db.commit_source(source, trans)
|
||||||
|
|
||||||
self.db.enable_signals()
|
self.db.enable_signals()
|
||||||
self.db.remove_object(self.media_handle,trans)
|
self.db.remove_object(self.media_handle, trans)
|
||||||
self.db.transaction_commit(trans,_("Remove Media Object"))
|
self.db.transaction_commit(trans, _("Remove Media Object"))
|
||||||
|
@ -27,13 +27,17 @@
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
|
import logging
|
||||||
|
log = logging.getLogger(".")
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# GTK libraries
|
# GTK libraries
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gtk
|
import gtk
|
||||||
from pango import WEIGHT_BOLD, STYLE_ITALIC, UNDERLINE_SINGLE
|
from gtk import glade
|
||||||
|
import gobject
|
||||||
|
from pango import UNDERLINE_SINGLE
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -45,9 +49,10 @@ import Spell
|
|||||||
import Config
|
import Config
|
||||||
import GrampsDisplay
|
import GrampsDisplay
|
||||||
import MarkupText
|
import MarkupText
|
||||||
from _EditPrimary import EditPrimary
|
from Editors._EditPrimary import EditPrimary
|
||||||
from DisplayTabs import GrampsTab, NoteBackRefList
|
from DisplayTabs import GrampsTab, NoteBackRefList
|
||||||
from GrampsWidgets import *
|
from GrampsWidgets import (MonitoredDataType, MonitoredCheckbox,
|
||||||
|
MonitoredEntry, PrivacyButton)
|
||||||
from gen.lib import Note
|
from gen.lib import Note
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -174,7 +179,7 @@ class EditNote(EditPrimary):
|
|||||||
and overridden here.
|
and overridden here.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.top = gtk.glade.XML(const.GLADE_FILE, "edit_note", "gramps")
|
self.top = glade.XML(const.GLADE_FILE, "edit_note", "gramps")
|
||||||
win = self.top.get_widget("edit_note")
|
win = self.top.get_widget("edit_note")
|
||||||
self.set_window(win, None, self.get_menu_title())
|
self.set_window(win, None, self.get_menu_title())
|
||||||
|
|
||||||
@ -236,7 +241,7 @@ class EditNote(EditPrimary):
|
|||||||
Called by the init routine of the base class (_EditPrimary).
|
Called by the init routine of the base class (_EditPrimary).
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.define_ok_button(self.top.get_widget('ok'),self.save)
|
self.define_ok_button(self.top.get_widget('ok'), self.save)
|
||||||
self.define_cancel_button(self.top.get_widget('cancel'))
|
self.define_cancel_button(self.top.get_widget('cancel'))
|
||||||
self.define_help_button(self.top.get_widget('help'), '')
|
self.define_help_button(self.top.get_widget('help'), '')
|
||||||
|
|
||||||
@ -275,22 +280,22 @@ class EditNote(EditPrimary):
|
|||||||
</ui>
|
</ui>
|
||||||
'''
|
'''
|
||||||
|
|
||||||
buffer = MarkupText.MarkupBuffer()
|
buffer_ = MarkupText.MarkupBuffer()
|
||||||
buffer.create_tag('hyperlink',
|
buffer_.create_tag('hyperlink',
|
||||||
underline=UNDERLINE_SINGLE,
|
underline=UNDERLINE_SINGLE,
|
||||||
foreground='blue')
|
foreground='blue')
|
||||||
buffer.match_add("(www|ftp)[" + HOSTCHARS + "]*\\.[" + HOSTCHARS +
|
buffer_.match_add("(www|ftp)[" + HOSTCHARS + "]*\\.[" + HOSTCHARS +
|
||||||
".]+" + "(:[0-9]+)?(" + URLPATH + ")?/?", HTTP)
|
".]+" + "(:[0-9]+)?(" + URLPATH + ")?/?", HTTP)
|
||||||
buffer.match_add("(mailto:)?[a-z0-9][a-z0-9.-]*@[a-z0-9][a-z0-9-]*"
|
buffer_.match_add("(mailto:)?[a-z0-9][a-z0-9.-]*@[a-z0-9][a-z0-9-]*"
|
||||||
"(\\.[a-z0-9][a-z0-9-]*)+", MAIL)
|
"(\\.[a-z0-9][a-z0-9-]*)+", MAIL)
|
||||||
buffer.match_add(SCHEME + "//(" + USER + "@)?[" + HOSTCHARS + ".]+" +
|
buffer_.match_add(SCHEME + "//(" + USER + "@)?[" + HOSTCHARS + ".]+" +
|
||||||
"(:[0-9]+)?(" + URLPATH + ")?/?", GENERAL)
|
"(:[0-9]+)?(" + URLPATH + ")?/?", GENERAL)
|
||||||
self.match = None
|
self.match = None
|
||||||
self.last_match = None
|
self.last_match = None
|
||||||
|
|
||||||
self.text = self.top.get_widget('text')
|
self.text = self.top.get_widget('text')
|
||||||
self.text.set_editable(not self.dbstate.db.readonly)
|
self.text.set_editable(not self.dbstate.db.readonly)
|
||||||
self.text.set_buffer(buffer)
|
self.text.set_buffer(buffer_)
|
||||||
self.text.connect('key-press-event',
|
self.text.connect('key-press-event',
|
||||||
self.on_textview_key_press_event)
|
self.on_textview_key_press_event)
|
||||||
self.text.connect('insert-at-cursor',
|
self.text.connect('insert-at-cursor',
|
||||||
@ -328,7 +333,7 @@ class EditNote(EditPrimary):
|
|||||||
# create a formatting toolbar
|
# create a formatting toolbar
|
||||||
if not self.dbstate.db.readonly:
|
if not self.dbstate.db.readonly:
|
||||||
uimanager = gtk.UIManager()
|
uimanager = gtk.UIManager()
|
||||||
uimanager.insert_action_group(buffer.format_action_group, 0)
|
uimanager.insert_action_group(buffer_.format_action_group, 0)
|
||||||
uimanager.add_ui_from_string(FORMAT_TOOLBAR)
|
uimanager.add_ui_from_string(FORMAT_TOOLBAR)
|
||||||
uimanager.ensure_update()
|
uimanager.ensure_update()
|
||||||
|
|
||||||
@ -337,12 +342,12 @@ class EditNote(EditPrimary):
|
|||||||
vbox = self.top.get_widget('container')
|
vbox = self.top.get_widget('container')
|
||||||
vbox.pack_start(toolbar)
|
vbox.pack_start(toolbar)
|
||||||
|
|
||||||
# setup initial values for textview and buffer
|
# setup initial values for textview and buffer_
|
||||||
if self.obj:
|
if self.obj:
|
||||||
self.empty = False
|
self.empty = False
|
||||||
self.flow_changed(self.obj.get_format())
|
self.flow_changed(self.obj.get_format())
|
||||||
buffer.set_text(self.obj.get(markup=True))
|
buffer_.set_text(self.obj.get(markup=True))
|
||||||
log.debug("Initial Note: %s" % buffer.get_text())
|
log.debug("Initial Note: %s" % buffer_.get_text())
|
||||||
else:
|
else:
|
||||||
self.empty = True
|
self.empty = True
|
||||||
|
|
||||||
@ -374,20 +379,20 @@ class EditNote(EditPrimary):
|
|||||||
x, y = textview.window_to_buffer_coords(gtk.TEXT_WINDOW_WIDGET,
|
x, y = textview.window_to_buffer_coords(gtk.TEXT_WINDOW_WIDGET,
|
||||||
int(event.x), int(event.y))
|
int(event.x), int(event.y))
|
||||||
iter = textview.get_iter_at_location(x, y)
|
iter = textview.get_iter_at_location(x, y)
|
||||||
buffer = textview.get_buffer()
|
buffer_ = textview.get_buffer()
|
||||||
self.match = buffer.match_check(iter.get_offset())
|
self.match = buffer_.match_check(iter.get_offset())
|
||||||
|
|
||||||
if self.match != self.last_match:
|
if self.match != self.last_match:
|
||||||
start, end = buffer.get_bounds()
|
start, end = buffer_.get_bounds()
|
||||||
buffer.remove_tag_by_name('hyperlink', start, end)
|
buffer_.remove_tag_by_name('hyperlink', start, end)
|
||||||
if self.match:
|
if self.match:
|
||||||
start_offset = self.match[MarkupText.MATCH_START]
|
start_offset = self.match[MarkupText.MATCH_START]
|
||||||
end_offset = self.match[MarkupText.MATCH_END]
|
end_offset = self.match[MarkupText.MATCH_END]
|
||||||
|
|
||||||
start = buffer.get_iter_at_offset(start_offset)
|
start = buffer_.get_iter_at_offset(start_offset)
|
||||||
end = buffer.get_iter_at_offset(end_offset)
|
end = buffer_.get_iter_at_offset(end_offset)
|
||||||
|
|
||||||
buffer.apply_tag_by_name('hyperlink', start, end)
|
buffer_.apply_tag_by_name('hyperlink', start, end)
|
||||||
window.set_cursor(self.hand_cursor)
|
window.set_cursor(self.hand_cursor)
|
||||||
else:
|
else:
|
||||||
window.set_cursor(self.regular_cursor)
|
window.set_cursor(self.regular_cursor)
|
||||||
@ -462,9 +467,9 @@ class EditNote(EditPrimary):
|
|||||||
def update_note(self):
|
def update_note(self):
|
||||||
"""Update the Note object with current value."""
|
"""Update the Note object with current value."""
|
||||||
if self.obj:
|
if self.obj:
|
||||||
buffer = self.text.get_buffer()
|
buffer_ = self.text.get_buffer()
|
||||||
(start, stop) = buffer.get_bounds()
|
(start, stop) = buffer_.get_bounds()
|
||||||
text = buffer.get_text(start, stop)
|
text = buffer_.get_text(start, stop)
|
||||||
self.obj.set(text)
|
self.obj.set(text)
|
||||||
log.debug(text)
|
log.debug(text)
|
||||||
|
|
||||||
@ -481,12 +486,12 @@ class EditNote(EditPrimary):
|
|||||||
self.update_note()
|
self.update_note()
|
||||||
|
|
||||||
if not self.obj.get_handle():
|
if not self.obj.get_handle():
|
||||||
self.db.add_note(self.obj,trans)
|
self.db.add_note(self.obj, trans)
|
||||||
msg = _("Add Note")
|
msg = _("Add Note")
|
||||||
else:
|
else:
|
||||||
if not self.obj.get_gramps_id():
|
if not self.obj.get_gramps_id():
|
||||||
self.obj.set_gramps_id(self.db.find_next_note_gramps_id())
|
self.obj.set_gramps_id(self.db.find_next_note_gramps_id())
|
||||||
self.db.commit_note(self.obj,trans)
|
self.db.commit_note(self.obj, trans)
|
||||||
msg = _("Edit Note")
|
msg = _("Edit Note")
|
||||||
|
|
||||||
self.db.transaction_commit(trans, msg)
|
self.db.transaction_commit(trans, msg)
|
||||||
@ -524,37 +529,37 @@ class DeleteNoteQuery:
|
|||||||
for handle in person_list:
|
for handle in person_list:
|
||||||
person = self.db.get_person_from_handle(handle)
|
person = self.db.get_person_from_handle(handle)
|
||||||
person.remove_note(note_handle)
|
person.remove_note(note_handle)
|
||||||
self.db.commit_person(person,trans)
|
self.db.commit_person(person, trans)
|
||||||
|
|
||||||
for handle in family_list:
|
for handle in family_list:
|
||||||
family = self.db.get_family_from_handle(handle)
|
family = self.db.get_family_from_handle(handle)
|
||||||
family.remove_note(note_handle)
|
family.remove_note(note_handle)
|
||||||
self.db.commit_family(family,trans)
|
self.db.commit_family(family, trans)
|
||||||
|
|
||||||
for handle in event_list:
|
for handle in event_list:
|
||||||
event = self.db.get_event_from_handle(handle)
|
event = self.db.get_event_from_handle(handle)
|
||||||
event.remove_note(note_handle)
|
event.remove_note(note_handle)
|
||||||
self.db.commit_event(event,trans)
|
self.db.commit_event(event, trans)
|
||||||
|
|
||||||
for handle in place_list:
|
for handle in place_list:
|
||||||
place = self.db.get_place_from_handle(handle)
|
place = self.db.get_place_from_handle(handle)
|
||||||
place.remove_note(note_handle)
|
place.remove_note(note_handle)
|
||||||
self.db.commit_place(place,trans)
|
self.db.commit_place(place, trans)
|
||||||
|
|
||||||
for handle in source_list:
|
for handle in source_list:
|
||||||
source = self.db.get_source_from_handle(handle)
|
source = self.db.get_source_from_handle(handle)
|
||||||
source.remove_note(note_handle)
|
source.remove_note(note_handle)
|
||||||
self.db.commit_source(source,trans)
|
self.db.commit_source(source, trans)
|
||||||
|
|
||||||
for handle in media_list:
|
for handle in media_list:
|
||||||
media = self.db.get_object_from_handle(handle)
|
media = self.db.get_object_from_handle(handle)
|
||||||
media.remove_note(note_handle)
|
media.remove_note(note_handle)
|
||||||
self.db.commit_media_object(media,trans)
|
self.db.commit_media_object(media, trans)
|
||||||
|
|
||||||
for handle in repo_list:
|
for handle in repo_list:
|
||||||
repo = self.db.get_repository_from_handle(handle)
|
repo = self.db.get_repository_from_handle(handle)
|
||||||
repo.remove_note(note_handle)
|
repo.remove_note(note_handle)
|
||||||
self.db.commit_repository(repo,trans)
|
self.db.commit_repository(repo, trans)
|
||||||
|
|
||||||
self.db.enable_signals()
|
self.db.enable_signals()
|
||||||
self.db.remove_note(note_handle, trans)
|
self.db.remove_note(note_handle, trans)
|
||||||
|
@ -36,6 +36,7 @@ log = logging.getLogger(".")
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gtk
|
import gtk
|
||||||
|
from gtk import glade
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -45,10 +46,11 @@ import gtk
|
|||||||
import const
|
import const
|
||||||
import Config
|
import Config
|
||||||
import gen.lib
|
import gen.lib
|
||||||
from _EditPrimary import EditPrimary
|
from Editors._EditPrimary import EditPrimary
|
||||||
|
from DisplayTabs import (GrampsTab, LocationEmbedList, SourceEmbedList,
|
||||||
from DisplayTabs import *
|
GalleryTab, NoteTab, WebEmbedList, PlaceBackRefList)
|
||||||
from GrampsWidgets import *
|
from GrampsWidgets import MonitoredEntry, PrivacyButton
|
||||||
|
from Errors import ValidationError
|
||||||
from PlaceUtils import conv_lat_lon
|
from PlaceUtils import conv_lat_lon
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -101,7 +103,7 @@ class MainLocTab(GrampsTab):
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class EditPlace(EditPrimary):
|
class EditPlace(EditPrimary):
|
||||||
|
|
||||||
def __init__(self,dbstate,uistate,track,place,callback=None):
|
def __init__(self, dbstate, uistate, track, place, callback=None):
|
||||||
EditPrimary.__init__(self, dbstate, uistate, track, place,
|
EditPrimary.__init__(self, dbstate, uistate, track, place,
|
||||||
dbstate.db.get_place_from_handle, callback)
|
dbstate.db.get_place_from_handle, callback)
|
||||||
|
|
||||||
@ -109,7 +111,7 @@ class EditPlace(EditPrimary):
|
|||||||
return gen.lib.Place()
|
return gen.lib.Place()
|
||||||
|
|
||||||
def _local_init(self):
|
def _local_init(self):
|
||||||
self.top = gtk.glade.XML(const.GLADE_FILE,"place_editor","gramps")
|
self.top = glade.XML(const.GLADE_FILE, "place_editor","gramps")
|
||||||
|
|
||||||
self.set_window(self.top.get_widget("place_editor"), None,
|
self.set_window(self.top.get_widget("place_editor"), None,
|
||||||
self.get_menu_title())
|
self.get_menu_title())
|
||||||
@ -132,7 +134,7 @@ class EditPlace(EditPrimary):
|
|||||||
return dialog_title
|
return dialog_title
|
||||||
|
|
||||||
def _connect_signals(self):
|
def _connect_signals(self):
|
||||||
self.define_ok_button(self.top.get_widget('ok'),self.save)
|
self.define_ok_button(self.top.get_widget('ok'), self.save)
|
||||||
self.define_cancel_button(self.top.get_widget('cancel'))
|
self.define_cancel_button(self.top.get_widget('cancel'))
|
||||||
self.define_help_button(self.top.get_widget('help'),'adv-plc')
|
self.define_help_button(self.top.get_widget('help'),'adv-plc')
|
||||||
|
|
||||||
@ -205,7 +207,7 @@ class EditPlace(EditPrimary):
|
|||||||
return ValidationError(_(u"Invalid longitude (syntax: 18\u00b09'" +
|
return ValidationError(_(u"Invalid longitude (syntax: 18\u00b09'" +
|
||||||
'48.21"E, -18.2412 or -18:9:48.21)'))
|
'48.21"E, -18.2412 or -18:9:48.21)'))
|
||||||
|
|
||||||
def build_menu_names(self,place):
|
def build_menu_names(self, place):
|
||||||
return (_('Edit Place'), self.get_menu_title())
|
return (_('Edit Place'), self.get_menu_title())
|
||||||
|
|
||||||
def _create_tabbed_pages(self):
|
def _create_tabbed_pages(self):
|
||||||
@ -257,13 +259,12 @@ class EditPlace(EditPrimary):
|
|||||||
Config.set(Config.PLACE_HEIGHT, height)
|
Config.set(Config.PLACE_HEIGHT, height)
|
||||||
Config.sync()
|
Config.sync()
|
||||||
|
|
||||||
def save(self,*obj):
|
def save(self, *obj):
|
||||||
self.ok_button.set_sensitive(False)
|
self.ok_button.set_sensitive(False)
|
||||||
title = self.obj.get_title()
|
|
||||||
|
|
||||||
trans = self.db.transaction_begin()
|
trans = self.db.transaction_begin()
|
||||||
if not self.obj.get_handle():
|
if not self.obj.get_handle():
|
||||||
self.db.add_place(self.obj,trans)
|
self.db.add_place(self.obj, trans)
|
||||||
msg = _("Add Place (%s)") % self.obj.get_title()
|
msg = _("Add Place (%s)") % self.obj.get_title()
|
||||||
else:
|
else:
|
||||||
if not self.obj.get_gramps_id():
|
if not self.obj.get_gramps_id():
|
||||||
@ -283,8 +284,8 @@ class EditPlace(EditPrimary):
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class DeletePlaceQuery:
|
class DeletePlaceQuery:
|
||||||
|
|
||||||
def __init__(self,dbstate,uistate,
|
def __init__(self, dbstate, uistate, place, person_list, family_list,
|
||||||
place,person_list,family_list,event_list):
|
event_list):
|
||||||
self.db = dbstate.db
|
self.db = dbstate.db
|
||||||
self.uistate = uistate
|
self.uistate = uistate
|
||||||
self.obj = place
|
self.obj = place
|
||||||
@ -300,20 +301,20 @@ class DeletePlaceQuery:
|
|||||||
|
|
||||||
for handle in self.person_list:
|
for handle in self.person_list:
|
||||||
person = self.db.get_person_from_handle(handle)
|
person = self.db.get_person_from_handle(handle)
|
||||||
person.remove_handle_references('Place',place_handle)
|
person.remove_handle_references('Place', place_handle)
|
||||||
self.db.commit_person(person,trans)
|
self.db.commit_person(person, trans)
|
||||||
|
|
||||||
for handle in self.family_list:
|
for handle in self.family_list:
|
||||||
family = self.db.get_family_from_handle(handle)
|
family = self.db.get_family_from_handle(handle)
|
||||||
family.remove_handle_references('Place',place_handle)
|
family.remove_handle_references('Place', place_handle)
|
||||||
self.db.commit_family(family,trans)
|
self.db.commit_family(family, trans)
|
||||||
|
|
||||||
for handle in self.event_list:
|
for handle in self.event_list:
|
||||||
event = self.db.get_event_from_handle(handle)
|
event = self.db.get_event_from_handle(handle)
|
||||||
event.remove_handle_references('Place',place_handle)
|
event.remove_handle_references('Place', place_handle)
|
||||||
self.db.commit_event(event,trans)
|
self.db.commit_event(event, trans)
|
||||||
|
|
||||||
self.db.enable_signals()
|
self.db.enable_signals()
|
||||||
self.db.remove_place(place_handle,trans)
|
self.db.remove_place(place_handle, trans)
|
||||||
self.db.transaction_commit(
|
self.db.transaction_commit(
|
||||||
trans,_("Delete Place (%s)") % self.obj.get_title())
|
trans,_("Delete Place (%s)") % self.obj.get_title())
|
||||||
|
@ -34,7 +34,8 @@ class EditPrimary(ManagedWindow.ManagedWindow):
|
|||||||
|
|
||||||
QR_CATEGORY = -1
|
QR_CATEGORY = -1
|
||||||
|
|
||||||
def __init__(self, state, uistate, track, obj, get_from_handle, callback=None):
|
def __init__(self, state, uistate, track, obj, get_from_handle,
|
||||||
|
callback=None):
|
||||||
"""Creates an edit window. Associates a person with the window."""
|
"""Creates an edit window. Associates a person with the window."""
|
||||||
|
|
||||||
self.dp = DateHandler.parser
|
self.dp = DateHandler.parser
|
||||||
@ -73,7 +74,7 @@ class EditPrimary(ManagedWindow.ManagedWindow):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def _add_db_signal(self, name, callback):
|
def _add_db_signal(self, name, callback):
|
||||||
self.signal_keys.append(self.db.connect(name,callback))
|
self.signal_keys.append(self.db.connect(name, callback))
|
||||||
|
|
||||||
def _connect_signals(self):
|
def _connect_signals(self):
|
||||||
pass
|
pass
|
||||||
@ -84,7 +85,7 @@ class EditPrimary(ManagedWindow.ManagedWindow):
|
|||||||
def _create_tabbed_pages(self):
|
def _create_tabbed_pages(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def build_window_key(self,obj):
|
def build_window_key(self, obj):
|
||||||
if obj and obj.get_handle():
|
if obj and obj.get_handle():
|
||||||
return obj.get_handle()
|
return obj.get_handle()
|
||||||
else:
|
else:
|
||||||
@ -101,11 +102,12 @@ class EditPrimary(ManagedWindow.ManagedWindow):
|
|||||||
page_no)
|
page_no)
|
||||||
child.set_parent_notebook(notebook)
|
child.set_parent_notebook(notebook)
|
||||||
|
|
||||||
def _switch_page_on_dnd(self, widget, context, x, y, time, notebook, page_no):
|
def _switch_page_on_dnd(self, widget, context, x, y, time, notebook,
|
||||||
|
page_no):
|
||||||
if notebook.get_current_page() != page_no:
|
if notebook.get_current_page() != page_no:
|
||||||
notebook.set_current_page(page_no)
|
notebook.set_current_page(page_no)
|
||||||
|
|
||||||
def _add_tab(self,notebook,page):
|
def _add_tab(self, notebook, page):
|
||||||
notebook.insert_page(page, page.get_tab_widget())
|
notebook.insert_page(page, page.get_tab_widget())
|
||||||
page.add_db_signal_callback(self._add_db_signal)
|
page.add_db_signal_callback(self._add_db_signal)
|
||||||
return page
|
return page
|
||||||
@ -122,19 +124,19 @@ class EditPrimary(ManagedWindow.ManagedWindow):
|
|||||||
button.connect('clicked', function)
|
button.connect('clicked', function)
|
||||||
button.set_sensitive(not self.db.readonly)
|
button.set_sensitive(not self.db.readonly)
|
||||||
|
|
||||||
def define_cancel_button(self,button):
|
def define_cancel_button(self, button):
|
||||||
button.connect('clicked',self.close)
|
button.connect('clicked', self.close)
|
||||||
|
|
||||||
def define_help_button(self,button,tag):
|
def define_help_button(self, button, tag):
|
||||||
button.connect('clicked', lambda x: GrampsDisplay.help(tag))
|
button.connect('clicked', lambda x: GrampsDisplay.help(tag))
|
||||||
|
|
||||||
def _do_close(self,*obj):
|
def _do_close(self, *obj):
|
||||||
for key in self.signal_keys:
|
for key in self.signal_keys:
|
||||||
self.db.disconnect(key)
|
self.db.disconnect(key)
|
||||||
self._cleanup_on_exit()
|
self._cleanup_on_exit()
|
||||||
ManagedWindow.ManagedWindow.close(self)
|
ManagedWindow.ManagedWindow.close(self)
|
||||||
|
|
||||||
def close(self,*obj):
|
def close(self, *obj):
|
||||||
"""If the data has changed, give the user a chance to cancel
|
"""If the data has changed, give the user a chance to cancel
|
||||||
the close window"""
|
the close window"""
|
||||||
if not Config.get(Config.DONT_ASK) and self.data_has_changed():
|
if not Config.get(Config.DONT_ASK) and self.data_has_changed():
|
||||||
@ -169,7 +171,7 @@ class EditPrimary(ManagedWindow.ManagedWindow):
|
|||||||
return cmp(cmp_obj.serialize()[1:],
|
return cmp(cmp_obj.serialize()[1:],
|
||||||
self.obj.serialize()[1:]) != 0
|
self.obj.serialize()[1:]) != 0
|
||||||
|
|
||||||
def save(self,*obj):
|
def save(self, *obj):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def set_contexteventbox(self, eventbox):
|
def set_contexteventbox(self, eventbox):
|
||||||
@ -237,7 +239,7 @@ class EditPrimary(ManagedWindow.ManagedWindow):
|
|||||||
Derived class can create a ui with menuitems and corresponding list of
|
Derived class can create a ui with menuitems and corresponding list of
|
||||||
actiongroups
|
actiongroups
|
||||||
"""
|
"""
|
||||||
return "",[]
|
return "", []
|
||||||
|
|
||||||
def _post_build_popup_ui(self):
|
def _post_build_popup_ui(self):
|
||||||
"""
|
"""
|
||||||
|
@ -33,6 +33,7 @@ from gettext import gettext as _
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gtk
|
import gtk
|
||||||
|
from gtk import glade
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -43,13 +44,13 @@ import const
|
|||||||
import Config
|
import Config
|
||||||
import gen.lib
|
import gen.lib
|
||||||
|
|
||||||
from GrampsWidgets import *
|
from GrampsWidgets import MonitoredEntry, MonitoredDataType, PrivacyButton
|
||||||
from DisplayTabs import AddrEmbedList,WebEmbedList,NoteTab,SourceBackRefList
|
from DisplayTabs import AddrEmbedList, WebEmbedList, NoteTab, SourceBackRefList
|
||||||
from _EditPrimary import EditPrimary
|
from Editors._EditPrimary import EditPrimary
|
||||||
|
|
||||||
class EditRepository(EditPrimary):
|
class EditRepository(EditPrimary):
|
||||||
|
|
||||||
def __init__(self,dbstate,uistate,track,repository):
|
def __init__(self, dbstate, uistate, track, repository):
|
||||||
|
|
||||||
EditPrimary.__init__(self, dbstate, uistate, track,
|
EditPrimary.__init__(self, dbstate, uistate, track,
|
||||||
repository, dbstate.db.get_repository_from_handle)
|
repository, dbstate.db.get_repository_from_handle)
|
||||||
@ -69,15 +70,16 @@ class EditRepository(EditPrimary):
|
|||||||
return title
|
return title
|
||||||
|
|
||||||
def _local_init(self):
|
def _local_init(self):
|
||||||
self.glade = gtk.glade.XML(const.GLADE_FILE,"repository_editor","gramps")
|
self.glade = glade.XML(const.GLADE_FILE, "repository_editor","gramps")
|
||||||
|
|
||||||
self.set_window(self.glade.get_widget("repository_editor"), None, self.get_menu_title())
|
self.set_window(self.glade.get_widget("repository_editor"), None,
|
||||||
|
self.get_menu_title())
|
||||||
|
|
||||||
width = Config.get(Config.REPO_WIDTH)
|
width = Config.get(Config.REPO_WIDTH)
|
||||||
height = Config.get(Config.REPO_HEIGHT)
|
height = Config.get(Config.REPO_HEIGHT)
|
||||||
self.window.resize(width, height)
|
self.window.resize(width, height)
|
||||||
|
|
||||||
def build_menu_names(self,source):
|
def build_menu_names(self, source):
|
||||||
return (_('Edit Repository'), self.get_menu_title())
|
return (_('Edit Repository'), self.get_menu_title())
|
||||||
|
|
||||||
def _setup_fields(self):
|
def _setup_fields(self):
|
||||||
@ -134,7 +136,7 @@ class EditRepository(EditPrimary):
|
|||||||
|
|
||||||
self._setup_notebook_tabs( notebook)
|
self._setup_notebook_tabs( notebook)
|
||||||
notebook.show_all()
|
notebook.show_all()
|
||||||
self.glade.get_widget("vbox").pack_start(notebook,True,True)
|
self.glade.get_widget("vbox").pack_start(notebook, True, True)
|
||||||
|
|
||||||
def _connect_signals(self):
|
def _connect_signals(self):
|
||||||
self.define_help_button(self.glade.get_widget('help'),'adv-src')
|
self.define_help_button(self.glade.get_widget('help'),'adv-src')
|
||||||
@ -172,7 +174,7 @@ class EditRepository(EditPrimary):
|
|||||||
Config.sync()
|
Config.sync()
|
||||||
|
|
||||||
class DelRepositoryQuery:
|
class DelRepositoryQuery:
|
||||||
def __init__(self,dbstate,uistate,repository,sources):
|
def __init__(self, dbstate, uistate, repository, sources):
|
||||||
self.obj = repository
|
self.obj = repository
|
||||||
self.db = dbstate.db
|
self.db = dbstate.db
|
||||||
self.uistate = uistate
|
self.uistate = uistate
|
||||||
@ -186,8 +188,8 @@ class DelRepositoryQuery:
|
|||||||
for handle in self.sources:
|
for handle in self.sources:
|
||||||
source = self.db.get_source_from_handle(handle)
|
source = self.db.get_source_from_handle(handle)
|
||||||
source.remove_repo_references(repos_handle_list)
|
source.remove_repo_references(repos_handle_list)
|
||||||
self.db.commit_source(source,trans)
|
self.db.commit_source(source, trans)
|
||||||
|
|
||||||
self.db.remove_repository(self.obj.get_handle(),trans)
|
self.db.remove_repository(self.obj.get_handle(), trans)
|
||||||
self.db.transaction_commit(
|
self.db.transaction_commit(
|
||||||
trans,_("Delete Repository (%s)") % self.obj.get_name())
|
trans, _("Delete Repository (%s)") % self.obj.get_name())
|
||||||
|
@ -35,7 +35,8 @@ log = logging.getLogger(".")
|
|||||||
# GTK/Gnome modules
|
# GTK/Gnome modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gtk.glade
|
import gtk
|
||||||
|
from gtk import glade
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -45,11 +46,11 @@ import gtk.glade
|
|||||||
import const
|
import const
|
||||||
import Config
|
import Config
|
||||||
import gen.lib
|
import gen.lib
|
||||||
from _EditPrimary import EditPrimary
|
from Editors._EditPrimary import EditPrimary
|
||||||
|
|
||||||
from DisplayTabs import \
|
from DisplayTabs import (NoteTab, GalleryTab, DataEmbedList,
|
||||||
NoteTab,GalleryTab,DataEmbedList,SourceBackRefList,RepoEmbedList
|
SourceBackRefList, RepoEmbedList)
|
||||||
from GrampsWidgets import *
|
from GrampsWidgets import MonitoredEntry, PrivacyButton
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -58,7 +59,7 @@ from GrampsWidgets import *
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class EditSource(EditPrimary):
|
class EditSource(EditPrimary):
|
||||||
|
|
||||||
def __init__(self,dbstate,uistate,track,source):
|
def __init__(self, dbstate, uistate, track,source):
|
||||||
|
|
||||||
EditPrimary.__init__(self, dbstate, uistate, track,
|
EditPrimary.__init__(self, dbstate, uistate, track,
|
||||||
source, dbstate.db.get_source_from_handle)
|
source, dbstate.db.get_source_from_handle)
|
||||||
@ -77,9 +78,10 @@ class EditSource(EditPrimary):
|
|||||||
def _local_init(self):
|
def _local_init(self):
|
||||||
|
|
||||||
assert(self.obj)
|
assert(self.obj)
|
||||||
self.glade = gtk.glade.XML(const.GLADE_FILE,"source_editor","gramps")
|
self.glade = glade.XML(const.GLADE_FILE, "source_editor","gramps")
|
||||||
|
|
||||||
self.set_window(self.glade.get_widget("source_editor"), None, self.get_menu_title())
|
self.set_window(self.glade.get_widget("source_editor"), None,
|
||||||
|
self.get_menu_title())
|
||||||
width = Config.get(Config.SOURCE_WIDTH)
|
width = Config.get(Config.SOURCE_WIDTH)
|
||||||
height = Config.get(Config.SOURCE_HEIGHT)
|
height = Config.get(Config.SOURCE_HEIGHT)
|
||||||
self.window.resize(width, height)
|
self.window.resize(width, height)
|
||||||
@ -155,9 +157,9 @@ class EditSource(EditPrimary):
|
|||||||
|
|
||||||
self._setup_notebook_tabs( notebook)
|
self._setup_notebook_tabs( notebook)
|
||||||
notebook.show_all()
|
notebook.show_all()
|
||||||
self.glade.get_widget('vbox').pack_start(notebook,True)
|
self.glade.get_widget('vbox').pack_start(notebook, True)
|
||||||
|
|
||||||
def build_menu_names(self,source):
|
def build_menu_names(self, source):
|
||||||
return (_('Edit Source'), self.get_menu_title())
|
return (_('Edit Source'), self.get_menu_title())
|
||||||
|
|
||||||
def save(self, *obj):
|
def save(self, *obj):
|
||||||
@ -192,7 +194,7 @@ class EditSource(EditPrimary):
|
|||||||
Config.sync()
|
Config.sync()
|
||||||
|
|
||||||
class DelSrcQuery:
|
class DelSrcQuery:
|
||||||
def __init__(self,dbstate,uistate,source,the_lists):
|
def __init__(self, dbstate, uistate, source, the_lists):
|
||||||
self.source = source
|
self.source = source
|
||||||
self.db = dbstate.db
|
self.db = dbstate.db
|
||||||
self.uistate = uistate
|
self.uistate = uistate
|
||||||
@ -202,47 +204,47 @@ class DelSrcQuery:
|
|||||||
trans = self.db.transaction_begin()
|
trans = self.db.transaction_begin()
|
||||||
self.db.disable_signals()
|
self.db.disable_signals()
|
||||||
|
|
||||||
(person_list,family_list,event_list,place_list,source_list,
|
(person_list, family_list, event_list, place_list, source_list,
|
||||||
media_list,repo_list) = self.the_lists
|
media_list, repo_list) = self.the_lists
|
||||||
|
|
||||||
src_handle_list = [self.source.get_handle()]
|
src_handle_list = [self.source.get_handle()]
|
||||||
|
|
||||||
for handle in person_list:
|
for handle in person_list:
|
||||||
person = self.db.get_person_from_handle(handle)
|
person = self.db.get_person_from_handle(handle)
|
||||||
person.remove_source_references(src_handle_list)
|
person.remove_source_references(src_handle_list)
|
||||||
self.db.commit_person(person,trans)
|
self.db.commit_person(person, trans)
|
||||||
|
|
||||||
for handle in family_list:
|
for handle in family_list:
|
||||||
family = self.db.get_family_from_handle(handle)
|
family = self.db.get_family_from_handle(handle)
|
||||||
family.remove_source_references(src_handle_list)
|
family.remove_source_references(src_handle_list)
|
||||||
self.db.commit_family(family,trans)
|
self.db.commit_family(family, trans)
|
||||||
|
|
||||||
for handle in event_list:
|
for handle in event_list:
|
||||||
event = self.db.get_event_from_handle(handle)
|
event = self.db.get_event_from_handle(handle)
|
||||||
event.remove_source_references(src_handle_list)
|
event.remove_source_references(src_handle_list)
|
||||||
self.db.commit_event(event,trans)
|
self.db.commit_event(event, trans)
|
||||||
|
|
||||||
for handle in place_list:
|
for handle in place_list:
|
||||||
place = self.db.get_place_from_handle(handle)
|
place = self.db.get_place_from_handle(handle)
|
||||||
place.remove_source_references(src_handle_list)
|
place.remove_source_references(src_handle_list)
|
||||||
self.db.commit_place(place,trans)
|
self.db.commit_place(place, trans)
|
||||||
|
|
||||||
for handle in source_list:
|
for handle in source_list:
|
||||||
source = self.db.get_source_from_handle(handle)
|
source = self.db.get_source_from_handle(handle)
|
||||||
source.remove_source_references(src_handle_list)
|
source.remove_source_references(src_handle_list)
|
||||||
self.db.commit_source(source,trans)
|
self.db.commit_source(source, trans)
|
||||||
|
|
||||||
for handle in media_list:
|
for handle in media_list:
|
||||||
media = self.db.get_object_from_handle(handle)
|
media = self.db.get_object_from_handle(handle)
|
||||||
media.remove_source_references(src_handle_list)
|
media.remove_source_references(src_handle_list)
|
||||||
self.db.commit_media_object(media,trans)
|
self.db.commit_media_object(media, trans)
|
||||||
|
|
||||||
for handle in repo_list:
|
for handle in repo_list:
|
||||||
repo = self.db.get_repository_from_handle(handle)
|
repo = self.db.get_repository_from_handle(handle)
|
||||||
repo.remove_source_references(src_handle_list)
|
repo.remove_source_references(src_handle_list)
|
||||||
self.db.commit_repository(repo,trans)
|
self.db.commit_repository(repo, trans)
|
||||||
|
|
||||||
self.db.enable_signals()
|
self.db.enable_signals()
|
||||||
self.db.remove_source(self.source.get_handle(),trans)
|
self.db.remove_source(self.source.get_handle(), trans)
|
||||||
self.db.transaction_commit(
|
self.db.transaction_commit(
|
||||||
trans,_("Delete Source (%s)") % self.source.get_title())
|
trans, _("Delete Source (%s)") % self.source.get_title())
|
||||||
|
Reference in New Issue
Block a user