* src/Bookmarks.py: pylint fixes
* src/ColumnOrder.py: pylint fixes * src/DateEdit.py: pylint fixes * src/DbLoader.py: pylint fixes * src/ManagedWindow.py: pylint fixes 2007-05-19 Don Allingham <don@gramps-project.org> svn: r8498
This commit is contained in:
parent
659814e22d
commit
a598df4f6d
@ -1,3 +1,10 @@
|
||||
2007-05-19 Don Allingham <don@gramps-project.org>
|
||||
* src/Bookmarks.py: pylint fixes
|
||||
* src/ColumnOrder.py: pylint fixes
|
||||
* src/DateEdit.py: pylint fixes
|
||||
* src/DbLoader.py: pylint fixes
|
||||
* src/ManagedWindow.py: pylint fixes
|
||||
|
||||
2007-05-19 Don Allingham <don@gramps-project.org>
|
||||
* src/AutoComp.py: removal of unused functions
|
||||
* src/BaseDoc.py: clean up and add documentation
|
||||
|
@ -89,18 +89,34 @@ class Bookmarks :
|
||||
self.dbstate.connect('database-changed', self.db_changed)
|
||||
|
||||
def db_changed(self, data):
|
||||
"""
|
||||
Reconnect the signals on a database changed.
|
||||
"""
|
||||
self.connect_signals()
|
||||
|
||||
def connect_signals(self):
|
||||
"""
|
||||
Connect the person-delete signal
|
||||
"""
|
||||
self.dbstate.db.connect('person-delete', self.remove_handles)
|
||||
|
||||
def update_bookmarks(self, bookmarks):
|
||||
"""
|
||||
Assign bookmarks
|
||||
"""
|
||||
self.bookmarks = bookmarks
|
||||
|
||||
def display(self):
|
||||
"""
|
||||
|
||||
Redraw teh display
|
||||
"""
|
||||
self.redraw()
|
||||
|
||||
def undisplay(self):
|
||||
"""
|
||||
Update the uimanager
|
||||
"""
|
||||
if self.active != DISABLED:
|
||||
self.uistate.uimanager.remove_ui(self.active)
|
||||
self.uistate.uimanager.remove_action_group(self.action_group)
|
||||
@ -108,8 +124,8 @@ class Bookmarks :
|
||||
|
||||
def redraw(self):
|
||||
"""Create the pulldown menu"""
|
||||
f = StringIO()
|
||||
f.write(_top)
|
||||
text = StringIO()
|
||||
text.write(_top)
|
||||
|
||||
self.undisplay()
|
||||
|
||||
@ -117,7 +133,7 @@ class Bookmarks :
|
||||
count = 0
|
||||
|
||||
if len(self.bookmarks.get()) > 0:
|
||||
f.write('<placeholder name="GoToBook">')
|
||||
text.write('<placeholder name="GoToBook">')
|
||||
|
||||
new_list = []
|
||||
for item in self.bookmarks.get():
|
||||
@ -126,20 +142,20 @@ class Bookmarks :
|
||||
func = self.callback(item)
|
||||
action_id = "BM:%s" % item
|
||||
actions.append((action_id, None, label, None, None, func))
|
||||
f.write('<menuitem action="%s"/>' % action_id)
|
||||
text.write('<menuitem action="%s"/>' % action_id)
|
||||
count += 1
|
||||
new_list.append(item)
|
||||
except AttributeError:
|
||||
pass
|
||||
f.write('</placeholder>')
|
||||
text.write('</placeholder>')
|
||||
self.bookmarks.set(new_list)
|
||||
|
||||
f.write(_btm)
|
||||
text.write(_btm)
|
||||
self.action_group.add_actions(actions)
|
||||
self.uistate.uimanager.insert_action_group(self.action_group, 1)
|
||||
self.active = self.uistate.uimanager.add_ui_from_string(f.getvalue())
|
||||
self.active = self.uistate.uimanager.add_ui_from_string(text.getvalue())
|
||||
self.uistate.uimanager.ensure_update()
|
||||
f.close()
|
||||
text.close()
|
||||
|
||||
def make_label(self, handle):
|
||||
person = self.dbstate.db.get_person_from_handle(handle)
|
||||
@ -289,7 +305,6 @@ class ListBookmarks(Bookmarks):
|
||||
def do_callback(self, handle):
|
||||
self.goto_handle(handle)
|
||||
|
||||
|
||||
class FamilyBookmarks(ListBookmarks) :
|
||||
"Handle the bookmarks interface for Gramps"
|
||||
|
||||
|
@ -18,16 +18,31 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
"""
|
||||
Handle the column ordering
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/Gnome modules
|
||||
# python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
import logging
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk.glade
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
from gettext import gettext as _
|
||||
|
||||
import ManagedWindow
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -35,13 +50,18 @@ import ManagedWindow
|
||||
# set up logging
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import logging
|
||||
log = logging.getLogger(".ColumnOrder")
|
||||
__LOG = logging.getLogger(".ColumnOrder")
|
||||
|
||||
|
||||
class ColumnOrder(ManagedWindow.ManagedWindow):
|
||||
"""
|
||||
Column ordering selection dialog
|
||||
"""
|
||||
|
||||
def __init__(self, win_name, uistate, arglist, column_names, callback):
|
||||
|
||||
"""
|
||||
Create the Column Ordering dialog
|
||||
"""
|
||||
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self)
|
||||
|
||||
self.glade = gtk.glade.XML(const.gladeFile, "columns", "gramps")
|
||||
@ -57,7 +77,7 @@ class ColumnOrder(ManagedWindow.ManagedWindow):
|
||||
self.tree.set_model(self.model)
|
||||
|
||||
checkbox = gtk.CellRendererToggle()
|
||||
checkbox.connect('toggled', self.toggled, self.model)
|
||||
checkbox.connect('toggled', __toggled, self.model)
|
||||
renderer = gtk.CellRendererText()
|
||||
|
||||
column_n = gtk.TreeViewColumn(_('Display'), checkbox, active=0)
|
||||
@ -82,9 +102,15 @@ class ColumnOrder(ManagedWindow.ManagedWindow):
|
||||
3, item)
|
||||
|
||||
def build_menu_names(self, obj):
|
||||
"""
|
||||
Build the information for the Managed Window menu entries
|
||||
"""
|
||||
return (_('Column Editor'), _('Column Editor'))
|
||||
|
||||
def ok_clicked(self, obj):
|
||||
"""
|
||||
called with the OK button is pressed
|
||||
"""
|
||||
newlist = []
|
||||
for i in range(0, len(self.arglist)):
|
||||
node = self.model.get_iter((int(i), ))
|
||||
@ -97,9 +123,16 @@ class ColumnOrder(ManagedWindow.ManagedWindow):
|
||||
self.close()
|
||||
|
||||
def cancel_clicked(self, obj):
|
||||
"""
|
||||
Called with the Cancel button is pressed.
|
||||
"""
|
||||
self.close()
|
||||
|
||||
def toggled(self, cell, path, model):
|
||||
def __toggled(cell, path, model):
|
||||
"""
|
||||
Called when the cell information is changed, updating the
|
||||
data model so the that change occurs.
|
||||
"""
|
||||
node = model.get_iter((int(path), ))
|
||||
value = not model.get_value(node, 0)
|
||||
model.set(node, 0, value)
|
||||
|
@ -49,7 +49,7 @@ from gettext import gettext as _
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import logging
|
||||
log = logging.getLogger(".DateEdit")
|
||||
__LOG = logging.getLogger(".DateEdit")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -31,10 +31,17 @@ Handling of loading new/existing databases.
|
||||
#-------------------------------------------------------------------------
|
||||
import os
|
||||
import sys
|
||||
from bsddb.db import DBAccessError, DBRunRecoveryError, DBPageNotFoundError, DBInvalidArgError
|
||||
from bsddb.db import DBAccessError, DBRunRecoveryError, \
|
||||
DBPageNotFoundError, DBInvalidArgError
|
||||
from gettext import gettext as _
|
||||
import logging
|
||||
log = logging.getLogger(".")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
__LOG = logging.getLogger(".")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -68,6 +75,8 @@ _KNOWN_FORMATS = {
|
||||
const.app_gedcom : _('GEDCOM'),
|
||||
}
|
||||
|
||||
__OPEN_FORMATS = [const.app_gramps, const.app_gramps_xml, const.app_gedcom]
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# DbLoader class
|
||||
@ -92,9 +101,7 @@ class DbLoader:
|
||||
add_xml_filter(choose)
|
||||
add_gedcom_filter(choose)
|
||||
|
||||
format_list = [const.app_gramps,const.app_gramps_xml,const.app_gedcom]
|
||||
|
||||
(box, type_selector) = format_maker(format_list)
|
||||
(box, type_selector) = format_maker(__OPEN_FORMATS)
|
||||
choose.set_extra_widget(box)
|
||||
|
||||
choose.set_current_folder(get_default_dir())
|
||||
@ -110,9 +117,7 @@ class DbLoader:
|
||||
filetype = Mime.get_type(filename)
|
||||
(the_path, the_file) = os.path.split(filename)
|
||||
choose.destroy()
|
||||
if filetype in [const.app_gramps,const.app_gramps_xml,
|
||||
const.app_gedcom]:
|
||||
|
||||
if filetype in __OPEN_FORMATS:
|
||||
self.read_file(filename, filetype)
|
||||
try:
|
||||
os.chdir(os.path.dirname(filename))
|
||||
@ -208,8 +213,7 @@ class DbLoader:
|
||||
add_xml_filter(choose)
|
||||
add_gedcom_filter(choose)
|
||||
|
||||
format_list = [const.app_gramps,const.app_gramps_xml,const.app_gedcom]
|
||||
(box, type_selector) = format_maker(format_list)
|
||||
(box, type_selector) = format_maker(__OPEN_FORMATS)
|
||||
choose.set_extra_widget(box)
|
||||
|
||||
default_dir = get_default_dir()
|
||||
@ -242,9 +246,7 @@ class DbLoader:
|
||||
str(msg))
|
||||
return ('','')
|
||||
# First we try our best formats
|
||||
if filetype not in (const.app_gramps,
|
||||
const.app_gramps_xml,
|
||||
const.app_gedcom):
|
||||
if filetype not in _OPEN_FORMATS:
|
||||
QuestionDialog.ErrorDialog(
|
||||
_("Could not open file: %s") % filename,
|
||||
_("Unknown type: %s") % filetype
|
||||
@ -288,7 +290,7 @@ class DbLoader:
|
||||
add_xml_filter(choose)
|
||||
add_gedcom_filter(choose)
|
||||
|
||||
format_list = [const.app_gramps,const.app_gramps_xml,const.app_gedcom]
|
||||
format_list = _OPEN_FORMATS
|
||||
|
||||
# Add more data type selections if opening existing db
|
||||
for data in import_list:
|
||||
@ -334,9 +336,7 @@ class DbLoader:
|
||||
return False
|
||||
|
||||
# First we try our best formats
|
||||
if filetype in (const.app_gramps,
|
||||
const.app_gramps_xml,
|
||||
const.app_gedcom):
|
||||
if filetype in _OPEN_FORMATS:
|
||||
importer = GrampsDbUtils.gramps_db_reader_factory(filetype)
|
||||
self.do_import(choose, importer, filename)
|
||||
return True
|
||||
@ -471,7 +471,7 @@ class DbLoader:
|
||||
_("Could not open file: %s") % filename,
|
||||
str(msg[1]))
|
||||
except Exception:
|
||||
log.error("Failed to open database.", exc_info=True)
|
||||
__LOG.error("Failed to open database.", exc_info=True)
|
||||
|
||||
return True
|
||||
|
||||
@ -493,7 +493,7 @@ class DbLoader:
|
||||
self.uistate.pulse_progressbar)
|
||||
old_database.close()
|
||||
except Exception:
|
||||
log.error("Failed to open database.", exc_info=True)
|
||||
__LOG.error("Failed to open database.", exc_info=True)
|
||||
return False
|
||||
|
||||
def do_import(self, dialog, importer, filename):
|
||||
@ -506,7 +506,7 @@ class DbLoader:
|
||||
dirname = os.path.dirname(filename) + os.path.sep
|
||||
Config.set(Config.RECENT_IMPORT_DIR, dirname)
|
||||
except Exception:
|
||||
log.error("Failed to import database.", exc_info=True)
|
||||
__LOG.error("Failed to import database.", exc_info=True)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -549,9 +549,8 @@ def add_gramps_files_filter(chooser):
|
||||
"""
|
||||
mime_filter = gtk.FileFilter()
|
||||
mime_filter.set_name(_('All GRAMPS files'))
|
||||
mime_filter.add_mime_type(const.app_gramps)
|
||||
mime_filter.add_mime_type(const.app_gramps_xml)
|
||||
mime_filter.add_mime_type(const.app_gedcom)
|
||||
for fmt in __OPEN_FORMATS:
|
||||
mime_filter.add_mime_type(fmt)
|
||||
chooser.add_filter(mime_filter)
|
||||
|
||||
def add_grdb_filter(chooser):
|
||||
|
@ -20,6 +20,11 @@
|
||||
|
||||
# $Id: DisplayState.py 6085 2006-03-05 23:39:20Z dallingham $
|
||||
|
||||
"""
|
||||
Provides the managed window interface, which allows GRAMPS to track
|
||||
the create/deletion of dialog windows.
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard python modules
|
||||
@ -210,13 +215,13 @@ class GrampsWindowManager:
|
||||
|
||||
def call_back_factory(self, item):
|
||||
if type(item) != list:
|
||||
def f(obj):
|
||||
def func(obj):
|
||||
if item.window_id and self.id2item.get(item.window_id):
|
||||
self.id2item[item.window_id].present()
|
||||
else:
|
||||
def f(obj):
|
||||
def func(obj):
|
||||
pass
|
||||
return f
|
||||
return func
|
||||
|
||||
def generate_id(self, item):
|
||||
return str(item.window_id)
|
||||
@ -393,12 +398,12 @@ class ManagedWindow:
|
||||
# Helper functions
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def set_titles(window,title,t,msg=None):
|
||||
def set_titles(window, title, text, msg=None):
|
||||
if title:
|
||||
title.set_text('<span weight="bold" size="larger">%s</span>' % t)
|
||||
title.set_text('<span weight="bold" size="larger">%s</span>' % text)
|
||||
title.set_use_markup(True)
|
||||
if msg:
|
||||
window.set_title('%s - GRAMPS' % msg)
|
||||
else:
|
||||
window.set_title('%s - GRAMPS' % t)
|
||||
window.set_title('%s - GRAMPS' % text)
|
||||
window.set_icon_from_file(const.icon)
|
||||
|
Loading…
x
Reference in New Issue
Block a user