2006-01-14 05:27:48 +00:00
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-02-22 19:11:55 +00:00
|
|
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
2006-01-14 05:27:48 +00:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2006-01-26 03:47:15 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK libraries
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-01-13 00:45:22 +00:00
|
|
|
import gtk
|
2006-01-15 01:26:47 +00:00
|
|
|
import gobject
|
2006-01-30 05:01:21 +00:00
|
|
|
import pango
|
|
|
|
from gtk.gdk import ACTION_COPY, BUTTON1_MASK
|
2006-01-15 01:26:47 +00:00
|
|
|
|
2006-01-29 04:50:11 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# python
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
from gettext import gettext as _
|
2006-01-30 05:01:21 +00:00
|
|
|
import pickle
|
2006-01-29 04:50:11 +00:00
|
|
|
|
2006-02-01 21:57:11 +00:00
|
|
|
try:
|
|
|
|
set()
|
|
|
|
except:
|
|
|
|
from sets import Set as set
|
2006-02-08 21:13:05 +00:00
|
|
|
print "set not used"
|
2006-02-01 21:57:11 +00:00
|
|
|
|
2006-01-26 03:47:15 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS libraries
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-01-13 00:45:22 +00:00
|
|
|
import DateHandler
|
|
|
|
import NameDisplay
|
|
|
|
import RelLib
|
|
|
|
import Utils
|
2006-02-02 05:20:42 +00:00
|
|
|
import ImgManip
|
2006-02-05 05:19:51 +00:00
|
|
|
import Spell
|
2006-03-01 05:08:11 +00:00
|
|
|
import Errors
|
2006-01-13 00:45:22 +00:00
|
|
|
|
2006-01-30 05:01:21 +00:00
|
|
|
from DdTargets import DdTargets
|
2006-01-15 01:26:47 +00:00
|
|
|
from GrampsWidgets import SimpleButton
|
|
|
|
|
2006-01-26 03:47:15 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-02-08 21:13:05 +00:00
|
|
|
dnddata = None
|
2006-01-13 00:45:22 +00:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2006-01-26 03:47:15 +00:00
|
|
|
# Classes
|
2006-01-13 00:45:22 +00:00
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-01-26 03:47:15 +00:00
|
|
|
|
2006-01-15 04:49:13 +00:00
|
|
|
class GrampsTab(gtk.HBox):
|
2006-01-26 03:47:15 +00:00
|
|
|
"""
|
|
|
|
This class provides the base level class for 'tabs', which are used to
|
|
|
|
fill in notebook tabs for GRAMPS edit dialogs. Each tab returns a
|
|
|
|
gtk container widget which can be inserted into a gtk.Notebook by the
|
|
|
|
instantiating object.
|
|
|
|
|
|
|
|
All tab classes should inherit from GrampsTab
|
|
|
|
"""
|
2006-01-13 00:45:22 +00:00
|
|
|
|
2006-01-15 04:49:13 +00:00
|
|
|
def __init__(self,dbstate,uistate,track,name):
|
2006-01-26 03:47:15 +00:00
|
|
|
"""
|
|
|
|
@param dbstate: The database state. Contains a reference to
|
|
|
|
the database, along with other state information. The GrampsTab
|
|
|
|
uses this to access the database and to pass to and created
|
|
|
|
child windows (such as edit dialogs).
|
|
|
|
@type dbstate: DbState
|
|
|
|
@param uistate: The UI state. Used primarily to pass to any created
|
|
|
|
subwindows.
|
|
|
|
@type uistate: DisplayState
|
|
|
|
@param track: The window tracking mechanism used to manage windows.
|
|
|
|
This is only used to pass to generted child windows.
|
|
|
|
@type track: list
|
|
|
|
@param name: Notebook label name
|
|
|
|
@type name: str/unicode
|
|
|
|
"""
|
2006-01-13 00:45:22 +00:00
|
|
|
gtk.HBox.__init__(self)
|
2006-01-26 03:47:15 +00:00
|
|
|
|
|
|
|
# store information to pass to child windows
|
2006-01-14 05:27:48 +00:00
|
|
|
self.dbstate = dbstate
|
|
|
|
self.uistate = uistate
|
|
|
|
self.track = track
|
2006-02-08 16:20:03 +00:00
|
|
|
self.changed = False
|
|
|
|
|
2006-01-26 03:47:15 +00:00
|
|
|
# save name used for notebook label, and build the widget used
|
|
|
|
# for the label
|
2006-01-13 00:45:22 +00:00
|
|
|
|
2006-01-26 03:47:15 +00:00
|
|
|
self.tab_name = name
|
|
|
|
self.label_container = self.build_label_widget()
|
2006-01-13 00:45:22 +00:00
|
|
|
|
2006-01-26 03:47:15 +00:00
|
|
|
# build the interface
|
2006-01-15 04:49:13 +00:00
|
|
|
self.build_interface()
|
2006-01-14 05:27:48 +00:00
|
|
|
|
2006-01-26 03:47:15 +00:00
|
|
|
def is_empty(self):
|
|
|
|
"""
|
|
|
|
Indicates if the tab contains any data. This is used to determine
|
|
|
|
how the label should be displayed.
|
|
|
|
"""
|
|
|
|
return True
|
|
|
|
|
|
|
|
def build_label_widget(self):
|
|
|
|
"""
|
|
|
|
Standard routine to build a widget. Does not need to be overridden
|
|
|
|
by the derrived class. Creates an container that has the label and
|
|
|
|
the icon in it.
|
|
|
|
@returns: widget to be used for the notebook label.
|
|
|
|
@rtype: gtk.HBox
|
|
|
|
"""
|
|
|
|
hbox = gtk.HBox()
|
|
|
|
self.tab_image = gtk.image_new_from_stock(self.get_icon_name(),
|
|
|
|
gtk.ICON_SIZE_MENU)
|
|
|
|
self.label = gtk.Label(self.tab_name)
|
|
|
|
hbox.pack_start(self.tab_image)
|
2006-01-30 05:01:21 +00:00
|
|
|
hbox.set_spacing(6)
|
2006-01-26 03:47:15 +00:00
|
|
|
hbox.add(self.label)
|
|
|
|
hbox.show_all()
|
|
|
|
return hbox
|
|
|
|
|
2006-01-15 04:49:13 +00:00
|
|
|
def get_icon_name(self):
|
2006-01-26 03:47:15 +00:00
|
|
|
"""
|
|
|
|
Provides the name of the registered stock icon to be used as the
|
|
|
|
icon in the label. This is typically overridden by the derrived
|
|
|
|
class to provide the new name.
|
|
|
|
@returns: stock icon name
|
|
|
|
@rtype: str
|
|
|
|
"""
|
2006-01-15 04:49:13 +00:00
|
|
|
return gtk.STOCK_NEW
|
|
|
|
|
|
|
|
def get_tab_widget(self):
|
2006-01-26 03:47:15 +00:00
|
|
|
"""
|
|
|
|
Provides the widget to be used for the notebook tab label. A
|
|
|
|
container class is provided, and the object may manipulate the
|
|
|
|
child widgets contained in the container.
|
|
|
|
@returns: gtk widget
|
|
|
|
@rtype: gtk.HBox
|
|
|
|
"""
|
|
|
|
return self.label_container
|
2006-01-15 04:49:13 +00:00
|
|
|
|
2006-01-26 22:31:34 +00:00
|
|
|
def _set_label(self):
|
2006-01-26 03:47:15 +00:00
|
|
|
"""
|
|
|
|
Updates the label based of if the tab contains information. Tabs
|
|
|
|
without information will not have an icon, and the text will not
|
|
|
|
be bold. Tabs that contain data will have their icon displayed and
|
|
|
|
the label text will be in bold face.
|
|
|
|
"""
|
|
|
|
if not self.is_empty():
|
2006-01-15 04:49:13 +00:00
|
|
|
self.tab_image.show()
|
|
|
|
self.label.set_text("<b>%s</b>" % self.tab_name)
|
|
|
|
self.label.set_use_markup(True)
|
2006-01-14 05:27:48 +00:00
|
|
|
else:
|
2006-01-15 04:49:13 +00:00
|
|
|
self.tab_image.hide()
|
|
|
|
self.label.set_text(self.tab_name)
|
|
|
|
|
|
|
|
def build_interface(self):
|
2006-01-26 03:47:15 +00:00
|
|
|
"""
|
|
|
|
Builds the interface for the derived class. This function should be
|
|
|
|
overridden in the derived class. Since the classes are derrived from
|
|
|
|
gtk.HBox, the self.pack_start, self.pack_end, and self.add functions
|
|
|
|
can be used to add widgets to the interface.
|
|
|
|
"""
|
2006-01-15 04:49:13 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
class ButtonTab(GrampsTab):
|
2006-01-26 03:47:15 +00:00
|
|
|
"""
|
|
|
|
This class derives from the base GrampsTab, yet is not a usable Tab. It
|
|
|
|
serves as another base tab for classes which need an Add/Edit/Remove button
|
|
|
|
combination.
|
|
|
|
"""
|
2006-01-15 04:49:13 +00:00
|
|
|
|
2006-02-10 01:10:52 +00:00
|
|
|
_MSG = {
|
|
|
|
'add' : _('Add'),
|
|
|
|
'del' : _('Remove'),
|
|
|
|
'edit' : _('Edit'),
|
|
|
|
'share' : _('Share'),
|
|
|
|
}
|
|
|
|
|
|
|
|
def __init__(self,dbstate,uistate,track,name,share_button=False):
|
2006-01-26 03:47:15 +00:00
|
|
|
"""
|
|
|
|
Similar to the base class, except after Build
|
|
|
|
@param dbstate: The database state. Contains a reference to
|
|
|
|
the database, along with other state information. The GrampsTab
|
|
|
|
uses this to access the database and to pass to and created
|
|
|
|
child windows (such as edit dialogs).
|
|
|
|
@type dbstate: DbState
|
|
|
|
@param uistate: The UI state. Used primarily to pass to any created
|
|
|
|
subwindows.
|
|
|
|
@type uistate: DisplayState
|
|
|
|
@param track: The window tracking mechanism used to manage windows.
|
|
|
|
This is only used to pass to generted child windows.
|
|
|
|
@type track: list
|
|
|
|
@param name: Notebook label name
|
|
|
|
@type name: str/unicode
|
|
|
|
"""
|
2006-01-15 04:49:13 +00:00
|
|
|
GrampsTab.__init__(self,dbstate,uistate,track,name)
|
2006-02-10 01:10:52 +00:00
|
|
|
self.tooltips = gtk.Tooltips()
|
|
|
|
self.create_buttons(share_button)
|
2006-01-14 05:27:48 +00:00
|
|
|
|
2006-02-20 04:59:20 +00:00
|
|
|
def create_buttons(self,share_button=False):
|
2006-01-26 22:31:34 +00:00
|
|
|
"""
|
|
|
|
Creates a button box consisting of three buttons, one for Add,
|
|
|
|
one for Edit, and one for Delete. This button box is then appended
|
|
|
|
hbox (self).
|
|
|
|
"""
|
2006-01-15 01:26:47 +00:00
|
|
|
self.add_btn = SimpleButton(gtk.STOCK_ADD, self.add_button_clicked)
|
|
|
|
self.edit_btn = SimpleButton(gtk.STOCK_EDIT, self.edit_button_clicked)
|
|
|
|
self.del_btn = SimpleButton(gtk.STOCK_REMOVE, self.del_button_clicked)
|
|
|
|
|
2006-02-10 01:10:52 +00:00
|
|
|
self.tooltips.set_tip(self.add_btn, self._MSG['add'])
|
|
|
|
self.tooltips.set_tip(self.edit_btn, self._MSG['edit'])
|
|
|
|
self.tooltips.set_tip(self.del_btn, self._MSG['del'])
|
|
|
|
|
|
|
|
if share_button:
|
|
|
|
self.share_btn = SimpleButton(gtk.STOCK_INDEX, self.share_button_clicked)
|
|
|
|
self.tooltips.set_tip(self.share_btn, self._MSG['share'])
|
|
|
|
|
2006-01-14 05:27:48 +00:00
|
|
|
vbox = gtk.VBox()
|
|
|
|
vbox.set_spacing(6)
|
|
|
|
vbox.pack_start(self.add_btn,False)
|
2006-02-10 01:10:52 +00:00
|
|
|
if share_button:
|
|
|
|
vbox.pack_start(self.share_btn,False)
|
2006-01-14 05:27:48 +00:00
|
|
|
vbox.pack_start(self.edit_btn,False)
|
|
|
|
vbox.pack_start(self.del_btn,False)
|
|
|
|
vbox.show_all()
|
|
|
|
self.pack_start(vbox,False)
|
|
|
|
|
2006-01-15 01:26:47 +00:00
|
|
|
def double_click(self, obj, event):
|
2006-01-26 22:31:34 +00:00
|
|
|
"""
|
|
|
|
Handles the double click on list. If the double click occurs,
|
|
|
|
the Edit button handler is called
|
|
|
|
"""
|
2006-01-18 22:33:27 +00:00
|
|
|
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
2006-01-15 01:26:47 +00:00
|
|
|
self.edit_button_clicked(obj)
|
2006-01-14 05:27:48 +00:00
|
|
|
|
|
|
|
def add_button_clicked(self,obj):
|
2006-01-26 22:31:34 +00:00
|
|
|
"""
|
|
|
|
Function called with the Add button is clicked. This function
|
|
|
|
should be overridden by the derived class.
|
|
|
|
"""
|
2006-01-15 05:12:05 +00:00
|
|
|
print "Uncaught Add clicked"
|
2006-01-14 05:27:48 +00:00
|
|
|
|
2006-02-10 01:10:52 +00:00
|
|
|
def share_button_clicked(self,obj):
|
|
|
|
"""
|
|
|
|
Function called with the Add button is clicked. This function
|
|
|
|
should be overridden by the derived class.
|
|
|
|
"""
|
|
|
|
print "Uncaught Share clicked"
|
|
|
|
|
2006-01-14 05:27:48 +00:00
|
|
|
def del_button_clicked(self,obj):
|
2006-01-26 22:31:34 +00:00
|
|
|
"""
|
|
|
|
Function called with the Delete button is clicked. This function
|
|
|
|
should be overridden by the derived class.
|
|
|
|
"""
|
2006-01-15 05:12:05 +00:00
|
|
|
print "Uncaught Delete clicked"
|
2006-01-14 05:27:48 +00:00
|
|
|
|
|
|
|
def edit_button_clicked(self,obj):
|
2006-01-26 22:31:34 +00:00
|
|
|
"""
|
|
|
|
Function called with the Edit button is clicked or the double
|
|
|
|
click is caught. This function should be overridden by the derived
|
|
|
|
class.
|
|
|
|
"""
|
2006-01-15 05:12:05 +00:00
|
|
|
print "Uncaught Edit clicked"
|
2006-01-14 05:27:48 +00:00
|
|
|
|
2006-02-08 16:20:03 +00:00
|
|
|
def _selection_changed(self,obj=None):
|
|
|
|
"""
|
|
|
|
Attached to the selection's 'changed' signal. Checks
|
|
|
|
to see if anything is selected. If it is, the edit and
|
|
|
|
delete buttons are enabled, otherwise the are disabled.
|
|
|
|
"""
|
|
|
|
if self.get_selected():
|
|
|
|
self.edit_btn.set_sensitive(True)
|
|
|
|
self.del_btn.set_sensitive(True)
|
|
|
|
else:
|
|
|
|
self.edit_btn.set_sensitive(False)
|
|
|
|
self.del_btn.set_sensitive(False)
|
|
|
|
|
2006-01-15 04:49:13 +00:00
|
|
|
class EmbeddedList(ButtonTab):
|
2006-01-26 22:31:34 +00:00
|
|
|
"""
|
|
|
|
This class provides the base class for all the list tabs. It
|
|
|
|
maintains a gtk.TreeView, including the selection and button
|
|
|
|
sensitivity.
|
|
|
|
"""
|
|
|
|
|
2006-01-15 04:49:13 +00:00
|
|
|
_HANDLE_COL = -1
|
2006-01-31 15:13:54 +00:00
|
|
|
_DND_TYPE = None
|
2006-01-15 04:49:13 +00:00
|
|
|
|
2006-02-10 01:10:52 +00:00
|
|
|
def __init__(self, dbstate, uistate, track, name, build_model,share=False):
|
2006-01-26 22:31:34 +00:00
|
|
|
"""
|
|
|
|
Creates a new list, using the passed build_model to
|
|
|
|
populate the list.
|
|
|
|
"""
|
2006-02-10 01:10:52 +00:00
|
|
|
ButtonTab.__init__(self, dbstate, uistate, track, name, share)
|
2006-01-31 15:13:54 +00:00
|
|
|
self.changed = False
|
2006-01-15 04:49:13 +00:00
|
|
|
self.build_model = build_model
|
|
|
|
|
2006-01-26 22:31:34 +00:00
|
|
|
# handle the selection
|
2006-01-15 04:49:13 +00:00
|
|
|
self.selection = self.tree.get_selection()
|
2006-01-26 22:31:34 +00:00
|
|
|
self.selection.connect('changed',self._selection_changed)
|
|
|
|
|
|
|
|
# build the columns
|
2006-01-15 04:49:13 +00:00
|
|
|
self.columns = []
|
|
|
|
self.build_columns()
|
2006-01-26 22:31:34 +00:00
|
|
|
|
2006-02-02 22:48:21 +00:00
|
|
|
if self._DND_TYPE:
|
|
|
|
self._set_dnd()
|
2006-01-30 05:01:21 +00:00
|
|
|
|
2006-01-26 22:31:34 +00:00
|
|
|
# build the initial data
|
2006-01-15 04:49:13 +00:00
|
|
|
self.rebuild()
|
|
|
|
self.show_all()
|
|
|
|
|
2006-01-31 15:13:54 +00:00
|
|
|
def find_index(self,obj):
|
|
|
|
"""
|
|
|
|
returns the index of the object within the associated data
|
|
|
|
"""
|
|
|
|
return self.get_data().index(obj)
|
|
|
|
|
|
|
|
def _set_dnd(self):
|
|
|
|
"""
|
|
|
|
Sets up drag-n-drop. The source and destionation are set by calling .target()
|
|
|
|
on the _DND_TYPE. Obviously, this means that there must be a _DND_TYPE
|
|
|
|
variable defined that points to an entry in DdTargets.
|
|
|
|
"""
|
|
|
|
self.tree.drag_dest_set(gtk.DEST_DEFAULT_ALL, [self._DND_TYPE.target()],
|
2006-01-30 05:01:21 +00:00
|
|
|
ACTION_COPY)
|
2006-01-31 15:13:54 +00:00
|
|
|
self.tree.drag_source_set(BUTTON1_MASK, [self._DND_TYPE.target()], ACTION_COPY)
|
2006-01-30 05:01:21 +00:00
|
|
|
self.tree.connect('drag_data_get', self.drag_data_get)
|
|
|
|
self.tree.connect('drag_data_received', self.drag_data_received)
|
|
|
|
|
|
|
|
def drag_data_get(self,widget, context, sel_data, info, time):
|
2006-01-31 15:13:54 +00:00
|
|
|
"""
|
|
|
|
Provide the drag_data_get function, which passes a tuple consisting of:
|
|
|
|
|
|
|
|
1) Drag type defined by the .drag_type field specfied by the value
|
|
|
|
assigned to _DND_TYPE
|
|
|
|
2) The id value of this object, used for the purpose of determining
|
|
|
|
the source of the object. If the source of the object is the same
|
|
|
|
as the object, we are doing a reorder instead of a normal drag
|
|
|
|
and drop
|
|
|
|
3) Pickled data. The pickled version of the selected object
|
|
|
|
4) Source row. Used for a reorder to determine the original position
|
|
|
|
of the object
|
|
|
|
"""
|
|
|
|
|
|
|
|
# get the selected object, returning if not is defined
|
2006-01-30 05:01:21 +00:00
|
|
|
obj = self.get_selected()
|
|
|
|
if not obj:
|
|
|
|
return
|
|
|
|
|
2006-01-31 15:13:54 +00:00
|
|
|
# pickle the data, and build the tuple to be passed
|
2006-01-30 05:01:21 +00:00
|
|
|
pickled = pickle.dumps(obj);
|
2006-01-31 15:13:54 +00:00
|
|
|
data = str((self._DND_TYPE.drag_type, id(self), pickled, self.find_index(obj)))
|
|
|
|
|
|
|
|
# pass as a string (8 bits)
|
|
|
|
sel_data.set(sel_data.target, 8, data)
|
2006-01-30 05:01:21 +00:00
|
|
|
|
|
|
|
def drag_data_received(self,widget,context,x,y,sel_data,info,time):
|
2006-01-31 15:13:54 +00:00
|
|
|
"""
|
|
|
|
Handle the standard gtk interface for drag_data_received.
|
|
|
|
|
|
|
|
If the selection data is define, extract the value from sel_data.data,
|
|
|
|
and decide if this is a move or a reorder.
|
|
|
|
"""
|
2006-01-30 05:01:21 +00:00
|
|
|
if sel_data and sel_data.data:
|
|
|
|
exec 'dnddata = %s' % sel_data.data
|
|
|
|
mytype = dnddata[0]
|
|
|
|
selfid = dnddata[1]
|
|
|
|
obj = pickle.loads(dnddata[2])
|
2006-01-31 15:13:54 +00:00
|
|
|
row_from = dnddata[3]
|
|
|
|
|
|
|
|
# make sure this is the correct DND type for this object
|
|
|
|
if mytype == self._DND_TYPE.drag_type:
|
|
|
|
|
|
|
|
# determine the destination row
|
|
|
|
row = self._find_row(x,y)
|
|
|
|
|
|
|
|
# if the is same object, we have a move, otherwise,
|
|
|
|
# it is a standard drag-n-drop
|
|
|
|
|
2006-01-30 05:01:21 +00:00
|
|
|
if id(self) == selfid:
|
2006-01-31 15:13:54 +00:00
|
|
|
self._move(row_from,row,obj)
|
2006-01-30 05:01:21 +00:00
|
|
|
else:
|
2006-01-31 15:13:54 +00:00
|
|
|
self._handle_drag(row,obj)
|
2006-01-30 05:01:21 +00:00
|
|
|
self.rebuild()
|
|
|
|
|
2006-01-31 15:13:54 +00:00
|
|
|
def _find_row(self,x,y):
|
|
|
|
row = self.tree.get_path_at_pos(x,y)
|
|
|
|
if row == None:
|
|
|
|
return len(self.get_data())
|
|
|
|
else:
|
|
|
|
return row[0][0]
|
2006-01-30 05:01:21 +00:00
|
|
|
|
2006-01-31 15:13:54 +00:00
|
|
|
def _handle_drag(self, row, obj):
|
|
|
|
self.get_data().insert(row,obj)
|
|
|
|
self.changed = True
|
|
|
|
self.rebuild()
|
|
|
|
|
|
|
|
def _move(self, row_from, row_to, obj):
|
|
|
|
dlist = self.get_data()
|
|
|
|
if row_from < row_to:
|
|
|
|
dlist.insert(row_to,obj)
|
|
|
|
del dlist[row_from]
|
|
|
|
else:
|
|
|
|
del dlist[row_from]
|
|
|
|
dlist.insert(row_to-1,obj)
|
|
|
|
self.changed = True
|
|
|
|
self.rebuild()
|
2006-01-30 05:01:21 +00:00
|
|
|
|
2006-01-15 05:12:05 +00:00
|
|
|
def get_icon_name(self):
|
2006-01-26 22:31:34 +00:00
|
|
|
"""
|
|
|
|
Specifies the basic icon used for a generic list. Typically,
|
|
|
|
a derived class will override this. The icon chose is the
|
|
|
|
STOCK_JUSTIFY_FILL icon, which in the default GTK style
|
|
|
|
looks kind of like a list.
|
|
|
|
"""
|
2006-01-15 05:12:05 +00:00
|
|
|
return gtk.STOCK_JUSTIFY_FILL
|
|
|
|
|
2006-02-01 21:57:11 +00:00
|
|
|
def del_button_clicked(self,obj):
|
|
|
|
ref = self.get_selected()
|
|
|
|
if ref:
|
|
|
|
ref_list = self.get_data()
|
|
|
|
ref_list.remove(ref)
|
|
|
|
self.changed = True
|
|
|
|
self.rebuild()
|
|
|
|
|
2006-01-15 04:49:13 +00:00
|
|
|
def build_interface(self):
|
2006-01-26 22:31:34 +00:00
|
|
|
"""
|
|
|
|
Builds the interface, instantiating a gtk.TreeView in a
|
|
|
|
gtk.ScrolledWindow.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# create the tree, turn on rule hinting and connect the
|
|
|
|
# button press to the double click function.
|
|
|
|
|
2006-01-15 04:49:13 +00:00
|
|
|
self.tree = gtk.TreeView()
|
2006-01-30 05:01:21 +00:00
|
|
|
self.tree.set_reorderable(True)
|
2006-01-15 04:49:13 +00:00
|
|
|
self.tree.set_rules_hint(True)
|
|
|
|
self.tree.connect('button_press_event',self.double_click)
|
|
|
|
|
2006-01-26 22:31:34 +00:00
|
|
|
# create the scrolled window, and attach the treeview
|
2006-01-15 04:49:13 +00:00
|
|
|
scroll = gtk.ScrolledWindow()
|
|
|
|
scroll.set_shadow_type(gtk.SHADOW_IN)
|
|
|
|
scroll.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
|
|
|
|
scroll.add(self.tree)
|
|
|
|
self.pack_start(scroll,True)
|
|
|
|
|
|
|
|
def get_selected(self):
|
2006-01-26 22:31:34 +00:00
|
|
|
"""
|
|
|
|
returns the value associated with selected row in the model,
|
|
|
|
based of the _HANDLE_COL value. Each model must define this
|
|
|
|
to indicate what the returned value should be. If no selection
|
|
|
|
has been made, None is returned.
|
|
|
|
"""
|
2006-01-15 04:49:13 +00:00
|
|
|
(model,node) = self.selection.get_selected()
|
|
|
|
if node:
|
|
|
|
return model.get_value(node,self._HANDLE_COL)
|
2006-01-29 04:50:11 +00:00
|
|
|
return None
|
2006-01-15 04:49:13 +00:00
|
|
|
|
2006-01-26 03:47:15 +00:00
|
|
|
def is_empty(self):
|
2006-01-26 22:31:34 +00:00
|
|
|
"""
|
|
|
|
Returns True if the get_data returns a length greater than
|
|
|
|
0. Typically, get_data returns the list of associated data.
|
|
|
|
"""
|
2006-01-29 04:30:16 +00:00
|
|
|
return len(self.get_data()) == 0
|
2006-01-26 03:47:15 +00:00
|
|
|
|
2006-01-13 00:45:22 +00:00
|
|
|
def get_data(self):
|
2006-01-26 22:31:34 +00:00
|
|
|
"""
|
|
|
|
Returns the data associated with the list. This is typically
|
|
|
|
a list of objects.
|
|
|
|
|
|
|
|
This should be overridden in the derrived classes.
|
|
|
|
"""
|
2006-01-13 00:45:22 +00:00
|
|
|
return []
|
|
|
|
|
|
|
|
def column_order(self):
|
2006-01-26 22:31:34 +00:00
|
|
|
"""
|
|
|
|
Specifies the column order for the columns. This should be
|
|
|
|
in the format of a list of tuples, in the format of (int,int),
|
|
|
|
where the first in indicates if the column is visible, and the
|
|
|
|
second column indicates the index into the model.
|
|
|
|
|
|
|
|
This should be overridden in the derrived classes.
|
|
|
|
"""
|
2006-01-13 00:45:22 +00:00
|
|
|
return []
|
|
|
|
|
|
|
|
def build_columns(self):
|
2006-01-26 22:31:34 +00:00
|
|
|
"""
|
|
|
|
Builds the columns and inserts them into the TreeView. Any
|
|
|
|
previous columns exist, they will be in the self.columns array,
|
|
|
|
and removed.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# remove any existing columns, which would be stored in
|
|
|
|
# self.columns
|
|
|
|
|
2006-01-13 00:45:22 +00:00
|
|
|
for column in self.columns:
|
|
|
|
self.tree.remove_column(column)
|
|
|
|
self.columns = []
|
|
|
|
|
2006-01-26 22:31:34 +00:00
|
|
|
# loop through the values returned by column_order
|
|
|
|
|
2006-01-13 00:45:22 +00:00
|
|
|
for pair in self.column_order():
|
2006-01-26 22:31:34 +00:00
|
|
|
|
|
|
|
# if the first value isn't 1, then we skip the values
|
2006-01-13 00:45:22 +00:00
|
|
|
if not pair[0]:
|
|
|
|
continue
|
2006-01-26 22:31:34 +00:00
|
|
|
|
|
|
|
# extract the name from the _column_names variable, and
|
|
|
|
# assign it to the column name. The text value is extracted
|
|
|
|
# from the model column specified in pair[1]
|
|
|
|
name = self._column_names[pair[1]][0]
|
2006-01-30 05:01:21 +00:00
|
|
|
renderer = gtk.CellRendererText()
|
|
|
|
renderer.set_property('ellipsize',pango.ELLIPSIZE_END)
|
|
|
|
column = gtk.TreeViewColumn(name, renderer, text=pair[1])
|
2006-01-26 22:31:34 +00:00
|
|
|
|
|
|
|
# insert the colum into the tree
|
2006-01-13 00:45:22 +00:00
|
|
|
column.set_resizable(True)
|
2006-01-30 05:01:21 +00:00
|
|
|
column.set_min_width(self._column_names[pair[1]][2])
|
2006-01-26 22:31:34 +00:00
|
|
|
column.set_sort_column_id(self._column_names[pair[1]][1])
|
2006-01-13 00:45:22 +00:00
|
|
|
self.columns.append(column)
|
|
|
|
self.tree.append_column(column)
|
|
|
|
|
|
|
|
def rebuild(self):
|
2006-01-26 22:31:34 +00:00
|
|
|
"""
|
|
|
|
Rebuilds the data in the database by creating a new model,
|
|
|
|
using the build_model function passed at creation time.
|
|
|
|
"""
|
2006-01-14 05:27:48 +00:00
|
|
|
self.model = self.build_model(self.get_data(),self.dbstate.db)
|
2006-01-13 00:45:22 +00:00
|
|
|
self.tree.set_model(self.model)
|
2006-01-26 22:31:34 +00:00
|
|
|
self._set_label()
|
|
|
|
self._selection_changed()
|
2006-01-13 00:45:22 +00:00
|
|
|
|
2006-01-14 05:27:48 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# EventEmbedList
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-01-13 22:28:54 +00:00
|
|
|
class EventEmbedList(EmbeddedList):
|
|
|
|
|
2006-01-15 01:26:47 +00:00
|
|
|
_HANDLE_COL = 6
|
2006-01-31 15:13:54 +00:00
|
|
|
_DND_TYPE = DdTargets.EVENTREF
|
2006-01-15 01:26:47 +00:00
|
|
|
|
2006-02-10 01:10:52 +00:00
|
|
|
_MSG = {
|
|
|
|
'add' : _('Add a new event'),
|
|
|
|
'del' : _('Remove the selected event'),
|
|
|
|
'edit' : _('Edit the selected event'),
|
|
|
|
'share' : _('Share an exisiting event'),
|
|
|
|
}
|
|
|
|
|
2006-01-26 22:31:34 +00:00
|
|
|
_column_names = [
|
2006-01-30 05:01:21 +00:00
|
|
|
(_('Type'),0,100),
|
2006-02-04 23:29:44 +00:00
|
|
|
(_('Description'),1,175),
|
2006-01-30 05:01:21 +00:00
|
|
|
(_('ID'),2, 60),
|
|
|
|
(_('Date'),3, 150),
|
|
|
|
(_('Place'),4, 140),
|
|
|
|
(_('Role'),5, 80),
|
2006-01-13 22:28:54 +00:00
|
|
|
]
|
|
|
|
|
2006-01-14 05:27:48 +00:00
|
|
|
def __init__(self,dbstate,uistate,track,obj):
|
2006-01-13 22:28:54 +00:00
|
|
|
self.obj = obj
|
2006-01-15 04:49:13 +00:00
|
|
|
EmbeddedList.__init__(self, dbstate, uistate, track,
|
2006-02-10 01:10:52 +00:00
|
|
|
_('Events'), EventRefModel, True)
|
2006-01-15 04:49:13 +00:00
|
|
|
|
|
|
|
def get_icon_name(self):
|
|
|
|
return 'gramps-event'
|
2006-01-13 22:28:54 +00:00
|
|
|
|
|
|
|
def get_data(self):
|
|
|
|
return self.obj.get_event_ref_list()
|
|
|
|
|
|
|
|
def column_order(self):
|
|
|
|
return ((1,0),(1,1),(1,2),(1,3),(1,4),(1,5))
|
|
|
|
|
2006-01-15 01:26:47 +00:00
|
|
|
def add_button_clicked(self,obj):
|
2006-02-22 00:12:52 +00:00
|
|
|
from EditEventRef import EditEventRef
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
|
|
|
EditEventRef(self.dbstate,self.uistate,self.track,
|
|
|
|
None, None, self.obj, self.event_added)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-02-10 01:10:52 +00:00
|
|
|
|
|
|
|
def share_button_clicked(self,obj):
|
2006-02-22 00:12:52 +00:00
|
|
|
from EditEventRef import EditEventRef
|
2006-02-10 01:10:52 +00:00
|
|
|
import SelectEvent
|
|
|
|
|
|
|
|
sel = SelectEvent.SelectEvent(self.dbstate.db,"Event Select")
|
|
|
|
event = sel.run()
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
|
|
|
EditEventRef(self.dbstate,self.uistate,self.track,
|
|
|
|
event, None, self.obj, self.event_added)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-01-15 01:26:47 +00:00
|
|
|
|
|
|
|
def edit_button_clicked(self,obj):
|
|
|
|
ref = self.get_selected()
|
|
|
|
if ref:
|
2006-02-22 00:12:52 +00:00
|
|
|
from EditEventRef import EditEventRef
|
2006-01-29 05:53:17 +00:00
|
|
|
event = self.dbstate.db.get_event_from_handle(ref.ref)
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
|
|
|
EditEventRef(self.dbstate,self.uistate,self.track,
|
|
|
|
event, ref, self.obj, self.event_updated)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-01-29 05:53:17 +00:00
|
|
|
|
|
|
|
def event_updated(self,value):
|
|
|
|
self.changed = True
|
|
|
|
self.rebuild()
|
2006-01-15 01:26:47 +00:00
|
|
|
|
2006-01-29 05:53:17 +00:00
|
|
|
def event_added(self,value):
|
2006-01-30 05:01:21 +00:00
|
|
|
value[0].ref = value[1].handle
|
2006-02-10 01:10:52 +00:00
|
|
|
self.get_data().append(value[0])
|
2006-01-29 05:53:17 +00:00
|
|
|
self.changed = True
|
|
|
|
self.rebuild()
|
2006-01-30 05:01:21 +00:00
|
|
|
|
|
|
|
class PersonEventEmbedList(EventEmbedList):
|
|
|
|
|
2006-01-31 15:13:54 +00:00
|
|
|
def __init__(self,dbstate,uistate,track,obj):
|
2006-02-03 22:31:46 +00:00
|
|
|
self.orig_data = [ data for data in [ obj.get_birth_ref(), \
|
|
|
|
obj.get_death_ref()] + \
|
2006-01-31 15:13:54 +00:00
|
|
|
obj.get_event_ref_list() \
|
|
|
|
if data ]
|
2006-01-30 05:01:21 +00:00
|
|
|
EventEmbedList.__init__(self, dbstate, uistate, track, obj)
|
|
|
|
|
|
|
|
def get_data(self):
|
2006-01-31 15:13:54 +00:00
|
|
|
return self.orig_data
|
2006-02-10 01:10:52 +00:00
|
|
|
|
|
|
|
def return_info(self):
|
|
|
|
new_list = []
|
|
|
|
birth_ref = None
|
|
|
|
death_ref = None
|
|
|
|
|
|
|
|
for ref in self.orig_data:
|
|
|
|
event = self.dbstate.db.get_event_from_handle(ref.ref)
|
|
|
|
if birth_ref == None and event.get_type()[0] == RelLib.Event.BIRTH:
|
|
|
|
birth_ref = ref
|
|
|
|
elif death_ref == None and event.get_type()[0] == RelLib.Event.DEATH:
|
|
|
|
death_ref = ref
|
|
|
|
else:
|
|
|
|
new_list.append(ref)
|
|
|
|
return (birth_ref, death_ref, new_list)
|
|
|
|
|
2006-01-25 05:07:10 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2006-02-24 22:00:20 +00:00
|
|
|
# BackRefList
|
2006-01-25 05:07:10 +00:00
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-02-24 22:00:20 +00:00
|
|
|
class BackRefList(EmbeddedList):
|
2006-01-25 05:07:10 +00:00
|
|
|
|
|
|
|
_HANDLE_COL = 3
|
|
|
|
|
2006-01-26 22:31:34 +00:00
|
|
|
_column_names = [
|
2006-01-30 05:01:21 +00:00
|
|
|
(_('Type'),0, 100),
|
|
|
|
(_('ID'), 1, 75),
|
|
|
|
(_('Name'),2, 250),
|
2006-01-25 05:07:10 +00:00
|
|
|
]
|
|
|
|
|
2006-02-24 22:00:20 +00:00
|
|
|
def __init__(self,dbstate,uistate,track,obj,refmodel):
|
2006-01-25 05:07:10 +00:00
|
|
|
self.obj = obj
|
|
|
|
EmbeddedList.__init__(self, dbstate, uistate, track,
|
2006-02-24 22:00:20 +00:00
|
|
|
_('References'), refmodel)
|
|
|
|
self.model.connect('row-inserted',self.update_label)
|
|
|
|
|
|
|
|
def update_label(self,*obj):
|
|
|
|
if not self.model.empty:
|
|
|
|
self._set_label()
|
2006-01-25 05:07:10 +00:00
|
|
|
|
2006-01-25 17:59:22 +00:00
|
|
|
def close(self):
|
|
|
|
self.model.close()
|
|
|
|
|
2006-02-24 22:00:20 +00:00
|
|
|
def is_empty(self):
|
|
|
|
return self.model.empty
|
2006-01-25 05:07:10 +00:00
|
|
|
|
2006-02-20 04:59:20 +00:00
|
|
|
def create_buttons(self,share=False):
|
2006-01-25 05:07:10 +00:00
|
|
|
self.edit_btn = SimpleButton(gtk.STOCK_EDIT, self.edit_button_clicked)
|
|
|
|
|
|
|
|
vbox = gtk.VBox()
|
|
|
|
vbox.set_spacing(6)
|
|
|
|
vbox.pack_start(self.edit_btn,False)
|
|
|
|
vbox.show_all()
|
|
|
|
self.pack_start(vbox,False)
|
|
|
|
|
2006-01-26 22:31:34 +00:00
|
|
|
def _selection_changed(self,obj=None):
|
2006-01-25 05:07:10 +00:00
|
|
|
if self.get_selected():
|
|
|
|
self.edit_btn.set_sensitive(True)
|
|
|
|
else:
|
|
|
|
self.edit_btn.set_sensitive(False)
|
|
|
|
|
|
|
|
def get_data(self):
|
|
|
|
return self.obj
|
|
|
|
|
|
|
|
def column_order(self):
|
|
|
|
return ((1,0),(1,1),(1,2))
|
|
|
|
|
2006-03-01 23:27:45 +00:00
|
|
|
def find_node(self):
|
|
|
|
(model,node) = self.selection.get_selected()
|
|
|
|
try:
|
|
|
|
return (model.get_value(node,0),model.get_value(node,3))
|
|
|
|
except:
|
|
|
|
return (None,None)
|
|
|
|
|
2006-01-25 05:07:10 +00:00
|
|
|
def edit_button_clicked(self,obj):
|
2006-03-01 23:27:45 +00:00
|
|
|
(reftype, ref) = self.find_node()
|
|
|
|
if reftype == 'Person':
|
|
|
|
try:
|
|
|
|
import EditPerson
|
|
|
|
|
|
|
|
person = self.dbstate.db.get_person_from_handle(ref)
|
|
|
|
EditPerson.EditPerson(self.dbstate, self.uistate, [], person)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
|
|
|
elif reftype == 'Family':
|
|
|
|
try:
|
|
|
|
import EditFamily
|
|
|
|
|
|
|
|
family = self.dbstate.db.get_family_from_handle(ref)
|
|
|
|
EditFamily.EditFamily(self.dbstate, self.uistate, [], family)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
|
|
|
elif reftype == 'Source':
|
|
|
|
try:
|
|
|
|
import EditFamily
|
|
|
|
|
|
|
|
source = self.dbstate.db.get_source_from_handle(ref)
|
|
|
|
EditSource.EditSource(self.dbstate, self.uistate, [], source)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
|
|
|
elif reftype == 'Place':
|
|
|
|
try:
|
|
|
|
import EditPlace
|
|
|
|
|
|
|
|
place = self.dbstate.db.get_place_from_handle(ref)
|
|
|
|
EditPlace.EditPlace(self.dbstate,self.uistate,[],place)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
|
|
|
elif reftype == 'Media':
|
|
|
|
try:
|
|
|
|
import EditMedia
|
|
|
|
|
|
|
|
obj = self.dbstate.db.get_object_from_handle(ref)
|
|
|
|
EditMedia.EditMedia(self.dbstate,self.uistate, [], obj)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-01-25 05:07:10 +00:00
|
|
|
|
2006-02-24 22:00:20 +00:00
|
|
|
class SourceBackRefList(BackRefList):
|
|
|
|
|
|
|
|
def __init__(self,dbstate,uistate,track,obj):
|
|
|
|
BackRefList.__init__(self, dbstate, uistate, track, obj,
|
|
|
|
BackRefModel)
|
|
|
|
|
|
|
|
def get_icon_name(self):
|
|
|
|
return 'gramps-source'
|
|
|
|
|
|
|
|
class EventBackRefList(BackRefList):
|
|
|
|
|
|
|
|
def __init__(self,dbstate,uistate,track,obj):
|
|
|
|
BackRefList.__init__(self, dbstate, uistate, track, obj,
|
|
|
|
BackRefModel)
|
|
|
|
|
|
|
|
def get_icon_name(self):
|
|
|
|
return 'gramps-event'
|
|
|
|
|
|
|
|
class MediaBackRefList(BackRefList):
|
|
|
|
|
|
|
|
def __init__(self,dbstate,uistate,track,obj):
|
|
|
|
BackRefList.__init__(self, dbstate, uistate, track, obj,
|
|
|
|
BackRefModel)
|
|
|
|
|
|
|
|
def get_icon_name(self):
|
|
|
|
return 'gramps-media'
|
|
|
|
|
|
|
|
class PlaceBackRefList(BackRefList):
|
|
|
|
|
|
|
|
def __init__(self,dbstate,uistate,track,obj):
|
|
|
|
BackRefList.__init__(self, dbstate, uistate, track, obj,
|
|
|
|
BackRefModel)
|
|
|
|
|
|
|
|
def get_icon_name(self):
|
|
|
|
return 'gramps-place'
|
|
|
|
|
|
|
|
|
2006-01-25 05:07:10 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# DataEmbedList
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class DataEmbedList(EmbeddedList):
|
|
|
|
|
2006-02-02 22:48:21 +00:00
|
|
|
_DND_TYPE = DdTargets.DATA
|
2006-01-26 22:31:34 +00:00
|
|
|
_column_names = [
|
2006-01-30 05:01:21 +00:00
|
|
|
(_('Key'),0,150),
|
|
|
|
(_('Value'),1,250),
|
2006-01-25 05:07:10 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
def __init__(self,dbstate,uistate,track,obj):
|
|
|
|
self.obj = obj
|
|
|
|
|
|
|
|
EmbeddedList.__init__(self, dbstate, uistate, track,
|
|
|
|
_('Data'), DataModel)
|
|
|
|
|
|
|
|
def get_data(self):
|
|
|
|
return self.obj.get_data_map()
|
|
|
|
|
|
|
|
def column_order(self):
|
|
|
|
return ((1,0),(1,1))
|
|
|
|
|
|
|
|
def add_button_clicked(self,obj):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def del_button_clicked(self,obj):
|
|
|
|
ref = self.get_selected()
|
|
|
|
if ref:
|
|
|
|
ref_list = self.obj.get_data_map()
|
|
|
|
ref_list.remove(ref)
|
|
|
|
self.rebuild()
|
|
|
|
|
|
|
|
def edit_button_clicked(self,obj):
|
|
|
|
ref = self.get_selected()
|
|
|
|
if ref:
|
|
|
|
print ref
|
|
|
|
|
2006-01-29 04:30:16 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class AttrEmbedList(EmbeddedList):
|
|
|
|
|
2006-01-29 05:53:17 +00:00
|
|
|
_HANDLE_COL = 2
|
2006-01-31 15:13:54 +00:00
|
|
|
_DND_TYPE = DdTargets.ATTRIBUTE
|
2006-01-29 04:30:16 +00:00
|
|
|
|
|
|
|
_column_names = [
|
2006-01-30 05:01:21 +00:00
|
|
|
(_('Type'),0,250),
|
|
|
|
(_('Value'),1,200),
|
2006-01-29 04:30:16 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
def __init__(self,dbstate,uistate,track,data):
|
|
|
|
self.data = data
|
|
|
|
EmbeddedList.__init__(self, dbstate, uistate, track,
|
|
|
|
_('Attributes'), AttrModel)
|
|
|
|
|
|
|
|
def get_data(self):
|
|
|
|
return self.data
|
|
|
|
|
|
|
|
def column_order(self):
|
|
|
|
return ((1,0),(1,1))
|
|
|
|
|
2006-02-01 21:57:11 +00:00
|
|
|
def add_button_clicked(self,obj):
|
2006-03-03 00:29:52 +00:00
|
|
|
import EditAttribute
|
2006-02-01 21:57:11 +00:00
|
|
|
pname = ''
|
|
|
|
attr_list = []
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
2006-03-03 00:29:52 +00:00
|
|
|
EditAttribute.EditAttribute(
|
2006-03-01 05:08:11 +00:00
|
|
|
self.dbstate, self.uistate, self.track, None,
|
|
|
|
pname, attr_list, self.add_callback)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-02-01 21:57:11 +00:00
|
|
|
|
|
|
|
def add_callback(self,name):
|
|
|
|
self.get_data().append(name)
|
|
|
|
self.changed = True
|
|
|
|
self.rebuild()
|
|
|
|
|
|
|
|
def edit_button_clicked(self,obj):
|
|
|
|
attr = self.get_selected()
|
|
|
|
if attr:
|
2006-03-03 00:29:52 +00:00
|
|
|
import EditAttribute
|
2006-02-01 21:57:11 +00:00
|
|
|
pname = ''
|
|
|
|
attr_list = []
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
2006-03-03 00:29:52 +00:00
|
|
|
EditAttribute.EditAttribute(
|
2006-03-01 05:08:11 +00:00
|
|
|
self.dbstate, self.uistate, self.track, attr,
|
|
|
|
pname, attr_list, self.edit_callback)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-02-01 21:57:11 +00:00
|
|
|
|
|
|
|
def edit_callback(self,name):
|
|
|
|
self.changed = True
|
|
|
|
self.rebuild()
|
|
|
|
|
2006-01-29 04:30:16 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class WebEmbedList(EmbeddedList):
|
|
|
|
|
2006-02-01 21:57:11 +00:00
|
|
|
_HANDLE_COL = 3
|
2006-01-31 15:13:54 +00:00
|
|
|
_DND_TYPE = DdTargets.URL
|
2006-01-29 04:30:16 +00:00
|
|
|
|
|
|
|
_column_names = [
|
2006-01-30 05:01:21 +00:00
|
|
|
(_('Type') ,0, 100),
|
|
|
|
(_('Path') ,1, 200),
|
|
|
|
(_('Description'),2, 150),
|
2006-01-29 04:30:16 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
def __init__(self,dbstate,uistate,track,data):
|
|
|
|
self.data = data
|
|
|
|
EmbeddedList.__init__(self, dbstate, uistate, track,
|
|
|
|
_('Internet'), WebModel)
|
|
|
|
|
|
|
|
def get_data(self):
|
|
|
|
return self.data
|
|
|
|
|
|
|
|
def column_order(self):
|
|
|
|
return ((1,0),(1,1),(1,2))
|
|
|
|
|
2006-02-01 21:57:11 +00:00
|
|
|
def add_button_clicked(self,obj):
|
2006-03-03 04:27:56 +00:00
|
|
|
import EditUrl
|
2006-02-01 21:57:11 +00:00
|
|
|
url = RelLib.Url()
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
2006-03-03 04:29:02 +00:00
|
|
|
EditUrl.EditUrl(self.dbstate, self.uistate, self.track,
|
|
|
|
'', url, self.add_callback)
|
2006-03-01 05:08:11 +00:00
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-02-01 21:57:11 +00:00
|
|
|
|
|
|
|
def add_callback(self,url):
|
|
|
|
self.get_data().append(url)
|
|
|
|
self.rebuild()
|
|
|
|
|
|
|
|
def edit_button_clicked(self,obj):
|
|
|
|
url = self.get_selected()
|
|
|
|
if url:
|
2006-03-03 04:27:56 +00:00
|
|
|
import EditUrl
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
2006-03-03 04:29:02 +00:00
|
|
|
EditUrl.EditUrl(self.dbstate, self.uistate, self.track,
|
|
|
|
'', url, self.edit_callback)
|
2006-03-01 05:08:11 +00:00
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-02-01 21:57:11 +00:00
|
|
|
|
|
|
|
def edit_callback(self,url):
|
|
|
|
self.rebuild()
|
|
|
|
|
2006-01-29 04:30:16 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class NameEmbedList(EmbeddedList):
|
|
|
|
|
2006-02-01 21:57:11 +00:00
|
|
|
_HANDLE_COL = 2
|
2006-01-31 15:13:54 +00:00
|
|
|
_DND_TYPE = DdTargets.NAME
|
2006-01-29 04:30:16 +00:00
|
|
|
|
|
|
|
_column_names = [
|
2006-01-30 05:01:21 +00:00
|
|
|
(_('Name'),0, 250),
|
|
|
|
(_('Type'),1, 100),
|
2006-01-29 04:30:16 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
def __init__(self,dbstate,uistate,track,data):
|
|
|
|
self.data = data
|
|
|
|
EmbeddedList.__init__(self, dbstate, uistate, track,
|
|
|
|
_('Names'), NameModel)
|
|
|
|
|
|
|
|
def get_data(self):
|
|
|
|
return self.data
|
|
|
|
|
|
|
|
def column_order(self):
|
|
|
|
return ((1,0),(1,1))
|
|
|
|
|
2006-02-01 21:57:11 +00:00
|
|
|
def add_button_clicked(self,obj):
|
2006-03-04 04:26:08 +00:00
|
|
|
import EditName
|
2006-02-01 21:57:11 +00:00
|
|
|
name = RelLib.Name()
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
2006-03-04 04:26:08 +00:00
|
|
|
EditName.EditName(self.dbstate, self.uistate, self.track,
|
|
|
|
name, self.add_callback)
|
2006-03-01 05:08:11 +00:00
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-02-01 21:57:11 +00:00
|
|
|
|
|
|
|
def add_callback(self,name):
|
|
|
|
self.get_data().append(name)
|
|
|
|
self.rebuild()
|
|
|
|
|
|
|
|
def edit_button_clicked(self,obj):
|
|
|
|
name = self.get_selected()
|
|
|
|
if name:
|
2006-03-04 04:26:08 +00:00
|
|
|
import EditName
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
2006-03-04 04:26:08 +00:00
|
|
|
EditName.EditName(self.dbstate, self.uistate, self.track,
|
|
|
|
name, self.edit_callback)
|
2006-03-01 05:08:11 +00:00
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-02-01 21:57:11 +00:00
|
|
|
|
|
|
|
def edit_callback(self,name):
|
|
|
|
self.rebuild()
|
|
|
|
|
2006-01-29 04:30:16 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class AddrEmbedList(EmbeddedList):
|
|
|
|
|
2006-02-01 21:57:11 +00:00
|
|
|
_HANDLE_COL = 5
|
2006-01-31 15:13:54 +00:00
|
|
|
_DND_TYPE = DdTargets.ADDRESS
|
2006-01-29 04:30:16 +00:00
|
|
|
|
|
|
|
_column_names = [
|
2006-01-30 05:01:21 +00:00
|
|
|
(_('Date'), 0, 150),
|
|
|
|
(_('Street'), 1, 225),
|
|
|
|
(_('State'), 2, 100),
|
|
|
|
(_('City'), 3, 100),
|
|
|
|
(_('Country'), 4, 75),
|
2006-01-29 04:30:16 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
def __init__(self,dbstate,uistate,track,data):
|
|
|
|
self.data = data
|
|
|
|
EmbeddedList.__init__(self, dbstate, uistate, track,
|
|
|
|
_('Addresses'), AddressModel)
|
|
|
|
|
|
|
|
def get_data(self):
|
|
|
|
return self.data
|
|
|
|
|
|
|
|
def column_order(self):
|
|
|
|
return ((1,0),(1,1),(1,2),(1,3),(1,4))
|
|
|
|
|
2006-02-01 21:57:11 +00:00
|
|
|
def add_button_clicked(self,obj):
|
2006-03-03 00:34:20 +00:00
|
|
|
import EditAddress
|
2006-02-01 21:57:11 +00:00
|
|
|
addr = RelLib.Address()
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
2006-03-03 00:34:20 +00:00
|
|
|
EditAddress.EditAddress(self.dbstate, self.uistate, self.track,
|
|
|
|
addr, self.add_callback)
|
2006-03-01 05:08:11 +00:00
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-02-01 21:57:11 +00:00
|
|
|
|
|
|
|
def add_callback(self,name):
|
|
|
|
self.get_data().append(name)
|
|
|
|
self.rebuild()
|
|
|
|
|
|
|
|
def edit_button_clicked(self,obj):
|
|
|
|
addr = self.get_selected()
|
|
|
|
if addr:
|
2006-03-03 00:34:20 +00:00
|
|
|
import EditAddress
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
2006-03-03 00:34:20 +00:00
|
|
|
EditAddress.EditAddress(self.dbstate, self.uistate, self.track,
|
|
|
|
addr, self.edit_callback)
|
2006-03-01 05:08:11 +00:00
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-02-01 21:57:11 +00:00
|
|
|
|
|
|
|
def edit_callback(self,name):
|
|
|
|
self.rebuild()
|
|
|
|
|
2006-02-05 19:00:25 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class LocationEmbedList(EmbeddedList):
|
|
|
|
|
|
|
|
_HANDLE_COL = 5
|
|
|
|
_DND_TYPE = DdTargets.ADDRESS
|
|
|
|
|
|
|
|
_column_names = [
|
|
|
|
(_('City'), 0, 150),
|
|
|
|
(_('County'), 1, 100),
|
|
|
|
(_('Church Parish'), 2, 100),
|
|
|
|
(_('State/Province'), 3, 100),
|
|
|
|
(_('Country'), 4, 75),
|
|
|
|
]
|
|
|
|
|
|
|
|
def __init__(self,dbstate,uistate,track,data):
|
|
|
|
self.data = data
|
|
|
|
EmbeddedList.__init__(self, dbstate, uistate, track,
|
|
|
|
_('Alternate Locations'), LocationModel)
|
|
|
|
|
|
|
|
def get_data(self):
|
|
|
|
return self.data
|
|
|
|
|
|
|
|
def column_order(self):
|
|
|
|
return ((1,0),(1,1),(1,2),(1,3),(1,4))
|
|
|
|
|
|
|
|
def add_button_clicked(self,obj):
|
2006-03-03 00:38:41 +00:00
|
|
|
import EditLocation
|
2006-02-05 19:00:25 +00:00
|
|
|
loc = RelLib.Location()
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
2006-03-03 00:38:41 +00:00
|
|
|
EditLocation.EditLocation(self.dbstate, self.uistate, self.track,
|
|
|
|
loc, self.add_callback)
|
2006-03-01 05:08:11 +00:00
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-02-05 19:00:25 +00:00
|
|
|
|
|
|
|
def add_callback(self,name):
|
|
|
|
self.get_data().append(name)
|
|
|
|
self.rebuild()
|
|
|
|
|
|
|
|
def edit_button_clicked(self,obj):
|
|
|
|
loc = self.get_selected()
|
|
|
|
if loc:
|
2006-03-03 00:38:41 +00:00
|
|
|
import EditLocation
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
2006-03-03 00:38:41 +00:00
|
|
|
EditLocation.EditLocation(self.dbstate, self.uistate, self.track,
|
|
|
|
loc, self.edit_callback)
|
2006-03-01 05:08:11 +00:00
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-02-05 19:00:25 +00:00
|
|
|
|
|
|
|
def edit_callback(self,name):
|
|
|
|
self.rebuild()
|
|
|
|
|
2006-01-14 05:27:48 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# NoteTab
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-01-15 04:49:13 +00:00
|
|
|
class NoteTab(GrampsTab):
|
2006-01-13 03:54:31 +00:00
|
|
|
|
2006-02-16 05:06:40 +00:00
|
|
|
def __init__(self, dbstate, uistate, track, note_obj,title=_('Note')):
|
2006-01-15 04:49:13 +00:00
|
|
|
self.note_obj = note_obj
|
2006-02-16 05:06:40 +00:00
|
|
|
GrampsTab.__init__(self, dbstate, uistate, track, title)
|
2006-01-15 04:49:13 +00:00
|
|
|
self.show_all()
|
2006-01-13 03:54:31 +00:00
|
|
|
|
2006-02-02 05:20:42 +00:00
|
|
|
def _update_label(self,*obj):
|
|
|
|
cc = self.buf.get_char_count()
|
|
|
|
if cc == 0 and not self.empty:
|
|
|
|
self.empty = True
|
|
|
|
self._set_label()
|
|
|
|
elif cc != 0 and self.empty:
|
|
|
|
self.empty = False
|
|
|
|
self._set_label()
|
|
|
|
|
2006-01-26 22:31:34 +00:00
|
|
|
def is_empty(self):
|
|
|
|
"""
|
|
|
|
Indicates if the tab contains any data. This is used to determine
|
|
|
|
how the label should be displayed.
|
|
|
|
"""
|
2006-02-02 05:20:42 +00:00
|
|
|
return self.buf.get_char_count() == 0
|
2006-01-26 22:31:34 +00:00
|
|
|
|
2006-01-15 04:49:13 +00:00
|
|
|
def build_interface(self):
|
2006-01-29 04:30:16 +00:00
|
|
|
vbox = gtk.VBox()
|
2006-02-02 05:20:42 +00:00
|
|
|
|
2006-02-03 22:31:46 +00:00
|
|
|
self.text = gtk.TextView()
|
2006-01-29 04:30:16 +00:00
|
|
|
self.flowed = gtk.RadioButton(None,_('Flowed'))
|
|
|
|
self.format = gtk.RadioButton(self.flowed,_('Formatted'))
|
|
|
|
|
|
|
|
if self.note_obj and self.note_obj.get_format():
|
|
|
|
self.format.set_active(True)
|
|
|
|
self.text.set_wrap_mode(gtk.WRAP_NONE)
|
|
|
|
else:
|
|
|
|
self.flowed.set_active(True)
|
|
|
|
self.text.set_wrap_mode(gtk.WRAP_WORD)
|
2006-02-05 05:19:51 +00:00
|
|
|
self.spellcheck = Spell.Spell(self.text)
|
2006-01-29 04:30:16 +00:00
|
|
|
|
|
|
|
self.flowed.connect('toggled',self.flow_changed)
|
|
|
|
|
2006-01-13 03:54:31 +00:00
|
|
|
scroll = gtk.ScrolledWindow()
|
|
|
|
scroll.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
|
|
|
|
scroll.add_with_viewport(self.text)
|
2006-02-03 22:31:46 +00:00
|
|
|
scroll.connect('focus-out-event',self.update)
|
2006-01-29 04:30:16 +00:00
|
|
|
|
|
|
|
vbox.pack_start(scroll,True)
|
|
|
|
vbox.set_spacing(6)
|
|
|
|
|
|
|
|
hbox = gtk.HBox()
|
|
|
|
hbox.set_spacing(6)
|
|
|
|
hbox.pack_start(self.flowed,False)
|
|
|
|
hbox.pack_start(self.format,False)
|
|
|
|
|
|
|
|
vbox.pack_start(hbox,False)
|
|
|
|
|
|
|
|
self.pack_start(vbox,True)
|
2006-02-02 05:20:42 +00:00
|
|
|
self.buf = self.text.get_buffer()
|
2006-01-15 04:49:13 +00:00
|
|
|
if self.note_obj:
|
2006-02-02 05:20:42 +00:00
|
|
|
self.empty = False
|
|
|
|
self.buf.insert_at_cursor(self.note_obj.get())
|
|
|
|
else:
|
|
|
|
self.empty = True
|
|
|
|
|
2006-02-03 22:31:46 +00:00
|
|
|
self.buf.connect('changed',self.update)
|
2006-01-26 22:31:34 +00:00
|
|
|
self.rebuild()
|
2006-01-13 03:54:31 +00:00
|
|
|
|
2006-02-03 22:31:46 +00:00
|
|
|
def update(self,obj):
|
|
|
|
if self.note_obj:
|
2006-02-05 05:19:51 +00:00
|
|
|
start = self.buf.get_start_iter()
|
|
|
|
stop = self.buf.get_end_iter()
|
|
|
|
text = self.buf.get_text(start,stop)
|
2006-02-03 22:36:58 +00:00
|
|
|
self.note_obj.set(text)
|
2006-02-03 22:31:46 +00:00
|
|
|
else:
|
|
|
|
print "NOTE OBJ DOES NOT EXIST"
|
2006-02-03 22:36:58 +00:00
|
|
|
self._update_label(obj)
|
2006-02-03 22:31:46 +00:00
|
|
|
return False
|
|
|
|
|
2006-01-29 04:30:16 +00:00
|
|
|
def flow_changed(self,obj):
|
|
|
|
if obj.get_active():
|
|
|
|
self.text.set_wrap_mode(gtk.WRAP_WORD)
|
|
|
|
else:
|
|
|
|
self.text.set_wrap_mode(gtk.WRAP_NONE)
|
|
|
|
|
2006-01-13 03:54:31 +00:00
|
|
|
def rebuild(self):
|
2006-01-26 22:31:34 +00:00
|
|
|
self._set_label()
|
2006-01-13 03:54:31 +00:00
|
|
|
|
2006-01-14 05:27:48 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GalleryTab
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-01-15 04:49:13 +00:00
|
|
|
class GalleryTab(ButtonTab):
|
2006-01-13 03:54:31 +00:00
|
|
|
|
2006-01-15 04:49:13 +00:00
|
|
|
def __init__(self, dbstate, uistate, track, media_list):
|
|
|
|
ButtonTab.__init__(self, dbstate, uistate, track, _('Gallery'))
|
2006-01-13 03:54:31 +00:00
|
|
|
self.media_list = media_list
|
2006-01-15 04:49:13 +00:00
|
|
|
self.rebuild()
|
|
|
|
self.show_all()
|
2006-01-13 03:54:31 +00:00
|
|
|
|
2006-02-22 04:33:34 +00:00
|
|
|
def double_click(self, obj, event):
|
|
|
|
"""
|
|
|
|
Handles the double click on list. If the double click occurs,
|
|
|
|
the Edit button handler is called
|
|
|
|
"""
|
|
|
|
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
|
|
|
self.edit_button_clicked(obj)
|
|
|
|
|
2006-01-15 04:49:13 +00:00
|
|
|
def get_icon_name(self):
|
|
|
|
return 'gramps-media'
|
|
|
|
|
2006-02-02 05:20:42 +00:00
|
|
|
def is_empty(self):
|
|
|
|
return len(self.media_list)==0
|
|
|
|
|
2006-02-08 16:20:03 +00:00
|
|
|
def _build_icon_model(self):
|
|
|
|
# build the list model
|
|
|
|
self.iconmodel= gtk.ListStore(gtk.gdk.Pixbuf,str,object)
|
|
|
|
|
|
|
|
def _connect_icon_model(self):
|
|
|
|
self.iconlist.set_model(self.iconmodel)
|
|
|
|
self.iconmodel.connect_after('row-inserted',self._update_internal_list)
|
|
|
|
self.iconmodel.connect_after('row-deleted',self._update_internal_list)
|
|
|
|
|
2006-01-15 04:49:13 +00:00
|
|
|
def build_interface(self):
|
2006-02-08 16:20:03 +00:00
|
|
|
|
|
|
|
self._build_icon_model()
|
|
|
|
# build the icon view
|
2006-01-13 03:54:31 +00:00
|
|
|
self.iconlist = gtk.IconView()
|
|
|
|
self.iconlist.set_pixbuf_column(0)
|
|
|
|
self.iconlist.set_text_column(1)
|
2006-02-08 16:20:03 +00:00
|
|
|
self.iconlist.set_margin(12)
|
|
|
|
self.iconlist.set_reorderable(True)
|
|
|
|
self.iconlist.set_item_width(125)
|
|
|
|
self.iconlist.set_spacing(24)
|
2006-01-18 19:36:23 +00:00
|
|
|
self.iconlist.set_selection_mode(gtk.SELECTION_SINGLE)
|
2006-02-08 16:20:03 +00:00
|
|
|
self.iconlist.connect('selection-changed',self._selection_changed)
|
2006-02-22 04:33:34 +00:00
|
|
|
self.iconlist.connect('button_press_event',self.double_click)
|
2006-02-08 16:20:03 +00:00
|
|
|
self._connect_icon_model()
|
2006-01-13 03:54:31 +00:00
|
|
|
|
|
|
|
scroll = gtk.ScrolledWindow()
|
|
|
|
scroll.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
|
|
|
|
scroll.add_with_viewport(self.iconlist)
|
|
|
|
self.pack_start(scroll,True)
|
|
|
|
|
2006-02-08 16:20:03 +00:00
|
|
|
def _update_internal_list(self, *obj):
|
|
|
|
node = self.iconmodel.get_iter_first()
|
|
|
|
newlist = []
|
|
|
|
while node != None:
|
|
|
|
newlist.append(self.iconmodel.get_value(node,2))
|
|
|
|
node = self.iconmodel.iter_next(node)
|
|
|
|
for i in xrange(len(self.media_list)):
|
|
|
|
self.media_list.pop()
|
|
|
|
for i in newlist:
|
|
|
|
self.media_list.append(i)
|
|
|
|
self.changed = True
|
|
|
|
|
2006-01-13 03:54:31 +00:00
|
|
|
def get_data(self):
|
|
|
|
return self.media_list
|
|
|
|
|
|
|
|
def rebuild(self):
|
2006-02-08 16:20:03 +00:00
|
|
|
self._build_icon_model()
|
2006-01-13 03:54:31 +00:00
|
|
|
for ref in self.media_list:
|
2006-01-26 22:31:34 +00:00
|
|
|
handle = ref.get_reference_handle()
|
|
|
|
obj = self.dbstate.db.get_object_from_handle(handle)
|
2006-02-02 05:20:42 +00:00
|
|
|
pixbuf = ImgManip.get_thumb_from_obj(obj)
|
2006-02-08 16:20:03 +00:00
|
|
|
self.iconmodel.append(row=[pixbuf,obj.get_description(),ref])
|
|
|
|
self._connect_icon_model()
|
2006-01-26 22:31:34 +00:00
|
|
|
self._set_label()
|
2006-02-08 16:20:03 +00:00
|
|
|
self._selection_changed()
|
|
|
|
|
2006-01-18 19:36:23 +00:00
|
|
|
def get_selected(self):
|
|
|
|
node = self.iconlist.get_selected_items()
|
|
|
|
if len(node) > 0:
|
|
|
|
return self.media_list[node[0][0]]
|
2006-01-29 04:50:11 +00:00
|
|
|
return None
|
2006-01-18 19:36:23 +00:00
|
|
|
|
|
|
|
def add_button_clicked(self,obj):
|
2006-02-22 04:33:34 +00:00
|
|
|
from EditMediaRef import EditMediaRef
|
|
|
|
|
|
|
|
sref = RelLib.MediaRef()
|
2006-02-22 19:11:36 +00:00
|
|
|
src = RelLib.MediaObject()
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
|
|
|
EditMediaRef(self.dbstate, self.uistate, self.track,
|
|
|
|
src, sref, self.add_callback)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-02-22 04:33:34 +00:00
|
|
|
|
|
|
|
def add_callback(self,name):
|
|
|
|
self.get_data().append(name)
|
|
|
|
self.changed = True
|
|
|
|
self.rebuild()
|
2006-01-18 19:36:23 +00:00
|
|
|
|
|
|
|
def del_button_clicked(self,obj):
|
|
|
|
ref = self.get_selected()
|
|
|
|
if ref:
|
|
|
|
self.media_list.remove(ref)
|
|
|
|
self.rebuild()
|
|
|
|
|
|
|
|
def edit_button_clicked(self,obj):
|
2006-02-08 16:20:03 +00:00
|
|
|
ref = self.get_selected()
|
|
|
|
if ref:
|
2006-02-22 04:33:34 +00:00
|
|
|
from EditMediaRef import EditMediaRef
|
|
|
|
|
|
|
|
obj = self.dbstate.db.get_object_from_handle(ref.get_reference_handle())
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
|
|
|
EditMediaRef(self.dbstate, self.uistate, self.track,
|
|
|
|
obj, ref, self.edit_callback)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-02-22 04:33:34 +00:00
|
|
|
|
|
|
|
def edit_callback(self, name):
|
|
|
|
self.changed = True
|
|
|
|
self.rebuild()
|
2006-01-18 19:36:23 +00:00
|
|
|
|
2006-01-24 04:13:21 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# SourceEmbedList
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class SourceEmbedList(EmbeddedList):
|
|
|
|
|
2006-01-29 05:53:17 +00:00
|
|
|
_HANDLE_COL = 4
|
2006-01-31 15:13:54 +00:00
|
|
|
_DND_TYPE = DdTargets.SOURCEREF
|
2006-01-30 05:01:21 +00:00
|
|
|
|
2006-01-26 22:31:34 +00:00
|
|
|
_column_names = [
|
2006-01-30 05:01:21 +00:00
|
|
|
(_('ID'), 0, 75),
|
|
|
|
(_('Title'), 1, 200),
|
|
|
|
(_('Author'), 2, 125),
|
|
|
|
(_('Page'), 3, 100),
|
2006-01-24 04:13:21 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
def __init__(self,dbstate,uistate,track,obj):
|
|
|
|
self.obj = obj
|
|
|
|
EmbeddedList.__init__(self, dbstate, uistate, track,
|
|
|
|
_('Sources'), SourceRefModel)
|
|
|
|
|
|
|
|
def get_icon_name(self):
|
|
|
|
return 'gramps-event'
|
|
|
|
|
|
|
|
def get_data(self):
|
|
|
|
return self.obj
|
|
|
|
|
|
|
|
def column_order(self):
|
2006-01-29 05:53:17 +00:00
|
|
|
return ((1,0),(1,1),(1,2),(1,3))
|
2006-01-24 04:13:21 +00:00
|
|
|
|
|
|
|
def add_button_clicked(self,obj):
|
2006-02-16 05:06:40 +00:00
|
|
|
from EditSourceRef import EditSourceRef
|
2006-02-02 05:20:42 +00:00
|
|
|
|
|
|
|
sref = RelLib.SourceRef()
|
2006-02-16 05:06:40 +00:00
|
|
|
src = RelLib.Source()
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
|
|
|
EditSourceRef(self.dbstate, self.uistate, self.track,
|
|
|
|
src, sref, self.add_callback)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-01-24 04:13:21 +00:00
|
|
|
|
2006-02-02 05:20:42 +00:00
|
|
|
def add_callback(self,obj):
|
2006-02-08 21:13:05 +00:00
|
|
|
self.get_data().append(obj)
|
2006-02-02 05:20:42 +00:00
|
|
|
self.changed = True
|
|
|
|
self.rebuild()
|
2006-01-24 04:13:21 +00:00
|
|
|
|
|
|
|
def edit_button_clicked(self,obj):
|
2006-02-20 04:59:20 +00:00
|
|
|
from EditSourceRef import EditSourceRef
|
2006-02-02 05:20:42 +00:00
|
|
|
|
|
|
|
sref = self.get_selected()
|
2006-02-20 04:59:20 +00:00
|
|
|
src = self.dbstate.db.get_source_from_handle(sref.ref)
|
2006-02-02 05:20:42 +00:00
|
|
|
if sref:
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
|
|
|
EditSourceRef(self.dbstate, self.uistate, self.track,
|
|
|
|
src, sref, self.edit_callback)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-02-02 05:20:42 +00:00
|
|
|
|
|
|
|
def edit_callback(self,name):
|
|
|
|
self.changed = True
|
|
|
|
self.rebuild()
|
2006-01-24 04:13:21 +00:00
|
|
|
|
2006-02-04 23:29:44 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# 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):
|
2006-02-26 04:29:39 +00:00
|
|
|
from EditRepositoryRef import EditRepositoryRef
|
2006-02-04 23:29:44 +00:00
|
|
|
|
2006-02-26 04:29:39 +00:00
|
|
|
ref = RelLib.RepoRef()
|
|
|
|
repo = RelLib.Repository()
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
|
|
|
EditRepositoryRef(
|
|
|
|
self.dbstate, self.uistate, self.track, repo, ref, self.add_callback)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-02-04 23:29:44 +00:00
|
|
|
|
2006-02-26 04:29:39 +00:00
|
|
|
def add_callback(self,value):
|
|
|
|
value[0].ref = value[1].handle
|
|
|
|
self.get_data().append(value[0])
|
2006-02-04 23:29:44 +00:00
|
|
|
self.changed = True
|
|
|
|
self.rebuild()
|
|
|
|
|
|
|
|
def edit_button_clicked(self,obj):
|
2006-02-26 04:29:39 +00:00
|
|
|
from EditRepositoryRef import EditRepositoryRef
|
2006-02-04 23:29:44 +00:00
|
|
|
|
|
|
|
ref = self.get_selected()
|
|
|
|
if ref:
|
2006-02-26 04:29:39 +00:00
|
|
|
repo = self.dbstate.db.get_repository_from_handle(ref.ref)
|
2006-03-01 05:08:11 +00:00
|
|
|
try:
|
|
|
|
EditRepositoryRef.EditRepositoryRef(
|
|
|
|
self.dbstate, self.uistate, self.track, repo,
|
|
|
|
ref, self.edit_callback)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-02-04 23:29:44 +00:00
|
|
|
|
|
|
|
def edit_callback(self,name):
|
|
|
|
self.changed = True
|
|
|
|
self.rebuild()
|
|
|
|
|
2006-01-13 00:45:22 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# ChildModel
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class ChildModel(gtk.ListStore):
|
|
|
|
|
2006-01-14 05:27:48 +00:00
|
|
|
_HANDLE_COL = -8
|
2006-01-30 05:01:21 +00:00
|
|
|
|
2006-01-28 20:38:03 +00:00
|
|
|
def __init__(self, family, db):
|
2006-01-18 22:33:27 +00:00
|
|
|
self.family = family
|
2006-01-28 20:38:03 +00:00
|
|
|
gtk.ListStore.__init__(self,int,str,str,str,str,str,
|
|
|
|
str,str,str,str,str,str,int,int)
|
2006-01-13 00:45:22 +00:00
|
|
|
self.db = db
|
|
|
|
index = 1
|
2006-01-28 20:38:03 +00:00
|
|
|
for child_handle in self.get_data():
|
2006-01-13 00:45:22 +00:00
|
|
|
child = db.get_person_from_handle(child_handle)
|
|
|
|
self.append(row=[index,
|
|
|
|
child.get_gramps_id(),
|
|
|
|
NameDisplay.displayer.display(child),
|
2006-02-08 21:13:05 +00:00
|
|
|
Utils.gender[child.get_gender()],
|
2006-01-18 22:33:27 +00:00
|
|
|
self.column_father_rel(child),
|
|
|
|
self.column_mother_rel(child),
|
2006-01-13 00:45:22 +00:00
|
|
|
self.column_birth_day(child),
|
|
|
|
self.column_death_day(child),
|
|
|
|
self.column_birth_place(child),
|
|
|
|
self.column_death_place(child),
|
|
|
|
child.get_handle(),
|
|
|
|
child.get_primary_name().get_sort_name(),
|
|
|
|
self.column_birth_sort(child),
|
|
|
|
self.column_death_sort(child),
|
|
|
|
])
|
|
|
|
index += 1
|
|
|
|
|
2006-01-28 20:38:03 +00:00
|
|
|
def get_data(self):
|
|
|
|
return self.family.get_child_handle_list()
|
|
|
|
|
2006-01-18 22:33:27 +00:00
|
|
|
def display_rel(self,rtype):
|
2006-01-19 02:06:27 +00:00
|
|
|
if type(rtype) == tuple:
|
|
|
|
rel = rtype[0]
|
|
|
|
val = rtype[1]
|
2006-01-18 22:33:27 +00:00
|
|
|
else:
|
2006-01-19 02:06:27 +00:00
|
|
|
rel = rtype
|
|
|
|
val = "???"
|
|
|
|
|
|
|
|
if rel == RelLib.Family.CUSTOM:
|
|
|
|
return unicode(val)
|
|
|
|
else:
|
|
|
|
return Utils.child_relations[rel]
|
2006-01-18 22:33:27 +00:00
|
|
|
|
|
|
|
def column_father_rel(self,data):
|
|
|
|
fhandle = self.family.handle
|
|
|
|
for (handle, mrel, frel) in data.get_parent_family_handle_list():
|
|
|
|
if handle == fhandle:
|
|
|
|
return self.display_rel(frel)
|
|
|
|
return ""
|
|
|
|
|
|
|
|
def column_mother_rel(self,data):
|
|
|
|
fhandle = self.family.handle
|
|
|
|
for (handle, mrel, frel) in data.get_parent_family_handle_list():
|
|
|
|
if handle == fhandle:
|
|
|
|
return self.display_rel(mrel)
|
|
|
|
return ""
|
|
|
|
|
2006-01-13 00:45:22 +00:00
|
|
|
def column_birth_day(self,data):
|
|
|
|
event_ref = data.get_birth_ref()
|
|
|
|
if event_ref and event_ref.ref:
|
|
|
|
event = self.db.get_event_from_handle(event_ref.ref)
|
|
|
|
return DateHandler.get_date(event)
|
|
|
|
else:
|
|
|
|
return u""
|
|
|
|
|
|
|
|
def column_birth_sort(self,data):
|
|
|
|
event_ref = data.get_birth_ref()
|
|
|
|
if event_ref and event_ref.ref:
|
|
|
|
event = self.db.get_event_from_handle(event_ref.ref)
|
|
|
|
return event.get_date_object().get_sort_value()
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
|
|
|
|
def column_death_day(self,data):
|
|
|
|
event_ref = data.get_death_ref()
|
|
|
|
if event_ref and event_ref.ref:
|
|
|
|
event = self.db.get_event_from_handle(event_ref.ref)
|
|
|
|
return DateHandler.get_date(event)
|
|
|
|
else:
|
|
|
|
return u""
|
|
|
|
|
|
|
|
def column_death_sort(self,data):
|
|
|
|
event_ref = data.get_death_ref()
|
|
|
|
if event_ref and event_ref.ref:
|
|
|
|
event = self.db.get_event_from_handle(event_ref.ref)
|
|
|
|
return event.get_date_object().get_sort_value()
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
|
|
|
|
def column_birth_place(self,data):
|
|
|
|
event_ref = data.get_birth_ref()
|
|
|
|
if event_ref and event_ref.ref:
|
|
|
|
event = self.db.get_event_from_handle(event_ref.ref)
|
|
|
|
if event:
|
|
|
|
place_handle = event.get_place_handle()
|
|
|
|
if place_handle:
|
|
|
|
return self.db.get_place_from_handle(place_handle).get_title()
|
|
|
|
return u""
|
|
|
|
|
|
|
|
def column_death_place(self,data):
|
|
|
|
event_ref = data.get_death_ref()
|
|
|
|
if event_ref and event_ref.ref:
|
|
|
|
event = self.db.get_event_from_handle(event_ref.ref)
|
|
|
|
if event:
|
|
|
|
place_handle = event.get_place_handle()
|
|
|
|
if place_handle:
|
|
|
|
return self.db.get_place_from_handle(place_handle).get_title()
|
|
|
|
return u""
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# EventRefModel
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class EventRefModel(gtk.ListStore):
|
|
|
|
|
|
|
|
def __init__(self,event_list,db):
|
2006-01-29 05:53:17 +00:00
|
|
|
gtk.ListStore.__init__(self,str,str,str,str,str,str,object)
|
2006-01-13 00:45:22 +00:00
|
|
|
self.db = db
|
|
|
|
for event_ref in event_list:
|
|
|
|
event = db.get_event_from_handle(event_ref.ref)
|
|
|
|
self.append(row=[
|
2006-01-15 01:26:47 +00:00
|
|
|
self.column_type(event),
|
2006-01-13 00:45:22 +00:00
|
|
|
event.get_description(),
|
|
|
|
event.get_gramps_id(),
|
|
|
|
self.column_date(event_ref),
|
|
|
|
self.column_place(event_ref),
|
2006-01-30 05:01:21 +00:00
|
|
|
self.column_role(event_ref),
|
2006-01-15 01:26:47 +00:00
|
|
|
event_ref
|
2006-01-13 00:45:22 +00:00
|
|
|
])
|
2006-01-14 05:27:48 +00:00
|
|
|
|
|
|
|
def column_type(self,event):
|
2006-01-29 04:30:16 +00:00
|
|
|
t,v = event.get_type()
|
|
|
|
if t == RelLib.Event.CUSTOM:
|
|
|
|
return v
|
2006-01-14 05:27:48 +00:00
|
|
|
else:
|
2006-01-29 04:30:16 +00:00
|
|
|
if Utils.personal_events.has_key(t):
|
|
|
|
return Utils.personal_events[t]
|
|
|
|
else:
|
|
|
|
return Utils.family_events[t]
|
2006-01-13 00:45:22 +00:00
|
|
|
|
2006-01-30 05:01:21 +00:00
|
|
|
def column_role(self,event_ref):
|
|
|
|
t,v = event_ref.get_role()
|
|
|
|
if t == RelLib.EventRef.CUSTOM:
|
|
|
|
return v
|
|
|
|
else:
|
2006-02-24 22:00:20 +00:00
|
|
|
try:
|
|
|
|
return Utils.event_roles[t]
|
|
|
|
except:
|
|
|
|
return Utils.family_event_roles.get(t,"error %d" % t)
|
2006-01-30 05:01:21 +00:00
|
|
|
|
2006-01-13 00:45:22 +00:00
|
|
|
def column_date(self,event_ref):
|
|
|
|
event = self.db.get_event_from_handle(event_ref.ref)
|
|
|
|
return DateHandler.get_date(event)
|
|
|
|
|
|
|
|
def column_place(self,event_ref):
|
|
|
|
if event_ref and event_ref.ref:
|
|
|
|
event = self.db.get_event_from_handle(event_ref.ref)
|
|
|
|
if event:
|
|
|
|
place_handle = event.get_place_handle()
|
|
|
|
if place_handle:
|
|
|
|
return self.db.get_place_from_handle(place_handle).get_title()
|
|
|
|
return u""
|
|
|
|
|
2006-01-13 03:54:31 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2006-01-14 05:27:48 +00:00
|
|
|
# AttrModel
|
2006-01-13 03:54:31 +00:00
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class AttrModel(gtk.ListStore):
|
|
|
|
|
|
|
|
def __init__(self,attr_list,db):
|
2006-01-29 05:53:17 +00:00
|
|
|
gtk.ListStore.__init__(self,str,str,object)
|
2006-01-13 03:54:31 +00:00
|
|
|
self.db = db
|
|
|
|
for attr in attr_list:
|
|
|
|
self.append(row=[
|
|
|
|
self.type_name(attr),
|
|
|
|
attr.get_value(),
|
2006-01-29 05:53:17 +00:00
|
|
|
attr,
|
2006-01-13 03:54:31 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
def type_name(self, attr):
|
2006-01-29 04:30:16 +00:00
|
|
|
t,v = attr.get_type()
|
|
|
|
if t == RelLib.Attribute.CUSTOM:
|
|
|
|
return v
|
|
|
|
elif Utils.personal_attributes.has_key(t):
|
|
|
|
return Utils.personal_attributes[t]
|
2006-01-13 03:54:31 +00:00
|
|
|
else:
|
2006-01-29 04:30:16 +00:00
|
|
|
return Utils.family_attributes[t]
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# NameModel
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class NameModel(gtk.ListStore):
|
|
|
|
|
|
|
|
def __init__(self,obj_list,db):
|
2006-01-29 05:53:17 +00:00
|
|
|
gtk.ListStore.__init__(self,str,str,object)
|
2006-01-29 04:30:16 +00:00
|
|
|
self.db = db
|
|
|
|
for obj in obj_list:
|
|
|
|
self.append(row=[
|
2006-01-29 04:50:11 +00:00
|
|
|
NameDisplay.displayer.display_name(obj),
|
|
|
|
self.type_name(obj),
|
2006-01-29 05:53:17 +00:00
|
|
|
obj,
|
2006-01-29 04:30:16 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
def type_name(self, obj):
|
|
|
|
t,v = obj.get_type()
|
|
|
|
if t == RelLib.Name.CUSTOM:
|
|
|
|
return v
|
|
|
|
else:
|
|
|
|
return Utils.name_types[t]
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# AddressModel
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class AddressModel(gtk.ListStore):
|
|
|
|
|
|
|
|
def __init__(self,obj_list,db):
|
2006-01-29 05:53:17 +00:00
|
|
|
gtk.ListStore.__init__(self,str,str,str,str,str,object)
|
2006-01-29 04:30:16 +00:00
|
|
|
self.db = db
|
|
|
|
for obj in obj_list:
|
|
|
|
self.append(row=[
|
|
|
|
DateHandler.get_date(obj),
|
|
|
|
obj.street,
|
|
|
|
obj.city,
|
|
|
|
obj.state,
|
|
|
|
obj.country,
|
2006-01-29 05:53:17 +00:00
|
|
|
obj,
|
2006-01-29 04:30:16 +00:00
|
|
|
])
|
|
|
|
|
2006-02-05 19:00:25 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# LocationModel
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class LocationModel(gtk.ListStore):
|
|
|
|
|
|
|
|
def __init__(self,obj_list,db):
|
|
|
|
gtk.ListStore.__init__(self,str,str,str,str,str,object)
|
|
|
|
self.db = db
|
|
|
|
for obj in obj_list:
|
|
|
|
self.append(row=[obj.city, obj.county, obj.parish,
|
|
|
|
obj.state, obj.country, obj, ])
|
|
|
|
|
2006-01-29 04:30:16 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# AddressModel
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class WebModel(gtk.ListStore):
|
|
|
|
|
|
|
|
def __init__(self,obj_list,db):
|
2006-01-29 05:53:17 +00:00
|
|
|
gtk.ListStore.__init__(self,str,str,str,object)
|
2006-01-29 04:30:16 +00:00
|
|
|
self.db = db
|
|
|
|
for obj in obj_list:
|
2006-02-01 21:57:11 +00:00
|
|
|
self.append(row=[self.show_type(obj.type),
|
|
|
|
obj.path, obj.desc, obj])
|
|
|
|
|
|
|
|
def show_type(self,rtype):
|
|
|
|
rel = rtype[0]
|
|
|
|
val = rtype[1]
|
|
|
|
if rel == RelLib.Url.CUSTOM:
|
|
|
|
return val
|
|
|
|
else:
|
|
|
|
return Utils.web_types[rel]
|
2006-01-13 03:54:31 +00:00
|
|
|
|
2006-01-24 04:13:21 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2006-01-25 05:07:10 +00:00
|
|
|
# DataModel
|
2006-01-24 04:13:21 +00:00
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-01-25 05:07:10 +00:00
|
|
|
class DataModel(gtk.ListStore):
|
2006-01-24 04:13:21 +00:00
|
|
|
|
2006-01-25 05:07:10 +00:00
|
|
|
def __init__(self,attr_list,db):
|
2006-01-24 04:13:21 +00:00
|
|
|
gtk.ListStore.__init__(self,str,str)
|
|
|
|
self.db = db
|
2006-01-25 05:07:10 +00:00
|
|
|
for attr in attr_list.keys():
|
2006-01-29 05:53:17 +00:00
|
|
|
self.append(row=[attr, attr_list[attr] ])
|
2006-01-24 04:13:21 +00:00
|
|
|
|
2006-01-25 05:07:10 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2006-02-04 23:29:44 +00:00
|
|
|
# SourceRefModel
|
2006-01-28 20:38:03 +00:00
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class SourceRefModel(gtk.ListStore):
|
|
|
|
|
|
|
|
def __init__(self,sref_list,db):
|
2006-01-29 05:53:17 +00:00
|
|
|
gtk.ListStore.__init__(self,str,str,str,str,object)
|
2006-01-28 20:38:03 +00:00
|
|
|
self.db = db
|
|
|
|
for sref in sref_list:
|
|
|
|
src = self.db.get_source_from_handle(sref.ref)
|
2006-01-29 05:53:17 +00:00
|
|
|
self.append(row=[src.gramps_id, src.title, src.author,
|
|
|
|
sref.page, sref, ])
|
2006-01-28 20:38:03 +00:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2006-02-04 23:29:44 +00:00
|
|
|
# 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)
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2006-02-24 22:00:20 +00:00
|
|
|
# BackRefModel
|
2006-01-25 05:07:10 +00:00
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-02-24 22:00:20 +00:00
|
|
|
class BackRefModel(gtk.ListStore):
|
2006-01-25 05:07:10 +00:00
|
|
|
|
|
|
|
def __init__(self,sref_list,db):
|
|
|
|
gtk.ListStore.__init__(self,str,str,str,str)
|
|
|
|
self.db = db
|
2006-01-25 17:59:22 +00:00
|
|
|
self.sref_list = sref_list
|
|
|
|
self.idle = 0
|
2006-02-24 22:00:20 +00:00
|
|
|
self.empty = True
|
2006-01-25 17:59:22 +00:00
|
|
|
self.idle = gobject.idle_add(self.load_model().next)
|
|
|
|
|
|
|
|
def close(self):
|
|
|
|
gobject.source_remove(self.idle)
|
|
|
|
|
|
|
|
def load_model(self):
|
2006-02-24 22:00:20 +00:00
|
|
|
self.empty = True
|
2006-01-25 17:59:22 +00:00
|
|
|
for ref in self.sref_list:
|
2006-02-24 22:00:20 +00:00
|
|
|
self.empty = False
|
2006-01-25 05:07:10 +00:00
|
|
|
dtype = ref[0]
|
|
|
|
if dtype == 'Person':
|
|
|
|
p = self.db.get_person_from_handle(ref[1])
|
|
|
|
gid = p.gramps_id
|
|
|
|
handle = p.handle
|
|
|
|
name = NameDisplay.displayer.display(p)
|
|
|
|
elif dtype == 'Family':
|
|
|
|
p = self.db.get_family_from_handle(ref[1])
|
|
|
|
gid = p.gramps_id
|
|
|
|
handle = p.handle
|
|
|
|
name = Utils.family_name(p,self.db)
|
2006-02-05 19:00:25 +00:00
|
|
|
elif dtype == 'Source':
|
|
|
|
p = self.db.get_source_from_handle(ref[1])
|
|
|
|
gid = p.gramps_id
|
|
|
|
handle = p.handle
|
|
|
|
name = p.get_title()
|
2006-01-25 05:07:10 +00:00
|
|
|
elif dtype == 'Event':
|
|
|
|
p = self.db.get_event_from_handle(ref[1])
|
|
|
|
gid = p.gramps_id
|
2006-01-26 03:47:15 +00:00
|
|
|
name = p.get_description()
|
2006-01-25 05:07:10 +00:00
|
|
|
handle = p.handle
|
|
|
|
if not name:
|
2006-01-26 03:47:15 +00:00
|
|
|
etype = p.get_type()
|
2006-01-25 05:07:10 +00:00
|
|
|
if etype[0] == RelLib.Event.CUSTOM:
|
|
|
|
name = etype[1]
|
|
|
|
elif Utils.personal_events.has_key(etype[0]):
|
|
|
|
name = Utils.personal_events[etype[0]]
|
|
|
|
else:
|
|
|
|
name = Utils.family_events[etype[0]]
|
|
|
|
elif dtype == 'Place':
|
|
|
|
p = self.db.get_place_from_handle(ref[1])
|
|
|
|
name = p.get_title()
|
|
|
|
gid = p.gramps_id
|
|
|
|
handle = p.handle
|
|
|
|
else:
|
|
|
|
p = self.db.get_object_from_handle(ref[1])
|
|
|
|
name = p.get_description()
|
|
|
|
gid = p.gramps_id
|
|
|
|
handle = p.handle
|
|
|
|
|
|
|
|
self.append(row=[dtype,gid,name,handle])
|
2006-01-25 17:59:22 +00:00
|
|
|
yield True
|
|
|
|
yield False
|
|
|
|
|
2006-02-24 22:00:20 +00:00
|
|
|
|