2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2005-01-11 09:47:53 +05:30
|
|
|
# Copyright (C) 2000-2005 Donald N. Allingham
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
|
2003-10-20 08:17:03 +05:30
|
|
|
# $Id$
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Standard python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import os
|
2005-12-06 12:08:09 +05:30
|
|
|
import gc
|
2002-11-03 02:49:58 +05:30
|
|
|
import urlparse
|
2004-08-31 23:57:57 +05:30
|
|
|
from gettext import gettext as _
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-02-24 05:55:34 +05:30
|
|
|
import gobject
|
2002-10-20 19:55:16 +05:30
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
|
|
|
import Utils
|
2005-01-06 22:58:31 +05:30
|
|
|
import GrampsKeys
|
2005-01-01 09:57:15 +05:30
|
|
|
import NameDisplay
|
2005-03-08 08:44:25 +05:30
|
|
|
import PluginMgr
|
2003-01-10 10:51:32 +05:30
|
|
|
import RelLib
|
2002-10-20 19:55:16 +05:30
|
|
|
import RelImage
|
2002-10-25 10:22:51 +05:30
|
|
|
import ListModel
|
2003-12-12 11:06:38 +05:30
|
|
|
import SelectObject
|
2004-04-04 10:09:52 +05:30
|
|
|
import GrampsMime
|
2004-06-03 11:05:30 +05:30
|
|
|
import Sources
|
2004-11-06 09:01:34 +05:30
|
|
|
import DateEdit
|
|
|
|
import DateHandler
|
|
|
|
import Date
|
2005-01-09 07:48:49 +05:30
|
|
|
import ImgManip
|
2005-08-18 11:28:28 +05:30
|
|
|
import Spell
|
2005-12-06 12:08:09 +05:30
|
|
|
import GrampsDisplay
|
|
|
|
|
2002-10-21 06:48:07 +05:30
|
|
|
from QuestionDialog import ErrorDialog
|
2005-04-01 20:45:36 +05:30
|
|
|
from DdTargets import DdTargets
|
2005-12-06 12:08:09 +05:30
|
|
|
from WindowUtils import GladeIf
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
_IMAGEX = 140
|
|
|
|
_IMAGEY = 150
|
2002-11-08 09:12:25 +05:30
|
|
|
_PAD = 5
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-08-13 09:58:07 +05:30
|
|
|
_last_path = ""
|
2002-12-17 10:42:28 +05:30
|
|
|
_iconlist_refs = []
|
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
_drag_targets = [
|
|
|
|
('STRING', 0, 0),
|
|
|
|
('text/plain',0,0),
|
|
|
|
('text/uri-list',0,2),
|
|
|
|
('application/x-rootwin-drop',0,1)]
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# ImageSelect class
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class ImageSelect:
|
|
|
|
|
2003-09-15 09:46:12 +05:30
|
|
|
def __init__(self, path, db, parent, parent_window=None):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""Creates an edit window. Associates a person with the window."""
|
|
|
|
self.path = path;
|
|
|
|
self.db = db
|
|
|
|
self.dataobj = None
|
2002-11-08 09:12:25 +05:30
|
|
|
self.parent = parent
|
2003-09-15 09:46:12 +05:30
|
|
|
self.parent_window = parent_window
|
2002-11-08 09:12:25 +05:30
|
|
|
self.canvas_list = {}
|
2003-01-06 10:44:49 +05:30
|
|
|
self.p_map = {}
|
2003-04-09 08:59:08 +05:30
|
|
|
self.canvas = None
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def add_thumbnail(self, photo):
|
|
|
|
"should be overrridden"
|
|
|
|
pass
|
|
|
|
|
|
|
|
def load_images(self):
|
|
|
|
"should be overrridden"
|
|
|
|
pass
|
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
def internal_toggled(self, obj):
|
|
|
|
self.fname.set_sensitive(not obj.get_active())
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def create_add_dialog(self):
|
|
|
|
"""Create the gnome dialog for selecting a new photo and entering
|
|
|
|
its description."""
|
|
|
|
|
|
|
|
if self.path == '':
|
|
|
|
return
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2003-08-17 07:44:33 +05:30
|
|
|
self.glade = gtk.glade.XML(const.imageselFile,"imageSelect","gramps")
|
2003-12-02 09:57:23 +05:30
|
|
|
self.window = self.glade.get_widget("imageSelect")
|
2003-03-06 11:42:51 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.fname = self.glade.get_widget("fname")
|
|
|
|
self.image = self.glade.get_widget("image")
|
2005-12-06 12:08:09 +05:30
|
|
|
self.internal = self.glade.get_widget("internal")
|
|
|
|
self.internal.connect('toggled',self.internal_toggled)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.description = self.glade.get_widget("photoDescription")
|
|
|
|
self.temp_name = ""
|
|
|
|
|
2003-12-02 09:57:23 +05:30
|
|
|
Utils.set_titles(self.window,self.glade.get_widget('title'),
|
2003-03-06 11:42:51 +05:30
|
|
|
_('Select a media object'))
|
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
self.gladeif = GladeIf(self.glade)
|
|
|
|
self.gladeif.connect('fname', 'update_preview', self.on_name_changed)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-08-13 09:58:07 +05:30
|
|
|
if os.path.isdir(_last_path):
|
2004-05-06 09:56:47 +05:30
|
|
|
self.fname.set_current_folder(_last_path)
|
2003-09-15 09:46:12 +05:30
|
|
|
|
|
|
|
if self.parent_window:
|
2003-12-02 09:57:23 +05:30
|
|
|
self.window.set_transient_for(self.parent_window)
|
|
|
|
self.window.show()
|
|
|
|
self.val = self.window.run()
|
|
|
|
if self.val == gtk.RESPONSE_OK:
|
2003-09-15 09:46:12 +05:30
|
|
|
self.on_savephoto_clicked()
|
2003-12-02 09:57:23 +05:30
|
|
|
self.window.destroy()
|
2005-12-06 12:08:09 +05:30
|
|
|
gc.collect()
|
2003-12-02 09:57:23 +05:30
|
|
|
|
|
|
|
def on_help_imagesel_clicked(self,obj):
|
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
2005-12-06 12:08:09 +05:30
|
|
|
GrampsDisplay.help('gramps-edit-quick')
|
2003-12-02 09:57:23 +05:30
|
|
|
self.val = self.window.run()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def on_name_changed(self, obj):
|
|
|
|
"""The filename has changed. Verify it and load the picture."""
|
2004-05-06 09:56:47 +05:30
|
|
|
filename = unicode(self.fname.get_filename())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
basename = os.path.basename(filename)
|
|
|
|
(root,ext) = os.path.splitext(basename)
|
2003-12-17 10:53:16 +05:30
|
|
|
old_title = unicode(self.description.get_text())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if old_title == "" or old_title == self.temp_name:
|
|
|
|
self.description.set_text(root)
|
|
|
|
self.temp_name = root
|
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
filename = Utils.find_file( filename)
|
|
|
|
if filename:
|
2004-08-20 17:41:56 +05:30
|
|
|
mtype = GrampsMime.get_type(filename)
|
2005-05-24 18:38:06 +05:30
|
|
|
if mtype and mtype.startswith("image"):
|
2002-10-20 19:55:16 +05:30
|
|
|
image = RelImage.scale_image(filename,const.thumbScale)
|
|
|
|
self.image.set_from_pixbuf(image)
|
|
|
|
else:
|
2005-02-24 05:55:34 +05:30
|
|
|
i = Utils.find_mime_type_pixbuf(mtype)
|
2003-02-04 00:54:27 +05:30
|
|
|
self.image.set_from_pixbuf(i)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-09-15 09:46:12 +05:30
|
|
|
def on_savephoto_clicked(self):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""Save the photo in the dataobj object. (Required function)"""
|
2003-08-13 09:58:07 +05:30
|
|
|
global _last_path
|
2004-10-23 09:26:48 +05:30
|
|
|
|
2004-05-06 09:56:47 +05:30
|
|
|
filename = self.fname.get_filename()
|
2003-08-13 09:58:07 +05:30
|
|
|
_last_path = os.path.dirname(filename)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-12-17 10:53:16 +05:30
|
|
|
description = unicode(self.description.get_text())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
internal = self.internal.get_active()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
if not internal:
|
|
|
|
if os.path.exists(filename) == 0:
|
|
|
|
msgstr = _("Cannot import %s")
|
|
|
|
msgstr2 = _("The filename supplied could not be found.")
|
|
|
|
ErrorDialog(msgstr % filename, msgstr2)
|
|
|
|
return
|
2004-05-24 10:02:19 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
already_imported = None
|
|
|
|
|
|
|
|
for o_id in self.db.get_media_object_handles():
|
|
|
|
o = self.db.get_object_from_handle(o_id)
|
|
|
|
if o.get_path() == filename:
|
|
|
|
already_imported = o
|
|
|
|
break
|
|
|
|
|
|
|
|
if already_imported:
|
|
|
|
oref = RelLib.MediaRef()
|
|
|
|
oref.set_reference_handle(already_imported.get_handle())
|
|
|
|
self.dataobj.add_media_reference(oref)
|
|
|
|
self.add_thumbnail(oref)
|
|
|
|
else:
|
|
|
|
mtype = GrampsMime.get_type(filename)
|
|
|
|
mobj = RelLib.MediaObject()
|
|
|
|
if description == "":
|
|
|
|
description = os.path.basename(filename)
|
|
|
|
mobj.set_description(description)
|
|
|
|
mobj.set_mime_type(mtype)
|
|
|
|
mobj.set_path(filename)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-02-21 11:41:59 +05:30
|
|
|
mobj = RelLib.MediaObject()
|
2004-02-14 11:10:30 +05:30
|
|
|
mobj.set_description(description)
|
2005-12-06 12:08:09 +05:30
|
|
|
mobj.set_mime_type(None)
|
2004-05-24 10:02:19 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
if not already_imported:
|
|
|
|
trans = self.db.transaction_begin()
|
|
|
|
self.savephoto(mobj,trans)
|
|
|
|
self.db.transaction_commit(trans,'Edit Media Objects')
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.parent.lists_changed = 1
|
|
|
|
self.load_images()
|
|
|
|
|
2005-04-04 21:08:36 +05:30
|
|
|
def savephoto(self, photo, transaction):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""Save the photo in the dataobj object - must be overridden"""
|
2004-08-31 23:57:57 +05:30
|
|
|
pass
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Gallery class - This class handles all the logic underlying a
|
|
|
|
# picture gallery. This class does not load or contain the widget
|
|
|
|
# data structure to actually display the gallery.
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class Gallery(ImageSelect):
|
2004-05-14 04:15:51 +05:30
|
|
|
def __init__(self, dataobj, commit, path, icon_list, db, parent, parent_window=None):
|
2003-09-15 09:46:12 +05:30
|
|
|
ImageSelect.__init__(self, path, db, parent, parent_window)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-05-14 04:15:51 +05:30
|
|
|
self.commit = commit
|
2002-10-20 19:55:16 +05:30
|
|
|
if path:
|
2005-04-01 20:45:36 +05:30
|
|
|
icon_list.drag_dest_set(gtk.DEST_DEFAULT_ALL,
|
|
|
|
[DdTargets.MEDIAOBJ.target()]+_drag_targets,
|
2002-10-20 19:55:16 +05:30
|
|
|
gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE)
|
2002-11-08 09:12:25 +05:30
|
|
|
icon_list.connect('event',self.item_event)
|
2005-12-06 12:08:09 +05:30
|
|
|
if not db.readonly:
|
|
|
|
icon_list.connect("drag_data_received",
|
2002-10-20 19:55:16 +05:30
|
|
|
self.on_photolist_drag_data_received)
|
|
|
|
icon_list.connect("drag_data_get",
|
|
|
|
self.on_photolist_drag_data_get)
|
2003-05-17 08:50:50 +05:30
|
|
|
icon_list.connect("drag_begin", self.on_drag_begin)
|
2002-11-08 09:12:25 +05:30
|
|
|
|
2002-12-17 10:42:28 +05:30
|
|
|
_iconlist_refs.append(icon_list)
|
2003-07-06 09:22:38 +05:30
|
|
|
self.in_event = 0
|
2004-08-31 23:57:57 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
# Remember arguments
|
|
|
|
self.path = path;
|
|
|
|
self.dataobj = dataobj;
|
|
|
|
self.iconlist = icon_list;
|
2002-11-28 11:22:02 +05:30
|
|
|
self.root = self.iconlist.root()
|
2004-08-11 09:12:38 +05:30
|
|
|
self.old_media_list = [RelLib.MediaRef(ref) for ref in dataobj.get_media_list()]
|
2004-08-27 09:11:57 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
# Local object variables
|
|
|
|
self.y = 0
|
2002-11-08 09:12:25 +05:30
|
|
|
self.remember_x = -1
|
|
|
|
self.remember_y = -1
|
|
|
|
self.button = None
|
|
|
|
self.drag_item = None
|
|
|
|
self.sel = None
|
|
|
|
self.photo = None
|
|
|
|
|
2004-08-04 10:23:29 +05:30
|
|
|
def close(self):
|
2002-12-11 10:48:47 +05:30
|
|
|
self.iconlist.hide()
|
2004-02-21 12:10:44 +05:30
|
|
|
if self.canvas_list:
|
|
|
|
for a in self.canvas_list.values():
|
|
|
|
a[0].destroy()
|
|
|
|
a[1].destroy()
|
|
|
|
a[2].destroy()
|
2002-12-11 10:48:47 +05:30
|
|
|
self.p_map = None
|
2002-12-17 10:42:28 +05:30
|
|
|
self.canvas_list = None
|
2002-11-27 11:26:23 +05:30
|
|
|
|
2002-11-08 09:12:25 +05:30
|
|
|
def on_canvas1_event(self,obj,event):
|
2003-01-06 10:44:49 +05:30
|
|
|
"""
|
|
|
|
Handle resize events over the canvas, redrawing if the size changes
|
|
|
|
"""
|
2004-02-22 00:29:45 +05:30
|
|
|
pass
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-05-17 08:50:50 +05:30
|
|
|
def on_drag_begin(self,obj,context):
|
2003-06-07 19:41:52 +05:30
|
|
|
if const.dnd_images:
|
2004-08-20 17:41:56 +05:30
|
|
|
handle = self.sel_obj.get_reference_handle()
|
2005-01-09 07:48:49 +05:30
|
|
|
media_obj = self.db.get_object_from_handle(handle)
|
2005-12-06 12:08:09 +05:30
|
|
|
pix = ImgManip.get_thumbnail_image(media_obj.get_path(),
|
|
|
|
media_obj.get_mime_type())
|
2003-05-17 08:50:50 +05:30
|
|
|
context.set_icon_pixbuf(pix,0,0)
|
|
|
|
|
2002-11-03 02:49:58 +05:30
|
|
|
def item_event(self, widget, event=None):
|
|
|
|
|
2003-07-06 09:22:38 +05:30
|
|
|
if self.in_event:
|
2005-12-06 12:08:09 +05:30
|
|
|
return False
|
|
|
|
|
2003-07-06 09:22:38 +05:30
|
|
|
self.in_event = 1
|
2002-11-08 09:12:25 +05:30
|
|
|
if self.button and event.type == gtk.gdk.MOTION_NOTIFY :
|
2004-02-06 12:14:22 +05:30
|
|
|
if widget.drag_check_threshold(int(self.remember_x),int(self.remember_y),
|
2004-02-04 10:12:06 +05:30
|
|
|
int(event.x),int(event.y)):
|
2002-11-25 10:00:36 +05:30
|
|
|
self.drag_item = widget.get_item_at(self.remember_x,
|
|
|
|
self.remember_y)
|
2005-08-18 11:28:28 +05:30
|
|
|
icon_index = self.get_index(widget,event.x,event.y)
|
2005-05-24 18:38:06 +05:30
|
|
|
if icon_index == -1:
|
|
|
|
return
|
2005-08-18 11:28:28 +05:30
|
|
|
for i in self.dataobj.get_media_list():
|
|
|
|
handle = i.get_reference_handle()
|
|
|
|
m = self.db.get_object_from_handle(handle)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
media_list = self.dataobj.get_media_list()
|
|
|
|
|
|
|
|
if icon_index >= len(media_list):
|
|
|
|
return False
|
|
|
|
self.sel_obj = media_list[icon_index]
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
handle = self.sel_obj.get_reference_handle()
|
|
|
|
media_obj = self.db.get_object_from_handle(handle)
|
|
|
|
|
2002-11-08 09:12:25 +05:30
|
|
|
if self.drag_item:
|
2005-04-01 20:45:36 +05:30
|
|
|
widget.drag_begin([DdTargets.MEDIAOBJ.target()]+_drag_targets,
|
2003-01-10 10:51:32 +05:30
|
|
|
gtk.gdk.ACTION_COPY|gtk.gdk.ACTION_MOVE,
|
|
|
|
self.button, event)
|
2003-05-17 08:50:50 +05:30
|
|
|
|
2003-07-06 09:22:38 +05:30
|
|
|
self.in_event = 0
|
2005-02-24 05:55:34 +05:30
|
|
|
return True
|
2002-11-25 10:00:36 +05:30
|
|
|
|
|
|
|
style = self.iconlist.get_style()
|
2002-11-08 09:12:25 +05:30
|
|
|
|
2002-11-03 02:49:58 +05:30
|
|
|
if event.type == gtk.gdk.BUTTON_PRESS:
|
|
|
|
if event.button == 1:
|
|
|
|
# Remember starting position.
|
2002-11-08 09:12:25 +05:30
|
|
|
|
|
|
|
item = widget.get_item_at(event.x,event.y)
|
|
|
|
if item:
|
2002-12-11 10:48:47 +05:30
|
|
|
(i,t,b,self.photo,oid) = self.p_map[item]
|
2002-11-08 09:12:25 +05:30
|
|
|
t.set(fill_color_gdk=style.fg[gtk.STATE_SELECTED])
|
|
|
|
b.set(fill_color_gdk=style.bg[gtk.STATE_SELECTED])
|
|
|
|
if self.sel:
|
2002-12-11 10:48:47 +05:30
|
|
|
(i,t,b,photo,oid) = self.p_map[self.sel]
|
2002-11-08 09:12:25 +05:30
|
|
|
t.set(fill_color_gdk=style.fg[gtk.STATE_NORMAL])
|
|
|
|
b.set(fill_color_gdk=style.bg[gtk.STATE_NORMAL])
|
|
|
|
|
|
|
|
self.sel = item
|
|
|
|
|
2002-11-03 02:49:58 +05:30
|
|
|
self.remember_x = event.x
|
|
|
|
self.remember_y = event.y
|
2002-11-08 09:12:25 +05:30
|
|
|
self.button = event.button
|
2003-07-06 09:22:38 +05:30
|
|
|
self.in_event = 0
|
2005-02-24 05:55:34 +05:30
|
|
|
return True
|
2002-11-03 02:49:58 +05:30
|
|
|
|
|
|
|
elif event.button == 3:
|
2002-11-08 09:12:25 +05:30
|
|
|
item = widget.get_item_at(event.x,event.y)
|
|
|
|
if item:
|
2002-12-11 10:48:47 +05:30
|
|
|
(i,t,b,self.photo,oid) = self.p_map[item]
|
2003-10-20 08:17:03 +05:30
|
|
|
self.show_popup(self.photo,event)
|
2003-07-06 09:22:38 +05:30
|
|
|
self.in_event = 0
|
2005-02-24 05:55:34 +05:30
|
|
|
return True
|
2002-11-08 09:12:25 +05:30
|
|
|
elif event.type == gtk.gdk.BUTTON_RELEASE:
|
|
|
|
self.button = 0
|
2002-11-03 02:49:58 +05:30
|
|
|
elif event.type == gtk.gdk.MOTION_NOTIFY:
|
|
|
|
if event.state & gtk.gdk.BUTTON1_MASK:
|
|
|
|
# Get the new position and move by the difference
|
|
|
|
new_x = event.x
|
|
|
|
new_y = event.y
|
|
|
|
|
|
|
|
self.remember_x = new_x
|
|
|
|
self.remember_y = new_y
|
|
|
|
|
2003-07-06 09:22:38 +05:30
|
|
|
self.in_event = 0
|
2005-02-24 05:55:34 +05:30
|
|
|
return True
|
2002-11-03 02:49:58 +05:30
|
|
|
|
2002-11-08 09:12:25 +05:30
|
|
|
if event.type == gtk.gdk.EXPOSE:
|
|
|
|
self.load_images()
|
2002-11-03 02:49:58 +05:30
|
|
|
|
2003-07-06 09:22:38 +05:30
|
|
|
self.in_event = 0
|
2005-02-24 05:55:34 +05:30
|
|
|
return False
|
2002-11-03 02:49:58 +05:30
|
|
|
|
2005-04-04 21:08:36 +05:30
|
|
|
def savephoto(self,photo,transaction):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""Save the photo in the dataobj object. (Required function)"""
|
2005-04-04 21:08:36 +05:30
|
|
|
self.db.add_object(photo,transaction)
|
2004-02-21 11:41:59 +05:30
|
|
|
oref = RelLib.MediaRef()
|
2004-07-28 07:59:07 +05:30
|
|
|
oref.set_reference_handle(photo.get_handle())
|
2004-02-22 10:27:06 +05:30
|
|
|
self.dataobj.add_media_reference(oref)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def add_thumbnail(self, photo):
|
|
|
|
"""Scale the image and add it to the IconList."""
|
2004-07-28 07:59:07 +05:30
|
|
|
oid = photo.get_reference_handle()
|
2005-05-24 18:38:06 +05:30
|
|
|
media_obj = self.db.get_object_from_handle(oid)
|
|
|
|
if self.canvas_list.has_key(photo):
|
|
|
|
(grp,item,text,x,y) = self.canvas_list[photo]
|
2002-11-08 09:12:25 +05:30
|
|
|
if x != self.cx or y != self.cy:
|
|
|
|
grp.move(self.cx-x,self.cy-y)
|
|
|
|
else:
|
2005-05-24 18:38:06 +05:30
|
|
|
description = media_obj.get_description()
|
2002-11-08 09:12:25 +05:30
|
|
|
if len(description) > 20:
|
|
|
|
description = "%s..." % description[0:20]
|
|
|
|
|
2003-02-05 19:23:00 +05:30
|
|
|
try:
|
2005-02-24 05:55:34 +05:30
|
|
|
mtype = media_obj.get_mime_type()
|
2005-12-06 12:08:09 +05:30
|
|
|
image = ImgManip.get_thumbnail_image(media_obj.get_path(),mtype)
|
2003-02-05 19:23:00 +05:30
|
|
|
except gobject.GError,msg:
|
|
|
|
ErrorDialog(str(msg))
|
|
|
|
image = gtk.gdk.pixbuf_new_from_file(const.icon)
|
|
|
|
except:
|
|
|
|
image = gtk.gdk.pixbuf_new_from_file(const.icon)
|
2005-03-03 11:03:22 +05:30
|
|
|
|
2002-11-08 09:12:25 +05:30
|
|
|
x = image.get_width()
|
|
|
|
y = image.get_height()
|
|
|
|
|
2005-01-27 08:48:21 +05:30
|
|
|
grp = self.root.add(CanvasGroup,x=self.cx,y=self.cy)
|
2002-11-08 09:12:25 +05:30
|
|
|
|
|
|
|
xloc = (_IMAGEX-x)/2
|
|
|
|
yloc = (_IMAGEY-y)/2
|
|
|
|
|
2002-11-25 10:00:36 +05:30
|
|
|
style = self.iconlist.get_style()
|
|
|
|
|
2005-01-27 08:48:21 +05:30
|
|
|
box = grp.add(CanvasRect,x1=0,x2=_IMAGEX,y1=_IMAGEY-20,
|
2002-11-25 10:00:36 +05:30
|
|
|
y2=_IMAGEY, fill_color_gdk=style.bg[gtk.STATE_NORMAL])
|
2005-01-27 08:48:21 +05:30
|
|
|
item = grp.add(CanvasPixbuf,
|
2002-11-25 10:00:36 +05:30
|
|
|
pixbuf=image,x=xloc, y=yloc)
|
2005-01-27 08:48:21 +05:30
|
|
|
text = grp.add(CanvasText, x=_IMAGEX/2,
|
2002-11-08 09:12:25 +05:30
|
|
|
anchor=gtk.ANCHOR_CENTER,
|
2002-11-25 10:00:36 +05:30
|
|
|
justification=gtk.JUSTIFY_CENTER,
|
|
|
|
y=_IMAGEY-10, text=description)
|
2002-11-08 09:12:25 +05:30
|
|
|
|
2004-01-06 10:32:06 +05:30
|
|
|
# make sure that the text string doesn't exceed the size of the box
|
|
|
|
|
2004-01-06 10:04:19 +05:30
|
|
|
bnds = text.get_bounds()
|
|
|
|
while bnds[0] <0:
|
|
|
|
description = description[0:-4] + "..."
|
|
|
|
text.set(text=description)
|
|
|
|
bnds = text.get_bounds()
|
|
|
|
|
2002-11-25 10:00:36 +05:30
|
|
|
for i in [ item, text, box, grp ] :
|
2002-11-28 11:22:02 +05:30
|
|
|
self.p_map[i] = (item,text,box,photo,oid)
|
2002-11-25 10:00:36 +05:30
|
|
|
i.show()
|
2002-11-08 09:12:25 +05:30
|
|
|
|
2005-05-24 18:38:06 +05:30
|
|
|
self.canvas_list[photo] = (grp,item,text,self.cx,self.cy)
|
2002-11-08 09:12:25 +05:30
|
|
|
|
2003-05-27 09:13:36 +05:30
|
|
|
self.cx += _PAD + _IMAGEX
|
|
|
|
|
2002-11-08 09:12:25 +05:30
|
|
|
if self.cx + _PAD + _IMAGEX > self.x:
|
|
|
|
self.cx = _PAD
|
2003-05-27 09:13:36 +05:30
|
|
|
self.cy += _PAD + _IMAGEY
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def load_images(self):
|
|
|
|
"""clears the currentImages list to free up any cached
|
|
|
|
Imlibs. Then add each photo in the place's list of photos to the
|
|
|
|
photolist window."""
|
|
|
|
|
|
|
|
self.pos = 0
|
2002-11-08 09:12:25 +05:30
|
|
|
self.cx = _PAD
|
|
|
|
self.cy = _PAD
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2002-11-03 02:49:58 +05:30
|
|
|
(self.x,self.y) = self.iconlist.get_size()
|
|
|
|
|
2002-11-08 09:12:25 +05:30
|
|
|
self.max = (self.x)/(_IMAGEX+_PAD)
|
2002-11-03 02:49:58 +05:30
|
|
|
|
2004-02-21 11:41:59 +05:30
|
|
|
for photo in self.dataobj.get_media_list():
|
2002-10-20 19:55:16 +05:30
|
|
|
self.add_thumbnail(photo)
|
|
|
|
|
|
|
|
if self.cy > self.y:
|
|
|
|
self.iconlist.set_scroll_region(0,0,self.x,self.cy)
|
|
|
|
else:
|
|
|
|
self.iconlist.set_scroll_region(0,0,self.x,self.y)
|
2003-11-13 00:15:07 +05:30
|
|
|
|
2004-02-21 11:41:59 +05:30
|
|
|
if self.dataobj.get_media_list():
|
2003-11-13 00:15:07 +05:30
|
|
|
Utils.bold_label(self.parent.gallery_label)
|
|
|
|
else:
|
|
|
|
Utils.unbold_label(self.parent.gallery_label)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2002-11-03 02:49:58 +05:30
|
|
|
def get_index(self,obj,x,y):
|
2005-08-18 11:28:28 +05:30
|
|
|
x_offset = int(x)/(_IMAGEX+_PAD)
|
|
|
|
y_offset = int(y)/(_IMAGEY+_PAD)
|
|
|
|
index = (y_offset*(self.max))+x_offset
|
2004-02-21 11:41:59 +05:30
|
|
|
return min(index,len(self.dataobj.get_media_list()))
|
2002-11-03 02:49:58 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def on_photolist_drag_data_received(self,w, context, x, y, data, info, time):
|
2004-06-03 11:05:30 +05:30
|
|
|
if data and data.format == 8:
|
2002-11-03 02:49:58 +05:30
|
|
|
icon_index = self.get_index(w,x,y)
|
2005-12-06 12:08:09 +05:30
|
|
|
d = Utils.fix_encoding(data.data.replace('\0',' ').strip())
|
2004-08-20 17:41:56 +05:30
|
|
|
protocol,site,mfile,j,k,l = urlparse.urlparse(d)
|
2002-10-20 19:55:16 +05:30
|
|
|
if protocol == "file":
|
2005-12-06 12:08:09 +05:30
|
|
|
name = Utils.fix_encoding(mfile)
|
2004-04-04 10:09:52 +05:30
|
|
|
mime = GrampsMime.get_type(name)
|
2004-02-21 11:41:59 +05:30
|
|
|
photo = RelLib.MediaObject()
|
2004-02-14 11:10:30 +05:30
|
|
|
photo.set_path(name)
|
|
|
|
photo.set_mime_type(mime)
|
2002-10-20 19:55:16 +05:30
|
|
|
basename = os.path.basename(name)
|
|
|
|
(root,ext) = os.path.splitext(basename)
|
2004-02-14 11:10:30 +05:30
|
|
|
photo.set_description(root)
|
2005-04-04 21:08:36 +05:30
|
|
|
trans = self.db.transaction_begin()
|
|
|
|
self.savephoto(photo,trans)
|
2005-01-06 22:58:31 +05:30
|
|
|
if GrampsKeys.get_media_reference() == 0:
|
2004-02-14 11:10:30 +05:30
|
|
|
photo.set_path(name)
|
2005-04-04 21:08:36 +05:30
|
|
|
self.db.transaction_commit(trans,_("Drag Media Object"))
|
2002-10-20 19:55:16 +05:30
|
|
|
self.parent.lists_changed = 1
|
2005-01-06 22:58:31 +05:30
|
|
|
if GrampsKeys.get_media_global():
|
2005-04-04 05:57:06 +05:30
|
|
|
GlobalMediaProperties(self.db,photo,
|
2004-06-03 11:05:30 +05:30
|
|
|
self,self.parent_window)
|
2002-10-20 19:55:16 +05:30
|
|
|
elif protocol != "":
|
|
|
|
import urllib
|
|
|
|
u = urllib.URLopener()
|
|
|
|
try:
|
|
|
|
tfile,headers = u.retrieve(d)
|
2004-07-09 10:01:43 +05:30
|
|
|
except (IOError,OSError), msg:
|
2002-10-20 19:55:16 +05:30
|
|
|
t = _("Could not import %s") % d
|
2003-02-24 10:21:57 +05:30
|
|
|
ErrorDialog(t,str(msg))
|
2002-10-20 19:55:16 +05:30
|
|
|
return
|
2005-12-06 12:08:09 +05:30
|
|
|
tfile = Utils.fix_encoding(tfile)
|
2004-04-04 10:09:52 +05:30
|
|
|
mime = GrampsMime.get_type(tfile)
|
2004-02-21 11:41:59 +05:30
|
|
|
photo = RelLib.MediaObject()
|
2004-02-14 11:10:30 +05:30
|
|
|
photo.set_mime_type(mime)
|
|
|
|
photo.set_description(d)
|
|
|
|
photo.set_path(tfile)
|
2005-04-04 21:08:36 +05:30
|
|
|
trans = self.db.transaction_begin()
|
|
|
|
self.db.add_object(photo,trans)
|
|
|
|
self.db.transaction_commit(trans,_("Drag Media Object"))
|
2004-02-21 11:41:59 +05:30
|
|
|
oref = RelLib.MediaRef()
|
2004-07-28 07:59:07 +05:30
|
|
|
oref.set_reference_handle(photo.get_handle())
|
2004-02-22 10:27:06 +05:30
|
|
|
self.dataobj.add_media_reference(oref)
|
2005-04-04 21:08:36 +05:30
|
|
|
# This code seems to be reproducing what is already done.
|
|
|
|
# try:
|
|
|
|
# photo.set_path(name)
|
|
|
|
# except:
|
|
|
|
# photo.set_path(tfile)
|
|
|
|
# return
|
2002-10-20 19:55:16 +05:30
|
|
|
self.add_thumbnail(oref)
|
|
|
|
self.parent.lists_changed = 1
|
2005-01-06 22:58:31 +05:30
|
|
|
if GrampsKeys.get_media_global():
|
2005-04-04 05:57:06 +05:30
|
|
|
GlobalMediaProperties(self.db,photo,
|
2004-06-03 11:05:30 +05:30
|
|
|
self,self.parent_window)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-07-28 07:59:07 +05:30
|
|
|
if self.db.has_object_handle(data.data):
|
2002-11-03 02:49:58 +05:30
|
|
|
icon_index = self.get_index(w,x,y)
|
2002-10-20 19:55:16 +05:30
|
|
|
index = 0
|
2004-02-21 11:41:59 +05:30
|
|
|
for p in self.dataobj.get_media_list():
|
2004-07-28 07:59:07 +05:30
|
|
|
if data.data == p.get_reference_handle():
|
2002-10-20 19:55:16 +05:30
|
|
|
if index == icon_index or icon_index == -1:
|
|
|
|
return
|
|
|
|
else:
|
2004-02-21 11:41:59 +05:30
|
|
|
nl = self.dataobj.get_media_list()
|
2002-10-20 19:55:16 +05:30
|
|
|
item = nl[index]
|
|
|
|
if icon_index == 0:
|
|
|
|
del nl[index]
|
|
|
|
nl = [item] + nl
|
|
|
|
else:
|
|
|
|
del nl[index]
|
|
|
|
nl = nl[0:icon_index] + [item] + nl[icon_index:]
|
2004-02-21 11:41:59 +05:30
|
|
|
self.dataobj.set_media_list(nl)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.parent.lists_changed = 1
|
|
|
|
self.load_images()
|
|
|
|
return
|
|
|
|
index = index + 1
|
2004-02-21 11:41:59 +05:30
|
|
|
oref = RelLib.MediaRef()
|
2004-07-28 07:59:07 +05:30
|
|
|
oref.set_reference_handle(data.data)
|
2004-02-22 10:27:06 +05:30
|
|
|
self.dataobj.add_media_reference(oref)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.add_thumbnail(oref)
|
|
|
|
self.parent.lists_changed = 1
|
2005-01-06 22:58:31 +05:30
|
|
|
if GrampsKeys.get_media_global():
|
2004-02-06 12:14:22 +05:30
|
|
|
LocalMediaProperties(oref,self.path,self,self.parent_window)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def on_photolist_drag_data_get(self,w, context, selection_data, info, time):
|
|
|
|
if info == 1:
|
|
|
|
return
|
2004-08-20 17:41:56 +05:30
|
|
|
data = self.p_map[self.drag_item]
|
|
|
|
selection_data.set(selection_data.target, 8, data[4])
|
2002-11-08 09:12:25 +05:30
|
|
|
self.drag_item = None
|
|
|
|
|
2004-02-23 08:15:36 +05:30
|
|
|
def on_add_media_clicked(self, obj):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""User wants to add a new photo. Create a dialog to find out
|
|
|
|
which photo they want."""
|
|
|
|
self.create_add_dialog()
|
|
|
|
|
2004-02-23 08:15:36 +05:30
|
|
|
def on_select_media_clicked(self,obj):
|
2003-12-12 11:06:38 +05:30
|
|
|
"""User wants to add a new object that is already in a database.
|
|
|
|
Create a dialog to find out which object they want."""
|
|
|
|
|
|
|
|
s_o = SelectObject.SelectObject(self.db,_("Select an Object"))
|
2004-08-20 17:41:56 +05:30
|
|
|
obj = s_o.run()
|
|
|
|
if not obj:
|
2003-12-12 11:06:38 +05:30
|
|
|
return
|
2004-02-21 11:41:59 +05:30
|
|
|
oref = RelLib.MediaRef()
|
2004-08-20 17:41:56 +05:30
|
|
|
oref.set_reference_handle(obj.get_handle())
|
2004-02-22 10:27:06 +05:30
|
|
|
self.dataobj.add_media_reference(oref)
|
2003-12-12 11:06:38 +05:30
|
|
|
self.add_thumbnail(oref)
|
|
|
|
|
|
|
|
self.parent.lists_changed = 1
|
|
|
|
self.load_images()
|
|
|
|
|
2004-02-23 08:15:36 +05:30
|
|
|
def on_delete_media_clicked(self, obj):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""User wants to delete a new photo. Remove it from the displayed
|
|
|
|
thumbnails, and remove it from the dataobj photo list."""
|
|
|
|
|
2002-11-10 00:14:58 +05:30
|
|
|
if self.sel:
|
2002-12-11 10:48:47 +05:30
|
|
|
(i,t,b,photo,oid) = self.p_map[self.sel]
|
2005-05-24 18:38:06 +05:30
|
|
|
val = self.canvas_list[photo]
|
2002-11-10 00:14:58 +05:30
|
|
|
val[0].hide()
|
|
|
|
val[1].hide()
|
|
|
|
val[2].hide()
|
|
|
|
|
2004-02-21 11:41:59 +05:30
|
|
|
l = self.dataobj.get_media_list()
|
2002-11-10 00:14:58 +05:30
|
|
|
l.remove(photo)
|
2004-02-21 11:41:59 +05:30
|
|
|
self.dataobj.set_media_list(l)
|
2002-11-10 00:14:58 +05:30
|
|
|
self.parent.lists_changed = 1
|
|
|
|
self.load_images()
|
2003-03-03 10:02:53 +05:30
|
|
|
|
2004-02-23 08:15:36 +05:30
|
|
|
def on_edit_media_clicked(self, obj):
|
2003-03-03 10:02:53 +05:30
|
|
|
"""User wants to delete a new photo. Remove it from the displayed
|
|
|
|
thumbnails, and remove it from the dataobj photo list."""
|
|
|
|
|
|
|
|
if self.sel:
|
|
|
|
(i,t,b,photo,oid) = self.p_map[self.sel]
|
2005-12-06 12:08:09 +05:30
|
|
|
base_obj = self.db.get_object_from_handle(photo.get_reference_handle())
|
|
|
|
|
|
|
|
if base_obj.get_mime_type():
|
|
|
|
LocalMediaProperties(photo,self.path,self,self.parent_window)
|
|
|
|
else:
|
|
|
|
import NoteEdit
|
|
|
|
NoteEdit.NoteEditor(base_obj,self.parent,self.parent_window,
|
|
|
|
self.note_callback)
|
2002-11-10 00:14:58 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
def note_callback(self,data):
|
|
|
|
trans = self.db.transaction_begin()
|
|
|
|
self.db.commit_media_object(data,trans)
|
|
|
|
self.db.transaction_commit(trans,_("Edit Media Object"))
|
|
|
|
|
2003-10-20 08:17:03 +05:30
|
|
|
def show_popup(self, photo, event):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""Look for right-clicks on a picture and create a popup
|
|
|
|
menu of the available actions."""
|
2002-11-03 02:49:58 +05:30
|
|
|
|
|
|
|
menu = gtk.Menu()
|
2003-02-09 00:46:12 +05:30
|
|
|
menu.set_title(_("Media Object"))
|
2004-08-20 17:41:56 +05:30
|
|
|
obj = self.db.get_object_from_handle(photo.get_reference_handle())
|
|
|
|
mtype = obj.get_mime_type()
|
2004-04-04 10:09:52 +05:30
|
|
|
progname = GrampsMime.get_application(mtype)
|
2002-11-03 02:49:58 +05:30
|
|
|
|
2004-05-14 04:15:51 +05:30
|
|
|
if progname and len(progname) > 1:
|
|
|
|
Utils.add_menuitem(menu,_("Open in %s") % progname[1],
|
|
|
|
photo,self.popup_view_photo)
|
2005-05-24 18:38:06 +05:30
|
|
|
if mtype and mtype.startswith("image"):
|
2002-11-03 02:49:58 +05:30
|
|
|
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)
|
2003-10-20 08:17:03 +05:30
|
|
|
menu.popup(None,None,None,event.button,event.time)
|
2002-11-03 02:49:58 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def popup_view_photo(self, obj):
|
|
|
|
"""Open this picture in a picture viewer"""
|
2002-11-03 02:49:58 +05:30
|
|
|
photo = obj.get_data('o')
|
2004-08-07 10:46:57 +05:30
|
|
|
Utils.view_photo(self.db.get_object_from_handle(photo.get_reference_handle()))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def popup_edit_photo(self, obj):
|
|
|
|
"""Open this picture in a picture editor"""
|
2002-11-08 09:40:31 +05:30
|
|
|
photo = obj.get_data('o')
|
2002-10-20 19:55:16 +05:30
|
|
|
if os.fork() == 0:
|
2004-08-07 10:46:57 +05:30
|
|
|
obj = self.db.get_object_from_handle(photo.get_reference_handle())
|
2004-02-25 09:38:51 +05:30
|
|
|
os.execvp(const.editor,[const.editor, obj.get_path()])
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def popup_change_description(self, obj):
|
|
|
|
"""Bring up a window allowing the user to edit the description
|
|
|
|
of a picture."""
|
2002-11-08 09:40:31 +05:30
|
|
|
photo = obj.get_data('o')
|
|
|
|
LocalMediaProperties(photo,self.path,self)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-05-03 09:36:03 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# LocalMediaProperties
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class LocalMediaProperties:
|
|
|
|
|
2004-02-06 12:14:22 +05:30
|
|
|
def __init__(self,photo,path,parent,parent_window=None):
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
self.parent = parent
|
|
|
|
if photo:
|
|
|
|
if self.parent.parent.child_windows.has_key(photo):
|
|
|
|
self.parent.parent.child_windows[photo].present(None)
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
self.win_key = photo
|
|
|
|
else:
|
|
|
|
self.win_key = self
|
|
|
|
self.child_windows = {}
|
2002-10-20 19:55:16 +05:30
|
|
|
self.photo = photo
|
2004-04-19 08:45:05 +05:30
|
|
|
self.db = parent.db
|
2004-08-20 17:41:56 +05:30
|
|
|
self.obj = self.db.get_object_from_handle(photo.get_reference_handle())
|
2004-02-14 11:10:30 +05:30
|
|
|
self.alist = photo.get_attribute_list()[:]
|
2002-10-20 19:55:16 +05:30
|
|
|
self.lists_changed = 0
|
|
|
|
|
2004-08-20 17:41:56 +05:30
|
|
|
fname = self.obj.get_path()
|
2005-12-06 12:08:09 +05:30
|
|
|
self.change_dialog = gtk.glade.XML(const.imageselFile,
|
|
|
|
"change_description","gramps")
|
2003-03-06 11:42:51 +05:30
|
|
|
|
2004-02-20 08:58:41 +05:30
|
|
|
title = _('Media Reference Editor')
|
2004-06-03 11:05:30 +05:30
|
|
|
self.window = self.change_dialog.get_widget('change_description')
|
|
|
|
Utils.set_titles(self.window,
|
2003-03-06 11:42:51 +05:30
|
|
|
self.change_dialog.get_widget('title'), title)
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
descr_window = self.change_dialog.get_widget("description")
|
2002-11-25 10:00:36 +05:30
|
|
|
self.pixmap = self.change_dialog.get_widget("pixmap")
|
2002-10-20 19:55:16 +05:30
|
|
|
self.attr_type = self.change_dialog.get_widget("attr_type")
|
|
|
|
self.attr_value = self.change_dialog.get_widget("attr_value")
|
|
|
|
self.attr_details = self.change_dialog.get_widget("attr_details")
|
2002-10-25 10:22:51 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.attr_list = self.change_dialog.get_widget("attr_list")
|
2002-12-11 10:48:47 +05:30
|
|
|
titles = [(_('Attribute'),0,150),(_('Value'),0,100)]
|
2002-10-25 10:22:51 +05:30
|
|
|
|
2003-12-16 06:07:47 +05:30
|
|
|
self.attr_label = self.change_dialog.get_widget("attr_local")
|
|
|
|
self.notes_label = self.change_dialog.get_widget("notes_local")
|
|
|
|
self.flowed = self.change_dialog.get_widget("flowed")
|
|
|
|
self.preform = self.change_dialog.get_widget("preform")
|
|
|
|
|
2002-11-25 10:00:36 +05:30
|
|
|
self.atree = ListModel.ListModel(self.attr_list,titles,
|
|
|
|
self.on_attr_list_select_row,
|
|
|
|
self.on_update_attr_clicked)
|
|
|
|
|
2004-06-13 11:48:20 +05:30
|
|
|
self.slist = self.change_dialog.get_widget("src_list")
|
2004-06-03 11:05:30 +05:30
|
|
|
self.sources_label = self.change_dialog.get_widget("source_label")
|
2004-08-20 17:41:56 +05:30
|
|
|
if self.obj:
|
2005-12-06 12:08:09 +05:30
|
|
|
self.srcreflist = [RelLib.SourceRef(ref)
|
|
|
|
for ref in self.photo.get_source_references()]
|
2004-06-03 11:05:30 +05:30
|
|
|
else:
|
|
|
|
self.srcreflist = []
|
|
|
|
|
|
|
|
self.sourcetab = Sources.SourceTab(self.srcreflist,self,
|
|
|
|
self.change_dialog,
|
|
|
|
self.window, self.slist,
|
|
|
|
self.change_dialog.get_widget('add_src'),
|
|
|
|
self.change_dialog.get_widget('edit_src'),
|
|
|
|
self.change_dialog.get_widget('del_src'))
|
|
|
|
|
2004-08-20 17:41:56 +05:30
|
|
|
descr_window.set_text(self.obj.get_description())
|
|
|
|
mtype = self.obj.get_mime_type()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
self.pix = ImgManip.get_thumbnail_image(self.obj.get_path(),mtype)
|
2004-10-23 09:26:48 +05:30
|
|
|
self.pixmap.set_from_pixbuf(self.pix)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
self.change_dialog.get_widget("private").set_active(photo.get_privacy())
|
2005-12-06 12:08:09 +05:30
|
|
|
coord = photo.get_rectangle()
|
|
|
|
if coord and type(coord) == tuple:
|
|
|
|
self.change_dialog.get_widget("upperx").set_value(coord[0])
|
|
|
|
self.change_dialog.get_widget("uppery").set_value(coord[1])
|
|
|
|
self.change_dialog.get_widget("lowerx").set_value(coord[2])
|
|
|
|
self.change_dialog.get_widget("lowery").set_value(coord[3])
|
|
|
|
|
2004-08-25 08:32:25 +05:30
|
|
|
self.change_dialog.get_widget("gid").set_text(self.obj.get_gramps_id())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-04-04 10:09:52 +05:30
|
|
|
self.change_dialog.get_widget("path").set_text(fname)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
mt = Utils.get_mime_description(mtype)
|
2005-12-06 12:08:09 +05:30
|
|
|
if mt:
|
|
|
|
self.change_dialog.get_widget("type").set_text(mt)
|
|
|
|
else:
|
|
|
|
self.change_dialog.get_widget("type").set_text("")
|
2003-12-16 06:07:47 +05:30
|
|
|
self.notes = self.change_dialog.get_widget("notes")
|
2005-08-18 11:28:28 +05:30
|
|
|
self.spell = Spell.Spell(self.notes)
|
2004-02-14 11:10:30 +05:30
|
|
|
if self.photo.get_note():
|
|
|
|
self.notes.get_buffer().set_text(self.photo.get_note())
|
2003-12-16 06:07:47 +05:30
|
|
|
Utils.bold_label(self.notes_label)
|
2004-02-14 11:10:30 +05:30
|
|
|
if self.photo.get_note_format() == 1:
|
2003-12-16 06:07:47 +05:30
|
|
|
self.preform.set_active(1)
|
|
|
|
else:
|
|
|
|
self.flowed.set_active(1)
|
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
self.gladeif = GladeIf(self.change_dialog)
|
|
|
|
self.gladeif.connect('change_description','delete_event',self.on_delete_event)
|
|
|
|
self.gladeif.connect('button84','clicked',self.close)
|
|
|
|
self.gladeif.connect('button82','clicked',self.on_ok_clicked)
|
|
|
|
self.gladeif.connect('button104','clicked',self.on_help_clicked)
|
|
|
|
self.gladeif.connect('notebook1','switch_page',self.on_notebook_switch_page)
|
|
|
|
self.gladeif.connect('button86','clicked',self.on_add_attr_clicked)
|
|
|
|
self.gladeif.connect('button100','clicked',self.on_update_attr_clicked)
|
|
|
|
self.gladeif.connect('button88','clicked',self.on_delete_attr_clicked)
|
|
|
|
|
2004-11-08 10:10:18 +05:30
|
|
|
media_obj = self.db.get_object_from_handle(self.photo.get_reference_handle())
|
2005-08-18 11:28:28 +05:30
|
|
|
gnote = self.change_dialog.get_widget('global_notes')
|
|
|
|
spell = Spell.Spell(gnote)
|
|
|
|
global_note = gnote.get_buffer()
|
2004-11-08 10:10:18 +05:30
|
|
|
global_note.insert_at_cursor(media_obj.get_note())
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.redraw_attr_list()
|
2004-02-06 12:14:22 +05:30
|
|
|
if parent_window:
|
|
|
|
self.window.set_transient_for(parent_window)
|
2005-04-26 21:34:21 +05:30
|
|
|
self.add_itself_to_menu()
|
2004-02-20 08:58:41 +05:30
|
|
|
self.window.show()
|
|
|
|
|
|
|
|
def on_delete_event(self,obj,b):
|
2005-12-06 12:08:09 +05:30
|
|
|
self.gladeif.close()
|
2004-02-20 08:58:41 +05:30
|
|
|
self.close_child_windows()
|
2005-04-26 21:34:21 +05:30
|
|
|
self.remove_itself_from_menu()
|
2005-12-06 12:08:09 +05:30
|
|
|
gc.collect()
|
2004-02-20 08:58:41 +05:30
|
|
|
|
|
|
|
def close(self,obj):
|
2005-12-06 12:08:09 +05:30
|
|
|
self.gladeif.close()
|
2004-02-20 08:58:41 +05:30
|
|
|
self.close_child_windows()
|
2005-04-26 21:34:21 +05:30
|
|
|
self.remove_itself_from_menu()
|
2004-02-06 12:14:22 +05:30
|
|
|
self.window.destroy()
|
2005-12-06 12:08:09 +05:30
|
|
|
gc.collect()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-20 08:58:41 +05:30
|
|
|
def close_child_windows(self):
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
for child_window in self.child_windows.values():
|
2004-02-20 08:58:41 +05:30
|
|
|
child_window.close(None)
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
self.child_windows = {}
|
2004-02-20 08:58:41 +05:30
|
|
|
|
|
|
|
def add_itself_to_menu(self):
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
self.parent.parent.child_windows[self.win_key] = self
|
2004-02-20 08:58:41 +05:30
|
|
|
label = _('Media Reference')
|
|
|
|
self.parent_menu_item = gtk.MenuItem(label)
|
|
|
|
self.parent_menu_item.set_submenu(gtk.Menu())
|
|
|
|
self.parent_menu_item.show()
|
2004-02-25 08:50:53 +05:30
|
|
|
self.parent.parent.winsmenu.append(self.parent_menu_item)
|
|
|
|
self.winsmenu = self.parent_menu_item.get_submenu()
|
2004-02-20 08:58:41 +05:30
|
|
|
self.menu_item = gtk.MenuItem(_('Reference Editor'))
|
|
|
|
self.menu_item.connect("activate",self.present)
|
|
|
|
self.menu_item.show()
|
2004-02-25 08:50:53 +05:30
|
|
|
self.winsmenu.append(self.menu_item)
|
2004-02-20 08:58:41 +05:30
|
|
|
|
|
|
|
def remove_itself_from_menu(self):
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
del self.parent.parent.child_windows[self.win_key]
|
2004-02-20 08:58:41 +05:30
|
|
|
self.menu_item.destroy()
|
2004-02-25 08:50:53 +05:30
|
|
|
self.winsmenu.destroy()
|
2004-02-20 08:58:41 +05:30
|
|
|
self.parent_menu_item.destroy()
|
|
|
|
|
|
|
|
def present(self,obj):
|
|
|
|
self.window.present()
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def redraw_attr_list(self):
|
2002-11-25 10:00:36 +05:30
|
|
|
self.atree.clear()
|
2003-06-11 08:24:57 +05:30
|
|
|
self.amap = {}
|
2002-11-25 10:00:36 +05:30
|
|
|
for attr in self.alist:
|
2004-02-14 11:10:30 +05:30
|
|
|
d = [attr.get_type(),attr.get_value()]
|
2004-08-20 17:41:56 +05:30
|
|
|
node = self.atree.add(d,attr)
|
|
|
|
self.amap[str(attr)] = node
|
2003-12-16 06:07:47 +05:30
|
|
|
if self.alist:
|
|
|
|
Utils.bold_label(self.attr_label)
|
|
|
|
else:
|
|
|
|
Utils.unbold_label(self.attr_label)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-12-16 06:07:47 +05:30
|
|
|
def on_notebook_switch_page(self,obj,junk,page):
|
|
|
|
t = self.notes.get_buffer()
|
2005-02-24 05:55:34 +05:30
|
|
|
text = unicode(t.get_text(t.get_start_iter(),t.get_end_iter(),False))
|
2003-12-16 06:07:47 +05:30
|
|
|
if text:
|
|
|
|
Utils.bold_label(self.notes_label)
|
|
|
|
else:
|
|
|
|
Utils.unbold_label(self.notes_label)
|
|
|
|
|
2004-02-06 12:14:22 +05:30
|
|
|
def on_apply_clicked(self):
|
2002-10-20 19:55:16 +05:30
|
|
|
priv = self.change_dialog.get_widget("private").get_active()
|
2002-10-27 09:13:12 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
coord = (
|
|
|
|
self.change_dialog.get_widget("upperx").get_value_as_int(),
|
|
|
|
self.change_dialog.get_widget("uppery").get_value_as_int(),
|
|
|
|
self.change_dialog.get_widget("lowerx").get_value_as_int(),
|
|
|
|
self.change_dialog.get_widget("lowery").get_value_as_int(),
|
|
|
|
)
|
|
|
|
if (coord[0] == None and coord[1] == None
|
|
|
|
and coord[2] == None and coord[3] == None):
|
|
|
|
coord = None
|
|
|
|
|
2003-12-16 06:07:47 +05:30
|
|
|
t = self.notes.get_buffer()
|
2005-02-24 05:55:34 +05:30
|
|
|
text = unicode(t.get_text(t.get_start_iter(),t.get_end_iter(),False))
|
2004-02-14 11:10:30 +05:30
|
|
|
note = self.photo.get_note()
|
2003-12-16 06:07:47 +05:30
|
|
|
format = self.preform.get_active()
|
2005-12-06 12:08:09 +05:30
|
|
|
if text != note or priv != self.photo.get_privacy() \
|
|
|
|
or coord != self.photo.get_rectangle() \
|
|
|
|
or format != self.photo.get_note_format():
|
|
|
|
self.photo.set_rectangle(coord)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.photo.set_note(text)
|
|
|
|
self.photo.set_privacy(priv)
|
2005-12-06 12:08:09 +05:30
|
|
|
self.photo.set_note_format(format)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.parent.lists_changed = 1
|
2004-06-13 11:48:20 +05:30
|
|
|
self.parent.parent.lists_changed = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.lists_changed:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.photo.set_attribute_list(self.alist)
|
2004-06-13 11:48:20 +05:30
|
|
|
self.photo.set_source_reference_list(self.srcreflist)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.parent.lists_changed = 1
|
2004-06-13 11:48:20 +05:30
|
|
|
self.parent.parent.lists_changed = 1
|
2004-03-30 10:20:24 +05:30
|
|
|
|
2004-08-13 10:04:07 +05:30
|
|
|
trans = self.db.transaction_begin()
|
2004-08-20 17:41:56 +05:30
|
|
|
self.db.commit_media_object(self.obj,trans)
|
2004-08-13 10:04:07 +05:30
|
|
|
self.db.transaction_commit(trans,_("Edit Media Object"))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-12-16 06:07:47 +05:30
|
|
|
def on_help_clicked(self, obj):
|
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
2005-12-06 12:08:09 +05:30
|
|
|
GrampsDisplay.help('gramps-edit-complete')
|
2003-12-16 06:07:47 +05:30
|
|
|
|
2004-02-20 08:58:41 +05:30
|
|
|
def on_ok_clicked(self,obj):
|
2004-02-06 12:14:22 +05:30
|
|
|
self.on_apply_clicked()
|
2004-02-20 08:58:41 +05:30
|
|
|
self.close(obj)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2002-11-25 10:00:36 +05:30
|
|
|
def on_attr_list_select_row(self,obj):
|
2004-08-20 17:41:56 +05:30
|
|
|
store,node = self.atree.get_selected()
|
|
|
|
if node:
|
|
|
|
attr = self.atree.get_object(node)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
self.attr_type.set_label(attr.get_type())
|
|
|
|
self.attr_value.set_text(attr.get_value())
|
2002-10-25 10:22:51 +05:30
|
|
|
else:
|
|
|
|
self.attr_type.set_label('')
|
|
|
|
self.attr_value.set_text('')
|
2003-06-11 08:24:57 +05:30
|
|
|
|
|
|
|
def attr_callback(self,attr):
|
|
|
|
self.redraw_attr_list()
|
|
|
|
self.atree.select_iter(self.amap[str(attr)])
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def on_update_attr_clicked(self,obj):
|
|
|
|
import AttrEdit
|
2002-10-25 10:22:51 +05:30
|
|
|
|
2004-08-20 17:41:56 +05:30
|
|
|
store,node = self.atree.get_selected()
|
|
|
|
if node:
|
|
|
|
attr = self.atree.get_object(node)
|
2002-10-20 19:55:16 +05:30
|
|
|
AttrEdit.AttributeEditor(self,attr,"Media Object",
|
2005-03-08 08:44:25 +05:30
|
|
|
PluginMgr.get_image_attributes(),
|
2003-06-11 08:24:57 +05:30
|
|
|
self.attr_callback)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def on_delete_attr_clicked(self,obj):
|
|
|
|
if Utils.delete_selected(obj,self.alist):
|
|
|
|
self.lists_changed = 1
|
|
|
|
self.redraw_attr_list()
|
|
|
|
|
|
|
|
def on_add_attr_clicked(self,obj):
|
|
|
|
import AttrEdit
|
|
|
|
AttrEdit.AttributeEditor(self,None,"Media Object",
|
2005-03-08 08:44:25 +05:30
|
|
|
PluginMgr.get_image_attributes(),
|
2003-06-11 08:24:57 +05:30
|
|
|
self.attr_callback)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GlobalMediaProperties
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class GlobalMediaProperties:
|
|
|
|
|
2005-04-04 05:57:06 +05:30
|
|
|
def __init__(self,db,obj,parent,parent_window=None):
|
2004-06-03 11:05:30 +05:30
|
|
|
self.parent = parent
|
2004-12-29 10:36:10 +05:30
|
|
|
self.dp = DateHandler.parser
|
|
|
|
self.dd = DateHandler.displayer
|
2004-08-20 17:41:56 +05:30
|
|
|
if obj:
|
2005-04-26 21:34:21 +05:30
|
|
|
if self.parent.parent.child_windows.has_key(obj.get_handle()):
|
|
|
|
self.parent.parent.child_windows[obj.get_handle()].present(None)
|
|
|
|
return
|
|
|
|
else:
|
2004-08-20 17:41:56 +05:30
|
|
|
self.win_key = obj.get_handle()
|
2004-06-03 11:05:30 +05:30
|
|
|
else:
|
|
|
|
self.win_key = self
|
2005-12-06 12:08:09 +05:30
|
|
|
self.pdmap = {}
|
2004-06-03 11:05:30 +05:30
|
|
|
self.child_windows = {}
|
2004-08-20 17:41:56 +05:30
|
|
|
self.obj = obj
|
2002-10-20 19:55:16 +05:30
|
|
|
self.lists_changed = 0
|
|
|
|
self.db = db
|
2005-12-06 12:08:09 +05:30
|
|
|
self.idle = None
|
2004-11-06 09:01:34 +05:30
|
|
|
if obj:
|
|
|
|
self.date_object = Date.Date(self.obj.get_date_object())
|
2005-06-05 09:31:56 +05:30
|
|
|
self.alist = self.obj.get_attribute_list()[:]
|
|
|
|
self.refs = 0
|
2004-11-06 09:01:34 +05:30
|
|
|
else:
|
|
|
|
self.date_object = Date.Date()
|
2005-06-05 09:31:56 +05:30
|
|
|
self.alist = []
|
|
|
|
self.refs = 1
|
2004-11-06 09:01:34 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
self.path = self.db.get_save_path()
|
2005-02-20 06:32:15 +05:30
|
|
|
self.change_dialog = gtk.glade.XML(const.imageselFile,
|
|
|
|
"change_global","gramps")
|
2005-12-06 12:08:09 +05:30
|
|
|
self.gladeif = GladeIf(self.change_dialog)
|
2003-03-06 11:42:51 +05:30
|
|
|
|
2005-02-20 06:32:15 +05:30
|
|
|
mode = not self.db.readonly
|
|
|
|
|
2004-06-03 11:05:30 +05:30
|
|
|
title = _('Media Properties Editor')
|
2003-03-06 11:42:51 +05:30
|
|
|
|
2004-06-03 11:05:30 +05:30
|
|
|
self.window = self.change_dialog.get_widget('change_global')
|
2004-11-06 09:01:34 +05:30
|
|
|
self.date_entry = self.change_dialog.get_widget('date')
|
2005-02-20 06:32:15 +05:30
|
|
|
self.date_entry.set_editable(mode)
|
|
|
|
|
2004-11-06 09:01:34 +05:30
|
|
|
if self.obj:
|
|
|
|
self.date_entry.set_text(self.dd.display(self.date_object))
|
|
|
|
|
2004-06-03 11:05:30 +05:30
|
|
|
Utils.set_titles(self.window,
|
2003-03-06 11:42:51 +05:30
|
|
|
self.change_dialog.get_widget('title'),title)
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.descr_window = self.change_dialog.get_widget("description")
|
2005-02-20 06:32:15 +05:30
|
|
|
self.descr_window.set_editable(mode)
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.notes = self.change_dialog.get_widget("notes")
|
2005-02-20 06:32:15 +05:30
|
|
|
self.notes.set_editable(mode)
|
2005-08-18 11:28:28 +05:30
|
|
|
self.spell = Spell.Spell(self.notes)
|
|
|
|
|
2005-02-20 06:32:15 +05:30
|
|
|
self.date_edit = self.change_dialog.get_widget("date_edit")
|
|
|
|
self.date_edit.set_sensitive(mode)
|
|
|
|
|
|
|
|
self.date_check = DateEdit.DateEdit(
|
2005-08-18 11:28:28 +05:30
|
|
|
self.date_object, self.date_entry,
|
|
|
|
self.date_edit, self.window)
|
2004-11-06 09:01:34 +05:30
|
|
|
|
2002-11-25 10:00:36 +05:30
|
|
|
self.pixmap = self.change_dialog.get_widget("pixmap")
|
2002-10-20 19:55:16 +05:30
|
|
|
self.attr_type = self.change_dialog.get_widget("attr_type")
|
|
|
|
self.attr_value = self.change_dialog.get_widget("attr_value")
|
|
|
|
self.attr_details = self.change_dialog.get_widget("attr_details")
|
2002-10-25 10:22:51 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.attr_list = self.change_dialog.get_widget("attr_list")
|
2002-11-25 10:00:36 +05:30
|
|
|
|
2003-11-14 00:20:01 +05:30
|
|
|
self.attr_label = self.change_dialog.get_widget("attrGlobal")
|
|
|
|
self.notes_label = self.change_dialog.get_widget("notesGlobal")
|
|
|
|
self.refs_label = self.change_dialog.get_widget("refsGlobal")
|
2003-12-16 06:07:47 +05:30
|
|
|
self.flowed = self.change_dialog.get_widget("global_flowed")
|
2005-02-20 06:32:15 +05:30
|
|
|
self.flowed.set_sensitive(mode)
|
2003-12-16 06:07:47 +05:30
|
|
|
self.preform = self.change_dialog.get_widget("global_preform")
|
2005-02-20 06:32:15 +05:30
|
|
|
self.preform.set_sensitive(mode)
|
2003-11-14 00:20:01 +05:30
|
|
|
|
2002-12-11 10:48:47 +05:30
|
|
|
titles = [(_('Attribute'),0,150),(_('Value'),1,100)]
|
2002-11-25 10:00:36 +05:30
|
|
|
|
|
|
|
self.atree = ListModel.ListModel(self.attr_list,titles,
|
|
|
|
self.on_attr_list_select_row,
|
|
|
|
self.on_update_attr_clicked)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-06-03 11:05:30 +05:30
|
|
|
self.slist = self.change_dialog.get_widget("src_list")
|
|
|
|
self.sources_label = self.change_dialog.get_widget("sourcesGlobal")
|
2004-08-20 17:41:56 +05:30
|
|
|
if self.obj:
|
2005-12-06 12:08:09 +05:30
|
|
|
self.srcreflist = [RelLib.SourceRef(ref)
|
|
|
|
for ref in self.obj.get_source_references()]
|
2004-06-03 11:05:30 +05:30
|
|
|
else:
|
|
|
|
self.srcreflist = []
|
|
|
|
|
2005-02-16 11:11:33 +05:30
|
|
|
self.sourcetab = Sources.SourceTab(
|
|
|
|
self.srcreflist,self,
|
|
|
|
self.change_dialog,
|
|
|
|
self.window, self.slist,
|
|
|
|
self.change_dialog.get_widget('gl_add_src'),
|
|
|
|
self.change_dialog.get_widget('gl_edit_src'),
|
|
|
|
self.change_dialog.get_widget('gl_del_src'))
|
|
|
|
|
2004-08-20 17:41:56 +05:30
|
|
|
self.descr_window.set_text(self.obj.get_description())
|
|
|
|
mtype = self.obj.get_mime_type()
|
2005-02-16 11:11:33 +05:30
|
|
|
if mtype:
|
2005-12-06 12:08:09 +05:30
|
|
|
pb = ImgManip.get_thumbnail_image(self.obj.get_path(),mtype)
|
2005-02-16 11:11:33 +05:30
|
|
|
self.pixmap.set_from_pixbuf(pb)
|
|
|
|
descr = Utils.get_mime_description(mtype)
|
2005-12-06 12:08:09 +05:30
|
|
|
if descr:
|
|
|
|
self.change_dialog.get_widget("type").set_text(descr)
|
2005-02-16 11:11:33 +05:30
|
|
|
else:
|
|
|
|
self.change_dialog.get_widget("type").set_text(_('Note'))
|
|
|
|
self.pixmap.hide()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-08-26 09:33:11 +05:30
|
|
|
self.change_dialog.get_widget("gid").set_text(self.obj.get_gramps_id())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.update_info()
|
|
|
|
|
2004-08-20 17:41:56 +05:30
|
|
|
if self.obj.get_note():
|
|
|
|
self.notes.get_buffer().set_text(self.obj.get_note())
|
2003-11-14 00:20:01 +05:30
|
|
|
Utils.bold_label(self.notes_label)
|
2004-08-20 17:41:56 +05:30
|
|
|
if self.obj.get_note_format() == 1:
|
2003-12-16 06:07:47 +05:30
|
|
|
self.preform.set_active(1)
|
|
|
|
else:
|
|
|
|
self.flowed.set_active(1)
|
2003-11-14 00:20:01 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
self.gladeif.connect('change_global','delete_event',
|
|
|
|
self.on_delete_event)
|
|
|
|
self.gladeif.connect('button91','clicked',self.close)
|
|
|
|
self.gladeif.connect('ok','clicked',self.on_ok_clicked)
|
|
|
|
self.gladeif.connect('button102','clicked',self.on_help_clicked)
|
|
|
|
self.gladeif.connect('notebook2','switch_page',
|
|
|
|
self.on_notebook_switch_page)
|
|
|
|
self.gladeif.connect('add_attr','clicked',self.on_add_attr_clicked)
|
|
|
|
self.gladeif.connect('button101','clicked',self.on_update_attr_clicked)
|
|
|
|
self.gladeif.connect('del_attr','clicked',self.on_delete_attr_clicked)
|
2005-02-20 06:32:15 +05:30
|
|
|
|
|
|
|
for name in ['gl_del_src','gl_add_src','add_attr','del_attr','ok']:
|
|
|
|
self.change_dialog.get_widget(name).set_sensitive(mode)
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.redraw_attr_list()
|
2004-06-03 11:05:30 +05:30
|
|
|
if parent_window:
|
|
|
|
self.window.set_transient_for(parent_window)
|
2005-04-26 21:34:21 +05:30
|
|
|
self.add_itself_to_menu()
|
2004-06-03 11:05:30 +05:30
|
|
|
self.window.show()
|
2005-06-05 09:31:56 +05:30
|
|
|
if not self.refs:
|
|
|
|
Utils.temp_label(self.refs_label,self.window)
|
2005-12-06 12:08:09 +05:30
|
|
|
self.cursor_type = None
|
|
|
|
self.idle = gobject.idle_add(self.display_refs)
|
2004-06-03 11:05:30 +05:30
|
|
|
|
|
|
|
def on_delete_event(self,obj,b):
|
|
|
|
self.close_child_windows()
|
|
|
|
self.remove_itself_from_menu()
|
2005-12-06 12:08:09 +05:30
|
|
|
gc.collect()
|
2004-06-03 11:05:30 +05:30
|
|
|
|
|
|
|
def close(self,obj):
|
|
|
|
self.close_child_windows()
|
2005-04-26 21:34:21 +05:30
|
|
|
self.remove_itself_from_menu()
|
2004-06-03 11:05:30 +05:30
|
|
|
self.window.destroy()
|
2005-12-06 12:08:09 +05:30
|
|
|
if self.idle != None:
|
|
|
|
gobject.source_remove(self.idle)
|
|
|
|
gc.collect()
|
2004-06-03 11:05:30 +05:30
|
|
|
|
|
|
|
def close_child_windows(self):
|
|
|
|
for child_window in self.child_windows.values():
|
|
|
|
child_window.close(None)
|
|
|
|
self.child_windows = {}
|
|
|
|
|
|
|
|
def add_itself_to_menu(self):
|
|
|
|
self.parent.parent.child_windows[self.win_key] = self
|
|
|
|
label = _('Media Object')
|
|
|
|
self.parent_menu_item = gtk.MenuItem(label)
|
|
|
|
self.parent_menu_item.set_submenu(gtk.Menu())
|
|
|
|
self.parent_menu_item.show()
|
|
|
|
self.parent.parent.winsmenu.append(self.parent_menu_item)
|
|
|
|
self.winsmenu = self.parent_menu_item.get_submenu()
|
|
|
|
self.menu_item = gtk.MenuItem(_('Properties Editor'))
|
|
|
|
self.menu_item.connect("activate",self.present)
|
|
|
|
self.menu_item.show()
|
|
|
|
self.winsmenu.append(self.menu_item)
|
|
|
|
|
|
|
|
def remove_itself_from_menu(self):
|
|
|
|
del self.parent.parent.child_windows[self.win_key]
|
|
|
|
self.menu_item.destroy()
|
|
|
|
self.winsmenu.destroy()
|
|
|
|
self.parent_menu_item.destroy()
|
|
|
|
|
|
|
|
def present(self,obj):
|
|
|
|
self.window.present()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def on_up_clicked(self,obj):
|
2004-08-20 17:41:56 +05:30
|
|
|
store,node = self.atree.get_selected()
|
|
|
|
if node:
|
|
|
|
row = self.atree.get_row(node)
|
2002-11-25 10:00:36 +05:30
|
|
|
if row != 0:
|
|
|
|
self.atree.select_row(row-1)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def on_down_clicked(self,obj):
|
2004-08-20 17:41:56 +05:30
|
|
|
model,node = self.atree.get_selected()
|
|
|
|
if not node:
|
2002-11-25 10:00:36 +05:30
|
|
|
return
|
2004-08-20 17:41:56 +05:30
|
|
|
row = self.atree.get_row(node)
|
2002-11-25 10:00:36 +05:30
|
|
|
self.atree.select_row(row+1)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def update_info(self):
|
2004-08-20 17:41:56 +05:30
|
|
|
fname = self.obj.get_path()
|
2004-04-04 10:09:52 +05:30
|
|
|
self.change_dialog.get_widget("path").set_text(fname)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def redraw_attr_list(self):
|
2002-11-25 10:00:36 +05:30
|
|
|
self.atree.clear()
|
2003-06-11 08:24:57 +05:30
|
|
|
self.amap = {}
|
2002-11-25 10:00:36 +05:30
|
|
|
for attr in self.alist:
|
2004-02-14 11:10:30 +05:30
|
|
|
d = [attr.get_type(),attr.get_value()]
|
2004-08-20 17:41:56 +05:30
|
|
|
node = self.atree.add(d,attr)
|
|
|
|
self.amap[str(attr)] = node
|
2003-11-14 00:20:01 +05:30
|
|
|
if self.alist:
|
|
|
|
Utils.bold_label(self.attr_label)
|
|
|
|
else:
|
|
|
|
Utils.unbold_label(self.attr_label)
|
|
|
|
|
2003-05-17 08:50:50 +05:30
|
|
|
def button_press(self,obj):
|
2005-12-06 12:08:09 +05:30
|
|
|
data = self.refmodel.get_selected_objects()
|
|
|
|
if not data:
|
2002-10-20 19:55:16 +05:30
|
|
|
return
|
2005-12-06 12:08:09 +05:30
|
|
|
(data_type,handle) = data[0]
|
|
|
|
if data_type == 0:
|
|
|
|
import EditPerson
|
2005-03-12 06:14:11 +05:30
|
|
|
person = self.db.get_person_from_handle(handle)
|
2005-12-06 12:08:09 +05:30
|
|
|
EditPerson.EditPerson(self.parent.parent,person,self.db)
|
|
|
|
elif data_type == 1:
|
|
|
|
import Marriage
|
2005-03-12 06:14:11 +05:30
|
|
|
family = self.db.get_family_from_handle(handle)
|
2005-12-06 12:08:09 +05:30
|
|
|
Marriage.Marriage(self.parent.parent,family,self.db)
|
|
|
|
elif data_type == 2:
|
|
|
|
import EventEdit
|
2005-03-12 06:14:11 +05:30
|
|
|
event = self.db.get_event_from_handle(handle)
|
2005-12-06 12:08:09 +05:30
|
|
|
event_name = event.get_name()
|
|
|
|
if const.family_events.has_key(event_name):
|
|
|
|
EventEdit.FamilyEventEditor(
|
|
|
|
self,", ", event, None, 0, None, None, self.db.readonly)
|
|
|
|
elif const.personal_events.has_key(event_name):
|
|
|
|
EventEdit.PersonEventEditor(
|
|
|
|
self,", ", event, None, 0, None, None, self.db.readonly)
|
|
|
|
elif event_name in ["Birth","Death"]:
|
|
|
|
EventEdit.PersonEventEditor(
|
|
|
|
self,", ", event, None, 1, None, None, self.db.readonly)
|
|
|
|
elif data_type == 3:
|
|
|
|
import EditPlace
|
2005-03-12 06:14:11 +05:30
|
|
|
place = self.db.get_place_from_handle(handle)
|
2005-12-06 12:08:09 +05:30
|
|
|
EditPlace.EditPlace(self.parent.parent,place)
|
|
|
|
elif data_type == 4:
|
2005-03-12 06:14:11 +05:30
|
|
|
source = self.db.get_source_from_handle(handle)
|
2005-12-06 12:08:09 +05:30
|
|
|
import EditSource
|
|
|
|
EditSource.EditSource(source,self.db,self.parent.parent,
|
|
|
|
None,self.db.readonly)
|
|
|
|
|
|
|
|
def display_refs(self):
|
|
|
|
media_handle = self.obj.get_handle()
|
|
|
|
self.refs = 1
|
2005-03-12 06:14:11 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
# Initialize things if we're entering this functioin
|
|
|
|
# for the first time
|
|
|
|
if not self.cursor_type:
|
|
|
|
self.cursor_type = 'Person'
|
|
|
|
self.cursor = self.db.get_person_cursor()
|
|
|
|
self.data = self.cursor.first()
|
|
|
|
|
|
|
|
self.any_refs = False
|
|
|
|
titles = [(_('Type'),0,150),(_('ID'),1,75),(_('Name'),2,150)]
|
|
|
|
self.refmodel = ListModel.ListModel(
|
|
|
|
self.change_dialog.get_widget("refinfo"),
|
|
|
|
titles,
|
|
|
|
event_func=self.button_press)
|
|
|
|
|
|
|
|
if self.cursor_type == 'Person':
|
|
|
|
while self.data:
|
|
|
|
handle,val = self.data
|
|
|
|
person = RelLib.Person()
|
|
|
|
person.unserialize(val)
|
|
|
|
if person.has_media_reference(media_handle):
|
|
|
|
name = NameDisplay.displayer.display(person)
|
|
|
|
gramps_id = person.get_gramps_id()
|
|
|
|
self.refmodel.add([_("Person"),gramps_id,name],
|
|
|
|
(0,handle))
|
|
|
|
self.any_refs = True
|
|
|
|
self.data = self.cursor.next()
|
|
|
|
if gtk.events_pending():
|
|
|
|
return True
|
|
|
|
self.cursor.close()
|
|
|
|
|
|
|
|
self.cursor_type = 'Family'
|
|
|
|
self.cursor = self.db.get_family_cursor()
|
|
|
|
self.data = self.cursor.first()
|
|
|
|
|
|
|
|
if self.cursor_type == 'Family':
|
|
|
|
while self.data:
|
|
|
|
handle,val = self.data
|
|
|
|
family = RelLib.Family()
|
|
|
|
family.unserialize(val)
|
|
|
|
if family.has_media_reference(media_handle):
|
|
|
|
name = Utils.family_name(family,self.db)
|
|
|
|
gramps_id = family.get_gramps_id()
|
|
|
|
self.refmodel.add([_("Family"),gramps_id,name],
|
|
|
|
(1,handle))
|
|
|
|
self.any_refs = True
|
|
|
|
self.data = self.cursor.next()
|
|
|
|
if gtk.events_pending():
|
|
|
|
return True
|
|
|
|
self.cursor.close()
|
|
|
|
|
|
|
|
self.cursor_type = 'Event'
|
|
|
|
self.cursor = self.db.get_event_cursor()
|
|
|
|
self.data = self.cursor.first()
|
|
|
|
|
|
|
|
if self.cursor_type == 'Event':
|
|
|
|
while self.data:
|
|
|
|
handle,val = self.data
|
|
|
|
event = RelLib.Event()
|
|
|
|
event.unserialize(val)
|
|
|
|
if event.has_media_reference(media_handle):
|
|
|
|
name = event.get_name()
|
|
|
|
gramps_id = event.get_gramps_id()
|
|
|
|
self.refmodel.add([_("Event"),gramps_id,name],
|
|
|
|
(2,handle))
|
|
|
|
self.any_refs = True
|
|
|
|
self.data = self.cursor.next()
|
|
|
|
if gtk.events_pending():
|
|
|
|
return True
|
|
|
|
self.cursor.close()
|
|
|
|
|
|
|
|
self.cursor_type = 'Place'
|
|
|
|
self.cursor = self.db.get_place_cursor()
|
|
|
|
self.data = self.cursor.first()
|
|
|
|
|
|
|
|
if self.cursor_type == 'Place':
|
|
|
|
while self.data:
|
|
|
|
handle,val = self.data
|
|
|
|
place = RelLib.Place()
|
|
|
|
place.unserialize(val)
|
|
|
|
if place.has_media_reference(media_handle):
|
|
|
|
name = place.get_title()
|
|
|
|
gramps_id = place.get_gramps_id()
|
|
|
|
self.refmodel.add([_("Place"),gramps_id,name],
|
|
|
|
(3,handle))
|
|
|
|
self.any_refs = True
|
|
|
|
self.data = self.cursor.next()
|
|
|
|
if gtk.events_pending():
|
|
|
|
return True
|
|
|
|
self.cursor.close()
|
|
|
|
|
|
|
|
self.cursor_type = 'Source'
|
|
|
|
self.cursor = self.db.get_source_cursor()
|
|
|
|
self.data = self.cursor.first()
|
|
|
|
|
|
|
|
if self.cursor_type == 'Source':
|
|
|
|
while self.data:
|
|
|
|
handle,val = self.data
|
|
|
|
source = RelLib.Source()
|
|
|
|
source.unserialize(val)
|
|
|
|
if source.has_media_reference(media_handle):
|
|
|
|
name = source.get_title()
|
|
|
|
gramps_id = source.get_gramps_id()
|
|
|
|
self.refmodel.add([_("Source"),gramps_id,name],
|
|
|
|
(4,handle))
|
|
|
|
self.any_refs = True
|
|
|
|
self.data = self.cursor.next()
|
|
|
|
if gtk.events_pending():
|
|
|
|
return True
|
|
|
|
self.cursor.close()
|
|
|
|
|
|
|
|
if self.any_refs:
|
2005-06-05 09:31:56 +05:30
|
|
|
Utils.bold_label(self.refs_label,self.window)
|
2003-11-14 00:20:01 +05:30
|
|
|
else:
|
2005-06-05 09:31:56 +05:30
|
|
|
Utils.unbold_label(self.refs_label,self.window)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
self.cursor_type = None
|
|
|
|
return False
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def on_notebook_switch_page(self,obj,junk,page):
|
2005-06-05 09:31:56 +05:30
|
|
|
if page == 3 and not self.refs:
|
|
|
|
Utils.temp_label(self.refs_label,self.window)
|
2005-12-06 12:08:09 +05:30
|
|
|
self.idle = gobject.idle_add(self.display_refs)
|
2003-11-14 00:20:01 +05:30
|
|
|
t = self.notes.get_buffer()
|
2005-02-24 05:55:34 +05:30
|
|
|
text = unicode(t.get_text(t.get_start_iter(),t.get_end_iter(),False))
|
2003-11-14 00:20:01 +05:30
|
|
|
if text:
|
|
|
|
Utils.bold_label(self.notes_label)
|
|
|
|
else:
|
|
|
|
Utils.unbold_label(self.notes_label)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-11-06 09:01:34 +05:30
|
|
|
def get_place(self,field,makenew=0):
|
|
|
|
text = unicode(field.get_text().strip())
|
|
|
|
if text:
|
|
|
|
if self.pdmap.has_key(text):
|
|
|
|
return self.pdmap[text]
|
|
|
|
elif makenew:
|
|
|
|
place = RelLib.Place()
|
|
|
|
place.set_title(text)
|
|
|
|
trans = self.db.transaction_begin()
|
|
|
|
self.db.add_place(place,trans)
|
|
|
|
self.db.transaction_commit(trans,_('Add Place (%s)' % text))
|
|
|
|
self.pdmap[text] = place.get_handle()
|
|
|
|
return place.get_handle()
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def on_apply_clicked(self, obj):
|
2002-10-27 09:13:12 +05:30
|
|
|
t = self.notes.get_buffer()
|
2005-02-24 05:55:34 +05:30
|
|
|
text = unicode(t.get_text(t.get_start_iter(),t.get_end_iter(),False))
|
2003-12-17 10:53:16 +05:30
|
|
|
desc = unicode(self.descr_window.get_text())
|
2004-08-20 17:41:56 +05:30
|
|
|
note = self.obj.get_note()
|
2005-07-09 01:54:54 +05:30
|
|
|
path = self.change_dialog.get_widget('path').get_text()
|
2005-12-06 12:08:09 +05:30
|
|
|
if path != self.obj.get_path():
|
|
|
|
mime = GrampsMime.get_type(path)
|
|
|
|
self.obj.set_mime_type(mime)
|
2005-07-09 01:54:54 +05:30
|
|
|
self.obj.set_path(path)
|
2004-11-06 09:01:34 +05:30
|
|
|
|
|
|
|
if not self.date_object.is_equal(self.obj.get_date_object()):
|
|
|
|
self.obj.set_date_object(self.date_object)
|
|
|
|
|
2003-12-16 06:07:47 +05:30
|
|
|
format = self.preform.get_active()
|
2004-08-20 17:41:56 +05:30
|
|
|
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)
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.lists_changed:
|
2004-08-20 17:41:56 +05:30
|
|
|
self.obj.set_attribute_list(self.alist)
|
|
|
|
self.obj.set_source_reference_list(self.srcreflist)
|
2004-08-13 10:04:07 +05:30
|
|
|
trans = self.db.transaction_begin()
|
2004-08-20 17:41:56 +05:30
|
|
|
self.db.commit_media_object(self.obj,trans)
|
2004-08-13 10:04:07 +05:30
|
|
|
self.db.transaction_commit(trans,_("Edit Media Object"))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-12-02 09:57:23 +05:30
|
|
|
def on_help_clicked(self, obj):
|
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
2005-12-06 12:08:09 +05:30
|
|
|
GrampsDisplay.help('adv-media')
|
2003-12-02 09:57:23 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def on_ok_clicked(self, obj):
|
|
|
|
self.on_apply_clicked(obj)
|
2004-06-13 11:48:20 +05:30
|
|
|
self.close(obj)
|
2003-12-02 09:57:23 +05:30
|
|
|
|
2003-03-03 10:02:53 +05:30
|
|
|
def on_attr_list_select_row(self,obj):
|
2004-08-20 17:41:56 +05:30
|
|
|
store,node = self.atree.get_selected()
|
|
|
|
if node:
|
|
|
|
attr = self.atree.get_object(node)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
self.attr_type.set_label(attr.get_type())
|
|
|
|
self.attr_value.set_text(attr.get_value())
|
2002-10-25 10:22:51 +05:30
|
|
|
else:
|
|
|
|
self.attr_type.set_label('')
|
|
|
|
self.attr_value.set_text('')
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-06-11 08:24:57 +05:30
|
|
|
def attr_callback(self,attr):
|
|
|
|
self.redraw_attr_list()
|
|
|
|
self.atree.select_iter(self.amap[str(attr)])
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def on_update_attr_clicked(self,obj):
|
|
|
|
import AttrEdit
|
2002-10-25 10:22:51 +05:30
|
|
|
|
2004-08-20 17:41:56 +05:30
|
|
|
store,node = self.atree.get_selected()
|
|
|
|
if node:
|
|
|
|
attr = self.atree.get_object(node)
|
2002-10-20 19:55:16 +05:30
|
|
|
AttrEdit.AttributeEditor(self,attr,"Media Object",
|
2005-03-08 08:44:25 +05:30
|
|
|
PluginMgr.get_image_attributes(),
|
2003-06-11 08:24:57 +05:30
|
|
|
self.attr_callback)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def on_delete_attr_clicked(self,obj):
|
|
|
|
if Utils.delete_selected(obj,self.alist):
|
|
|
|
self.lists_changed = 1
|
|
|
|
self.redraw_attr_list()
|
|
|
|
|
|
|
|
def on_add_attr_clicked(self,obj):
|
|
|
|
import AttrEdit
|
|
|
|
AttrEdit.AttributeEditor(self,None,"Media Object",
|
2005-03-08 08:44:25 +05:30
|
|
|
PluginMgr.get_image_attributes(),
|
2003-06-11 08:24:57 +05:30
|
|
|
self.attr_callback)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
class DeleteMediaQuery:
|
|
|
|
|
2005-04-04 05:57:06 +05:30
|
|
|
def __init__(self,media_handle,db,the_lists):
|
2002-10-20 19:55:16 +05:30
|
|
|
self.db = db
|
2005-03-12 06:14:11 +05:30
|
|
|
self.media_handle = media_handle
|
|
|
|
self.the_lists = the_lists
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def query_response(self):
|
2004-08-13 10:04:07 +05:30
|
|
|
trans = self.db.transaction_begin()
|
2005-06-05 09:31:56 +05:30
|
|
|
self.db.disable_signals()
|
2004-03-30 10:20:24 +05:30
|
|
|
|
2005-03-12 06:14:11 +05:30
|
|
|
(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)
|
|
|
|
|
2005-06-05 09:31:56 +05:30
|
|
|
self.db.enable_signals()
|
2005-03-12 06:14:11 +05:30
|
|
|
self.db.remove_object(self.media_handle,trans)
|
2004-08-13 10:04:07 +05:30
|
|
|
self.db.transaction_commit(trans,_("Remove Media Object"))
|
2004-11-06 09:01:34 +05:30
|
|
|
|
|
|
|
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)
|