Moved tag_label to before func in TAGS_. Modified column lengths to attempt to better view the displaying area.

svn: r17910
This commit is contained in:
Rob G. Healey 2011-07-09 19:07:52 +00:00
parent b09102b184
commit 9ff5fd9039

View File

@ -179,8 +179,8 @@ TAGS_ = [
(DESCRIPTION, 'Exif.Image.ImageDescription', None, None, None), (DESCRIPTION, 'Exif.Image.ImageDescription', None, None, None),
(DESCRIPTION, 'Exif.Image.Artist', None, None, None), (DESCRIPTION, 'Exif.Image.Artist', None, None, None),
(DESCRIPTION, 'Exif.Image.Copyright', None, None, None), (DESCRIPTION, 'Exif.Image.Copyright', None, None, None),
(DESCRIPTION, 'Exif.Photo.DateTimeOriginal', None, _format_datetime, None), (DESCRIPTION, 'Exif.Photo.DateTimeOriginal', None, None, _format_datetime),
(DESCRIPTION, 'Exif.Image.DateTime', None, _format_datetime, None), (DESCRIPTION, 'Exif.Image.DateTime', None, None, _format_datetime),
(DESCRIPTION, 'Exif.Image.Rating', None, None, None), (DESCRIPTION, 'Exif.Image.Rating', None, None, None),
# Origin subclass... # Origin subclass...
@ -208,36 +208,37 @@ TAGS_ = [
(CAMERA, 'Exif.Photo.MeteringMode', None, None, None), (CAMERA, 'Exif.Photo.MeteringMode', None, None, None),
(CAMERA, 'Exif.Photo.Flash', None, None, None), (CAMERA, 'Exif.Photo.Flash', None, None, None),
(CAMERA, 'Exif.Image.SelfTimerMode', None, None, None), (CAMERA, 'Exif.Image.SelfTimerMode', None, None, None),
(CAMERA, 'Exif.Image.CameraSerialNumber', None, None, None),
# GPS subclass... # GPS subclass...
(GPS, 'Exif.GPSInfo.GPSLatitude', (GPS, 'Exif.GPSInfo.GPSLatitude',
'Exif.GPSInfo.GPSLatitudeRef', _format_gps, None), 'Exif.GPSInfo.GPSLatitudeRef', None, _format_gps),
(GPS, 'Exif.GPSInfo.GPSLongitude', (GPS, 'Exif.GPSInfo.GPSLongitude',
'Exif.GPSInfo.GPSLongitudeRef', _format_gps, None), 'Exif.GPSInfo.GPSLongitudeRef', None, _format_gps),
(GPS, 'Exif.GPSInfo.GPSAltitude', (GPS, 'Exif.GPSInfo.GPSAltitude',
'Exif.GPSInfo.GPSAltitudeRef', None, None), 'Exif.GPSInfo.GPSAltitudeRef', None, None),
(GPS, 'Exif.Image.GPSTag', None, None, None), (GPS, 'Exif.Image.GPSTag', None, None, None),
(GPS, 'Exif.GPSInfo.GPSTimeStamp', None, _format_time, None),
(GPS, 'Exif.GPSInfo.GPSTimeStamp', None, None, _format_time),
(GPS, 'Exif.GPSInfo.GPSSatellites', None, None, None), (GPS, 'Exif.GPSInfo.GPSSatellites', None, None, None),
# Advanced subclass... # Advanced subclass...
(ADVANCED, 'Xmp.MicrosoftPhoto.LensManufacturer', None, None, _("Lens Manufacturer")), (ADVANCED, 'Exif.Photo.Contrast', None, _("Contrast"), None),
(ADVANCED, 'Xmp.MicrosoftPhoto.LensModel', None, None, _("Lens Model")), (ADVANCED, 'Exif.Photo.LightSource', None, _("Light Source"), None),
(ADVANCED, 'Xmp.MicrosoftPhoto.FlashManufacturer', None, None, _("Flash Manufacturer")), (ADVANCED, 'Exif.Photo.ExposureProgram', None, _("Exposure Program"), None),
(ADVANCED, 'Xmp.MicrosoftPhoto.FlashModel', None, None, _("Flash Model")), (ADVANCED, 'Exif.Photo.Saturation', None, _("Saturation"), None),
(ADVANCED, 'Exif.Image.CameraSerialNumber', None, None, None), (ADVANCED, 'Exif.Photo.Sharpness', None, _("Sharpness"), None),
(ADVANCED, 'Exif.Photo.Contrast', None, None, _("Contrast")), (ADVANCED, 'Exif.Photo.WhiteBalance', None, _("White Balance"), None),
(ADVANCED, 'Exif.Photo.LightSource', None, None, _("Light Source")),
(ADVANCED, 'Exif.Photo.ExposureProgram', None, None, _("Exposure Program")),
(ADVANCED, 'Exif.Photo.Saturation', None, None, _("Saturation")),
(ADVANCED, 'Exif.Photo.Sharpness', None, None, _("Sharpness")),
(ADVANCED, 'Exif.Photo.WhiteBalance', None, None, _("White Balance")),
(ADVANCED, 'Exif.Image.ExifTag', None, None, None), (ADVANCED, 'Exif.Image.ExifTag', None, None, None),
(ADVANCED, 'Exif.Image.BatteryLevel', None, None, None), (ADVANCED, 'Exif.Image.BatteryLevel', None, None, None),
(ADVANCED, 'Exif.Image.XPKeywords', None, None, None), (ADVANCED, 'Exif.Image.XPKeywords', None, None, None),
(ADVANCED, 'Exif.Image.XPComment', None, None, None), (ADVANCED, 'Exif.Image.XPComment', None, None, None),
(ADVANCED, 'Exif.Image.XPSubject', None, None, None), (ADVANCED, 'Exif.Image.XPSubject', None, None, None),
(ADVANCED, 'Exif.Photo.DateTimeDigitized', None, _format_datetime, None) (ADVANCED, 'Exif.Photo.DateTimeDigitized', None, None, _format_datetime)
] ]
# set up Exif keys for Image Exif metadata keypairs... # set up Exif keys for Image Exif metadata keypairs...
@ -245,6 +246,7 @@ _DATAMAP = {
"Exif.Image.ImageDescription" : "Description", "Exif.Image.ImageDescription" : "Description",
"Exif.Photo.DateTimeOriginal" : "Original", "Exif.Photo.DateTimeOriginal" : "Original",
"Exif.Image.DateTime" : "Modified", "Exif.Image.DateTime" : "Modified",
"Exif.Photo.DateTimeDigitized" : "Digitized",
"Exif.Image.Artist" : "Artist", "Exif.Image.Artist" : "Artist",
"Exif.Image.Copyright" : "Copyright", "Exif.Image.Copyright" : "Copyright",
"Exif.GPSInfo.GPSLatitudeRef" : "LatitudeRef", "Exif.GPSInfo.GPSLatitudeRef" : "LatitudeRef",
@ -343,12 +345,13 @@ class EditExifMetadata(Gramplet):
self.plugin_image = False self.plugin_image = False
vbox = self.__build_gui() vbox = self.__build_gui()
self.connect_signal("Media", self.update)
self.connect_signal("media-update", self.update)
self.gui.get_container_widget().remove(self.gui.textview) self.gui.get_container_widget().remove(self.gui.textview)
self.gui.get_container_widget().add_with_viewport(vbox) self.gui.get_container_widget().add_with_viewport(vbox)
self.dbstate.db.connect('media-update', self.update)
self.connect_signal('Media', self.update)
self.update()
def __build_gui(self): def __build_gui(self):
""" """
will display all exif metadata and all buttons. will display all exif metadata and all buttons.
@ -358,35 +361,35 @@ class EditExifMetadata(Gramplet):
main_vbox.set_border_width(10) main_vbox.set_border_width(10)
# Displays the file name... # Displays the file name...
medialabel = gtk.HBox(False) medialabel = gtk.HBox(False, 0)
label = self.__create_label("MediaLabel", False, False, False) label = self.__create_label("MediaLabel", False, False, False)
medialabel.pack_start(label, expand =False) medialabel.pack_start(label, expand =False)
main_vbox.pack_start(medialabel, expand =False, fill =False, padding =2) main_vbox.pack_start(medialabel, expand =False, fill =True, padding =0)
label.show() label.show()
# Displays mime type information... # Displays mime type information...
mimetype = gtk.HBox(False) mimetype = gtk.HBox(False, 0)
label = self.__create_label("MimeType", False, False, False) label = self.__create_label("MimeType", False, False, False)
mimetype.pack_start(label, expand =False) mimetype.pack_start(label, expand =False)
main_vbox.pack_start(mimetype, expand =False, fill =False, padding =2) main_vbox.pack_start(mimetype, expand =False, fill =True, padding =0)
label.show() label.show()
# image dimensions... # image dimensions...
imagesize = gtk.HBox(False) imagesize = gtk.HBox(False, 0)
label = self.__create_label("ImageSize", False, False, False) label = self.__create_label("ImageSize", False, False, False)
imagesize.pack_start(label, expand =False, fill =False, padding =0) imagesize.pack_start(label, expand =False, fill =False, padding =0)
main_vbox.pack_start(imagesize, expand =False, fill =True, padding =5) main_vbox.pack_start(imagesize, expand =False, fill =True, padding =0)
label.hide() label.show()
# Displays all plugin messages... # Displays all plugin messages...
messagearea = gtk.HBox(False) messagearea = gtk.HBox(False, 0)
label = self.__create_label("MessageArea", False, False, False) label = self.__create_label("MessageArea", False, False, False)
messagearea.pack_start(label, expand =False) messagearea.pack_start(label, expand =False)
main_vbox.pack_start(messagearea, expand =False, fill =False, padding =2) main_vbox.pack_start(messagearea, expand =False, fill =True, padding =0)
label.show() label.show()
# Separator line before the buttons... # Separator line before the buttons...
main_vbox.pack_start(gtk.HSeparator(), expand =False, fill =True, padding =0) main_vbox.pack_start(gtk.HSeparator(), expand =False, fill =True, padding =5)
# Thumbnail, ImageType, and Convert buttons... # Thumbnail, ImageType, and Convert buttons...
new_hbox = gtk.HBox(False, 0) new_hbox = gtk.HBox(False, 0)
@ -464,8 +467,8 @@ class EditExifMetadata(Gramplet):
""" """
top = gtk.TreeView() top = gtk.TreeView()
titles = [(_('Key'), 1, 200), titles = [(_('Key'), 1, 190),
(_('Value'), 2, 290)] (_('Value'), 2, 250)]
self.model = ListModel(top, titles, list_mode="tree") self.model = ListModel(top, titles, list_mode="tree")
return top return top
@ -507,24 +510,27 @@ class EditExifMetadata(Gramplet):
return return
# get image from database... # get image from database...
self.orig_image = db.get_object_from_handle(active_handle) self.orig_image = self.dbstate.db.get_object_from_handle(active_handle)
if not self.orig_image: if not self.orig_image:
self.set_has_data(False) self.set_has_data(False)
return return
# get file path and attempt to find it? # get file path and attempt to find it?
self.image_path = Utils.media_path_full(db, self.orig_image.get_path() ) self.image_path = Utils.media_path_full(self.dbstate.db,
self.orig_image.get_path() )
if not os.path.isfile(self.image_path): if not os.path.isfile(self.image_path):
self.set_has_data(False) self.set_has_data(False)
return return
# display file description/ title... # display file description/ title...
self.exif_widgets["MediaLabel"].set_text(_html_escape(self.orig_image.get_description() ) ) self.exif_widgets["MediaLabel"].set_text(_html_escape(
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["MimeType"].set_text("%s, %s" % ( self.exif_widgets["MimeType"].set_text(
mime_type, gen.mime.get_description(mime_type) ) ) gen.mime.get_description(mime_type) )
# 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)
@ -543,7 +549,8 @@ class EditExifMetadata(Gramplet):
# get dirpath/ basename, and extension... # get dirpath/ basename, and extension...
self.basename, self.extension = os.path.splitext(self.image_path) self.basename, self.extension = os.path.splitext(self.image_path)
# if image file type is not an Exiv2 acceptable image type, offer to convert it.... # if image file type is not an Exiv2 acceptable image type,
# offer to convert it....
if self.extension not in _VALIDIMAGEMAP.values(): if self.extension not in _VALIDIMAGEMAP.values():
imgtype_format = _validconvert imgtype_format = _validconvert
@ -554,8 +561,6 @@ class EditExifMetadata(Gramplet):
self.exif_widgets["ImageTypes"].set_active(0) self.exif_widgets["ImageTypes"].set_active(0)
self.activate_buttons(["ImageTypes"]) self.activate_buttons(["ImageTypes"])
else:
self.activate_buttons(["Edit"])
# determine if it is a mime image object? # determine if it is a mime image object?
if mime_type: if mime_type:
@ -570,23 +575,24 @@ class EditExifMetadata(Gramplet):
ttype, tdata = self.plugin_image.getThumbnailData() ttype, tdata = self.plugin_image.getThumbnailData()
width, height = tdata.dimensions width, height = tdata.dimensions
thumbnail = True thumbnail = True
except (IOError, OSError): except (IOError, OSError):
thumbnail = False thumbnail = False
else: # pyexiv2-0.2.0 and above else: # pyexiv2-0.2.0 and above...
try:
previews = self.plugin_image.previews
thumbnail = True
if not previews:
thumbnail = False
except (IOError, OSError):
thumbnail = False
# get image width and height... # get image width and height...
self.exif_widgets["ImageSize"].show() self.exif_widgets["ImageSize"].show()
width, height = self.plugin_image.dimensions width, height = self.plugin_image.dimensions
self.exif_widgets["ImageSize"].set_text(_("Image Size : %04d x %04d pixels") % (width, height)) self.exif_widgets["ImageSize"].set_text(_("Image Size : %04d x %04d pixels") % (width, height))
try:
previews = self.plugin_image.previews
thumbnail = True
except (IOError, OSError):
thumbnail = False
# if a thumbnail exists, then activate the buttton? # if a thumbnail exists, then activate the buttton?
if thumbnail: if thumbnail:
self.activate_buttons(["Thumbnail"]) self.activate_buttons(["Thumbnail"])
@ -616,63 +622,42 @@ class EditExifMetadata(Gramplet):
if not metadatatags_: if not metadatatags_:
self.exif_widgets["MessageArea"].set_text(_("No Exif metadata for this image...")) self.exif_widgets["MessageArea"].set_text(_("No Exif metadata for this image..."))
self.set_has_data(False) self.set_has_data(False)
return
if OLD_API: # prior to v0.2.0 else:
try: for section, key, key2, tag_label, func in TAGS_:
self.plugin_image.readMetadata() if key in metadatatags_:
has_metadata = True
except (IOError, OSError):
has_metadata = False
if has_metadata: if section not in self.sections:
for section, key, key2, func, label in TAGS_: node = self.model.add([section, ''])
if key in metadatatags_: self.sections[section] = node
if section not in self.sections: else:
node = self.model.add([section, '']) node = self.sections[section]
self.sections[section] = node
else:
node = self.sections[section]
if OLD_API: # prior to v0.2.0
label = self.plugin_image.tagDetails(key)[0] label = self.plugin_image.tagDetails(key)[0]
tag_value = self.plugin_image.interpretedExifValue(key)
if func: if func:
human_value = func(self.plugin_image[key]) human_value = func(tag_value)
else: else:
human_value = self.plugin_image.interpretedExifValue(key) human_value = tag_value
if key2: if key2:
human_value += ' ' + self.plugin_image.interpretedExifValue(key2) human_value += ' ' + self.plugin_image.interpretedExifValue(key2)
self.model.add((label, human_value), node =node)
self.model.tree.expand_all()
else: # v0.2.0 and above
try:
self.plugin_image.read()
has_metadata = True
except (IOError, OSError):
has_metadata = False
if has_metadata:
for section, key, key2, func, label in TAGS_:
if key in metadatatags_:
if section not in self.sections:
node = self.model.add([section, ''])
self.sections[section] = node
else:
node = self.sections[section]
else: # v0.2.0 and above
tag = self.plugin_image[key] tag = self.plugin_image[key]
label = tag.label
if func: if func:
label = tag.label
human_value = func(tag.value) human_value = func(tag.value)
elif ("Xmp" in key or "Iptc" in key):
human_value = self._get_value(key)
else: else:
label = tag.value
human_value = tag.human_value human_value = tag.human_value
if key2: if key2:
human_value += ' ' + self.plugin_image[key2].human_value human_value += ' ' + self.plugin_image[key2].human_value
self.model.add((label, human_value), node =node) self.model.add((label, human_value), node =node)
self.model.tree.expand_all()
# once completed displaying, open all nodes...
self.model.tree.expand_all()
# update has_data functionality... # update has_data functionality...
self.set_has_data(self.model.count > 0) self.set_has_data(self.model.count > 0)
@ -1496,7 +1481,6 @@ class EditExifMetadata(Gramplet):
sets the value for the metadata keytag_s sets the value for the metadata keytag_s
""" """
tagclass_ = keytag_[0:4]
if OLD_API: if OLD_API:
self.plugin_image[keytag_] = keyvalue_ self.plugin_image[keytag_] = keyvalue_
@ -1504,15 +1488,7 @@ class EditExifMetadata(Gramplet):
try: try:
self.plugin_image.__setitem__(keytag_, keyvalue_) self.plugin_image.__setitem__(keytag_, keyvalue_)
except KeyError: except KeyError:
if tagclass_ == "Exif": self.plugin_image[keytag_] = pyexiv2.ExifTag(keytag_, keyvalue_)
self.plugin_image[keytag_] = pyexiv2.ExifTag(keytag_, keyvalue_)
elif tagclass_ == "Xmp.":
self.plugin_image[keytag_] = pyexiv2.XmpTag(keytag_, keyvalue_)
elif tagclass_ == "Iptc":
self.plugin_image[keytag_] = IptcTag(keytag_, keyvalue_)
except (ValueError, AttributeError): except (ValueError, AttributeError):
pass pass