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
This commit is contained in:
Benny Malengier 2007-09-29 00:26:26 +00:00
parent cc63610f0d
commit d5d067a01b
5 changed files with 217 additions and 169 deletions

View File

@ -1,3 +1,11 @@
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)
2007-09-28 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
* src/docgen/PdfDoc.py: Rewrite without gtk.PrintOperation dependency.

View File

@ -87,6 +87,14 @@ class EditMediaRef(EditReference):
self.pixmap.set_from_pixbuf(self.pix)
coord = self.source_ref.get_rectangle()
#upgrade path: set invalid (from eg old db) to none
if (coord[0] == None and coord[1] == None
and coord[2] == None and coord[3] == None) or (
coord[0] == 0 and coord[1] == 0
and coord[2] == 100 and coord[3] == 100) or (
coord[0] == coord[2] and coord[1] == coord[3]
):
coord = None
self.rectangle = coord
@ -97,38 +105,44 @@ class EditMediaRef(EditReference):
self.subpixmap.set_from_pixbuf(self.subpix)
if coord and type(coord) == tuple:
self.top.get_widget("upperx").set_value(coord[0])
self.top.get_widget("uppery").set_value(coord[1])
self.top.get_widget("lowerx").set_value(coord[2])
self.top.get_widget("lowery").set_value(coord[3])
self.top.get_widget("corner1_x").set_value(coord[0])
self.top.get_widget("corner1_y").set_value(coord[1])
self.top.get_widget("corner2_x").set_value(coord[2])
self.top.get_widget("corner2_y").set_value(coord[3])
else:
self.top.get_widget("corner1_x").set_value(0)
self.top.get_widget("corner1_y").set_value(0)
self.top.get_widget("corner2_x").set_value(100)
self.top.get_widget("corner2_y").set_value(100)
if self.dbstate.db.readonly:
self.top.get_widget("upperx").set_sensitive(False)
self.top.get_widget("uppery").set_sensitive(False)
self.top.get_widget("lowerx").set_sensitive(False)
self.top.get_widget("lowery").set_sensitive(False)
self.top.get_widget("corner1_x").set_sensitive(False)
self.top.get_widget("corner1_y").set_sensitive(False)
self.top.get_widget("corner2_x").set_sensitive(False)
self.top.get_widget("corner2_y").set_sensitive(False)
self.upperx_spinbutton = MonitoredSpinButton(
self.top.get_widget("upperx"),
self.set_upperx,
self.get_upperx,
self.corner1_x_spinbutton = MonitoredSpinButton(
self.top.get_widget("corner1_x"),
self.set_corner1_x,
self.get_corner1_x,
self.db.readonly)
self.uppery_spinbutton = MonitoredSpinButton(
self.top.get_widget("uppery"),
self.set_uppery,
self.get_uppery,
self.corner1_y_spinbutton = MonitoredSpinButton(
self.top.get_widget("corner1_y"),
self.set_corner1_y,
self.get_corner1_y,
self.db.readonly)
self.lowerx_spinbutton = MonitoredSpinButton(
self.top.get_widget("lowerx"),
self.set_lowerx,
self.get_lowerx,
self.corner2_x_spinbutton = MonitoredSpinButton(
self.top.get_widget("corner2_x"),
self.set_corner2_x,
self.get_corner2_x,
self.db.readonly)
self.lowery_spinbutton = MonitoredSpinButton(
self.top.get_widget("lowery"),
self.set_lowery,
self.get_lowery,
self.corner2_y_spinbutton = MonitoredSpinButton(
self.top.get_widget("corner2_y"),
self.set_corner2_y,
self.get_corner2_y,
self.db.readonly)
self.descr_window = MonitoredEntry(
@ -165,75 +179,81 @@ class EditMediaRef(EditReference):
else:
self.top.get_widget("type").set_text("")
def set_upperx(self, value):
def set_corner1_x(self, value):
"""
Callback for the signal handling of the spinbutton for the left x coordinate of the subsection.
Updates the subsection thumbnail using the given value for the left x coordinate.
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
@param value: the left x coordinate of the subsection
@param value: the first corner x coordinate of the subsection in int
"""
if self.rectangle == None:
self.rectangle = (0,0,0,0)
self.rectangle = (0,0,100,100)
self.rectangle = (value,
self.rectangle[1],
self.rectangle[2],
self.rectangle[3])
self.update_subpixmap()
def set_uppery(self, value):
def set_corner1_y(self, value):
"""
Callback for the signal handling of the spinbutton for the upper y coordinate of the subsection.
Updates the subsection thumbnail using the given value for the upper y coordinate.
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
@param value: the upper y coordinate of the subsection
@param value: the first corner y coordinate of the subsection in int
"""
if self.rectangle == None:
self.rectangle = (0,0,0,0)
self.rectangle = (0,0,100,100)
self.rectangle = (self.rectangle[0],
value,
self.rectangle[2],
self.rectangle[3])
self.update_subpixmap()
def set_lowerx(self, value):
def set_corner2_x(self, value):
"""
Callback for the signal handling of the spinbutton for the right x coordinate of the subsection.
Updates the subsection thumbnail using the given value for the right x coordinate.
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
@param value: the right x coordinate of the subsection
@param value: the second corner x coordinate of the subsection in int
"""
if self.rectangle == None:
self.rectangle = (0,0,0,0)
self.rectangle = (0,0,100,100)
self.rectangle = (self.rectangle[0],
self.rectangle[1],
value,
self.rectangle[3])
self.update_subpixmap()
def set_lowery(self, value):
def set_corner2_y(self, value):
"""
Callback for the signal handling of the spinbutton for the lower y coordinate of the subsection.
Updates the subsection thumbnail using the given value for the lower y coordinate.
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
@param value: the lower y coordinate of the subsection
@param value: the second corner y coordinate of the subsection in int
"""
if self.rectangle == None:
self.rectangle = (0,0,0,0)
self.rectangle = (0,0,100,100)
self.rectangle = (self.rectangle[0],
self.rectangle[1],
self.rectangle[2],
value)
self.update_subpixmap()
def get_upperx(self):
def get_corner1_x(self):
"""
Callback for the signal handling of the spinbutton for the left x coordinate of the subsection.
Callback for the signal handling of the spinbutton for the first corner
x coordinate of the subsection.
@returns: the left x coordinate of the subsection or 0 if there is no selection
@returns: the first corner x coordinate of the subsection or 0 if
there is no selection
"""
if self.rectangle != None:
@ -241,11 +261,13 @@ class EditMediaRef(EditReference):
else:
return 0
def get_uppery(self):
def get_corner1_y(self):
"""
Callback for the signal handling of the spinbutton for the uppper y coordinate of the subsection.
Callback for the signal handling of the spinbutton for the first corner
y coordinate of the subsection.
@returns: the upper y coordinate of the subsection or 0 if there is no selection
@returns: the first corner y coordinate of the subsection or 0 if
there is no selection
"""
if self.rectangle != None:
@ -253,29 +275,33 @@ class EditMediaRef(EditReference):
else:
return 0
def get_lowerx(self):
def get_corner2_x(self):
"""
Callback for the signal handling of the spinbutton for the right x coordinate of the subsection.
Callback for the signal handling of the spinbutton for the second
corner x coordinate of the subsection.
@returns: the right x coordinate of the subsection or 0 if there is no selection
@returns: the second corner x coordinate of the subsection or 100 if
there is no selection
"""
if self.rectangle != None:
return self.rectangle[2]
else:
return 0
return 100
def get_lowery(self):
def get_corner2_y(self):
"""
Callback for the signal handling of the spinbutton for the lower y coordinate of the subsection.
Callback for the signal handling of the spinbutton for the second
corner x coordinate of the subsection.
@returns: the lower y coordinate of the subsection or 0 if there is no selection
@returns: the second corner x coordinate of the subsection or 100 if
there is no selection
"""
if self.rectangle != None:
return self.rectangle[3]
else:
return 0
return 100
def update_subpixmap(self):
"""
@ -392,14 +418,19 @@ class EditMediaRef(EditReference):
def save(self,*obj):
coord = (
self.top.get_widget("upperx").get_value_as_int(),
self.top.get_widget("uppery").get_value_as_int(),
self.top.get_widget("lowerx").get_value_as_int(),
self.top.get_widget("lowery").get_value_as_int(),
self.top.get_widget("corner1_x").get_value_as_int(),
self.top.get_widget("corner1_y").get_value_as_int(),
self.top.get_widget("corner2_x").get_value_as_int(),
self.top.get_widget("corner2_y").get_value_as_int(),
)
#do not set unset or invalid coord
if (coord[0] == None and coord[1] == None
and coord[2] == None and coord[3] == None):
and coord[2] == None and coord[3] == None) or (
coord[0] == 0 and coord[1] == 0
and coord[2] == 100 and coord[3] == 100) or (
coord[0] == coord[2] and coord[1] == coord[3]
):
coord = None
self.source_ref.set_rectangle(coord)

View File

@ -123,6 +123,7 @@ class EditPerson(EditPrimary):
RelLib.Person.UNKNOWN)
self.load_obj = None
self.load_rect = None
self.top = gtk.glade.XML(const.PERSON_GLADE, "edit_person", "gramps")
self.set_window(self.top.get_widget("edit_person"), None, self.get_menu_title())
@ -387,7 +388,7 @@ class EditPerson(EditPrimary):
def _image_callback(self, ref, obj):
"""
Called when a media reference had been edited. This allows fot
Called when a media reference had been edited. This allows for
the updating image on the main form which has just been modified.
"""
self.load_photo(obj.get_path(), ref.get_rectangle())
@ -528,6 +529,7 @@ class EditPerson(EditPrimary):
def load_photo(self, path, rectangle=None):
"""loads, scales, and displays the person's main photo from the path"""
self.load_obj = path
self.load_rect = rectangle
if path == None:
self.obj_photo.hide()
else:
@ -702,13 +704,16 @@ class EditPerson(EditPrimary):
def load_person_image(self):
"""
Loads the primary image into the main form if it exists.
Used as callback on Gallery Tab too.
"""
media_list = self.obj.get_media_list()
if media_list:
photo = media_list[0]
object_handle = photo.get_reference_handle()
obj = self.db.get_object_from_handle(object_handle)
if self.load_obj != obj.get_path():
#reload if different media, or different rectangle
if self.load_obj != obj.get_path() or \
self.load_rect != photo.get_rectangle():
mime_type = obj.get_mime_type()
if mime_type and mime_type.startswith("image"):
self.load_photo(obj.get_path(), photo.get_rectangle())

View File

@ -408,7 +408,7 @@ class GrampsDbBase(GrampsDBCallback):
def request_rebuild(self):
"""
Notifies clients that the data has change significantly, and that all
Notifies clients that the data has changed significantly, and that all
internal data dependent on the database should be rebuilt.
"""
self.emit('person-rebuild')

View File

@ -4619,7 +4619,7 @@
<child>
<widget class="GtkLabel" id="label425">
<property name="visible">True</property>
<property name="label" translatable="yes">Lower X:</property>
<property name="label" translatable="yes">Corner 2: X</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@ -4644,66 +4644,10 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="label426">
<property name="visible">True</property>
<property name="label" translatable="yes">Upper X:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label427">
<property name="visible">True</property>
<property name="label" translatable="yes">Upper Y:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label428">
<property name="visible">True</property>
<property name="label" translatable="yes">Lower Y:</property>
<property name="label" translatable="yes">Y</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@ -4731,7 +4675,7 @@
<child>
<widget class="GtkLabel" id="label430">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Subsection&lt;/b&gt;</property>
<property name="label" translatable="yes">&lt;b&gt;Referenced Region&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@ -4757,50 +4701,9 @@
</child>
<child>
<widget class="GtkSpinButton" id="upperx">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="climb_rate">1</property>
<property name="digits">0</property>
<property name="numeric">True</property>
<property name="update_policy">GTK_UPDATE_ALWAYS</property>
<property name="snap_to_ticks">False</property>
<property name="wrap">False</property>
<property name="adjustment">0 0 100 1 10 10</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="uppery">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="climb_rate">1</property>
<property name="digits">0</property>
<property name="numeric">True</property>
<property name="update_policy">GTK_UPDATE_ALWAYS</property>
<property name="snap_to_ticks">False</property>
<property name="wrap">False</property>
<property name="adjustment">0 0 100 1 10 10</property>
</widget>
<packing>
<property name="left_attach">4</property>
<property name="right_attach">5</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="lowery">
<widget class="GtkSpinButton" id="corner2_y">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">If media is an image, select a region of the image that is referenced. Point (0,0) is the top left corner. Do this by giving two corners on a diagonal of the rectangular region you want to use.</property>
<property name="can_focus">True</property>
<property name="climb_rate">1</property>
<property name="digits">0</property>
@ -4820,8 +4723,9 @@
</child>
<child>
<widget class="GtkSpinButton" id="lowerx">
<widget class="GtkSpinButton" id="corner2_x">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">If media is an image, select a region of the image that is referenced. Point (0,0) is the top left corner. Do this by giving two corners on a diagonal of the rectangular region you want to use.</property>
<property name="can_focus">True</property>
<property name="climb_rate">1</property>
<property name="digits">0</property>
@ -4930,6 +4834,106 @@
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label426">
<property name="visible">True</property>
<property name="label" translatable="yes">Corner 1: X</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="corner1_x">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">If media is an image, select a region of the image that is referenced. Point (0,0) is the top left corner. Do this by giving two corners on a diagonal of the rectangular region you want to use.</property>
<property name="can_focus">True</property>
<property name="climb_rate">1</property>
<property name="digits">0</property>
<property name="numeric">True</property>
<property name="update_policy">GTK_UPDATE_ALWAYS</property>
<property name="snap_to_ticks">False</property>
<property name="wrap">False</property>
<property name="adjustment">0 0 100 1 10 10</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="corner1_y">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">If media is an image, select a region of the image that is referenced. Point (0,0) is the top left corner. Do this by giving two corners on a diagonal of the rectangular region you want to use.</property>
<property name="can_focus">True</property>
<property name="climb_rate">1</property>
<property name="digits">0</property>
<property name="numeric">True</property>
<property name="update_policy">GTK_UPDATE_ALWAYS</property>
<property name="snap_to_ticks">False</property>
<property name="wrap">False</property>
<property name="adjustment">0 0 100 1 10 10</property>
</widget>
<packing>
<property name="left_attach">4</property>
<property name="right_attach">5</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label427">
<property name="visible">True</property>
<property name="label" translatable="yes">Y</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>