From e499e58d00bd1c742236556d0d6146305bdf7b23 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Mon, 29 Nov 2004 03:24:02 +0000 Subject: [PATCH] * src/EditPerson.py: Allow the photo to accept events, allowing us to display a popup menu similar to galleries * src/gramps.glade: Add eventbox to the image, allowing events * src/MediaView.py: use object handle instead of gramps ID when getting value from the list. svn: r3764 --- ChangeLog | 7 +++++ src/EditPerson.py | 76 ++++++++++++++++++++++++++++++++++++++++++++--- src/MediaView.py | 3 +- src/gramps.glade | 18 +++++++---- 4 files changed, 94 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4149b2503..cf5bf97f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-11-28 Don Allingham + * src/EditPerson.py: Allow the photo to accept events, allowing us + to display a popup menu similar to galleries + * src/gramps.glade: Add eventbox to the image, allowing events + * src/MediaView.py: use object handle instead of gramps ID when + getting value from the list. + 2004-11-27 Don Allingham * src/plugins/PatchNames.py: add the ability to detect common surname prefixes diff --git a/src/EditPerson.py b/src/EditPerson.py index 026d513ec..aad77021e 100644 --- a/src/EditPerson.py +++ b/src/EditPerson.py @@ -49,6 +49,7 @@ import const import Utils import GrampsGconfKeys import GrampsCfg +import GrampsMime import ImageSelect import AutoComp import ListModel @@ -58,6 +59,7 @@ import DateEdit import Date import DateHandler import TransTable +import ImageSelect from QuestionDialog import WarningDialog, ErrorDialog, SaveDialog @@ -223,6 +225,9 @@ class EditPerson: self.inet_label = self.get_widget("inet_label") self.gallery_label = self.get_widget("gallery_label") self.lds_tab = self.get_widget("lds_tab") + self.person_photo = self.get_widget("personPix") + self.eventbox = self.get_widget("eventbox1") + self.get_widget("changed").set_text(person.get_change_display()) self.prefix_label = self.get_widget('prefix_label') @@ -455,6 +460,8 @@ class EditPerson: if self.person.get_complete_flag(): self.complete.set_active(1) + self.eventbox.connect('button-press-event',self.image_button_press) + self.redraw_event_list() self.redraw_attr_list() self.redraw_addr_list() @@ -465,6 +472,67 @@ class EditPerson: self.add_itself_to_winsmenu() self.window.show() + def image_button_press(self,obj,event): + if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: + + media_list = self.person.get_media_list() + if media_list: + ph = media_list[0] + object_handle = ph.get_reference_handle() + obj = self.db.get_object_from_handle(object_handle) + ImageSelect.LocalMediaProperties(ph,obj.get_path(),self,self.window) + elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: + media_list = self.person.get_media_list() + if media_list: + ph = media_list[0] + self.show_popup(ph,event) + + def show_popup(self, photo, event): + """Look for right-clicks on a picture and create a popup + menu of the available actions.""" + + menu = gtk.Menu() + menu.set_title(_("Media Object")) + obj = self.db.get_object_from_handle(photo.get_reference_handle()) + mtype = obj.get_mime_type() + progname = GrampsMime.get_application(mtype) + + if progname and len(progname) > 1: + Utils.add_menuitem(menu,_("Open in %s") % progname[1], + photo,self.popup_view_photo) + if mtype[0:5] == "image": + Utils.add_menuitem(menu,_("Edit with the GIMP"), + photo,self.popup_edit_photo) + Utils.add_menuitem(menu,_("Edit Object Properties"),photo, + self.popup_change_description) + menu.popup(None,None,None,event.button,event.time) + + def popup_view_photo(self, obj): + """Open this picture in a picture viewer""" + media_list = self.person.get_media_list() + if media_list: + ph = media_list[0] + object_handle = ph.get_reference_handle() + Utils.view_photo(self.db.get_object_from_handle(object_handle)) + + def popup_edit_photo(self, obj): + """Open this picture in a picture editor""" + media_list = self.person.get_media_list() + if media_list: + ph = media_list[0] + object_handle = ph.get_reference_handle() + if os.fork() == 0: + obj = self.db.get_object_from_handle(object_handle) + os.execvp(const.editor,[const.editor, obj.get_path()]) + + def popup_change_description(self,obj): + media_list = self.person.get_media_list() + if media_list: + ph = media_list[0] + object_handle = ph.get_reference_handle() + obj = self.db.get_object_from_handle(object_handle) + ImageSelect.LocalMediaProperties(ph,obj.get_path(),self,self.window) + def close_child_windows(self): for child_window in self.child_windows.values(): child_window.close(None) @@ -1442,7 +1510,7 @@ class EditPerson: """loads, scales, and displays the person's main photo""" self.load_obj = photo if photo == None: - self.get_widget("personPix").hide() + self.person_photo.hide() else: try: i = pixbuf_new_from_file(photo) @@ -1451,10 +1519,10 @@ class EditPerson: x = int(scale*(i.get_width())) y = int(scale*(i.get_height())) i = i.scale_simple(x,y,INTERP_BILINEAR) - self.get_widget("personPix").set_from_pixbuf(i) - self.get_widget("personPix").show() + self.person_photo.set_from_pixbuf(i) + self.person_photo.show() except: - self.get_widget("personPix").hide() + self.person_photo.hide() def update_lists(self): """Updates the person's lists if anything has changed""" diff --git a/src/MediaView.py b/src/MediaView.py index 97eeafb18..03780043d 100644 --- a/src/MediaView.py +++ b/src/MediaView.py @@ -337,7 +337,8 @@ class MediaView: if not node: return if (const.dnd_images): - obj = self.db.get_object_from_handle(store.get_value(node,1)) + handle = store.get_value(node,5) + obj = self.db.get_object_from_handle(handle) image = self.db.get_thumbnail_image(obj.get_handle()) context.set_icon_pixbuf(image,0,0) diff --git a/src/gramps.glade b/src/gramps.glade index a8eafe322..8ec647a68 100644 --- a/src/gramps.glade +++ b/src/gramps.glade @@ -9187,12 +9187,20 @@ Other GTK_SHADOW_ETCHED_IN - + True - 0.5 - 0.5 - 0 - 0 + True + False + + + + True + 0.5 + 0.5 + 0 + 0 + +