Commit 4993cf29 authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

Added ability to change IPTC fields

parent 566ee398
......@@ -326,6 +326,8 @@ extensions/edit_metadata/Makefile
extensions/edit_metadata/data/Makefile
extensions/edit_metadata/data/ui/Makefile
extensions/exiv2/Makefile
extensions/exiv2/data/Makefile
extensions/exiv2/data/ui/Makefile
extensions/file_manager/Makefile
extensions/file_tools/Makefile
extensions/file_tools/data/Makefile
......
if ENABLE_EXIV2
SUBDIRS = data
extensiondir = $(libdir)/gthumb-2.0/extensions
extension_LTLIBRARIES = libexiv2.la
libexiv2_la_SOURCES = \
exiv2-utils.h \
exiv2-utils.cpp \
gth-edit-exiv2-page.c \
gth-edit-exiv2-page.h \
gth-metadata-provider-exiv2.c \
gth-metadata-provider-exiv2.h \
main.c
......
SUBDIRS = ui
-include $(top_srcdir)/git.mk
uidir = $(datadir)/gthumb-2.0/ui
ui_DATA = edit-exiv2-page.ui
EXTRA_DIST = $(ui_DATA)
-include $(top_srcdir)/git.mk
<?xml version="1.0"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkTable" id="content">
<property name="visible">True</property>
<property name="n_rows">10</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
<object class="GtkEntry" id="copyright_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="max_length">128</property>
<property name="invisible_char">&#x25CF;</property>
<property name="activates_default">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">C_opyright:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">byline_entry</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Co_untry:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Language:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkEntry" id="country_name_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="max_length">64</property>
<property name="invisible_char">&#x25CF;</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Code:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="country_code_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="width_chars">5</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="credit_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="max_length">32</property>
<property name="invisible_char">&#x25CF;</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Cr_edit:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="destination_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="max_length">1024</property>
<property name="invisible_char">&#x25CF;</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Destination:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="source_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="max_length">1024</property>
<property name="invisible_char">&#x25CF;</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label11">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Source:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox4">
<property name="visible">True</property>
<child>
<object class="GtkSpinButton" id="urgency_spinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">urgency_adjustment</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">9</property>
<property name="bottom_attach">10</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Urgency:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="top_attach">9</property>
<property name="bottom_attach">10</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Object Name:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="object_name_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="max_length">1024</property>
<property name="invisible_char">&#x25CF;</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox5">
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkEntry" id="byline_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="max_length">32</property>
<property name="invisible_char">&#x25CF;</property>
<property name="activates_default">True</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Byline _Title:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">byline_entry</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="byline_title_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="max_length">32</property>
<property name="invisible_char">&#x25CF;</property>
<property name="activates_default">True</property>
<property name="width_chars">16</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<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="y_options"></property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label10">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Byline:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="city_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="max_length">32</property>
<property name="invisible_char">&#x25CF;</property>
<property name="activates_default">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_City:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">byline_entry</property>
</object>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<child>
<object class="GtkEntry" id="language_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="max_length">3</property>
<property name="invisible_char">&#x25CF;</property>
<property name="width_chars">3</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
</object>
<object class="GtkAdjustment" id="urgency_adjustment">
<property name="upper">9</property>
<property name="step_increment">1</property>
</object>
</interface>
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* GThumb
*
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
#include <extensions/edit_metadata/gth-edit-metadata-dialog.h>
#include "exiv2-utils.h"
#include "gth-edit-exiv2-page.h"
#define GTH_EDIT_EXIV2_PAGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTH_TYPE_EDIT_EXIV2_PAGE, GthEditExiv2PagePrivate))
#define GET_WIDGET(name) _gtk_builder_get_widget (self->priv->builder, (name))
static gpointer gth_edit_exiv2_page_parent_class = NULL;
struct _GthEditExiv2PagePrivate {
GtkBuilder *builder;
gboolean supported;
};
static void
set_entry_value (GthEditExiv2Page *self,
GthFileData *file_data,
const char *attribute,
const char *widget_id)
{
GthMetadata *metadata;
metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, attribute);
if (metadata != NULL)
gtk_entry_set_text (GTK_ENTRY (GET_WIDGET (widget_id)), gth_metadata_get_formatted (metadata));
else
gtk_entry_set_text (GTK_ENTRY (GET_WIDGET (widget_id)), "");
}
void
gth_edit_exiv2_page_real_set_file (GthEditMetadataPage *base,
GthFileData *file_data)
{
GthEditExiv2Page *self;
GthMetadata *metadata;
self = GTH_EDIT_EXIV2_PAGE (base);
self->priv->supported = exiv2_supports_writes (gth_file_data_get_mime_type (file_data));
if (! self->priv->supported) {
gtk_widget_hide (GTK_WIDGET (base));
return;
}
set_entry_value (self, file_data, "Iptc::Application2::Copyright", "copyright_entry");
set_entry_value (self, file_data, "Iptc::Application2::Credit", "credit_entry");
set_entry_value (self, file_data, "Iptc::Application2::Byline", "byline_entry");
set_entry_value (self, file_data, "Iptc::Application2::BylineTitle", "byline_title_entry");
set_entry_value (self, file_data, "Iptc::Application2::CountryName", "country_name_entry");
set_entry_value (self, file_data, "Iptc::Application2::CountryCode", "country_code_entry");
set_entry_value (self, file_data, "Iptc::Application2::City", "city_entry");
set_entry_value (self, file_data, "Iptc::Application2::Language", "language_entry");
set_entry_value (self, file_data, "Iptc::Application2::ObjectName", "object_name_entry");
set_entry_value (self, file_data, "Iptc::Application2::Source", "source_entry");
set_entry_value (self, file_data, "Iptc::Envelope::Destination", "destination_entry");
metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "Iptc::Application2::Urgency");
if (metadata != NULL) {
float v;
if (sscanf (gth_metadata_get_formatted (metadata), "%f", &v) == 1)
gtk_adjustment_set_value (GTK_ADJUSTMENT (GET_WIDGET ("urgency_adjustment")), (double) v);
else
gtk_adjustment_set_value (GTK_ADJUSTMENT (GET_WIDGET ("urgency_adjustment")), 0.0);
}
else
gtk_adjustment_set_value (GTK_ADJUSTMENT (GET_WIDGET ("urgency_adjustment")), 0.0);
gtk_widget_show (GTK_WIDGET (base));
}
static void
set_attribute_from_entry (GthEditExiv2Page *self,
GFileInfo *info,
const char *attribute,
const char *widget_id)
{
GthMetadata *metadata;
metadata = g_object_new (GTH_TYPE_METADATA,
"id", attribute,
"raw", gtk_entry_get_text (GTK_ENTRY (GET_WIDGET (widget_id))),
"formatted", gtk_entry_get_text (GTK_ENTRY (GET_WIDGET (widget_id))),
NULL);
g_file_info_set_attribute_object (info, attribute, G_OBJECT (metadata));
g_object_unref (metadata);
}
void
gth_edit_exiv2_page_real_update_info (GthEditMetadataPage *base,
GFileInfo *info)
{
GthEditExiv2Page *self;
double v;
char *s;
GthMetadata *metadata;
self = GTH_EDIT_EXIV2_PAGE (base);
if (! self->priv->supported)
return;
set_attribute_from_entry (self, info, "Iptc::Application2::Copyright", "copyright_entry");
set_attribute_from_entry (self, info, "Iptc::Application2::Credit", "credit_entry");
set_attribute_from_entry (self, info, "Iptc::Application2::Byline", "byline_entry");
set_attribute_from_entry (self, info, "Iptc::Application2::BylineTitle", "byline_title_entry");
set_attribute_from_entry (self, info, "Iptc::Application2::CountryName", "country_name_entry");
set_attribute_from_entry (self, info, "Iptc::Application2::CountryCode", "country_code_entry");
set_attribute_from_entry (self, info, "Iptc::Application2::City", "city_entry");
set_attribute_from_entry (self, info, "Iptc::Application2::Language", "language_entry");
set_attribute_from_entry (self, info, "Iptc::Application2::ObjectName", "object_name_entry");
set_attribute_from_entry (self, info, "Iptc::Application2::Source", "source_entry");
set_attribute_from_entry (self, info, "Iptc::Envelope::Destination", "destination_entry");
/* urgency */
v = gtk_adjustment_get_value (GTK_ADJUSTMENT (GET_WIDGET ("urgency_adjustment")));
s = g_strdup_printf ("%1.g", v);
metadata = g_object_new (GTH_TYPE_METADATA,
"id", "Iptc::Application2::Urgency",
"raw", s,
"formatted", s,
NULL);
g_file_info_set_attribute_object (info, "Iptc::Application2::Urgency", G_OBJECT (metadata));
g_object_unref (metadata);
g_free (s);
}
const char *
gth_edit_exiv2_page_real_get_name (GthEditMetadataPage *self)
{
return _("Other");
}
static void
gth_edit_exiv2_page_finalize (GObject *object)
{
GthEditExiv2Page *self;
self