[niepce] Various cleanup



commit 33d249754a682cf543eae1490db1033653f437c0
Author: Hubert Figuière <hub figuiere net>
Date:   Fri May 12 22:08:20 2017 -0400

    Various cleanup
    
    -LibraryClient::Ptr -> LibraryClientPtr
    -Use unique_ptr<> for ClientImpl and UIDataProvider
    -Carry a reference to the shell in the LibraryCellRenderer
    -Get the UIDataProvider from the IModuleShell

 src/engine/db/storage.hpp             |   17 ++++++-----
 src/engine/library/commands.cpp       |   51 ++++++++++++++++-----------------
 src/fwk/toolkit/command.hpp           |    4 +-
 src/libraryclient/clientimpl.cpp      |   10 ++----
 src/libraryclient/clientimpl.hpp      |    6 ++--
 src/libraryclient/libraryclient.cpp   |    4 +--
 src/libraryclient/libraryclient.hpp   |   41 +++++++++++++-------------
 src/niepce/ui/dialogs/editlabels.cpp  |    4 +-
 src/niepce/ui/dialogs/editlabels.hpp  |   10 +++---
 src/niepce/ui/filmstripcontroller.cpp |    8 +++--
 src/niepce/ui/filmstripcontroller.hpp |    5 ++-
 src/niepce/ui/gridviewmodule.cpp      |    8 ++---
 src/niepce/ui/gridviewmodule.hpp      |    1 -
 src/niepce/ui/imageliststore.cpp      |    4 +-
 src/niepce/ui/imageliststore.hpp      |    2 +-
 src/niepce/ui/imoduleshell.hpp        |   10 +++++-
 src/niepce/ui/librarycellrenderer.cpp |    8 ++--
 src/niepce/ui/librarycellrenderer.hpp |   12 +++----
 src/niepce/ui/moduleshell.hpp         |   11 ++++--
 src/niepce/ui/niepcewindow.cpp        |    8 +++--
 src/niepce/ui/niepcewindow.hpp        |    4 +-
 src/niepce/ui/selectioncontroller.cpp |    4 +-
 src/niepce/ui/selectioncontroller.hpp |    2 +-
 src/niepce/ui/thumbstripview.cpp      |   11 ++++---
 src/niepce/ui/thumbstripview.hpp      |    4 ++-
 src/niepce/ui/workspacecontroller.cpp |    7 ++--
 src/niepce/ui/workspacecontroller.hpp |    2 +-
 27 files changed, 134 insertions(+), 124 deletions(-)
---
diff --git a/src/engine/db/storage.hpp b/src/engine/db/storage.hpp
index 55116c2..4271052 100644
--- a/src/engine/db/storage.hpp
+++ b/src/engine/db/storage.hpp
@@ -27,16 +27,17 @@
 
 namespace eng {
 
-       /** @brief the interface for a storage */
-       class Storage
-       {
-       public:
-               typedef std::shared_ptr<Storage> Ptr;
+/** @brief the interface for a storage */
+class Storage
+{
+public:
 
-               virtual ~Storage();
+    virtual ~Storage();
 
-               virtual bool fetchKeywordsForFile(int file, Keyword::IdList &keywords) = 0;
-       };
+    virtual bool fetchKeywordsForFile(int file, Keyword::IdList &keywords) = 0;
+};
+
+typedef std::shared_ptr<Storage> StoragePtr;
 
 }
 
diff --git a/src/engine/library/commands.cpp b/src/engine/library/commands.cpp
index e36cff2..bf834cd 100644
--- a/src/engine/library/commands.cpp
+++ b/src/engine/library/commands.cpp
@@ -39,8 +39,8 @@ namespace eng {
 
 void Commands::cmdListAllKeywords(const Library::Ptr & lib)
 {
-    Keyword::ListPtr l( new Keyword::List );
-    lib->getAllKeywords( l );
+    Keyword::ListPtr l(new Keyword::List);
+    lib->getAllKeywords(l);
     /////
     // notify folder added l
     lib->notify(Library::NotifyType::ADDED_KEYWORDS, boost::any(l));
@@ -48,16 +48,16 @@ void Commands::cmdListAllKeywords(const Library::Ptr & lib)
 
 void Commands::cmdListAllFolders(const Library::Ptr & lib)
 {
-    LibFolder::ListPtr l( new LibFolder::List );
-    lib->getAllFolders( l );
+    LibFolder::ListPtr l(new LibFolder::List);
+    lib->getAllFolders(l);
     /////
     // notify folder added l
     lib->notify(Library::NotifyType::ADDED_FOLDERS, boost::any(l));
 }
 
 void Commands::cmdImportFile(const Library::Ptr & lib,
-                              const std::string & file_path,
-                              bool manage)
+                             const std::string & file_path,
+                             bool manage)
 {
     DBG_ASSERT(!manage, "managing file is currently unsupported");
 
@@ -66,8 +66,7 @@ void Commands::cmdImportFile(const Library::Ptr & lib,
 
     std::string folder = fwk::path_dirname(file_path);
 
-    LibFolder::Ptr pf;
-    pf = lib->getFolder(folder);
+    LibFolder::Ptr pf = lib->getFolder(folder);
     if(!pf) {
         pf = lib->addFolder(folder);
         LibFolder::ListPtr l(new LibFolder::List);
@@ -80,16 +79,15 @@ void Commands::cmdImportFile(const Library::Ptr & lib,
                 boost::any());
 }
 
-void Commands::cmdImportFiles(const Library::Ptr & lib, 
-                              const std::string & folder, 
+void Commands::cmdImportFiles(const Library::Ptr & lib,
+                              const std::string & folder,
                               const FileList::Ptr & files, bool manage)
 {
     DBG_ASSERT(!manage, "managing file is currently unsupported");
 
     FileBundle::ListPtr bundles = FileBundle::filter_bundles(files);
 
-    LibFolder::Ptr pf;
-    pf = lib->getFolder(folder);
+    LibFolder::Ptr pf = lib->getFolder(folder);
     if(!pf) {
         pf = lib->addFolder(folder);
         LibFolder::ListPtr l( new LibFolder::List );
@@ -106,27 +104,28 @@ void Commands::cmdImportFiles(const Library::Ptr & lib,
 }
 
 
-void Commands::cmdQueryFolderContent(const Library::Ptr & lib, 
+void Commands::cmdQueryFolderContent(const Library::Ptr & lib,
                                      library_id_t folder_id)
 {
     LibFile::ListPtr fl(new LibFile::List());
     lib->getFolderContent(folder_id, fl);
-    lib->notify(Library::NotifyType::FOLDER_CONTENT_QUERIED, boost::any(fl));          
+    lib->notify(Library::NotifyType::FOLDER_CONTENT_QUERIED, boost::any(fl));
 }
 
-void Commands::cmdCountFolder(const Library::Ptr & lib, 
+void Commands::cmdCountFolder(const Library::Ptr & lib,
                               eng::library_id_t folder_id)
 {
     int count = lib->countFolder(folder_id);
-    lib->notify(Library::NotifyType::FOLDER_COUNTED, boost::any(std::make_pair(folder_id, count)));
+    lib->notify(Library::NotifyType::FOLDER_COUNTED,
+                boost::any(std::make_pair(folder_id, count)));
 }
 
-void Commands::cmdQueryKeywordContent(const Library::Ptr & lib, 
+void Commands::cmdQueryKeywordContent(const Library::Ptr & lib,
                                       library_id_t keyword_id)
 {
     LibFile::ListPtr fl(new LibFile::List());
     lib->getKeywordContent(keyword_id, fl);
-    lib->notify(Library::NotifyType::KEYWORD_CONTENT_QUERIED, boost::any(fl));         
+    lib->notify(Library::NotifyType::KEYWORD_CONTENT_QUERIED, boost::any(fl));
 }
 
 void Commands::cmdRequestMetadata(const Library::Ptr & lib,
@@ -138,7 +137,7 @@ void Commands::cmdRequestMetadata(const Library::Ptr & lib,
 }
 
 void Commands::cmdSetMetadata(const Library::Ptr & lib,
-                              library_id_t file_id, fwk::PropertyIndex meta, 
+                              library_id_t file_id, fwk::PropertyIndex meta,
                               const fwk::PropertyValue & value)
 {
     metadata_desc_t m;
@@ -155,17 +154,17 @@ void Commands::cmdWriteMetadata(const Library::Ptr & lib,
     lib->writeMetaData(file_id);
 }
 
-void Commands::cmdMoveFileToFolder(const Library::Ptr & lib, 
+void Commands::cmdMoveFileToFolder(const Library::Ptr & lib,
                                    library_id_t file_id, library_id_t from_folder_id,
                                    library_id_t to_folder_id)
 {
     if(lib->moveFileToFolder(file_id, to_folder_id)) {
-        std::pair<library_id_t, library_id_t> move;
-        move.first = file_id;
-        move.second = to_folder_id;
-        lib->notify(Library::NotifyType::FILE_MOVED, boost::any(move));
-        lib->notify(Library::NotifyType::FOLDER_COUNT_CHANGE, boost::any(std::make_pair(from_folder_id, 
-1)));
-        lib->notify(Library::NotifyType::FOLDER_COUNT_CHANGE, boost::any(std::make_pair(to_folder_id, 1)));
+        lib->notify(Library::NotifyType::FILE_MOVED,
+                    boost::any(std::make_pair(file_id, to_folder_id)));
+        lib->notify(Library::NotifyType::FOLDER_COUNT_CHANGE,
+                    boost::any(std::make_pair(from_folder_id, -1)));
+        lib->notify(Library::NotifyType::FOLDER_COUNT_CHANGE,
+                    boost::any(std::make_pair(to_folder_id, 1)));
     }
 }
 
diff --git a/src/fwk/toolkit/command.hpp b/src/fwk/toolkit/command.hpp
index fc2b1bc..6964e1c 100644
--- a/src/fwk/toolkit/command.hpp
+++ b/src/fwk/toolkit/command.hpp
@@ -47,7 +47,7 @@ public:
         , m_undo(_undo)
         {
         }
-        
+
     virtual void undo() override
         {
             m_undo(m_argstorage);
@@ -75,7 +75,7 @@ public:
         , m_undo(_undo)
         {
         }
-        
+
     virtual void undo() override
         {
             m_undo();
diff --git a/src/libraryclient/clientimpl.cpp b/src/libraryclient/clientimpl.cpp
index d07df06..355e3d4 100644
--- a/src/libraryclient/clientimpl.cpp
+++ b/src/libraryclient/clientimpl.cpp
@@ -32,24 +32,22 @@ using eng::tid_t;
 
 namespace libraryclient {
 
-ClientImpl *ClientImpl::makeClientImpl(const fwk::Moniker & moniker,
-                                       const fwk::NotificationCenter::Ptr & nc)
+std::unique_ptr<ClientImpl> ClientImpl::makeClientImpl(const fwk::Moniker & moniker,
+                                                       const fwk::NotificationCenter::Ptr & nc)
 {
-    return new ClientImpl(moniker, nc);
+    return std::unique_ptr<ClientImpl>(new ClientImpl(moniker, nc));
 }
 
 ClientImpl::ClientImpl(const fwk::Moniker & moniker, const fwk::NotificationCenter::Ptr & nc)
     : m_moniker(moniker),
-      m_localLibrary(nullptr)
+      m_localLibrary(new LocalLibraryServer(moniker.path(), nc))
 {
     DBG_OUT("creating implementation with moniker %s",
             moniker.c_str());
-    m_localLibrary = new LocalLibraryServer(moniker.path(), nc);
 }
 
 ClientImpl::~ClientImpl()
 {
-    delete m_localLibrary;
 }
 
 bool ClientImpl::ok() const
diff --git a/src/libraryclient/clientimpl.hpp b/src/libraryclient/clientimpl.hpp
index 89e5a75..286a0b8 100644
--- a/src/libraryclient/clientimpl.hpp
+++ b/src/libraryclient/clientimpl.hpp
@@ -34,8 +34,8 @@ class LocalLibraryServer;
 class ClientImpl
 {
 public:
-    static ClientImpl *makeClientImpl(const fwk::Moniker & moniker,
-                                      const fwk::NotificationCenter::Ptr & nc);
+    static std::unique_ptr<ClientImpl> makeClientImpl(const fwk::Moniker & moniker,
+                                                      const fwk::NotificationCenter::Ptr & nc);
 
     ClientImpl(const fwk::Moniker & moniker, const fwk::NotificationCenter::Ptr & nc);
     virtual ~ClientImpl();
@@ -68,7 +68,7 @@ public:
 
 protected:
     const fwk::Moniker m_moniker;
-    LocalLibraryServer *m_localLibrary;
+    std::unique_ptr<LocalLibraryServer> m_localLibrary;
 private:
     /** do the dirty work of scheduling the op */
     eng::tid_t schedule_op(const eng::Op::function_t & func);
diff --git a/src/libraryclient/libraryclient.cpp b/src/libraryclient/libraryclient.cpp
index 261ec20..c711efe 100644
--- a/src/libraryclient/libraryclient.cpp
+++ b/src/libraryclient/libraryclient.cpp
@@ -31,7 +31,7 @@ namespace libraryclient {
 
 const char * s_thumbcacheDirname = "thumbcache";
 
-LibraryClient::LibraryClient(const fwk::Moniker & moniker, 
+LibraryClient::LibraryClient(const fwk::Moniker & moniker,
                              const fwk::NotificationCenter::Ptr & nc)
     : m_pImpl(ClientImpl::makeClientImpl(moniker, nc))
     , m_thumbnailCache(moniker.path() + "/" + s_thumbcacheDirname, nc)
@@ -42,8 +42,6 @@ LibraryClient::LibraryClient(const fwk::Moniker & moniker,
 
 LibraryClient::~LibraryClient()
 {
-    delete m_pImpl;
-    delete m_uidataprovider;
 }
 
 bool LibraryClient::ok() const
diff --git a/src/libraryclient/libraryclient.hpp b/src/libraryclient/libraryclient.hpp
index fbaf9f9..321ea32 100644
--- a/src/libraryclient/libraryclient.hpp
+++ b/src/libraryclient/libraryclient.hpp
@@ -44,15 +44,14 @@ class LibraryClient
     : public eng::Storage
 {
 public:
-    typedef std::shared_ptr< LibraryClient > Ptr;
-    
+
     LibraryClient(const fwk::Moniker & moniker, const fwk::NotificationCenter::Ptr & nc);
     virtual ~LibraryClient();
     // @return false in case of error.
     bool ok() const;
 
     static eng::tid_t newTid();
-    /** get all the keywords 
+    /** get all the keywords
      * @return transaction ID
      */
     eng::tid_t getAllKeywords();
@@ -60,26 +59,26 @@ public:
      * @return transaction ID
      */
     eng::tid_t getAllFolders();
-    
+
     eng::tid_t queryFolderContent(eng::library_id_t id);
     eng::tid_t queryKeywordContent(eng::library_id_t id);
     eng::tid_t countFolder(eng::library_id_t id);
     eng::tid_t requestMetadata(eng::library_id_t id);
-    
+
     /** set the metadata */
     eng::tid_t setMetadata(eng::library_id_t id, fwk::PropertyIndex meta, const fwk::PropertyValue & value);
     eng::tid_t moveFileToFolder(eng::library_id_t file_id, eng::library_id_t from_folder,
                                 eng::library_id_t to_folder);
     eng::tid_t write_metadata(eng::library_id_t file_id);
-    
+
     /** get all the labels */
     eng::tid_t getAllLabels();
     eng::tid_t createLabel(const std::string & s, const std::string & color);
     eng::tid_t deleteLabel(int id);
     /** update a label */
-    eng::tid_t updateLabel(eng::library_id_t id, const std::string & new_name, 
+    eng::tid_t updateLabel(eng::library_id_t id, const std::string & new_name,
                            const std::string & new_color);
-    
+
     /** tell to process the Xmp update Queue */
     eng::tid_t processXmpUpdateQueue(bool write_xmp);
 
@@ -94,35 +93,37 @@ public:
      * @param manage true if imports have to be managed
      */
     void importFromDirectory(const std::string & dir, bool manage);
-    
+
     eng::ThumbnailCache & thumbnailCache()
         { return m_thumbnailCache; }
-    
+
     /* sync call */
     virtual bool fetchKeywordsForFile(int file, eng::Keyword::IdList &keywords) override;
-    UIDataProvider *getDataProvider() const
+    const std::unique_ptr<UIDataProvider>& getDataProvider() const
         { return m_uidataprovider; }
-    
+
     // state
     eng::library_id_t trash_id() const
         {
            return m_trash_id;
         }
-    void set_trash_id(eng::library_id_t id) 
+    void set_trash_id(eng::library_id_t id)
         {
            m_trash_id = id;
         }
 private:
-    ClientImpl* m_pImpl;
-    
-    eng::ThumbnailCache                    m_thumbnailCache;
-    UIDataProvider *m_uidataprovider;
+    std::unique_ptr<ClientImpl> m_pImpl;
+
+    eng::ThumbnailCache m_thumbnailCache;
+    std::unique_ptr<UIDataProvider> m_uidataprovider;
     eng::library_id_t m_trash_id;
-    
-    LibraryClient(const LibraryClient &);
-    LibraryClient & operator=(const LibraryClient &);
+
+    LibraryClient(const LibraryClient &) = delete;
+    LibraryClient & operator=(const LibraryClient &) = delete;
 };
 
+typedef std::shared_ptr<LibraryClient> LibraryClientPtr;
+
 }
 
 #endif
diff --git a/src/niepce/ui/dialogs/editlabels.cpp b/src/niepce/ui/dialogs/editlabels.cpp
index bef30dc..bf93c21 100644
--- a/src/niepce/ui/dialogs/editlabels.cpp
+++ b/src/niepce/ui/dialogs/editlabels.cpp
@@ -35,11 +35,11 @@
 #include "editlabels.hpp"
 
 
-using libraryclient::LibraryClient;
+using libraryclient::LibraryClientPtr;
 
 namespace ui {
 
-EditLabels::EditLabels(const LibraryClient::Ptr & libclient)
+EditLabels::EditLabels(const LibraryClientPtr & libclient)
     : fwk::Dialog(GLADEDIR"editlabels.ui", "editLabels")
     , m_labels(libclient->getDataProvider()->getLabels())
     , m_lib_client(libclient)
diff --git a/src/niepce/ui/dialogs/editlabels.hpp b/src/niepce/ui/dialogs/editlabels.hpp
index b0f7053..dac3f61 100644
--- a/src/niepce/ui/dialogs/editlabels.hpp
+++ b/src/niepce/ui/dialogs/editlabels.hpp
@@ -39,18 +39,18 @@ class EditLabels
 {
 public:
     typedef std::shared_ptr<EditLabels> Ptr;
-    EditLabels(const libraryclient::LibraryClient::Ptr &);
+    EditLabels(const libraryclient::LibraryClientPtr &);
 
     virtual void setup_widget() override;
 private:
     void label_name_changed(size_t idx);
     void label_colour_changed(size_t idx);
     void update_labels(int /*response*/);
-    const eng::Label::List            & m_labels;
+    const eng::Label::List& m_labels;
     std::array<Gtk::ColorButton*, 5> m_colours;
-    std::array<Gtk::Entry*, 5>   m_entries;
-    std::array<bool, 5>          m_status;
-    libraryclient::LibraryClient::Ptr m_lib_client;
+    std::array<Gtk::Entry*, 5> m_entries;
+    std::array<bool, 5> m_status;
+    libraryclient::LibraryClientPtr m_lib_client;
 };
 
 
diff --git a/src/niepce/ui/filmstripcontroller.cpp b/src/niepce/ui/filmstripcontroller.cpp
index fea5efe..8e3b19c 100644
--- a/src/niepce/ui/filmstripcontroller.cpp
+++ b/src/niepce/ui/filmstripcontroller.cpp
@@ -31,8 +31,10 @@
 
 namespace ui {
 
-FilmStripController::FilmStripController(const Glib::RefPtr<ImageListStore> & store)
-    : m_store(store)
+FilmStripController::FilmStripController(const Glib::RefPtr<ImageListStore> & store,
+                                         const IModuleShell& shell)
+    : m_shell(shell)
+    , m_store(store)
 {
 }
 
@@ -42,7 +44,7 @@ Gtk::Widget * FilmStripController::buildWidget()
         return m_widget;
     }
     DBG_ASSERT(static_cast<bool>(m_store), "m_store NULL");
-    m_thumbview = manage(new ThumbStripView(m_store));
+    m_thumbview = manage(new ThumbStripView(m_store, m_shell));
     GtkWidget *thn = eog_thumb_nav_new(m_thumbview,
                                        EogThumbNavMode::ONE_ROW, true);
     m_thumbview->set_selection_mode(Gtk::SELECTION_SINGLE);
diff --git a/src/niepce/ui/filmstripcontroller.hpp b/src/niepce/ui/filmstripcontroller.hpp
index 7b8e151..1b4e746 100644
--- a/src/niepce/ui/filmstripcontroller.hpp
+++ b/src/niepce/ui/filmstripcontroller.hpp
@@ -32,6 +32,7 @@ namespace Gtk {
 
 namespace ui {
 
+class IModuleShell;
 
 class FilmStripController
        : public fwk::UiController,
@@ -41,7 +42,8 @@ public:
        typedef std::shared_ptr<FilmStripController> Ptr;
        typedef std::weak_ptr<FilmStripController> WeakPtr;
 
-       FilmStripController(const Glib::RefPtr<ImageListStore> & store);
+       FilmStripController(const Glib::RefPtr<ImageListStore>& store,
+                           const IModuleShell& shell);
 
        virtual Gtk::IconView * image_list() override;
        virtual eng::library_id_t get_selected() override;
@@ -50,6 +52,7 @@ public:
        virtual Gtk::Widget * buildWidget() override;
 
 private:
+       const IModuleShell& m_shell;
        Gtk::IconView * m_thumbview;
        Glib::RefPtr<ImageListStore> m_store;
 };
diff --git a/src/niepce/ui/gridviewmodule.cpp b/src/niepce/ui/gridviewmodule.cpp
index 5f50d56..8f3c3d7 100644
--- a/src/niepce/ui/gridviewmodule.cpp
+++ b/src/niepce/ui/gridviewmodule.cpp
@@ -40,13 +40,10 @@ GridViewModule::GridViewModule(const IModuleShell & shell,
                                const Glib::RefPtr<ImageListStore> & store)
   : m_shell(shell)
   , m_model(store)
-  , m_uidataprovider(nullptr)
   , m_librarylistview(nullptr)
   , m_lib_splitview(Gtk::ORIENTATION_HORIZONTAL)
   , m_dock(nullptr)
 {
-    m_uidataprovider = m_shell.getLibraryClient()->getDataProvider();
-    DBG_ASSERT(m_uidataprovider, "provider is NULL");
 }
 
 GridViewModule::~GridViewModule()
@@ -119,8 +116,9 @@ Gtk::Widget * GridViewModule::buildWidget()
       .connect(sigc::mem_fun(*this,  &GridViewModule::on_librarylistview_click));
 
   // the main cell
-  LibraryCellRenderer * libcell = Gtk::manage(new LibraryCellRenderer(m_uidataprovider));
-  libcell->signal_rating_changed.connect(sigc::mem_fun(*this, &GridViewModule::on_rating_changed));
+  LibraryCellRenderer* libcell = Gtk::manage(new LibraryCellRenderer(m_shell));
+  libcell->signal_rating_changed.connect(
+      sigc::mem_fun(*this, &GridViewModule::on_rating_changed));
 
   Glib::RefPtr<Gtk::CellArea> cell_area = m_librarylistview->property_cell_area();
   cell_area->pack_start(*libcell, FALSE);
diff --git a/src/niepce/ui/gridviewmodule.hpp b/src/niepce/ui/gridviewmodule.hpp
index 4bcfe48..4099f64 100644
--- a/src/niepce/ui/gridviewmodule.hpp
+++ b/src/niepce/ui/gridviewmodule.hpp
@@ -84,7 +84,6 @@ private:
 
   const IModuleShell &               m_shell;
   Glib::RefPtr<ImageListStore> m_model;
-  libraryclient::UIDataProvider *m_uidataprovider;
 
   // library split view
   fwk::ImageGridView*          m_librarylistview;
diff --git a/src/niepce/ui/imageliststore.cpp b/src/niepce/ui/imageliststore.cpp
index c72d7da..329bde3 100644
--- a/src/niepce/ui/imageliststore.cpp
+++ b/src/niepce/ui/imageliststore.cpp
@@ -169,11 +169,11 @@ void ImageListStore::on_tnail_notification(const eng::ThumbnailNotification &tn)
     }
 }
 
-libraryclient::LibraryClient::Ptr ImageListStore::getLibraryClient()
+libraryclient::LibraryClientPtr ImageListStore::getLibraryClient()
 {
     ModuleShell::Ptr shell = std::dynamic_pointer_cast<ModuleShell>(m_controller.lock());
     DBG_ASSERT(static_cast<bool>(shell), "parent not a ModuleShell");
-    return     shell->getLibraryClient();
+    return shell->getLibraryClient();
 }
 
 
diff --git a/src/niepce/ui/imageliststore.hpp b/src/niepce/ui/imageliststore.hpp
index a99e862..6cc4be7 100644
--- a/src/niepce/ui/imageliststore.hpp
+++ b/src/niepce/ui/imageliststore.hpp
@@ -77,7 +77,7 @@ protected:
     ImageListStore(const Columns& columns);
 private:
     static Glib::RefPtr<Gdk::Pixbuf> get_loading_icon();
-    libraryclient::LibraryClient::Ptr getLibraryClient();
+    libraryclient::LibraryClientPtr getLibraryClient();
     static bool is_property_interesting(fwk::PropertyIndex idx);
 
     const Columns           & m_columns;
diff --git a/src/niepce/ui/imoduleshell.hpp b/src/niepce/ui/imoduleshell.hpp
index 2b00693..cf72289 100644
--- a/src/niepce/ui/imoduleshell.hpp
+++ b/src/niepce/ui/imoduleshell.hpp
@@ -1,7 +1,7 @@
 /*
  * niepce - ui/imoduleshell.hpp
  *
- * Copyright (C) 2011-2014 Hubert Figuiere
+ * Copyright (C) 2011-2017 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
@@ -21,8 +21,13 @@
 #ifndef _UI_IMODULESHELL_HPP__
 #define _UI_IMODULESHELL_HPP__
 
+#include <memory>
 #include "niepce/ui/selectioncontroller.hpp"
 
+namespace libraryclient {
+class UIDataProvider;
+}
+
 namespace ui {
 
 class IModuleShell
@@ -30,7 +35,8 @@ class IModuleShell
 public:
     virtual ~IModuleShell() {}
     virtual const ui::SelectionController::Ptr & get_selection_controller() const = 0;
-    virtual libraryclient::LibraryClient::Ptr getLibraryClient() const = 0;
+    virtual libraryclient::LibraryClientPtr getLibraryClient() const = 0;
+    virtual const std::unique_ptr<libraryclient::UIDataProvider>& get_ui_data_provider() const = 0;
 };
 
 }
diff --git a/src/niepce/ui/librarycellrenderer.cpp b/src/niepce/ui/librarycellrenderer.cpp
index cf03e35..df4a171 100644
--- a/src/niepce/ui/librarycellrenderer.cpp
+++ b/src/niepce/ui/librarycellrenderer.cpp
@@ -26,6 +26,7 @@
 #include "engine/db/label.hpp"
 #include "libraryclient/uidataprovider.hpp"
 #include "librarycellrenderer.hpp"
+#include "imoduleshell.hpp"
 
 #include <gdkmm/general.h>
 
@@ -37,9 +38,10 @@
 
 namespace ui {
 
-LibraryCellRenderer::LibraryCellRenderer(libraryclient::UIDataProvider *provider)
+LibraryCellRenderer::LibraryCellRenderer(const IModuleShell& shell)
     : Glib::ObjectBase(typeid(LibraryCellRenderer)),
       Gtk::CellRendererPixbuf(),
+      m_shell(shell),
       m_size(160),
       m_pad(16),
       m_drawborder(true),
@@ -47,7 +49,6 @@ LibraryCellRenderer::LibraryCellRenderer(libraryclient::UIDataProvider *provider
       m_drawrating(true),
       m_drawlabel(true),
       m_drawflag(true),
-      m_uiDataProvider(provider),
       m_libfileproperty(*this, "libfile")
 {
     property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
@@ -270,10 +271,9 @@ LibraryCellRenderer::render_vfunc(const Cairo::RefPtr<Cairo::Context>& cr,
 
         int left = drawFormatEmblem(cr, emblem, r);
         if(m_drawlabel) {
-            DBG_ASSERT(m_uiDataProvider, "no UIDataProvider");
             uint32_t label_id = file->label();
             if(label_id != 0) {
-                auto result = m_uiDataProvider->colourForLabel(label_id);
+                auto result = m_shell.get_ui_data_provider()->colourForLabel(label_id);
                 DBG_ASSERT(!result.empty(), "colour not found");
                 if (!result.empty()) {
                     drawLabel(cr, left, result.unwrap(), r);
diff --git a/src/niepce/ui/librarycellrenderer.hpp b/src/niepce/ui/librarycellrenderer.hpp
index eea1bae..0d52555 100644
--- a/src/niepce/ui/librarycellrenderer.hpp
+++ b/src/niepce/ui/librarycellrenderer.hpp
@@ -30,18 +30,16 @@
 #include "engine/db/label.hpp"
 #include "fwk/toolkit/widgets/imagegridview.hpp"
 
-namespace libraryclient {
-class UIDataProvider;
-}
-
 namespace ui {
 
+class IModuleShell;
+
 class LibraryCellRenderer
        : public Gtk::CellRendererPixbuf
         , public fwk::ClickableCellRenderer
 {
 public:
-    LibraryCellRenderer(libraryclient::UIDataProvider *provider);
+    LibraryCellRenderer(const IModuleShell& shell);
     
     virtual void get_preferred_width_vfunc(Gtk::Widget& widget, int& minimum_width, int& natural_width) 
const override;
     virtual void get_preferred_height_vfunc(Gtk::Widget& widget, int& minimum_height, int& natural_height) 
const override;
@@ -86,6 +84,7 @@ protected:
     void _drawFlag(const Cairo::RefPtr<Cairo::Context> & cr, 
                    int flag_value, double x, double y);
 private:
+    const IModuleShell& m_shell;
     int                                 m_size;
     int                                 m_pad;
     bool                                m_drawborder;
@@ -93,9 +92,8 @@ private:
     bool                                m_drawrating;
     bool                                m_drawlabel;
     bool                                m_drawflag;
-    libraryclient::UIDataProvider      *m_uiDataProvider;
     Glib::Property<eng::LibFile::Ptr>   m_libfileproperty;
-    
+
     Cairo::RefPtr<Cairo::ImageSurface>  m_raw_format_emblem;
     Cairo::RefPtr<Cairo::ImageSurface>  m_rawjpeg_format_emblem;
     Cairo::RefPtr<Cairo::ImageSurface>  m_img_format_emblem;
diff --git a/src/niepce/ui/moduleshell.hpp b/src/niepce/ui/moduleshell.hpp
index a112137..a2ad82e 100644
--- a/src/niepce/ui/moduleshell.hpp
+++ b/src/niepce/ui/moduleshell.hpp
@@ -49,7 +49,7 @@ public:
     typedef std::shared_ptr<ModuleShell> Ptr;
     typedef std::weak_ptr<ModuleShell> WeakPtr;
 
-    ModuleShell(const libraryclient::LibraryClient::Ptr & libclient)
+    ModuleShell(const libraryclient::LibraryClientPtr& libclient)
         : m_libraryclient(libclient)
         , m_actionGroup(Gio::SimpleActionGroup::create())
         {
@@ -72,11 +72,14 @@ public:
         {
             return m_selection_controller;
         }
-    virtual libraryclient::LibraryClient::Ptr getLibraryClient() const override
+    virtual libraryclient::LibraryClientPtr getLibraryClient() const override
         {
             return m_libraryclient;
         }
-
+    virtual const std::unique_ptr<libraryclient::UIDataProvider>& get_ui_data_provider() const override
+        {
+            return m_libraryclient->getDataProvider();
+        }
     Glib::RefPtr<Gio::Menu> getMenu() const
         { return m_menu; }
 
@@ -95,7 +98,7 @@ protected:
     void on_module_deactivated(const std::string & name) const;
     void on_module_activated(const std::string & name) const;
 private:
-    libraryclient::LibraryClient::Ptr m_libraryclient;
+    libraryclient::LibraryClientPtr m_libraryclient;
     Glib::RefPtr<Gio::SimpleActionGroup> m_actionGroup;
 
     // managed widgets...
diff --git a/src/niepce/ui/niepcewindow.cpp b/src/niepce/ui/niepcewindow.cpp
index 0a5eb3c..1827413 100644
--- a/src/niepce/ui/niepcewindow.cpp
+++ b/src/niepce/ui/niepcewindow.cpp
@@ -49,6 +49,7 @@
 #include "selectioncontroller.hpp"
 
 using libraryclient::LibraryClient;
+using libraryclient::LibraryClientPtr;
 using fwk::Application;
 using fwk::Configuration;
 using fwk::UndoHistory;
@@ -128,7 +129,8 @@ NiepceWindow::_createModuleShell()
 
 
     SelectionController::Ptr selection_controller = m_moduleshell->get_selection_controller();
-    m_filmstrip = FilmStripController::Ptr(new FilmStripController(m_moduleshell->get_list_store()));
+    m_filmstrip = FilmStripController::Ptr(
+        new FilmStripController(m_moduleshell->get_list_store(), *m_moduleshell));
     add(m_filmstrip);
 
     m_vbox.pack_start(*(m_filmstrip->buildWidget()), Gtk::PACK_SHRINK);
@@ -384,8 +386,8 @@ std::string NiepceWindow::prompt_open_library()
 bool NiepceWindow::open_library(const std::string & libMoniker)
 {
     fwk::Moniker mon = fwk::Moniker(libMoniker);
-    m_libClient = LibraryClient::Ptr(new LibraryClient(mon,
-                                                       m_notifcenter));
+    m_libClient = LibraryClientPtr(new LibraryClient(mon,
+                                                     m_notifcenter));
     if(!m_libClient->ok()) {
         m_libClient = nullptr;
         return false;
diff --git a/src/niepce/ui/niepcewindow.hpp b/src/niepce/ui/niepcewindow.hpp
index f850259..8454ae7 100644
--- a/src/niepce/ui/niepcewindow.hpp
+++ b/src/niepce/ui/niepcewindow.hpp
@@ -51,7 +51,7 @@ public:
 
     virtual void set_title(const std::string & title) override;
 
-    libraryclient::LibraryClient::Ptr getLibraryClient() const
+    libraryclient::LibraryClientPtr getLibraryClient() const
         { return m_libClient; }
     fwk::Configuration::Ptr getLibraryConfig() const
         { return m_library_cfg; }
@@ -87,7 +87,7 @@ private:
     FilmStripController::Ptr       m_filmstrip;
     Gtk::Statusbar                 m_statusBar;
     Glib::RefPtr<Gio::SimpleActionGroup> m_action_group;
-    libraryclient::LibraryClient::Ptr m_libClient;
+    libraryclient::LibraryClientPtr m_libClient;
     fwk::Configuration::Ptr        m_library_cfg;
 };
 
diff --git a/src/niepce/ui/selectioncontroller.cpp b/src/niepce/ui/selectioncontroller.cpp
index 2707835..81729bd 100644
--- a/src/niepce/ui/selectioncontroller.cpp
+++ b/src/niepce/ui/selectioncontroller.cpp
@@ -104,11 +104,11 @@ void SelectionController::selected(const IImageSelectable::WeakPtr & selectableW
 }
 
 
-libraryclient::LibraryClient::Ptr SelectionController::getLibraryClient()
+libraryclient::LibraryClientPtr SelectionController::getLibraryClient()
 {
     ModuleShell::Ptr shell = std::dynamic_pointer_cast<ModuleShell>(m_parent.lock());
     DBG_ASSERT(static_cast<bool>(shell), "parent not a ModuleShell");
-    return     shell->getLibraryClient();
+    return shell->getLibraryClient();
 }
 
 eng::library_id_t SelectionController::get_selection() const
diff --git a/src/niepce/ui/selectioncontroller.hpp b/src/niepce/ui/selectioncontroller.hpp
index 8e6b377..dca999d 100644
--- a/src/niepce/ui/selectioncontroller.hpp
+++ b/src/niepce/ui/selectioncontroller.hpp
@@ -113,7 +113,7 @@ public:
 protected:
     virtual void _added() override;
 private:
-    libraryclient::LibraryClient::Ptr getLibraryClient();
+    libraryclient::LibraryClientPtr getLibraryClient();
 
     bool _set_metadata(const std::string & undo_label,
                        const eng::LibFile::Ptr & file,
diff --git a/src/niepce/ui/thumbstripview.cpp b/src/niepce/ui/thumbstripview.cpp
index abfb227..b78caa6 100644
--- a/src/niepce/ui/thumbstripview.cpp
+++ b/src/niepce/ui/thumbstripview.cpp
@@ -59,12 +59,12 @@ class ThumbStripCell
     : public LibraryCellRenderer
 {
 public:
-    ThumbStripCell();
+    ThumbStripCell(const IModuleShell& shell);
 };
 
-ThumbStripCell::ThumbStripCell()
+ThumbStripCell::ThumbStripCell(const IModuleShell& shell)
     : Glib::ObjectBase(typeid(ThumbStripCell))
-    , LibraryCellRenderer(nullptr)
+    , LibraryCellRenderer(shell)
 {
     set_pad(0);
     set_size(100);
@@ -75,7 +75,8 @@ ThumbStripCell::ThumbStripCell()
     set_drawflag(false);
 }
 
-ThumbStripView::ThumbStripView(const Glib::RefPtr<ui::ImageListStore> & store)
+ThumbStripView::ThumbStripView(const Glib::RefPtr<ui::ImageListStore> & store,
+                               const IModuleShell& shell)
     : Glib::ObjectBase(typeid(ThumbStripView))
     , Gtk::IconView(Glib::RefPtr<Gtk::TreeModel>::cast_dynamic(store))
     , m_start_thumb(0)
@@ -83,7 +84,7 @@ ThumbStripView::ThumbStripView(const Glib::RefPtr<ui::ImageListStore> & store)
     , m_store(store)
     , m_model_item_count(0)
 {
-    m_renderer = manage(new ThumbStripCell());
+    m_renderer = manage(new ThumbStripCell(shell));
 
     pack_start(*m_renderer, FALSE);
     m_renderer->property_height() = 100;
diff --git a/src/niepce/ui/thumbstripview.hpp b/src/niepce/ui/thumbstripview.hpp
index 4085a47..8b4c581 100644
--- a/src/niepce/ui/thumbstripview.hpp
+++ b/src/niepce/ui/thumbstripview.hpp
@@ -30,11 +30,13 @@
 
 namespace ui {
 
+class IModuleShell;
+
 class ThumbStripView
   : public Gtk::IconView
 {
 public:
-    ThumbStripView(const Glib::RefPtr<ui::ImageListStore> & store);
+    ThumbStripView(const Glib::RefPtr<ui::ImageListStore>& store, const IModuleShell& shell);
 
     void set_model(const Glib::RefPtr<ui::ImageListStore> & store);
     const Glib::RefPtr<ui::ImageListStore> & get_model() const;
diff --git a/src/niepce/ui/workspacecontroller.cpp b/src/niepce/ui/workspacecontroller.cpp
index f2d7ec9..c1aabe4 100644
--- a/src/niepce/ui/workspacecontroller.cpp
+++ b/src/niepce/ui/workspacecontroller.cpp
@@ -70,7 +70,7 @@ WorkspaceController::WorkspaceController()
     }
 }
 
-libraryclient::LibraryClient::Ptr WorkspaceController::getLibraryClient() const
+libraryclient::LibraryClientPtr WorkspaceController::getLibraryClient() const
 {
     return std::dynamic_pointer_cast<NiepceWindow>(m_parent.lock())->getLibraryClient();
 }
@@ -346,9 +346,8 @@ void WorkspaceController::expand_from_cfg(const char* key,
 
 void WorkspaceController::on_ready()
 {
-    libraryclient::LibraryClient::Ptr libraryClient = getLibraryClient();
-    if(libraryClient)
-    {
+    libraryclient::LibraryClientPtr libraryClient = getLibraryClient();
+    if (libraryClient) {
         libraryClient->getAllFolders();
         libraryClient->getAllKeywords();
     }
diff --git a/src/niepce/ui/workspacecontroller.hpp b/src/niepce/ui/workspacecontroller.hpp
index 4427a59..a37539c 100644
--- a/src/niepce/ui/workspacecontroller.hpp
+++ b/src/niepce/ui/workspacecontroller.hpp
@@ -94,7 +94,7 @@ private:
     void on_row_collapsed(const Gtk::TreeIter& iter,
                           const Gtk::TreePath& path);
 
-    libraryclient::LibraryClient::Ptr getLibraryClient() const;
+    libraryclient::LibraryClientPtr getLibraryClient() const;
     fwk::Configuration::Ptr getLibraryConfig() const;
 
     /** add a folder item to the treeview */


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