* src/DataViews/_EventView.py: pychecker fixes

* src/ViewManager.py: call scratchpad properly
	* src/GrampsCfg.py: pychecker fixes
	* src/Editors/_EditEvent.py
	* src/DisplayModels.py:pychecker fixes
	* src/DisplayTabs.py: pychecker fixes
	* src/ScratchPad.py: use ManagedWindow
	* src/GenericFilter.py: pychecker fixes
	* src/ImgManip.py: pychecker fixes
	* src/PageView.py: pychecker fixes
	* src/ArgHandler.py: pychecker fixes


svn: r6389
This commit is contained in:
Don Allingham 2006-04-21 04:14:00 +00:00
parent 112a0aa332
commit 471694030c
12 changed files with 121 additions and 138 deletions

View File

@ -1,4 +1,15 @@
2006-04-20 Don Allingham <don@gramps-project.org> 2006-04-20 Don Allingham <don@gramps-project.org>
* src/DataViews/_EventView.py: pychecker fixes
* src/ViewManager.py: call scratchpad properly
* src/GrampsCfg.py: pychecker fixes
* src/Editors/_EditEvent.py
* src/DisplayModels.py:pychecker fixes
* src/DisplayTabs.py: pychecker fixes
* src/ScratchPad.py: use ManagedWindow
* src/GenericFilter.py: pychecker fixes
* src/ImgManip.py: pychecker fixes
* src/PageView.py: pychecker fixes
* src/ArgHandler.py: pychecker fixes
* src/Editors/_EditFamily.py: Handle marker type in UI * src/Editors/_EditFamily.py: Handle marker type in UI
* src/DataViews/_FamilyViews.py: clean up * src/DataViews/_FamilyViews.py: clean up
* src/DataViews/_PedigreeViews.py: clean up * src/DataViews/_PedigreeViews.py: clean up

View File

@ -26,6 +26,13 @@
Module responsible for handling the command line arguments for GRAMPS. Module responsible for handling the command line arguments for GRAMPS.
""" """
#-------------------------------------------------------------------------
#
# GNOME/GTK
#
#-------------------------------------------------------------------------
import gtk
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Standard python modules # Standard python modules
@ -46,6 +53,8 @@ import Mime
import QuestionDialog import QuestionDialog
import Config import Config
import RecentFiles import RecentFiles
import Utils
from PluginUtils import Report, Tool, cl_list, cli_tool_list from PluginUtils import Report, Tool, cl_list, cli_tool_list
#------------------------------------------------------------------------- #-------------------------------------------------------------------------

View File

@ -121,7 +121,7 @@ class EventView(PageView.ListView):
def define_actions(self): def define_actions(self):
PageView.ListView.define_actions(self) PageView.ListView.define_actions(self)
self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES, self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
'_Column Editor', callback=self.column_editor), '_Column Editor', callback=self.column_editor)
def column_editor(self,obj): def column_editor(self,obj):
import ColumnOrder import ColumnOrder

View File

@ -46,7 +46,6 @@ import gtk
import NameDisplay import NameDisplay
import DateHandler import DateHandler
import RelLib import RelLib
import Utils
import ToolTips import ToolTips
import GrampsLocale import GrampsLocale
import const import const
@ -694,7 +693,7 @@ class RepositoryModel(BaseModel):
return unicode(data[1]) return unicode(data[1])
def column_type(self,data): def column_type(self,data):
return Utils.format_repository_type(data[2]) return str(RelLib.RepositoryType(data[2]))
def column_name(self,data): def column_name(self,data):
return unicode(data[3]) return unicode(data[3])

View File

@ -2006,14 +2006,11 @@ class AttrModel(gtk.ListStore):
self.db = db self.db = db
for attr in attr_list: for attr in attr_list:
self.append(row=[ self.append(row=[
self.type_name(attr), str(attr.get_type()),
attr.get_value(), attr.get_value(),
attr, attr,
]) ])
def type_name(self, attr):
return Utils.format_attribute( attr.get_type())
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# LdsModel # LdsModel
@ -2168,11 +2165,12 @@ class RepoRefModel(gtk.ListStore):
self.db = db self.db = db
for ref in ref_list: for ref in ref_list:
repo = self.db.get_repository_from_handle(ref.ref) repo = self.db.get_repository_from_handle(ref.ref)
self.append(row=[repo.gramps_id, repo.name, ref.call_number, self.append(row=[
self.type_of(repo), ref, ]) repo.gramps_id,
repo.name,
def type_of(self, ref): ref.call_number,
return Utils.format_source_media_type(ref.get_type()) str(repo.get_type()),
ref, ])
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #

View File

@ -160,10 +160,8 @@ class EditEvent(EditPrimary):
self.backref_tab = self._add_tab( self.backref_tab = self._add_tab(
notebook, notebook,
EventBackRefList(self.dbstate, self.uistate, self.track, EventBackRefList(self.dbstate, self.uistate, self.track,
self.dbstate.db.find_backlink_handles(self.obj.handle), self.dbstate.db.find_backlink_handles(self.obj.handle)))
self.enable_warnbox
))
notebook.show_all() notebook.show_all()
self.top.get_widget('vbox').pack_start(notebook,True) self.top.get_widget('vbox').pack_start(notebook,True)

View File

@ -1642,7 +1642,7 @@ class IsWitness(Rule):
if not event_list: if not event_list:
return return
for event_ref in event_list: for event_ref in event_list:
if event_reg: if event_ref:
event = self.db.get_event_from_handle(event_ref.ref) event = self.db.get_event_from_handle(event_ref.ref)
if event_type and not event.get_name() == event_type: if event_type and not event.get_name() == event_type:
continue continue
@ -2630,8 +2630,8 @@ class FilterWidget:
def on_filter_name_changed(self,obj): def on_filter_name_changed(self,obj):
print "on_filter_name_changed" print "on_filter_name_changed"
index = self.filter_list.get_active() index = self.filter_list.get_active()
mime_filter = self.filter_model.get_filter(index) # mime_filter = self.filter_model.get_filter(index)
qual = mime_filter.need_param # qual = mime_filter.need_param
# if qual: # if qual:
# self.filter_text.show() # self.filter_text.show()
# self.filter_text.set_sensitive(True) # self.filter_text.set_sensitive(True)

View File

@ -46,7 +46,6 @@ import gtk.glade
import Config import Config
import RelLib import RelLib
import const import const
import Utils
import DateHandler import DateHandler
import GrampsDisplay import GrampsDisplay
import QuestionDialog import QuestionDialog

View File

@ -26,7 +26,6 @@
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import os import os
import signal
import md5 import md5
import tempfile import tempfile
@ -61,7 +60,8 @@ class ImgManip:
self.width = self.img.get_width() self.width = self.img.get_width()
self.height = self.img.get_height() self.height = self.img.get_height()
except gobject.GError: except gobject.GError:
return (0,0) self.width = 0
self.height = 0
def size(self): def size(self):
return (self.width, self.height) return (self.width, self.height)

View File

@ -71,6 +71,8 @@ class PageView:
self.dbstate.connect('database-changed',self.enable_action_group) self.dbstate.connect('database-changed',self.enable_action_group)
self.dirty = True self.dirty = True
self.active = False self.active = False
self.handle_col = 0
self.selection = None
def set_active(self): def set_active(self):
self.active = True self.active = True

View File

@ -30,7 +30,6 @@ import os
from xml.sax.saxutils import escape from xml.sax.saxutils import escape
from gettext import gettext as _ from gettext import gettext as _
import Utils import Utils
import RelLib
from time import strftime as strftime from time import strftime as strftime
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -48,10 +47,10 @@ from gtk.gdk import ACTION_COPY, BUTTON1_MASK
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import const import const
import Utils
import TreeTips import TreeTips
import DateHandler import DateHandler
import GrampsDisplay import GrampsDisplay
import ManagedWindow
from DdTargets import DdTargets from DdTargets import DdTargets
@ -74,9 +73,8 @@ BLANK_PIC = gtk.gdk.Pixbuf(0,0,8,1,1)
class ScratchPadWrapper(object): class ScratchPadWrapper(object):
def __init__(self,dbstate,obj): def __init__(self,db,obj):
self.dbstate = dbstate self.database_changed(db)
self.database_changed(dbstate.db)
self._db.connect('database-changed', self.database_changed) self._db.connect('database-changed', self.database_changed)
self._obj = obj self._obj = obj
@ -214,15 +212,15 @@ class ScratchPadEvent(ScratchPadWrapper):
DRAG_TARGET = DdTargets.EVENT DRAG_TARGET = DdTargets.EVENT
ICON = LINK_PIC ICON = LINK_PIC
def __init__(self,dbstate,obj): def __init__(self,db,obj):
ScratchPadWrapper.__init__(self,dbstate,obj) ScratchPadWrapper.__init__(self,db,obj)
self._type = _("Event Link") self._type = _("Event Link")
(drag_type, idval, handle, val) = pickle.loads(obj) (drag_type, idval, handle, val) = pickle.loads(obj)
value = dbstate.db.get_event_from_handle(handle) value = db.get_event_from_handle(handle)
self._title = Utils.format_personal_event(value.get_type()) self._title = str(value.get_type())
self._value = value.get_description() self._value = value.get_description()
def tooltip(self): def tooltip(self):
@ -261,13 +259,12 @@ class ScratchPadFamilyEvent(ScratchPadGrampsTypeWrapper):
DRAG_TARGET = DdTargets.FAMILY_EVENT DRAG_TARGET = DdTargets.FAMILY_EVENT
ICON = BLANK_PIC ICON = BLANK_PIC
def __init__(self,dbstate,obj): def __init__(self,db,obj):
ScratchPadGrampsTypeWrapper.__init__(self,dbstate,obj) ScratchPadGrampsTypeWrapper.__init__(self,db,obj)
self._type = _("Family Event") self._type = _("Family Event")
self._title = Utils.format_family_event(self._obj.get_name()) self._title = str(self._obj.get_type())
self._value = self._obj.get_description() self._value = self._obj.get_description()
def tooltip(self): def tooltip(self):
global escape global escape
@ -278,8 +275,8 @@ class ScratchPadFamilyEvent(ScratchPadGrampsTypeWrapper):
"\t<b>%s:</b>\t%s\n"\ "\t<b>%s:</b>\t%s\n"\
"\t<b>%s:</b>\t%s\n" % ( "\t<b>%s:</b>\t%s\n" % (
_("Family Event"), _("Family Event"),
_("Type"),escape(Utils.format_family_event(self._obj.get_name())), _("Type"),escape(str(self._obj.get_type())),
_("Date"),escape(DateHander.get_date(self._obj)), _("Date"),escape(DateHandler.get_date(self._obj)),
_("Place"),escape(place_title(self.db,self._obj)), _("Place"),escape(place_title(self.db,self._obj)),
_("Cause"),escape(self._obj.get_cause()), _("Cause"),escape(self._obj.get_cause()),
_("Description"), escape(self._obj.get_description())) _("Description"), escape(self._obj.get_description()))
@ -303,13 +300,12 @@ class ScratchPadUrl(ScratchPadGrampsTypeWrapper):
DRAG_TARGET = DdTargets.URL DRAG_TARGET = DdTargets.URL
ICON = BLANK_PIC ICON = BLANK_PIC
def __init__(self,dbstate,obj): def __init__(self,db,obj):
ScratchPadGrampsTypeWrapper.__init__(self,dbstate,obj) ScratchPadGrampsTypeWrapper.__init__(self,db,obj)
self._type = _("Url") self._type = _("Url")
self._title = self._obj.get_path() self._title = self._obj.get_path()
self._value = self._obj.get_description() self._value = self._obj.get_description()
def tooltip(self): def tooltip(self):
global escape global escape
return "<big><b>%s</b></big>\n\n"\ return "<big><b>%s</b></big>\n\n"\
@ -326,8 +322,8 @@ class ScratchPadAttribute(ScratchPadGrampsTypeWrapper):
DRAG_TARGET = DdTargets.ATTRIBUTE DRAG_TARGET = DdTargets.ATTRIBUTE
ICON = BLANK_PIC ICON = BLANK_PIC
def __init__(self,dbstate,obj): def __init__(self, db, obj):
ScratchPadGrampsTypeWrapper.__init__(self,dbstate,obj) ScratchPadGrampsTypeWrapper.__init__(self, db, obj)
self._type = _("Attribute") self._type = _("Attribute")
self._title = Utils.format_personal_attribute(self._obj.get_type()) self._title = Utils.format_personal_attribute(self._obj.get_type())
self._value = self._obj.get_value() self._value = self._obj.get_value()
@ -359,8 +355,8 @@ class ScratchPadFamilyAttribute(ScratchPadGrampsTypeWrapper):
DRAG_TARGET = DdTargets.FAMILY_ATTRIBUTE DRAG_TARGET = DdTargets.FAMILY_ATTRIBUTE
ICON = BLANK_PIC ICON = BLANK_PIC
def __init__(self,dbstate,obj): def __init__(self, db, obj):
ScratchPadGrampsTypeWrapper.__init__(self,dbstate,obj) ScratchPadGrampsTypeWrapper.__init__(self, db, obj)
self._type = _("Family Attribute") self._type = _("Family Attribute")
self._title = Utils.format_family_attribute(self._obj.get_type()) self._title = Utils.format_family_attribute(self._obj.get_type())
self._value = self._obj.get_value() self._value = self._obj.get_value()
@ -392,8 +388,8 @@ class ScratchPadSourceRef(ScratchPadGrampsTypeWrapper):
DRAG_TARGET = DdTargets.SOURCEREF DRAG_TARGET = DdTargets.SOURCEREF
ICON = BLANK_PIC ICON = BLANK_PIC
def __init__(self,dbstate,obj): def __init__(self, db, obj):
ScratchPadGrampsTypeWrapper.__init__(self,dbstate,obj) ScratchPadGrampsTypeWrapper.__init__(self, db, obj)
self._type = _("Source Reference") self._type = _("Source Reference")
base = self._db.get_source_from_handle(self._obj.get_base_handle()) base = self._db.get_source_from_handle(self._obj.get_base_handle())
@ -422,18 +418,13 @@ class ScratchPadRepoRef(ScratchPadGrampsTypeWrapper):
DRAG_TARGET = DdTargets.REPOREF DRAG_TARGET = DdTargets.REPOREF
ICON = BLANK_PIC ICON = BLANK_PIC
def __init__(self,dbstate,obj): def __init__(self, db, obj):
ScratchPadGrampsTypeWrapper.__init__(self,dbstate,obj) ScratchPadGrampsTypeWrapper.__init__(self, db, obj)
self._type = _("Repository Reference") self._type = _("Repository Reference")
base = self._db.get_repository_from_handle(self._obj.ref) base = self._db.get_repository_from_handle(self._obj.ref)
self._title = base.get_name() self._title = base.get_name()
self._value = str(base.get_type())
value = base.get_type()
if value == RelLib.Repository.CUSTOM:
self._value = value[1]
else:
self._value = Utils.repository_types[value[0]]
def tooltip(self): def tooltip(self):
return "" return ""
@ -444,8 +435,8 @@ class ScratchPadEventRef(ScratchPadGrampsTypeWrapper):
DRAG_TARGET = DdTargets.EVENTREF DRAG_TARGET = DdTargets.EVENTREF
ICON = BLANK_PIC ICON = BLANK_PIC
def __init__(self,dbstate,obj): def __init__(self, db, obj):
ScratchPadGrampsTypeWrapper.__init__(self,dbstate,obj) ScratchPadGrampsTypeWrapper.__init__(self, db, obj)
self._type = _("EventRef") self._type = _("EventRef")
base = self._db.get_event_from_handle(self._obj.ref) base = self._db.get_event_from_handle(self._obj.ref)
@ -461,8 +452,8 @@ class ScratchPadName(ScratchPadGrampsTypeWrapper):
DRAG_TARGET = DdTargets.NAME DRAG_TARGET = DdTargets.NAME
ICON = BLANK_PIC ICON = BLANK_PIC
def __init__(self,dbstate,obj): def __init__(self, db, obj):
ScratchPadGrampsTypeWrapper.__init__(self,dbstate,obj) ScratchPadGrampsTypeWrapper.__init__(self, db, obj)
self._type = _("Name") self._type = _("Name")
self._title = self._obj.get_name() self._title = self._obj.get_name()
self._value = str(self._obj.get_type()) self._value = str(self._obj.get_type())
@ -496,8 +487,8 @@ class ScratchPadText(ScratchPadWrapper):
DRAG_TARGET = DdTargets.TEXT DRAG_TARGET = DdTargets.TEXT
ICON = BLANK_PIC ICON = BLANK_PIC
def __init__(self,dbstate,obj): def __init__(self, db, obj):
ScratchPadWrapper.__init__(self,dbstate,obj) ScratchPadWrapper.__init__(self, db, obj)
self._type = _("Text") self._type = _("Text")
self._title = "" self._title = ""
@ -515,8 +506,8 @@ class ScratchMediaObj(ScratchPadWrapper):
DRAG_TARGET = DdTargets.MEDIAOBJ DRAG_TARGET = DdTargets.MEDIAOBJ
ICON = LINK_PIC ICON = LINK_PIC
def __init__(self,dbstate,obj): def __init__(self, db, nobj):
ScratchPadWrapper.__init__(self,dbstate,obj) ScratchPadWrapper.__init__(self, db, obj)
self._type = _("Media Object") self._type = _("Media Object")
self._title = "" self._title = ""
@ -534,8 +525,8 @@ class ScratchPersonLink(ScratchPadWrapper):
DRAG_TARGET = DdTargets.PERSON_LINK DRAG_TARGET = DdTargets.PERSON_LINK
ICON = LINK_PIC ICON = LINK_PIC
def __init__(self,dbstate,obj): def __init__(self, db, obj):
ScratchPadWrapper.__init__(self,dbstate,obj) ScratchPadWrapper.__init__(self, db, obj)
self._type = _("Person Link") self._type = _("Person Link")
(drag_type, idval, handle, val) = pickle.loads(obj) (drag_type, idval, handle, val) = pickle.loads(obj)
@ -583,8 +574,8 @@ class ScratchSourceLink(ScratchPadWrapper):
DRAG_TARGET = DdTargets.SOURCE_LINK DRAG_TARGET = DdTargets.SOURCE_LINK
ICON = LINK_PIC ICON = LINK_PIC
def __init__(self,dbstate,obj): def __init__(self, db, obj):
ScratchPadWrapper.__init__(self,dbstate,obj) ScratchPadWrapper.__init__(self, db, obj)
self._type = _("Source Link") self._type = _("Source Link")
(drag_type, idval, handle, val) = pickle.loads(obj) (drag_type, idval, handle, val) = pickle.loads(obj)
@ -603,19 +594,15 @@ class ScratchRepositoryLink(ScratchPadWrapper):
DRAG_TARGET = DdTargets.REPO_LINK DRAG_TARGET = DdTargets.REPO_LINK
ICON = LINK_PIC ICON = LINK_PIC
def __init__(self,dbstate,obj): def __init__(self, db, obj):
ScratchPadWrapper.__init__(self,dbstate,obj) ScratchPadWrapper.__init__(self, db, obj)
self._type = _("Repository Link") self._type = _("Repository Link")
(drag_type, idval, handle, val) = pickle.loads(obj) (drag_type, idval, handle, val) = pickle.loads(obj)
source = self._db.get_repository_from_handle(handle) source = self._db.get_repository_from_handle(handle)
self._title = source.get_name() self._title = source.get_name()
value = source.get_type() self._value = str(source.get_type())
if value == RelLib.Repository.CUSTOM:
self._value = value[1]
else:
self._value = Utils.repository_types[value[0]]
def tooltip(self): def tooltip(self):
return "" return ""
@ -791,21 +778,21 @@ class ScratchPadListView:
# Methods for rendering the cells. # Methods for rendering the cells.
def object_pixbuf(self, column, cell, model, iter, user_data=None): def object_pixbuf(self, column, cell, model, node, user_data=None):
o = model.get_value(iter, 1) o = model.get_value(node, 1)
cell.set_property('pixbuf', o.__class__.ICON) cell.set_property('pixbuf', o.__class__.ICON)
def object_type(self, column, cell, model, iter, user_data=None): def object_type(self, column, cell, model, node, user_data=None):
o = model.get_value(iter, 1) o = model.get_value(node, 1)
cell.set_property('text', o.get_type()) cell.set_property('text', o.get_type())
def object_title(self, column, cell, model, iter, user_data=None): def object_title(self, column, cell, model, node, user_data=None):
o = model.get_value(iter, 1) o = model.get_value(node, 1)
cell.set_property('text', o.get_title()) cell.set_property('text', o.get_title())
def object_value(self, column, cell, model, iter, user_data=None): def object_value(self, column, cell, model, node, user_data=None):
o = model.get_value(iter, 1) o = model.get_value(node, 1)
cell.set_property('text', o.get_value()) cell.set_property('text', o.get_value())
@ -813,12 +800,12 @@ class ScratchPadListView:
def on_object_select_row(self,obj): def on_object_select_row(self,obj):
tree_selection = self._widget.get_selection() tree_selection = self._widget.get_selection()
model,iter = tree_selection.get_selected() model,node = tree_selection.get_selected()
self._widget.unset_rows_drag_source() self._widget.unset_rows_drag_source()
if iter != None: if node != None:
o = model.get_value(iter,1) o = model.get_value(node,1)
targets = [ScratchPadListView.LOCAL_DRAG_TARGET] + \ targets = [ScratchPadListView.LOCAL_DRAG_TARGET] + \
[target.target() for target in o.__class__.DROP_TARGETS] [target.target() for target in o.__class__.DROP_TARGETS]
@ -830,8 +817,8 @@ class ScratchPadListView:
def object_drag_data_get(self, widget, context, sel_data, info, time): def object_drag_data_get(self, widget, context, sel_data, info, time):
tree_selection = widget.get_selection() tree_selection = widget.get_selection()
model,iter = tree_selection.get_selected() model,node = tree_selection.get_selected()
o = model.get_value(iter,1) o = model.get_value(node,1)
sel_data.set(sel_data.target, 8, o.pack()) sel_data.set(sel_data.target, 8, o.pack())
@ -883,12 +870,12 @@ class ScratchPadListView:
drop_info = widget.get_dest_row_at_pos(x, y) drop_info = widget.get_dest_row_at_pos(x, y)
if drop_info: if drop_info:
path, position = drop_info path, position = drop_info
iter = model.get_iter(path) node = model.get_iter(path)
if (position == gtk.TREE_VIEW_DROP_BEFORE if (position == gtk.TREE_VIEW_DROP_BEFORE
or position == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE): or position == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE):
model.insert_before(iter,[o.__class__.DRAG_TARGET.drag_type,o,o.tooltip]) model.insert_before(node,[o.__class__.DRAG_TARGET.drag_type,o,o.tooltip])
else: else:
model.insert_after(iter,[o.__class__.DRAG_TARGET.drag_type,o,o.tooltip]) model.insert_after(node,[o.__class__.DRAG_TARGET.drag_type,o,o.tooltip])
else: else:
model.append([o.__class__.DRAG_TARGET.drag_type,o,o.tooltip]) model.append([o.__class__.DRAG_TARGET.drag_type,o,o.tooltip])
@ -917,7 +904,7 @@ class ScratchPadListView:
# ScatchPadWindow class # ScatchPadWindow class
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class ScratchPadWindow: class ScratchPadWindow(ManagedWindow.ManagedWindow):
""" """
The ScratchPad provides a temporary area to hold objects that can The ScratchPad provides a temporary area to hold objects that can
be reused accross multiple Person records. The pad provides a window be reused accross multiple Person records. The pad provides a window
@ -942,33 +929,37 @@ class ScratchPadWindow:
# maintain a list of these. # maintain a list of these.
otree = None otree = None
def __init__(self,database,parent): def __init__(self, dbstate, uistate):
"""Initializes the ScratchPad class, and displays the window""" """Initializes the ScratchPad class, and displays the window"""
self.parent = parent ManagedWindow.ManagedWindow.__init__(self, uistate, [], self)
self.db = dbstate.db
self.database_changed(database) self.database_changed(self.db)
self.db.connect('database-changed', self.database_changed) self.db.connect('database-changed', self.database_changed)
self.glade_file = os.path.join(const.glade_dir,"scratchpad.glade") self.glade_file = os.path.join(const.glade_dir,"scratchpad.glade")
self.top = gtk.glade.XML(self.glade_file,"scratch_pad","gramps") self.top = gtk.glade.XML(self.glade_file,"scratch_pad","gramps")
self.window = self.top.get_widget("scratch_pad") self.set_window(self.top.get_widget("scratch_pad"))
self.window.set_icon_from_file(const.icon)
self.clear_all_btn = self.top.get_widget("btn_clear_all") self.clear_all_btn = self.top.get_widget("btn_clear_all")
self.clear_btn = self.top.get_widget("btn_clear") self.clear_btn = self.top.get_widget("btn_clear")
self.object_list = ScratchPadListView(self.db,self.top.get_widget('objectlist')) self.object_list = ScratchPadListView(
self.object_list.get_selection().connect('changed',self.set_clear_btn_sensitivity) self.db,self.top.get_widget('objectlist'))
self.object_list.get_selection().connect('changed',
self.set_clear_btn_sensitivity)
self.set_clear_btn_sensitivity(sel=self.object_list.get_selection()) self.set_clear_btn_sensitivity(sel=self.object_list.get_selection())
if not ScratchPadWindow.otree: if not ScratchPadWindow.otree:
ScratchPadWindow.otree = ScratchPadListModel() ScratchPadWindow.otree = ScratchPadListModel()
self.set_clear_all_btn_sensitivity(treemodel=ScratchPadWindow.otree) self.set_clear_all_btn_sensitivity(treemodel=ScratchPadWindow.otree)
ScratchPadWindow.otree.connect('row-deleted',self.set_clear_all_btn_sensitivity) ScratchPadWindow.otree.connect('row-deleted',
ScratchPadWindow.otree.connect('row-inserted',self.set_clear_all_btn_sensitivity) self.set_clear_all_btn_sensitivity)
ScratchPadWindow.otree.connect('row-inserted',
self.set_clear_all_btn_sensitivity)
self.object_list.set_model(ScratchPadWindow.otree) self.object_list.set_model(ScratchPadWindow.otree)
@ -977,20 +968,24 @@ class ScratchPadWindow:
"on_close_scratchpad" : self.on_close_scratchpad, "on_close_scratchpad" : self.on_close_scratchpad,
"on_clear_clicked": self.on_clear_clicked, "on_clear_clicked": self.on_clear_clicked,
"on_help_clicked": self.on_help_clicked, "on_help_clicked": self.on_help_clicked,
"on_objectlist_delete_event": self.on_delete_event, "on_objectlist_delete_event": self.close,
"on_scratch_pad_delete_event": self.on_delete_event "on_scratch_pad_delete_event": self.close,
}) })
self.clear_all_btn.connect_object('clicked', gtk.ListStore.clear, ScratchPadWindow.otree) self.clear_all_btn.connect_object('clicked', gtk.ListStore.clear,
ScratchPadWindow.otree)
self.db.connect('database-changed', lambda x: ScratchPadWindow.otree.clear()) self.db.connect('database-changed', lambda x: ScratchPadWindow.otree.clear())
self.add_itself_to_menu() self.show()
self.window.show()
def build_menu_names(self,obj):
return ('ScratchPad','ScratchPad')
def database_changed(self,database): def database_changed(self,database):
self.db = database self.db = database
def set_clear_all_btn_sensitivity(self, treemodel=None, path=None, iter=None, user_param1=None): def set_clear_all_btn_sensitivity(self, treemodel=None,
path=None, node=None, user_param1=None):
if len(treemodel) == 0: if len(treemodel) == 0:
self.clear_all_btn.set_sensitive(False) self.clear_all_btn.set_sensitive(False)
else: else:
@ -1002,47 +997,19 @@ class ScratchPadWindow:
else: else:
self.clear_btn.set_sensitive(True) self.clear_btn.set_sensitive(True)
def on_delete_event(self,obj,b):
self.remove_itself_from_menu()
def add_itself_to_menu(self):
"""Add the ScratchPad window to the list of windows in the
main GRAMPS interface. If this is the first instance to be
created a submenu is created, if it is not the first instance
then an entry is created in the existing sub menu."""
return
self.parent.child_windows[self.win_key] = self
self.parent_menu_item = gtk.MenuItem(_('Scratch Pad'))
self.parent_menu_item.connect("activate",self.present)
self.parent_menu_item.show()
self.parent.winsmenu.append(self.parent_menu_item)
def remove_itself_from_menu(self):
"""Remove the instance of the pad from the Window menu in the
main GRAMPS window. If this is the last pad then remove the
ScratchPad sub menu as well."""
return
del self.parent.child_windows[self.win_key]
self.parent_menu_item.destroy()
def present(self,obj):
self.window.present()
def on_help_clicked(self,obj): def on_help_clicked(self,obj):
"""Display the relevant portion of GRAMPS manual""" """Display the relevant portion of GRAMPS manual"""
GrampsDisplay.help('tools-util-scratch-pad') GrampsDisplay.help('tools-util-scratch-pad')
def on_close_scratchpad(self,obj): def on_close_scratchpad(self,obj):
self.remove_itself_from_menu() self.close()
self.window.destroy()
def on_clear_clicked(self,obj): def on_clear_clicked(self,obj):
"""Deletes the selected object from the object list""" """Deletes the selected object from the object list"""
selection = self.object_list.get_selection() selection = self.object_list.get_selection()
model, iter = selection.get_selected() model, node = selection.get_selected()
if iter: if node:
model.remove(iter) model.remove(node)
return return

View File

@ -930,7 +930,7 @@ class ViewManager:
def scratchpad(self, obj): def scratchpad(self, obj):
import ScratchPad import ScratchPad
ScratchPad.ScratchPadWindow(self.state, self) ScratchPad.ScratchPadWindow(self.state, self.uistate)
def undo(self, obj): def undo(self, obj):
self.state.db.undo() self.state.db.undo()