Remove column config from db, move to the plugins

Start with reuse of preferences for all configuration
Allow all view plugins to set configuration dialog
TODO: activate the column reorder in config of listviews


svn: r14176
This commit is contained in:
Benny Malengier 2010-02-01 07:01:45 +00:00
parent f0cfe6c5e9
commit a89e8d1d18
27 changed files with 538 additions and 881 deletions

View File

@ -7,7 +7,6 @@ src/ansel_utf8.py
src/Assistant.py src/Assistant.py
src/AutoComp.py src/AutoComp.py
src/Bookmarks.py src/Bookmarks.py
src/ColumnOrder.py
src/const.py src/const.py
src/DateEdit.py src/DateEdit.py
src/Date.py src/Date.py
@ -18,7 +17,6 @@ src/ExportAssistant.py
src/ExportOptions.py src/ExportOptions.py
src/glade.py src/glade.py
src/GrampsAboutDialog.py src/GrampsAboutDialog.py
src/GrampsCfg.py
src/GrampsDisplay.py src/GrampsDisplay.py
src/gramps.py src/gramps.py
src/ImgManip.py src/ImgManip.py
@ -187,6 +185,8 @@ src/gen/utils/callman.py
# gui - GUI code # gui - GUI code
src/gui/__init__.py src/gui/__init__.py
src/gui/columnorder.py
src/gui/configure.py
src/gui/dbguielement.py src/gui/dbguielement.py
src/gui/dbloader.py src/gui/dbloader.py
src/gui/dbman.py src/gui/dbman.py
@ -842,7 +842,7 @@ src/glade/displaystate.glade
src/glade/addmedia.glade src/glade/addmedia.glade
src/glade/questiondialog.glade src/glade/questiondialog.glade
src/glade/columnorder.glade src/glade/columnorder.glade
src/glade/grampscfg.glade src/glade/configure.glade
src/glade/dateedit.glade src/glade/dateedit.glade
src/glade/editsource.glade src/glade/editsource.glade
src/glade/styleeditor.glade src/glade/styleeditor.glade

View File

@ -26,8 +26,7 @@ gdir_PYTHON = \
Assistant.py\ Assistant.py\
AutoComp.py\ AutoComp.py\
Bookmarks.py\ Bookmarks.py\
ColumnOrder.py\ config.py\
config.py\
const.py\ const.py\
DateEdit.py\ DateEdit.py\
Date.py\ Date.py\
@ -39,7 +38,6 @@ gdir_PYTHON = \
ExportOptions.py\ ExportOptions.py\
glade.py\ glade.py\
GrampsAboutDialog.py\ GrampsAboutDialog.py\
GrampsCfg.py\
GrampsDisplay.py\ GrampsDisplay.py\
gramps.py\ gramps.py\
ImgManip.py\ ImgManip.py\

View File

@ -285,31 +285,6 @@ register('preferences.sprefix', 'S%04d')
register('preferences.todo-color', '#ff0000') register('preferences.todo-color', '#ff0000')
register('preferences.use-last-view', True) register('preferences.use-last-view', True)
register('person-view.columns', [(1, 0, 250), (1, 1, 50), (1, 2, 75),
(1, 3, 100), (1, 4, 175), (1, 5, 100),
(1, 6, 175), (1, 7, 100), (0, 8, 100)])
register('child-view.columns', [(1, 0), (1, 1), (1, 2), (1, 3), (1, 4),
(1, 5), (0, 6), (0, 7)])
register('place-view.columns', [(1, 0, 250), (1, 1, 75), (1, 11, 100),
(0, 3, 100), (1, 4, 100, ), (0, 5, 150),
(1, 6, 150), (0, 7, 150), (0, 8, 150),
(0, 9, 150), (0, 10, 150),(0,2,100)])
register('source-view.columns', [(1, 0, 200), (1, 1, 75), (1, 2, 150),
(0, 3, 100), (1, 4, 150), (0, 5, 100)])
register('media-view.columns', [(1, 0, 200, ), (1, 1, 75), (1, 2, 100),
(1, 3, 200), (1, 5, 150), (0, 4, 150)])
register('repository-view.columns', [(1, 0, 200), (1, 1, 75), (0, 5, 100),
(0, 6, 100), (1, 2, 100), (1, 3, 250),
(1, 4, 100), (0, 7, 100), (0, 8, 100),
(0, 9, 100), (0, 10, 100), (0, 12, 100)])
register('event-view.columns', [(1, 0, 200), (1, 1, 75), (1, 2, 100),
(0, 6, 230), (1, 3, 150),
(1, 4, 200), (0, 5, 100)])
register('family-view.columns', [(1, 0, 75), (1, 1, 200), (1, 2, 200),
(1, 3, 100), (0, 4, 100)])
register('note-view.columns', [(1, 0, 350), (1, 1, 75), (1, 2, 100),
(1, 3, 100)])
register('researcher.researcher-addr', '') register('researcher.researcher-addr', '')
register('researcher.researcher-city', '') register('researcher.researcher-city', '')
register('researcher.researcher-country', '') register('researcher.researcher-country', '')

View File

@ -195,13 +195,6 @@ class DbReadBase(object):
""" """
raise NotImplementedError raise NotImplementedError
def get_event_column_order(self):
"""
Return the Event display common information stored in the database's
metadata.
"""
raise NotImplementedError
def get_event_cursor(self): def get_event_cursor(self):
""" """
Return a reference to a cursor over Family objects Return a reference to a cursor over Family objects
@ -289,13 +282,6 @@ class DbReadBase(object):
""" """
raise NotImplementedError raise NotImplementedError
def get_family_list_column_order(self):
"""
Return the Person display common information stored in the database's
metadata.
"""
raise NotImplementedError
def get_family_relation_types(self): def get_family_relation_types(self):
""" """
Return a list of all relationship types associated with Family Return a list of all relationship types associated with Family
@ -334,13 +320,6 @@ class DbReadBase(object):
""" """
raise NotImplementedError raise NotImplementedError
def get_media_column_order(self):
"""
Return the MediaObject display common information stored in the
database's metadata.
"""
raise NotImplementedError
def get_media_cursor(self): def get_media_cursor(self):
""" """
Return a reference to a cursor over Media objects Return a reference to a cursor over Media objects
@ -387,13 +366,6 @@ class DbReadBase(object):
""" """
raise NotImplementedError raise NotImplementedError
def get_note_column_order(self):
"""
Return the Note display common information stored in the database's
metadata.
"""
raise NotImplementedError
def get_note_cursor(self): def get_note_cursor(self):
""" """
Return a reference to a cursor over Note objects Return a reference to a cursor over Note objects
@ -503,13 +475,6 @@ class DbReadBase(object):
""" """
raise NotImplementedError raise NotImplementedError
def get_person_column_order(self):
"""
Return the Person display common information stored in the database's
metadata.
"""
raise NotImplementedError
def get_person_cursor(self): def get_person_cursor(self):
""" """
Return a reference to a cursor over Person objects Return a reference to a cursor over Person objects
@ -555,13 +520,6 @@ class DbReadBase(object):
""" """
raise NotImplementedError raise NotImplementedError
def get_place_column_order(self):
"""
Return the Place display common information stored in thedatabase's
metadata.
"""
raise NotImplementedError
def get_place_cursor(self): def get_place_cursor(self):
""" """
Return a reference to a cursor over Place objects Return a reference to a cursor over Place objects
@ -666,13 +624,6 @@ class DbReadBase(object):
""" """
raise NotImplementedError raise NotImplementedError
def get_repository_column_order(self):
"""
Return the Repository display common information stored in the
database's metadata.
"""
raise NotImplementedError
def get_repository_cursor(self): def get_repository_cursor(self):
""" """
Return a reference to a cursor over Repository objects Return a reference to a cursor over Repository objects
@ -729,13 +680,6 @@ class DbReadBase(object):
""" """
raise NotImplementedError raise NotImplementedError
def get_source_column_order(self):
"""
Return the Source display common information stored in the database's
metadata.
"""
raise NotImplementedError
def get_source_cursor(self): def get_source_cursor(self):
""" """
Return a reference to a cursor over Source objects Return a reference to a cursor over Source objects
@ -1072,74 +1016,6 @@ class DbReadBase(object):
""" """
raise NotImplementedError raise NotImplementedError
def get_child_column_order(self):
"""
Return the Person display common information stored in the database's
metadata.
"""
raise NotImplementedError
def set_child_column_order(self, col_list):
"""
Store the Person display common information in the database's metadata.
"""
raise NotImplementedError
def set_column_order(self, col_list, name):
"""
Store the display information in the database's metadata.
"""
raise NotImplementedError
def set_event_column_order(self, col_list):
"""
Store the Event display common information in the database's metadata.
"""
raise NotImplementedError
def set_family_list_column_order(self, col_list):
"""
Store the Person display common information in the database's metadata.
"""
raise NotImplementedError
def set_media_column_order(self, col_list):
"""
Store the Media display common information in the database's metadata.
"""
raise NotImplementedError
def set_note_column_order(self, col_list):
"""
Store the Note display common information in the database's metadata.
"""
raise NotImplementedError
def set_person_column_order(self, col_list):
"""
Store the Person display common information in the database's metadata.
"""
raise NotImplementedError
def set_place_column_order(self, col_list):
"""
Store the Place display common information in the database's metadata.
"""
raise NotImplementedError
def set_repository_column_order(self, col_list):
"""
Store the Repository display common information in the database's
metadata.
"""
raise NotImplementedError
def set_source_column_order(self, col_list):
"""
Store the Source display common information in the database's metadata.
"""
raise NotImplementedError
def set_mediapath(self, path): def set_mediapath(self, path):
""" """
Set the default media path for database, path should be utf-8. Set the default media path for database, path should be utf-8.

View File

@ -43,13 +43,7 @@ __all__ = (
('PERSON_KEY', 'FAMILY_KEY', 'SOURCE_KEY', 'EVENT_KEY', ('PERSON_KEY', 'FAMILY_KEY', 'SOURCE_KEY', 'EVENT_KEY',
'MEDIA_KEY', 'PLACE_KEY', 'REPOSITORY_KEY', 'NOTE_KEY', 'MEDIA_KEY', 'PLACE_KEY', 'REPOSITORY_KEY', 'NOTE_KEY',
'REFERENCE_KEY', 'PERSON_COL_KEY', 'FAMILY_COL_KEY', 'REFERENCE_KEY'
'CHILD_COL_KEY'
) +
('PERSON_COL_KEY', 'FAMILY_COL_KEY', 'CHILD_COL_KEY',
'PLACE_COL_KEY', 'SOURCE_COL_KEY', 'MEDIA_COL_KEY',
'EVENT_COL_KEY', 'REPOSITORY_COL_KEY', 'NOTE_COL_KEY'
) + ) +
('TXNADD', 'TXNUPD', 'TXNDEL') ('TXNADD', 'TXNUPD', 'TXNDEL')
@ -84,14 +78,4 @@ REPOSITORY_KEY = 6
REFERENCE_KEY = 7 REFERENCE_KEY = 7
NOTE_KEY = 8 NOTE_KEY = 8
PERSON_COL_KEY = 'person-view.columns'
CHILD_COL_KEY = 'child-view.columns'
PLACE_COL_KEY = 'place-view.columns'
SOURCE_COL_KEY = 'source-view.columns'
MEDIA_COL_KEY = 'media-view.columns'
REPOSITORY_COL_KEY = 'repository-view.columns'
EVENT_COL_KEY = 'event-view.columns'
FAMILY_COL_KEY = 'family-view.columns'
NOTE_COL_KEY = 'note-view.columns'
TXNADD, TXNUPD, TXNDEL = 0, 1, 2 TXNADD, TXNUPD, TXNDEL = 0, 1, 2

View File

@ -52,7 +52,6 @@ from gen.utils.callback import Callback
from gen.db import (GrampsCursor, DbReadBase) from gen.db import (GrampsCursor, DbReadBase)
from Utils import create_id from Utils import create_id
import Errors import Errors
import config
LOG = logging.getLogger(DBLOGNAME) LOG = logging.getLogger(DBLOGNAME)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -157,16 +156,8 @@ class DbBsddbRead(DbReadBase, Callback):
returns a list of all Event types assocated with instances of <object> returns a list of all Event types assocated with instances of <object>
in the database. in the database.
.. method:: get_<object>_column_order()
returns the object's display common information.
""" """
# This holds a reference to the gramps Config module if
# it is available, it is setup by the factory methods.
__config__ = None
__signals__ = {} __signals__ = {}
# If this is True logging will be turned on. # If this is True logging will be turned on.
try: try:
@ -1369,150 +1360,6 @@ class DbBsddbRead(DbReadBase, Callback):
return self.metadata.get('mediapath', None) return self.metadata.get('mediapath', None)
return None return None
def set_column_order(self, col_list, name):
if (self.metadata is not None) and (not self.readonly):
self.metadata[name] = col_list
def set_person_column_order(self, col_list):
"""
Store the Person display common information in the database's metadata.
"""
self.set_column_order(col_list, PERSON_COL_KEY)
def set_family_list_column_order(self, col_list):
"""
Store the Person display common information in the database's metadata.
"""
self.set_column_order(col_list, FAMILY_COL_KEY)
def set_child_column_order(self, col_list):
"""
Store the Person display common information in the database's metadata.
"""
self.set_column_order(col_list, CHILD_COL_KEY)
def set_place_column_order(self, col_list):
"""
Store the Place display common information in the database's metadata.
"""
self.set_column_order(col_list, PLACE_COL_KEY)
def set_source_column_order(self, col_list):
"""
Store the Source display common information in the database's metadata.
"""
self.set_column_order(col_list, SOURCE_COL_KEY)
def set_media_column_order(self, col_list):
"""
Store the Media display common information in the database's metadata.
"""
self.set_column_order(col_list, MEDIA_COL_KEY)
def set_event_column_order(self, col_list):
"""
Store the Event display common information in the database's metadata.
"""
self.set_column_order(col_list, EVENT_COL_KEY)
def set_repository_column_order(self, col_list):
"""
Store the Repository display common information in the database's
metadata.
"""
self.set_column_order(col_list, REPOSITORY_COL_KEY)
def set_note_column_order(self, col_list):
"""
Store the Note display common information in the database's metadata.
"""
self.set_column_order(col_list, NOTE_COL_KEY)
def __get_column_order(self, name):
default = config.get_default(name)
cols = config.get(name)
if len(cols) != len(default):
return cols + default[len(cols):]
else:
return cols
def get_person_column_order(self):
"""
Return the Person display common information stored in the database's
metadata.
"""
return self.__get_column_order(PERSON_COL_KEY)
def __get_columns(self, key):
default = config.get_default(key)
values = self.__get_column_order(key)
new = []
for val in values:
if len(val) == 2:
for x in default:
if val[1] == x[1]:
new.append((val[0], val[1], x[2]))
break
else:
new.append(val)
return new
def get_family_list_column_order(self):
"""
Return the Person display common information stored in the database's
metadata.
"""
return self.__get_columns(FAMILY_COL_KEY)
def get_child_column_order(self):
"""
Return the Person display common information stored in the database's
metadata.
"""
return self.__get_column_order(CHILD_COL_KEY)
def get_place_column_order(self):
"""
Return the Place display common information stored in thedatabase's
metadata.
"""
return self.__get_columns(PLACE_COL_KEY)
def get_source_column_order(self):
"""
Return the Source display common information stored in the database's
metadata.
"""
return self.__get_columns(SOURCE_COL_KEY)
def get_media_column_order(self):
"""
Return the MediaObject display common information stored in the
database's metadata.
"""
return self.__get_columns(MEDIA_COL_KEY)
def get_event_column_order(self):
"""
Return the Event display common information stored in the database's
metadata.
"""
return self.__get_columns(EVENT_COL_KEY)
def get_repository_column_order(self):
"""
Return the Repository display common information stored in the
database's metadata.
"""
return self.__get_columns(REPOSITORY_COL_KEY)
def get_note_column_order(self):
"""
Return the Note display common information stored in the database's
metadata.
"""
return self.__get_columns(NOTE_COL_KEY)
def find_backlink_handles(self, handle, include_classes=None): def find_backlink_handles(self, handle, include_classes=None):
""" """
Find all objects that hold a reference to the object handle. Find all objects that hold a reference to the object handle.

View File

@ -20,12 +20,10 @@ class DbTest(object):
"find_next_repository_gramps_id", "find_next_repository_gramps_id",
"find_next_source_gramps_id", "find_next_source_gramps_id",
"get_bookmarks", "get_bookmarks",
"get_child_column_order",
"get_child_reference_types", "get_child_reference_types",
"get_default_handle", "get_default_handle",
"get_default_person", "get_default_person",
"get_event_bookmarks", "get_event_bookmarks",
"get_event_column_order",
"get_event_cursor", "get_event_cursor",
"get_event_from_gramps_id", "get_event_from_gramps_id",
"get_event_from_handle", "get_event_from_handle",
@ -38,14 +36,12 @@ class DbTest(object):
"get_family_from_gramps_id", "get_family_from_gramps_id",
"get_family_from_handle", "get_family_from_handle",
"get_family_handles", "get_family_handles",
"get_family_list_column_order",
"get_family_relation_types", "get_family_relation_types",
"get_from_handle", "get_from_handle",
"get_gramps_ids", "get_gramps_ids",
"get_marker_types", "get_marker_types",
"get_media_attribute_types", "get_media_attribute_types",
"get_media_bookmarks", "get_media_bookmarks",
"get_media_column_order",
"get_media_cursor", "get_media_cursor",
"get_media_object_handles", "get_media_object_handles",
"get_mediapath", "get_mediapath",
@ -53,7 +49,6 @@ class DbTest(object):
"get_name_group_mapping", "get_name_group_mapping",
"get_name_types", "get_name_types",
"get_note_bookmarks", "get_note_bookmarks",
"get_note_column_order",
"get_note_cursor", "get_note_cursor",
"get_note_from_gramps_id", "get_note_from_gramps_id",
"get_note_from_handle", "get_note_from_handle",
@ -70,14 +65,12 @@ class DbTest(object):
"get_object_from_gramps_id", "get_object_from_gramps_id",
"get_object_from_handle", "get_object_from_handle",
"get_person_attribute_types", "get_person_attribute_types",
"get_person_column_order",
"get_person_cursor", "get_person_cursor",
"get_person_event_types", "get_person_event_types",
"get_person_from_gramps_id", "get_person_from_gramps_id",
"get_person_from_handle", "get_person_from_handle",
"get_person_handles", "get_person_handles",
"get_place_bookmarks", "get_place_bookmarks",
"get_place_column_order",
"get_place_cursor", "get_place_cursor",
"get_place_from_gramps_id", "get_place_from_gramps_id",
"get_place_from_handle", "get_place_from_handle",
@ -94,7 +87,6 @@ class DbTest(object):
"get_reference_map_primary_cursor", "get_reference_map_primary_cursor",
"get_reference_map_referenced_cursor", "get_reference_map_referenced_cursor",
"get_repo_bookmarks", "get_repo_bookmarks",
"get_repository_column_order",
"get_repository_cursor", "get_repository_cursor",
"get_repository_from_gramps_id", "get_repository_from_gramps_id",
"get_repository_from_handle", "get_repository_from_handle",
@ -103,7 +95,6 @@ class DbTest(object):
"get_researcher", "get_researcher",
"get_save_path", "get_save_path",
"get_source_bookmarks", "get_source_bookmarks",
"get_source_column_order",
"get_source_cursor", "get_source_cursor",
"get_source_from_gramps_id", "get_source_from_gramps_id",
"get_source_from_handle", "get_source_from_handle",
@ -152,17 +143,6 @@ class DbTest(object):
"set_prefixes", "set_prefixes",
"set_repository_id_prefix", "set_repository_id_prefix",
"set_source_id_prefix", "set_source_id_prefix",
# Column order:
"set_child_column_order",
"set_column_order",
"set_event_column_order",
"set_family_list_column_order",
"set_media_column_order",
"set_note_column_order",
"set_person_column_order",
"set_place_column_order",
"set_repository_column_order",
"set_source_column_order",
# Other set methods: # Other set methods:
"set_mediapath", "set_mediapath",
"set_redo_callback", "set_redo_callback",

View File

@ -19,7 +19,7 @@ dist_pkgdata_DATA = \
addmedia.glade \ addmedia.glade \
questiondialog.glade \ questiondialog.glade \
columnorder.glade \ columnorder.glade \
grampscfg.glade \ configure.glade \
dateedit.glade \ dateedit.glade \
editsource.glade \ editsource.glade \
styleeditor.glade \ styleeditor.glade \

View File

@ -13,6 +13,8 @@ pkgdatadir = $(datadir)/@PACKAGE@/gui
pkgdata_PYTHON = \ pkgdata_PYTHON = \
__init__.py \ __init__.py \
columnorder.py \
configure.py \
dbguielement.py \ dbguielement.py \
dbloader.py \ dbloader.py \
dbman.py \ dbman.py \

View File

@ -50,8 +50,8 @@ import DateHandler
from gen.display.name import displayer as _nd from gen.display.name import displayer as _nd
from gen.display.name import NameDisplayError from gen.display.name import NameDisplayError
import Utils import Utils
from gen.lib import Name
import gen.lib import gen.lib
from gen.lib import Name
import ManagedWindow import ManagedWindow
from gui.widgets import MarkupLabel, BasicLabel from gui.widgets import MarkupLabel, BasicLabel
from QuestionDialog import ErrorDialog, QuestionDialog2, OkDialog from QuestionDialog import ErrorDialog, QuestionDialog2, OkDialog
@ -121,44 +121,209 @@ will be removed around empty fields. Other text will appear literally."""))
def build_menu_names(self, obj): def build_menu_names(self, obj):
return (_(" Name Editor"), _("Preferences")) return (_(" Name Editor"), _("Preferences"))
class GrampsPreferences(ManagedWindow.ManagedWindow):
def __init__(self, uistate, dbstate): #-------------------------------------------------------------------------
#
# ConfigureDialog
#
#-------------------------------------------------------------------------
class ConfigureDialog(ManagedWindow.ManagedWindow):
"""
Base class for configuration dialogs. They provide a Notebook, to which
pages are added with configuration options, and a Cancel and Save button.
On save, a config file on which the dialog works, is saved to disk, and
a callback called.
"""
def __init__(self, uistate, dbstate, configure_page_funcs, configobj,
configmanager,
dialogtitle=_("Preferences"), on_close=None):
"""
Set up a configuration dialog
:param uistate: a DisplayState instance
:param dbstate: a DbState instance
:param configure_page_funcs: a list of function that return a tuple
(str, gtk.Widget). The string is used as label for the
configuration page, and the widget as the content of the
configuration page
:param configobj: the unique object that is configured, it must be
identifiable (id(configobj)). If the configure dialog of the
configobj is already open, a Errors.WindowActiveError will be
raised. Grab this exception in the calling method
:param configmanager: a configmanager object. Several convenience
methods are present in ConfigureDialog to set up widgets that
write changes directly via this configmanager.
:param dialogtitle: the title of the configuration dialog
:param on_close: callback that is called on close
"""
self.dbstate = dbstate self.dbstate = dbstate
ManagedWindow.ManagedWindow.__init__(self, uistate, [], GrampsPreferences) self.__config = configmanager
ManagedWindow.ManagedWindow.__init__(self, uistate, [], configobj)
self.set_window( self.set_window(
gtk.Dialog(_('Preferences'), gtk.Dialog(dialogtitle, flags=gtk.DIALOG_NO_SEPARATOR,
flags=gtk.DIALOG_NO_SEPARATOR,
buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)), buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)),
None, _('Preferences'), None) None, dialogtitle, None)
panel = gtk.Notebook() self.panel = gtk.Notebook()
self.window.vbox.add(panel) self.window.vbox.add(self.panel)
self.__on_close = on_close
self.window.connect('response', self.done) self.window.connect('response', self.done)
panel.append_page(self.add_behavior_panel(),
MarkupLabel(_('General'))) self.__setup_pages(configure_page_funcs)
panel.append_page(self.add_database_panel(),
MarkupLabel(_('Database')))
panel.append_page(self.add_formats_panel(),
MarkupLabel(_('Display')))
panel.append_page(self.add_text_panel(),
MarkupLabel(_('Text')))
panel.append_page(self.add_prefix_panel(),
MarkupLabel(_('ID Formats')))
panel.append_page(self.add_date_panel(),
MarkupLabel(_('Dates')))
panel.append_page(self.add_advanced_panel(),
MarkupLabel(_('Warnings')))
panel.append_page(self.add_researcher_panel(),
MarkupLabel(_('Researcher')))
panel.append_page(self.add_color_panel(),
MarkupLabel(_('Marker Colors')))
self.window.show_all() self.window.show_all()
self.show() self.show()
def __setup_pages(self, configure_page_funcs):
"""
This method builds the notebookpages in the panel
"""
for func in configure_page_funcs:
labeltitle, widget = func()
self.panel.append_page(widget, MarkupLabel(labeltitle))
def done(self, obj, value): def done(self, obj, value):
Utils.update_constants() if self.__on_close:
self.__on_close()
self.close() self.close()
def update_int_entry(self, obj, constant):
"""
:param obj: an object with get_text method that should contain an
integer
:param constant: the config setting to which the integer value must be
saved
"""
try:
self.__config.set(constant, int(obj.get_text()))
except:
print "WARNING: ignoring invalid value for '%s'" % constant
def update_entry(self, obj, constant):
"""
:param obj: an object with get_text method
:param constant: the config setting to which the text value must be
saved
"""
self.__config.set(constant, unicode(obj.get_text()))
def update_color(self, obj, constant, color_hex_label):
color = obj.get_color()
hexval = "#%02x%02x%02x" % (color.red/256,
color.green/256,
color.blue/256)
color_hex_label.set_text(hexval)
self.__config.set(constant, hexval)
def update_checkbox(self, obj, constant):
self.__config.set(constant, obj.get_active())
def update_radiobox(self, obj, constant):
self.__config.set(constant, obj.get_active())
def add_checkbox(self, table, label, index, constant, start=1, stop=9):
checkbox = gtk.CheckButton(label)
checkbox.set_active(self.__config.get(constant))
checkbox.connect('toggled', self.update_checkbox, constant)
table.attach(checkbox, start, stop, index, index+1, yoptions=0)
def add_radiobox(self, table, label, index, constant, group, column):
radiobox = gtk.RadioButton(group,label)
if self.__config.get(constant) == True:
radiobox.set_active(True)
radiobox.connect('toggled', self.update_radiobox, constant)
table.attach(radiobox, column, column+1, index, index+1, yoptions=0)
return radiobox
def add_text(self, table, label, index):
text = gtk.Label()
text.set_line_wrap(True)
text.set_alignment(0.,0.)
text.set_text(label)
table.attach(text, 1, 9, index, index+1, yoptions=0)
def add_path_box(self, table, label, index, entry, path, callback_label,
callback_sel):
""" Add an entry to give in path and a select button to open a
dialog.
Changing entry calls callback_label
Clicking open button call callback_sel
"""
lwidget = BasicLabel("%s: " %label)
hbox = gtk.HBox()
if path:
entry.set_text(path)
entry.connect('changed', callback_label)
btn = gtk.Button()
btn.connect('clicked', callback_sel)
image = gtk.Image()
image.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_BUTTON)
image.show()
btn.add(image)
hbox.pack_start(entry, expand=True, fill=True)
hbox.pack_start(btn, expand=False, fill=False)
table.attach(lwidget, 1, 2, index, index+1, yoptions=0,
xoptions=gtk.FILL)
table.attach(hbox, 2, 3, index, index+1, yoptions=0)
def add_entry(self, table, label, index, constant, callback=None):
if not callback:
callback = self.update_entry
lwidget = BasicLabel("%s: " % label)
entry = gtk.Entry()
entry.set_text(self.__config.get(constant))
entry.connect('changed', callback, constant)
table.attach(lwidget, 0, 1, index, index+1, yoptions=0,
xoptions=gtk.FILL)
table.attach(entry, 1, 2, index, index+1, yoptions=0)
def add_pos_int_entry(self, table, label, index, constant, callback=None):
""" entry field for positive integers
"""
lwidget = BasicLabel("%s: " % label)
entry = gtk.Entry()
entry.set_text(str(self.__config.get(constant)))
if callback:
entry.connect('changed', callback, constant)
table.attach(lwidget, 1, 2, index, index+1, yoptions=0,
xoptions=gtk.FILL)
table.attach(entry, 2, 3, index, index+1, yoptions=0)
def add_color(self, table, label, index, constant):
lwidget = BasicLabel("%s: " % label)
hexval = self.__config.get(constant)
color = gtk.gdk.color_parse(hexval)
entry = gtk.ColorButton(color=color)
color_hex_label = BasicLabel(hexval)
entry.connect('color-set', self.update_color, constant, color_hex_label)
table.attach(lwidget, 0, 1, index, index+1, yoptions=0,
xoptions=gtk.FILL)
table.attach(entry, 1, 2, index, index+1, yoptions=0, xoptions=0)
table.attach(color_hex_label, 2, 3, index, index+1, yoptions=0)
return entry
#-------------------------------------------------------------------------
#
# GrampsPreferences
#
#-------------------------------------------------------------------------
class GrampsPreferences(ConfigureDialog):
def __init__(self, uistate, dbstate):
page_funcs = (
self.add_behavior_panel,
self.add_database_panel,
self.add_formats_panel,
self.add_text_panel,
self.add_prefix_panel,
self.add_date_panel,
self.add_advanced_panel,
self.add_researcher_panel,
self.add_color_panel
)
ConfigureDialog.__init__(self, uistate, dbstate, page_funcs,
GrampsPreferences, config,
on_close=Utils.update_constants)
def add_researcher_panel(self): def add_researcher_panel(self):
table = gtk.Table(3, 8) table = gtk.Table(3, 8)
table.set_border_width(12) table.set_border_width(12)
@ -172,7 +337,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
self.add_entry(table, _('ZIP/Postal Code'), 5, 'researcher.researcher-postal') self.add_entry(table, _('ZIP/Postal Code'), 5, 'researcher.researcher-postal')
self.add_entry(table, _('Phone'), 6, 'researcher.researcher-phone') self.add_entry(table, _('Phone'), 6, 'researcher.researcher-phone')
self.add_entry(table, _('Email'), 7, 'researcher.researcher-email') self.add_entry(table, _('Email'), 7, 'researcher.researcher-email')
return table return _('Researcher'), table
def add_prefix_panel(self): def add_prefix_panel(self):
""" """
@ -198,7 +363,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
self.update_idformat_entry) self.update_idformat_entry)
self.add_entry(table, _('Note'), 7, 'preferences.nprefix', self.add_entry(table, _('Note'), 7, 'preferences.nprefix',
self.update_idformat_entry) self.update_idformat_entry)
return table return _('ID Formats'), table
def add_advanced_panel(self): def add_advanced_panel(self):
table = gtk.Table(4, 8) table = gtk.Table(4, 8)
@ -222,7 +387,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
table, _('Show plugin status dialog on plugin load error.'), table, _('Show plugin status dialog on plugin load error.'),
3, 'behavior.pop-plugin-status') 3, 'behavior.pop-plugin-status')
return table return _('Warnings'), table
def add_color_panel(self): def add_color_panel(self):
table = gtk.Table(3, 8) table = gtk.Table(3, 8)
@ -240,7 +405,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
button = gtk.Button(stock=gtk.STOCK_REVERT_TO_SAVED) button = gtk.Button(stock=gtk.STOCK_REVERT_TO_SAVED)
button.connect('clicked', self.reset_colors) button.connect('clicked', self.reset_colors)
table.attach(button, 1, 2, 3, 4, yoptions=0, xoptions=0) table.attach(button, 1, 2, 3, 4, yoptions=0, xoptions=0)
return table return _('Marker Colors'), table
def reset_colors(self, obj): def reset_colors(self, obj):
@ -734,7 +899,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
_("Show text in sidebar buttons (requires restart)"), _("Show text in sidebar buttons (requires restart)"),
row, 'interface.sidebar-text', stop=3) row, 'interface.sidebar-text', stop=3)
row += 1 row += 1
return table return _('Display'), table
def add_text_panel(self): def add_text_panel(self):
row = 0 row = 0
@ -760,7 +925,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
self.add_entry(table, _('Private record'), row, self.add_entry(table, _('Private record'), row,
'preferences.private-record-text') 'preferences.private-record-text')
row += 1 row += 1
return table return _('Text'), table
def cb_name_dialog(self, obj): def cb_name_dialog(self, obj):
the_list = self.fmt_obox.get_model() the_list = self.fmt_obox.get_model()
@ -810,7 +975,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
_('Markup for invalid date format'), _('Markup for invalid date format'),
7, 'preferences.invalid-date-format', self.update_entry) 7, 'preferences.invalid-date-format', self.update_entry)
return table return _('Dates'), table
def add_behavior_panel(self): def add_behavior_panel(self):
table = gtk.Table(3, 8) table = gtk.Table(3, 8)
@ -845,7 +1010,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
7, self.path_entry, self.dbstate.db.get_mediapath(), 7, self.path_entry, self.dbstate.db.get_mediapath(),
self.set_mediapath, self.select_mediapath) self.set_mediapath, self.select_mediapath)
return table return _('General'), table
def add_database_panel(self): def add_database_panel(self):
table = gtk.Table(2, 2) table = gtk.Table(2, 2)
@ -860,88 +1025,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
_('Automatically load last database'), _('Automatically load last database'),
1, 'behavior.autoload') 1, 'behavior.autoload')
return table return _('Database'), table
def add_checkbox(self, table, label, index, constant, start=1, stop=9):
checkbox = gtk.CheckButton(label)
checkbox.set_active(config.get(constant))
checkbox.connect('toggled', self.update_checkbox, constant)
table.attach(checkbox, start, stop, index, index+1, yoptions=0)
def add_radiobox(self, table, label, index, constant, group, column):
radiobox = gtk.RadioButton(group,label)
if config.get(constant) == True:
radiobox.set_active(True)
radiobox.connect('toggled', self.update_radiobox, constant)
table.attach(radiobox, column, column+1, index, index+1, yoptions=0)
return radiobox
def add_text(self, table, label, index):
text = gtk.Label()
text.set_line_wrap(True)
text.set_alignment(0.,0.)
text.set_text(label)
table.attach(text, 1, 9, index, index+1, yoptions=0)
def add_path_box(self, table, label, index, entry, path, callback_label,
callback_sel):
""" Add an entry to give in path and a select button to open a
dialog.
Changing entry calls callback_label
Clicking open button call callback_sel
"""
lwidget = BasicLabel("%s: " %label)
hbox = gtk.HBox()
if path:
entry.set_text(path)
entry.connect('changed', callback_label)
btn = gtk.Button()
btn.connect('clicked', callback_sel)
image = gtk.Image()
image.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_BUTTON)
image.show()
btn.add(image)
hbox.pack_start(entry, expand=True, fill=True)
hbox.pack_start(btn, expand=False, fill=False)
table.attach(lwidget, 1, 2, index, index+1, yoptions=0,
xoptions=gtk.FILL)
table.attach(hbox, 2, 3, index, index+1, yoptions=0)
def add_entry(self, table, label, index, constant, callback=None):
if not callback:
callback = self.update_entry
lwidget = BasicLabel("%s: " % label)
entry = gtk.Entry()
entry.set_text(config.get(constant))
entry.connect('changed', callback, constant)
table.attach(lwidget, 0, 1, index, index+1, yoptions=0,
xoptions=gtk.FILL)
table.attach(entry, 1, 2, index, index+1, yoptions=0)
def add_pos_int_entry(self, table, label, index, constant, callback=None):
""" entry field for positive integers
"""
lwidget = BasicLabel("%s: " % label)
entry = gtk.Entry()
entry.set_text(str(config.get(constant)))
if callback:
entry.connect('changed', callback, constant)
table.attach(lwidget, 1, 2, index, index+1, yoptions=0,
xoptions=gtk.FILL)
table.attach(entry, 2, 3, index, index+1, yoptions=0)
def add_color(self, table, label, index, constant):
lwidget = BasicLabel("%s: " % label)
hexval = config.get(constant)
color = gtk.gdk.color_parse(hexval)
entry = gtk.ColorButton(color=color)
color_hex_label = BasicLabel(hexval)
entry.connect('color-set', self.update_color, constant, color_hex_label)
table.attach(lwidget, 0, 1, index, index+1, yoptions=0,
xoptions=gtk.FILL)
table.attach(entry, 1, 2, index, index+1, yoptions=0, xoptions=0)
table.attach(color_hex_label, 2, 3, index, index+1, yoptions=0)
return entry
def set_mediapath(self, *obj): def set_mediapath(self, *obj):
if self.path_entry.get_text().strip(): if self.path_entry.get_text().strip():
@ -969,15 +1053,6 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
self.path_entry.set_text(val) self.path_entry.set_text(val)
f.destroy() f.destroy()
def update_int_entry(self, obj, constant):
try:
config.set(constant, int(obj.get_text()))
except:
print "WARNING: ignoring invalid value for '%s'" % constant
def update_entry(self, obj, constant):
config.set(constant, unicode(obj.get_text()))
def update_idformat_entry(self, obj, constant): def update_idformat_entry(self, obj, constant):
config.set(constant, unicode(obj.get_text())) config.set(constant, unicode(obj.get_text()))
self.dbstate.db.set_prefixes( self.dbstate.db.set_prefixes(
@ -1009,20 +1084,6 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
else: else:
obj.set_text(str(intval)) obj.set_text(str(intval))
def update_color(self, obj, constant, color_hex_label):
color = obj.get_color()
hexval = "#%02x%02x%02x" % (color.red/256,
color.green/256,
color.blue/256)
color_hex_label.set_text(hexval)
config.set(constant, hexval)
def update_checkbox(self, obj, constant):
config.set(constant, obj.get_active())
def update_radiobox(self, obj, constant):
config.set(constant, obj.get_active())
def build_menu_names(self, obj): def build_menu_names(self, obj):
return (_('Preferences'), None) return (_('Preferences'), None)

View File

@ -67,7 +67,6 @@ import ReportBase
import DisplayState import DisplayState
import const import const
import config import config
import GrampsCfg
import Errors import Errors
from QuestionDialog import (ErrorDialog, WarningDialog, QuestionDialog2, from QuestionDialog import (ErrorDialog, WarningDialog, QuestionDialog2,
InfoDialog) InfoDialog)
@ -76,6 +75,7 @@ import UndoHistory
from gui.dbloader import DbLoader from gui.dbloader import DbLoader
import GrampsDisplay import GrampsDisplay
from gui.widgets.progressdialog import ProgressMonitor, GtkProgressDialog from gui.widgets.progressdialog import ProgressMonitor, GtkProgressDialog
from gui.configure import GrampsPreferences
from gen.db.backup import backup from gen.db.backup import backup
from gen.db.exceptions import DbException from gen.db.exceptions import DbException
from GrampsAboutDialog import GrampsAboutDialog from GrampsAboutDialog import GrampsAboutDialog
@ -762,7 +762,7 @@ class ViewManager(CLIManager):
Open the preferences dialog. Open the preferences dialog.
""" """
try: try:
GrampsCfg.GrampsPreferences(self.uistate, self.dbstate) GrampsPreferences(self.uistate, self.dbstate)
self._key = self.uistate.connect('nameformat-changed', self._key = self.uistate.connect('nameformat-changed',
self.active_page.build_tree) self.active_page.build_tree)
except Errors.WindowActiveError: except Errors.WindowActiveError:
@ -885,6 +885,7 @@ class ViewManager(CLIManager):
page = page_def(self.dbstate, self.uistate) page = page_def(self.dbstate, self.uistate)
# Category is (string, trans): # Category is (string, trans):
page.set_category(pdata.category) page.set_category(pdata.category)
page.set_ident(page.get_category() + '_' + pdata.id)
page_title = page.get_title() page_title = page.get_title()
page_category = page.get_category() page_category = page.get_category()
page_translated_category = page.get_translated_category() page_translated_category = page.get_translated_category()
@ -1103,6 +1104,12 @@ class ViewManager(CLIManager):
mergeid = self.uimanager.add_ui_from_string(self.ui_category[ mergeid = self.uimanager.add_ui_from_string(self.ui_category[
category_page]) category_page])
self.merge_ids.append(mergeid) self.merge_ids.append(mergeid)
configaction = self.actiongroup.get_action('ConfigView')
if self.active_page.can_configure():
configaction.set_sensitive(True)
else:
configaction.set_sensitive(False)
def change_category(self, obj, page, num=-1): def change_category(self, obj, page, num=-1):
""" """
@ -1330,7 +1337,7 @@ class ViewManager(CLIManager):
""" """
Displays the configuration dialog for the active view Displays the configuration dialog for the active view
""" """
pass self.active_page.configure()
def undo(self, obj): def undo(self, obj):
""" """

View File

@ -51,6 +51,7 @@ import pango
# #
#---------------------------------------------------------------- #----------------------------------------------------------------
from gui.views.navigationview import NavigationView from gui.views.navigationview import NavigationView
from gui.columnorder import ColumnOrder
import config import config
import TreeTips import TreeTips
import Errors import Errors
@ -80,7 +81,13 @@ LISTTREE = 1
# #
#---------------------------------------------------------------- #----------------------------------------------------------------
class ListView(NavigationView): class ListView(NavigationView):
COLUMN_NAMES = []
#listview config settings that are always present related to the columns
CONFIGSETTINGS = (
('columns.visible', []),
('columns.order', []),
('columns.sizecol', [])
)
ADD_MSG = "" ADD_MSG = ""
EDIT_MSG = "" EDIT_MSG = ""
DEL_MSG = "" DEL_MSG = ""
@ -127,6 +134,7 @@ class ListView(NavigationView):
contains the interface. This containter will be inserted into contains the interface. This containter will be inserted into
a gtk.Notebook page. a gtk.Notebook page.
""" """
self.init_config()
self.vbox = gtk.VBox() self.vbox = gtk.VBox()
self.vbox.set_border_width(4) self.vbox.set_border_width(4)
self.vbox.set_spacing(4) self.vbox.set_spacing(4)
@ -469,10 +477,24 @@ class ListView(NavigationView):
def column_order(self): def column_order(self):
""" """
Must be set by children. The method that obtains the column order Column order is obtained from the config file of the listview.
to be used. Format: see ColumnOrder. A column order is a list of 3-tuples. The order in the list is the
order the columns must appear in.
For a column, the 3-tuple should be (enable, modelcol, sizecol), where
enable: show this column or don't show it
modelcol: column in the datamodel this column is build of
size: size the column should have
""" """
raise NotImplementedError order = self._config.get('columns.order')
size = self._config.get('columns.sizecol')
vis = self._config.get('columns.visible')
colord = []
for val, size in zip(order, size):
if val in vis:
colord.append((1, val, size))
else:
colord.append((0, val, size))
return colord
def column_ord_setfunc(self, clist): def column_ord_setfunc(self, clist):
""" """
@ -1038,8 +1060,38 @@ class ListView(NavigationView):
def close_branch(self, obj): def close_branch(self, obj):
""" """
Collapse the selected branches. Collapse the selected branches.
obj: for use of method in event callback :param obj: not used, present only to allow the use of the method in
event callback
""" """
selected = self.selection.get_selected_rows() selected = self.selection.get_selected_rows()
for path in selected[1]: for path in selected[1]:
self.list.collapse_row(path) self.list.collapse_row(path)
def can_configure(self):
"""
See :class:`~gui.views.pageview.PageView
:return: bool
"""
return True
def config_connect(self):
"""
Overwriten from :class:`~gui.views.pageview.PageView method
This method will be called after the ini file is initialized
"""
#func = self.config_callback(self.build_tree)
#self._config.connect('columns.visible', func)
#self._config.connect('columns.order', func)
pass
def _get_configure_page_funcs(self):
"""
Return a list of functions that create gtk elements to use in the
notebook pages of the Configure dialog
:return: list of functions
"""
def columnpage():
return _('Columns', ColumnOrder(self._config, COLUMN_NAMES,
tree=False))
return [columnpage]

View File

@ -46,8 +46,11 @@ from gen.ggettext import gettext as _
# GRAMPS # GRAMPS
# #
#---------------------------------------------------------------- #----------------------------------------------------------------
import Errors
from gui.dbguielement import DbGUIElement from gui.dbguielement import DbGUIElement
from gui.widgets.menutoolbuttonaction import MenuToolButtonAction from gui.widgets.menutoolbuttonaction import MenuToolButtonAction
from gui.configure import ConfigureDialog
from config import config
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# #
@ -84,6 +87,8 @@ class PageView(DbGUIElement):
placed behind the same button in the sidebar placed behind the same button in the sidebar
""" """
CONFIGSETTINGS = []
def __init__(self, title, dbstate, uistate): def __init__(self, title, dbstate, uistate):
self.title = title self.title = title
self.dbstate = dbstate self.dbstate = dbstate
@ -102,6 +107,7 @@ class PageView(DbGUIElement):
self._dirty_on_change_inactive = True self._dirty_on_change_inactive = True
self.func_list = {} self.func_list = {}
self.category = "Miscellaneous" self.category = "Miscellaneous"
self.ident = None
self.translated_category = _("Miscellaneous") self.translated_category = _("Miscellaneous")
self.dbstate.connect('no-database', self.disable_action_group) self.dbstate.connect('no-database', self.disable_action_group)
@ -110,6 +116,9 @@ class PageView(DbGUIElement):
self.model = None self.model = None
self.selection = None self.selection = None
self.handle_col = 0 self.handle_col = 0
self._config = None
self.__configure_content = None
DbGUIElement.__init__(self, dbstate.db) DbGUIElement.__init__(self, dbstate.db)
@ -232,6 +241,12 @@ class PageView(DbGUIElement):
""" """
return self.translated_category return self.translated_category
def set_ident(self, ident):
"""
Set the id of the view. This is an unique ident
"""
self.ident = ident
def get_display(self): def get_display(self):
""" """
Builds the graphical display, returning the top level widget. Builds the graphical display, returning the top level widget.
@ -373,3 +388,73 @@ class PageView(DbGUIElement):
that should be called when quiting the main application. that should be called when quiting the main application.
""" """
pass pass
def init_config(self):
"""
If you need a view with a config, then call this method in the
build_tree method. It will set up a config file for the
view, and use CONFIGSETTINGS to set the config defaults.
The config is later accessbile via self._config
So you can do
self._config.get("section.variable1")
self._config.set("section.variable1", value)
self._config.save()
CONFIGSETTINGS should be a list with tuples like
("section.variable1", value)
"""
if self._config:
return
self._config = config.register_manager(self.ident,
use_config_path=True)
for section, value in self.CONFIGSETTINGS:
self._config.register(section, value)
self._config.init()
self.config_connect()
def config_connect(self):
"""
Overwrite this method to set connects to the config file to monitor
changes. This method will be called after the ini file is initialized
Eg:
self.config.connect("section.option", self.callback)
"""
pass
def config_callback(self, callback):
"""
Convenience wrappen to create a callback for a config setting
:param callback: a callback function to call.
"""
return lambda arg1, arg2, arg3, arg4: callback()
def can_configure(self):
"""
Inheriting classes should set if the view has a configure window or not
:return: bool
"""
return False
def configure(self):
"""
Open the configure dialog for the view.
"""
if not self.__configure_content:
self.__configure_content = self._get_configure_page_funcs()
title = _("Configure %(cat)s - %(view)s") % \
{'cat': self.get_category(), 'view': self.get_title()}
try:
ConfigureDialog(self.uistate, self.dbstate,
self.__configure_content,
self, self._config, dialogtitle=title)
except Errors.WindowActiveError:
return
def _get_configure_page_funcs(self):
"""
Return a list of functions that create gtk elements to use in the
notebook pages of the Configure view
:return: list of functions
"""
raise NotImplementedError

View File

@ -70,7 +70,21 @@ from gen.ggettext import gettext as _
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class PlaceBaseView(ListView): class PlaceBaseView(ListView):
""" base view class for place views, be they flat list or tree
"""
COL_NAME = 0
COL_ID = 1
COL_PARISH = 2
COL_ZIP = 3
COL_CITY = 4
COL_COUNTY = 5
COL_STATE = 6
COL_COUNTRY = 7
COL_LAT = 8
COL_LON = 9
COL_CHAN = 10
COL_STREET = 11
# name of the columns
COLUMN_NAMES = [ COLUMN_NAMES = [
_('Place Name'), _('Place Name'),
_('ID'), _('ID'),
@ -85,7 +99,16 @@ class PlaceBaseView(ListView):
_('Last Changed'), _('Last Changed'),
_('Street'), _('Street'),
] ]
# default setting with visible columns, order of the col, and their size
CONFIGSETTINGS = (
('columns.visible', [COL_NAME, COL_ID, COL_STREET, COL_CITY, COL_STATE
]),
('columns.order', [COL_NAME, COL_ID, COL_STREET, COL_ZIP, COL_CITY,
COL_COUNTY, COL_STATE, COL_COUNTRY, COL_LAT,
COL_LON, COL_PARISH, COL_CHAN]),
('columns.sizecol', [250, 75, 100, 100, 100, 100, 150, 150, 150,
150, 150, 100])
)
ADD_MSG = _("Add a new place") ADD_MSG = _("Add a new place")
EDIT_MSG = _("Edit the selected place") EDIT_MSG = _("Edit the selected place")
DEL_MSG = _("Delete the selected place") DEL_MSG = _("Delete the selected place")
@ -124,17 +147,12 @@ class PlaceBaseView(ListView):
def navigation_type(self): def navigation_type(self):
return 'Place' return 'Place'
def column_ord_setfunc(self, clist):
self.dbstate.db.set_place_column_order(clist)
def get_bookmarks(self): def get_bookmarks(self):
return self.dbstate.db.get_place_bookmarks() return self.dbstate.db.get_place_bookmarks()
def define_actions(self): def define_actions(self):
ListView.define_actions(self) ListView.define_actions(self)
self._add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor'), callback=self._column_editor)
self._add_action('FastMerge', None, _('_Merge...'), self._add_action('FastMerge', None, _('_Merge...'),
callback=self.fast_merge) callback=self.fast_merge)
self._add_toolmenu_action('MapsList', _('Loading...'), self._add_toolmenu_action('MapsList', _('Loading...'),
@ -268,19 +286,6 @@ class PlaceBaseView(ListView):
def drag_info(self): def drag_info(self):
return DdTargets.PLACE_LINK return DdTargets.PLACE_LINK
def _column_editor(self, obj):
import ColumnOrder
ColumnOrder.ColumnOrder(
_('Select Place Columns'),
self.uistate,
self.dbstate.db.get_place_column_order(),
PlaceBaseView.COLUMN_NAMES,
self.set_column_order)
def column_order(self):
return self.dbstate.db.get_place_column_order()
def get_stock(self): def get_stock(self):
return 'gramps-place' return 'gramps-place'
@ -311,7 +316,6 @@ class PlaceBaseView(ListView):
<menuitem action="Edit"/> <menuitem action="Edit"/>
<menuitem action="Remove"/> <menuitem action="Remove"/>
</placeholder> </placeholder>
<menuitem action="ColumnEdit"/>
<menuitem action="FilterEdit"/> <menuitem action="FilterEdit"/>
<placeholder name="Merge"> <placeholder name="Merge">
<menuitem action="FastMerge"/> <menuitem action="FastMerge"/>

View File

@ -60,6 +60,7 @@ class NoteModel(FlatBaseModel):
self.column_id, self.column_id,
self.column_type, self.column_type,
self.column_marker, self.column_marker,
self.column_change,
self.column_handle, self.column_handle,
self.column_marker_color self.column_marker_color
] ]
@ -68,10 +69,11 @@ class NoteModel(FlatBaseModel):
self.column_id, self.column_id,
self.column_type, self.column_type,
self.column_marker, self.column_marker,
self.column_change,
self.column_handle, self.column_handle,
self.column_marker_color self.column_marker_color
] ]
self.marker_color_column = 5 self.marker_color_column = 6
FlatBaseModel.__init__(self, db, scol, order, search=search, FlatBaseModel.__init__(self, db, scol, order, search=search,
skip=skip, sort_map=sort_map) skip=skip, sort_map=sort_map)
@ -124,3 +126,7 @@ class NoteModel(FlatBaseModel):
return None return None
except IndexError: except IndexError:
return None return None
def column_change(self,data):
return unicode(time.strftime('%x %X',time.localtime(
data[Note.POS_CHANGE])), GrampsLocale.codeset)

View File

@ -338,19 +338,6 @@ class GrampsBSDDB(DbGrdb, UpdateCallback):
self.metadata.sync() self.metadata.sync()
return None return None
def _set_column_order(self, col_list, name):
if self.metadata and not self.readonly:
if self.UseTXN:
# Start transaction if needed
the_txn = self.env.txn_begin()
else:
the_txn = None
self.metadata.put(name, col_list, txn=the_txn)
if self.UseTXN:
the_txn.commit()
else:
self.metadata.sync()
def version_supported(self): def version_supported(self):
dbversion = self.metadata.get('version',default=_DBVERSION) dbversion = self.metadata.get('version',default=_DBVERSION)
return ((dbversion <= _DBVERSION) and (dbversion >= _MINVERSION)) return ((dbversion <= _DBVERSION) and (dbversion >= _MINVERSION))
@ -1588,21 +1575,23 @@ class GrampsBSDDB(DbGrdb, UpdateCallback):
# Remove event column metadata, since columns have changed. # Remove event column metadata, since columns have changed.
# This will reset all columns to defaults in event view # This will reset all columns to defaults in event view
for name in (PERSON_COL_KEY, EVENT_COL_KEY): ## This action is removed: column data is no longer used, so no
try: ## need to change it
if self.UseTXN: #for name in (PERSON_COL_KEY, EVENT_COL_KEY):
# Start transaction if needed # try:
the_txn = self.env.txn_begin() # if self.UseTXN:
else: # # Start transaction if needed
the_txn = None # the_txn = self.env.txn_begin()
self.metadata.delete(name, txn=the_txn) # else:
if self.UseTXN: # the_txn = None
the_txn.commit() # self.metadata.delete(name, txn=the_txn)
else: # if self.UseTXN:
self.metadata.sync() # the_txn.commit()
except KeyError: # else:
if self.UseTXN: # self.metadata.sync()
the_txn.abort() # except KeyError:
# if self.UseTXN:
# the_txn.abort()
# This upgrade adds attribute lists to Event and EventRef objects # This upgrade adds attribute lists to Event and EventRef objects
length = self.get_number_of_events() + len(self.person_map) \ length = self.get_number_of_events() + len(self.person_map) \

View File

@ -58,10 +58,7 @@ from gen.utils.callback import Callback
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gen.db.dbconst import (PERSON_KEY, FAMILY_KEY, SOURCE_KEY, EVENT_KEY, from gen.db.dbconst import (PERSON_KEY, FAMILY_KEY, SOURCE_KEY, EVENT_KEY,
MEDIA_KEY, PLACE_KEY, REPOSITORY_KEY, NOTE_KEY, MEDIA_KEY, PLACE_KEY, REPOSITORY_KEY, NOTE_KEY,
REFERENCE_KEY, PERSON_COL_KEY, FAMILY_COL_KEY, REFERENCE_KEY)
CHILD_COL_KEY, PLACE_COL_KEY, SOURCE_COL_KEY,
MEDIA_COL_KEY, EVENT_COL_KEY, REPOSITORY_COL_KEY,
NOTE_COL_KEY)
_UNDO_SIZE = 1000 _UNDO_SIZE = 1000
@ -2294,171 +2291,6 @@ class DbGrdb(Callback):
return self.metadata.get('mediapath', None) return self.metadata.get('mediapath', None)
return None return None
def set_column_order(self, col_list, name):
if (self.metadata is not None) and (not self.readonly):
self.metadata[name] = col_list
def set_person_column_order(self, col_list):
"""
Store the Person display common information in the database's metadata.
"""
self.set_column_order(col_list, PERSON_COL_KEY)
def set_family_list_column_order(self, col_list):
"""
Store the Person display common information in the database's metadata.
"""
self.set_column_order(col_list, FAMILY_COL_KEY)
def set_child_column_order(self, col_list):
"""
Store the Person display common information in the database's metadata.
"""
self.set_column_order(col_list, CHILD_COL_KEY)
def set_place_column_order(self, col_list):
"""
Store the Place display common information in the database's metadata.
"""
self.set_column_order(col_list, PLACE_COL_KEY)
def set_source_column_order(self, col_list):
"""
Store the Source display common information in the database's metadata.
"""
self.set_column_order(col_list, SOURCE_COL_KEY)
def set_media_column_order(self, col_list):
"""
Store the Media display common information in the database's metadata.
"""
self.set_column_order(col_list, MEDIA_COL_KEY)
def set_event_column_order(self, col_list):
"""
Store the Event display common information in the database's metadata.
"""
self.set_column_order(col_list, EVENT_COL_KEY)
def set_repository_column_order(self, col_list):
"""
Store the Repository display common information in the database's
metadata.
"""
self.set_column_order(col_list, REPOSITORY_COL_KEY)
def set_note_column_order(self, col_list):
"""
Store the Note display common information in the database's metadata.
"""
self.set_column_order(col_list, NOTE_COL_KEY)
def __get_column_order(self, name, default):
if self.metadata is None:
return default
else:
cols = self.metadata.get(name, default)
if len(cols) != len(default):
return cols + default[len(cols):]
else:
return cols
def get_person_column_order(self):
"""
Return the Person display common information stored in the database's
metadata.
"""
default = [(1, 1, 100), (1, 2, 100), (1, 3, 150), (0, 4, 150),
(1, 5, 150), (0, 6, 150), (0, 7, 100), (0, 8, 100),
]
return self.__get_column_order(PERSON_COL_KEY, default)
def __get_columns(self, key, default):
values = self.__get_column_order(key, default)
new = []
for val in values:
if len(val) == 2:
for x in default:
if val[1] == x[1]:
new.append((val[0], val[1], x[2]))
break
else:
new.append(val)
return new
def get_family_list_column_order(self):
"""
Return the Person display common information stored in the database's
metadata.
"""
default = [(1, 0, 75), (1, 1, 200), (1, 2, 200), (1, 3, 100),
(0, 4, 100)]
return self.__get_columns(FAMILY_COL_KEY, default)
def get_child_column_order(self):
"""
Return the Person display common information stored in the database's
metadata.
"""
default = [(1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5),
(0, 6), (0, 7)]
return self.__get_column_order(CHILD_COL_KEY, default)
def get_place_column_order(self):
"""
Return the Place display common information stored in thedatabase's
metadata.
"""
default = [(1, 0, 250), (1, 1, 75), (1, 11, 100), (0, 3, 100),
(1, 4, 100, ), (0, 5, 150), (1, 6, 150), (0, 7, 150),
(0, 8, 150), (0, 9, 150), (0, 10, 150),(0,2,100)]
return self.__get_columns(PLACE_COL_KEY, default)
def get_source_column_order(self):
"""
Return the Source display common information stored in the database's
metadata.
"""
default = [(1, 0, 200), (1, 1, 75), (1, 2, 150), (0, 3, 100),
(1, 4, 150), (0, 5, 100)]
return self.__get_columns(SOURCE_COL_KEY, default)
def get_media_column_order(self):
"""
Return the MediaObject display common information stored in the
database's metadata.
"""
default = [(1, 0, 200, ), (1, 1, 75), (1, 2, 100), (1, 3, 200),
(1, 5, 150), (0, 4, 150)]
return self.__get_columns(MEDIA_COL_KEY, default)
def get_event_column_order(self):
"""
Return the Event display common information stored in the database's
metadata.
"""
default = [(1, 0, 200), (1, 1, 75), (1, 2, 100), (1, 3, 150),
(1, 4, 200), (0, 5, 100)]
return self.__get_columns(EVENT_COL_KEY, default)
def get_repository_column_order(self):
"""
Return the Repository display common information stored in the
database's metadata.
"""
default = [(1, 0, 200), (1, 1, 75), (0, 5, 100), (0, 6, 100),
(1, 2, 100), (1, 3, 250), (1, 4, 100), (0, 7, 100),
(0, 8, 100), (0, 9, 100), (0, 10, 100), (0, 12, 100)]
return self.__get_columns(REPOSITORY_COL_KEY, default)
def get_note_column_order(self):
"""
Return the Note display common information stored in the database's
metadata.
"""
default = [(1, 0, 350), (1, 1, 75), (1, 2, 100), (1, 3, 100)]
return self.__get_columns(NOTE_COL_KEY, default)
def delete_primary_from_reference_map(self, handle, transaction): def delete_primary_from_reference_map(self, handle, transaction):
""" """
Called each time an object is removed from the database. Called each time an object is removed from the database.

View File

@ -66,6 +66,15 @@ class EventView(ListView):
""" """
EventView class, derived from the ListView EventView class, derived from the ListView
""" """
# columns in the model used in view
COL_DESCR = 0
COL_ID = 1
COL_TYPE = 2
COL_DATE = 3
COL_PLACE = 4
COL_CHAN = 5
COL_PARTIC = 6
# name of the columns
COLUMN_NAMES = [ COLUMN_NAMES = [
_('Description'), _('Description'),
_('ID'), _('ID'),
@ -75,7 +84,13 @@ class EventView(ListView):
_('Last Changed'), _('Last Changed'),
_('Main Participants'), _('Main Participants'),
] ]
# default setting with visible columns, order of the col, and their size
CONFIGSETTINGS = (
('columns.visible', [COL_DESCR, COL_ID, COL_TYPE, COL_DATE, COL_PLACE]),
('columns.order', [COL_DESCR, COL_ID, COL_TYPE, COL_PARTIC, COL_DATE,
COL_PLACE, COL_CHAN]),
('columns.sizecol', [200, 75, 100, 230, 150, 200, 100])
)
ADD_MSG = _("Add a new event") ADD_MSG = _("Add a new event")
EDIT_MSG = _("Edit the selected event") EDIT_MSG = _("Edit the selected event")
DEL_MSG = _("Delete the selected event") DEL_MSG = _("Delete the selected event")
@ -113,9 +128,6 @@ class EventView(ListView):
def navigation_type(self): def navigation_type(self):
return 'Event' return 'Event'
def column_ord_setfunc(self, clist):
self.dbstate.db.set_event_column_order(clist)
def get_bookmarks(self): def get_bookmarks(self):
""" """
Return the bookmark object Return the bookmark object
@ -128,12 +140,6 @@ class EventView(ListView):
""" """
return DdTargets.EVENT return DdTargets.EVENT
def column_order(self):
"""
returns a tuple indicating the column order
"""
return self.dbstate.db.get_event_column_order()
def get_stock(self): def get_stock(self):
""" """
Use the gramps-event stock icon Use the gramps-event stock icon
@ -170,7 +176,6 @@ class EventView(ListView):
<menuitem action="Edit"/> <menuitem action="Edit"/>
<menuitem action="Remove"/> <menuitem action="Remove"/>
</placeholder> </placeholder>
<menuitem action="ColumnEdit"/>
<menuitem action="FilterEdit"/> <menuitem action="FilterEdit"/>
</menu> </menu>
</menubar> </menubar>
@ -203,8 +208,6 @@ class EventView(ListView):
ListView.define_actions(self) ListView.define_actions(self)
self._add_action('FilterEdit', None, _('Event Filter Editor'), self._add_action('FilterEdit', None, _('Event Filter Editor'),
callback=self.filter_editor,) callback=self.filter_editor,)
self._add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor'), callback=self._column_editor,)
self._add_action('QuickReport', None, self._add_action('QuickReport', None,
_("Quick View"), None, None, None) _("Quick View"), None, None, None)
self._add_action('Dummy', None, self._add_action('Dummy', None,
@ -217,19 +220,6 @@ class EventView(ListView):
else: else:
return None return None
def _column_editor(self, obj):
"""
returns a tuple indicating the column order
"""
import ColumnOrder
ColumnOrder.ColumnOrder(
_('Select Event Columns'),
self.uistate,
self.dbstate.db.get_event_column_order(),
EventView.COLUMN_NAMES,
self.set_column_order)
def add(self, obj): def add(self, obj):
try: try:
EditEvent(self.dbstate, self.uistate, [], gen.lib.Event()) EditEvent(self.dbstate, self.uistate, [], gen.lib.Event())

View File

@ -59,7 +59,16 @@ from gen.plug import CATEGORY_QR_FAMILY
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class FamilyView(ListView): class FamilyView(ListView):
""" FamilyView class, derived from the ListView
"""
# columns in the model used in view
COL_ID = 0
COL_FATHER = 1
COL_MOTHER = 2
COL_REL = 3
COL_MARDATE = 4
COL_CHAN = 5
# name of the columns
COLUMN_NAMES = [ COLUMN_NAMES = [
_('ID'), _('ID'),
_('Father'), _('Father'),
@ -68,6 +77,14 @@ class FamilyView(ListView):
_('Marriage Date'), _('Marriage Date'),
_('Last Changed'), _('Last Changed'),
] ]
#default setting with visible columns, order of the col, and their size
CONFIGSETTINGS = (
('columns.visible', [COL_ID, COL_FATHER, COL_MOTHER, COL_REL,
COL_MARDATE]),
('columns.order', [COL_ID, COL_FATHER, COL_MOTHER, COL_REL,
COL_MARDATE, COL_CHAN]),
('columns.sizecol', [75, 200, 200, 100, 100, 100])
)
ADD_MSG = _("Add a new family") ADD_MSG = _("Add a new family")
EDIT_MSG = _("Edit the selected family") EDIT_MSG = _("Edit the selected family")
@ -103,22 +120,6 @@ class FamilyView(ListView):
def navigation_type(self): def navigation_type(self):
return 'Family' return 'Family'
def column_ord_setfunc(self, clist):
self.dbstate.db.set_family_list_column_order(clist)
def column_order(self):
return self.dbstate.db.get_family_list_column_order()
def _column_editor(self, obj):
import ColumnOrder
ColumnOrder.ColumnOrder(
_('Select Family Columns'),
self.uistate,
self.dbstate.db.get_family_list_column_order(),
FamilyView.COLUMN_NAMES,
self.set_column_order)
def get_stock(self): def get_stock(self):
return 'gramps-family' return 'gramps-family'
@ -143,7 +144,6 @@ class FamilyView(ListView):
<menuitem action="Edit"/> <menuitem action="Edit"/>
<menuitem action="Remove"/> <menuitem action="Remove"/>
</placeholder> </placeholder>
<menuitem action="ColumnEdit"/>
<menuitem action="FilterEdit"/> <menuitem action="FilterEdit"/>
</menu> </menu>
<menu action="BookMenu"> <menu action="BookMenu">
@ -182,8 +182,6 @@ class FamilyView(ListView):
"""Add the Forward action group to handle the Forward button.""" """Add the Forward action group to handle the Forward button."""
ListView.define_actions(self) ListView.define_actions(self)
self._add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor...'), callback=self._column_editor)
self._add_action('FilterEdit', None, _('Family Filter Editor'), self._add_action('FilterEdit', None, _('Family Filter Editor'),
callback=self.filter_editor,) callback=self.filter_editor,)

View File

@ -75,7 +75,13 @@ class MediaView(ListView):
thumbnail image at the top of the view that must be updated when the thumbnail image at the top of the view that must be updated when the
selection changes or when the selected media object changes. selection changes or when the selected media object changes.
""" """
COL_TITLE = 0
COL_ID = 1
COL_TYPE = 2
COL_PATH = 3
COL_CHAN = 4
COL_DATE = 5
#name of the columns
COLUMN_NAMES = [ COLUMN_NAMES = [
_('Title'), _('Title'),
_('ID'), _('ID'),
@ -84,6 +90,14 @@ class MediaView(ListView):
_('Last Changed'), _('Last Changed'),
_('Date'), _('Date'),
] ]
# default setting with visible columns, order of the col, and their size
CONFIGSETTINGS = (
('columns.visible', [COL_TITLE, COL_ID, COL_TYPE, COL_PATH,
COL_DATE]),
('columns.order', [COL_TITLE, COL_ID, COL_TYPE, COL_PATH,
COL_DATE, COL_CHAN]),
('columns.sizecol', [200, 75, 100, 200, 150, 150])
)
ADD_MSG = _("Add a new media object") ADD_MSG = _("Add a new media object")
EDIT_MSG = _("Edit the selected media object") EDIT_MSG = _("Edit the selected media object")
@ -122,9 +136,6 @@ class MediaView(ListView):
def navigation_type(self): def navigation_type(self):
return 'Media' return 'Media'
def column_ord_setfunc(self, clist):
self.dbstate.db.set_media_column_order(clist)
def _set_dnd(self): def _set_dnd(self):
""" """
Set up drag-n-drop. The source and destination are set by calling .target() Set up drag-n-drop. The source and destination are set by calling .target()
@ -219,8 +230,6 @@ class MediaView(ListView):
""" """
ListView.define_actions(self) ListView.define_actions(self)
self._add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor'), callback=self._column_editor)
self._add_action('FilterEdit', None, _('Media Filter Editor'), self._add_action('FilterEdit', None, _('Media Filter Editor'),
callback=self.filter_editor) callback=self.filter_editor)
self._add_action('OpenMedia', 'gramps-viewmedia', _('View'), self._add_action('OpenMedia', 'gramps-viewmedia', _('View'),
@ -254,25 +263,6 @@ class MediaView(ListView):
mfolder, mfile = os.path.split(mpath) mfolder, mfile = os.path.split(mpath)
open_file_with_default_application(mfolder) open_file_with_default_application(mfolder)
def _column_editor(self, obj):
"""
Start the column editor dialog
"""
import ColumnOrder
ColumnOrder.ColumnOrder(
_('Select Media Columns'),
self.uistate,
self.dbstate.db.get_media_column_order(),
MediaView.COLUMN_NAMES,
self.set_column_order)
def column_order(self):
"""
Get the column order from the database
"""
return self.dbstate.db.get_media_column_order()
def get_stock(self): def get_stock(self):
""" """
Return the icon for this view Return the icon for this view
@ -354,7 +344,6 @@ class MediaView(ListView):
<menuitem action="Edit"/> <menuitem action="Edit"/>
<menuitem action="Remove"/> <menuitem action="Remove"/>
</placeholder> </placeholder>
<menuitem action="ColumnEdit"/>
<menuitem action="FilterEdit"/> <menuitem action="FilterEdit"/>
</menu> </menu>
<menu action="BookMenu"> <menu action="BookMenu">

View File

@ -50,7 +50,6 @@ import Utils
import Errors import Errors
import Bookmarks import Bookmarks
import config import config
import ColumnOrder
from gen.lib import Note from gen.lib import Note
from DdTargets import DdTargets from DdTargets import DdTargets
from Filters.SideBar import NoteSidebarFilter from Filters.SideBar import NoteSidebarFilter
@ -63,13 +62,28 @@ from gen.plug import CATEGORY_QR_NOTE
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class NoteView(ListView): class NoteView(ListView):
"""
Noteview, a normal flat listview for the notes
"""
COL_PREVIEW = 0
COL_ID = 1
COL_TYPE = 2
COL_MARKER = 3
COL_CHAN = 4
COLUMN_NAMES = [ COLUMN_NAMES = [
_('Preview'), _('Preview'),
_('ID'), _('ID'),
_('Type'), _('Type'),
_('Marker'), _('Marker'),
_('Last Changed')
] ]
# default setting with visible columns, order of the col, and their size
CONFIGSETTINGS = (
('columns.visible', [COL_PREVIEW, COL_ID, COL_TYPE, COL_MARKER]),
('columns.order', [COL_PREVIEW, COL_ID, COL_TYPE, COL_MARKER,
COL_CHAN]),
('columns.sizecol', [350, 75, 100, 100, 100]))
ADD_MSG = _("Add a new note") ADD_MSG = _("Add a new note")
EDIT_MSG = _("Edit the selected note") EDIT_MSG = _("Edit the selected note")
@ -105,9 +119,6 @@ class NoteView(ListView):
def navigation_type(self): def navigation_type(self):
return 'Note' return 'Note'
def column_ord_setfunc(self, clist):
self.dbstate.db.set_note_column_order(clist)
def get_bookmarks(self): def get_bookmarks(self):
""" """
Return the bookmark object Return the bookmark object
@ -120,12 +131,6 @@ class NoteView(ListView):
""" """
return DdTargets.NOTE_LINK return DdTargets.NOTE_LINK
def column_order(self):
"""
returns a tuple indicating the column order
"""
return self.dbstate.db.get_note_column_order()
def get_stock(self): def get_stock(self):
""" """
Use the gramps-event stock icon Use the gramps-event stock icon
@ -162,7 +167,6 @@ class NoteView(ListView):
<menuitem action="Edit"/> <menuitem action="Edit"/>
<menuitem action="Remove"/> <menuitem action="Remove"/>
</placeholder> </placeholder>
<menuitem action="ColumnEdit"/>
<menuitem action="FilterEdit"/> <menuitem action="FilterEdit"/>
</menu> </menu>
</menubar> </menubar>
@ -200,8 +204,6 @@ class NoteView(ListView):
def define_actions(self): def define_actions(self):
ListView.define_actions(self) ListView.define_actions(self)
self._add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor'), callback=self._column_editor)
self._add_action('FilterEdit', None, _('Note Filter Editor'), self._add_action('FilterEdit', None, _('Note Filter Editor'),
callback=self.filter_editor,) callback=self.filter_editor,)
self._add_action('QuickReport', None, _("Quick View"), None, None, None) self._add_action('QuickReport', None, _("Quick View"), None, None, None)
@ -214,17 +216,6 @@ class NoteView(ListView):
else: else:
return None return None
def _column_editor(self, obj):
"""
returns a tuple indicating the column order
"""
ColumnOrder.ColumnOrder(
_('Select Note Columns'),
self.uistate,
self.dbstate.db.get_note_column_order(),
NoteView.COLUMN_NAMES,
self.set_column_order)
def add(self, obj): def add(self, obj):
try: try:
EditNote(self.dbstate, self.uistate, [], Note()) EditNote(self.dbstate, self.uistate, [], Note())

View File

@ -73,8 +73,18 @@ from gen.ggettext import sgettext as _
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class PersonView(ListView): class PersonView(ListView):
""" """
PersonView class, derived from the ListView PersonView class, derived from the ListView, a treeview
""" """
COL_NAME = 0
COL_ID = 1
COL_GEN = 2
COL_BDAT = 3
COL_BPLAC = 4
COL_DDAT = 5
COL_DPLAC = 6
COL_SPOUSE = 7
COL_CHAN = 8
#name of the columns
COLUMN_NAMES = [ COLUMN_NAMES = [
_('Name'), _('Name'),
_('ID'), _('ID'),
@ -86,7 +96,13 @@ class PersonView(ListView):
_('Spouse'), _('Spouse'),
_('Last Changed'), _('Last Changed'),
] ]
# default setting with visible columns, order of the col, and their size
CONFIGSETTINGS = (
('columns.visible', [COL_NAME, COL_ID, COL_GEN, COL_BDAT, COL_DDAT]),
('columns.order', [COL_NAME, COL_ID, COL_GEN, COL_BDAT, COL_BPLAC,
COL_DDAT, COL_DPLAC, COL_SPOUSE, COL_CHAN]),
('columns.sizecol', [250, 75, 75, 100, 175, 100, 175, 100, 100])
)
ADD_MSG = _("Add a new person") ADD_MSG = _("Add a new person")
EDIT_MSG = _("Edit the selected person") EDIT_MSG = _("Edit the selected person")
DEL_MSG = _("Delete the selected person") DEL_MSG = _("Delete the selected person")
@ -127,9 +143,6 @@ class PersonView(ListView):
""" """
return LISTTREE return LISTTREE
def column_ord_setfunc(self, clist):
self.dbstate.db.set_person_column_order(clist)
def navigation_type(self): def navigation_type(self):
return 'Person' return 'Person'
@ -151,17 +164,11 @@ class PersonView(ListView):
""" """
return DdTargets.PERSON_LINK_LIST return DdTargets.PERSON_LINK_LIST
def column_order(self):
"""
returns a tuple indicating the column order
"""
return self.dbstate.db.get_person_column_order()
def exact_search(self): def exact_search(self):
""" """
Returns a tuple indicating columns requiring an exact search Returns a tuple indicating columns requiring an exact search
""" """
return (2,) # Gender ('female' contains the string 'male') return (PersonView.COL_GEN,) # Gender ('female' contains the string 'male')
def get_stock(self): def get_stock(self):
""" """
@ -207,7 +214,6 @@ class PersonView(ListView):
<menuitem action="Remove"/> <menuitem action="Remove"/>
</placeholder> </placeholder>
<menuitem action="SetActive"/> <menuitem action="SetActive"/>
<menuitem action="ColumnEdit"/>
<menuitem action="FilterEdit"/> <menuitem action="FilterEdit"/>
<placeholder name="Merge"> <placeholder name="Merge">
<menuitem action="CmpMerge"/> <menuitem action="CmpMerge"/>
@ -252,19 +258,6 @@ class PersonView(ListView):
else: else:
return None return None
def _column_editor(self, obj):
"""
returns a tuple indicating the column order
"""
import ColumnOrder
ColumnOrder.ColumnOrder(
_('Select Person Columns'),
self.uistate,
self.dbstate.db.get_person_column_order(),
PersonView.COLUMN_NAMES,
self.set_column_order)
def add(self, obj): def add(self, obj):
person = gen.lib.Person() person = gen.lib.Person()
@ -391,9 +384,7 @@ class PersonView(ListView):
('Add', gtk.STOCK_ADD, _("_Add..."), "<control>Insert", ('Add', gtk.STOCK_ADD, _("_Add..."), "<control>Insert",
_("Add a new person"), self.add), _("Add a new person"), self.add),
('Remove', gtk.STOCK_REMOVE, _("_Remove"), "<control>Delete", ('Remove', gtk.STOCK_REMOVE, _("_Remove"), "<control>Delete",
_("Remove the Selected Person"), self.remove), _("Remove the Selected Person"), self.remove),
('ColumnEdit', gtk.STOCK_PROPERTIES, _('_Column Editor...'), None,
None, self._column_editor),
('CmpMerge', None, _('Compare and _Merge...'), None, None, ('CmpMerge', None, _('Compare and _Merge...'), None, None,
self.cmp_merge), self.cmp_merge),
('FastMerge', None, _('_Fast Merge...'), None, None, ('FastMerge', None, _('_Fast Merge...'), None, None,

View File

@ -107,7 +107,6 @@ class PlaceTreeView(PlaceBaseView):
<menuitem action="Edit"/> <menuitem action="Edit"/>
<menuitem action="Remove"/> <menuitem action="Remove"/>
</placeholder> </placeholder>
<menuitem action="ColumnEdit"/>
<menuitem action="FilterEdit"/> <menuitem action="FilterEdit"/>
<placeholder name="Merge"> <placeholder name="Merge">
<menuitem action="FastMerge"/> <menuitem action="FastMerge"/>

View File

@ -61,6 +61,21 @@ from gen.ggettext import gettext as _
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class RepositoryView(ListView): class RepositoryView(ListView):
""" repository listview class
"""
COL_NAME = 0
COL_ID = 1
COL_TYPE = 2
COL_URL = 3
COL_STREET = 4
COL_ZIP = 5
COL_CITY = 6
COL_COUNTY = 7
COL_STATE = 8
COL_COUNTRY = 9
COL_EMAIL = 10
COL_SURL = 11
COL_CHAN = 12
COLUMN_NAMES = [ COLUMN_NAMES = [
_('Name'), _('Name'),
@ -77,7 +92,17 @@ class RepositoryView(ListView):
_('Search URL'), _('Search URL'),
_('Last Changed'), _('Last Changed'),
] ]
# default setting with visible columns, order of the col, and their size
CONFIGSETTINGS = (
('columns.visible', [COL_NAME, COL_ID, COL_TYPE, COL_URL, COL_STREET,
]),
('columns.order', [COL_NAME, COL_ID, COL_ZIP, COL_CITY, COL_TYPE,
COL_URL, COL_STREET, COL_COUNTY, COL_STATE,
COL_COUNTRY, COL_EMAIL, COL_SURL,
COL_CHAN]),
('columns.sizecol', [200, 75, 100, 100, 100, 250, 100, 100, 100,
100, 100, 100, 100])
)
ADD_MSG = _("Add a new repository") ADD_MSG = _("Add a new repository")
EDIT_MSG = _("Edit the selected repository") EDIT_MSG = _("Edit the selected repository")
DEL_MSG = _("Delete the selected repository") DEL_MSG = _("Delete the selected repository")
@ -113,9 +138,6 @@ class RepositoryView(ListView):
def navigation_type(self): def navigation_type(self):
return 'Repository' return 'Repository'
def column_ord_setfunc(self, clist):
self.dbstate.db.set_repository_column_order(clist)
def get_bookmarks(self): def get_bookmarks(self):
return self.dbstate.db.get_repo_bookmarks() return self.dbstate.db.get_repo_bookmarks()
@ -124,8 +146,6 @@ class RepositoryView(ListView):
def define_actions(self): def define_actions(self):
ListView.define_actions(self) ListView.define_actions(self)
self._add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor'), callback=self._column_editor)
self._add_action('FilterEdit', None, _('Repository Filter Editor'), self._add_action('FilterEdit', None, _('Repository Filter Editor'),
callback=self.filter_editor,) callback=self.filter_editor,)
self._add_action('QuickReport', None, self._add_action('QuickReport', None,
@ -133,19 +153,6 @@ class RepositoryView(ListView):
self._add_action('Dummy', None, self._add_action('Dummy', None,
' ', None, None, self.dummy_report) ' ', None, None, self.dummy_report)
def _column_editor(self, obj):
import ColumnOrder
ColumnOrder.ColumnOrder(
_('Select Repository Columns'),
self.uistate,
self.dbstate.db.get_repository_column_order(),
RepositoryView.COLUMN_NAMES,
self.set_column_order)
def column_order(self):
return self.dbstate.db.get_repository_column_order()
def get_stock(self): def get_stock(self):
return 'gramps-repository' return 'gramps-repository'
@ -176,7 +183,6 @@ class RepositoryView(ListView):
<menuitem action="Edit"/> <menuitem action="Edit"/>
<menuitem action="Remove"/> <menuitem action="Remove"/>
</placeholder> </placeholder>
<menuitem action="ColumnEdit"/>
<menuitem action="FilterEdit"/> <menuitem action="FilterEdit"/>
</menu> </menu>
</menubar> </menubar>

View File

@ -63,7 +63,15 @@ from gen.ggettext import gettext as _
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class SourceView(ListView): class SourceView(ListView):
""" sources listview class
"""
COL_TITLE = 0
COL_ID = 1
COL_AUTH = 2
COL_ABBR = 3
COL_PINFO = 4
COL_CHAN = 5
# name of the columns
COLUMN_NAMES = [ COLUMN_NAMES = [
_('Title'), _('Title'),
_('ID'), _('ID'),
@ -72,7 +80,13 @@ class SourceView(ListView):
_('Publication Information'), _('Publication Information'),
_('Last Changed'), _('Last Changed'),
] ]
# default setting with visible columns, order of the col, and their size
CONFIGSETTINGS = (
('columns.visible', [COL_TITLE, COL_ID, COL_AUTH, COL_PINFO]),
('columns.order', [COL_TITLE, COL_ID, COL_AUTH, COL_ABBR, COL_PINFO,
COL_CHAN]),
('columns.sizecol', [200, 75, 150, 100, 150, 100])
)
ADD_MSG = _("Add a new source") ADD_MSG = _("Add a new source")
EDIT_MSG = _("Edit the selected source") EDIT_MSG = _("Edit the selected source")
DEL_MSG = _("Delete the selected source") DEL_MSG = _("Delete the selected source")
@ -108,9 +122,6 @@ class SourceView(ListView):
def navigation_type(self): def navigation_type(self):
return 'Source' return 'Source'
def column_ord_setfunc(self, clist):
self.dbstate.db.set_source_column_order(clist)
def get_bookmarks(self): def get_bookmarks(self):
return self.dbstate.db.get_source_bookmarks() return self.dbstate.db.get_source_bookmarks()
@ -119,8 +130,6 @@ class SourceView(ListView):
def define_actions(self): def define_actions(self):
ListView.define_actions(self) ListView.define_actions(self)
self._add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
_('_Column Editor'), callback=self._column_editor)
self._add_action('FastMerge', None, _('_Merge'), self._add_action('FastMerge', None, _('_Merge'),
callback=self.fast_merge) callback=self.fast_merge)
self._add_action('FilterEdit', None, _('Source Filter Editor'), self._add_action('FilterEdit', None, _('Source Filter Editor'),
@ -128,19 +137,6 @@ class SourceView(ListView):
self._add_action('QuickReport', None, _("Quick View"), None, None, None) self._add_action('QuickReport', None, _("Quick View"), None, None, None)
self._add_action('Dummy', None, ' ', None, None, self.dummy_report) self._add_action('Dummy', None, ' ', None, None, self.dummy_report)
def _column_editor(self, obj):
import ColumnOrder
ColumnOrder.ColumnOrder(
_('Select Source Columns'),
self.uistate,
self.dbstate.db.get_source_column_order(),
SourceView.COLUMN_NAMES,
self.set_column_order)
def column_order(self):
return self.dbstate.db.get_source_column_order()
def get_stock(self): def get_stock(self):
return 'gramps-source' return 'gramps-source'
@ -171,7 +167,6 @@ class SourceView(ListView):
<menuitem action="Edit"/> <menuitem action="Edit"/>
<menuitem action="Remove"/> <menuitem action="Remove"/>
</placeholder> </placeholder>
<menuitem action="ColumnEdit"/>
<menuitem action="FilterEdit"/> <menuitem action="FilterEdit"/>
<placeholder name="Merge"> <placeholder name="Merge">
<menuitem action="FastMerge"/> <menuitem action="FastMerge"/>