2007-01-16 12:42:10 +05:30
|
|
|
#
|
2006-02-22 10:03:34 +05:30
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
2009-02-08 04:24:16 +05:30
|
|
|
# 2008-2009 Stephane Charette <stephanecharette@gmail.com>
|
|
|
|
# 2009 Gary Burton
|
2006-02-22 10:03:34 +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
|
|
|
|
#
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Standard python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2010-01-18 10:12:17 +05:30
|
|
|
from gen.ggettext import sgettext as _
|
2006-02-22 10:03:34 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2009-06-24 02:19:18 +05:30
|
|
|
from gui.utils import open_file_with_default_application
|
2006-02-22 10:03:34 +05:30
|
|
|
import const
|
2010-01-25 01:47:14 +05:30
|
|
|
import gen.mime
|
2007-09-11 03:44:33 +05:30
|
|
|
import ThumbNails
|
2009-02-01 09:51:17 +05:30
|
|
|
import Utils
|
2007-10-08 22:11:39 +05:30
|
|
|
from gen.lib import NoteType
|
2009-05-15 01:45:59 +05:30
|
|
|
from glade import Glade
|
2009-12-16 11:41:06 +05:30
|
|
|
from displaytabs import (SourceEmbedList, AttrEmbedList, MediaBackRefList,
|
2008-02-19 01:37:09 +05:30
|
|
|
NoteTab)
|
2009-12-14 08:50:19 +05:30
|
|
|
from gui.widgets import MonitoredSpinButton, MonitoredEntry, PrivacyButton
|
2009-12-15 11:26:12 +05:30
|
|
|
from editreference import RefTab, EditReference
|
|
|
|
from addmedia import AddMediaObject
|
2006-02-22 10:03:34 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2006-03-05 08:06:09 +05:30
|
|
|
# EditMediaRef
|
2006-02-22 10:03:34 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-03-05 08:06:09 +05:30
|
|
|
class EditMediaRef(EditReference):
|
2006-11-26 10:09:34 +05:30
|
|
|
|
2006-03-05 04:23:46 +05:30
|
|
|
def __init__(self, state, uistate, track, media, media_ref, update):
|
2006-03-05 08:06:09 +05:30
|
|
|
EditReference.__init__(self, state, uistate, track, media,
|
|
|
|
media_ref, update)
|
2008-01-16 17:58:56 +05:30
|
|
|
if not self.source.get_handle():
|
|
|
|
#show the addmedia dialog immediately, with track of parent.
|
|
|
|
AddMediaObject(state, self.uistate, self.track, self.source,
|
|
|
|
self._update_addmedia)
|
2006-02-22 10:03:34 +05:30
|
|
|
|
2006-03-05 08:06:09 +05:30
|
|
|
def _local_init(self):
|
2009-10-08 06:42:51 +05:30
|
|
|
self.width_key = 'interface.media-ref-width'
|
|
|
|
self.height_key = 'interface.media-ref-height'
|
2009-05-15 01:45:59 +05:30
|
|
|
self.top = Glade()
|
2006-02-22 10:03:34 +05:30
|
|
|
|
2009-05-15 01:45:59 +05:30
|
|
|
self.set_window(self.top.toplevel,
|
2009-05-07 00:45:55 +05:30
|
|
|
self.top.get_object('title'),
|
2006-04-24 03:48:01 +05:30
|
|
|
_('Media Reference Editor'))
|
2009-05-07 00:45:55 +05:30
|
|
|
self.define_warn_box(self.top.get_object("warn_box"))
|
|
|
|
self.top.get_object("label427").set_text(_("Y coordinate|Y"))
|
|
|
|
self.top.get_object("label428").set_text(_("Y coordinate|Y"))
|
2007-12-20 19:19:41 +05:30
|
|
|
|
2009-05-07 00:45:55 +05:30
|
|
|
tblref = self.top.get_object('table50')
|
|
|
|
notebook = self.top.get_object('notebook_ref')
|
2007-12-20 19:19:41 +05:30
|
|
|
#recreate start page as GrampsTab
|
|
|
|
notebook.remove_page(0)
|
|
|
|
self.reftab = RefTab(self.dbstate, self.uistate, self.track,
|
|
|
|
_('General'), tblref)
|
2009-05-07 00:45:55 +05:30
|
|
|
tblref = self.top.get_object('table2')
|
|
|
|
notebook = self.top.get_object('notebook_shared')
|
2007-12-20 19:19:41 +05:30
|
|
|
#recreate start page as GrampsTab
|
|
|
|
notebook.remove_page(0)
|
|
|
|
self.primtab = RefTab(self.dbstate, self.uistate, self.track,
|
2008-02-16 04:08:47 +05:30
|
|
|
_('_General'), tblref)
|
2007-12-20 19:19:41 +05:30
|
|
|
|
2008-01-16 17:58:56 +05:30
|
|
|
def draw_preview(self):
|
|
|
|
"""
|
|
|
|
Draw the two preview images. This method can be called on eg change of
|
|
|
|
the path.
|
|
|
|
"""
|
|
|
|
self.mtype = self.source.get_mime_type()
|
2009-02-01 09:51:17 +05:30
|
|
|
fullpath = Utils.media_path_full(self.db, self.source.get_path())
|
2008-02-18 19:36:41 +05:30
|
|
|
self.pix = ThumbNails.get_thumbnail_image(fullpath,
|
2008-01-16 17:58:56 +05:30
|
|
|
self.mtype)
|
|
|
|
self.pixmap.set_from_pixbuf(self.pix)
|
2006-03-05 08:06:09 +05:30
|
|
|
|
2008-02-18 19:36:41 +05:30
|
|
|
self.subpix = ThumbNails.get_thumbnail_image(fullpath,
|
2008-01-16 17:58:56 +05:30
|
|
|
self.mtype,
|
|
|
|
self.rectangle)
|
|
|
|
self.subpixmap.set_from_pixbuf(self.subpix)
|
|
|
|
|
2010-01-25 01:47:14 +05:30
|
|
|
mt = gen.mime.get_description(self.mtype)
|
2009-05-07 00:45:55 +05:30
|
|
|
self.top.get_object("type").set_text(mt if mt else "")
|
|
|
|
|
2006-03-05 08:06:09 +05:30
|
|
|
def _setup_fields(self):
|
2009-05-07 00:45:55 +05:30
|
|
|
ebox_shared = self.top.get_object('eventbox')
|
2008-10-12 15:09:11 +05:30
|
|
|
ebox_shared.connect('button-press-event', self.button_press_event)
|
|
|
|
|
|
|
|
if not self.dbstate.db.readonly:
|
|
|
|
self.button_press_coords = (0, 0)
|
2009-05-07 00:45:55 +05:30
|
|
|
ebox_ref = self.top.get_object('eventbox1')
|
2008-10-12 15:09:11 +05:30
|
|
|
ebox_ref.connect('button-press-event', self.button_press_event_ref)
|
2009-05-07 00:45:55 +05:30
|
|
|
ebox_ref.connect('button-release-event',
|
|
|
|
self.button_release_event_ref)
|
2008-10-12 15:09:11 +05:30
|
|
|
ebox_ref.add_events(gtk.gdk.BUTTON_PRESS_MASK)
|
|
|
|
ebox_ref.add_events(gtk.gdk.BUTTON_RELEASE_MASK)
|
|
|
|
|
2009-05-07 00:45:55 +05:30
|
|
|
self.pixmap = self.top.get_object("pixmap")
|
2008-01-16 17:58:56 +05:30
|
|
|
|
2006-03-05 08:06:09 +05:30
|
|
|
coord = self.source_ref.get_rectangle()
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
#upgrade path: set invalid (from eg old db) to none
|
2008-07-03 23:58:44 +05:30
|
|
|
|
|
|
|
if coord is not None and coord in (
|
2009-05-07 00:45:55 +05:30
|
|
|
(None,)*4,
|
2008-07-03 23:58:44 +05:30
|
|
|
(0, 0, 100, 100),
|
2009-05-07 00:45:55 +05:30
|
|
|
(coord[0], coord[1])*2
|
2008-06-16 20:31:46 +05:30
|
|
|
):
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
coord = None
|
2008-06-16 20:31:46 +05:30
|
|
|
|
2007-09-29 00:03:22 +05:30
|
|
|
self.rectangle = coord
|
2009-05-07 00:45:55 +05:30
|
|
|
self.subpixmap = self.top.get_object("subpixmap")
|
2008-01-16 17:58:56 +05:30
|
|
|
|
|
|
|
self.draw_preview()
|
2009-05-07 00:45:55 +05:30
|
|
|
|
|
|
|
corners = ["corner1_x", "corner1_y", "corner2_x", "corner2_y"]
|
2007-09-29 00:03:22 +05:30
|
|
|
|
2008-05-26 01:25:47 +05:30
|
|
|
if coord and isinstance(coord, tuple):
|
2009-05-07 00:45:55 +05:30
|
|
|
for index, corner in enumerate(corners):
|
|
|
|
self.top.get_object(corner).set_value(coord[index])
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
else:
|
2009-05-07 00:45:55 +05:30
|
|
|
for corner, value in zip(corners, [0, 0, 100, 100]):
|
|
|
|
self.top.get_object(corner).set_value(value)
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
|
2006-12-15 18:09:28 +05:30
|
|
|
if self.dbstate.db.readonly:
|
2009-05-07 00:45:55 +05:30
|
|
|
for corner in corners:
|
|
|
|
self.top.get_object(corner).set_sensitive(False)
|
2006-02-22 10:03:34 +05:30
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
self.corner1_x_spinbutton = MonitoredSpinButton(
|
2009-05-07 00:45:55 +05:30
|
|
|
self.top.get_object("corner1_x"),
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
self.set_corner1_x,
|
|
|
|
self.get_corner1_x,
|
2007-09-29 00:03:22 +05:30
|
|
|
self.db.readonly)
|
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
self.corner1_y_spinbutton = MonitoredSpinButton(
|
2009-05-07 00:45:55 +05:30
|
|
|
self.top.get_object("corner1_y"),
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
self.set_corner1_y,
|
|
|
|
self.get_corner1_y,
|
2007-09-29 00:03:22 +05:30
|
|
|
self.db.readonly)
|
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
self.corner2_x_spinbutton = MonitoredSpinButton(
|
2009-05-07 00:45:55 +05:30
|
|
|
self.top.get_object("corner2_x"),
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
self.set_corner2_x,
|
|
|
|
self.get_corner2_x,
|
2007-09-29 00:03:22 +05:30
|
|
|
self.db.readonly)
|
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
self.corner2_y_spinbutton = MonitoredSpinButton(
|
2009-05-07 00:45:55 +05:30
|
|
|
self.top.get_object("corner2_y"),
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
self.set_corner2_y,
|
|
|
|
self.get_corner2_y,
|
2007-09-29 00:03:22 +05:30
|
|
|
self.db.readonly)
|
|
|
|
|
2006-03-05 04:23:46 +05:30
|
|
|
self.descr_window = MonitoredEntry(
|
2009-05-07 00:45:55 +05:30
|
|
|
self.top.get_object("description"),
|
2006-03-05 08:06:09 +05:30
|
|
|
self.source.set_description,
|
|
|
|
self.source.get_description,
|
2006-03-05 04:23:46 +05:30
|
|
|
self.db.readonly)
|
|
|
|
|
2006-08-30 05:15:07 +05:30
|
|
|
self.ref_privacy = PrivacyButton(
|
2009-05-07 00:45:55 +05:30
|
|
|
self.top.get_object("private"),
|
2006-03-05 08:06:09 +05:30
|
|
|
self.source_ref,
|
2006-03-05 04:23:46 +05:30
|
|
|
self.db.readonly)
|
|
|
|
|
2006-02-22 10:03:34 +05:30
|
|
|
self.gid = MonitoredEntry(
|
2009-05-07 00:45:55 +05:30
|
|
|
self.top.get_object("gid"),
|
2006-03-05 08:06:09 +05:30
|
|
|
self.source.set_gramps_id,
|
|
|
|
self.source.get_gramps_id,
|
2006-02-22 10:03:34 +05:30
|
|
|
self.db.readonly)
|
|
|
|
|
2006-08-30 05:15:07 +05:30
|
|
|
self.privacy = PrivacyButton(
|
2009-05-07 00:45:55 +05:30
|
|
|
self.top.get_object("privacy"),
|
2006-08-30 05:15:07 +05:30
|
|
|
self.source,
|
|
|
|
self.db.readonly)
|
|
|
|
|
2006-02-22 10:03:34 +05:30
|
|
|
self.path_obj = MonitoredEntry(
|
2009-05-07 00:45:55 +05:30
|
|
|
self.top.get_object("path"),
|
2006-03-05 08:06:09 +05:30
|
|
|
self.source.set_path,
|
|
|
|
self.source.get_path,
|
2006-02-22 10:03:34 +05:30
|
|
|
self.db.readonly)
|
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
def set_corner1_x(self, value):
|
2007-09-29 00:03:22 +05:30
|
|
|
"""
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
Callback for the signal handling of the spinbutton for the first
|
|
|
|
corner x coordinate of the subsection.
|
|
|
|
Updates the subsection thumbnail using the given value
|
2007-09-29 00:03:22 +05:30
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
@param value: the first corner x coordinate of the subsection in int
|
2007-09-29 00:03:22 +05:30
|
|
|
"""
|
|
|
|
|
2009-02-24 00:41:46 +05:30
|
|
|
if self.rectangle is None:
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
self.rectangle = (0,0,100,100)
|
2009-05-07 00:45:55 +05:30
|
|
|
self.rectangle = (value,) + self.rectangle[1:]
|
2007-09-29 00:03:22 +05:30
|
|
|
self.update_subpixmap()
|
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
def set_corner1_y(self, value):
|
2007-09-29 00:03:22 +05:30
|
|
|
"""
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
Callback for the signal handling of the spinbutton for the first
|
|
|
|
corner y coordinate of the subsection.
|
|
|
|
Updates the subsection thumbnail using the given value
|
2007-09-29 00:03:22 +05:30
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
@param value: the first corner y coordinate of the subsection in int
|
2007-09-29 00:03:22 +05:30
|
|
|
"""
|
|
|
|
|
2009-02-24 00:41:46 +05:30
|
|
|
if self.rectangle is None:
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
self.rectangle = (0,0,100,100)
|
2009-05-07 00:45:55 +05:30
|
|
|
self.rectangle = self.rectangle[:1] + (value,) + self.rectangle[2:]
|
2009-06-30 14:20:10 +05:30
|
|
|
self.update_subpixmap()
|
2007-09-29 00:03:22 +05:30
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
def set_corner2_x(self, value):
|
2007-09-29 00:03:22 +05:30
|
|
|
"""
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
Callback for the signal handling of the spinbutton for the second
|
|
|
|
corner x coordinate of the subsection.
|
|
|
|
Updates the subsection thumbnail using the given value
|
2007-09-29 00:03:22 +05:30
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
@param value: the second corner x coordinate of the subsection in int
|
2007-09-29 00:03:22 +05:30
|
|
|
"""
|
|
|
|
|
2009-02-24 00:41:46 +05:30
|
|
|
if self.rectangle is None:
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
self.rectangle = (0,0,100,100)
|
2009-05-07 00:45:55 +05:30
|
|
|
self.rectangle = self.rectangle[:2] + (value,) + self.rectangle[3:]
|
2007-09-29 00:03:22 +05:30
|
|
|
self.update_subpixmap()
|
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
def set_corner2_y(self, value):
|
2007-09-29 00:03:22 +05:30
|
|
|
"""
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
Callback for the signal handling of the spinbutton for the second
|
|
|
|
corner y coordinate of the subsection.
|
|
|
|
Updates the subsection thumbnail using the given value
|
2007-09-29 00:03:22 +05:30
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
@param value: the second corner y coordinate of the subsection in int
|
2007-09-29 00:03:22 +05:30
|
|
|
"""
|
|
|
|
|
2009-02-24 00:41:46 +05:30
|
|
|
if self.rectangle is None:
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
self.rectangle = (0,0,100,100)
|
2009-05-07 00:45:55 +05:30
|
|
|
self.rectangle = self.rectangle[:3] + (value,)
|
2007-09-29 00:03:22 +05:30
|
|
|
self.update_subpixmap()
|
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
def get_corner1_x(self):
|
2007-09-29 00:03:22 +05:30
|
|
|
"""
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
Callback for the signal handling of the spinbutton for the first corner
|
|
|
|
x coordinate of the subsection.
|
2007-09-29 00:03:22 +05:30
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
@returns: the first corner x coordinate of the subsection or 0 if
|
|
|
|
there is no selection
|
2007-09-29 00:03:22 +05:30
|
|
|
"""
|
|
|
|
|
2009-02-24 00:41:46 +05:30
|
|
|
if self.rectangle is not None:
|
2007-09-29 00:03:22 +05:30
|
|
|
return self.rectangle[0]
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
def get_corner1_y(self):
|
2007-09-29 00:03:22 +05:30
|
|
|
"""
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
Callback for the signal handling of the spinbutton for the first corner
|
|
|
|
y coordinate of the subsection.
|
2007-09-29 00:03:22 +05:30
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
@returns: the first corner y coordinate of the subsection or 0 if
|
|
|
|
there is no selection
|
2007-09-29 00:03:22 +05:30
|
|
|
"""
|
|
|
|
|
2009-02-24 00:41:46 +05:30
|
|
|
if self.rectangle is not None:
|
2007-09-29 00:03:22 +05:30
|
|
|
return self.rectangle[1]
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
def get_corner2_x(self):
|
2007-09-29 00:03:22 +05:30
|
|
|
"""
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
Callback for the signal handling of the spinbutton for the second
|
|
|
|
corner x coordinate of the subsection.
|
2007-09-29 00:03:22 +05:30
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
@returns: the second corner x coordinate of the subsection or 100 if
|
|
|
|
there is no selection
|
2007-09-29 00:03:22 +05:30
|
|
|
"""
|
|
|
|
|
2009-02-24 00:41:46 +05:30
|
|
|
if self.rectangle is not None:
|
2007-09-29 00:03:22 +05:30
|
|
|
return self.rectangle[2]
|
|
|
|
else:
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
return 100
|
2007-09-29 00:03:22 +05:30
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
def get_corner2_y(self):
|
2007-09-29 00:03:22 +05:30
|
|
|
"""
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
Callback for the signal handling of the spinbutton for the second
|
|
|
|
corner x coordinate of the subsection.
|
2007-09-29 00:03:22 +05:30
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
@returns: the second corner x coordinate of the subsection or 100 if
|
|
|
|
there is no selection
|
2007-09-29 00:03:22 +05:30
|
|
|
"""
|
|
|
|
|
2009-02-24 00:41:46 +05:30
|
|
|
if self.rectangle is not None:
|
2007-09-29 00:03:22 +05:30
|
|
|
return self.rectangle[3]
|
|
|
|
else:
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
return 100
|
2007-09-29 00:03:22 +05:30
|
|
|
|
|
|
|
def update_subpixmap(self):
|
|
|
|
"""
|
|
|
|
Updates the thumbnail of the specified subsection
|
|
|
|
"""
|
|
|
|
|
|
|
|
path = self.source.get_path()
|
2009-02-24 00:41:46 +05:30
|
|
|
if path is None:
|
2007-09-29 00:03:22 +05:30
|
|
|
self.subpixmap.hide()
|
|
|
|
else:
|
|
|
|
try:
|
2009-02-01 09:51:17 +05:30
|
|
|
fullpath = Utils.media_path_full(self.db, path)
|
2008-02-18 19:36:41 +05:30
|
|
|
pixbuf = gtk.gdk.pixbuf_new_from_file(fullpath)
|
2007-09-29 00:03:22 +05:30
|
|
|
width = pixbuf.get_width()
|
|
|
|
height = pixbuf.get_height()
|
|
|
|
upper_x = min(self.rectangle[0], self.rectangle[2])/100.
|
|
|
|
lower_x = max(self.rectangle[0], self.rectangle[2])/100.
|
|
|
|
upper_y = min(self.rectangle[1], self.rectangle[3])/100.
|
|
|
|
lower_y = max(self.rectangle[1], self.rectangle[3])/100.
|
|
|
|
sub_x = int(upper_x * width)
|
|
|
|
sub_y = int(upper_y * height)
|
|
|
|
sub_width = int((lower_x - upper_x) * width)
|
|
|
|
sub_height = int((lower_y - upper_y) * height)
|
|
|
|
if sub_width > 0 and sub_height > 0:
|
|
|
|
pixbuf = pixbuf.subpixbuf(sub_x, sub_y, sub_width, sub_height)
|
|
|
|
width = sub_width
|
|
|
|
height = sub_height
|
|
|
|
ratio = float(max(height, width))
|
|
|
|
scale = const.THUMBSCALE / ratio
|
|
|
|
x = int(scale * width)
|
|
|
|
y = int(scale * height)
|
|
|
|
pixbuf = pixbuf.scale_simple(x, y, gtk.gdk.INTERP_BILINEAR)
|
|
|
|
self.subpixmap.set_from_pixbuf(pixbuf)
|
|
|
|
self.subpixmap.show()
|
|
|
|
except:
|
|
|
|
self.subpixmap.hide()
|
|
|
|
|
2007-08-29 18:20:37 +05:30
|
|
|
def build_menu_names(self, person):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Provide the information needed by the base class to define the
|
2007-08-29 18:20:37 +05:30
|
|
|
window management menu entries.
|
|
|
|
"""
|
|
|
|
if self.source:
|
|
|
|
submenu_label = _('Media: %s') % self.source.get_gramps_id()
|
|
|
|
else:
|
|
|
|
submenu_label = _('New Media')
|
|
|
|
return (_('Media Reference Editor'),submenu_label)
|
|
|
|
|
2006-12-10 09:54:11 +05:30
|
|
|
def button_press_event(self, obj, event):
|
|
|
|
if event.button==1 and event.type == gtk.gdk._2BUTTON_PRESS:
|
2009-02-01 09:51:17 +05:30
|
|
|
photo_path = Utils.media_path_full(self.db, self.source.get_path())
|
2009-06-24 02:19:18 +05:30
|
|
|
open_file_with_default_application(photo_path)
|
2006-12-10 09:54:11 +05:30
|
|
|
|
2008-10-12 15:09:11 +05:30
|
|
|
def button_press_event_ref(self, widget, event):
|
|
|
|
"""
|
|
|
|
Handle the button-press-event generated by the eventbox
|
|
|
|
parent of the subpixmap. Remember these coordinates
|
|
|
|
so we can crop the picture when button-release-event
|
|
|
|
is received.
|
|
|
|
"""
|
|
|
|
self.button_press_coords = (event.x, event.y)
|
|
|
|
|
|
|
|
def button_release_event_ref(self, widget, event):
|
|
|
|
"""
|
|
|
|
Handle the button-release-event generated by the eventbox
|
|
|
|
parent of the subpixmap. Crop the picture accordingly.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# reset the crop on double-click or click+CTRL
|
|
|
|
if (event.button==1 and event.type == gtk.gdk._2BUTTON_PRESS) or \
|
|
|
|
(event.button==1 and (event.state & gtk.gdk.CONTROL_MASK) ):
|
|
|
|
self.corner1_x_spinbutton.set_value(0)
|
|
|
|
self.corner1_y_spinbutton.set_value(0)
|
|
|
|
self.corner2_x_spinbutton.set_value(100)
|
|
|
|
self.corner2_y_spinbutton.set_value(100)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
# ensure the clicks happened at least 5 pixels away from each other
|
|
|
|
new_x1 = min(self.button_press_coords[0], event.x)
|
|
|
|
new_y1 = min(self.button_press_coords[1], event.y)
|
|
|
|
new_x2 = max(self.button_press_coords[0], event.x)
|
|
|
|
new_y2 = max(self.button_press_coords[1], event.y)
|
|
|
|
|
|
|
|
if new_x2 - new_x1 >= 5 and new_y2 - new_y1 >= 5:
|
|
|
|
|
|
|
|
# get the image size and calculate the X and Y offsets
|
|
|
|
# (image is centered when smaller than const.THUMBSCALE)
|
|
|
|
pixbuf = self.subpixmap.get_pixbuf();
|
|
|
|
w = pixbuf.get_width()
|
|
|
|
h = pixbuf.get_height()
|
|
|
|
x = (const.THUMBSCALE - w) / 2
|
|
|
|
y = (const.THUMBSCALE - h) / 2
|
|
|
|
|
|
|
|
# if the click was outside of the image,
|
|
|
|
# bring it within the boundaries
|
|
|
|
if new_x1 < x:
|
|
|
|
new_x1 = x
|
|
|
|
if new_y1 < y:
|
|
|
|
new_y1 = y
|
|
|
|
if new_x2 >= x + w:
|
|
|
|
new_x2 = x + w - 1
|
|
|
|
if new_y2 >= y + h:
|
|
|
|
new_y2 = y + h - 1
|
|
|
|
|
|
|
|
# get the old spinbutton % values
|
|
|
|
old_x1 = self.corner1_x_spinbutton.get_value()
|
|
|
|
old_y1 = self.corner1_y_spinbutton.get_value()
|
|
|
|
old_x2 = self.corner2_x_spinbutton.get_value()
|
|
|
|
old_y2 = self.corner2_y_spinbutton.get_value()
|
|
|
|
delta_x = old_x2 - old_x1 # horizontal scale
|
|
|
|
delta_y = old_y2 - old_y1 # vertical scale
|
|
|
|
|
|
|
|
# Took a while to figure out the math here.
|
|
|
|
#
|
|
|
|
# 1) figure out the current crop % values
|
|
|
|
# by doing the following:
|
|
|
|
#
|
|
|
|
# xp = click_location_x / width * 100
|
|
|
|
# yp = click_location_y / height * 100
|
|
|
|
#
|
|
|
|
# but remember that click_location_x and _y
|
|
|
|
# might not be zero-based for non-rectangular
|
|
|
|
# images, so subtract the pixbuf "x" and "y"
|
|
|
|
# to bring the values back to zero-based
|
|
|
|
#
|
|
|
|
# 2) the minimum value cannot be less than the
|
|
|
|
# existing crop value, so add the current
|
|
|
|
# minimum to the new values
|
|
|
|
|
|
|
|
new_x1 = old_x1 + delta_x * (new_x1 - x) / w
|
|
|
|
new_y1 = old_y1 + delta_y * (new_y1 - y) / h
|
|
|
|
new_x2 = old_x1 + delta_x * (new_x2 - x) / w
|
|
|
|
new_y2 = old_y1 + delta_y * (new_y2 - y) / h
|
|
|
|
|
|
|
|
# set the new values
|
|
|
|
self.corner1_x_spinbutton.set_value(new_x1)
|
|
|
|
self.corner1_y_spinbutton.set_value(new_y1)
|
|
|
|
self.corner2_x_spinbutton.set_value(new_x2)
|
|
|
|
self.corner2_y_spinbutton.set_value(new_y2)
|
|
|
|
|
2008-01-16 17:58:56 +05:30
|
|
|
def _update_addmedia(self, obj):
|
|
|
|
"""
|
|
|
|
Called when the add media dialog has been called.
|
|
|
|
This allows us to update the main form in response to
|
|
|
|
any changes: Redraw relevant fields: description, mimetype and path
|
|
|
|
"""
|
|
|
|
for obj in (self.descr_window, self.path_obj):
|
|
|
|
obj.update()
|
|
|
|
self.draw_preview()
|
|
|
|
|
2006-03-05 04:23:46 +05:30
|
|
|
def _connect_signals(self):
|
2009-05-07 00:45:55 +05:30
|
|
|
self.define_cancel_button(self.top.get_object('button84'))
|
|
|
|
self.define_ok_button(self.top.get_object('button82'),self.save)
|
2006-03-05 04:23:46 +05:30
|
|
|
|
2009-08-05 16:02:05 +05:30
|
|
|
def _connect_db_signals(self):
|
|
|
|
"""
|
|
|
|
Connect any signals that need to be connected.
|
|
|
|
Called by the init routine of the base class (_EditPrimary).
|
|
|
|
"""
|
|
|
|
self._add_db_signal('media-rebuild', self.close)
|
|
|
|
self._add_db_signal('media-delete', self.check_for_close)
|
|
|
|
|
2006-02-22 10:03:34 +05:30
|
|
|
def _create_tabbed_pages(self):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Create the notebook tabs and inserts them into the main
|
2006-02-22 10:03:34 +05:30
|
|
|
window.
|
|
|
|
"""
|
2009-05-07 00:45:55 +05:30
|
|
|
notebook_ref = self.top.get_object('notebook_ref')
|
|
|
|
notebook_src = self.top.get_object('notebook_shared')
|
2007-12-20 19:19:41 +05:30
|
|
|
|
|
|
|
self._add_tab(notebook_src, self.primtab)
|
|
|
|
self._add_tab(notebook_ref, self.reftab)
|
|
|
|
|
2006-03-05 08:06:09 +05:30
|
|
|
self.srcref_list = self._add_tab(
|
|
|
|
notebook_ref,
|
2006-10-09 08:15:26 +05:30
|
|
|
SourceEmbedList(self.dbstate,self.uistate,self.track,
|
|
|
|
self.source_ref))
|
2006-03-05 08:06:09 +05:30
|
|
|
|
|
|
|
self.attr_list = self._add_tab(
|
|
|
|
notebook_ref,
|
|
|
|
AttrEmbedList(self.dbstate,self.uistate,self.track,
|
|
|
|
self.source_ref.get_attribute_list()))
|
|
|
|
|
|
|
|
self.backref_list = self._add_tab(
|
|
|
|
notebook_src,
|
|
|
|
MediaBackRefList(self.dbstate,self.uistate,self.track,
|
2006-04-21 04:02:17 +05:30
|
|
|
self.db.find_backlink_handles(self.source.handle),
|
|
|
|
self.enable_warnbox
|
|
|
|
))
|
2006-03-05 08:06:09 +05:30
|
|
|
|
|
|
|
self.note_ref_tab = self._add_tab(
|
|
|
|
notebook_ref,
|
|
|
|
NoteTab(self.dbstate, self.uistate, self.track,
|
2007-05-08 02:11:16 +05:30
|
|
|
self.source_ref.get_note_list(),
|
|
|
|
notetype=NoteType.MEDIAREF))
|
2006-03-05 08:06:09 +05:30
|
|
|
|
|
|
|
self.src_srcref_list = self._add_tab(
|
|
|
|
notebook_src,
|
2006-10-09 08:15:26 +05:30
|
|
|
SourceEmbedList(self.dbstate,self.uistate,self.track,
|
|
|
|
self.source))
|
2006-03-05 08:06:09 +05:30
|
|
|
|
|
|
|
self.src_attr_list = self._add_tab(
|
|
|
|
notebook_src,
|
|
|
|
AttrEmbedList(self.dbstate,self.uistate,self.track,
|
|
|
|
self.source.get_attribute_list()))
|
|
|
|
|
|
|
|
self.src_note_ref_tab = self._add_tab(
|
|
|
|
notebook_src,
|
|
|
|
NoteTab(self.dbstate, self.uistate, self.track,
|
2007-05-08 02:11:16 +05:30
|
|
|
self.source.get_note_list(),
|
|
|
|
notetype=NoteType.MEDIA))
|
2006-03-05 08:06:09 +05:30
|
|
|
|
2008-02-16 04:08:47 +05:30
|
|
|
self._setup_notebook_tabs(notebook_src)
|
|
|
|
self._setup_notebook_tabs(notebook_ref)
|
2007-01-16 12:42:10 +05:30
|
|
|
|
2006-03-05 08:06:09 +05:30
|
|
|
def save(self,*obj):
|
2008-01-16 17:58:56 +05:30
|
|
|
#first save primary object
|
|
|
|
trans = self.db.transaction_begin()
|
|
|
|
if self.source.handle:
|
|
|
|
self.db.commit_media_object(self.source, trans)
|
|
|
|
self.db.transaction_commit(trans, _("Edit Media Object (%s)"
|
|
|
|
) % self.source.get_description())
|
|
|
|
else:
|
|
|
|
self.db.add_object(self.source, trans)
|
|
|
|
self.db.transaction_commit(trans,_("Add Media Object (%s)"
|
|
|
|
) % self.source.get_description())
|
2006-02-22 10:03:34 +05:30
|
|
|
|
2008-01-16 17:58:56 +05:30
|
|
|
#save reference object in memory
|
2006-02-22 10:03:34 +05:30
|
|
|
coord = (
|
2009-05-07 00:45:55 +05:30
|
|
|
self.top.get_object("corner1_x").get_value_as_int(),
|
|
|
|
self.top.get_object("corner1_y").get_value_as_int(),
|
|
|
|
self.top.get_object("corner2_x").get_value_as_int(),
|
|
|
|
self.top.get_object("corner2_y").get_value_as_int(),
|
2006-02-22 10:03:34 +05:30
|
|
|
)
|
2008-07-03 23:58:44 +05:30
|
|
|
|
2007-09-29 Benny Malengier <benny.malengier@gramps-project.org>
* src/GrampsDb/_GrampsDbBase.py: documentation string error
* src/Editors/_EditPerson.py: reload image if rectangle changes
* src/glade/gramps.glade: rename in Media editor referencer,
use region and corner as terms, add tooltip
* src/Editors/_EditMediaRef.py: rename to upper/lower to corner1/2,
provide upgrade path, default to (0,0,100,100) not (0,0,0,0)
svn: r9031
2007-09-29 05:56:26 +05:30
|
|
|
#do not set unset or invalid coord
|
2008-07-03 23:58:44 +05:30
|
|
|
|
|
|
|
if coord is not None and coord in (
|
2009-05-07 00:45:55 +05:30
|
|
|
(None,)*4,
|
2008-07-03 23:58:44 +05:30
|
|
|
(0, 0, 100, 100),
|
2009-05-07 00:45:55 +05:30
|
|
|
(coord[0], coord[1])*2
|
2008-06-16 20:31:46 +05:30
|
|
|
):
|
2006-02-22 10:03:34 +05:30
|
|
|
coord = None
|
2008-06-16 20:31:46 +05:30
|
|
|
|
2006-03-05 08:06:09 +05:30
|
|
|
self.source_ref.set_rectangle(coord)
|
2006-02-22 10:03:34 +05:30
|
|
|
|
2008-01-16 17:58:56 +05:30
|
|
|
#call callback if given
|
2006-03-05 08:06:09 +05:30
|
|
|
if self.update:
|
|
|
|
self.update(self.source_ref,self.source)
|
2008-01-16 17:58:56 +05:30
|
|
|
|
2006-04-24 04:13:36 +05:30
|
|
|
self.close()
|