diff --git a/ChangeLog b/ChangeLog index c8256dc6a..5c214dbe0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,10 @@ * src/DisplayState.py: add standard function for using WATCH cursor * src/PageView.py: enable watch cursor when it is necessary to rebuild a page. + * src/EditMedia.py: break out of ImageSelect, since ImageSelect + will probably go away. Add media editing ability using DisplayTabs. + * src/MediaView.py: call EditMedia + * src/gramps.glade: clean up media editor dialog 2006-02-02 Alex Roitman * src/GrampsDb/_GrampsBSDDB.py (transaction_begin, diff --git a/src/EditMedia.py b/src/EditMedia.py new file mode 100644 index 000000000..7c79b44b9 --- /dev/null +++ b/src/EditMedia.py @@ -0,0 +1,295 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2000-2005 Donald N. Allingham +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# $Id$ + +#------------------------------------------------------------------------- +# +# Standard python modules +# +#------------------------------------------------------------------------- +from gettext import gettext as _ + +#------------------------------------------------------------------------- +# +# GTK/Gnome modules +# +#------------------------------------------------------------------------- +import gobject +import gtk +import gtk.glade + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +import const +import Utils +import RelLib +import GrampsMime +import DateEdit +import DateHandler +import Date +import ImgManip +import DisplayState +import GrampsDisplay + +from QuestionDialog import ErrorDialog +from DdTargets import DdTargets +from WindowUtils import GladeIf +from DisplayTabs import * + +_drag_targets = [ + ('STRING', 0, 0), + ('text/plain',0,0), + ('text/uri-list',0,2), + ('application/x-rootwin-drop',0,1)] + +#------------------------------------------------------------------------- +# +# EditMedia +# +#------------------------------------------------------------------------- +class EditMedia(DisplayState.ManagedWindow): + + def __init__(self,state,uistate,track,obj): + #self.parent = parent + self.dp = DateHandler.parser + self.dd = DateHandler.displayer + + DisplayState.ManagedWindow.__init__(self, uistate, track, obj) + + if self.already_exist: + return + + self.state = state + self.uistate = uistate + + self.pdmap = {} + self.obj = obj + self.lists_changed = 0 + self.db = self.state.db + self.idle = None + if obj: + self.date_object = Date.Date(self.obj.get_date_object()) + self.alist = self.obj.get_attribute_list()[:] + self.refs = 0 + else: + self.date_object = Date.Date() + self.alist = [] + self.refs = 1 + + self.refmodel = None # this becomes the model for the references + + self.path = self.db.get_save_path() + self.change_dialog = gtk.glade.XML(const.gladeFile, + "change_global","gramps") + self.gladeif = GladeIf(self.change_dialog) + + mode = not self.db.readonly + + title = _('Media Properties Editor') + + self.window = self.change_dialog.get_widget('change_global') + self.date_entry = self.change_dialog.get_widget('date') + self.date_entry.set_editable(mode) + + if self.obj: + self.date_entry.set_text(self.dd.display(self.date_object)) + + Utils.set_titles(self.window, + self.change_dialog.get_widget('title'),title) + + self.descr_window = self.change_dialog.get_widget("description") + self.descr_window.set_editable(mode) + self.descr_window.set_text(self.obj.get_description()) + + self.date_edit = self.change_dialog.get_widget("date_edit") + self.date_edit.set_sensitive(mode) + + self.date_check = DateEdit.DateEdit( + self.date_object, self.date_entry, + self.date_edit, self.window) + + self.pixmap = self.change_dialog.get_widget("pixmap") + + mtype = self.obj.get_mime_type() + if mtype: + pb = ImgManip.get_thumbnail_image(self.obj.get_path(),mtype) + self.pixmap.set_from_pixbuf(pb) + descr = GrampsMime.get_description(mtype) + if descr: + self.change_dialog.get_widget("type").set_text(descr) + else: + self.change_dialog.get_widget("type").set_text(_('Note')) + self.pixmap.hide() + + self.change_dialog.get_widget("gid").set_text(self.obj.get_gramps_id()) + + self.update_info() + + self.gladeif.connect('change_global','delete_event', + self.on_delete_event) + self.gladeif.connect('button91','clicked',self.close_window) + self.gladeif.connect('ok','clicked',self.on_ok_clicked) + self.gladeif.connect('button102','clicked',self.on_help_clicked) + + self.vbox = self.change_dialog.get_widget('vbox') + self.notebook = gtk.Notebook() + self.notebook.show() + self.vbox.pack_start(self.notebook,True) + + self.attr_list = AttrEmbedList(self.state, self.uistate, self.track, + self.obj.get_attribute_list()) + self.note_tab = NoteTab(self.state, self.uistate, self.track, + self.obj.get_note_object()) + self.src_list = SourceEmbedList(self.state,self.uistate, + self.track,self.obj.source_list) + + self.notebook.insert_page(self.src_list) + self.notebook.set_tab_label(self.src_list,self.src_list.get_tab_widget()) + + self.notebook.insert_page(self.attr_list) + self.notebook.set_tab_label(self.attr_list,self.attr_list.get_tab_widget()) + + self.notebook.insert_page(self.note_tab) + self.notebook.set_tab_label(self.note_tab,self.note_tab.get_tab_widget()) + self.show() + + def build_menu_names(self,person): + win_menu_label = _("Media Properties") + return (_('Edit Media Object'),win_menu_label) + + def build_window_key(self,person): + if person: + return person.get_handle() + else: + return id(self) + + def on_delete_event(self,obj,b): + self.close() + + def close_window(self,obj): + if self.idle != None: + gobject.source_remove(self.idle) + self.close() + + def update_info(self): + fname = self.obj.get_path() + self.change_dialog.get_widget("path").set_text(fname) + + def on_apply_clicked(self, obj): + t = self.notes.get_buffer() + text = unicode(t.get_text(t.get_start_iter(),t.get_end_iter(),False)) + desc = unicode(self.descr_window.get_text()) + note = self.obj.get_note() + path = self.change_dialog.get_widget('path').get_text() + if path != self.obj.get_path(): + mime = GrampsMime.get_type(path) + self.obj.set_mime_type(mime) + self.obj.set_path(path) + + if not self.date_object.is_equal(self.obj.get_date_object()): + self.obj.set_date_object(self.date_object) + + format = self.preform.get_active() + if text != note or desc != self.obj.get_description(): + self.obj.set_note(text) + self.obj.set_description(desc) + if format != self.obj.get_note_format(): + self.obj.set_note_format(format) + if self.lists_changed: + self.obj.set_attribute_list(self.alist) + self.obj.set_source_reference_list(self.srcreflist) + trans = self.db.transaction_begin() + self.db.commit_media_object(self.obj,trans) + self.db.transaction_commit(trans,_("Edit Media Object")) + + def on_help_clicked(self, obj): + """Display the relevant portion of GRAMPS manual""" + GrampsDisplay.help('adv-media') + + def on_ok_clicked(self, obj): + self.on_apply_clicked(obj) + self.close(obj) + +class DeleteMediaQuery: + + def __init__(self,media_handle,db,the_lists): + self.db = db + self.media_handle = media_handle + self.the_lists = the_lists + + def query_response(self): + trans = self.db.transaction_begin() + self.db.disable_signals() + + (person_list,family_list,event_list, + place_list,source_list) = self.the_lists + + for handle in person_list: + person = self.db.get_person_from_handle(handle) + new_list = [ photo for photo in person.get_media_list() \ + if photo.get_reference_handle() != self.media_handle ] + person.set_media_list(new_list) + self.db.commit_person(person,trans) + + for handle in family_list: + family = self.db.get_family_from_handle(handle) + new_list = [ photo for photo in family.get_media_list() \ + if photo.get_reference_handle() != self.media_handle ] + family.set_media_list(new_list) + self.db.commit_family(family,trans) + + for handle in event_list: + event = self.db.get_event_from_handle(handle) + new_list = [ photo for photo in event.get_media_list() \ + if photo.get_reference_handle() != self.media_handle ] + event.set_media_list(new_list) + self.db.commit_event(event,trans) + + for handle in place_list: + place = self.db.get_place_from_handle(handle) + new_list = [ photo for photo in place.get_media_list() \ + if photo.get_reference_handle() != self.media_handle ] + place.set_media_list(new_list) + self.db.commit_place(place,trans) + + for handle in source_list: + source = self.db.get_source_from_handle(handle) + new_list = [ photo for photo in source.get_media_list() \ + if photo.get_reference_handle() != self.media_handle ] + source.set_media_list(new_list) + self.db.commit_source(source,trans) + + self.db.enable_signals() + self.db.remove_object(self.media_handle,trans) + self.db.transaction_commit(trans,_("Remove Media Object")) + +def build_dropdown(entry,strings): + store = gtk.ListStore(str) + for value in strings: + node = store.append() + store.set(node,0,value) + completion = gtk.EntryCompletion() + completion.set_text_column(0) + completion.set_model(store) + entry.set_completion(completion) diff --git a/src/MediaView.py b/src/MediaView.py index 15c3b1d61..0eba27adc 100644 --- a/src/MediaView.py +++ b/src/MediaView.py @@ -173,8 +173,8 @@ class MediaView(PageView.ListView): obj = self.dbstate.db.get_object_from_handle(handle) if obj.get_mime_type(): - ImageSelect.GlobalMediaProperties(self.dbstate,self.uistate, [], - obj) + import EditMedia + EditMedia.EditMedia(self.dbstate,self.uistate, [], obj) else: import NoteEdit NoteEdit.NoteEditor(obj,self.parent,self.topWindow, diff --git a/src/gramps.glade b/src/gramps.glade index 7fb61453d..e085a52b7 100644 --- a/src/gramps.glade +++ b/src/gramps.glade @@ -11282,8 +11282,8 @@ Very High GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE False - 500 - 400 + 600 + 450 True False gramps.png @@ -11360,7 +11360,7 @@ Very High - + 12 True False @@ -11397,61 +11397,12 @@ Very High False 0 - - - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN - - - - 100 - 100 - True - 0.5 - 0.5 - 0 - 0 - - - - - - True - <b>Preview</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - label_item - - - - - 0 - False - True - - - 12 True - 2 - 2 + 4 + 3 False 6 12 @@ -11475,8 +11426,37 @@ Very High 0 - 0 - 1 + 1 + 2 + 1 + 2 + fill + + + + + + + True + _Title: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + description + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 0 1 fill @@ -11485,12 +11465,33 @@ Very High - + True - Object type: - False + True + True + True + 0 + + True + * + False + + + 2 + 3 + 0 + 1 + + + + + + + True + _Date: + True False - GTK_JUSTIFY_CENTER + GTK_JUSTIFY_LEFT False False 0 @@ -11503,19 +11504,100 @@ Very High 0 - 0 - 1 - 1 - 2 + 1 + 2 + 2 + 3 fill - + True - + False + 0 + + + + True + True + True + True + 0 + + True + * + False + + + 0 + True + True + + + + + + True + Invoke date editor + True + GTK_RELIEF_NONE + True + + + + True + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + + + + 2 + 3 + 2 + 3 + fill + fill + + + + + + True + True + True + True + 0 + + True + * + False + + + 2 + 3 + 1 + 2 + + + + + + + True + Path: False False GTK_JUSTIFY_CENTER @@ -11533,8 +11615,30 @@ Very High 1 2 - 0 - 1 + 3 + 4 + fill + + + + + + + True + True + True + True + 0 + + True + * + False + + + 2 + 3 + 3 + 4 @@ -11548,7 +11652,7 @@ Very High GTK_JUSTIFY_CENTER False False - 0 + 0.5 0.5 0 0 @@ -11558,14 +11662,66 @@ Very High 0 - 1 - 2 - 1 - 2 + 0 + 1 + 3 + 4 fill + + + + True + 0 + 0.5 + GTK_SHADOW_ETCHED_IN + + + + 100 + 100 + True + 0.5 + 0.5 + 0 + 0 + + + + + + True + <b>Preview</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + label_item + + + + + 0 + 1 + 0 + 3 + fill + fill + + 0 @@ -11580,1008 +11736,6 @@ Very High False - - - - True - True - True - True - GTK_POS_TOP - False - False - - - - - True - False - 0 - - - - 12 - True - 3 - 2 - False - 6 - 6 - - - - True - _Title: - True - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - description - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 0 - 1 - fill - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 0 - 1 - - - - - - - True - _Date: - True - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 2 - 3 - fill - - - - - - - True - False - 0 - - - - True - True - True - True - 0 - - True - * - False - - - 0 - True - True - - - - - - True - Invoke date editor - True - GTK_RELIEF_NONE - True - - - - True - 0.5 - 0.5 - 0 - 0 - - - - - 0 - False - False - - - - - 1 - 2 - 2 - 3 - fill - fill - - - - - - True - Path: - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 1 - 1 - 2 - fill - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 1 - 2 - - - - - - 0 - True - True - - - - - False - True - - - - - - True - <b>General</b> - False - True - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - tab - - - - - - True - False - 0 - - - - 12 - True - 3 - 3 - False - 6 - 12 - - - - True - Value: - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 2 - 3 - fill - - - - - - - True - - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 2 - 3 - 2 - 3 - - - - - - - True - Type: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 1 - 2 - fill - - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 2 - 3 - 1 - 2 - fill - - - - - - - True - <b>Attributes</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 3 - 0 - 1 - fill - - - - - - 0 - False - True - - - - - - 6 - True - False - 6 - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - False - True - False - False - False - - - - - 0 - True - True - - - - - - True - False - 6 - - - - True - Creates a new attribute from the above data - True - GTK_RELIEF_NORMAL - True - - - - - True - gtk-add - 4 - 0.5 - 0.5 - 0 - 0 - - - - - 0 - False - False - - - - - - True - True - GTK_RELIEF_NORMAL - True - - - - - True - edit_sm.png - 0.5 - 0.5 - 0 - 0 - - - - - 0 - False - False - - - - - - True - Delete the selected attribute - True - True - GTK_RELIEF_NORMAL - True - - - - - True - gtk-remove - 4 - 0.5 - 0.5 - 0 - 0 - - - - - 0 - False - False - - - - - - - - - 0 - False - True - - - - - 0 - True - True - - - - - - True - GTK_BUTTONBOX_SPREAD - 30 - - - 0 - False - True - - - - - False - True - - - - - - True - Attributes - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - tab - - - - - - True - False - 0 - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - True - GTK_JUSTIFY_LEFT - GTK_WRAP_WORD - True - 0 - 0 - 0 - 0 - 0 - 0 - - - - - - 0 - True - True - - - - - - 12 - True - 2 - 3 - False - 12 - 24 - - - - True - <b>Format</b> - True - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - 3 - 0 - 1 - fill - - - - - - - True - Multiple spaces, tabs, and single line breaks are replaced with single spaces. Two consecutive line breaks mark a new paragraph. - True - _Flowed - True - GTK_RELIEF_NORMAL - True - True - False - True - - - 1 - 2 - 1 - 2 - - - - - - - - True - Formatting is preserved, except for the leading whitespace. Multiple spaces, tabs, and all line breaks are respected. - True - _Preformatted - True - GTK_RELIEF_NORMAL - True - False - False - True - global_flowed - - - 2 - 3 - 1 - 2 - - - - - - - 0 - False - True - - - - - False - True - - - - - - True - Notes - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - tab - - - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - False - True - False - False - False - - - - - False - True - - - - - - True - References - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - tab - - - - - - True - False - 0 - - - - 6 - True - False - 6 - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - False - True - False - False - False - - - - - 0 - True - True - - - - - - True - False - 6 - - - - True - True - GTK_RELIEF_NORMAL - True - - - - True - gtk-add - 4 - 0.5 - 0.5 - 0 - 0 - - - - - 0 - False - False - - - - - - True - True - GTK_RELIEF_NORMAL - True - - - - True - edit_sm.png - 0.5 - 0.5 - 0 - 0 - - - - - 0 - False - False - - - - - - True - True - GTK_RELIEF_NORMAL - True - - - - True - gtk-remove - 4 - 0.5 - 0.5 - 0 - 0 - - - - - 0 - False - False - - - - - - - - - 0 - False - True - - - - - 0 - True - True - - - - - - True - GTK_BUTTONBOX_SPREAD - 30 - - - 0 - False - True - - - - - False - True - - - - - - True - Sources - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - tab - - - - - 0 - True - True - - 0