Icons for drag and drop
svn: r1535
This commit is contained in:
parent
f17265cf9e
commit
dff2e9ddc0
@ -600,8 +600,23 @@ class FamilyView:
|
|||||||
data = str(('child',id));
|
data = str(('child',id));
|
||||||
sel_data.set(sel_data.target, bits_per, data)
|
sel_data.set(sel_data.target, bits_per, data)
|
||||||
|
|
||||||
def drag_begin(self, context, a):
|
def drag_begin(self, obj, context):
|
||||||
return
|
return
|
||||||
|
# model, iter = self.child_selection.get_selected()
|
||||||
|
# path = model.get_path(iter)
|
||||||
|
# pixmap = self.child_list.create_row_drag_icon(path)
|
||||||
|
# print "map",pixmap
|
||||||
|
|
||||||
|
# myimage = gtk.Image()
|
||||||
|
# print "set",pixmap
|
||||||
|
# myimage.set_from_pixmap(pixmap,None)
|
||||||
|
|
||||||
|
# print "image"
|
||||||
|
# pixbuf = myimage.get_pixbuf()
|
||||||
|
# print "buf", pixbuf
|
||||||
|
|
||||||
|
# context.set_icon_pixbuf(pixbuf,0,0)
|
||||||
|
# return
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -219,6 +219,7 @@ class Gallery(ImageSelect):
|
|||||||
self.on_photolist_drag_data_received)
|
self.on_photolist_drag_data_received)
|
||||||
icon_list.connect("drag_data_get",
|
icon_list.connect("drag_data_get",
|
||||||
self.on_photolist_drag_data_get)
|
self.on_photolist_drag_data_get)
|
||||||
|
icon_list.connect("drag_begin", self.on_drag_begin)
|
||||||
|
|
||||||
_iconlist_refs.append(icon_list)
|
_iconlist_refs.append(icon_list)
|
||||||
|
|
||||||
@ -251,6 +252,13 @@ class Gallery(ImageSelect):
|
|||||||
Handle resize events over the canvas, redrawing if the size changes
|
Handle resize events over the canvas, redrawing if the size changes
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def on_drag_begin(self,obj,context):
|
||||||
|
if const.dnd_iamges:
|
||||||
|
mtype = self.sel_obj.getReference().getMimeType()
|
||||||
|
name = Utils.thumb_path(self.db.getSavePath(),self.sel_obj.getReference())
|
||||||
|
pix = gtk.gdk.pixbuf_new_from_file(name)
|
||||||
|
context.set_icon_pixbuf(pix,0,0)
|
||||||
|
|
||||||
def item_event(self, widget, event=None):
|
def item_event(self, widget, event=None):
|
||||||
|
|
||||||
if self.button and event.type == gtk.gdk.MOTION_NOTIFY :
|
if self.button and event.type == gtk.gdk.MOTION_NOTIFY :
|
||||||
@ -258,10 +266,13 @@ class Gallery(ImageSelect):
|
|||||||
event.x,event.y):
|
event.x,event.y):
|
||||||
self.drag_item = widget.get_item_at(self.remember_x,
|
self.drag_item = widget.get_item_at(self.remember_x,
|
||||||
self.remember_y)
|
self.remember_y)
|
||||||
|
icon_index = self.get_index(widget,event.x,event.y)-1
|
||||||
|
self.sel_obj = self.dataobj.getPhotoList()[icon_index]
|
||||||
if self.drag_item:
|
if self.drag_item:
|
||||||
widget.drag_begin(_drag_targets,
|
widget.drag_begin(_drag_targets,
|
||||||
gtk.gdk.ACTION_COPY|gtk.gdk.ACTION_MOVE,
|
gtk.gdk.ACTION_COPY|gtk.gdk.ACTION_MOVE,
|
||||||
self.button, event)
|
self.button, event)
|
||||||
|
|
||||||
return gtk.TRUE
|
return gtk.TRUE
|
||||||
|
|
||||||
style = self.iconlist.get_style()
|
style = self.iconlist.get_style()
|
||||||
@ -458,7 +469,6 @@ class Gallery(ImageSelect):
|
|||||||
photo.setPath(name)
|
photo.setPath(name)
|
||||||
except:
|
except:
|
||||||
photo.setPath(tfile)
|
photo.setPath(tfile)
|
||||||
# w.drag_finish(context, 1, 0, time)
|
|
||||||
return
|
return
|
||||||
self.add_thumbnail(oref)
|
self.add_thumbnail(oref)
|
||||||
self.parent.lists_changed = 1
|
self.parent.lists_changed = 1
|
||||||
@ -472,10 +482,8 @@ class Gallery(ImageSelect):
|
|||||||
for p in self.dataobj.getPhotoList():
|
for p in self.dataobj.getPhotoList():
|
||||||
if data.data == p.getReference().getId():
|
if data.data == p.getReference().getId():
|
||||||
if index == icon_index or icon_index == -1:
|
if index == icon_index or icon_index == -1:
|
||||||
# w.drag_finish(context, 0, 0, time)
|
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
# w.drag_finish(context, 1, 0, time)
|
|
||||||
nl = self.dataobj.getPhotoList()
|
nl = self.dataobj.getPhotoList()
|
||||||
item = nl[index]
|
item = nl[index]
|
||||||
if icon_index == 0:
|
if icon_index == 0:
|
||||||
@ -810,12 +818,10 @@ class GlobalMediaProperties:
|
|||||||
d = [attr.getType(),attr.getValue()]
|
d = [attr.getType(),attr.getValue()]
|
||||||
self.atree.add(d,attr)
|
self.atree.add(d,attr)
|
||||||
|
|
||||||
def button_press(self,obj,event):
|
def button_press(self,obj):
|
||||||
store,iter = self.refmodel.selection.get_selected()
|
store,iter = self.refmodel.selection.get_selected()
|
||||||
if not iter:
|
if not iter:
|
||||||
return
|
return
|
||||||
if event.button == 1 and event.type == gtk.gdk._2BUTTON_PRESS:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def display_refs(self):
|
def display_refs(self):
|
||||||
if self.refs == 1:
|
if self.refs == 1:
|
||||||
|
@ -111,6 +111,11 @@ class MediaView:
|
|||||||
self.list.drag_dest_set(gtk.DEST_DEFAULT_ALL,
|
self.list.drag_dest_set(gtk.DEST_DEFAULT_ALL,
|
||||||
t,gtk.gdk.ACTION_COPY|gtk.gdk.ACTION_MOVE)
|
t,gtk.gdk.ACTION_COPY|gtk.gdk.ACTION_MOVE)
|
||||||
|
|
||||||
|
|
||||||
|
self.list.connect("drag_data_received", self.on_drag_data_received)
|
||||||
|
self.list.connect("drag_data_get", self.on_drag_data_get)
|
||||||
|
self.list.connect("drag_begin", self.on_drag_begin)
|
||||||
|
|
||||||
self.update = update
|
self.update = update
|
||||||
self.list.connect('button-press-event',self.on_button_press_event)
|
self.list.connect('button-press-event',self.on_button_press_event)
|
||||||
self.selection.connect('changed',self.on_select_row)
|
self.selection.connect('changed',self.on_select_row)
|
||||||
@ -275,12 +280,26 @@ class MediaView:
|
|||||||
if o.getReference() == mobj:
|
if o.getReference() == mobj:
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def on_drag_begin(self,obj,context):
|
||||||
|
store,iter = self.selection.get_selected()
|
||||||
|
if not iter:
|
||||||
|
return
|
||||||
|
if (const.dnd_images):
|
||||||
|
object = self.db.getObject(store.get_value(iter,1))
|
||||||
|
mtype = object.getMimeType()
|
||||||
|
name = Utils.thumb_path(self.db.getSavePath(),object)
|
||||||
|
pix = gtk.gdk.pixbuf_new_from_file(name)
|
||||||
|
context.set_icon_pixbuf(pix,0,0)
|
||||||
|
|
||||||
def on_drag_data_get(self,w, context, selection_data, info, time):
|
def on_drag_data_get(self,w, context, selection_data, info, time):
|
||||||
if info == 1:
|
if info == 1:
|
||||||
return
|
return
|
||||||
d = w.get_row_data(w.focus_row)
|
|
||||||
id = d.getId()
|
store,iter = self.selection.get_selected()
|
||||||
|
if not iter:
|
||||||
|
return
|
||||||
|
id = store.get_value(iter,1)
|
||||||
selection_data.set(selection_data.target, 8, id)
|
selection_data.set(selection_data.target, 8, id)
|
||||||
|
|
||||||
def on_drag_data_received(self,w, context, x, y, data, info, time):
|
def on_drag_data_received(self,w, context, x, y, data, info, time):
|
||||||
@ -298,7 +317,6 @@ class MediaView:
|
|||||||
photo.setDescription(description)
|
photo.setDescription(description)
|
||||||
self.db.addObject(photo)
|
self.db.addObject(photo)
|
||||||
Utils.modified()
|
Utils.modified()
|
||||||
w.drag_finish(context, 1, 0, time)
|
|
||||||
self.load_media()
|
self.load_media()
|
||||||
if GrampsCfg.mediaref == 0:
|
if GrampsCfg.mediaref == 0:
|
||||||
name = RelImage.import_media_object(name,
|
name = RelImage.import_media_object(name,
|
||||||
@ -336,12 +354,9 @@ class MediaView:
|
|||||||
photo.setPath(name)
|
photo.setPath(name)
|
||||||
except:
|
except:
|
||||||
photo.setPath(tfile)
|
photo.setPath(tfile)
|
||||||
w.drag_finish(context, 1, 0, time)
|
|
||||||
return
|
return
|
||||||
Utils.modified()
|
Utils.modified()
|
||||||
if GrampsCfg.globalprop:
|
if GrampsCfg.globalprop:
|
||||||
ImageSelect.GlobalMediaProperties(self.db,photo,None)
|
ImageSelect.GlobalMediaProperties(self.db,photo,None)
|
||||||
else:
|
|
||||||
w.drag_finish(context, 0, 0, time)
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,6 +96,7 @@ template_dir = "%s/templates" % dataDir
|
|||||||
fdl = "%s/fdl.txt" % dataDir
|
fdl = "%s/fdl.txt" % dataDir
|
||||||
|
|
||||||
startup = 1
|
startup = 1
|
||||||
|
dnd_images = 1
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user