* src/DataViews/_NoteView.py: enable shortcuts and drag-and-drop.

* src/Bookmarks.py (NoteBookmarks.make_label): better note label.
	* src/DisplayTabs/_NoteModel.py: better note label for preview.
	* src/DisplayTabs/_NoteTab.py: enable accepting drag-and-drop notes.
	* src/ScratchPad.py: ScratchPadNote added.
	* src/DdTargets.py: NOTE_LINK added.

2007-03-28  Zsolt Foldvari  <zfoldvar@users.sourceforge.net>


svn: r8334
This commit is contained in:
Zsolt Foldvari 2007-03-28 16:27:45 +00:00
parent 33fedc18d4
commit 0cc78b2e89
7 changed files with 101 additions and 26 deletions

View File

@ -1,3 +1,11 @@
2007-03-28 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
* src/DataViews/_NoteView.py: enable shortcuts and drag-and-drop.
* src/Bookmarks.py (NoteBookmarks.make_label): better note label.
* src/DisplayTabs/_NoteModel.py: better note label for preview.
* src/DisplayTabs/_NoteTab.py: enable accepting drag-and-drop notes.
* src/ScratchPad.py: ScratchPadNote added.
* src/DdTargets.py: NOTE_LINK added.
2007-03-28 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
* src/DataViews/_NoteView.py: put back column editor support.
* src/GrampsDb/_GrampsDbBase.py (get_note_column_order): fix default

View File

@ -391,7 +391,9 @@ class NoteBookmarks(ListBookmarks) :
def make_label(self,handle):
obj = self.dbstate.db.get_note_from_handle(handle)
name = obj.get().replace('\n', ' ')[:80]
name = obj.get().replace('\n', ' ')
if len(name) > 40:
name = name[:40]+"..."
return ("%s [%s]" % (name, obj.gramps_id), obj)
def connect_signals(self):

View File

@ -38,13 +38,15 @@ import gtk
# gramps modules
#
#-------------------------------------------------------------------------
from RelLib import Note
import PageView
import DisplayModels
import Utils
import Errors
import Bookmarks
import Config
import ColumnOrder
from RelLib import Note
from DdTargets import DdTargets
from QuestionDialog import QuestionDialog, ErrorDialog
from Filters.SideBar import NoteSidebarFilter
from Editors import EditNote, DeleteNoteQuery
@ -85,8 +87,8 @@ class NoteView(PageView.ListView):
}
self.func_list = {
# '<CONTROL>J' : self.jump,
# '<CONTROL>BackSpace' : self.key_delete,
'<CONTROL>J' : self.jump,
'<CONTROL>BackSpace' : self.key_delete,
}
PageView.ListView.__init__(
@ -110,9 +112,10 @@ class NoteView(PageView.ListView):
self.add_action('FilterEdit', None, _('Note Filter Editor'),
callback=self.filter_editor,)
def column_editor(self, obj):
import ColumnOrder
def drag_info(self):
return DdTargets.NOTE_LINK
def column_editor(self, obj):
ColumnOrder.ColumnOrder(
_('Select Note Columns'),
self.uistate,

View File

@ -120,6 +120,7 @@ class _DdTargets(object):
self.MEDIAOBJ = _DdType(self,'mediaobj')
self.MEDIAREF = _DdType(self,'mediaref')
self.DATA = _DdType(self,'data_tuple')
self.NOTE_LINK = _DdType(self,'note-link')
self.PERSON_LINK = _DdType(self,'person-link')
self.PERSON_LINK_LIST = _DdType(self,'person-link-list')
@ -133,7 +134,8 @@ class _DdTargets(object):
# List of all types that are used between
# gramps widgets but should not be exported
# to non gramps widgets.
self._all_gramps_types = [self.URL,
self._all_gramps_types = [
self.URL,
self.EVENT,
self.ATTRIBUTE,
self.ADDRESS,
@ -149,7 +151,9 @@ class _DdTargets(object):
self.SOURCE_LINK,
self.PERSON_LINK,
self.PERSON_LINK_LIST,
self.PERSONREF]
self.PERSONREF,
self.NOTE_LINK,
]
self.CHILD = _DdType(self,'child')
self.SPOUSE = _DdType(self,'spouse')

View File

@ -39,8 +39,11 @@ class NoteModel(gtk.ListStore):
self.db = db
for handle in note_list:
note = self.db.get_note_from_handle(handle)
text = note.get().replace('\n', ' ')
if len(text) > 80:
text = text[:80]+"..."
self.append(row=[
str(note.get_type()),
note.get().replace('\n', ' ')[:80],
text,
handle,
])

View File

@ -26,6 +26,14 @@
#
#-------------------------------------------------------------------------
from gettext import gettext as _
import cPickle as pickle
#-------------------------------------------------------------------------
#
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
#-------------------------------------------------------------------------
#
@ -39,6 +47,7 @@ from DisplayTabs import log
from _NoteModel import NoteModel
from _EmbeddedList import EmbeddedList
from Editors import EditNote
from DdTargets import DdTargets
#-------------------------------------------------------------------------
#
@ -65,6 +74,18 @@ class NoteTab(EmbeddedList):
EmbeddedList.__init__(self, dbstate, uistate, track,
_("Notes"), NoteModel)
self.tree.drag_dest_set(gtk.DEST_DEFAULT_ALL,
[DdTargets.NOTE_LINK.target()],
gtk.gdk.ACTION_COPY)
self.tree.connect('drag_data_received', self.on_drag_data_received)
def on_drag_data_received(self, widget, context, x, y,
selection, info, time):
"""Insert the received note to the note list of current object.
"""
(drag_type, idval, obj, val) = pickle.loads(selection.data)
self.add_callback(obj)
def get_editor(self):
pass

View File

@ -281,6 +281,39 @@ class ScratchPadPlace(ScratchPadWrapper):
return True
return False
class ScratchPadNote(ScratchPadWrapper):
DROP_TARGETS = [DdTargets.NOTE_LINK]
DRAG_TARGET = DdTargets.NOTE_LINK
ICON = LINK_PIC
def __init__(self,dbstate,obj):
ScratchPadWrapper.__init__(self,dbstate,obj)
self._type = _("Note")
(drag_type, idval, handle, val) = pickle.loads(obj)
value = self._db.get_note_from_handle(handle)
self._title = value.get_gramps_id()
note = value.get().replace('\n', ' ')
if len(note) > 80:
self._value = note[:80]+"..."
else:
self._value = note
def tooltip(self):
global escape
return ""
def is_valid(self):
data = pickle.loads(self._obj)
handle = data[2]
obj = self._db.get_note_from_handle(handle)
if obj:
return True
return False
class ScratchPadFamilyEvent(ScratchPadGrampsTypeWrapper):
DROP_TARGETS = [DdTargets.FAMILY_EVENT]
@ -958,6 +991,7 @@ class ScratchPadListView:
self.register_wrapper_class(ScratchPersonLinkList)
self.register_wrapper_class(ScratchPadPersonRef)
self.register_wrapper_class(ScratchPadText)
self.register_wrapper_class(ScratchPadNote)
def register_wrapper_class(self,wrapper_class):
for drop_target in wrapper_class.DROP_TARGETS: