2007-02-13 23:26:31 +05:30
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2001-2006 Donald N. Allingham
|
2008-07-26 14:04:09 +05:30
|
|
|
# Copyright (C) 2008 Gary Burton
|
2007-02-13 23:26:31 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2007-03-27 23:58:26 +05:30
|
|
|
# $Id$
|
2007-02-13 23:26:31 +05:30
|
|
|
|
|
|
|
"""
|
2008-01-25 02:08:10 +05:30
|
|
|
Place View.
|
2007-02-13 23:26:31 +05:30
|
|
|
"""
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import PageView
|
|
|
|
import DisplayModels
|
|
|
|
import Utils
|
|
|
|
import Errors
|
|
|
|
import Bookmarks
|
|
|
|
import Config
|
2007-03-28 21:57:45 +05:30
|
|
|
import ColumnOrder
|
2007-10-08 22:11:39 +05:30
|
|
|
from gen.lib import Note
|
2007-03-28 21:57:45 +05:30
|
|
|
from DdTargets import DdTargets
|
2007-02-25 00:46:50 +05:30
|
|
|
from Filters.SideBar import NoteSidebarFilter
|
2007-03-27 23:58:26 +05:30
|
|
|
from Editors import EditNote, DeleteNoteQuery
|
2007-02-13 23:26:31 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# internationalization
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
from gettext import gettext as _
|
|
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# NoteView
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class NoteView(PageView.ListView):
|
2007-09-25 17:39:25 +05:30
|
|
|
|
|
|
|
COLUMN_NAMES = [
|
2008-01-10 02:45:28 +05:30
|
|
|
_('Preview'),
|
2007-09-25 17:39:25 +05:30
|
|
|
_('ID'),
|
|
|
|
_('Type'),
|
|
|
|
_('Marker'),
|
|
|
|
]
|
2007-02-13 23:26:31 +05:30
|
|
|
|
|
|
|
ADD_MSG = _("Add a new note")
|
|
|
|
EDIT_MSG = _("Edit the selected note")
|
|
|
|
DEL_MSG = _("Delete the selected note")
|
|
|
|
FILTER_TYPE = "Note"
|
|
|
|
|
|
|
|
def __init__(self, dbstate, uistate):
|
|
|
|
|
|
|
|
signal_map = {
|
2007-02-20 10:05:34 +05:30
|
|
|
'note-add' : self.row_add,
|
|
|
|
'note-update' : self.row_update,
|
|
|
|
'note-delete' : self.row_delete,
|
2007-10-03 22:04:51 +05:30
|
|
|
'note-rebuild' : self.object_build,
|
2007-03-28 21:57:45 +05:30
|
|
|
}
|
2007-02-13 23:26:31 +05:30
|
|
|
|
|
|
|
self.func_list = {
|
2007-03-28 21:57:45 +05:30
|
|
|
'<CONTROL>J' : self.jump,
|
|
|
|
'<CONTROL>BackSpace' : self.key_delete,
|
|
|
|
}
|
2007-02-13 23:26:31 +05:30
|
|
|
|
|
|
|
PageView.ListView.__init__(
|
2007-09-25 17:39:25 +05:30
|
|
|
self, _('Notes'), dbstate, uistate, NoteView.COLUMN_NAMES,
|
|
|
|
len(NoteView.COLUMN_NAMES), DisplayModels.NoteModel, signal_map,
|
2007-03-27 23:58:26 +05:30
|
|
|
dbstate.db.get_note_bookmarks(),
|
2007-02-25 00:46:50 +05:30
|
|
|
Bookmarks.NoteBookmarks,
|
|
|
|
filter_class=NoteSidebarFilter,
|
2008-07-26 14:04:09 +05:30
|
|
|
multiple=True)
|
2007-02-13 23:26:31 +05:30
|
|
|
|
|
|
|
Config.client.notify_add("/apps/gramps/interface/filter",
|
|
|
|
self.filter_toggle)
|
|
|
|
|
|
|
|
def get_bookmarks(self):
|
2007-07-08 08:57:06 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return the bookmark object
|
2007-07-08 08:57:06 +05:30
|
|
|
"""
|
2007-03-27 23:58:26 +05:30
|
|
|
return self.dbstate.db.get_note_bookmarks()
|
2007-02-13 23:26:31 +05:30
|
|
|
|
2007-03-28 21:57:45 +05:30
|
|
|
def drag_info(self):
|
2007-07-08 08:57:06 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Indicate that the drag type is an EVENT
|
2007-07-08 08:57:06 +05:30
|
|
|
"""
|
2007-03-28 21:57:45 +05:30
|
|
|
return DdTargets.NOTE_LINK
|
2007-02-13 23:26:31 +05:30
|
|
|
|
|
|
|
def column_order(self):
|
2007-07-08 08:57:06 +05:30
|
|
|
"""
|
|
|
|
returns a tuple indicating the column order
|
|
|
|
"""
|
2007-03-28 19:30:03 +05:30
|
|
|
return self.dbstate.db.get_note_column_order()
|
2007-02-13 23:26:31 +05:30
|
|
|
|
|
|
|
def get_stock(self):
|
2007-07-08 08:57:06 +05:30
|
|
|
"""
|
|
|
|
Use the gramps-event stock icon
|
|
|
|
"""
|
2007-02-13 23:26:31 +05:30
|
|
|
return 'gramps-notes'
|
|
|
|
|
|
|
|
def ui_definition(self):
|
2007-07-08 08:57:06 +05:30
|
|
|
"""
|
|
|
|
Defines the UI string for UIManager
|
|
|
|
"""
|
2007-02-13 23:26:31 +05:30
|
|
|
return '''<ui>
|
|
|
|
<menubar name="MenuBar">
|
|
|
|
<menu action="BookMenu">
|
|
|
|
<placeholder name="AddEditBook">
|
|
|
|
<menuitem action="AddBook"/>
|
|
|
|
<menuitem action="EditBook"/>
|
|
|
|
</placeholder>
|
|
|
|
</menu>
|
|
|
|
<menu action="EditMenu">
|
|
|
|
<placeholder name="CommonEdit">
|
|
|
|
<menuitem action="Add"/>
|
|
|
|
<menuitem action="Edit"/>
|
|
|
|
<menuitem action="Remove"/>
|
|
|
|
</placeholder>
|
|
|
|
<menuitem action="ColumnEdit"/>
|
2007-02-25 17:49:47 +05:30
|
|
|
<menuitem action="FilterEdit"/>
|
2007-02-13 23:26:31 +05:30
|
|
|
</menu>
|
|
|
|
</menubar>
|
|
|
|
<toolbar name="ToolBar">
|
|
|
|
<placeholder name="CommonEdit">
|
|
|
|
<toolitem action="Add"/>
|
|
|
|
<toolitem action="Edit"/>
|
|
|
|
<toolitem action="Remove"/>
|
|
|
|
</placeholder>
|
|
|
|
</toolbar>
|
|
|
|
<popup name="Popup">
|
|
|
|
<menuitem action="Add"/>
|
|
|
|
<menuitem action="Edit"/>
|
|
|
|
<menuitem action="Remove"/>
|
|
|
|
</popup>
|
|
|
|
</ui>'''
|
|
|
|
|
2007-07-08 08:57:06 +05:30
|
|
|
def define_actions(self):
|
|
|
|
PageView.ListView.define_actions(self)
|
2007-09-13 09:50:24 +05:30
|
|
|
self._add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
|
|
|
|
_('_Column Editor'), callback=self._column_editor)
|
|
|
|
self._add_action('FilterEdit', None, _('Note Filter Editor'),
|
|
|
|
callback=self.filter_editor,)
|
2007-07-08 08:57:06 +05:30
|
|
|
|
|
|
|
def get_handle_from_gramps_id(self, gid):
|
|
|
|
obj = self.dbstate.db.get_note_from_gramps_id(gid)
|
|
|
|
if obj:
|
|
|
|
return obj.get_handle()
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
2007-09-13 09:50:24 +05:30
|
|
|
def _column_editor(self, obj):
|
2007-07-08 08:57:06 +05:30
|
|
|
"""
|
|
|
|
returns a tuple indicating the column order
|
|
|
|
"""
|
|
|
|
ColumnOrder.ColumnOrder(
|
|
|
|
_('Select Note Columns'),
|
|
|
|
self.uistate,
|
|
|
|
self.dbstate.db.get_note_column_order(),
|
2007-09-25 17:39:25 +05:30
|
|
|
NoteView.COLUMN_NAMES,
|
2007-07-08 08:57:06 +05:30
|
|
|
self.set_column_order)
|
|
|
|
|
|
|
|
def set_column_order(self, clist):
|
|
|
|
self.dbstate.db.set_note_column_order(clist)
|
|
|
|
self.build_columns()
|
2007-02-13 23:26:31 +05:30
|
|
|
|
|
|
|
def add(self, obj):
|
|
|
|
try:
|
2007-03-27 23:58:26 +05:30
|
|
|
EditNote(self.dbstate, self.uistate, [], Note())
|
2007-02-13 23:26:31 +05:30
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def remove(self, obj):
|
2008-07-26 14:04:09 +05:30
|
|
|
self.remove_selected_objects()
|
|
|
|
|
|
|
|
def remove_object_from_handle(self, handle):
|
|
|
|
the_lists = Utils.get_note_referents(handle, self.dbstate.db)
|
|
|
|
object = self.dbstate.db.get_note_from_handle(handle)
|
|
|
|
query = DeleteNoteQuery(self.dbstate, self.uistate, object, the_lists)
|
|
|
|
is_used = any(the_lists)
|
|
|
|
return (query, is_used, object)
|
2007-02-13 23:26:31 +05:30
|
|
|
|
|
|
|
def edit(self, obj):
|
2008-07-26 17:29:37 +05:30
|
|
|
for handle in self.selected_handles():
|
2007-02-20 10:05:34 +05:30
|
|
|
note = self.dbstate.db.get_note_from_handle(handle)
|
2007-02-13 23:26:31 +05:30
|
|
|
try:
|
2007-02-26 07:09:16 +05:30
|
|
|
EditNote(self.dbstate, self.uistate, [], note)
|
2007-02-13 23:26:31 +05:30
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|