* 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
This commit is contained in:
Don Allingham 2004-11-29 03:24:02 +00:00
parent 6cfc4f5ac0
commit f451761fb9
4 changed files with 94 additions and 10 deletions

View File

@ -1,3 +1,10 @@
2004-11-28 Don Allingham <dallingham@users.sourceforge.net>
* 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 <dallingham@users.sourceforge.net> 2004-11-27 Don Allingham <dallingham@users.sourceforge.net>
* src/plugins/PatchNames.py: add the ability to detect * src/plugins/PatchNames.py: add the ability to detect
common surname prefixes common surname prefixes

View File

@ -49,6 +49,7 @@ import const
import Utils import Utils
import GrampsGconfKeys import GrampsGconfKeys
import GrampsCfg import GrampsCfg
import GrampsMime
import ImageSelect import ImageSelect
import AutoComp import AutoComp
import ListModel import ListModel
@ -58,6 +59,7 @@ import DateEdit
import Date import Date
import DateHandler import DateHandler
import TransTable import TransTable
import ImageSelect
from QuestionDialog import WarningDialog, ErrorDialog, SaveDialog from QuestionDialog import WarningDialog, ErrorDialog, SaveDialog
@ -223,6 +225,9 @@ class EditPerson:
self.inet_label = self.get_widget("inet_label") self.inet_label = self.get_widget("inet_label")
self.gallery_label = self.get_widget("gallery_label") self.gallery_label = self.get_widget("gallery_label")
self.lds_tab = self.get_widget("lds_tab") 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.get_widget("changed").set_text(person.get_change_display())
self.prefix_label = self.get_widget('prefix_label') self.prefix_label = self.get_widget('prefix_label')
@ -455,6 +460,8 @@ class EditPerson:
if self.person.get_complete_flag(): if self.person.get_complete_flag():
self.complete.set_active(1) self.complete.set_active(1)
self.eventbox.connect('button-press-event',self.image_button_press)
self.redraw_event_list() self.redraw_event_list()
self.redraw_attr_list() self.redraw_attr_list()
self.redraw_addr_list() self.redraw_addr_list()
@ -465,6 +472,67 @@ class EditPerson:
self.add_itself_to_winsmenu() self.add_itself_to_winsmenu()
self.window.show() 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): def close_child_windows(self):
for child_window in self.child_windows.values(): for child_window in self.child_windows.values():
child_window.close(None) child_window.close(None)
@ -1442,7 +1510,7 @@ class EditPerson:
"""loads, scales, and displays the person's main photo""" """loads, scales, and displays the person's main photo"""
self.load_obj = photo self.load_obj = photo
if photo == None: if photo == None:
self.get_widget("personPix").hide() self.person_photo.hide()
else: else:
try: try:
i = pixbuf_new_from_file(photo) i = pixbuf_new_from_file(photo)
@ -1451,10 +1519,10 @@ class EditPerson:
x = int(scale*(i.get_width())) x = int(scale*(i.get_width()))
y = int(scale*(i.get_height())) y = int(scale*(i.get_height()))
i = i.scale_simple(x,y,INTERP_BILINEAR) i = i.scale_simple(x,y,INTERP_BILINEAR)
self.get_widget("personPix").set_from_pixbuf(i) self.person_photo.set_from_pixbuf(i)
self.get_widget("personPix").show() self.person_photo.show()
except: except:
self.get_widget("personPix").hide() self.person_photo.hide()
def update_lists(self): def update_lists(self):
"""Updates the person's lists if anything has changed""" """Updates the person's lists if anything has changed"""

View File

@ -337,7 +337,8 @@ class MediaView:
if not node: if not node:
return return
if (const.dnd_images): 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()) image = self.db.get_thumbnail_image(obj.get_handle())
context.set_icon_pixbuf(image,0,0) context.set_icon_pixbuf(image,0,0)

View File

@ -9187,12 +9187,20 @@ Other</property>
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property> <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
<child> <child>
<widget class="GtkImage" id="personPix"> <widget class="GtkEventBox" id="eventbox1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0.5</property> <property name="visible_window">True</property>
<property name="yalign">0.5</property> <property name="above_child">False</property>
<property name="xpad">0</property>
<property name="ypad">0</property> <child>
<widget class="GtkImage" id="personPix">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget> </widget>
</child> </child>