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
This commit is contained in:
Alex Roitman 2006-08-01 04:31:10 +00:00
parent ed76c8b5b1
commit 36d13d0bff
14 changed files with 82 additions and 171 deletions

View File

@ -1,3 +1,31 @@
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.
2006-07-31 Don Allingham <don@gramps-project.org>
* src/plugins/FindDupes.py: Fix title (bug 314)
* src/plugins/merge.glade: change button name (bug 315)

View File

@ -1,3 +1,6 @@
2006-07-31 Alex Roitman <shura@gramps-project.org>
* POTFILES.in: Remove obsolete file.
2006-07-30 Alex Roitman <shura@gramps-project.org>
* POTFILES.in: Add missing file.

View File

@ -370,7 +370,6 @@ src/Filters/_FilterList.py
src/Filters/_FilterMenu.py
src/Filters/_FilterParser.py
src/Filters/_FilterStore.py
src/Filters/_FilterWidget.py
src/Filters/_GenericFilter.py
src/Filters/__init__.py
src/Filters/_ParamFilter.py

View File

@ -220,8 +220,8 @@ class PersonView(PageView.PersonNavView):
self.vbox.set_border_width(4)
self.vbox.set_spacing(4)
self.search_bar = SearchBar(
self.uistate, self.build_tree, self.goto_active_person)
self.search_bar = SearchBar(self.dbstate, self.uistate,
self.build_tree, self.goto_active_person)
filter_box = self.search_bar.build()
self.tree = gtk.TreeView()
@ -417,7 +417,8 @@ class PersonView(PageView.PersonNavView):
self.tree.scroll_to_cell(path,None,1,0.5,0)
except KeyError:
self.selection.unselect_all()
self.uistate.push_message(_("Active person not visible"))
self.uistate.push_message(self.dbstate,
_("Active person not visible"))
self.dbstate.active = p
def setup_filter(self):
@ -635,7 +636,7 @@ class PersonView(PageView.PersonNavView):
self.tree.drag_source_set(BUTTON1_MASK,
[DdTargets.PERSON_LINK_LIST.target()],
ACTION_COPY)
self.uistate.modify_statusbar()
self.uistate.modify_statusbar(self.dbstate)
def drag_data_get(self, widget, context, sel_data, info, time):
selected_ids = self.get_selected_objects()
@ -766,8 +767,10 @@ class PersonView(PageView.PersonNavView):
def key_goto_home_person(self):
self.home(None)
self.uistate.push_message(_("Go to default person"))
self.uistate.push_message(self.dbstate,
_("Go to default person"))
def key_edit_selected_person(self):
self.edit(None)
self.uistate.push_message(_("Edit selected person"))
self.uistate.push_message(self.dbstate,
_("Edit selected person"))

View File

@ -104,7 +104,7 @@ class RelationshipView(PageView.PersonNavView):
def shade_update(self, client, cnxn_id, entry, data):
self.use_shade = Config.get(Config.RELATION_SHADE)
self.uistate.modify_statusbar()
self.uistate.modify_statusbar(self.dbstate)
self.redraw()
def build_tree(self):

View File

@ -250,9 +250,8 @@ class DisplayState(GrampsDb.GrampsDBCallback):
__signals__ = {
}
def __init__(self, window, status, progress, warnbtn, uimanager, dbstate):
def __init__(self, window, status, progress, warnbtn, uimanager):
self.dbstate = dbstate
self.uimanager = uimanager
self.window = window
GrampsDb.GrampsDBCallback.__init__(self)
@ -270,15 +269,17 @@ class DisplayState(GrampsDb.GrampsDBCallback):
self.log = logging.getLogger()
self.log.setLevel(logging.WARN)
self.log.addHandler(self.rh)
self.dbstate.connect('database-changed', self.db_changed)
# This call has been moved one level up,
# but this connection is still made!
# self.dbstate.connect('database-changed', self.db_changed)
def db_changed(self, db):
from PluginUtils import _PluginMgr
self.relationship = _PluginMgr.relationship_class(db)
def display_relationship(self):
default_person = self.dbstate.db.get_default_person()
active = self.dbstate.get_active_person()
def display_relationship(self,dbstate):
default_person = dbstate.db.get_default_person()
active = dbstate.get_active_person()
if default_person == None or active == None:
return u''
@ -311,22 +312,22 @@ class DisplayState(GrampsDb.GrampsDBCallback):
def set_open_recent_menu(self,menu):
self.widget.set_menu(menu)
def push_message(self, text):
def push_message(self, dbstate, text):
self.status_text(text)
gobject.timeout_add(5000,self.modify_statusbar)
gobject.timeout_add(5000,self.modify_statusbar,dbstate)
def modify_statusbar(self,active=None):
def modify_statusbar(self,dbstate,active=None):
self.status.pop(self.status_id)
if self.dbstate.active == None:
if dbstate.active == None:
self.status.push(self.status_id,"")
else:
person = self.dbstate.get_active_person()
person = dbstate.get_active_person()
if person:
pname = NameDisplay.displayer.display(person)
name = "[%s] %s" % (person.get_gramps_id(),pname)
if Config.get(Config.STATUSBAR) > 1:
if person.handle != self.dbstate.db.get_default_handle():
msg = self.display_relationship()
if person.handle != dbstate.db.get_default_handle():
msg = self.display_relationship(dbstate)
if msg:
name = "%s (%s)" % (name,msg.strip())
else:

View File

@ -11,7 +11,6 @@ pkgdata_PYTHON = \
_FilterMenu.py \
_FilterParser.py \
_FilterStore.py \
_FilterWidget.py \
_GenericFilter.py \
_ParamFilter.py \
__init__.py \

View File

@ -1,129 +0,0 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2002-2006 Donald N. Allingham
#
# 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
#
# $Id$
"""
Package providing filtering framework for GRAMPS.
"""
#-------------------------------------------------------------------------
#
# GTK
#
#-------------------------------------------------------------------------
import gtk
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _GenericFilter import GenericFilter
from _FilterStore import FilterStore
#-------------------------------------------------------------------------
#
# FilterWidget
#
#-------------------------------------------------------------------------
class FilterWidget:
def __init__( self, uistate, on_apply, apply_done = None):
self.on_apply_callback = on_apply
self.apply_done_callback = apply_done
self.uistate = uistate
def build( self):
self.filterbar = gtk.HBox()
self.filterbar.set_spacing(4)
self.filter_text = gtk.Entry()
self.filter_list = gtk.ComboBox()
self.filter_button = gtk.Button(stock=gtk.STOCK_FIND)
self.filter_button.connect( 'clicked',self.apply_filter_clicked)
self.filterbar.pack_start(self.filter_list,False)
self.filterbar.pack_start(self.filter_text,True)
self.filterbar.pack_end(self.filter_button,False)
# self.filter_text.set_sensitive(False)
return self.filterbar
def setup_filter( self, default_filters, namespace="generic"):
cell = gtk.CellRendererText()
self.filter_list.clear()
self.filter_list.pack_start(cell,True)
self.filter_list.add_attribute(cell,'text',0)
filter_list = []
for f in default_filters:
all = GenericFilter()
rule = f[0](f[1])
#print rule
all.set_name( rule.name)
all.add_rule( rule)
filter_list.append(all)
self.filter_model = FilterStore(filter_list, namespace)
self.filter_list.set_model(self.filter_model)
self.filter_list.set_active(self.filter_model.default_index())
self.filter_list.connect('changed',self.on_filter_name_changed)
# self.filter_text.set_sensitive(False)
self.DataFilter = filter_list[self.filter_model.default_index()]
def apply_filter_clicked(self,ev=None):
print "apply_filter_clicked"
index = self.filter_list.get_active()
self.DataFilter = self.filter_model.get_filter(index)
if self.DataFilter.need_param:
qual = unicode(self.filter_text.get_text())
self.DataFilter.set_parameter(qual)
self.apply_filter()
if self.apply_done_callback:
self.apply_done_callback()
def on_filter_name_changed(self,obj):
pass
# index = self.filter_list.get_active()
# mime_filter = self.filter_model.get_filter(index)
# qual = mime_filter.need_param
# if qual:
# self.filter_text.show()
# self.filter_text.set_sensitive(True)
# else:
# self.filter_text.hide()
# self.filter_text.set_sensitive(False)
def apply_filter(self,current_model=None):
self.uistate.status_text(_('Updating display...'))
self.on_apply_callback()
self.uistate.modify_statusbar()
def get_filter( self):
print "get_filter"
#print self.DataFilter.flist[0]
return self.DataFilter
def show( self):
self.filterbar.show()
def hide( self):
self.filterbar.hide()

View File

@ -18,7 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id:$
# $Id$
"""
Package providing filtering framework for GRAMPS.
@ -40,9 +40,10 @@ _RETURN = gtk.gdk.keyval_from_name("Return")
#
#-------------------------------------------------------------------------
class SearchBar:
def __init__( self, uistate, on_apply, apply_done = None):
def __init__( self, dbstate, uistate, on_apply, apply_done = None):
self.on_apply_callback = on_apply
self.apply_done_callback = apply_done
self.dbstate = dbstate
self.uistate = uistate
self.apply_text = ''
@ -138,7 +139,7 @@ class SearchBar:
self.filter_button.set_sensitive(False)
self.uistate.status_text(_('Updating display...'))
self.on_apply_callback()
self.uistate.modify_statusbar()
self.uistate.modify_statusbar(self.dbstate)
def show(self):
self.filterbar.show()

View File

@ -50,7 +50,6 @@ if not SystemFilters:
if not CustomFilters:
reload_custom_filters()
from _FilterWidget import FilterWidget
from _FilterComboBox import FilterComboBox
from _FilterMenu import build_filter_menu, build_filter_model
from _FilterStore import FilterStore

View File

@ -75,9 +75,10 @@ class BaseNavigation:
self.func - array of functions to take action based off of.
"""
def __init__(self, uistate, history, title):
def __init__(self, dbstate, uistate, history, title):
self.title = title
self.ui = "".join(_top) + "".join(_btm)
self.dbstate = dbstate
self.uistate = uistate
self.action_group = gtk.ActionGroup(self.title)
self.active = DISABLED
@ -148,14 +149,15 @@ class PersonNavigation(BaseNavigation):
"""
Builds a navigation item for the Person class.
"""
def __init__(self, uistate):
def __init__(self, dbstate, uistate):
"""
Associates the functions with the associated items. Builds the function
array so that there are unique functions for each possible index (0-9)
The callback simply calls change_active_handle
"""
BaseNavigation.__init__(self, uistate, uistate.phistory, 'PersonHistory')
fcn_ptr = self.uistate.dbstate.change_active_handle
BaseNavigation.__init__(self, dbstate, uistate,
uistate.phistory, 'PersonHistory')
fcn_ptr = self.dbstate.change_active_handle
self.func = [ generate(fcn_ptr, self.items, index) \
for index in range(0, 10) ]
@ -164,7 +166,7 @@ class PersonNavigation(BaseNavigation):
"""
Builds a name in the format of 'NAME [GRAMPSID]'
"""
person = self.uistate.dbstate.db.get_person_from_handle(item)
person = self.dbstate.db.get_person_from_handle(item)
return "%s [%s]" % (NameDisplay.displayer.display(person),
person.gramps_id)

View File

@ -218,7 +218,8 @@ class BookMarkView(PageView):
if self.dbstate.active:
self.bookmarks.add(self.dbstate.active.get_handle())
name = NameDisplay.displayer.display(self.dbstate.active)
self.uistate.push_message(_("%s has been bookmarked") % name)
self.uistate.push_message(self.dbstate,
_("%s has been bookmarked") % name)
else:
from QuestionDialog import WarningDialog
WarningDialog(
@ -362,6 +363,7 @@ class PersonNavView(BookMarkView):
self.dbstate.change_active_person(person)
else:
self.uistate.push_message(
self.dbstate,
_("Error: %s is not a valid GRAMPS ID") % gid)
dialog.destroy()
@ -381,7 +383,7 @@ class PersonNavView(BookMarkView):
try:
handle = hobj.forward()
self.dbstate.change_active_handle(handle)
self.uistate.modify_statusbar()
self.uistate.modify_statusbar(self.dbstate)
hobj.mhistory.append(hobj.history[hobj.index])
self.fwd_action.set_sensitive(not hobj.at_end())
self.back_action.set_sensitive(True)
@ -401,7 +403,7 @@ class PersonNavView(BookMarkView):
try:
handle = hobj.back()
self.active = self.dbstate.db.get_person_from_handle(handle)
self.uistate.modify_statusbar()
self.uistate.modify_statusbar(self.dbstate)
self.dbstate.change_active_handle(handle)
hobj.mhistory.append(hobj.history[hobj.index])
self.back_action.set_sensitive(not hobj.at_front())
@ -516,7 +518,7 @@ class ListView(BookMarkView):
self.vbox.set_border_width(4)
self.vbox.set_spacing(4)
self.search_bar = SearchBar(self.uistate, self.build_tree)
self.search_bar = SearchBar(self.dbstate,self.uistate, self.build_tree)
filter_box = self.search_bar.build()
self.list = gtk.TreeView()

View File

@ -252,7 +252,8 @@ class ViewManager:
self.uistate = DisplayState.DisplayState(
self.window, self.statusbar, self.progress, self.warnbtn,
self.uimanager, self.state)
self.uimanager)
self.state.connect('database-changed', self.uistate.db_changed)
toolbar = self.uimanager.get_widget('/ToolBar')
openbtn = gtk.MenuToolButton(gtk.STOCK_OPEN)
@ -273,7 +274,7 @@ class ViewManager:
)
openbtn.show()
self.person_nav = Navigation.PersonNavigation(self.uistate)
self.person_nav = Navigation.PersonNavigation(self.state,self.uistate)
self._navigation_type[PageView.NAVIGATION_PERSON] = (self.person_nav,
None)
self.recent_manager = DisplayState.RecentDocsMenu(
@ -404,7 +405,8 @@ class ViewManager:
try:
self.active_page.call_function(name)
except:
self.uistate.push_message(_("Key %s is not bound") % name)
self.uistate.push_message(self.state,
_("Key %s is not bound") % name)
def init_interface(self):
self._init_lists()
@ -421,7 +423,7 @@ class ViewManager:
self.statusbar_key_update)
def statusbar_key_update(self,client,cnxn_id,entry,data):
self.uistate.modify_statusbar()
self.uistate.modify_statusbar(self.state)
def post_init_interface(self):
# Showing the main window is deferred so that
@ -444,7 +446,7 @@ class ViewManager:
old_win.close()
PluginStatus.PluginStatus(self.state,self.uistate, [])
self.uistate.push_message(_('Ready'))
self.uistate.push_message(self.state,_('Ready'))
def quit(self, obj=None):
self.state.db.close()
@ -864,7 +866,8 @@ class ViewManager:
if self.state.active:
self.bookmarks.add(self.state.active.get_handle())
name = NameDisplay.displayer.display(self.state.active)
self.uistate.push_message(_("%s has been bookmarked") % name)
self.uistate.push_message(self.state,
_("%s has been bookmarked") % name)
else:
QuestionDialog.WarningDialog(
_("Could Not Set a Bookmark"),

View File

@ -226,7 +226,7 @@ class Checkpoint(Tool.Tool, ManagedWindow.ManagedWindow):
self.uistate.window.window.set_cursor(None)
self.window.window.set_cursor(None)
self.uistate.pulse_progressbar(0)
self.uistate.modify_statusbar()
self.uistate.modify_statusbar(self.dbstate)
def timestamp(self):
return unicode(time.strftime('%x %X',time.localtime(time.time())))