diff --git a/gramps/src/EditPerson.glade b/gramps/src/EditPerson.glade index b4427895c..b55c42296 100644 --- a/gramps/src/EditPerson.glade +++ b/gramps/src/EditPerson.glade @@ -3548,6 +3548,11 @@ editPerson Tue, 27 Mar 2001 22:01:31 GMT + + drag_data_received + on_photolist_drag_data_received + Tue, 09 Oct 2001 20:50:19 GMT + GTK_SELECTION_SINGLE 100 20 diff --git a/gramps/src/EditPerson.py b/gramps/src/EditPerson.py index eea314833..207001de8 100644 --- a/gramps/src/EditPerson.py +++ b/gramps/src/EditPerson.py @@ -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") diff --git a/gramps/src/ImageSelect.py b/gramps/src/ImageSelect.py index 464a44b73..aaa2f3734 100644 --- a/gramps/src/ImageSelect.py +++ b/gramps/src/ImageSelect.py @@ -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) #------------------------------------------------------------------------- # diff --git a/gramps/src/Marriage.py b/gramps/src/Marriage.py index cdfaa1ef0..7b66abb02 100644 --- a/gramps/src/Marriage.py +++ b/gramps/src/Marriage.py @@ -25,6 +25,7 @@ #------------------------------------------------------------------------- from gtk import * from gnome.ui import * +import GDK import libglade import os diff --git a/gramps/src/gramps.glade b/gramps/src/gramps.glade index d2447c753..2f9933ad8 100644 --- a/gramps/src/gramps.glade +++ b/gramps/src/gramps.glade @@ -610,13 +610,14 @@ GtkNotebook GnomeDock:contents notebook1 + True switch_page on_notebook1_switch_page True Fri, 20 Oct 2000 01:16:41 GMT - False + True True GTK_POS_TOP False @@ -2444,8 +2445,6 @@ preview 100 100 - 96 - 96 @@ -2875,6 +2874,11 @@ on_media_list_select_row Tue, 09 Oct 2001 17:22:54 GMT + + drag_data_get + on_media_list_drag_data_get + Tue, 09 Oct 2001 21:02:46 GMT + 5 33,331,104,168,80 GTK_SELECTION_SINGLE @@ -2996,7 +3000,7 @@ GtkLabel Notebook:tab label256 - + GTK_JUSTIFY_CENTER False 0.5 @@ -6868,7 +6872,7 @@ Unknown 400 recentdbs 15 - Open a GRAMPS Databases + Open a GRAMPS Database True False diff --git a/gramps/src/gramps_main.py b/gramps/src/gramps_main.py index 518acd1e2..444d8e8fe 100755 --- a/gramps/src/gramps_main.py +++ b/gramps/src/gramps_main.py @@ -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, diff --git a/gramps/src/marriage.glade b/gramps/src/marriage.glade index 023bfe20a..33869daf3 100644 --- a/gramps/src/marriage.glade +++ b/gramps/src/marriage.glade @@ -1262,6 +1262,11 @@ marriageEditor Thu, 29 Mar 2001 13:59:27 GMT + + drag_data_received + on_photolist_drag_data_received + Tue, 09 Oct 2001 21:29:08 GMT + GTK_SELECTION_SINGLE 100 4