commit f786e6283985aea4087e162bbf6168bd434eed87
Author: Dan Callaghan <djc@djc.id.au>
Date: Thu, 25 Dec 2008 16:13:58 +1000
yay, it finally does something
Diffstat:
6 files changed, 133 insertions(+), 0 deletions(-)
diff --git a/MainWindow.cpp b/MainWindow.cpp
@@ -0,0 +1,20 @@
+
+#include "MainWindow.h"
+
+MainWindow::MainWindow(const std::string& path) :
+ model(MetadataTreeModel::create(path)) {
+
+ set_title("XMPEdit");
+ set_border_width(5);
+
+ tree_view.set_model(model);
+ tree_view.append_column("Predicate", model->columns.pred_column);
+ tree_view.append_column("Value", model->columns.value_column);
+ add(tree_view);
+
+ show_all_children();
+
+}
+
+MainWindow::~MainWindow() {
+}
diff --git a/MainWindow.h b/MainWindow.h
@@ -0,0 +1,21 @@
+
+#ifndef MAINWINDOW_H_
+#define MAINWINDOW_H_
+
+#include "MetadataTreeModel.h"
+#include <gtkmm/treeview.h>
+#include <gtkmm/window.h>
+
+class MainWindow : public Gtk::Window {
+
+public:
+ MainWindow(const std::string& path);
+ virtual ~MainWindow();
+
+private:
+ Glib::RefPtr<MetadataTreeModel> model;
+ Gtk::TreeView tree_view;
+
+};
+
+#endif /* MAINWINDOW_H_ */
diff --git a/Makefile b/Makefile
@@ -0,0 +1,15 @@
+CXXFLAGS = -O2 -g -Wall -fmessage-length=0 $(shell pkg-config gtkmm-2.4 --cflags) $(shell pkg-config exiv2 --cflags)
+
+OBJS = xmpedit.o MainWindow.o MetadataTreeModel.o
+
+LIBS = $(shell pkg-config gtkmm-2.4 --libs) $(shell pkg-config exiv2 --libs)
+
+TARGET = xmpedit
+
+$(TARGET): $(OBJS)
+ $(CXX) -o $(TARGET) $(OBJS) $(LIBS)
+
+all: $(TARGET)
+
+clean:
+ rm -f $(OBJS) $(TARGET)
diff --git a/MetadataTreeModel.cpp b/MetadataTreeModel.cpp
@@ -0,0 +1,35 @@
+
+#include "MetadataTreeModel.h"
+#include <exiv2/convert.hpp>
+
+MetadataTreeModel::MetadataTreeModel(const std::string& path) {
+ set_column_types(columns);
+
+ Exiv2::Image::AutoPtr image(Exiv2::ImageFactory::open(path));
+ image->readMetadata();
+ Exiv2::XmpData data = image->xmpData();
+
+ // convert EXIF and IPTC
+ Exiv2::copyExifToXmp(image->exifData(), data);
+ Exiv2::copyIptcToXmp(image->iptcData(), data);
+
+ for (Exiv2::XmpData::const_iterator i = data.begin(); i != data.end(); ++ i) {
+ Row row(*append());
+ Glib::ustring pred(i->groupName());
+ pred += ":";
+ pred += i->tagName();
+ row[columns.pred_column] = pred;
+ Glib::ustring value(i->value().toString());
+ value += " [";
+ value += i->typeName();
+ value += "]";
+ row[columns.value_column] = value;
+ }
+}
+
+MetadataTreeModel::~MetadataTreeModel(void) {
+}
+
+Glib::RefPtr<MetadataTreeModel> MetadataTreeModel::create(const std::string& path) {
+ return Glib::RefPtr<MetadataTreeModel>(new MetadataTreeModel(path));
+}
diff --git a/MetadataTreeModel.h b/MetadataTreeModel.h
@@ -0,0 +1,31 @@
+
+#ifndef METADATATREEMODEL_H_
+#define METADATATREEMODEL_H_
+
+#include <string>
+#include <gtkmm/liststore.h>
+#include <exiv2/image.hpp>
+
+class MetadataTreeModel : public Gtk::ListStore {
+
+public:
+ MetadataTreeModel(const std::string& path);
+ virtual ~MetadataTreeModel(void);
+ static Glib::RefPtr<MetadataTreeModel> create(const std::string& path);
+
+private:
+ struct ModelColumns : public Gtk::TreeModel::ColumnRecord {
+ Gtk::TreeModelColumn<Glib::ustring> pred_column;
+ Gtk::TreeModelColumn<Glib::ustring> value_column;
+ ModelColumns(void) {
+ add(pred_column);
+ add(value_column);
+ }
+ };
+
+public:
+ ModelColumns columns;
+
+};
+
+#endif /* METADATATREEMODEL_H_ */
diff --git a/xmpedit.cpp b/xmpedit.cpp
@@ -0,0 +1,11 @@
+
+#include <gtkmm/main.h>
+
+#include "MainWindow.h"
+
+int main(int argc, char *argv[]) {
+ Gtk::Main kit(argc, argv);
+ MainWindow window("/home/dan/Photos/indro3.jpg");
+ Gtk::Main::run(window);
+ return 0;
+}