From 9bb495d06ad39925510eb9e4176cb5e57dbca690 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sun, 10 Dec 2006 04:24:11 +0000 Subject: [PATCH] 2006-12-09 Don Allingham * src/DataViews/_MediaView.py: external view support for media objects * src/Editors/_EditPlace.py: external view support for media objects * src/Editors/_EditMediaRef.py: external view support for media objects * src/Editors/_EditMedia.py: external view support for media objects * src/glade/gramps.glade: external view support for media objects svn: r7773 --- gramps2/ChangeLog | 7 ++++ gramps2/src/DataViews/_MediaView.py | 33 ++++++++++++++++-- gramps2/src/Editors/_EditMedia.py | 15 +++++++++ gramps2/src/Editors/_EditMediaRef.py | 16 ++++++++- gramps2/src/Editors/_EditPlace.py | 2 +- gramps2/src/glade/gramps.glade | 50 +++++++++++++++++++--------- 6 files changed, 102 insertions(+), 21 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 81ea857f1..43a6e99e2 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,10 @@ +2006-12-09 Don Allingham + * src/DataViews/_MediaView.py: external view support for media objects + * src/Editors/_EditPlace.py: external view support for media objects + * src/Editors/_EditMediaRef.py: external view support for media objects + * src/Editors/_EditMedia.py: external view support for media objects + * src/glade/gramps.glade: external view support for media objects + 2006-12-09 Benny Malengier * src/PlaceUtils.py: better parsing of longitude/latitude diff --git a/gramps2/src/DataViews/_MediaView.py b/gramps2/src/DataViews/_MediaView.py index a82a46d24..fbaa3cf76 100644 --- a/gramps2/src/DataViews/_MediaView.py +++ b/gramps2/src/DataViews/_MediaView.py @@ -179,8 +179,21 @@ class MediaView(PageView.ListView): self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES, _('_Column Editor'), callback=self.column_editor) self.add_action('FilterEdit', None, _('Media Filter Editor'), - callback=self.filter_editor,) + callback=self.filter_editor) + self.add_action('OpenMedia', None, _('View in an external viewer'), + callback=self.view_media) + def view_media(self, obj): + mlist = [] + self.selection.selected_foreach(self.blist,mlist) + + for handle in mlist: + ref_obj = self.dbstate.db.get_object_from_handle(handle) + mime_type = ref_obj.get_mime_type() + app = Mime.get_application(mime_type) + if app: + Utils.launch(app[0],ref_obj.get_path()) + def filter_toggle(self, client, cnxn_id, etnry, data): if Config.get(Config.FILTER): self.search_bar.hide() @@ -229,26 +242,39 @@ class MediaView(PageView.ListView): self.image = gtk.Image() self.image.set_size_request(int(const.thumbScale), int(const.thumbScale)) - vbox.pack_start(self.image,False) - vbox.pack_start(base,True) + ebox = gtk.EventBox() + ebox.add(self.image) + ebox.connect('button-press-event', self.button_press_event) + vbox.pack_start(ebox, False) + vbox.pack_start(base, True) + + self.tt = gtk.Tooltips() + self.tt.set_tip(ebox, _('Double click image to view in an external viewer')) self.selection.connect('changed',self.row_change) self._set_dnd() return vbox + def button_press_event(self, obj, event): + if event.button==1 and event.type == gtk.gdk._2BUTTON_PRESS: + self.view_media(obj) + def row_change(self,obj): handle = self.first_selected() if not handle: try: self.image.clear() + self.tt.disable() except AttributeError: # Working around the older pygtk # that lacks clear() method for gtk.Image() self.image.set_from_file(None) + self.tt.enable() else: obj = self.dbstate.db.get_object_from_handle(handle) pix = ImgManip.get_thumbnail_image(obj.get_path()) self.image.set_from_pixbuf(pix) + self.tt.enable() def ui_definition(self): return ''' @@ -279,6 +305,7 @@ class MediaView(PageView.ListView): + ''' diff --git a/gramps2/src/Editors/_EditMedia.py b/gramps2/src/Editors/_EditMedia.py index 49ce56e6c..d761a4340 100644 --- a/gramps2/src/Editors/_EditMedia.py +++ b/gramps2/src/Editors/_EditMedia.py @@ -117,11 +117,13 @@ class EditMedia(EditPrimary): self.obj, self.db.readonly) pixmap = self.glade.get_widget("pixmap") + ebox = self.glade.get_widget('eventbox') mtype = self.obj.get_mime_type() if mtype: pb = ImgManip.get_thumbnail_image(self.obj.get_path(),mtype) pixmap.set_from_pixbuf(pb) + ebox.connect('button-press-event', self.button_press_event) descr = Mime.get_description(mtype) if descr: self.glade.get_widget("type").set_text(descr) @@ -175,6 +177,19 @@ class EditMedia(EditPrimary): def build_menu_names(self,person): return (_('Edit Media Object'), self.get_menu_title()) + def button_press_event(self, obj, event): + if event.button==1 and event.type == gtk.gdk._2BUTTON_PRESS: + self.view_media(obj) + + def view_media(self, obj): + + ref_obj = self.dbstate.db.get_object_from_handle(self.obj.handle) + mime_type = ref_obj.get_mime_type() + app = Mime.get_application(mime_type) + if app: + import Utils + Utils.launch(app[0],ref_obj.get_path()) + def select_file(self,obj): f = gtk.FileChooserDialog( _('Select Media Object'), diff --git a/gramps2/src/Editors/_EditMediaRef.py b/gramps2/src/Editors/_EditMediaRef.py index bc338879c..ce51eafd6 100644 --- a/gramps2/src/Editors/_EditMediaRef.py +++ b/gramps2/src/Editors/_EditMediaRef.py @@ -1,4 +1,4 @@ -# +0# # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham @@ -80,6 +80,9 @@ class EditMediaRef(EditReference): self.pix = ImgManip.get_thumbnail_image(self.source.get_path(),mtype) self.pixmap = self.top.get_widget("pixmap") + ebox = self.top.get_widget('eventbox') + ebox.connect('button-press-event', self.button_press_event) + self.pixmap.set_from_pixbuf(self.pix) coord = self.source_ref.get_rectangle() @@ -124,6 +127,17 @@ class EditMediaRef(EditReference): else: self.top.get_widget("type").set_text("") + def button_press_event(self, obj, event): + if event.button==1 and event.type == gtk.gdk._2BUTTON_PRESS: + self.view_media(obj) + + def view_media(self, obj): + mime_type = self.source.get_mime_type() + app = Mime.get_application(mime_type) + if app: + import Utils + Utils.launch(app[0],self.source.get_path()) + def _connect_signals(self): self.define_cancel_button(self.top.get_widget('button84')) self.define_ok_button(self.top.get_widget('button82'),self.save) diff --git a/gramps2/src/Editors/_EditPlace.py b/gramps2/src/Editors/_EditPlace.py index e6f16e77e..afa72b5e5 100644 --- a/gramps2/src/Editors/_EditPlace.py +++ b/gramps2/src/Editors/_EditPlace.py @@ -74,7 +74,7 @@ class EditPlace(EditPrimary): self.window.show() def get_menu_title(self): - if self.obj.get_handle(): + if self.obj and self.obj.get_handle(): title = self.obj.get_title() dialog_title = _('Place: %s') % title else: diff --git a/gramps2/src/glade/gramps.glade b/gramps2/src/glade/gramps.glade index 4de1eb183..d8c436535 100644 --- a/gramps2/src/glade/gramps.glade +++ b/gramps2/src/glade/gramps.glade @@ -1583,7 +1583,7 @@ True - North/South position, eg 50.84988, 50°50'59.60"N or 50:50:59.60 + North/South position, eg 50.84988, 50°50'59.60"N or 50:50:59.60 True True True @@ -1634,7 +1634,7 @@ True - East/West position, eg -2.88589, 2°53'9.23" W or -2:53:9.23 + East/West position, eg -2.88589, 2°53'9.23" W or -2:53:9.23 True True True @@ -5129,14 +5129,23 @@ GTK_SHADOW_ETCHED_IN - - 100 - 100 + True - 0.5 - 0.5 - 0 - 0 + Double click image to view in an external viewer + True + False + + + + 100 + 100 + True + 0.5 + 0.5 + 0 + 0 + + @@ -5615,14 +5624,23 @@ GTK_SHADOW_ETCHED_IN - - 100 - 100 + True - 0.5 - 0.5 - 0 - 0 + Double click image to view in an external viewer + True + False + + + + 100 + 100 + True + 0.5 + 0.5 + 0 + 0 + +