[gnote] Move get_icon() from Notebook to SpecialNotebook



commit 4525405192c5d9c06ce0ad1b1d1b62884f461761
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Fri Feb 28 22:38:58 2014 +0200

    Move get_icon() from Notebook to SpecialNotebook
    
    Make Notebook class non-ui.

 src/notebooks/notebook.cpp |    5 -----
 src/notebooks/notebook.hpp |    3 ++-
 src/searchnoteswidget.cpp  |    8 +++++++-
 3 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/src/notebooks/notebook.cpp b/src/notebooks/notebook.cpp
index 7e5a72e..547aa8f 100644
--- a/src/notebooks/notebook.cpp
+++ b/src/notebooks/notebook.cpp
@@ -216,11 +216,6 @@ namespace notebooks {
     return true;
   }
 
-  Glib::RefPtr<Gdk::Pixbuf> Notebook::get_icon()
-  {
-    return IconManager::obj().get_icon(IconManager::NOTEBOOK, 22);
-  }
-
   std::string Notebook::normalize(const std::string & s)
   {
     return Glib::ustring(sharp::string_trim(s)).lowercase();
diff --git a/src/notebooks/notebook.hpp b/src/notebooks/notebook.hpp
index c9f4293..ed57e70 100644
--- a/src/notebooks/notebook.hpp
+++ b/src/notebooks/notebook.hpp
@@ -55,7 +55,6 @@ public:
   Note::Ptr create_notebook_note();
   virtual bool contains_note(const Note::Ptr & note, bool include_system = false);
   virtual bool add_note(const Note::Ptr &);
-  virtual Glib::RefPtr<Gdk::Pixbuf> get_icon();
   static std::string normalize(const std::string & s);
 ////
   virtual ~Notebook()
@@ -88,6 +87,8 @@ class SpecialNotebook
 {
 public:
   typedef shared_ptr<SpecialNotebook> Ptr;
+
+  virtual Glib::RefPtr<Gdk::Pixbuf> get_icon() = 0;
 protected:
   SpecialNotebook(NoteManager & m, const std::string &s)
     : Notebook(m, s, true)
diff --git a/src/searchnoteswidget.cpp b/src/searchnoteswidget.cpp
index b9f3b33..77be130 100644
--- a/src/searchnoteswidget.cpp
+++ b/src/searchnoteswidget.cpp
@@ -298,7 +298,13 @@ void SearchNotesWidget::notebook_pixbuf_cell_data_func(Gtk::CellRenderer * rende
   }
 
   Gtk::CellRendererPixbuf *crp = dynamic_cast<Gtk::CellRendererPixbuf*>(renderer);
-  crp->property_pixbuf() = notebook->get_icon();
+  notebooks::SpecialNotebook::Ptr special_nb = dynamic_pointer_cast<notebooks::SpecialNotebook>(notebook);
+  if(special_nb) {
+    crp->property_pixbuf() = special_nb->get_icon();
+  }
+  else {
+    crp->property_pixbuf() = IconManager::obj().get_icon(IconManager::NOTEBOOK, 22);
+  }
 }
 
 void SearchNotesWidget::notebook_text_cell_data_func(Gtk::CellRenderer * renderer,


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