2005-04-01 Richard Taylor <rjt-gramps@thegrindstone.me.uk>

* src/DdTargets.py: added dnd type for media objects
	* src/ImageSelect.py: altered dnd code to use gramps specific dnd target
	when dnd is used between gramps windows.
	* src/plugins/ScratchPad.py: added support for media object. This is still
	a little simplistic. It would be nice to generate thumbnails as tooltips and
	to access some of the image meta data in the ui.


svn: r4274
This commit is contained in:
Richard Taylor 2005-04-01 15:15:36 +00:00
parent 40be278f7d
commit 2d42bb07f5
4 changed files with 39 additions and 4 deletions

View File

@ -1,3 +1,11 @@
2005-04-01 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/DdTargets.py: added dnd type for media objects
* src/ImageSelect.py: altered dnd code to use gramps specific dnd target
when dnd is used between gramps windows.
* src/plugins/ScratchPad.py: added support for media object. This is still
a little simplistic. It would be nice to generate thumbnails as tooltips and
to access some of the image meta data in the ui.
2005-04-01 Richard Taylor <rjt-gramps@thegrindstone.me.uk> 2005-04-01 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/ImageSelect.py (Gallery.on_drag_begin): tiny fix to correct image dnd * src/ImageSelect.py (Gallery.on_drag_begin): tiny fix to correct image dnd

View File

@ -103,6 +103,7 @@ class _DdTargets(object):
self.ADDRESS = _DdType(self,'paddr') self.ADDRESS = _DdType(self,'paddr')
self.SOURCEREF = _DdType(self,'srcref') self.SOURCEREF = _DdType(self,'srcref')
self.NAME = _DdType(self,'name') self.NAME = _DdType(self,'name')
self.MEDIAOBJ = _DdType(self,'mediaobj')
self.FAMILY_EVENT = _DdType(self,'fevent') self.FAMILY_EVENT = _DdType(self,'fevent')
self.FAMILY_ATTRIBUTE = _DdType(self,'fattr') self.FAMILY_ATTRIBUTE = _DdType(self,'fattr')
@ -156,7 +157,8 @@ class _DdTargets(object):
"""return a list of all the type names that are internal """return a list of all the type names that are internal
to gramps.""" to gramps."""
return (self.URL.drag_type, return (self.MEDIAOBJ.drag_type,
self.URL.drag_type,
self.EVENT.drag_type, self.EVENT.drag_type,
self.ATTRIBUTE.drag_type, self.ATTRIBUTE.drag_type,
self.ADDRESS.drag_type, self.ADDRESS.drag_type,
@ -179,7 +181,8 @@ class _DdTargets(object):
def all_gramps_targets(self): def all_gramps_targets(self):
"""return a list off the internal gramps targets.""" """return a list off the internal gramps targets."""
return (self.URL.target(), return (self.MEDIAOBJ.target(),
self.URL.target(),
self.EVENT.target(), self.EVENT.target(),
self.ATTRIBUTE.target(), self.ATTRIBUTE.target(),
self.ADDRESS.target(), self.ADDRESS.target(),

View File

@ -66,6 +66,7 @@ import DateHandler
import Date import Date
import ImgManip import ImgManip
from QuestionDialog import ErrorDialog from QuestionDialog import ErrorDialog
from DdTargets import DdTargets
_IMAGEX = 140 _IMAGEX = 140
_IMAGEY = 150 _IMAGEY = 150
@ -228,7 +229,8 @@ class Gallery(ImageSelect):
self.commit = commit self.commit = commit
if path: if path:
icon_list.drag_dest_set(gtk.DEST_DEFAULT_ALL, _drag_targets, icon_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,
[DdTargets.MEDIAOBJ.target()]+_drag_targets,
gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE) gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE)
icon_list.connect('event',self.item_event) icon_list.connect('event',self.item_event)
icon_list.connect("drag_data_received", icon_list.connect("drag_data_received",
@ -292,7 +294,7 @@ class Gallery(ImageSelect):
icon_index = self.get_index(widget,event.x,event.y)-1 icon_index = self.get_index(widget,event.x,event.y)-1
self.sel_obj = self.dataobj.get_media_list()[icon_index] self.sel_obj = self.dataobj.get_media_list()[icon_index]
if self.drag_item: if self.drag_item:
widget.drag_begin(_drag_targets, widget.drag_begin([DdTargets.MEDIAOBJ.target()]+_drag_targets,
gtk.gdk.ACTION_COPY|gtk.gdk.ACTION_MOVE, gtk.gdk.ACTION_COPY|gtk.gdk.ACTION_MOVE,
self.button, event) self.button, event)
@ -547,6 +549,7 @@ class Gallery(ImageSelect):
return return
data = self.p_map[self.drag_item] data = self.p_map[self.drag_item]
selection_data.set(selection_data.target, 8, data[4]) selection_data.set(selection_data.target, 8, data[4])
print "dragging ", repr(data[4]), " with target ", repr(selection_data.target)
self.drag_item = None self.drag_item = None
def on_add_media_clicked(self, obj): def on_add_media_clicked(self, obj):

View File

@ -406,6 +406,25 @@ class ScratchPadText(ScratchPadWrapper):
"%s" % (_("Text"), "%s" % (_("Text"),
escape(self._obj)) escape(self._obj))
class ScratchMediaObj(ScratchPadWrapper):
DROP_TARGETS = [DdTargets.MEDIAOBJ]
DRAG_TARGET = DdTargets.MEDIAOBJ
ICON = LINK_PIC
def __init__(self,db,obj):
ScratchPadWrapper.__init__(self,db,obj)
self._type = _("Media Object")
self._title = ""
self._value = ""
def tooltip(self):
global escape
return "<big><b>%s</b></big>\n"\
"%s" % (_("Media Object"),
escape(self._obj))
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -498,6 +517,8 @@ class ScratchPadListView:
self.register_wrapper_class(ScratchPadSourceRef) self.register_wrapper_class(ScratchPadSourceRef)
self.register_wrapper_class(ScratchPadName) self.register_wrapper_class(ScratchPadName)
self.register_wrapper_class(ScratchPadText) self.register_wrapper_class(ScratchPadText)
self.register_wrapper_class(ScratchMediaObj)
def register_wrapper_class(self,wrapper_class): def register_wrapper_class(self,wrapper_class):
for drop_target in wrapper_class.DROP_TARGETS: for drop_target in wrapper_class.DROP_TARGETS: