Drag and drop
svn: r454
This commit is contained in:
parent
0f6897d6b0
commit
8707a8c7b4
@ -3548,6 +3548,11 @@
|
||||
<object>editPerson</object>
|
||||
<last_modification_time>Tue, 27 Mar 2001 22:01:31 GMT</last_modification_time>
|
||||
</signal>
|
||||
<signal>
|
||||
<name>drag_data_received</name>
|
||||
<handler>on_photolist_drag_data_received</handler>
|
||||
<last_modification_time>Tue, 09 Oct 2001 20:50:19 GMT</last_modification_time>
|
||||
</signal>
|
||||
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
|
||||
<icon_width>100</icon_width>
|
||||
<row_spacing>20</row_spacing>
|
||||
|
@ -31,6 +31,7 @@ import string
|
||||
# GTK/Gnome modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from GDK import *
|
||||
from gtk import *
|
||||
from gnome.ui import *
|
||||
import libglade
|
||||
@ -97,8 +98,9 @@ class EditPerson:
|
||||
|
||||
# widgets
|
||||
self.window = self.get_widget("editPerson")
|
||||
self.gallery_widget = self.top.get_widget("photolist")
|
||||
self.gallery = PersonGallery(self, self.path, "i%s" % person.getId(), \
|
||||
self.top.get_widget("photolist"), self.db)
|
||||
self.gallery_widget, self.db)
|
||||
self.notes_field = self.get_widget("personNotes")
|
||||
self.event_name_field = self.get_widget("eventName")
|
||||
self.event_place_field = self.get_widget("eventPlace")
|
||||
|
@ -33,6 +33,7 @@ import string
|
||||
#-------------------------------------------------------------------------
|
||||
from gtk import *
|
||||
from gnome.ui import *
|
||||
import GDK
|
||||
import gnome.mime
|
||||
import libglade
|
||||
import GdkImlib
|
||||
@ -133,7 +134,7 @@ class ImageSelect:
|
||||
photo = Photo()
|
||||
photo.setPath(name)
|
||||
photo.setDescription(description)
|
||||
photo.setMimeType(gnome.mime.type_or_default(name,"unknown"))
|
||||
photo.setMimeType(gnome.mime.type_or_default_of_file(name,"unknown"))
|
||||
|
||||
self.savephoto(photo)
|
||||
|
||||
@ -159,6 +160,19 @@ class Gallery(ImageSelect):
|
||||
def __init__(self, dataobj, path, prefix, icon_list, db):
|
||||
ImageSelect.__init__(self, path, prefix, db)
|
||||
|
||||
t = [
|
||||
('STRING', 0, 0),
|
||||
('text/plain',0,0),
|
||||
('application/x-rootwin-drop',0,1)]
|
||||
|
||||
icon_list.drag_dest_set(DEST_DEFAULT_ALL, t, GDK.ACTION_COPY)
|
||||
icon_list.connect("drag_data_received", self.on_photolist_drag_data_received)
|
||||
|
||||
icon_list.drag_source_set(GDK.BUTTON1_MASK|GDK.BUTTON3_MASK,t,\
|
||||
GDK.ACTION_COPY)
|
||||
icon_list.connect("drag_data_get", self.on_photolist_drag_data_get)
|
||||
|
||||
|
||||
# Be paranoid - development only error messages
|
||||
assert dataobj.addPhoto, "Gallery data object must contain an addPhoto routine."
|
||||
assert dataobj.getPhotoList, "Gallery data object must contain an getPhotoList routine."
|
||||
@ -216,7 +230,6 @@ class Gallery(ImageSelect):
|
||||
self.add_thumbnail(photo)
|
||||
self.icon_list.thaw()
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# on_photo_select_icon - User clicked on a photo. Remember which one.
|
||||
@ -225,6 +238,36 @@ class Gallery(ImageSelect):
|
||||
def on_photo_select_icon(self, obj,iconNumber,event):
|
||||
self.selectedIcon = iconNumber
|
||||
|
||||
def on_photolist_drag_data_received(self,w, context, x, y, data, info, time):
|
||||
if data and data.format == 8:
|
||||
if data.data[0:5] == "file:":
|
||||
name = string.strip(data.data[5:])
|
||||
mime = gnome.mime.type_or_default_of_file(name,"unknown")
|
||||
if mime[0:5] == "image":
|
||||
photo = Photo()
|
||||
photo.setPath(name)
|
||||
photo.setMimeType(mime)
|
||||
self.savephoto(photo)
|
||||
else:
|
||||
print name,mime
|
||||
else:
|
||||
if self.db.getObjectMap().has_key(data.data):
|
||||
w.drag_finish(context, TRUE, FALSE, time)
|
||||
oref = ObjectRef()
|
||||
oref.setReference(self.db.findObjectNoMap(data.data))
|
||||
self.dataobj.addPhoto(oref)
|
||||
self.add_thumbnail(oref)
|
||||
utils.modified()
|
||||
else:
|
||||
w.drag_finish(context, FALSE, FALSE, time)
|
||||
|
||||
def on_photolist_drag_data_get(self,w, context, selection_data, info, time):
|
||||
if info == 1:
|
||||
return
|
||||
if self.selectedIcon != -1:
|
||||
ref = self.dataobj.getPhotoList()[self.selectedIcon]
|
||||
id = ref.getReference().getId()
|
||||
selection_data.set(selection_data.target, 8, id)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -25,6 +25,7 @@
|
||||
#-------------------------------------------------------------------------
|
||||
from gtk import *
|
||||
from gnome.ui import *
|
||||
import GDK
|
||||
|
||||
import libglade
|
||||
import os
|
||||
|
@ -610,13 +610,14 @@
|
||||
<class>GtkNotebook</class>
|
||||
<child_name>GnomeDock:contents</child_name>
|
||||
<name>notebook1</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>switch_page</name>
|
||||
<handler>on_notebook1_switch_page</handler>
|
||||
<after>True</after>
|
||||
<last_modification_time>Fri, 20 Oct 2000 01:16:41 GMT</last_modification_time>
|
||||
</signal>
|
||||
<show_tabs>False</show_tabs>
|
||||
<show_tabs>True</show_tabs>
|
||||
<show_border>True</show_border>
|
||||
<tab_pos>GTK_POS_TOP</tab_pos>
|
||||
<scrollable>False</scrollable>
|
||||
@ -2444,8 +2445,6 @@
|
||||
<name>preview</name>
|
||||
<width>100</width>
|
||||
<height>100</height>
|
||||
<scaled_width>96</scaled_width>
|
||||
<scaled_height>96</scaled_height>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
@ -2875,6 +2874,11 @@
|
||||
<handler>on_media_list_select_row</handler>
|
||||
<last_modification_time>Tue, 09 Oct 2001 17:22:54 GMT</last_modification_time>
|
||||
</signal>
|
||||
<signal>
|
||||
<name>drag_data_get</name>
|
||||
<handler>on_media_list_drag_data_get</handler>
|
||||
<last_modification_time>Tue, 09 Oct 2001 21:02:46 GMT</last_modification_time>
|
||||
</signal>
|
||||
<columns>5</columns>
|
||||
<column_widths>33,331,104,168,80</column_widths>
|
||||
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
|
||||
@ -2996,7 +3000,7 @@
|
||||
<class>GtkLabel</class>
|
||||
<child_name>Notebook:tab</child_name>
|
||||
<name>label256</name>
|
||||
<label>label256</label>
|
||||
<label>Media</label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>0.5</xalign>
|
||||
@ -6868,7 +6872,7 @@ Unknown
|
||||
<width>400</width>
|
||||
<history_id>recentdbs</history_id>
|
||||
<max_saved>15</max_saved>
|
||||
<title>Open a GRAMPS Databases</title>
|
||||
<title>Open a GRAMPS Database</title>
|
||||
<directory>True</directory>
|
||||
<modal>False</modal>
|
||||
<child>
|
||||
|
@ -3260,6 +3260,15 @@ def on_main_key_release_event(obj,event):
|
||||
elif event.keyval == GDK.Insert:
|
||||
load_new_person(obj)
|
||||
|
||||
def on_media_list_drag_data_get(w, context, selection_data, info, time):
|
||||
if info == 1:
|
||||
return
|
||||
if len(w.selection) > 0:
|
||||
row = w.selection[0]
|
||||
d = w.get_row_data(row)
|
||||
id = d.getId()
|
||||
selection_data.set(selection_data.target, 8, id)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Main program
|
||||
@ -3307,6 +3316,8 @@ def main(arg):
|
||||
dateArrow = gtop.get_widget("dateSort")
|
||||
deathArrow = gtop.get_widget("deathSort")
|
||||
|
||||
t = [('STRING', 0, 0)]
|
||||
media_list.drag_source_set(GDK.BUTTON1_MASK|GDK.BUTTON3_MASK,t,GDK.ACTION_COPY)
|
||||
person_list.set_column_visibility(5,0)
|
||||
person_list.set_column_visibility(6,0)
|
||||
person_list.set_column_visibility(7,0)
|
||||
@ -3375,6 +3386,7 @@ def main(arg):
|
||||
"on_main_key_release_event" : on_main_key_release_event,
|
||||
"on_media_activate" : on_media_activate,
|
||||
"on_media_list_select_row" : on_media_list_select_row,
|
||||
"on_media_list_drag_data_get" : on_media_list_drag_data_get,
|
||||
"on_places_activate" : on_places_activate,
|
||||
"on_preferences_activate" : on_preferences_activate,
|
||||
"on_remove_child_clicked" : on_remove_child_clicked,
|
||||
|
@ -1262,6 +1262,11 @@
|
||||
<object>marriageEditor</object>
|
||||
<last_modification_time>Thu, 29 Mar 2001 13:59:27 GMT</last_modification_time>
|
||||
</signal>
|
||||
<signal>
|
||||
<name>drag_data_received</name>
|
||||
<handler>on_photolist_drag_data_received</handler>
|
||||
<last_modification_time>Tue, 09 Oct 2001 21:29:08 GMT</last_modification_time>
|
||||
</signal>
|
||||
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
|
||||
<icon_width>100</icon_width>
|
||||
<row_spacing>4</row_spacing>
|
||||
|
Loading…
Reference in New Issue
Block a user