2005-08-09 10:11:20 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2007-06-28 11:11:40 +05:30
|
|
|
# Copyright (C) 2001-2007 Donald N. Allingham
|
2005-08-09 10:11:20 +05:30
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2007-09-12 09:29:39 +05:30
|
|
|
# This program is distributed in the hope that it will be useful,
|
2005-08-09 10:11:20 +05:30
|
|
|
# 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
|
|
|
|
#
|
|
|
|
|
2008-01-25 01:32:09 +05:30
|
|
|
# $Id:PageView.py 9912 2008-01-22 09:17:46Z acraphae $
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
"""
|
|
|
|
Provide the base classes for GRAMPS' DataView classes
|
|
|
|
"""
|
|
|
|
|
2006-02-09 02:43:05 +05:30
|
|
|
#----------------------------------------------------------------
|
|
|
|
#
|
2007-09-13 09:50:24 +05:30
|
|
|
# python modules
|
2006-02-09 02:43:05 +05:30
|
|
|
#
|
|
|
|
#----------------------------------------------------------------
|
2006-03-23 04:33:57 +05:30
|
|
|
import cPickle as pickle
|
2006-02-09 02:43:05 +05:30
|
|
|
|
|
|
|
#----------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gtk
|
|
|
|
#
|
|
|
|
#----------------------------------------------------------------
|
2005-08-09 10:11:20 +05:30
|
|
|
import gtk
|
2006-01-20 23:48:03 +05:30
|
|
|
import pango
|
2006-02-09 02:43:05 +05:30
|
|
|
|
|
|
|
#----------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS
|
|
|
|
#
|
|
|
|
#----------------------------------------------------------------
|
2006-05-10 21:38:56 +05:30
|
|
|
import Config
|
2005-08-19 18:14:44 +05:30
|
|
|
import TreeTips
|
2006-04-27 03:18:13 +05:30
|
|
|
import Bookmarks
|
2006-07-30 09:04:10 +05:30
|
|
|
import Errors
|
2006-05-10 21:38:56 +05:30
|
|
|
from Filters import SearchBar
|
2007-08-31 01:19:04 +05:30
|
|
|
import Utils
|
2006-03-19 08:55:31 +05:30
|
|
|
import const
|
2009-02-03 03:25:22 +05:30
|
|
|
from widgets.menutoolbuttonaction import MenuToolButtonAction
|
|
|
|
|
2008-01-25 01:32:09 +05:30
|
|
|
from TransUtils import sgettext as _
|
2008-07-26 14:05:07 +05:30
|
|
|
from QuestionDialog import QuestionDialog, QuestionDialog2
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2005-08-11 05:23:24 +05:30
|
|
|
NAVIGATION_NONE = -1
|
|
|
|
NAVIGATION_PERSON = 0
|
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
#------------------------------------------------------------------------------
|
2005-08-12 08:05:27 +05:30
|
|
|
#
|
|
|
|
# PageView
|
|
|
|
#
|
2007-09-12 09:29:39 +05:30
|
|
|
#------------------------------------------------------------------------------
|
2005-08-09 10:11:20 +05:30
|
|
|
class PageView:
|
2007-09-12 09:29:39 +05:30
|
|
|
"""
|
|
|
|
The PageView class is the base class for all Data Views in GRAMPS. All
|
|
|
|
Views should derive from this class. The ViewManager understands the public
|
|
|
|
interface of this class
|
|
|
|
"""
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2007-05-08 09:38:25 +05:30
|
|
|
def __init__(self, title, dbstate, uistate):
|
2005-08-09 10:11:20 +05:30
|
|
|
self.title = title
|
2005-08-11 05:23:24 +05:30
|
|
|
self.dbstate = dbstate
|
|
|
|
self.uistate = uistate
|
2005-08-09 10:11:20 +05:30
|
|
|
self.action_list = []
|
|
|
|
self.action_toggle_list = []
|
2009-02-03 03:25:22 +05:30
|
|
|
self.action_toolmenu_list = []
|
|
|
|
self.action_toolmenu = {} #easy access to toolmenuaction and proxies
|
2005-08-09 10:11:20 +05:30
|
|
|
self.action_group = None
|
2005-08-10 19:58:16 +05:30
|
|
|
self.additional_action_groups = []
|
2005-08-11 05:23:24 +05:30
|
|
|
self.additional_uis = []
|
2005-08-09 10:11:20 +05:30
|
|
|
self.widget = None
|
2007-01-20 09:52:31 +05:30
|
|
|
self.model = None
|
2007-09-12 09:29:39 +05:30
|
|
|
self.ui_def = '<ui></ui>'
|
|
|
|
self.dbstate.connect('no-database', self.disable_action_group)
|
|
|
|
self.dbstate.connect('database-changed', self.enable_action_group)
|
2006-01-20 11:03:38 +05:30
|
|
|
self.dirty = True
|
|
|
|
self.active = False
|
2006-04-21 09:44:00 +05:30
|
|
|
self.handle_col = 0
|
|
|
|
self.selection = None
|
2007-09-12 09:29:39 +05:30
|
|
|
self.func_list = {}
|
2006-05-02 09:20:46 +05:30
|
|
|
|
|
|
|
def call_function(self, key):
|
2007-09-12 09:29:39 +05:30
|
|
|
"""
|
|
|
|
Calls the function associated with the key value
|
|
|
|
"""
|
2006-05-02 09:20:46 +05:30
|
|
|
self.func_list.get(key)()
|
2006-01-20 11:03:38 +05:30
|
|
|
|
2006-06-21 08:13:19 +05:30
|
|
|
def post(self):
|
|
|
|
pass
|
|
|
|
|
2006-01-20 11:03:38 +05:30
|
|
|
def set_active(self):
|
2007-09-12 09:29:39 +05:30
|
|
|
"""
|
|
|
|
Called with the PageView is set as active. If the page is "dirty",
|
|
|
|
then we rebuild the data.
|
|
|
|
"""
|
2006-01-20 11:03:38 +05:30
|
|
|
self.active = True
|
|
|
|
if self.dirty:
|
2006-02-02 22:30:37 +05:30
|
|
|
self.uistate.set_busy_cursor(True)
|
2006-01-20 11:03:38 +05:30
|
|
|
self.build_tree()
|
2006-02-02 22:30:37 +05:30
|
|
|
self.uistate.set_busy_cursor(False)
|
2006-01-20 11:03:38 +05:30
|
|
|
|
|
|
|
def set_inactive(self):
|
2007-09-12 09:29:39 +05:30
|
|
|
"""
|
|
|
|
Marks page as being active (currently displayed)
|
|
|
|
"""
|
2006-01-20 11:03:38 +05:30
|
|
|
self.active = False
|
|
|
|
|
|
|
|
def build_tree(self):
|
2007-09-12 09:29:39 +05:30
|
|
|
"""
|
|
|
|
Rebuilds the current display. This must be overridden by the derived
|
|
|
|
class.
|
|
|
|
"""
|
|
|
|
raise NotImplementedError
|
2005-08-11 05:23:24 +05:30
|
|
|
|
|
|
|
def navigation_type(self):
|
2007-09-12 09:29:39 +05:30
|
|
|
"""
|
|
|
|
Indictates the navigation type. Currently, we only support navigation
|
|
|
|
for views that are Person centric.
|
|
|
|
"""
|
2005-08-11 05:23:24 +05:30
|
|
|
return NAVIGATION_NONE
|
|
|
|
|
|
|
|
def ui_definition(self):
|
2007-09-12 09:29:39 +05:30
|
|
|
"""
|
|
|
|
returns the XML UI definition for the UIManager
|
|
|
|
"""
|
|
|
|
return self.ui_def
|
2005-08-11 05:23:24 +05:30
|
|
|
|
|
|
|
def additional_ui_definitions(self):
|
2007-09-12 09:29:39 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return any additional interfaces for the UIManager that the view
|
2007-09-12 09:29:39 +05:30
|
|
|
needs to define.
|
|
|
|
"""
|
2005-08-11 05:23:24 +05:30
|
|
|
return self.additional_uis
|
2005-08-10 19:58:16 +05:30
|
|
|
|
|
|
|
def disable_action_group(self):
|
2007-09-12 09:29:39 +05:30
|
|
|
"""
|
|
|
|
Turns off the visibility of the View's action group, if defined
|
|
|
|
"""
|
2005-08-10 19:58:16 +05:30
|
|
|
if self.action_group:
|
|
|
|
self.action_group.set_visible(False)
|
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
def enable_action_group(self, obj):
|
|
|
|
"""
|
|
|
|
Turns on the visibility of the View's action group, if defined
|
|
|
|
"""
|
2005-08-10 19:58:16 +05:30
|
|
|
if self.action_group:
|
|
|
|
self.action_group.set_visible(True)
|
|
|
|
|
2005-08-09 10:11:20 +05:30
|
|
|
def get_stock(self):
|
2007-09-12 09:29:39 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return image associated with the view, which is used for the
|
2007-09-12 09:29:39 +05:30
|
|
|
icon for the button.
|
|
|
|
"""
|
|
|
|
return gtk.STOCK_MISSING_IMAGE
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
def get_title(self):
|
2007-09-12 09:29:39 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return the title of the view. This is used to define the text for the
|
2007-09-12 09:29:39 +05:30
|
|
|
button, and for the tab label.
|
|
|
|
"""
|
2005-08-09 10:11:20 +05:30
|
|
|
return self.title
|
|
|
|
|
|
|
|
def get_display(self):
|
2007-09-12 09:29:39 +05:30
|
|
|
"""
|
|
|
|
Builds the graphical display, returning the top level widget.
|
|
|
|
"""
|
2005-08-09 10:11:20 +05:30
|
|
|
if not self.widget:
|
|
|
|
self.widget = self.build_widget()
|
|
|
|
return self.widget
|
|
|
|
|
|
|
|
def build_widget(self):
|
2007-09-12 09:29:39 +05:30
|
|
|
"""
|
|
|
|
Builds the container widget for the interface. Must be overridden by the
|
|
|
|
the base class. Returns a gtk container widget.
|
|
|
|
"""
|
|
|
|
raise NotImplementedError
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
def define_actions(self):
|
2007-09-12 09:29:39 +05:30
|
|
|
"""
|
|
|
|
Defines the UIManager actions. Called by the ViewManager to set up the
|
|
|
|
View. The user typically defines self.action_list and
|
|
|
|
self.action_toggle_list in this function.
|
|
|
|
|
|
|
|
Derived classes must override this function.
|
|
|
|
"""
|
|
|
|
raise NotImplementedError
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
def __build_action_group(self):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Create an UIManager ActionGroup from the values in self.action_list
|
2007-09-12 09:29:39 +05:30
|
|
|
and self.action_toggle_list. The user should define these in
|
|
|
|
self.define_actions
|
|
|
|
"""
|
2005-08-09 10:11:20 +05:30
|
|
|
self.action_group = gtk.ActionGroup(self.title)
|
|
|
|
if len(self.action_list) > 0:
|
|
|
|
self.action_group.add_actions(self.action_list)
|
|
|
|
if len(self.action_toggle_list) > 0:
|
|
|
|
self.action_group.add_toggle_actions(self.action_toggle_list)
|
2009-02-03 03:25:22 +05:30
|
|
|
for action_toolmenu in self.action_toolmenu_list:
|
|
|
|
self.action_toolmenu[action_toolmenu[0]] = \
|
|
|
|
MenuToolButtonAction(action_toolmenu[0], #unique name
|
|
|
|
action_toolmenu[1], #label
|
|
|
|
action_toolmenu[2], #tooltip
|
|
|
|
action_toolmenu[3], #callback
|
|
|
|
action_toolmenu[4] #arrow tooltip
|
|
|
|
)
|
|
|
|
self.action_group.add_action(
|
|
|
|
self.action_toolmenu[action_toolmenu[0]])
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2007-09-13 09:50:24 +05:30
|
|
|
def _add_action(self, name, stock_icon, label, accel=None, tip=None,
|
2005-08-12 08:05:27 +05:30
|
|
|
callback=None):
|
2007-09-13 09:50:24 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Add an action to the action list for the current view.
|
2007-09-13 09:50:24 +05:30
|
|
|
"""
|
2009-02-03 03:25:22 +05:30
|
|
|
self.action_list.append((name, stock_icon, label, accel, tip,
|
|
|
|
callback))
|
2005-08-09 10:11:20 +05:30
|
|
|
|
2007-09-13 09:50:24 +05:30
|
|
|
def _add_toggle_action(self, name, stock_icon, label, accel=None,
|
|
|
|
tip=None, callback=None, value=False):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Add a toggle action to the action list for the current view.
|
2007-09-13 09:50:24 +05:30
|
|
|
"""
|
2007-09-12 09:29:39 +05:30
|
|
|
self.action_toggle_list.append((name, stock_icon, label, accel,
|
|
|
|
tip, callback, value))
|
2009-02-03 03:25:22 +05:30
|
|
|
|
|
|
|
def _add_toolmenu_action(self, name, label, tooltip, callback,
|
|
|
|
arrowtooltip):
|
|
|
|
self.action_toolmenu_list.append((name, label, tooltip, callback,
|
|
|
|
arrowtooltip))
|
2005-08-09 10:11:20 +05:30
|
|
|
|
|
|
|
def get_actions(self):
|
2007-09-13 09:50:24 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return the actions that should be used for the view. This includes the
|
2007-09-13 09:50:24 +05:30
|
|
|
standard action group (which handles the main toolbar), along with
|
|
|
|
additional action groups.
|
|
|
|
|
|
|
|
If the action group is not defined, we build it the first time. This
|
|
|
|
allows us to delay the intialization until it is really needed.
|
|
|
|
|
|
|
|
The ViewManager uses this function to extract the actions to install
|
|
|
|
into the UIManager.
|
|
|
|
"""
|
2005-08-09 10:11:20 +05:30
|
|
|
if not self.action_group:
|
2007-09-12 09:29:39 +05:30
|
|
|
self.__build_action_group()
|
2005-08-10 19:58:16 +05:30
|
|
|
return [self.action_group] + self.additional_action_groups
|
|
|
|
|
2007-09-13 09:50:24 +05:30
|
|
|
def _add_action_group(self, group):
|
|
|
|
"""
|
|
|
|
Allows additional action groups to be added to the view.
|
|
|
|
"""
|
2005-08-10 19:58:16 +05:30
|
|
|
self.additional_action_groups.append(group)
|
2005-08-11 05:23:24 +05:30
|
|
|
|
2005-08-11 22:49:03 +05:30
|
|
|
def change_page(self):
|
2007-09-13 09:50:24 +05:30
|
|
|
"""
|
|
|
|
Called when the page changes.
|
|
|
|
"""
|
2007-04-02 04:07:10 +05:30
|
|
|
self.uistate.clear_filter_results()
|
2005-08-12 03:43:44 +05:30
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
def edit(self, obj):
|
|
|
|
"""
|
|
|
|
Template function to allow the editing of the selected object
|
|
|
|
"""
|
|
|
|
raise NotImplementedError
|
2006-04-20 08:40:23 +05:30
|
|
|
|
2008-07-26 14:05:07 +05:30
|
|
|
def remove(self, handle):
|
2007-09-12 09:29:39 +05:30
|
|
|
"""
|
2008-07-26 14:05:07 +05:30
|
|
|
Template function to allow the removal of an object by its handle
|
|
|
|
"""
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
def remove_selected_objects(self):
|
|
|
|
"""
|
|
|
|
Function to remove selected objects
|
|
|
|
"""
|
|
|
|
prompt = True
|
|
|
|
if len(self.selected_handles()) > 1:
|
|
|
|
q = QuestionDialog2(
|
|
|
|
_("Remove selected items?"),
|
|
|
|
_("More than one item has been selected for deletion. "
|
|
|
|
"Ask before deleting each one?"),
|
|
|
|
_("Yes"),
|
|
|
|
_("No"))
|
|
|
|
prompt = q.run()
|
|
|
|
|
|
|
|
if not prompt:
|
|
|
|
self.uistate.set_busy_cursor(1)
|
|
|
|
|
|
|
|
for handle in self.selected_handles():
|
|
|
|
(query, is_used, object) = self.remove_object_from_handle(handle)
|
|
|
|
if prompt:
|
|
|
|
if is_used:
|
|
|
|
msg = _('This item is currently being used. '
|
|
|
|
'Deleting it will remove it from the database and '
|
|
|
|
'from all other items that reference it.')
|
|
|
|
else:
|
|
|
|
msg = _('Deleting item will remove it from the database.')
|
|
|
|
|
|
|
|
msg = "%s %s" % (msg, Utils.data_recover_msg)
|
|
|
|
#descr = object.get_description()
|
|
|
|
#if descr == "":
|
|
|
|
descr = object.get_gramps_id()
|
|
|
|
self.uistate.set_busy_cursor(1)
|
|
|
|
QuestionDialog(_('Delete %s?') % descr, msg,
|
|
|
|
_('_Delete Item'), query.query_response)
|
|
|
|
self.uistate.set_busy_cursor(0)
|
|
|
|
else:
|
|
|
|
query.query_response()
|
|
|
|
|
|
|
|
if not prompt:
|
|
|
|
self.uistate.set_busy_cursor(0)
|
|
|
|
|
|
|
|
def remove_object_from_handle(self, handle):
|
|
|
|
"""
|
|
|
|
Template function to allow the removal of an object by its handle
|
2007-09-12 09:29:39 +05:30
|
|
|
"""
|
|
|
|
raise NotImplementedError
|
2006-04-20 08:40:23 +05:30
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
def add(self, obj):
|
|
|
|
"""
|
|
|
|
Template function to allow the adding of a new object
|
|
|
|
"""
|
|
|
|
raise NotImplementedError
|
2006-04-20 08:40:23 +05:30
|
|
|
|
2007-09-13 09:50:24 +05:30
|
|
|
def _key_press(self, obj, event):
|
2007-01-30 10:05:13 +05:30
|
|
|
#act if no modifier, and allow Num Lock as MOD2_MASK
|
2007-09-12 09:29:39 +05:30
|
|
|
if not event.state or event.state in (gtk.gdk.MOD2_MASK, ):
|
2007-01-30 10:05:13 +05:30
|
|
|
if event.keyval in (gtk.keysyms.Return, gtk.keysyms.KP_Enter):
|
|
|
|
self.edit(obj)
|
|
|
|
return True
|
2005-08-12 03:43:44 +05:30
|
|
|
return False
|
2005-08-12 08:05:27 +05:30
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
def blist(self, store, path, node, sel_list):
|
|
|
|
handle = store.get_value(node, self.handle_col)
|
2005-08-12 08:05:27 +05:30
|
|
|
sel_list.append(handle)
|
|
|
|
|
|
|
|
def selected_handles(self):
|
|
|
|
mlist = []
|
2007-09-12 09:29:39 +05:30
|
|
|
self.selection.selected_foreach(self.blist, mlist)
|
2005-08-12 08:05:27 +05:30
|
|
|
return mlist
|
|
|
|
|
|
|
|
def first_selected(self):
|
|
|
|
mlist = []
|
2007-09-12 09:29:39 +05:30
|
|
|
self.selection.selected_foreach(self.blist, mlist)
|
2005-08-12 08:05:27 +05:30
|
|
|
if mlist:
|
|
|
|
return mlist[0]
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
2007-12-26 21:18:51 +05:30
|
|
|
def on_delete(self):
|
|
|
|
"""
|
|
|
|
Method called on shutdown. Data views should put code here
|
|
|
|
that should be called when quiting the main application.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
2006-04-27 03:18:13 +05:30
|
|
|
class BookMarkView(PageView):
|
|
|
|
|
|
|
|
def __init__(self, title, state, uistate, bookmarks, bm_type):
|
|
|
|
PageView.__init__(self, title, state, uistate)
|
|
|
|
self.bm_type = bm_type
|
|
|
|
self.setup_bookmarks(bookmarks)
|
|
|
|
|
2006-04-27 04:13:59 +05:30
|
|
|
def goto_handle(self, obj):
|
2007-09-12 09:29:39 +05:30
|
|
|
raise NotImplementedError
|
2006-04-27 04:13:59 +05:30
|
|
|
|
2006-04-27 03:18:13 +05:30
|
|
|
def setup_bookmarks(self, bookmarks):
|
|
|
|
self.bookmarks = self.bm_type(
|
2006-04-27 04:13:59 +05:30
|
|
|
self.dbstate, self.uistate, bookmarks, self.goto_handle)
|
2006-04-27 03:18:13 +05:30
|
|
|
|
|
|
|
def add_bookmark(self, obj):
|
2007-06-28 11:11:40 +05:30
|
|
|
from BasicUtils import name_displayer
|
2006-04-27 03:18:13 +05:30
|
|
|
|
|
|
|
if self.dbstate.active:
|
|
|
|
self.bookmarks.add(self.dbstate.active.get_handle())
|
2007-06-28 11:11:40 +05:30
|
|
|
name = name_displayer.display(self.dbstate.active)
|
2007-09-12 09:29:39 +05:30
|
|
|
self.uistate.push_message(self.dbstate,
|
In .:
2006-07-31 Alex Roitman <shura@gramps-project.org>
* src/Filters/_SearchBar.py (SearchBar.__init__): Take dbstate as
a constructor argument; (SearchBar.apply_filter): pass dbstate.
* src/PageView.py (BookMarkView.add_bookmark,
PersonNavView.jumpto, PersonNavView.fwd_clicked,
PersonNavView.back_clicked, ListView.build_widget): Pass dbstate.
* src/Navigation.py (BaseNavigation.__init__,
PersonNavigation.__init__): Take dbstate as a constructor argument;
(PersonNavigation.build_item_name): properly access dbstate.
* src/DisplayState.py (__init__): Do not take dbstate as a
constructor argument; Do not connect dbstate signal here (moved to
ViewManager);
(display_relationship,push_message,modify_statusbar): Make dbstate
an argument.
* src/plugins/Checkpoint.py (run_tool): Pass dbstate.
* src/ViewManager.py (_build_main_window): Do not pass dbstate to
uistate DisplayState constructor; connect dbstate signal handler;
pass dbstate to Navigation; (keypress): Pass dbstate;
(statusbar_key_update): Pass dbstate;
(do_load_plugins): Pass dbstate;
(ViewManager.add_bookmark): Pass dbstate.
* src/DataViews/_RelationView.py (shade_update): Pass dbstate.
* src/DataViews/_PersonView.py (build_widget,_goto,
key_goto_home_person, key_edit_selected_person): Pass dbstate.
* src/Filters/Makefile.am (pkgdata_PYTHON): Remove obsolete file.
* src/Filters/__init__.py: Remove importing obsolete module.
* src/Filters/_FilterWidget.py: Remove obsolete module.
In po:
2006-07-31 Alex Roitman <shura@gramps-project.org>
* POTFILES.in: Remove obsolete file.
svn: r7104
2006-08-01 10:01:10 +05:30
|
|
|
_("%s has been bookmarked") % name)
|
2006-04-27 03:18:13 +05:30
|
|
|
else:
|
|
|
|
from QuestionDialog import WarningDialog
|
|
|
|
WarningDialog(
|
|
|
|
_("Could Not Set a Bookmark"),
|
|
|
|
_("A bookmark could not be set because "
|
|
|
|
"no one was selected."))
|
|
|
|
|
|
|
|
def set_active(self):
|
|
|
|
PageView.set_active(self)
|
|
|
|
self.bookmarks.display()
|
|
|
|
|
|
|
|
def set_inactive(self):
|
|
|
|
PageView.set_inactive(self)
|
|
|
|
self.bookmarks.undisplay()
|
|
|
|
|
|
|
|
def edit_bookmarks(self, obj):
|
|
|
|
self.bookmarks.edit()
|
|
|
|
|
|
|
|
def enable_action_group(self, obj):
|
|
|
|
PageView.enable_action_group(self, obj)
|
|
|
|
|
2007-01-04 10:39:41 +05:30
|
|
|
def disable_action_group(self):
|
2006-04-27 03:18:13 +05:30
|
|
|
PageView.disable_action_group(self)
|
|
|
|
|
|
|
|
def define_actions(self):
|
|
|
|
self.book_action = gtk.ActionGroup(self.title + '/Bookmark')
|
|
|
|
self.book_action.add_actions([
|
2008-01-29 02:52:06 +05:30
|
|
|
('AddBook', 'gramps-bookmark-new', _('_Add Bookmark'),
|
2007-09-13 09:50:24 +05:30
|
|
|
'<control>d', None, self.add_bookmark),
|
2008-02-19 14:48:47 +05:30
|
|
|
('EditBook', 'gramps-bookmark-edit',
|
|
|
|
_("%(title)s...") % {'title': _("Organize Bookmarks")},
|
|
|
|
'<shift><control>b', None,
|
2007-09-12 09:29:39 +05:30
|
|
|
self.edit_bookmarks),
|
2006-04-27 03:18:13 +05:30
|
|
|
])
|
|
|
|
|
2007-09-13 09:50:24 +05:30
|
|
|
self._add_action_group(self.book_action)
|
2006-04-27 03:18:13 +05:30
|
|
|
|
2005-08-12 08:05:27 +05:30
|
|
|
#----------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# PersonNavView
|
|
|
|
#
|
|
|
|
#----------------------------------------------------------------
|
2006-04-27 03:18:13 +05:30
|
|
|
class PersonNavView(BookMarkView):
|
2005-08-12 08:05:27 +05:30
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
def __init__(self, title, dbstate, uistate, callback=None):
|
|
|
|
BookMarkView.__init__(self, title, dbstate, uistate,
|
|
|
|
dbstate.db.get_bookmarks(),
|
2006-04-27 03:18:13 +05:30
|
|
|
Bookmarks.Bookmarks)
|
2005-08-11 22:49:03 +05:30
|
|
|
|
|
|
|
def navigation_type(self):
|
|
|
|
return NAVIGATION_PERSON
|
|
|
|
|
|
|
|
def define_actions(self):
|
|
|
|
# add the Forward action group to handle the Forward button
|
|
|
|
|
2006-04-27 03:18:13 +05:30
|
|
|
BookMarkView.define_actions(self)
|
|
|
|
|
2005-08-11 22:49:03 +05:30
|
|
|
self.fwd_action = gtk.ActionGroup(self.title + '/Forward')
|
|
|
|
self.fwd_action.add_actions([
|
2007-09-12 09:29:39 +05:30
|
|
|
('Forward', gtk.STOCK_GO_FORWARD, _("_Forward"),
|
|
|
|
"<ALT>Right", _("Go to the next person in the history"),
|
2006-05-08 06:45:19 +05:30
|
|
|
self.fwd_clicked)
|
2005-08-11 22:49:03 +05:30
|
|
|
])
|
|
|
|
|
|
|
|
# add the Backward action group to handle the Forward button
|
|
|
|
self.back_action = gtk.ActionGroup(self.title + '/Backward')
|
|
|
|
self.back_action.add_actions([
|
2007-09-12 09:29:39 +05:30
|
|
|
('Back', gtk.STOCK_GO_BACK, _("_Back"),
|
|
|
|
"<ALT>Left", _("Go to the previous person in the history"),
|
2006-05-08 06:45:19 +05:30
|
|
|
self.back_clicked)
|
2005-08-11 22:49:03 +05:30
|
|
|
])
|
2005-08-11 05:23:24 +05:30
|
|
|
|
2007-09-13 09:50:24 +05:30
|
|
|
self._add_action('HomePerson', gtk.STOCK_HOME, _("_Home"),
|
|
|
|
accel="<Alt>Home",
|
|
|
|
tip=_("Go to the default person"), callback=self.home)
|
|
|
|
self._add_action('FilterEdit', None, _('Person Filter Editor'),
|
2006-12-19 07:59:47 +05:30
|
|
|
callback=self.filter_editor)
|
|
|
|
|
|
|
|
self.other_action = gtk.ActionGroup(self.title + '/PersonOther')
|
|
|
|
self.other_action.add_actions([
|
2007-01-28 04:38:08 +05:30
|
|
|
('SetActive', gtk.STOCK_HOME, _("Set _Home Person"), None,
|
2007-09-12 09:29:39 +05:30
|
|
|
None, self.set_default_person),
|
2006-12-19 07:59:47 +05:30
|
|
|
])
|
2006-01-05 00:26:06 +05:30
|
|
|
|
2007-09-13 09:50:24 +05:30
|
|
|
self._add_action_group(self.back_action)
|
|
|
|
self._add_action_group(self.fwd_action)
|
|
|
|
self._add_action_group(self.other_action)
|
2005-08-11 22:49:03 +05:30
|
|
|
|
|
|
|
def disable_action_group(self):
|
|
|
|
"""
|
2007-09-12 09:29:39 +05:30
|
|
|
Normally, this would not be overridden from the base class. However,
|
2005-08-11 22:49:03 +05:30
|
|
|
in this case, we have additional action groups that need to be
|
|
|
|
handled correctly.
|
|
|
|
"""
|
2006-04-27 03:18:13 +05:30
|
|
|
BookMarkView.disable_action_group(self)
|
2005-08-11 22:49:03 +05:30
|
|
|
|
|
|
|
self.fwd_action.set_visible(False)
|
|
|
|
self.back_action.set_visible(False)
|
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
def enable_action_group(self, obj):
|
2005-08-11 22:49:03 +05:30
|
|
|
"""
|
2007-09-12 09:29:39 +05:30
|
|
|
Normally, this would not be overridden from the base class. However,
|
2005-08-11 22:49:03 +05:30
|
|
|
in this case, we have additional action groups that need to be
|
|
|
|
handled correctly.
|
|
|
|
"""
|
2007-09-12 09:29:39 +05:30
|
|
|
BookMarkView.enable_action_group(self, obj)
|
2005-08-11 22:49:03 +05:30
|
|
|
|
|
|
|
self.fwd_action.set_visible(True)
|
|
|
|
self.back_action.set_visible(True)
|
|
|
|
hobj = self.uistate.phistory
|
|
|
|
self.fwd_action.set_sensitive(not hobj.at_end())
|
|
|
|
self.back_action.set_sensitive(not hobj.at_front())
|
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
def set_default_person(self, obj):
|
2006-02-10 06:40:52 +05:30
|
|
|
active = self.dbstate.active
|
|
|
|
if active:
|
|
|
|
self.dbstate.db.set_default_person_handle(active.get_handle())
|
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
def home(self, obj):
|
2005-08-11 22:49:03 +05:30
|
|
|
defperson = self.dbstate.db.get_default_person()
|
|
|
|
if defperson:
|
|
|
|
self.dbstate.change_active_person(defperson)
|
|
|
|
|
2007-01-26 05:45:21 +05:30
|
|
|
def jump(self):
|
2007-09-12 09:29:39 +05:30
|
|
|
dialog = gtk.Dialog(_('Jump to by GRAMPS ID'), None,
|
2006-01-08 10:10:33 +05:30
|
|
|
gtk.DIALOG_NO_SEPARATOR)
|
|
|
|
dialog.set_border_width(12)
|
2007-09-13 09:50:24 +05:30
|
|
|
label = gtk.Label('<span weight="bold" size="larger">%s</span>' %
|
|
|
|
_('Jump to by GRAMPS ID'))
|
2006-01-08 10:10:33 +05:30
|
|
|
label.set_use_markup(True)
|
|
|
|
dialog.vbox.add(label)
|
|
|
|
dialog.vbox.set_spacing(10)
|
|
|
|
dialog.vbox.set_border_width(12)
|
|
|
|
hbox = gtk.HBox()
|
2007-09-12 09:29:39 +05:30
|
|
|
hbox.pack_start(gtk.Label("%s: " % _('ID')), False)
|
2006-01-08 10:10:33 +05:30
|
|
|
text = gtk.Entry()
|
|
|
|
text.set_activates_default(True)
|
2007-09-12 09:29:39 +05:30
|
|
|
hbox.pack_start(text, False)
|
|
|
|
dialog.vbox.pack_start(hbox, False)
|
|
|
|
dialog.add_buttons(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
2006-01-08 10:10:33 +05:30
|
|
|
gtk.STOCK_JUMP_TO, gtk.RESPONSE_OK)
|
|
|
|
dialog.set_default_response(gtk.RESPONSE_OK)
|
|
|
|
dialog.vbox.show_all()
|
|
|
|
|
|
|
|
if dialog.run() == gtk.RESPONSE_OK:
|
|
|
|
gid = text.get_text()
|
|
|
|
person = self.dbstate.db.get_person_from_gramps_id(gid)
|
|
|
|
if person:
|
|
|
|
self.dbstate.change_active_person(person)
|
|
|
|
else:
|
2006-05-10 09:32:45 +05:30
|
|
|
self.uistate.push_message(
|
2007-09-12 09:29:39 +05:30
|
|
|
self.dbstate,
|
2006-05-10 09:32:45 +05:30
|
|
|
_("Error: %s is not a valid GRAMPS ID") % gid)
|
2006-01-08 10:10:33 +05:30
|
|
|
dialog.destroy()
|
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
def filter_editor(self, obj):
|
2006-07-03 07:58:44 +05:30
|
|
|
from FilterEditor import FilterEditor
|
|
|
|
|
2006-07-30 09:04:10 +05:30
|
|
|
try:
|
2007-09-12 09:29:39 +05:30
|
|
|
FilterEditor('Person', const.CUSTOM_FILTERS,
|
|
|
|
self.dbstate, self.uistate)
|
2006-07-30 09:04:10 +05:30
|
|
|
except Errors.WindowActiveError:
|
2007-09-12 09:29:39 +05:30
|
|
|
return
|
2006-07-03 07:58:44 +05:30
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
def fwd_clicked(self, obj, step=1):
|
2005-08-11 22:49:03 +05:30
|
|
|
hobj = self.uistate.phistory
|
|
|
|
hobj.lock = True
|
|
|
|
if not hobj.at_end():
|
|
|
|
try:
|
|
|
|
handle = hobj.forward()
|
|
|
|
self.dbstate.change_active_handle(handle)
|
In .:
2006-07-31 Alex Roitman <shura@gramps-project.org>
* src/Filters/_SearchBar.py (SearchBar.__init__): Take dbstate as
a constructor argument; (SearchBar.apply_filter): pass dbstate.
* src/PageView.py (BookMarkView.add_bookmark,
PersonNavView.jumpto, PersonNavView.fwd_clicked,
PersonNavView.back_clicked, ListView.build_widget): Pass dbstate.
* src/Navigation.py (BaseNavigation.__init__,
PersonNavigation.__init__): Take dbstate as a constructor argument;
(PersonNavigation.build_item_name): properly access dbstate.
* src/DisplayState.py (__init__): Do not take dbstate as a
constructor argument; Do not connect dbstate signal here (moved to
ViewManager);
(display_relationship,push_message,modify_statusbar): Make dbstate
an argument.
* src/plugins/Checkpoint.py (run_tool): Pass dbstate.
* src/ViewManager.py (_build_main_window): Do not pass dbstate to
uistate DisplayState constructor; connect dbstate signal handler;
pass dbstate to Navigation; (keypress): Pass dbstate;
(statusbar_key_update): Pass dbstate;
(do_load_plugins): Pass dbstate;
(ViewManager.add_bookmark): Pass dbstate.
* src/DataViews/_RelationView.py (shade_update): Pass dbstate.
* src/DataViews/_PersonView.py (build_widget,_goto,
key_goto_home_person, key_edit_selected_person): Pass dbstate.
* src/Filters/Makefile.am (pkgdata_PYTHON): Remove obsolete file.
* src/Filters/__init__.py: Remove importing obsolete module.
* src/Filters/_FilterWidget.py: Remove obsolete module.
In po:
2006-07-31 Alex Roitman <shura@gramps-project.org>
* POTFILES.in: Remove obsolete file.
svn: r7104
2006-08-01 10:01:10 +05:30
|
|
|
self.uistate.modify_statusbar(self.dbstate)
|
2005-08-11 22:49:03 +05:30
|
|
|
hobj.mhistory.append(hobj.history[hobj.index])
|
|
|
|
self.fwd_action.set_sensitive(not hobj.at_end())
|
|
|
|
self.back_action.set_sensitive(True)
|
|
|
|
except:
|
|
|
|
hobj.clear()
|
|
|
|
self.fwd_action.set_sensitive(False)
|
|
|
|
self.back_action.set_sensitive(False)
|
|
|
|
else:
|
|
|
|
self.fwd_action.set_sensitive(False)
|
|
|
|
self.back_action.set_sensitive(True)
|
|
|
|
hobj.lock = False
|
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
def back_clicked(self, obj, step=1):
|
2005-08-11 22:49:03 +05:30
|
|
|
hobj = self.uistate.phistory
|
|
|
|
hobj.lock = True
|
|
|
|
if not hobj.at_front():
|
|
|
|
try:
|
|
|
|
handle = hobj.back()
|
|
|
|
self.active = self.dbstate.db.get_person_from_handle(handle)
|
In .:
2006-07-31 Alex Roitman <shura@gramps-project.org>
* src/Filters/_SearchBar.py (SearchBar.__init__): Take dbstate as
a constructor argument; (SearchBar.apply_filter): pass dbstate.
* src/PageView.py (BookMarkView.add_bookmark,
PersonNavView.jumpto, PersonNavView.fwd_clicked,
PersonNavView.back_clicked, ListView.build_widget): Pass dbstate.
* src/Navigation.py (BaseNavigation.__init__,
PersonNavigation.__init__): Take dbstate as a constructor argument;
(PersonNavigation.build_item_name): properly access dbstate.
* src/DisplayState.py (__init__): Do not take dbstate as a
constructor argument; Do not connect dbstate signal here (moved to
ViewManager);
(display_relationship,push_message,modify_statusbar): Make dbstate
an argument.
* src/plugins/Checkpoint.py (run_tool): Pass dbstate.
* src/ViewManager.py (_build_main_window): Do not pass dbstate to
uistate DisplayState constructor; connect dbstate signal handler;
pass dbstate to Navigation; (keypress): Pass dbstate;
(statusbar_key_update): Pass dbstate;
(do_load_plugins): Pass dbstate;
(ViewManager.add_bookmark): Pass dbstate.
* src/DataViews/_RelationView.py (shade_update): Pass dbstate.
* src/DataViews/_PersonView.py (build_widget,_goto,
key_goto_home_person, key_edit_selected_person): Pass dbstate.
* src/Filters/Makefile.am (pkgdata_PYTHON): Remove obsolete file.
* src/Filters/__init__.py: Remove importing obsolete module.
* src/Filters/_FilterWidget.py: Remove obsolete module.
In po:
2006-07-31 Alex Roitman <shura@gramps-project.org>
* POTFILES.in: Remove obsolete file.
svn: r7104
2006-08-01 10:01:10 +05:30
|
|
|
self.uistate.modify_statusbar(self.dbstate)
|
2005-08-11 22:49:03 +05:30
|
|
|
self.dbstate.change_active_handle(handle)
|
|
|
|
hobj.mhistory.append(hobj.history[hobj.index])
|
|
|
|
self.back_action.set_sensitive(not hobj.at_front())
|
|
|
|
self.fwd_action.set_sensitive(True)
|
|
|
|
except:
|
|
|
|
hobj.clear()
|
|
|
|
self.fwd_action.set_sensitive(False)
|
|
|
|
self.back_action.set_sensitive(False)
|
|
|
|
else:
|
|
|
|
self.back_action.set_sensitive(False)
|
|
|
|
self.fwd_action.set_sensitive(True)
|
|
|
|
hobj.lock = False
|
|
|
|
|
|
|
|
def handle_history(self, handle):
|
|
|
|
"""
|
|
|
|
Updates the person history information
|
2007-09-09 03:36:30 +05:30
|
|
|
It will push the person at the end of the history if that person is
|
|
|
|
not present person
|
2005-08-11 22:49:03 +05:30
|
|
|
"""
|
|
|
|
hobj = self.uistate.phistory
|
2007-09-09 03:36:30 +05:30
|
|
|
if handle and not hobj.lock and not (handle == hobj.present()):
|
2005-08-11 22:49:03 +05:30
|
|
|
hobj.push(handle)
|
|
|
|
self.fwd_action.set_sensitive(not hobj.at_end())
|
|
|
|
self.back_action.set_sensitive(not hobj.at_front())
|
|
|
|
|
|
|
|
def change_page(self):
|
|
|
|
hobj = self.uistate.phistory
|
|
|
|
self.fwd_action.set_sensitive(not hobj.at_end())
|
|
|
|
self.back_action.set_sensitive(not hobj.at_front())
|
2006-12-19 07:59:47 +05:30
|
|
|
self.other_action.set_sensitive(not self.dbstate.db.readonly)
|
2005-08-12 03:43:44 +05:30
|
|
|
|
2005-08-12 08:05:27 +05:30
|
|
|
#----------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# ListView
|
|
|
|
#
|
|
|
|
#----------------------------------------------------------------
|
2006-04-27 03:18:13 +05:30
|
|
|
class ListView(BookMarkView):
|
2005-08-12 03:43:44 +05:30
|
|
|
|
2006-05-08 06:45:19 +05:30
|
|
|
ADD_MSG = ""
|
|
|
|
EDIT_MSG = ""
|
|
|
|
DEL_MSG = ""
|
2007-08-31 01:19:04 +05:30
|
|
|
QR_CATEGORY = -1
|
2006-05-08 06:45:19 +05:30
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
def __init__(self, title, dbstate, uistate, columns, handle_col,
|
|
|
|
make_model, signal_map, get_bookmarks, bm_type,
|
2006-07-10 09:04:19 +05:30
|
|
|
multiple=False, filter_class=None):
|
2006-04-27 03:18:13 +05:30
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
BookMarkView.__init__(self, title, dbstate, uistate,
|
2006-04-27 03:18:13 +05:30
|
|
|
get_bookmarks, bm_type)
|
2006-07-10 09:04:19 +05:30
|
|
|
|
|
|
|
self.filter_class = filter_class
|
2005-08-12 03:43:44 +05:30
|
|
|
self.renderer = gtk.CellRendererText()
|
2007-09-12 09:29:39 +05:30
|
|
|
self.renderer.set_property('ellipsize', pango.ELLIPSIZE_END)
|
2005-08-12 03:43:44 +05:30
|
|
|
self.sort_col = 0
|
|
|
|
self.columns = []
|
|
|
|
self.colinfo = columns
|
|
|
|
self.handle_col = handle_col
|
|
|
|
self.make_model = make_model
|
|
|
|
self.signal_map = signal_map
|
2006-05-26 01:09:44 +05:30
|
|
|
self.multiple_selection = multiple
|
2006-07-10 09:04:19 +05:30
|
|
|
self.generic_filter = None
|
2007-09-12 09:29:39 +05:30
|
|
|
dbstate.connect('database-changed', self.change_db)
|
2005-08-12 03:43:44 +05:30
|
|
|
|
2006-07-10 09:04:19 +05:30
|
|
|
def build_filter_container(self, box, filter_class):
|
2007-05-08 09:38:25 +05:30
|
|
|
self.filter_sidebar = filter_class(self.dbstate, self.uistate,
|
|
|
|
self.filter_clicked)
|
2006-07-10 09:04:19 +05:30
|
|
|
self.filter_pane = self.filter_sidebar.get_widget()
|
|
|
|
|
|
|
|
hpaned = gtk.HBox()
|
|
|
|
hpaned.pack_start(self.vbox, True, True)
|
|
|
|
hpaned.pack_end(self.filter_pane, False, False)
|
2006-07-11 03:16:46 +05:30
|
|
|
self.filter_toggle(None, None, None, None)
|
2006-07-10 09:04:19 +05:30
|
|
|
return hpaned
|
|
|
|
|
2007-01-09 10:02:07 +05:30
|
|
|
def filter_toggle(self, client, cnxn_id, entry, data):
|
|
|
|
if Config.get(Config.FILTER):
|
|
|
|
self.search_bar.hide()
|
|
|
|
self.filter_pane.show()
|
|
|
|
else:
|
|
|
|
self.search_bar.show()
|
|
|
|
self.filter_pane.hide()
|
|
|
|
|
2006-07-10 09:04:19 +05:30
|
|
|
def post(self):
|
|
|
|
if self.filter_class:
|
|
|
|
if Config.get(Config.FILTER):
|
|
|
|
self.search_bar.hide()
|
|
|
|
self.filter_pane.show()
|
|
|
|
else:
|
|
|
|
self.search_bar.show()
|
|
|
|
self.filter_pane.hide()
|
|
|
|
|
|
|
|
def filter_clicked(self):
|
|
|
|
self.generic_filter = self.filter_sidebar.get_filter()
|
|
|
|
self.build_tree()
|
|
|
|
|
2006-04-27 03:18:13 +05:30
|
|
|
def add_bookmark(self, obj):
|
|
|
|
mlist = []
|
|
|
|
self.selection.selected_foreach(self.blist, mlist)
|
|
|
|
|
|
|
|
if mlist:
|
|
|
|
self.bookmarks.add(mlist[0])
|
|
|
|
else:
|
|
|
|
from QuestionDialog import WarningDialog
|
|
|
|
WarningDialog(
|
|
|
|
_("Could Not Set a Bookmark"),
|
|
|
|
_("A bookmark could not be set because "
|
|
|
|
"nothing was selected."))
|
|
|
|
|
2007-01-26 05:45:21 +05:30
|
|
|
def jump(self):
|
2007-09-12 09:29:39 +05:30
|
|
|
dialog = gtk.Dialog(_('Jump to by GRAMPS ID'), None,
|
2007-01-26 05:45:21 +05:30
|
|
|
gtk.DIALOG_NO_SEPARATOR)
|
|
|
|
dialog.set_border_width(12)
|
2007-09-12 09:29:39 +05:30
|
|
|
label = gtk.Label('<span weight="bold" size="larger">%s</span>' %
|
|
|
|
_('Jump to by GRAMPS ID'))
|
2007-01-26 05:45:21 +05:30
|
|
|
label.set_use_markup(True)
|
|
|
|
dialog.vbox.add(label)
|
|
|
|
dialog.vbox.set_spacing(10)
|
|
|
|
dialog.vbox.set_border_width(12)
|
|
|
|
hbox = gtk.HBox()
|
2007-09-12 09:29:39 +05:30
|
|
|
hbox.pack_start(gtk.Label("%s: " % _('ID')), False)
|
2007-01-26 05:45:21 +05:30
|
|
|
text = gtk.Entry()
|
|
|
|
text.set_activates_default(True)
|
2007-09-12 09:29:39 +05:30
|
|
|
hbox.pack_start(text, False)
|
|
|
|
dialog.vbox.pack_start(hbox, False)
|
|
|
|
dialog.add_buttons(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
2007-01-26 05:45:21 +05:30
|
|
|
gtk.STOCK_JUMP_TO, gtk.RESPONSE_OK)
|
|
|
|
dialog.set_default_response(gtk.RESPONSE_OK)
|
|
|
|
dialog.vbox.show_all()
|
|
|
|
|
|
|
|
if dialog.run() == gtk.RESPONSE_OK:
|
|
|
|
gid = text.get_text()
|
|
|
|
handle = self.get_handle_from_gramps_id(gid)
|
|
|
|
if handle:
|
|
|
|
self.goto_handle(handle)
|
|
|
|
else:
|
|
|
|
self.uistate.push_message(
|
2007-09-12 09:29:39 +05:30
|
|
|
self.dbstate,
|
2007-01-26 05:45:21 +05:30
|
|
|
_("Error: %s is not a valid GRAMPS ID") % gid)
|
|
|
|
dialog.destroy()
|
|
|
|
|
2006-03-23 04:33:57 +05:30
|
|
|
def drag_info(self):
|
|
|
|
return None
|
2006-03-27 10:36:10 +05:30
|
|
|
|
2007-07-08 08:57:06 +05:30
|
|
|
def drag_begin(self, widget, context):
|
2006-03-27 10:36:10 +05:30
|
|
|
widget.drag_source_set_icon_stock(self.get_stock())
|
2007-07-08 08:57:06 +05:30
|
|
|
return True
|
|
|
|
|
2005-08-12 08:05:27 +05:30
|
|
|
def column_order(self):
|
|
|
|
assert False
|
|
|
|
|
2005-08-12 03:43:44 +05:30
|
|
|
def build_widget(self):
|
|
|
|
"""
|
|
|
|
Builds the interface and returns a gtk.Container type that
|
|
|
|
contains the interface. This containter will be inserted into
|
|
|
|
a gtk.Notebook page.
|
|
|
|
"""
|
2006-01-17 20:41:15 +05:30
|
|
|
self.vbox = gtk.VBox()
|
2006-06-20 02:31:57 +05:30
|
|
|
self.vbox.set_border_width(4)
|
2006-01-17 20:41:15 +05:30
|
|
|
self.vbox.set_spacing(4)
|
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
self.search_bar = SearchBar(self.dbstate, self.uistate,
|
2007-04-02 04:07:10 +05:30
|
|
|
self.search_build_tree)
|
2006-05-10 21:38:56 +05:30
|
|
|
filter_box = self.search_bar.build()
|
2006-01-17 20:41:15 +05:30
|
|
|
|
2005-08-12 03:43:44 +05:30
|
|
|
self.list = gtk.TreeView()
|
|
|
|
self.list.set_rules_hint(True)
|
|
|
|
self.list.set_headers_visible(True)
|
|
|
|
self.list.set_headers_clickable(True)
|
2006-01-20 23:48:03 +05:30
|
|
|
self.list.set_fixed_height_mode(True)
|
2007-09-13 09:50:24 +05:30
|
|
|
self.list.connect('button-press-event', self._button_press)
|
|
|
|
self.list.connect('key-press-event', self._key_press)
|
2006-03-23 04:33:57 +05:30
|
|
|
if self.drag_info():
|
|
|
|
self.list.connect('drag_data_get', self.drag_data_get)
|
2006-03-27 10:36:10 +05:30
|
|
|
self.list.connect('drag_begin', self.drag_begin)
|
2005-08-12 03:43:44 +05:30
|
|
|
|
|
|
|
scrollwindow = gtk.ScrolledWindow()
|
|
|
|
scrollwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
|
|
|
scrollwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)
|
|
|
|
scrollwindow.add(self.list)
|
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
self.vbox.pack_start(filter_box, False)
|
|
|
|
self.vbox.pack_start(scrollwindow, True)
|
2006-01-17 20:41:15 +05:30
|
|
|
|
2005-08-12 03:43:44 +05:30
|
|
|
self.renderer = gtk.CellRendererText()
|
2007-09-12 09:29:39 +05:30
|
|
|
self.renderer.set_property('ellipsize', pango.ELLIPSIZE_END)
|
2005-08-12 03:43:44 +05:30
|
|
|
self.inactive = False
|
|
|
|
|
|
|
|
self.columns = []
|
|
|
|
self.build_columns()
|
|
|
|
self.selection = self.list.get_selection()
|
2006-05-26 01:09:44 +05:30
|
|
|
if self.multiple_selection:
|
|
|
|
self.selection.set_mode(gtk.SELECTION_MULTIPLE)
|
2007-09-12 09:29:39 +05:30
|
|
|
self.selection.connect('changed', self.row_changed)
|
2005-08-12 03:43:44 +05:30
|
|
|
|
2006-01-17 20:41:15 +05:30
|
|
|
self.setup_filter()
|
|
|
|
|
2006-07-10 09:04:19 +05:30
|
|
|
if self.filter_class:
|
|
|
|
return self.build_filter_container(self.vbox, self.filter_class)
|
|
|
|
else:
|
|
|
|
return self.vbox
|
2005-08-12 03:43:44 +05:30
|
|
|
|
2007-04-02 04:07:10 +05:30
|
|
|
def search_build_tree(self):
|
|
|
|
self.build_tree()
|
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
def row_changed(self, obj):
|
2006-03-23 04:33:57 +05:30
|
|
|
"""Called with a row is changed. Check the selected objects from
|
|
|
|
the person_tree to get the IDs of the selected objects. Set the
|
|
|
|
active person to the first person in the list. If no one is
|
|
|
|
selected, set the active person to None"""
|
|
|
|
|
|
|
|
if self.drag_info():
|
|
|
|
selected_ids = self.selected_handles()
|
|
|
|
|
|
|
|
if len(selected_ids) == 1:
|
2007-09-13 09:50:24 +05:30
|
|
|
self.list.drag_source_set(gtk.gdk.BUTTON1_MASK,
|
2007-09-12 09:29:39 +05:30
|
|
|
[self.drag_info().target()],
|
2007-09-13 09:50:24 +05:30
|
|
|
gtk.gdk.ACTION_COPY)
|
2006-03-23 04:33:57 +05:30
|
|
|
|
|
|
|
def drag_data_get(self, widget, context, sel_data, info, time):
|
|
|
|
selected_ids = self.selected_handles()
|
|
|
|
|
2006-11-07 06:59:15 +05:30
|
|
|
if selected_ids:
|
|
|
|
data = (self.drag_info().drag_type, id(self), selected_ids[0], 0)
|
2007-09-12 09:29:39 +05:30
|
|
|
sel_data.set(sel_data.target, 8 , pickle.dumps(data))
|
2007-07-08 08:57:06 +05:30
|
|
|
return True
|
2006-03-23 04:33:57 +05:30
|
|
|
|
2006-01-17 20:41:15 +05:30
|
|
|
def setup_filter(self):
|
2008-01-18 22:33:55 +05:30
|
|
|
"""Build the default filters and add them to the filter menu."""
|
2006-05-10 21:38:56 +05:30
|
|
|
cols = []
|
|
|
|
for pair in [pair for pair in self.column_order() if pair[0]]:
|
2007-09-12 09:29:39 +05:30
|
|
|
cols.append((self.colinfo[pair[1]], pair[1]))
|
2006-05-10 21:38:56 +05:30
|
|
|
self.search_bar.setup_filter(cols)
|
2006-01-17 20:41:15 +05:30
|
|
|
|
2006-04-27 04:13:59 +05:30
|
|
|
def goto_handle(self, handle):
|
2007-10-03 22:04:51 +05:30
|
|
|
if not handle or self.inactive:
|
2006-04-27 04:13:59 +05:30
|
|
|
return
|
|
|
|
|
2007-10-03 22:04:51 +05:30
|
|
|
# mark inactive to prevent recursion
|
2006-04-27 04:13:59 +05:30
|
|
|
self.inactive = True
|
|
|
|
|
2007-10-03 22:04:51 +05:30
|
|
|
# select the handle in the view
|
2006-04-27 04:13:59 +05:30
|
|
|
try:
|
|
|
|
path = self.model.on_get_path(handle)
|
|
|
|
self.selection.unselect_all()
|
|
|
|
self.selection.select_path(path)
|
2007-09-12 09:29:39 +05:30
|
|
|
self.list.scroll_to_cell(path, None, 1, 0.5, 0)
|
2006-04-27 04:13:59 +05:30
|
|
|
except KeyError:
|
|
|
|
self.selection.unselect_all()
|
|
|
|
|
|
|
|
# disable the inactive flag
|
|
|
|
self.inactive = False
|
|
|
|
|
2007-07-08 08:57:06 +05:30
|
|
|
def column_clicked(self, obj, data):
|
2005-08-12 03:43:44 +05:30
|
|
|
if self.sort_col != data:
|
|
|
|
order = gtk.SORT_ASCENDING
|
|
|
|
else:
|
|
|
|
if (self.columns[data].get_sort_order() == gtk.SORT_DESCENDING
|
2006-02-09 02:43:05 +05:30
|
|
|
or not self.columns[data].get_sort_indicator()):
|
2005-08-12 03:43:44 +05:30
|
|
|
order = gtk.SORT_ASCENDING
|
|
|
|
else:
|
|
|
|
order = gtk.SORT_DESCENDING
|
2006-05-15 09:44:03 +05:30
|
|
|
|
2005-08-12 03:43:44 +05:30
|
|
|
self.sort_col = data
|
|
|
|
handle = self.first_selected()
|
2006-05-10 21:38:56 +05:30
|
|
|
|
|
|
|
if Config.get(Config.FILTER):
|
2007-10-08 01:29:01 +05:30
|
|
|
search = (True, self.generic_filter)
|
2006-05-10 21:38:56 +05:30
|
|
|
else:
|
2007-09-12 09:29:39 +05:30
|
|
|
search = (False, self.search_bar.get_value())
|
2006-05-15 09:44:03 +05:30
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
self.model = self.make_model(self.dbstate.db, self.sort_col, order,
|
|
|
|
search=search,
|
2006-08-12 03:44:18 +05:30
|
|
|
sort_map=self.column_order())
|
2006-05-15 09:44:03 +05:30
|
|
|
|
2005-08-12 03:43:44 +05:30
|
|
|
self.list.set_model(self.model)
|
|
|
|
|
|
|
|
if handle:
|
|
|
|
path = self.model.on_get_path(handle)
|
|
|
|
self.selection.select_path(path)
|
2007-07-08 08:57:06 +05:30
|
|
|
self.list.scroll_to_cell(path, None, 1, 0.5, 0)
|
2006-01-09 06:24:04 +05:30
|
|
|
for i in xrange(len(self.columns)):
|
2006-11-08 10:45:26 +05:30
|
|
|
enable_sort_flag = (i==self.sort_col)
|
|
|
|
self.columns[i].set_sort_indicator(enable_sort_flag)
|
2005-08-12 03:43:44 +05:30
|
|
|
self.columns[self.sort_col].set_sort_order(order)
|
2007-07-08 08:57:06 +05:30
|
|
|
|
|
|
|
# set the search column to be the sorted column
|
|
|
|
search_col = self.column_order()[data][1]
|
|
|
|
self.list.set_search_column(search_col)
|
2008-03-22 21:11:33 +05:30
|
|
|
|
2005-08-12 03:43:44 +05:30
|
|
|
def build_columns(self):
|
|
|
|
for column in self.columns:
|
|
|
|
self.list.remove_column(column)
|
|
|
|
|
|
|
|
self.columns = []
|
|
|
|
|
|
|
|
index = 0
|
2006-01-09 06:24:04 +05:30
|
|
|
for pair in [pair for pair in self.column_order() if pair[0]]:
|
2005-08-12 03:43:44 +05:30
|
|
|
name = self.colinfo[pair[1]]
|
2007-03-06 09:43:14 +05:30
|
|
|
|
2008-07-17 23:40:32 +05:30
|
|
|
if self.model and 'marker_color_column' in self.model.__dict__:
|
2007-03-06 09:43:14 +05:30
|
|
|
mcol = self.model.marker_color_column
|
2007-09-12 09:29:39 +05:30
|
|
|
column = gtk.TreeViewColumn(name, self.renderer, text=pair[1],
|
2007-03-06 09:43:14 +05:30
|
|
|
foreground=mcol)
|
|
|
|
else:
|
|
|
|
column = gtk.TreeViewColumn(name, self.renderer, text=pair[1])
|
2007-09-13 09:50:24 +05:30
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
column.connect('clicked', self.column_clicked, index)
|
2005-08-12 03:43:44 +05:30
|
|
|
column.set_resizable(True)
|
2006-01-20 23:48:03 +05:30
|
|
|
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
|
|
|
|
column.set_fixed_width(pair[2])
|
2005-08-12 03:43:44 +05:30
|
|
|
column.set_clickable(True)
|
|
|
|
self.columns.append(column)
|
|
|
|
self.list.append_column(column)
|
|
|
|
index += 1
|
2005-08-19 18:14:44 +05:30
|
|
|
|
2005-08-12 03:43:44 +05:30
|
|
|
def build_tree(self):
|
2006-01-20 11:03:38 +05:30
|
|
|
if self.active:
|
2006-05-10 21:38:56 +05:30
|
|
|
if Config.get(Config.FILTER):
|
2006-07-10 09:04:19 +05:30
|
|
|
filter_info = (True, self.generic_filter)
|
2006-05-10 21:38:56 +05:30
|
|
|
else:
|
2006-07-10 09:04:19 +05:30
|
|
|
filter_info = (False, self.search_bar.get_value())
|
2006-05-10 21:38:56 +05:30
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
self.model = self.make_model(self.dbstate.db, self.sort_col,
|
2006-07-10 09:04:19 +05:30
|
|
|
search=filter_info)
|
2006-01-20 11:03:38 +05:30
|
|
|
self.list.set_model(self.model)
|
2008-03-22 21:11:33 +05:30
|
|
|
self.build_columns()
|
2006-01-20 11:03:38 +05:30
|
|
|
|
2008-06-16 20:31:46 +05:30
|
|
|
if const.USE_TIPS and self.model.tooltip_column is not None:
|
2006-07-10 09:04:19 +05:30
|
|
|
self.tooltips = TreeTips.TreeTips(
|
|
|
|
self.list, self.model.tooltip_column, True)
|
2006-01-20 11:03:38 +05:30
|
|
|
self.dirty = False
|
2007-09-12 09:29:39 +05:30
|
|
|
self.uistate.show_filter_results(self.dbstate,
|
|
|
|
self.model.displayed,
|
2007-04-02 09:26:30 +05:30
|
|
|
self.model.total)
|
2006-01-20 11:03:38 +05:30
|
|
|
else:
|
|
|
|
self.dirty = True
|
2007-10-03 22:04:51 +05:30
|
|
|
|
|
|
|
def object_build(self):
|
2008-01-11 04:57:06 +05:30
|
|
|
"""callback, for if tree must be rebuilt and bookmarks redrawn
|
2007-10-03 22:04:51 +05:30
|
|
|
"""
|
|
|
|
if self.active:
|
|
|
|
self.bookmarks.redraw()
|
|
|
|
self.build_tree()
|
2006-01-20 11:03:38 +05:30
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
def filter_toggle_action(self, obj):
|
2006-07-10 09:04:19 +05:30
|
|
|
if obj.get_active():
|
|
|
|
self.search_bar.hide()
|
|
|
|
self.filter_pane.show()
|
|
|
|
active = True
|
|
|
|
else:
|
|
|
|
self.search_bar.show()
|
|
|
|
self.filter_pane.hide()
|
|
|
|
active = False
|
|
|
|
Config.set(Config.FILTER, active)
|
|
|
|
self.build_tree()
|
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
def filter_editor(self, obj):
|
2007-01-09 10:02:07 +05:30
|
|
|
from FilterEditor import FilterEditor
|
|
|
|
|
|
|
|
try:
|
2007-09-12 09:29:39 +05:30
|
|
|
FilterEditor(self.FILTER_TYPE , const.CUSTOM_FILTERS,
|
2007-01-09 10:02:07 +05:30
|
|
|
self.dbstate, self.uistate)
|
|
|
|
except Errors.WindowActiveError:
|
2007-09-12 09:29:39 +05:30
|
|
|
return
|
2007-01-09 10:02:07 +05:30
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
def change_db(self, db):
|
2005-08-12 03:43:44 +05:30
|
|
|
for sig in self.signal_map:
|
|
|
|
db.connect(sig, self.signal_map[sig])
|
2006-04-27 03:18:13 +05:30
|
|
|
self.bookmarks.update_bookmarks(self.get_bookmarks())
|
2006-01-20 11:03:38 +05:30
|
|
|
if self.active:
|
|
|
|
self.build_tree()
|
2006-04-27 03:18:13 +05:30
|
|
|
self.bookmarks.redraw()
|
2006-01-20 11:03:38 +05:30
|
|
|
else:
|
|
|
|
self.dirty = True
|
2005-08-12 03:43:44 +05:30
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
def row_add(self, handle_list):
|
2006-02-08 10:38:28 +05:30
|
|
|
if self.active:
|
2007-01-30 10:05:13 +05:30
|
|
|
for handle in handle_list:
|
|
|
|
self.model.add_row_by_handle(handle)
|
2006-06-17 09:25:00 +05:30
|
|
|
else:
|
|
|
|
self.dirty = True
|
2005-08-12 03:43:44 +05:30
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
def row_update(self, handle_list):
|
2007-01-20 09:52:31 +05:30
|
|
|
if self.model:
|
|
|
|
self.model.prev_handle = None
|
2006-02-08 10:38:28 +05:30
|
|
|
if self.active:
|
|
|
|
for handle in handle_list:
|
|
|
|
self.model.update_row_by_handle(handle)
|
2006-06-17 09:25:00 +05:30
|
|
|
else:
|
|
|
|
self.dirty = True
|
2005-08-12 03:43:44 +05:30
|
|
|
|
2007-09-12 09:29:39 +05:30
|
|
|
def row_delete(self, handle_list):
|
2006-02-08 10:38:28 +05:30
|
|
|
if self.active:
|
|
|
|
for handle in handle_list:
|
|
|
|
self.model.delete_row_by_handle(handle)
|
2006-06-17 09:25:00 +05:30
|
|
|
else:
|
|
|
|
self.dirty = True
|
2005-08-12 03:43:44 +05:30
|
|
|
|
|
|
|
def define_actions(self):
|
|
|
|
"""
|
|
|
|
Required define_actions function for PageView. Builds the action
|
2007-09-12 09:29:39 +05:30
|
|
|
group information required. We extend beyond the normal here,
|
2005-08-12 03:43:44 +05:30
|
|
|
since we want to have more than one action group for the PersonView.
|
|
|
|
Most PageViews really won't care about this.
|
|
|
|
"""
|
2006-04-27 03:18:13 +05:30
|
|
|
|
|
|
|
BookMarkView.define_actions(self)
|
2005-08-12 03:43:44 +05:30
|
|
|
|
2006-12-19 07:59:47 +05:30
|
|
|
self.edit_action = gtk.ActionGroup(self.title + '/ChangeOrder')
|
|
|
|
self.edit_action.add_actions([
|
2008-01-29 02:52:06 +05:30
|
|
|
('Add', gtk.STOCK_ADD, _("_Add..."), "<control>Insert",
|
2007-09-12 09:29:39 +05:30
|
|
|
self.ADD_MSG, self.add),
|
2007-01-26 18:26:52 +05:30
|
|
|
('Remove', gtk.STOCK_REMOVE, _("_Remove"), "<control>Delete",
|
2007-09-12 09:29:39 +05:30
|
|
|
self.DEL_MSG, self.remove),
|
2008-01-29 02:52:06 +05:30
|
|
|
('ExportTab', None, _('Export View...'), None, None, self.export),
|
2006-12-19 07:59:47 +05:30
|
|
|
])
|
|
|
|
|
2007-09-13 09:50:24 +05:30
|
|
|
self._add_action_group(self.edit_action)
|
2006-12-19 07:59:47 +05:30
|
|
|
|
2008-01-29 02:52:06 +05:30
|
|
|
self._add_action('Edit', gtk.STOCK_EDIT, _("action|_Edit..."),
|
2007-09-13 09:50:24 +05:30
|
|
|
accel="<control>Return",
|
|
|
|
tip=self.EDIT_MSG,
|
|
|
|
callback=self.edit)
|
2006-05-08 06:45:19 +05:30
|
|
|
|
2007-09-13 09:50:24 +05:30
|
|
|
self._add_toggle_action('Filter', None, _('_Filter'),
|
|
|
|
callback=self.filter_toggle_action)
|
2005-08-12 03:43:44 +05:30
|
|
|
|
2007-09-13 09:50:24 +05:30
|
|
|
def _column_editor(self, obj):
|
|
|
|
"""
|
|
|
|
Causes the View to display a column editor. This should be overridden
|
|
|
|
by any class that provides columns (such as a list based view)
|
|
|
|
"""
|
2007-09-17 00:15:57 +05:30
|
|
|
raise NotImplemented
|
2006-12-19 07:59:47 +05:30
|
|
|
|
2007-09-13 09:50:24 +05:30
|
|
|
def _button_press(self, obj, event):
|
2008-02-29 04:43:07 +05:30
|
|
|
if not self.dbstate.open:
|
|
|
|
return False
|
2007-08-31 01:19:04 +05:30
|
|
|
from QuickReports import create_quickreport_menu
|
2005-08-12 08:05:27 +05:30
|
|
|
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
2005-08-20 03:40:35 +05:30
|
|
|
self.edit(obj)
|
2005-08-12 08:05:27 +05:30
|
|
|
return True
|
|
|
|
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
|
|
|
menu = self.uistate.uimanager.get_widget('/Popup')
|
2007-08-31 01:19:04 +05:30
|
|
|
#construct quick reports if needed
|
2007-09-12 09:29:39 +05:30
|
|
|
if menu and self.QR_CATEGORY > -1 :
|
2007-08-31 01:19:04 +05:30
|
|
|
qr_menu = self.uistate.uimanager.\
|
|
|
|
get_widget('/Popup/QuickReport').get_submenu()
|
|
|
|
if qr_menu :
|
|
|
|
self.uistate.uimanager.\
|
|
|
|
get_widget('/Popup/QuickReport').remove_submenu()
|
|
|
|
reportactions = []
|
|
|
|
if menu and self.dbstate.active:
|
|
|
|
(ui, reportactions) = create_quickreport_menu(
|
2007-09-12 09:29:39 +05:30
|
|
|
self.QR_CATEGORY,
|
|
|
|
self.dbstate,
|
2007-12-21 11:52:46 +05:30
|
|
|
self.uistate,
|
2007-08-31 01:19:04 +05:30
|
|
|
self.first_selected())
|
|
|
|
if len(reportactions) > 1 :
|
|
|
|
qr_menu = gtk.Menu()
|
|
|
|
for action in reportactions[1:] :
|
|
|
|
Utils.add_menuitem(qr_menu, action[2], None, action[5])
|
|
|
|
self.uistate.uimanager.get_widget('/Popup/QuickReport').\
|
|
|
|
set_submenu(qr_menu)
|
2005-09-16 18:48:52 +05:30
|
|
|
if menu:
|
2007-08-31 01:19:04 +05:30
|
|
|
menu.popup(None, None, None, event.button, event.time)
|
2005-09-16 18:48:52 +05:30
|
|
|
return True
|
2007-08-31 01:19:04 +05:30
|
|
|
|
2005-08-12 08:05:27 +05:30
|
|
|
return False
|
|
|
|
|
2007-09-13 09:50:24 +05:30
|
|
|
def _key_press(self, obj, event):
|
2008-02-29 04:43:07 +05:30
|
|
|
if not self.dbstate.open:
|
|
|
|
return False
|
2007-09-12 09:29:39 +05:30
|
|
|
if not event.state or event.state in (gtk.gdk.MOD2_MASK, ):
|
2007-01-30 10:05:13 +05:30
|
|
|
if event.keyval in (gtk.keysyms.Return, gtk.keysyms.KP_Enter):
|
|
|
|
self.edit(obj)
|
|
|
|
return True
|
2005-08-12 03:43:44 +05:30
|
|
|
return False
|
|
|
|
|
2006-12-19 07:59:47 +05:30
|
|
|
def change_page(self):
|
2007-04-02 09:26:30 +05:30
|
|
|
if self.model:
|
2007-09-12 09:29:39 +05:30
|
|
|
self.uistate.show_filter_results(self.dbstate,
|
|
|
|
self.model.displayed,
|
2007-04-02 09:26:30 +05:30
|
|
|
self.model.total)
|
2006-12-19 07:59:47 +05:30
|
|
|
self.edit_action.set_sensitive(not self.dbstate.db.readonly)
|
2006-04-27 03:18:13 +05:30
|
|
|
|
2007-01-26 10:39:25 +05:30
|
|
|
def key_delete(self):
|
|
|
|
self.remove(None)
|
|
|
|
|
2007-02-06 10:49:16 +05:30
|
|
|
def export(self, obj):
|
|
|
|
chooser = gtk.FileChooserDialog(
|
2008-01-29 02:52:06 +05:30
|
|
|
_("Export View as Spreadsheet"),
|
2007-02-06 10:49:16 +05:30
|
|
|
self.uistate.window,
|
2007-09-12 09:29:39 +05:30
|
|
|
gtk.FILE_CHOOSER_ACTION_SAVE,
|
2007-02-06 10:49:16 +05:30
|
|
|
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
2008-01-16 19:01:35 +05:30
|
|
|
gtk.STOCK_SAVE, gtk.RESPONSE_OK))
|
2007-02-06 10:49:16 +05:30
|
|
|
chooser.set_do_overwrite_confirmation(True)
|
|
|
|
|
|
|
|
combobox = gtk.combo_box_new_text()
|
|
|
|
label = gtk.Label(_("Format:"))
|
|
|
|
label.set_alignment(1.0, 0.5)
|
|
|
|
box = gtk.HBox()
|
|
|
|
box.pack_start(label, True, True, padding=12)
|
|
|
|
box.pack_start(combobox, False, False)
|
|
|
|
combobox.append_text(_('CSV'))
|
2007-02-06 10:55:27 +05:30
|
|
|
combobox.append_text(_('Open Document Spreadsheet'))
|
2007-02-06 10:49:16 +05:30
|
|
|
combobox.set_active(0)
|
|
|
|
box.show_all()
|
|
|
|
chooser.set_extra_widget(box)
|
|
|
|
|
|
|
|
while True:
|
|
|
|
value = chooser.run()
|
|
|
|
fn = chooser.get_filename()
|
|
|
|
fl = combobox.get_active()
|
|
|
|
if value == gtk.RESPONSE_OK:
|
|
|
|
if fn:
|
|
|
|
chooser.destroy()
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
chooser.destroy()
|
|
|
|
return
|
|
|
|
self.write_tabbed_file(fn, fl)
|
|
|
|
|
|
|
|
def write_tabbed_file(self, name, type):
|
2008-02-19 01:37:09 +05:30
|
|
|
"""
|
|
|
|
Write a tabbed file to the specified name.
|
|
|
|
|
|
|
|
The output file type is determined by the type variable.
|
|
|
|
"""
|
|
|
|
from docgen import CSVTab, ODSTab
|
|
|
|
ofile = None
|
2007-02-06 10:49:16 +05:30
|
|
|
data_cols = [pair[1] for pair in self.column_order() if pair[0]]
|
|
|
|
|
|
|
|
column_names = [self.colinfo[i] for i in data_cols]
|
2008-02-19 01:37:09 +05:30
|
|
|
if type == 0:
|
|
|
|
ofile = CSVTab(len(column_names))
|
|
|
|
else:
|
|
|
|
ofile = ODSTab(len(column_names))
|
2007-02-06 10:49:16 +05:30
|
|
|
|
2008-02-19 01:37:09 +05:30
|
|
|
ofile.open(name)
|
|
|
|
ofile.start_page()
|
|
|
|
ofile.start_row()
|
2007-02-06 10:49:16 +05:30
|
|
|
for name in column_names:
|
2008-02-19 01:37:09 +05:30
|
|
|
ofile.write_cell(name)
|
|
|
|
ofile.end_row()
|
2007-02-06 10:49:16 +05:30
|
|
|
|
|
|
|
for row in self.model:
|
2008-02-19 01:37:09 +05:30
|
|
|
ofile.start_row()
|
2007-02-06 10:49:16 +05:30
|
|
|
for index in data_cols:
|
2008-02-19 01:37:09 +05:30
|
|
|
ofile.write_cell(row[index])
|
|
|
|
ofile.end_row()
|
|
|
|
ofile.end_page()
|
|
|
|
ofile.close()
|
2007-02-06 10:49:16 +05:30
|
|
|
|