Removed the Exif metadata Viewing Area...

svn: r17477
This commit is contained in:
Rob G. Healey 2011-05-12 01:06:38 +00:00
parent 5d95f00489
commit b70ea64125

View File

@ -187,14 +187,11 @@ _DATAMAP.update( (val, key) for key, val in _DATAMAP.items() )
# Toolt tips for the buttons in the gramplet... # Toolt tips for the buttons in the gramplet...
_BUTTONTIPS = { _BUTTONTIPS = {
# CopyTo button...
"CopyTo" : _("Copies information from the Display area to the Edit area."),
# Clear Edit Area button... # Clear Edit Area button...
"Clear" : _("Clears the Exif metadata from the Edit area."), "Clear" : _("Clears the Exif metadata from the Edit area."),
# Calendar date select button... # Calendar date select button...
"Date:Select" : _("Allows you to select a date from a pop-up window calendar. \n" "Popup:Select" : _("Allows you to select a date from a pop-up window calendar. \n"
"Warning: You will still need to edit the time..."), "Warning: You will still need to edit the time..."),
# Convert to decimal button... # Convert to decimal button...
@ -286,53 +283,46 @@ class EditExifMetadata(Gramplet):
_setup_widget_tooltips(self.exif_widgets) _setup_widget_tooltips(self.exif_widgets)
def build_gui(self): def build_gui(self):
"""
creates the editing area fields.
"""
vbox = gtk.VBox() vbox = gtk.VBox()
medialabel = gtk.HBox(False) hbox = gtk.HBox(False)
self.exif_widgets["Media:Label"] = gtk.Label() label = gtk.Label()
self.exif_widgets["Media:Label"].set_alignment(0.0, 0.0) label.set_alignment(0.0, 0.0)
medialabel.pack_start(self.exif_widgets["Media:Label"], expand =False) self.exif_widgets["Media:Label"] = label
vbox.pack_start(medialabel, expand =False) hbox.pack_start(self.exif_widgets["Media:Label"], expand =False)
vbox.pack_start(hbox, expand =False)
mimetype = gtk.HBox(False) hbox = gtk.HBox(False)
self.exif_widgets["Mime:Type"] = gtk.Label() label = gtk.Label()
self.exif_widgets["Mime:Type"].set_alignment(0.0, 0.0) label.set_alignment(0.0, 0.0)
mimetype.pack_start(self.exif_widgets["Mime:Type"], expand =False) self.exif_widgets["Mime:Type"] = label
vbox.pack_start(mimetype, expand =False) hbox.pack_start(self.exif_widgets["Mime:Type"], expand =False)
vbox.pack_start(hbox, expand =False)
messagearea = gtk.HBox(False) hbox = gtk.HBox(False)
self.exif_widgets["Message:Area"] = gtk.Label(_("Click an image to begin...")) label = gtk.Label()
self.exif_widgets["Message:Area"].set_alignment(0.5, 0.0) label.set_alignment(0.5, 0.0)
messagearea.pack_start(self.exif_widgets["Message:Area"], expand =False) self.exif_widgets["Message:Area"] = label
vbox.pack_start(messagearea, expand =False) hbox.pack_start(self.exif_widgets["Message:Area"], expand =False)
vbox.pack_start(hbox, expand =False)
self.model = gtk.ListStore(object, str, str) # Edit, Clear, Convert horizontal box
view = gtk.TreeView(self.model) ecc_box = gtk.HButtonBox()
ecc_box.set_layout(gtk.BUTTONBOX_START)
# Key Column vbox.pack_start(ecc_box, expand =False, fill =False, padding =10)
view.append_column( self.__create_column(_("Key"), 1) )
# Value Column
view.append_column( self.__create_column(_("Value"), 2) )
# CopyTo, Clear, Convert horizontal box
ccc_box = gtk.HButtonBox()
ccc_box.set_layout(gtk.BUTTONBOX_START)
vbox.pack_start(ccc_box, expand =False, fill =False, padding =10)
# Copy To Edit Area button...
ccc_box.add( self.__create_button(
"CopyTo", False, [self.CopyTo], gtk.STOCK_COPY, False) )
# Clear button... # Clear button...
ccc_box.add( self.__create_button( ecc_box.add( self.__create_button(
"Clear", False, [self.clear_metadata], gtk.STOCK_CLEAR, False) ) "Clear", False, [self.clear_metadata], gtk.STOCK_CLEAR, False) )
# is ImageMagick installed? # is ImageMagick installed?
if _MAGICK_FOUND: if _MAGICK_FOUND:
# Convert button... # Convert button...
ccc_box.add( self.__create_button( ecc_box.add( self.__create_button(
"Convert", False, [self.__convert_dialog], gtk.STOCK_CONVERT, False) ) "Convert", False, [self.__convert_dialog], gtk.STOCK_CONVERT, False) )
for items in [ for items in [
@ -349,10 +339,11 @@ class EditExifMetadata(Gramplet):
# copyright field # copyright field
("Copyright", _("Copyright"), None, False, [], True, 0), ("Copyright", _("Copyright"), None, False, [], True, 0),
# calendar date clickable entry # calendar date clickable entry...
("Date", "", None, True, ("Popup", "", None, True,
[("Select", _("Select Date"), "button", self.select_date)], [("Select", _("Select Date"), "button", self.select_date)],
True, 0), True, 0),
# Original Date/ Time Entry, 1826-April-12 14:06:00 # Original Date/ Time Entry, 1826-April-12 14:06:00
("DateTime", _("Date/ Time"), None, False, [], True, 0), ("DateTime", _("Date/ Time"), None, False, [], True, 0),
@ -388,9 +379,6 @@ class EditExifMetadata(Gramplet):
hsd_box.add(self.__create_button( hsd_box.add(self.__create_button(
"Delete", False, [self.__delete_dialog], gtk.STOCK_DELETE, False)) "Delete", False, [self.__delete_dialog], gtk.STOCK_DELETE, False))
# adds Exif Metadata Viewing Area
vbox.pack_start(view, padding =10)
return vbox return vbox
def update_has_data(self): def update_has_data(self):
@ -454,15 +442,17 @@ class EditExifMetadata(Gramplet):
# clear Display and Edit Areas # clear Display and Edit Areas
self.clear_metadata(self.orig_image) self.clear_metadata(self.orig_image)
self.model.clear()
# De-activate the buttons except for Help... # De-activate the buttons except for Help...
self.deactivate_buttons(["CopyTo", "Clear", "Save"]) self.deactivate_buttons(["Clear", "Save"])
if _MAGICK_FOUND: if _MAGICK_FOUND:
self.deactivate_buttons(["Convert", "Delete"]) self.deactivate_buttons(["Convert"])
# Re-post initial image message... if (_MAGICK_FOUND or _HEAD_FOUND):
self.deactivate_buttons(["Delete"])
# set Message Area to Select...
self.exif_widgets["Message:Area"].set_text(_("Select an image to begin...")) self.exif_widgets["Message:Area"].set_text(_("Select an image to begin..."))
active_handle = self.get_active("Media") active_handle = self.get_active("Media")
@ -504,48 +494,26 @@ class EditExifMetadata(Gramplet):
self.exif_widgets["Media:Label"].set_text(_html_escape( self.exif_widgets["Media:Label"].set_text(_html_escape(
self.orig_image.get_description() ) ) self.orig_image.get_description() ) )
# will create the image and read it... # will create the plugin image and read it...
self.setup_image(self.image_path, True) self.setup_image(self.image_path, True)
# Checks to make sure that ImageMagick is installed on this computer and # Checks to make sure that ImageMagick is installed on this computer and
# the image is NOT a jpeg image... # the image is NOT a (.jpeg, .jfif, .jpg) image...
if _MAGICK_FOUND: if _MAGICK_FOUND:
basename, extension = os.path.splitext(self.image_path) basename, extension = os.path.splitext(self.image_path)
if extension not in [".jpeg", ".jpg", ".jfif"]: if extension not in [".jpeg", ".jpg", ".jfif"]:
self.activate_buttons(["Convert"]) self.activate_buttons(["Convert"])
# displays the imge Exif metadata # displays the imge Exif metadata
self.display_exif_tags(self.orig_image) self.EditArea(self.orig_image)
else: else:
self.exif_widgets["Message:Area"].set_text(_("Choose a different image...")) self.exif_widgets["Message:Area"].set_text(_("Please choose a different image..."))
return return
else: else:
self.exif_widgets["Message:Area"].set_text(_("Choose a different image...")) self.exif_widgets["Message:Area"].set_text(_("Please choose a different image..."))
return return
def __create_column(self, name, colnum, fixed =True):
"""
will create the column for the column row...
"""
renderer = gtk.CellRendererText()
column = gtk.TreeViewColumn(name, renderer, text =colnum)
if fixed:
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_expand(True)
else:
column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
column.set_expand(False)
column.set_alignment(0.0)
column.set_sort_column_id(colnum)
return column
def __create_button(self, pos, text, callback =[], icon =False, sensitive = True): def __create_button(self, pos, text, callback =[], icon =False, sensitive = True):
""" """
creates and returns a button for display creates and returns a button for display
@ -729,61 +697,40 @@ class EditExifMetadata(Gramplet):
return KeyValue return KeyValue
def display_exif_tags(self, obj): def clear_metadata(self, obj, cleartype = "All"):
""" """
once the pyexiv2.Image has been created, we display clears all data fields to nothing
all of the image Exif metadata...
@param: cleartype --
"Date" = clears only Date entry fields
"All" = clears all data fields
""" """
# set has data flag... # clear all data fields
self.set_has_data(len(self.MediaDataTags) > 0) if cleartype == "All":
for widgetsName in ["Description", "Modified", "Artist", "Copyright",
# Activate Clear and Save buttons... "DateTime", "Latitude", "Longitude"]:
self.activate_buttons(["Clear", "Save"]) self.exif_widgets[widgetsName].set_text("")
# check to see if we got metadata from the media object?
if self.MediaDataTags:
# activate CopyTo button...
self.activate_buttons(["CopyTo"])
# set Message Area to Display...
self.exif_widgets["Message:Area"].set_text(_("Displaying image Exif metadata..."))
for KeyTag in self.MediaDataTags:
if LesserVersion:
label = self.plugin_image.tagDetails(KeyTag)[0]
human_value = self.plugin_image.interpretedExifValue(KeyTag)
# clear only the date/ time field
else: else:
try: self.exif_widgets["Modified"].set_text("")
tag = self.plugin_image[KeyTag] self.exif_widgets["DateTime"].set_text("")
label = tag.label
human_value = tag.human_value
except AttributeError:
human_value = False
if KeyTag in ("Exif.Image.DateTime", def EditArea(self, obj):
"Exif.Photo.DateTimeOriginal",
"Exif.Photo.DateTimeDigitized"):
human_value = _process_datetime(self._get_value(KeyTag))
if human_value is not False:
self.model.append((self.plugin_image, label, human_value))
def CopyTo(self, obj):
""" """
reads the image metadata after the pyexiv2.Image has been created reads the image metadata after the pyexiv2.Image has been created
""" """
if LesserVersion: # separate KeyTags into the ones that we will be using...
imageKeyTags = [KeyTag for KeyTag in self.plugin_image.exifKeys() if KeyTag in _DATAMAP] imageKeyTags = [KeyTag for KeyTag in self.MediaDataTags if KeyTag in _DATAMAP]
else: # activate Clear button...
imageKeyTags = [KeyTag for KeyTag in self.plugin_image.exif_keys if KeyTag in _DATAMAP] self.activate_buttons(["Clear"])
if imageKeyTags: if imageKeyTags:
# set Message Area to Copying...
self.exif_widgets["Message:Area"].set_text(_("Copying Exif metadata to the Edit Area...")) self.exif_widgets["Message:Area"].set_text(_("Copying Exif metadata to the Edit Area..."))
for KeyTag in imageKeyTags: for KeyTag in imageKeyTags:
@ -797,15 +744,15 @@ class EditExifMetadata(Gramplet):
if widgetsName in ["Description", "Artist", "Copyright"]: if widgetsName in ["Description", "Artist", "Copyright"]:
self.exif_widgets[widgetsName].set_text(tagValue) self.exif_widgets[widgetsName].set_text(tagValue)
# Original Date of the image... # Last Changed/ Modified...
elif widgetsName == "DateTime": elif widgetsName == "Modified":
use_date = self._get_value(KeyTag) use_date = self._get_value(KeyTag)
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 is not False: if use_date is not False:
self.exif_widgets[widgetsName].set_text(use_date) self.exif_widgets[widgetsName].set_text(use_date)
# Last Changed/ Modified... # Original Date/ Time of this image...
elif widgetsName == "Modified": elif widgetsName == "DateTime":
use_date = self._get_value(KeyTag) use_date = self._get_value(KeyTag)
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 is not False: if use_date is not False:
@ -845,37 +792,6 @@ class EditExifMetadata(Gramplet):
self.exif_widgets["Longitude"].set_text( self.exif_widgets["Longitude"].set_text(
"""%s° %s %s%s""" % (longdeg, longmin, longsec, LongitudeRef) ) """%s° %s %s%s""" % (longdeg, longmin, longsec, LongitudeRef) )
# enable Save button after metadata has been "Copied to Edit Area"...
self.activate_buttons(["Save"])
if _MAGICK_FOUND:
self.activate_buttons(["Delete"])
# Clear the Message Area...
self.exif_widgets["Message:Area"].set_text("")
def clear_metadata(self, obj, cleartype = "All"):
"""
clears all data fields to nothing
@param: cleartype --
"Date" = clears only Date entry fields
"All" = clears all data fields
"""
# set Message Area text...
self.exif_widgets["Message:Area"].set_text(_("Edit area has been cleared..."))
# clear all data fields
if cleartype == "All":
for widgetsName in ["Description", "Artist", "Copyright", "DateTime",
"Latitude", "Longitude"]:
self.exif_widgets[widgetsName].set_text("")
# clear only the date/ time field
else:
self.exif_widgets["DateTime"].set_text("")
def convertdelete(self): def convertdelete(self):
""" """
will convert2Jpeg and delete original non-jpeg image. will convert2Jpeg and delete original non-jpeg image.
@ -1102,27 +1018,33 @@ class EditExifMetadata(Gramplet):
""" """
# determine if there has been something entered in the data fields? # determine if there has been something entered in the data fields?
datatags = (len(self.exif_widgets["Description"].get_text() ) + datatags = (
len(self.exif_widgets["Description"].get_text() ) +
len(self.exif_widgets["Artist"].get_text() ) + len(self.exif_widgets["Artist"].get_text() ) +
len(self.exif_widgets["Copyright"].get_text() ) + len(self.exif_widgets["Copyright"].get_text() ) +
len(self.exif_widgets["DateTime"].get_text() )+ len(self.exif_widgets["DateTime"].get_text() )+
len(self.exif_widgets["Latitude"].get_text() ) + len(self.exif_widgets["Latitude"].get_text() ) +
len(self.exif_widgets["Longitude"].get_text() ) ) len(self.exif_widgets["Longitude"].get_text() )
)
# Description data field # Description data field...
self._set_value(_DATAMAP["Description"], self.exif_widgets["Description"].get_text() ) description = self.exif_widgets["Description"].get_text() or ""
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...
self._set_value(_DATAMAP["Modified"], datetime.now() ) modified = datetime.now()
self._set_value(_DATAMAP["Modified"], modified)
# display modified Date/ Time # display modified Date/ Time...
self.exif_widgets["Modified"].set_text(_format_datetime(datetime.now() ) ) self.exif_widgets["Modified"].set_text(_format_datetime(modified) )
# Artist/ Author data field # Artist/ Author data field...
self._set_value(_DATAMAP["Artist"], self.exif_widgets["Artist"].get_text() ) artist = self.exif_widgets["Artist"].get_text() or ""
self._set_value(_DATAMAP["Artist"], artist)
# Copyright data field # Copyright data field...
self._set_value(_DATAMAP["Copyright"], self.exif_widgets["Copyright"].get_text() ) copyright = self.exif_widgets["Copyright"].get_text() or ""
self._set_value(_DATAMAP["Copyright"], copyright)
# Original Date/ Time data field # Original Date/ Time data field
DateTime = self.exif_widgets["DateTime"].get_text() DateTime = self.exif_widgets["DateTime"].get_text()
@ -1131,6 +1053,9 @@ class EditExifMetadata(Gramplet):
if DateTime is not False: if DateTime is not False:
self._set_value(_DATAMAP["DateTime"], DateTime) self._set_value(_DATAMAP["DateTime"], DateTime)
# display formatted date/ time as set in user preferences...
self.exif_widgets["DateTime"].set_text(DateTime)
# 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()