* src/Filters/Rules/MediaObject: Added to replace Media.

* src/Filters/Rules/Media: Removed.
	* src/DataViews/_MediaView.py (filter_editor): Change Media to
	MediaObject.
	* src/Filters/_GenericFilter.py: Change Media to MediaObject.
	* src/DataViews/_PersonView.py (build_widget): Pass uistate
	to filter class.
	* src/PageView.py (ListView.build_filter_container): Pass uistate
	to filter class.
	* src/DisplayState.py (DisplayState.__signals__): Register
	'filters-changed' signal.
	* src/FilterEditor/_ShowResults.py: Change Media to MediaObject.
	* src/FilterEditor/_EditRule.py: Change Media to MediaObject.
	* src/FilterEditor/_FilterEditor.py (close): Emit 'filters-changed'.
	* src/Filters/SideBar/*py: Take uistate and connect to the
	'filters-changed' signal.


svn: r7233
This commit is contained in:
Alex Roitman 2006-08-22 16:49:21 +00:00
parent 00500b4fa6
commit 686a956248
28 changed files with 116 additions and 75 deletions

View File

@ -1,4 +1,20 @@
2006-08-22 Alex Roitman <shura@gramps-project.org>
* src/Filters/Rules/MediaObject: Added to replace Media.
* src/Filters/Rules/Media: Removed.
* src/DataViews/_MediaView.py (filter_editor): Change Media to
MediaObject.
* src/Filters/_GenericFilter.py: Change Media to MediaObject.
* src/DataViews/_PersonView.py (build_widget): Pass uistate
to filter class.
* src/PageView.py (ListView.build_filter_container): Pass uistate
to filter class.
* src/DisplayState.py (DisplayState.__signals__): Register
'filters-changed' signal.
* src/FilterEditor/_ShowResults.py: Change Media to MediaObject.
* src/FilterEditor/_EditRule.py: Change Media to MediaObject.
* src/FilterEditor/_FilterEditor.py (close): Emit 'filters-changed'.
* src/Filters/SideBar/*py: Take uistate and connect to the
'filters-changed' signal.
* src/glade/gramps.glade: Make MediaRef editor's General label bold.
2006-08-21 Alex Roitman <shura@gramps-project.org>

View File

@ -195,7 +195,7 @@ class MediaView(PageView.ListView):
from FilterEditor import FilterEditor
try:
FilterEditor('Media',const.custom_filters,
FilterEditor('MediaObject',const.custom_filters,
self.dbstate,self.uistate)
except Errors.WindowActiveError:
pass

View File

@ -267,7 +267,8 @@ class PersonView(PageView.PersonNavView):
self.selection.set_mode(gtk.SELECTION_MULTIPLE)
self.selection.connect('changed',self.row_changed)
self.filter_sidebar = PersonSidebarFilter(self.filter_clicked)
self.filter_sidebar = PersonSidebarFilter(self.uistate,
self.filter_clicked)
self.filter_pane = self.filter_sidebar.get_widget()
hpaned.pack_start(self.vbox, True, True)

View File

@ -248,6 +248,7 @@ class WarnHandler(RotateHandler):
class DisplayState(GrampsDb.GrampsDBCallback):
__signals__ = {
'filters-changed' : (str,),
}
def __init__(self, window, status, progress, warnbtn, uimanager):

View File

@ -226,7 +226,7 @@ class MyID(gtk.HBox):
'Event' : _('Event'),
'Place' : _('Place'),
'Source' : _('Source'),
'Media' : _('Media Object'),
'MediaObject' : _('Media Object'),
'Repository' : _('Repository'),
}
@ -254,10 +254,7 @@ class MyID(gtk.HBox):
self.set_text('')
def button_press(self,obj):
if self.namespace == 'Media':
obj_class = 'MediaObject'
else:
obj_class = self.namespace
obj_class = self.namespace
selector = selector_factory(obj_class)
inst = selector(self.dbstate, self.uistate, self.track)
val = inst.run()
@ -285,7 +282,7 @@ class MyID(gtk.HBox):
elif self.namespace == 'Source':
source = self.db.get_source_from_gramps_id(gramps_id)
name = source.get_title()
elif self.namespace == 'Media':
elif self.namespace == 'MediaObject':
obj = self.db.get_object_from_gramps_id(gramps_id)
name = obj.get_path()
elif self.namespace == 'Repository':
@ -383,8 +380,8 @@ class EditRule(ManagedWindow.ManagedWindow):
class_list = Rules.Source.editor_rule_list
elif self.space == 'Place':
class_list = Rules.Place.editor_rule_list
elif self.space == 'Media':
class_list = Rules.Media.editor_rule_list
elif self.space == 'MediaObject':
class_list = Rules.MediaObject.editor_rule_list
elif self.space == 'Repository':
class_list = Rules.Repository.editor_rule_list

View File

@ -127,6 +127,7 @@ class FilterEditor(ManagedWindow.ManagedWindow):
self.filterdb.save()
reload_custom_filters()
reload_system_filters()
self.uistate.emit('filters-changed',(self.space,))
ManagedWindow.ManagedWindow.close(self,obj)
def draw_filters(self):
@ -178,7 +179,7 @@ class FilterEditor(ManagedWindow.ManagedWindow):
return self.db.get_source_handles()
elif self.space == 'Place':
return self.db.get_place_handles()
elif self.space == 'Media':
elif self.space == 'MediaObject':
return self.db.get_media_object_handles()
elif self.space == 'Repository':
return self.db.get_repository_handles()

View File

@ -123,7 +123,7 @@ class ShowResults(ManagedWindow.ManagedWindow):
place = self.db.get_place_from_handle(handle)
name = place.get_title()
gid = place.get_gramps_id()
elif self.space == 'Media':
elif self.space == 'MediaObject':
obj = self.db.get_object_from_handle(handle)
name = obj.get_description()
gid = obj.get_gramps_id()
@ -150,7 +150,7 @@ class ShowResults(ManagedWindow.ManagedWindow):
elif self.space == 'Place':
name = self.db.get_place_from_handle(handle).get_title()
sortname = locale.strxfrm(name)
elif self.space == 'Media':
elif self.space == 'MediaObject':
name = self.db.get_object_from_handle(handle).get_description()
sortname = locale.strxfrm(name)
elif self.space == 'Repository':

View File

@ -41,5 +41,5 @@ import Family
import Event
import Source
import Place
import Media
import MediaObject
import Repository

View File

@ -54,8 +54,8 @@ GenericEventFilter = GenericFilterFactory('Event')
#-------------------------------------------------------------------------
class EventSidebarFilter(SidebarFilter):
def __init__(self, clicked):
SidebarFilter.__init__(self)
def __init__(self,uistate, clicked):
SidebarFilter.__init__(self,uistate)
self.clicked_func = clicked
def create_widget(self):
@ -76,16 +76,11 @@ class EventSidebarFilter(SidebarFilter):
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
all = GenericEventFilter()
all.set_name(_("None"))
all.add_rule(Rules.Event.AllEvents([]))
self.generic = gtk.ComboBox()
cell = gtk.CellRendererText()
self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0)
self.generic.set_model(build_filter_model('Event', [all]))
self.generic.set_active(0)
self.on_filters_changed('Event')
self.add_text_entry(_('ID'), self.filter_id)
self.add_text_entry(_('Description'), self.filter_desc)
@ -149,3 +144,11 @@ class EventSidebarFilter(SidebarFilter):
generic_filter.add_rule(rule)
return generic_filter
def on_filters_changed(self,name_space):
if name_space == 'Event':
all = GenericEventFilter()
all.set_name(_("None"))
all.add_rule(Rules.Event.AllEvents([]))
self.generic.set_model(build_filter_model('Event', [all]))
self.generic.set_active(0)

View File

@ -54,8 +54,8 @@ GenericFamilyFilter = GenericFilterFactory('Family')
#-------------------------------------------------------------------------
class FamilySidebarFilter(SidebarFilter):
def __init__(self, clicked):
SidebarFilter.__init__(self)
def __init__(self,uistate, clicked):
SidebarFilter.__init__(self,uistate)
self.clicked_func = clicked
def create_widget(self):
@ -86,16 +86,11 @@ class FamilySidebarFilter(SidebarFilter):
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
all = GenericFamilyFilter()
all.set_name(_("None"))
all.add_rule(Rules.Family.AllFamilies([]))
self.generic = gtk.ComboBox()
cell = gtk.CellRendererText()
self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0)
self.generic.set_model(build_filter_model('Family', [all]))
self.generic.set_active(0)
self.on_filters_changed('Family')
self.add_text_entry(_('ID'), self.filter_id)
self.add_text_entry(_('Father'), self.filter_father)
@ -180,3 +175,10 @@ class FamilySidebarFilter(SidebarFilter):
return generic_filter
def on_filters_changed(self,name_space):
if name_space == 'Family':
all = GenericFamilyFilter()
all.set_name(_("None"))
all.add_rule(Rules.Family.AllFamilies([]))
self.generic.set_model(build_filter_model('Family', [all]))
self.generic.set_active(0)

View File

@ -44,9 +44,9 @@ import RelLib
from _SidebarFilter import SidebarFilter
from Filters import GenericFilterFactory, build_filter_model, Rules
from Filters.Rules.Media import *
from Filters.Rules.MediaObject import *
GenericMediaFilter = GenericFilterFactory('Media')
GenericMediaFilter = GenericFilterFactory('MediaObject')
#-------------------------------------------------------------------------
#
# PersonSidebarFilter class
@ -54,8 +54,8 @@ GenericMediaFilter = GenericFilterFactory('Media')
#-------------------------------------------------------------------------
class MediaSidebarFilter(SidebarFilter):
def __init__(self, clicked):
SidebarFilter.__init__(self)
def __init__(self,uistate, clicked):
SidebarFilter.__init__(self,uistate)
self.clicked_func = clicked
def create_widget(self):
@ -69,16 +69,11 @@ class MediaSidebarFilter(SidebarFilter):
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
all = GenericMediaFilter()
all.set_name(_("None"))
all.add_rule(Rules.Media.AllMedia([]))
self.generic = gtk.ComboBox()
cell = gtk.CellRendererText()
self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0)
self.generic.set_model(build_filter_model('MediaObject', [all]))
self.generic.set_active(0)
self.on_filters_changed('MediaObject')
self.add_text_entry(_('ID'), self.filter_id)
self.add_text_entry(_('Title'), self.filter_title)
@ -142,3 +137,12 @@ class MediaSidebarFilter(SidebarFilter):
generic_filter.add_rule(rule)
return generic_filter
def on_filters_changed(self,name_space):
print name_space
if name_space == 'MediaObject':
all = GenericMediaFilter()
all.set_name(_("None"))
all.add_rule(Rules.MediaObject.AllMedia([]))
self.generic.set_model(build_filter_model('MediaObject', [all]))
self.generic.set_active(0)

View File

@ -53,8 +53,8 @@ from Filters import GenericFilter, build_filter_model, Rules
#-------------------------------------------------------------------------
class PersonSidebarFilter(SidebarFilter):
def __init__(self, clicked):
SidebarFilter.__init__(self)
def __init__(self,uistate,clicked):
SidebarFilter.__init__(self,uistate)
self.clicked_func = clicked
def create_widget(self):
@ -79,16 +79,11 @@ class PersonSidebarFilter(SidebarFilter):
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
all = GenericFilter()
all.set_name(_("None"))
all.add_rule(Rules.Person.Everyone([]))
self.generic = gtk.ComboBox()
cell = gtk.CellRendererText()
self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0)
self.generic.set_model(build_filter_model('Person', [all]))
self.generic.set_active(0)
self.on_filters_changed('Person')
self.add_text_entry(_('Name'), self.filter_name)
self.add_text_entry(_('ID'), self.filter_id)
@ -177,3 +172,10 @@ class PersonSidebarFilter(SidebarFilter):
return generic_filter
def on_filters_changed(self,name_space):
if name_space == 'Person':
all = GenericFilter()
all.set_name(_("None"))
all.add_rule(Rules.Person.Everyone([]))
self.generic.set_model(build_filter_model('Person', [all]))
self.generic.set_active(0)

View File

@ -54,8 +54,8 @@ GenericPlaceFilter = GenericFilterFactory('Place')
#-------------------------------------------------------------------------
class PlaceSidebarFilter(SidebarFilter):
def __init__(self, clicked):
SidebarFilter.__init__(self)
def __init__(self,uistate, clicked):
SidebarFilter.__init__(self,uistate)
self.clicked_func = clicked
def create_widget(self):
@ -72,16 +72,11 @@ class PlaceSidebarFilter(SidebarFilter):
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
all = GenericPlaceFilter()
all.set_name(_("None"))
all.add_rule(Rules.Place.AllPlaces([]))
self.generic = gtk.ComboBox()
cell = gtk.CellRendererText()
self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0)
self.generic.set_model(build_filter_model('Place', [all]))
self.generic.set_active(0)
self.on_filters_changed('Place')
self.add_text_entry(_('ID'), self.filter_id)
self.add_text_entry(_('Name'), self.filter_title)
@ -154,3 +149,11 @@ class PlaceSidebarFilter(SidebarFilter):
generic_filter.add_rule(rule)
return generic_filter
def on_filters_changed(self,name_space):
if name_space == 'Place':
all = GenericPlaceFilter()
all.set_name(_("None"))
all.add_rule(Rules.Place.AllPlaces([]))
self.generic.set_model(build_filter_model('Place', [all]))
self.generic.set_active(0)

View File

@ -54,8 +54,8 @@ GenericRepoFilter = GenericFilterFactory('Repository')
#-------------------------------------------------------------------------
class RepoSidebarFilter(SidebarFilter):
def __init__(self, clicked):
SidebarFilter.__init__(self)
def __init__(self,uistate, clicked):
SidebarFilter.__init__(self,uistate)
self.clicked_func = clicked
def create_widget(self):
@ -76,16 +76,11 @@ class RepoSidebarFilter(SidebarFilter):
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
all = GenericRepoFilter()
all.set_name(_("None"))
all.add_rule(Rules.Repository.AllRepos([]))
self.generic = gtk.ComboBox()
cell = gtk.CellRendererText()
self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0)
self.generic.set_model(build_filter_model('Repository', [all]))
self.generic.set_active(0)
self.on_filters_changed('Repository')
self.add_text_entry(_('ID'), self.filter_id)
self.add_text_entry(_('Name'), self.filter_title)
@ -149,3 +144,11 @@ class RepoSidebarFilter(SidebarFilter):
generic_filter.add_rule(rule)
return generic_filter
def on_filters_changed(self,name_space):
if name_space == 'Repository':
all = GenericRepoFilter()
all.set_name(_("None"))
all.add_rule(Rules.Repository.AllRepos([]))
self.generic.set_model(build_filter_model('Repository', [all]))
self.generic.set_active(0)

View File

@ -28,7 +28,7 @@ _RETURN = gtk.gdk.keyval_from_name("Return")
class SidebarFilter:
def __init__(self):
def __init__(self,uistate):
self.position = 1
self.table = gtk.Table(3,11)
self.table.set_border_width(6)
@ -36,6 +36,7 @@ class SidebarFilter:
self.table.set_col_spacing(0,6)
self.table.set_col_spacing(1,6)
self._init_interface()
uistate.connect('filters-changed',self.on_filters_changed)
def _init_interface(self):
self.table.attach(GrampsWidgets.MarkupLabel(_('<b>Filter</b>')),
@ -101,3 +102,7 @@ class SidebarFilter:
self.table.attach(widget, 2, 3, self.position, self.position+1,
xoptions=gtk.FILL, yoptions=0)
self.position += 1
def on_filters_changed(self,namespace):
pass

View File

@ -54,8 +54,8 @@ GenericSourceFilter = GenericFilterFactory('Source')
#-------------------------------------------------------------------------
class SourceSidebarFilter(SidebarFilter):
def __init__(self, clicked):
SidebarFilter.__init__(self)
def __init__(self,uistate, clicked):
SidebarFilter.__init__(self,uistate)
self.clicked_func = clicked
def create_widget(self):
@ -67,16 +67,11 @@ class SourceSidebarFilter(SidebarFilter):
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
all = GenericSourceFilter()
all.set_name(_("None"))
all.add_rule(Rules.Source.AllSources([]))
self.generic = gtk.ComboBox()
cell = gtk.CellRendererText()
self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0)
self.generic.set_model(build_filter_model('Source', [all]))
self.generic.set_active(0)
self.on_filters_changed('Source')
self.add_text_entry(_('ID'), self.filter_id)
self.add_text_entry(_('Title'), self.filter_title)
@ -136,3 +131,11 @@ class SourceSidebarFilter(SidebarFilter):
generic_filter.add_rule(rule)
return generic_filter
def on_filters_changed(self,name_space):
if name_space == 'Source':
all = GenericSourceFilter()
all.set_name(_("None"))
all.add_rule(Rules.Source.AllSources([]))
self.generic.set_model(build_filter_model('Source', [all]))
self.generic.set_active(0)

View File

@ -300,7 +300,7 @@ def GenericFilterFactory(namespace):
return GenericSourceFilter
elif namespace == 'Place':
return GenericPlaceFilter
elif namespace == 'Media':
elif namespace == 'MediaObject':
return GenericMediaFilter
elif namespace == 'Repository':
return GenericRepoFilter

View File

@ -464,7 +464,7 @@ class ListView(BookMarkView):
dbstate.connect('database-changed',self.change_db)
def build_filter_container(self, box, filter_class):
self.filter_sidebar = filter_class(self.filter_clicked)
self.filter_sidebar = filter_class(self.uistate,self.filter_clicked)
self.filter_pane = self.filter_sidebar.get_widget()
hpaned = gtk.HBox()