Fixed a problem in _TOOLTIPS, and added 'Datestamp' label to show Original Date/ Time, which is still editable.

svn: r17509
This commit is contained in:
Rob G. Healey 2011-05-16 21:02:33 +00:00
parent 1f5aff0dcf
commit 152e95f082

View File

@ -144,24 +144,21 @@ _vtypes = [".jpeg", ".jpg", ".jfif", ".exv", ".tiff", ".dng", ".nef", ".pef", ".
# define tooltips for all entries # define tooltips for all entries
_TOOLTIPS = { _TOOLTIPS = {
# Description... "Description" : _("Provide a short descripion for this image."),
"Description" : _("Provide a short descripion for this image."),
# Artist "Artist" : _("Enter the Artist/ Author of this image. The person's name or "
"Artist" : _("Enter the Artist/ Author of this image. The person's name or "
"the company who is responsible for the creation of this image."), "the company who is responsible for the creation of this image."),
# Copyright "Copyright" : _("Enter the copyright information for this image. \n"),
"Copyright" : _("Enter the copyright information for this image. \n"
"Example: (C) 2010 Smith and Wesson"),
# GPS Latitude... "DateDisplay" : _("This date is the Original Date/ Time of the image.\n"
"Latitude" : _(u"Enter the GPS Latitude Coordinates for your image,\n" "The date and time it was taken/ or created."),
u"Example: 43.722965, 43 43 22 N, 38° 38 03″ N, 38 38 3"),
# GPS Longitude... "Latitude" : _("Enter the GPS Latitude Coordinates for this image,\n"
"Longitude" : _(u"Enter the GPS Longitude Coordinates for your image,\n" "Example: 43.722965, 43 43 22 N, 38° 38 03″ N, 38 38 3"),
u"Example: 10.396378, 10 23 46 E, 105° 6 6″ W, -105 6 6") }.items()
"Longitude" : _("Enter the GPS Longitude Coordinates for your image,\n"
"Example: 10.396378, 10 23 46 E, 105° 6 6″ W, -105 6 6") }.items()
# set up Exif keys for Image.exif_keys # set up Exif keys for Image.exif_keys
_DATAMAP = { _DATAMAP = {
@ -287,8 +284,8 @@ class EditExifMetadata(Gramplet):
label = gtk.Label() label = gtk.Label()
label.set_alignment(0.0, 0.0) label.set_alignment(0.0, 0.0)
label.set_line_wrap(True) label.set_line_wrap(True)
self.exif_widgets["Media:Label"] = label self.exif_widgets["MediaLabel"] = label
medialabel.pack_start(self.exif_widgets["Media:Label"], expand =False) medialabel.pack_start(self.exif_widgets["MediaLabel"], expand =False)
main_vbox.pack_start(medialabel, expand =False) main_vbox.pack_start(medialabel, expand =False)
# Displays mime type information... # Displays mime type information...
@ -296,8 +293,8 @@ class EditExifMetadata(Gramplet):
label = gtk.Label() label = gtk.Label()
label.set_alignment(0.0, 0.0) label.set_alignment(0.0, 0.0)
label.set_line_wrap(True) label.set_line_wrap(True)
self.exif_widgets["Mime:Type"] = label self.exif_widgets["MimeType"] = label
mimetype.pack_start(self.exif_widgets["Mime:Type"], expand =False) mimetype.pack_start(self.exif_widgets["MimeType"], expand =False)
main_vbox.pack_start(mimetype, expand =False) main_vbox.pack_start(mimetype, expand =False)
# Displays all plugin messages... # Displays all plugin messages...
@ -305,8 +302,8 @@ class EditExifMetadata(Gramplet):
label = gtk.Label() label = gtk.Label()
label.set_alignment(0.5, 0.0) label.set_alignment(0.5, 0.0)
label.set_line_wrap(True) label.set_line_wrap(True)
self.exif_widgets["Message:Area"] = label self.exif_widgets["MessageArea"] = label
messagearea.pack_start(self.exif_widgets["Message:Area"], expand =False) messagearea.pack_start(self.exif_widgets["MessageArea"], expand =False)
main_vbox.pack_start(messagearea, expand =False) main_vbox.pack_start(messagearea, expand =False)
# Clear, Thumbnail View, Convert horizontal box # Clear, Thumbnail View, Convert horizontal box
@ -444,6 +441,9 @@ class EditExifMetadata(Gramplet):
# GPS Latitude/ Longitude Coordinates... # GPS Latitude/ Longitude Coordinates...
for items in [ for items in [
# Original Date Displayed...
("DateDisplay", _("Datestamp"), None, True, [], True, 0),
# GPS Latitude Reference and Latitude... # GPS Latitude Reference and Latitude...
("Latitude", _("Latitude"), None, False, [], True, 0), ("Latitude", _("Latitude"), None, False, [], True, 0),
@ -584,7 +584,7 @@ class EditExifMetadata(Gramplet):
self.activate_buttons(["Save"]) self.activate_buttons(["Save"])
# set Message Area to Entering Data... # set Message Area to Entering Data...
self.exif_widgets["Message:Area"].set_text(_("Entering data...")) self.exif_widgets["MessageArea"].set_text(_("Entering data..."))
if not self.exif_widgets["Clear"].get_sensitive(): if not self.exif_widgets["Clear"].get_sensitive():
self.activate_buttons(["Clear"]) self.activate_buttons(["Clear"])
@ -610,30 +610,30 @@ class EditExifMetadata(Gramplet):
self.orig_image = db.get_object_from_handle(active_handle) self.orig_image = db.get_object_from_handle(active_handle)
self.image_path = Utils.media_path_full(db, self.orig_image.get_path() ) self.image_path = Utils.media_path_full(db, self.orig_image.get_path() )
if (not self.orig_image or not os.path.isfile(self.image_path)): if (not self.orig_image or not os.path.isfile(self.image_path)):
self.exif_widgets["Message:Area"].set_text(_("Image is either missing or deleted,\n" self.exif_widgets["MessageArea"].set_text(_("Image is either missing or deleted,\n"
"Please choose a different image...")) "Please choose a different image..."))
return return
# check image read privileges... # check image read privileges...
_readable = os.access(self.image_path, os.R_OK) _readable = os.access(self.image_path, os.R_OK)
if not _readable: if not _readable:
self.exif_widgets["Message:Area"].set_text(_("Image is NOT readable,\n" self.exif_widgets["MessageArea"].set_text(_("Image is NOT readable,\n"
"Please choose a different image...")) "Please choose a different image..."))
return return
# check image write privileges... # check image write privileges...
_writable = os.access(self.image_path, os.W_OK) _writable = os.access(self.image_path, os.W_OK)
if not _writable: if not _writable:
self.exif_widgets["Message:Area"].set_text(_("Image is NOT writable,\n" self.exif_widgets["MessageArea"].set_text(_("Image is NOT writable,\n"
"You will NOT be able to save Exif metadata....")) "You will NOT be able to save Exif metadata...."))
# display file description/ title... # display file description/ title...
self.exif_widgets["Media:Label"].set_text(_html_escape( self.exif_widgets["MediaLabel"].set_text(_html_escape(
self.orig_image.get_description() ) ) self.orig_image.get_description() ) )
# Mime type information... # Mime type information...
mime_type = self.orig_image.get_mime_type() mime_type = self.orig_image.get_mime_type()
self.exif_widgets["Mime:Type"].set_text(mime_type) self.exif_widgets["MimeType"].set_text(mime_type)
# disable all data fields and buttons if NOT an exiv2 image type? # disable all data fields and buttons if NOT an exiv2 image type?
basename, self.extension = os.path.splitext(self.image_path) basename, self.extension = os.path.splitext(self.image_path)
@ -661,10 +661,10 @@ class EditExifMetadata(Gramplet):
self.EditArea(self.orig_image) self.EditArea(self.orig_image)
else: else:
self.exif_widgets["Message:Area"].set_text(_("Please choose a different image...")) self.exif_widgets["MessageArea"].set_text(_("Please choose a different image..."))
return return
else: else:
self.exif_widgets["Message:Area"].set_text(_("Please choose a different image...")) self.exif_widgets["MessageArea"].set_text(_("Please choose a different image..."))
return return
def __convert_dialog(self, obj): def __convert_dialog(self, obj):
@ -823,13 +823,13 @@ class EditExifMetadata(Gramplet):
# clear all data fields # clear all data fields
if cleartype == "All": if cleartype == "All":
for widgetsName in ["Description", "Artist", "Copyright", for widgetsName in ["MediaLabel", "MimeType", "MessageArea", "DateDisplay",
"Latitude", "Longitude", "Media:Label", "Mime:Type", "Message:Area"]: "Description", "Artist", "Copyright", "Latitude", "Longitude"]:
self.exif_widgets[widgetsName].set_text("") self.exif_widgets[widgetsName].set_text("")
# clear only the date/ time field # clear only the date/ time field
else: else:
self.exif_widgets["Message:Area"].set_text("") self.exif_widgets["MessageArea"].set_text("")
# De-activate the buttons except for Help... # De-activate the buttons except for Help...
self.deactivate_buttons(["Clear", "ThumbnailView", "Save", "Advanced"]) self.deactivate_buttons(["Clear", "ThumbnailView", "Save", "Advanced"])
@ -841,7 +841,7 @@ class EditExifMetadata(Gramplet):
self.deactivate_buttons(["Delete"]) self.deactivate_buttons(["Delete"])
# set Message Area to Select... # set Message Area to Select...
self.exif_widgets["Message:Area"].set_text(_("Select an image to begin...")) self.exif_widgets["MessageArea"].set_text(_("Select an image to begin..."))
def EditArea(self, obj): def EditArea(self, obj):
""" """
@ -867,7 +867,7 @@ class EditExifMetadata(Gramplet):
imageKeyTags = [KeyTag for KeyTag in MediaDataTags if KeyTag in _DATAMAP] imageKeyTags = [KeyTag for KeyTag in MediaDataTags if KeyTag in _DATAMAP]
# set Message Area to Copying... # set Message Area to Copying...
self.exif_widgets["Message:Area"].set_text(_("Copying Exif metadata to the Edit Area...")) self.exif_widgets["MessageArea"].set_text(_("Copying Exif metadata to the Edit Area..."))
for KeyTag in imageKeyTags: for KeyTag in imageKeyTags:
@ -885,7 +885,7 @@ class EditExifMetadata(Gramplet):
use_date = self._get_value(_DATAMAP["Modified"]) use_date = self._get_value(_DATAMAP["Modified"])
use_date = _process_datetime(use_date) if use_date else False use_date = _process_datetime(use_date) if use_date else False
if use_date: if use_date:
self.exif_widgets["Message:Area"].set_text( self.exif_widgets["MessageArea"].set_text(
_("Last Changed: %s") % use_date) _("Last Changed: %s") % use_date)
# Original Creation Date/ Time... # Original Creation Date/ Time...
@ -916,6 +916,17 @@ class EditExifMetadata(Gramplet):
# set the date/ time spin buttons... # set the date/ time spin buttons...
self.exif_widgets[widget].set_value(value) self.exif_widgets[widget].set_value(value)
use_date = False
if year < 1900:
use_date = "%04d-%s-%02d %02d:%02d:%02d" % (
year, _dd.long_months[month], day, hour, mins, secs)
else:
use_date = datetime(year, month, day, hour, mins, secs)
if use_date:
if isinstance(use_date, datetime):
use_date = _format_datetime(use_date)
self.exif_widgets["DateDisplay"].set_text(use_date)
# LatitudeRef, Latitude, LongitudeRef, Longitude... # LatitudeRef, Latitude, LongitudeRef, Longitude...
elif widgetsName == "Latitude": elif widgetsName == "Latitude":
@ -953,7 +964,7 @@ class EditExifMetadata(Gramplet):
else: else:
# set Message Area to None... # set Message Area to None...
self.exif_widgets["Message:Area"].set_text(_("There is NO Exif metadata for this image yet...")) self.exif_widgets["MessageArea"].set_text(_("There is NO Exif metadata for this image yet..."))
for widget, tooltip in _TOOLTIPS: for widget, tooltip in _TOOLTIPS:
if widget is not "Modified": if widget is not "Modified":
@ -973,7 +984,7 @@ class EditExifMetadata(Gramplet):
delete_result = str(delete) delete_result = str(delete)
if delete_result: if delete_result:
self.exif_widgets["Message:Area"].set_text(_("Image has been converted to a .jpg image,\n" self.exif_widgets["MessageArea"].set_text(_("Image has been converted to a .jpg image,\n"
"and original image has been deleted!")) "and original image has been deleted!"))
def convert2Jpeg(self): def convert2Jpeg(self):
@ -990,7 +1001,7 @@ class EditExifMetadata(Gramplet):
if str(convert): if str(convert):
# set Message Area to Convert... # set Message Area to Convert...
self.exif_widgets["Message:Area"].set_text(_("Converting image,\n" self.exif_widgets["MessageArea"].set_text(_("Converting image,\n"
"You will need to delete the original image file...")) "You will need to delete the original image file..."))
self.deactivate_buttons(["Convert"]) self.deactivate_buttons(["Convert"])
@ -1249,15 +1260,15 @@ class EditExifMetadata(Gramplet):
len(self.exif_widgets["Longitude"].get_text() ) ) len(self.exif_widgets["Longitude"].get_text() ) )
# Description data field... # Description data field...
description = self.exif_widgets["Description"].get_text() or "" description = self.exif_widgets["Description"].get_text()
self._set_value(_DATAMAP["Description"], description) self._set_value(_DATAMAP["Description"], description)
# Modify Date/ Time... not a data field, but saved anyway... # Modify Date/ Time... not a data field, but saved anyway...
modified = datetime.today() modified = datetime.now()
self._set_value(_DATAMAP["Modified"], modified) self._set_value(_DATAMAP["Modified"], modified)
# display modified Date/ Time... # display modified Date/ Time...
self.exif_widgets["Message:Area"].set_text(_("Last Changed: %s") % _format_datetime(modified) ) self.exif_widgets["MessageArea"].set_text(_("Last Changed: %s") % _format_datetime(modified) )
# Artist/ Author data field... # Artist/ Author data field...
artist = self.exif_widgets["Artist"].get_text() artist = self.exif_widgets["Artist"].get_text()
@ -1268,12 +1279,12 @@ class EditExifMetadata(Gramplet):
self._set_value(_DATAMAP["Copyright"], copyright) self._set_value(_DATAMAP["Copyright"], copyright)
# Original Date/ Time # Original Date/ Time
year = self.exif_widgets["Year"].get_value_as_int() year = _get_spin_value("Year", self.exif_widgets)
month = self.exif_widgets["Month"].get_value_as_int() month = _get_spin_value("Month", self.exif_widgets)
day = self.exif_widgets["Day"].get_value_as_int() day = _get_spin_value("Day", self.exif_widgets)
hour = self.exif_widgets["Hour"].get_value_as_int() hour = _get_spin_value("Hour", self.exif_widgets)
minutes = self.exif_widgets["Minutes"].get_value_as_int() minutes = _get_spin_value("Minutes", self.exif_widgets)
seconds = self.exif_widgets["Seconds"].get_value_as_int() seconds = _get_spin_value("Seconds", self.exif_widgets)
use_date = False use_date = False
if year < 1900: if year < 1900:
@ -1284,6 +1295,11 @@ class EditExifMetadata(Gramplet):
if use_date: if use_date:
self._set_value(_DATAMAP["Original"], use_date) self._set_value(_DATAMAP["Original"], use_date)
# display it also...
if isinstance(use_date, datetime):
use_date = _format_datetime(use_date)
self.exif_widgets["DateDisplay"].set_text(use_date)
# Latitude/ Longitude data fields # Latitude/ Longitude data fields
latitude = self.exif_widgets["Latitude"].get_text() latitude = self.exif_widgets["Latitude"].get_text()
longitude = self.exif_widgets["Longitude"].get_text() longitude = self.exif_widgets["Longitude"].get_text()
@ -1345,10 +1361,10 @@ class EditExifMetadata(Gramplet):
if datatags: if datatags:
# set Message Area to Saved... # set Message Area to Saved...
self.exif_widgets["Message:Area"].set_text(_("Saving Exif metadata to this image...")) self.exif_widgets["MessageArea"].set_text(_("Saving Exif metadata to this image..."))
else: else:
# set Message Area to Cleared... # set Message Area to Cleared...
self.exif_widgets["Message:Area"].set_text(_("Image Exif metadata has been cleared " self.exif_widgets["MessageArea"].set_text(_("Image Exif metadata has been cleared "
"from this image...")) "from this image..."))
# writes all Exif Metadata to image even if the fields are all empty... # writes all Exif Metadata to image even if the fields are all empty...
@ -1383,13 +1399,13 @@ class EditExifMetadata(Gramplet):
if erase_results: if erase_results:
# set Message Area for deleting... # set Message Area for deleting...
self.exif_widgets["Message:Area"].set_text(_("Deleting all Exif metadata...")) self.exif_widgets["MessageArea"].set_text(_("Deleting all Exif metadata..."))
# Clear the Edit Areas # Clear the Edit Areas
self.clear_metadata(self.plugin_image) self.clear_metadata(self.plugin_image)
# set Message Area to Delete... # set Message Area to Delete...
self.exif_widgets["Message:Area"].set_text(_("All Exif metadata has been " self.exif_widgets["MessageArea"].set_text(_("All Exif metadata has been "
"deleted from this image...")) "deleted from this image..."))
self.update() self.update()
@ -1470,17 +1486,26 @@ def _setup_datafields_buttons(extension, exif_widgets):
* if file extension is NOT an exiv2 image type? * if file extension is NOT an exiv2 image type?
""" """
goodextension = True if extension in _vtypes else False # _vtypes is a list of valid exiv2 image types...
goodextension = (extension in _vtypes)
# Modified and DateDisplay are gtk.Label(), which does NOT have ability to set editable or not...
for widget, tooltip in _TOOLTIPS: for widget, tooltip in _TOOLTIPS:
if widget is not "Modified": if not widget in ["Modified", "DateDisplay"]:
exif_widgets[widget].set_visibility(goodextension)
exif_widgets[widget].set_editable(goodextension) exif_widgets[widget].set_editable(goodextension)
# Do NOT disable the Help button...
for widget, tooltip in _BUTTONTIPS.items(): for widget, tooltip in _BUTTONTIPS.items():
if (widget not in ["Help", "Clear"] and not goodextension): if (widget is not "Help" and not goodextension):
exif_widgets[widget].set_sensitive(False) exif_widgets[widget].set_sensitive(False)
def _get_spin_value(pos, exif_widgets):
"""
will retrieve the spinner's value and format it as two digit integer...
"""
return exif_widgets[pos].get_value_as_int()
def _setup_widget_tips(exif_widgets): def _setup_widget_tips(exif_widgets):
""" """
set up widget tooltips... set up widget tooltips...