From d5d067a01b9f0073fe4b5cf37a35d8e0934d2137 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Sat, 29 Sep 2007 00:26:26 +0000 Subject: [PATCH] 2007-09-29 Benny Malengier * 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 --- ChangeLog | 8 ++ src/Editors/_EditMediaRef.py | 157 +++++++++++++++---------- src/Editors/_EditPerson.py | 9 +- src/GrampsDb/_GrampsDbBase.py | 2 +- src/glade/gramps.glade | 210 +++++++++++++++++----------------- 5 files changed, 217 insertions(+), 169 deletions(-) diff --git a/ChangeLog b/ChangeLog index cb4648b52..cc4fabbbe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-09-29 Benny Malengier + * 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 * src/docgen/PdfDoc.py: Rewrite without gtk.PrintOperation dependency. diff --git a/src/Editors/_EditMediaRef.py b/src/Editors/_EditMediaRef.py index 4c9053b51..88ccd67c9 100644 --- a/src/Editors/_EditMediaRef.py +++ b/src/Editors/_EditMediaRef.py @@ -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) diff --git a/src/Editors/_EditPerson.py b/src/Editors/_EditPerson.py index e95c978a6..3148953a9 100644 --- a/src/Editors/_EditPerson.py +++ b/src/Editors/_EditPerson.py @@ -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()) diff --git a/src/GrampsDb/_GrampsDbBase.py b/src/GrampsDb/_GrampsDbBase.py index 77ad23072..1634ae24a 100644 --- a/src/GrampsDb/_GrampsDbBase.py +++ b/src/GrampsDb/_GrampsDbBase.py @@ -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') diff --git a/src/glade/gramps.glade b/src/glade/gramps.glade index 11112e870..7604fbd32 100644 --- a/src/glade/gramps.glade +++ b/src/glade/gramps.glade @@ -4619,7 +4619,7 @@ True - Lower X: + Corner 2: X False False GTK_JUSTIFY_LEFT @@ -4644,66 +4644,10 @@ - - - True - Upper X: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 1 - 2 - 2 - 3 - fill - - - - - - - True - Upper Y: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 3 - 4 - 2 - 3 - fill - - - - True - Lower Y: + Y False False GTK_JUSTIFY_LEFT @@ -4731,7 +4675,7 @@ True - <b>Subsection</b> + <b>Referenced Region</b> False True GTK_JUSTIFY_LEFT @@ -4757,50 +4701,9 @@ - - True - True - 1 - 0 - True - GTK_UPDATE_ALWAYS - False - False - 0 0 100 1 10 10 - - - 2 - 3 - 2 - 3 - - - - - - - True - True - 1 - 0 - True - GTK_UPDATE_ALWAYS - False - False - 0 0 100 1 10 10 - - - 4 - 5 - 2 - 3 - - - - - - + True + 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. True 1 0 @@ -4820,8 +4723,9 @@ - + True + 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. True 1 0 @@ -4930,6 +4834,106 @@ fill + + + + True + Corner 1: X + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 2 + 3 + fill + + + + + + + True + 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. + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 0 0 100 1 10 10 + + + 2 + 3 + 2 + 3 + + + + + + + True + 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. + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 0 0 100 1 10 10 + + + 4 + 5 + 2 + 3 + + + + + + + True + Y + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 3 + 4 + 2 + 3 + fill + + + False