[gnote] * use static data where it make sense.
- From: Hubert Figuière <hub src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnote] * use static data where it make sense.
- Date: Mon, 27 Apr 2009 12:41:56 -0400 (EDT)
commit 1f481f3d24a3761548e3161668d24126ec9e41cf
Author: Hubert Figuiere <hub figuiere net>
Date: Mon Apr 27 01:23:08 2009 -0400
* use static data where it make sense.
---
src/notebooks/notebooknoteaddin.cpp | 20 ++++++++++++++++----
src/notebooks/notebooknoteaddin.hpp | 7 +++++--
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/src/notebooks/notebooknoteaddin.cpp b/src/notebooks/notebooknoteaddin.cpp
index 5e7b3ff..2e4ae79 100644
--- a/src/notebooks/notebooknoteaddin.cpp
+++ b/src/notebooks/notebooknoteaddin.cpp
@@ -33,13 +33,25 @@
namespace gnote {
namespace notebooks {
+ bool NotebookNoteAddin::s_static_inited = false;
+ Glib::RefPtr<Gdk::Pixbuf> NotebookNoteAddin::s_notebookIcon;
+ Glib::RefPtr<Gdk::Pixbuf> NotebookNoteAddin::s_newNotebookIcon;
+
+ void NotebookNoteAddin::_init_static()
+ {
+ if(!s_static_inited) {
+ s_notebookIcon = utils::get_icon("notebook", 22);
+ s_newNotebookIcon = utils::get_icon("notebook-new", 16);
+ s_static_inited = true;
+ }
+ }
+
NotebookNoteAddin::NotebookNoteAddin()
: m_toolButton(NULL)
, m_menu(NULL)
{
- m_notebookIcon = utils::get_icon("notebook", 22);
- m_newNotebookIcon = utils::get_icon("notebook-new", 16);
+ _init_static();
}
@@ -55,7 +67,7 @@ namespace notebooks {
void NotebookNoteAddin::initialize_tool_button()
{
- m_toolButton = manage(new Gtk::MenuToolButton(*manage(new Gtk::Image(m_notebookIcon))));
+ m_toolButton = manage(new Gtk::MenuToolButton(*manage(new Gtk::Image(s_notebookIcon))));
Gtk::Label * l = manage(new Gtk::Label());
// Ellipsize names longer than 12 chars in length
// TODO: Should we hardcode the ellipsized notebook name to 12 chars?
@@ -177,7 +189,7 @@ namespace notebooks {
// Add the "New Notebook..."
Gtk::ImageMenuItem *newNotebookMenuItem =
manage(new Gtk::ImageMenuItem (_("_New notebook..."), true));
- newNotebookMenuItem->set_image(*manage(new Gtk::Image (m_newNotebookIcon)));
+ newNotebookMenuItem->set_image(*manage(new Gtk::Image (s_newNotebookIcon)));
newNotebookMenuItem->signal_activate()
.connect(sigc::mem_fun(*this,&NotebookNoteAddin::on_new_notebook_menu_item));
newNotebookMenuItem->show ();
diff --git a/src/notebooks/notebooknoteaddin.hpp b/src/notebooks/notebooknoteaddin.hpp
index bda1617..84f9a6b 100644
--- a/src/notebooks/notebooknoteaddin.hpp
+++ b/src/notebooks/notebooknoteaddin.hpp
@@ -60,11 +60,14 @@ namespace notebooks {
Gtk::Menu *m_menu;
std::list<Gtk::MenuItem *> m_menu_items;
Gtk::RadioButtonGroup m_radio_group;
- Glib::RefPtr<Gdk::Pixbuf> m_notebookIcon;
- Glib::RefPtr<Gdk::Pixbuf> m_newNotebookIcon;
sigc::connection m_show_menu_cid;
sigc::connection m_note_added_cid;
sigc::connection m_note_removed_cid;
+
+ static void _init_static();
+ static bool s_static_inited;
+ static Glib::RefPtr<Gdk::Pixbuf> s_notebookIcon;
+ static Glib::RefPtr<Gdk::Pixbuf> s_newNotebookIcon;
};
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]