[niepce] Preference to enable writing XMP. Disabled by default.
- From: Hubert FiguiÃre <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] Preference to enable writing XMP. Disabled by default.
- Date: Thu, 23 Feb 2012 06:39:42 +0000 (UTC)
commit b52f0d4e8ca7ce20f01f3e753a9bb26b84fecf5a
Author: Hub Figuiere <hub figuiere net>
Date: Wed Feb 22 20:57:20 2012 -0800
Preference to enable writing XMP. Disabled by default.
src/engine/db/library.cpp | 13 ++----
src/engine/db/library.hpp | 4 +-
src/engine/library/commands.cpp | 4 +-
src/engine/library/commands.hpp | 2 +-
src/libraryclient/clientimpl.cpp | 4 +-
src/libraryclient/clientimpl.hpp | 2 +-
src/libraryclient/libraryclient.cpp | 4 +-
src/libraryclient/libraryclient.hpp | 4 +-
src/niepce/ui/dialogs/preferences.ui | 56 ++++++++++++++++++++++++++-
src/niepce/ui/dialogs/preferencesdialog.cpp | 24 +++++++----
src/niepce/ui/imageliststore.cpp | 4 +-
11 files changed, 90 insertions(+), 31 deletions(-)
---
diff --git a/src/engine/db/library.cpp b/src/engine/db/library.cpp
index bdf4cfc..2c581d2 100644
--- a/src/engine/db/library.cpp
+++ b/src/engine/db/library.cpp
@@ -894,11 +894,8 @@ bool Library::getXmpIdsInQueue(std::vector<library_id_t> & ids)
}
-bool Library::rewriteXmpForId(library_id_t id)
+bool Library::rewriteXmpForId(library_id_t id, bool write_xmp)
{
- /// DISABLED
-#if 0
-
SQLStatement del(boost::format("DELETE FROM xmp_update_queue "
" WHERE id='%1%';") % id);
SQLStatement getxmp(boost::format("SELECT xmp, main_file, xmp_file FROM files "
@@ -907,7 +904,7 @@ bool Library::rewriteXmpForId(library_id_t id)
if(m_dbdrv->execute_statement(del)
&& m_dbdrv->execute_statement(getxmp)) {
- while(m_dbdrv->read_next_row()) {
+ while(write_xmp && m_dbdrv->read_next_row()) {
std::string xmp_buffer;
library_id_t main_file_id;
library_id_t xmp_file_id;
@@ -956,12 +953,12 @@ bool Library::rewriteXmpForId(library_id_t id)
DBG_OUT("db exception %s", e.what());
return false;
}
-#endif
+
return true;
}
-bool Library::processXmpUpdateQueue()
+bool Library::processXmpUpdateQueue(bool write_xmp)
{
bool retval = false;
std::vector<library_id_t> ids;
@@ -969,7 +966,7 @@ bool Library::processXmpUpdateQueue()
if(retval) {
std::for_each(ids.begin(), ids.end(),
boost::bind(&Library::rewriteXmpForId,
- this, _1));
+ this, _1, write_xmp));
}
return retval;
}
diff --git a/src/engine/db/library.hpp b/src/engine/db/library.hpp
index 3d41b4e..59e9013 100644
--- a/src/engine/db/library.hpp
+++ b/src/engine/db/library.hpp
@@ -175,7 +175,7 @@ public:
bool deleteLabel(library_id_t label_id);
/** Trigger the processing of the XMP update queue */
- bool processXmpUpdateQueue();
+ bool processXmpUpdateQueue(bool rewrite_xmp);
/** Locate the keyword, creating it if needed
* @param keyword the keyword to locate
@@ -204,7 +204,7 @@ private:
/** rewrite the XMP sidecar for the file whose id is %id
* and remove it from the queue.
*/
- bool rewriteXmpForId(library_id_t id);
+ bool rewriteXmpForId(library_id_t id, bool rewrite_xmp);
/** set an "internal" metadata of type int */
bool setInternalMetaDataInt(library_id_t file_id, const char* col,
diff --git a/src/engine/library/commands.cpp b/src/engine/library/commands.cpp
index 82419ec..d945f62 100644
--- a/src/engine/library/commands.cpp
+++ b/src/engine/library/commands.cpp
@@ -177,9 +177,9 @@ void Commands::cmdUpdateLabel(const Library::Ptr & lib,
}
-void Commands::cmdProcessXmpUpdateQueue(const Library::Ptr & lib)
+void Commands::cmdProcessXmpUpdateQueue(const Library::Ptr & lib, bool write_xmp)
{
- lib->processXmpUpdateQueue();
+ lib->processXmpUpdateQueue(write_xmp);
}
}
diff --git a/src/engine/library/commands.hpp b/src/engine/library/commands.hpp
index 527cf51..7db756c 100644
--- a/src/engine/library/commands.hpp
+++ b/src/engine/library/commands.hpp
@@ -65,7 +65,7 @@ public:
static void cmdUpdateLabel(const Library::Ptr & lib,
eng::library_id_t label_id, const std::string & name,
const std::string & color);
- static void cmdProcessXmpUpdateQueue(const Library::Ptr & lib);
+ static void cmdProcessXmpUpdateQueue(const Library::Ptr & lib, bool write_xmp);
};
}
diff --git a/src/libraryclient/clientimpl.cpp b/src/libraryclient/clientimpl.cpp
index ea4cfb4..4ed1884 100644
--- a/src/libraryclient/clientimpl.cpp
+++ b/src/libraryclient/clientimpl.cpp
@@ -170,11 +170,11 @@ tid_t ClientImpl::updateLabel(eng::library_id_t label_id, const std::string & ne
}
-tid_t ClientImpl::processXmpUpdateQueue()
+tid_t ClientImpl::processXmpUpdateQueue(bool write_xmp)
{
tid_t id = LibraryClient::newTid();
Op::Ptr op(new Op(id, boost::bind(&Commands::cmdProcessXmpUpdateQueue,
- _1)));
+ _1, write_xmp)));
m_localLibrary->schedule(op);
return id;
}
diff --git a/src/libraryclient/clientimpl.hpp b/src/libraryclient/clientimpl.hpp
index 887878b..28d63c3 100644
--- a/src/libraryclient/clientimpl.hpp
+++ b/src/libraryclient/clientimpl.hpp
@@ -56,7 +56,7 @@ public:
eng::tid_t updateLabel(eng::library_id_t id, const std::string & new_name,
const std::string & new_color);
- eng::tid_t processXmpUpdateQueue();
+ eng::tid_t processXmpUpdateQueue(bool write_xmp);
eng::tid_t importFromDirectory(const std::string & dir, bool manage);
diff --git a/src/libraryclient/libraryclient.cpp b/src/libraryclient/libraryclient.cpp
index 3ba0c40..f09d9c5 100644
--- a/src/libraryclient/libraryclient.cpp
+++ b/src/libraryclient/libraryclient.cpp
@@ -122,9 +122,9 @@ eng::tid_t LibraryClient::updateLabel(library_id_t id, const std::string & new_n
return m_pImpl->updateLabel(id, new_name, new_color);
}
-eng::tid_t LibraryClient::processXmpUpdateQueue()
+eng::tid_t LibraryClient::processXmpUpdateQueue(bool write_xmp)
{
- return m_pImpl->processXmpUpdateQueue();
+ return m_pImpl->processXmpUpdateQueue(write_xmp);
}
void LibraryClient::importFromDirectory(const std::string & dir, bool manage)
diff --git a/src/libraryclient/libraryclient.hpp b/src/libraryclient/libraryclient.hpp
index 01f9dc1..e5022c0 100644
--- a/src/libraryclient/libraryclient.hpp
+++ b/src/libraryclient/libraryclient.hpp
@@ -1,7 +1,7 @@
/*
* niepce - libraryclient/libraryclient.hpp
*
- * Copyright (C) 2007-2009 Hubert Figuiere
+ * Copyright (C) 2007-2009,2012 Hubert Figuiere
*
* 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
@@ -78,7 +78,7 @@ public:
const std::string & new_color);
/** tell to process the Xmp update Queue */
- eng::tid_t processXmpUpdateQueue();
+ eng::tid_t processXmpUpdateQueue(bool write_xmp);
/** Import files from a directory
* @param dir the directory
diff --git a/src/niepce/ui/dialogs/preferences.ui b/src/niepce/ui/dialogs/preferences.ui
index 3140fcc..6bf8c6e 100644
--- a/src/niepce/ui/dialogs/preferences.ui
+++ b/src/niepce/ui/dialogs/preferences.ui
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <!-- interface-requires gtk+ 2.12 -->
+ <!-- interface-requires gtk+ 3.0 -->
<object class="GtkDialog" id="preferences">
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -69,6 +69,7 @@
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
+ <property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
@@ -78,6 +79,38 @@
<property name="height">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="write_xmp_checkbutton">
+ <property name="label" translatable="yes">Write XMP automatically (not recommended)</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">2</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</object>
</child>
<child type="tab">
@@ -113,6 +146,27 @@
<property name="height">1</property>
</packing>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</object>
<packing>
<property name="position">1</property>
diff --git a/src/niepce/ui/dialogs/preferencesdialog.cpp b/src/niepce/ui/dialogs/preferencesdialog.cpp
index c427dce..4921538 100644
--- a/src/niepce/ui/dialogs/preferencesdialog.cpp
+++ b/src/niepce/ui/dialogs/preferencesdialog.cpp
@@ -42,9 +42,10 @@ void PreferencesDialog::setup_widget()
add_header(_("Preferences"));
- Gtk::CheckButton * theme_checkbutton = NULL;
- Gtk::CheckButton * reopen_checkbutton = NULL;
- fwk::DataBinderPool * binder_pool = new fwk::DataBinderPool();
+ Gtk::CheckButton* theme_checkbutton = NULL;
+ Gtk::CheckButton* reopen_checkbutton = NULL;
+ Gtk::CheckButton* write_xmp_checkbutton = NULL;
+ fwk::DataBinderPool* binder_pool = new fwk::DataBinderPool();
gtkDialog().signal_hide().connect(boost::bind(&fwk::DataBinderPool::destroy,
binder_pool));
@@ -54,15 +55,20 @@ void PreferencesDialog::setup_widget()
theme_checkbutton->set_active(fwk::Application::app()
->get_use_dark_theme());
theme_checkbutton->signal_toggled().connect(
- boost::bind(&fwk::Application::set_use_dark_theme,
- fwk::Application::app(),
- theme_checkbutton->property_active()));
+ boost::bind(&fwk::Application::set_use_dark_theme,
+ fwk::Application::app(),
+ theme_checkbutton->property_active()));
builder()->get_widget("reopen_checkbutton", reopen_checkbutton);
binder_pool->add_binder(new fwk::ConfigDataBinder<bool>(
- reopen_checkbutton->property_active(),
- fwk::Application::app()->config(),
- "reopen_last_library"));
+ reopen_checkbutton->property_active(),
+ fwk::Application::app()->config(),
+ "reopen_last_library"));
+ builder()->get_widget("write_xmp_checkbutton", write_xmp_checkbutton);
+ binder_pool->add_binder(new fwk::ConfigDataBinder<bool>(
+ write_xmp_checkbutton->property_active(),
+ fwk::Application::app()->config(),
+ "write_xmp_automatically"));
m_is_setup = true;
}
diff --git a/src/niepce/ui/imageliststore.cpp b/src/niepce/ui/imageliststore.cpp
index 1dd2950..e94e52f 100644
--- a/src/niepce/ui/imageliststore.cpp
+++ b/src/niepce/ui/imageliststore.cpp
@@ -121,7 +121,9 @@ void ImageListStore::on_lib_notification(const eng::LibNotification &ln)
}
case eng::Library::NOTIFY_XMP_NEEDS_UPDATE:
{
- getLibraryClient()->processXmpUpdateQueue();
+ fwk::Configuration & cfg = fwk::Application::app()->config();
+ int write_xmp = boost::lexical_cast<int>(cfg.getValue("write_xmp_automatically", "0"));
+ getLibraryClient()->processXmpUpdateQueue(write_xmp);
break;
}
default:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]