[gnote] Add method get_icon() to Notebook



commit 77222fa8508dc0ef4645ae0a9bfdf67e75605f66
Author: Aurimas Äernius <aurisc4 gmail com>
Date:   Mon Nov 12 22:24:20 2012 +0200

    Add method get_icon() to Notebook
    
    Used to return notebook icon.
    Use it for displaying icon in notebooks list.

 src/notebooks/notebook.cpp |   21 +++++++++++++++++++++
 src/notebooks/notebook.hpp |    4 ++++
 src/searchnoteswidget.cpp  |   13 +------------
 3 files changed, 26 insertions(+), 12 deletions(-)
---
diff --git a/src/notebooks/notebook.cpp b/src/notebooks/notebook.cpp
index 8a57818..06de039 100644
--- a/src/notebooks/notebook.cpp
+++ b/src/notebooks/notebook.cpp
@@ -25,6 +25,7 @@
 
 #include "sharp/string.hpp"
 #include "gnote.hpp"
+#include "iconmanager.hpp"
 #include "notemanager.hpp"
 #include "notebooks/notebook.hpp"
 #include "notebooks/notebookmanager.hpp"
@@ -194,6 +195,11 @@ 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 sharp::string_to_lower(sharp::string_trim(s));
@@ -233,6 +239,11 @@ namespace notebooks {
     return false;
   }
 
+  Glib::RefPtr<Gdk::Pixbuf> AllNotesNotebook::get_icon()
+  {
+    return IconManager::obj().get_icon(IconManager::FILTER_NOTE_ALL, 22);
+  }
+
 
   UnfiledNotesNotebook::UnfiledNotesNotebook()
     : SpecialNotebook(_("Unfiled Notes"))
@@ -257,6 +268,11 @@ namespace notebooks {
     return true;
   }
 
+  Glib::RefPtr<Gdk::Pixbuf> UnfiledNotesNotebook::get_icon()
+  {
+    return IconManager::obj().get_icon(IconManager::FILTER_NOTE_UNFILED, 22);
+  }
+
 
   PinnedNotesNotebook::PinnedNotesNotebook()
     : SpecialNotebook(_("Pinned Notes"))
@@ -280,5 +296,10 @@ namespace notebooks {
     return true;
   }
 
+  Glib::RefPtr<Gdk::Pixbuf> PinnedNotesNotebook::get_icon()
+  {
+    return IconManager::obj().get_icon(IconManager::PIN_DOWN, 22);
+  }
+
 }
 }
diff --git a/src/notebooks/notebook.hpp b/src/notebooks/notebook.hpp
index 9a0737d..a386a59 100644
--- a/src/notebooks/notebook.hpp
+++ b/src/notebooks/notebook.hpp
@@ -54,6 +54,7 @@ public:
   Note::Ptr create_notebook_note();
   virtual bool contains_note(const Note::Ptr &);
   virtual bool add_note(const Note::Ptr &);
+  virtual Glib::RefPtr<Gdk::Pixbuf> get_icon();
   static std::string normalize(const std::string & s);
 ////
   virtual ~Notebook()
@@ -104,6 +105,7 @@ public:
   virtual std::string get_normalized_name() const;
   virtual bool        contains_note(const Note::Ptr &);
   virtual bool        add_note(const Note::Ptr &);
+  virtual Glib::RefPtr<Gdk::Pixbuf> get_icon();
 };
 
 
@@ -121,6 +123,7 @@ public:
   virtual std::string get_normalized_name() const;
   virtual bool        contains_note(const Note::Ptr &);
   virtual bool        add_note(const Note::Ptr &);
+  virtual Glib::RefPtr<Gdk::Pixbuf> get_icon();
 };
 
 
@@ -133,6 +136,7 @@ public:
   virtual std::string get_notmalized_name() const;
   virtual bool        contains_note(const Note::Ptr &);
   virtual bool        add_note(const Note::Ptr &);
+  virtual Glib::RefPtr<Gdk::Pixbuf> get_icon();
 };
 
 
diff --git a/src/searchnoteswidget.cpp b/src/searchnoteswidget.cpp
index 6f34e9f..8990193 100644
--- a/src/searchnoteswidget.cpp
+++ b/src/searchnoteswidget.cpp
@@ -472,18 +472,7 @@ void SearchNotesWidget::notebook_pixbuf_cell_data_func(Gtk::CellRenderer * rende
   }
 
   Gtk::CellRendererPixbuf *crp = dynamic_cast<Gtk::CellRendererPixbuf*>(renderer);
-  if(std::tr1::dynamic_pointer_cast<notebooks::AllNotesNotebook>(notebook)) {
-    crp->property_pixbuf() = IconManager::obj().get_icon(IconManager::FILTER_NOTE_ALL, 22);
-  }
-  else if(std::tr1::dynamic_pointer_cast<notebooks::UnfiledNotesNotebook>(notebook)) {
-    crp->property_pixbuf() = IconManager::obj().get_icon(IconManager::FILTER_NOTE_UNFILED, 22);
-  }
-  else if(std::tr1::dynamic_pointer_cast<notebooks::PinnedNotesNotebook>(notebook)) {
-    crp->property_pixbuf() = IconManager::obj().get_icon(IconManager::PIN_DOWN, 22);
-  }
-  else {
-    crp->property_pixbuf() = IconManager::obj().get_icon(IconManager::NOTEBOOK, 22);
-  }
+  crp->property_pixbuf() = notebook->get_icon();
 }
 
 void SearchNotesWidget::notebook_text_cell_data_func(Gtk::CellRenderer * renderer,



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