[niepce] * Implement labels, at least partially.



commit b3105f6a6a080a294b691f2aa589b5c834e5fd84
Author: Hubert Figuiere <hub figuiere net>
Date:   Sat Apr 11 20:20:34 2009 -0400

    	* Implement labels, at least partially.
---
 ChangeLog                            |    4 +
 src/engine/db/Makefile.am            |    1 +
 src/engine/db/label.hpp              |   73 +++++++++
 src/engine/db/library.cpp            |    3 +
 src/engine/db/library.h              |    6 +-
 src/fwk/Makefile.am                  |    8 +
 src/fwk/base/color.cpp               |   51 +++++++
 src/fwk/base/color.hpp               |   46 ++++++
 src/fwk/toolkit/frame.hpp            |    8 +-
 src/niepce/ui/Makefile.am            |    5 +-
 src/niepce/ui/dialogs/editlabels.cpp |   72 +++++++++
 src/niepce/ui/dialogs/editlabels.hpp |   57 +++++++
 src/niepce/ui/dialogs/editlabels.ui  |  271 ++++++++++++++++++++++++++++++++++
 src/niepce/ui/niepcewindow.cpp       |   28 +++-
 src/niepce/ui/niepcewindow.hpp       |    4 +
 15 files changed, 623 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f9459d2..427a0cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-04-11  Hubert Figuiere  <hub figuiere net>
+
+	* Implement labels, at least partially.
+
 2009-04-09  Hubert Figuiere  <hub figuiere net>
 
 	* src/fwk/toolkit/mimetype.cpp: Check boost version
diff --git a/src/engine/db/Makefile.am b/src/engine/db/Makefile.am
index 65bdcfe..922120e 100644
--- a/src/engine/db/Makefile.am
+++ b/src/engine/db/Makefile.am
@@ -31,6 +31,7 @@ noinst_HEADERS = library.h
 libniepcedb_a_SOURCES = library.cpp \
 	libfile.h libfile.cpp \
 	libfolder.h \
+	label.hpp \
 	libmetadata.h libmetadata.cpp \
 	keyword.h keyword.cpp \
 	storage.h storage.cpp \
diff --git a/src/engine/db/label.hpp b/src/engine/db/label.hpp
new file mode 100644
index 0000000..85b0791
--- /dev/null
+++ b/src/engine/db/label.hpp
@@ -0,0 +1,73 @@
+/*
+ * niepce - engine/db/label.hpp
+ *
+ * Copyright (C) 2009 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
+ * the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __NIEPCE_DB_LABEL_HPP__
+#define __NIEPCE_DB_LABEL_HPP__
+
+#include <string>
+#include <vector>
+
+#include <tr1/memory>
+
+#include "fwk/base/color.hpp"
+
+namespace eng {
+
+/** represent a label assigned to a library object
+ * There shouldn't be much instances of this.
+ */
+class Label
+{
+public:
+    typedef std::tr1::shared_ptr<Label> Ptr;
+    typedef std::vector<Ptr> List;
+
+    Label(int _id, const std::string & _label, const std::string & _colorstring)
+        : m_id(_id), m_label(_label)
+        , m_color(_colorstring)
+        {
+        }
+		
+    int id() const
+        { return m_id; }
+		const std::string & label() 
+        { return m_label; }
+    void set_label(const std::string & l)
+        { m_label = l; }
+    const fwk::RgbColor color() const
+        { return m_color; }
+private:
+    int              m_id;
+    std::string      m_label;
+    fwk::RgbColor    m_color;
+};
+
+}
+
+#endif
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0))
+  indent-tabs-mode:nil
+  fill-column:80
+  End:
+*/
diff --git a/src/engine/db/library.cpp b/src/engine/db/library.cpp
index bfc313c..6177e3a 100644
--- a/src/engine/db/library.cpp
+++ b/src/engine/db/library.cpp
@@ -140,6 +140,8 @@ bool Library::_initDb()
                               " keyword TEXT, parent_id INTEGER)");
     SQLStatement keywordingTable("CREATE TABLE keywording (file_id INTEGER,"
                                  " keyword_id INTEGER)");
+    SQLStatement labelTable("CREATE TABLE labels (id INTEGER PRIMARY KEY,"
+                            " name TEXT, color TEXT)");
     SQLStatement xmpUpdateQueueTable("CREATE TABLE xmp_update_queue "
                                      " (id INTEGER UNIQUE)");
 //		SQLStatement collsTable("CREATE TABLE collections (id INTEGER PRIMARY KEY,"
@@ -167,6 +169,7 @@ bool Library::_initDb()
     m_dbdrv->execute_statement(fsFileTable);
     m_dbdrv->execute_statement(keywordTable);
     m_dbdrv->execute_statement(keywordingTable);
+    m_dbdrv->execute_statement(labelTable);
     m_dbdrv->execute_statement(xmpUpdateQueueTable);
 //		m_dbdrv->execute_statement(collsTable);
 //		m_dbdrv->execute_statement(collectingTable);
diff --git a/src/engine/db/library.h b/src/engine/db/library.h
index 1bb69db..9e69a6a 100644
--- a/src/engine/db/library.h
+++ b/src/engine/db/library.h
@@ -40,7 +40,7 @@
 
 // The database schema version. Increase at each change.
 // Some will be persistent and have a conversion TBD.
-#define DB_SCHEMA_VERSION 2
+#define DB_SCHEMA_VERSION 3
 
 namespace db {
 
@@ -58,8 +58,8 @@ namespace db {
 			NOTIFY_FOLDER_CONTENT_QUERIED,
 			NOTIFY_KEYWORD_CONTENT_QUERIED,
 			NOTIFY_METADATA_QUERIED,
-            NOTIFY_METADATA_CHANGED,
-            NOTIFY_XMP_NEEDS_UPDATE,
+      NOTIFY_METADATA_CHANGED,
+      NOTIFY_XMP_NEEDS_UPDATE,
 			NOTIFY_FOLDER_COUNTED
 		} NotifyType;
 
diff --git a/src/fwk/Makefile.am b/src/fwk/Makefile.am
index cfbc4fa..d3d2f1b 100644
--- a/src/fwk/Makefile.am
+++ b/src/fwk/Makefile.am
@@ -1 +1,9 @@
 SUBDIRS = utils toolkit
+
+
+INCLUDES = -I$(top_srcdir)/src
+
+noinst_LIBRARIES = libfwk.a
+
+
+libfwk_a_SOURCES = base/color.hpp base/color.cpp
\ No newline at end of file
diff --git a/src/fwk/base/color.cpp b/src/fwk/base/color.cpp
new file mode 100644
index 0000000..47e5390
--- /dev/null
+++ b/src/fwk/base/color.cpp
@@ -0,0 +1,51 @@
+
+
+#include <vector>
+
+#include <boost/algorithm/string/classification.hpp>
+#include <boost/algorithm/string/split.hpp>
+#include <boost/format.hpp>
+#include <boost/lexical_cast.hpp>
+
+#include "fwk/base/color.hpp"
+
+namespace fwk {
+
+
+  RgbColor::RgbColor(value_type r, value_type g, value_type b)
+  {
+    at(0) = r;
+    at(1) = g;
+    at(2) = b;
+  }
+
+
+  RgbColor::RgbColor(const std::string & s)
+  {
+    std::vector<std::string> components;
+    boost::split(components, s, boost::is_any_of(" "));
+    if(components.size() >= 3) {
+      try {
+        for(int i = 0; i < 3; ++i) {
+          at(i) = boost::lexical_cast<value_type>(components[i]);
+        }
+        return;
+      }
+      catch(...) {
+
+      }
+    }
+    // fallback in case of failure
+    at(0) = 0;
+    at(1) = 0;
+    at(2) = 0;      
+  }
+
+
+  std::string RgbColor::to_string() const
+  {
+    return str(boost::format("%1% %2% %3%") % at(0) % at(1) % at(2));
+  }
+
+
+}
diff --git a/src/fwk/base/color.hpp b/src/fwk/base/color.hpp
new file mode 100644
index 0000000..d6a3462
--- /dev/null
+++ b/src/fwk/base/color.hpp
@@ -0,0 +1,46 @@
+/*
+ * niepce - fwk/base/color.hpp
+ *
+ * Copyright (C) 2009 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
+ * the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+
+
+#ifndef __FWK_BASE_COLOR_HPP_
+#define __FWK_BASE_COLOR_HPP_
+
+#include <string>
+#include <tr1/array>
+
+namespace fwk {
+
+  /** A RgbColor tuple (3 components, 8bpp)
+   *  To be used only for UI.
+   */
+  class RgbColor
+    : public std::tr1::array<uint8_t, 3>
+  {
+  public:
+    RgbColor(value_type r = 0, value_type g = 0, value_type b = 0);
+    RgbColor(const std::string & );
+    
+    std::string to_string() const;
+  };
+
+}
+
+
+#endif
diff --git a/src/fwk/toolkit/frame.hpp b/src/fwk/toolkit/frame.hpp
index b2e3c16..059c84d 100644
--- a/src/fwk/toolkit/frame.hpp
+++ b/src/fwk/toolkit/frame.hpp
@@ -45,7 +45,13 @@ public:
 		Frame(const std::string & gladeFile, const Glib::ustring & widgetName,
           const std::string & layout_cfg_key = "");
 		Frame(const std::string & layout_cfg_key = "");
-		~Frame();
+		virtual ~Frame();
+
+    /** convenience to return the Frame::Ptr from this */
+    Ptr shared_frame_ptr()
+        {
+            return boost::static_pointer_cast<Frame>(shared_from_this());
+        }
 
 		Gtk::Window & gtkWindow()
         {
diff --git a/src/niepce/ui/Makefile.am b/src/niepce/ui/Makefile.am
index d1473f6..886a0ff 100644
--- a/src/niepce/ui/Makefile.am
+++ b/src/niepce/ui/Makefile.am
@@ -3,7 +3,9 @@
 DIST_SUBDIRS = thumb-view dialogs
 
 gladefiles = dialogs/preferences.ui \
-	dialogs/importdialog.ui
+	dialogs/importdialog.ui \
+	dialogs/editlabels.ui \
+	$(NULL)
 
 gladedir = @datarootdir@/niepce/glade/
 glade_DATA = $(gladefiles)
@@ -31,6 +33,7 @@ libniepceui_a_SOURCES = niepcewindow.hpp niepcewindow.cpp \
 	imageliststore.h imageliststore.cpp\
 	workspacecontroller.h workspacecontroller.cpp \
 	metadatapanecontroller.hpp metadatapanecontroller.cpp \
+	dialogs/editlabels.hpp dialogs/editlabels.cpp \
 	dialogs/importdialog.hpp dialogs/importdialog.cpp \
 	dialogs/preferencesdialog.hpp dialogs/preferencesdialog.cpp \
 	selectioncontroller.h selectioncontroller.cpp \
diff --git a/src/niepce/ui/dialogs/editlabels.cpp b/src/niepce/ui/dialogs/editlabels.cpp
new file mode 100644
index 0000000..74cc14a
--- /dev/null
+++ b/src/niepce/ui/dialogs/editlabels.cpp
@@ -0,0 +1,72 @@
+/*
+ * niepce - niepce/ui/dialogs/editlabels.hpp
+ *
+ * Copyright (C) 2009 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
+ * the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include <boost/format.hpp>
+
+#include <gtkmm/entry.h>
+#include <gtkmm/label.h>
+
+#include "editlabels.hpp"
+
+
+namespace ui {
+
+EditLabels::EditLabels(const eng::Label::List & labels)
+    : fwk::Dialog(GLADEDIR"editlabels.ui", "editLabels")
+    , m_labels(labels)
+{
+}
+
+
+void EditLabels::setup_widget()
+{
+    Glib::RefPtr<Gtk::Builder> _builder = builder();
+    const char * color_fmt = "color%1%";
+    const char * value_fmt = "value%1%";
+    for(size_t i = 0; i < 5; i++) {
+        if(m_labels.size() <= i) {
+            break;
+        }
+        Gtk::Label *colorlbl;
+        Gtk::Entry *labelentry;
+        _builder->get_widget(str(boost::format(color_fmt) % (i+1)), colorlbl);
+        _builder->get_widget(str(boost::format(value_fmt) % (i+1)), labelentry);
+        labelentry->set_text(m_labels[i]->label());
+        labelentry->signal_changed().connect(
+            sigc::bind(sigc::mem_fun(*this, &EditLabels::label_name_changed), labelentry, i+1));
+    }
+}
+
+
+void EditLabels::label_name_changed(Gtk::Entry *w, size_t idx)
+{
+    m_labels[idx]->set_label(w->get_text());
+}
+
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0))
+  indent-tabs-mode:nil
+  fill-column:80
+  End:
+*/
+}
diff --git a/src/niepce/ui/dialogs/editlabels.hpp b/src/niepce/ui/dialogs/editlabels.hpp
new file mode 100644
index 0000000..a2d2f1d
--- /dev/null
+++ b/src/niepce/ui/dialogs/editlabels.hpp
@@ -0,0 +1,57 @@
+/*
+ * niepce - niepce/ui/dialogs/editlabels.hpp
+ *
+ * Copyright (C) 2009 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
+ * the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __UI_EDITLABELS_HPP__
+#define __UI_EDITLABELS_HPP__
+
+#include <gtkmm/label.h>
+
+#include "engine/db/label.hpp"
+#include "fwk/toolkit/dialog.hpp"
+
+namespace ui {
+
+
+class EditLabels
+    : public fwk::Dialog
+{
+public:
+    typedef boost::shared_ptr<EditLabels> Ptr;
+    EditLabels(const eng::Label::List &);
+
+    virtual void setup_widget();
+private:
+    void label_name_changed(Gtk::Entry *, size_t idx);
+    eng::Label::List m_labels;
+};
+
+
+}
+
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0))
+  indent-tabs-mode:nil
+  fill-column:80
+  End:
+*/
+#endif
diff --git a/src/niepce/ui/dialogs/editlabels.ui b/src/niepce/ui/dialogs/editlabels.ui
new file mode 100644
index 0000000..7adc31f
--- /dev/null
+++ b/src/niepce/ui/dialogs/editlabels.ui
@@ -0,0 +1,271 @@
+<?xml version="1.0"?>
+<interface>
+  <!-- interface-requires gtk+ 2.12 -->
+  <!-- interface-naming-policy toplevel-contextual -->
+  <object class="GtkDialog" id="editLabels">
+    <property name="border_width">5</property>
+    <property name="type_hint">normal</property>
+    <property name="has_separator">False</property>
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="dialog-vbox1">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child>
+          <object class="GtkFrame" id="frame1">
+            <property name="visible">True</property>
+            <property name="label_xalign">0</property>
+            <property name="shadow_type">none</property>
+            <child>
+              <object class="GtkAlignment" id="alignment1">
+                <property name="visible">True</property>
+                <property name="left_padding">12</property>
+                <child>
+                  <object class="GtkTable" id="table2">
+                    <property name="visible">True</property>
+                    <property name="n_rows">5</property>
+                    <property name="n_columns">3</property>
+                    <property name="column_spacing">8</property>
+                    <property name="row_spacing">8</property>
+                    <child>
+                      <object class="GtkLabel" id="label1">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Label _6</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">value1</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label2">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Label _7</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">value2</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>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label3">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Label _8</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">value3</property>
+                      </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>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label4">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Label _9</property>
+                        <property name="use_markup">True</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">value4</property>
+                      </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>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="value1">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">&#x25CF;</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">2</property>
+                        <property name="right_attach">3</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="value2">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">&#x25CF;</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">2</property>
+                        <property name="right_attach">3</property>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="value3">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">&#x25CF;</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">2</property>
+                        <property name="right_attach">3</property>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">3</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="value4">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">&#x25CF;</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">2</property>
+                        <property name="right_attach">3</property>
+                        <property name="top_attach">3</property>
+                        <property name="bottom_attach">4</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label5">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">Label _10</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">value5</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>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="value5">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">&#x2022;</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">2</property>
+                        <property name="right_attach">3</property>
+                        <property name="top_attach">4</property>
+                        <property name="bottom_attach">5</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="color1">
+                        <property name="visible">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="color2">
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="color3">
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">3</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="color4">
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="top_attach">3</property>
+                        <property name="bottom_attach">4</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="color5">
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="top_attach">4</property>
+                        <property name="bottom_attach">5</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child type="label">
+              <object class="GtkLabel" id="dialog_title">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">&lt;b&gt;Edit Labels&lt;/b&gt;</property>
+                <property name="use_markup">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area1">
+            <property name="visible">True</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="button2">
+                <property name="label" translatable="yes">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="button1">
+                <property name="label" translatable="yes">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="1">button2</action-widget>
+      <action-widget response="0">button1</action-widget>
+    </action-widgets>
+  </object>
+</interface>
diff --git a/src/niepce/ui/niepcewindow.cpp b/src/niepce/ui/niepcewindow.cpp
index 1c79423..d420c87 100644
--- a/src/niepce/ui/niepcewindow.cpp
+++ b/src/niepce/ui/niepcewindow.cpp
@@ -47,6 +47,7 @@
 #include "librarymainviewcontroller.h"
 #include "dialogs/importdialog.hpp"
 #include "dialogs/preferencesdialog.hpp"
+#include "dialogs/editlabels.hpp"
 #include "selectioncontroller.h"
 
 using libraryclient::LibraryClient;
@@ -324,7 +325,7 @@ void NiepceWindow::init_actions()
                           boost::bind(&SelectionController::set_label, 
                                       BIND_SHARED_PTR(SelectionController, m_selection_controller)
                                       , 4));
-    m_refActionGroup->add(Gtk::Action::create("EditLabels", _("Edit Labels...")),
+    m_refActionGroup->add(Gtk::Action::create("EditLabels", _("_Edit Labels...")),
                           sigc::mem_fun(*this, &NiepceWindow::on_action_edit_labels));
     
     m_refActionGroup->add(Gtk::Action::create("SetRating", _("Set _Rating")));
@@ -397,8 +398,7 @@ void NiepceWindow::on_action_file_import()
 	
     ImportDialog::Ptr import_dialog(new ImportDialog());
 
-    result = import_dialog->run_modal(
-        boost::static_pointer_cast<fwk::Frame>(shared_from_this()));
+    result = import_dialog->run_modal(shared_frame_ptr());
     switch(result) {
     case 0:
     {
@@ -411,7 +411,6 @@ void NiepceWindow::on_action_file_import()
             std::for_each(to_import.begin(), to_import.end(),
                           boost::bind(&LibraryClient::importFromDirectory,
                                       m_libClient, _1, false));
-//            m_libClient->importFromDirectory(to_import, false);
         }
         break;
     }
@@ -488,11 +487,8 @@ void NiepceWindow::on_preferences()
     DBG_OUT("on_preferences");
 
     fwk::Dialog::Ptr dlg(new PreferencesDialog());
-    dlg->run_modal(boost::static_pointer_cast<Frame>(shared_from_this()));
+    dlg->run_modal(shared_frame_ptr());
 
-//    show_modal_dialog(GLADEDIR"preferences.ui", "preferences",
-//                      boost::bind(&NiepceWindow::preference_dialog_setup,
-//                                  this, _1, _2));
     DBG_OUT("end on_preferences");
 }
 
@@ -507,11 +503,25 @@ void NiepceWindow::open_library(const std::string & libMoniker)
 void NiepceWindow::on_action_edit_labels()
 {
     DBG_OUT("edit labels");
+    // get the labels.
+    EditLabels::Ptr dlg(new EditLabels(get_labels()));
+    int result = dlg->run_modal(shared_frame_ptr());
+    switch(result) {
+    case 0:
+        // ok
+        // update the labels.
+        break;
+    case 1:
+        // cancel
+        break;
+    default:
+        break;
+    }
 }
 
 void NiepceWindow::set_title(const std::string & title)
 {
-    Frame::set_title(std::string(_("Niepce Digital - ")) + title);
+    Frame::set_title(_("Niepce Digital - ") + title);
 }
 
 
diff --git a/src/niepce/ui/niepcewindow.hpp b/src/niepce/ui/niepcewindow.hpp
index f93a2a6..86ea4fa 100644
--- a/src/niepce/ui/niepcewindow.hpp
+++ b/src/niepce/ui/niepcewindow.hpp
@@ -33,6 +33,7 @@
 #include "fwk/toolkit/frame.hpp"
 #include "fwk/toolkit/notificationcenter.hpp"
 #include "fwk/toolkit/configdatabinder.hpp"
+#include "engine/db/label.hpp"
 #include "libraryclient/libraryclient.h"
 #include "ui/librarymainviewcontroller.h"
 #include "ui/workspacecontroller.h"
@@ -79,6 +80,8 @@ private:
     void init_actions();
 
     void open_library(const std::string & libMoniker);
+    eng::Label::List &   get_labels()
+        { return m_labels; }
 		
     fwk::NotificationCenter::Ptr  m_lib_notifcenter;
 
@@ -91,6 +94,7 @@ private:
     Gtk::Statusbar                 m_statusBar;
     Glib::RefPtr<Gtk::ActionGroup> m_refActionGroup;
     libraryclient::LibraryClient::Ptr m_libClient;
+    eng::Label::List               m_labels;
     // connections
     boost::signals::scoped_connection m_undostate_conn;
     boost::signals::scoped_connection m_redostate_conn;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]