[gnote] Add Special Notes notebook



commit 86915257ab95752ffa9c0077f740b8abb5a26696
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun Aug 4 22:49:40 2013 +0300

    Add Special Notes notebook
    
    Notebook to display otherwise hidden notes.

 configure.ac                                       |    1 +
 po/POTFILES.in                                     |    2 +
 src/addins/Makefile.am                             |    1 +
 src/addins/specialnotes/Makefile.am                |   19 ++++
 src/addins/specialnotes/specialnotes.desktop.in    |    9 ++
 .../specialnotes/specialnotesapplicationaddin.cpp  |  109 ++++++++++++++++++++
 .../specialnotes/specialnotesapplicationaddin.hpp  |   62 +++++++++++
 7 files changed, 203 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 31d5b9c..ce7d7ec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -179,6 +179,7 @@ src/addins/notedirectorywatcher/Makefile
 src/addins/noteoftheday/Makefile
 src/addins/printnotes/Makefile
 src/addins/replacetitle/Makefile
+src/addins/specialnotes/Makefile
 src/addins/statistics/Makefile
 src/addins/stickynoteimport/Makefile
 src/addins/tableofcontents/Makefile
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 509580a..fb77163 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -27,6 +27,8 @@ src/addins/printnotes/printnotes.desktop.in
 src/addins/printnotes/printnotesnoteaddin.cpp
 src/addins/replacetitle/replacetitle.desktop.in
 src/addins/replacetitle/replacetitlenoteaddin.cpp
+src/addins/specialnotes/specialnotes.desktop.in
+src/addins/specialnotes/specialnotesapplicationaddin.cpp
 src/addins/statistics/statisticsapplicationaddin.cpp
 src/addins/statistics/statistics.desktop.in
 src/addins/statistics/statisticswidget.cpp
diff --git a/src/addins/Makefile.am b/src/addins/Makefile.am
index 2503cb0..52ef422 100644
--- a/src/addins/Makefile.am
+++ b/src/addins/Makefile.am
@@ -11,6 +11,7 @@ SUBDIRS = backlinks \
        noteoftheday \
        printnotes \
        replacetitle \
+       specialnotes \
        statistics \
        stickynoteimport \
        tableofcontents \
diff --git a/src/addins/specialnotes/Makefile.am b/src/addins/specialnotes/Makefile.am
new file mode 100644
index 0000000..5574457
--- /dev/null
+++ b/src/addins/specialnotes/Makefile.am
@@ -0,0 +1,19 @@
+
+include $(builddir)/../addins.mk
+
+ INTLTOOL_DESKTOP_RULE@
+
+desktop_in_files = specialnotes.desktop.in
+desktop_files    = $(desktop_in_files:.desktop.in=.desktop)
+
+addinsdir = $(ADDINSDIR)
+addins_LTLIBRARIES = specialnotes.la
+addins_DATA = $(desktop_files)
+
+specialnotes_la_SOURCES = \
+       specialnotesapplicationaddin.hpp \
+       specialnotesapplicationaddin.cpp \
+       $(NULL)
+
+EXTRA_DIST = $(desktop_in_files)
+DISTCLEANFILES = $(desktop_files)
diff --git a/src/addins/specialnotes/specialnotes.desktop.in b/src/addins/specialnotes/specialnotes.desktop.in
new file mode 100644
index 0000000..0d1a557
--- /dev/null
+++ b/src/addins/specialnotes/specialnotes.desktop.in
@@ -0,0 +1,9 @@
+[AddinInfo]
+Id=SpecialNotesAddin
+_Name=Special Notes
+_Description=Show special notes, that are otherwise hidden
+_Authors=Aurimas Černius
+Category=Tools
+Version=0.1
+DefaultEnabled=false
+Module=specialnotes
diff --git a/src/addins/specialnotes/specialnotesapplicationaddin.cpp 
b/src/addins/specialnotes/specialnotesapplicationaddin.cpp
new file mode 100644
index 0000000..54614b8
--- /dev/null
+++ b/src/addins/specialnotes/specialnotesapplicationaddin.cpp
@@ -0,0 +1,109 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2013 Aurimas Cernius
+ *
+ * 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 <glibmm/i18n.h>
+
+#include "notebooks/notebook.hpp"
+#include "notebooks/notebookmanager.hpp"
+#include "specialnotesapplicationaddin.hpp"
+
+using gnote::Note;
+using gnote::notebooks::Notebook;
+
+
+namespace {
+  class SpecialNotesNotebook
+    : public gnote::notebooks::SpecialNotebook
+  {
+  public:
+    SpecialNotesNotebook(gnote::NoteManager & nm)
+      : SpecialNotebook(nm, _("Special Notes"))
+      {}
+
+    virtual std::string get_normalized_name() const override
+      {
+        return "___SpecialNotesAddin___SpecialNotes__Notebook___";
+      }
+
+    virtual bool contains_note(const Note::Ptr & note, bool = false) override
+      {
+        return is_template_note(note);
+      }
+
+    virtual bool add_note(const Note::Ptr &) override
+      {
+        return false;
+      }
+
+    /*virtual Glib::RefPtr<Gdk::Pixbuf> get_icon() override
+      {
+      }*/
+  };
+}
+
+
+namespace specialnotes {
+
+DECLARE_MODULE(SpecialNotesModule);
+
+
+SpecialNotesModule::SpecialNotesModule()
+{
+  ADD_INTERFACE_IMPL(SpecialNotesApplicationAddin);
+}
+
+
+const char *SpecialNotesApplicationAddin::IFACE_NAME = "gnote::ApplicationAddin";
+
+SpecialNotesApplicationAddin::SpecialNotesApplicationAddin()
+  : m_initialized(false)
+{
+}
+
+SpecialNotesApplicationAddin::~SpecialNotesApplicationAddin()
+{
+}
+
+void SpecialNotesApplicationAddin::initialize()
+{
+  if(!m_initialized) {
+    m_initialized = true;
+
+    m_notebook = Notebook::Ptr(new SpecialNotesNotebook(note_manager()));
+    gnote::notebooks::NotebookManager::obj().add_notebook(m_notebook);
+  }
+}
+
+void SpecialNotesApplicationAddin::shutdown()
+{
+  if(m_notebook != NULL) {
+    gnote::notebooks::NotebookManager::obj().delete_notebook(m_notebook);
+    m_notebook.reset();
+    m_initialized = false;
+  }
+}
+
+bool SpecialNotesApplicationAddin::initialized()
+{
+  return m_initialized;
+}
+
+}
+
diff --git a/src/addins/specialnotes/specialnotesapplicationaddin.hpp 
b/src/addins/specialnotes/specialnotesapplicationaddin.hpp
new file mode 100644
index 0000000..6c66096
--- /dev/null
+++ b/src/addins/specialnotes/specialnotesapplicationaddin.hpp
@@ -0,0 +1,62 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2013 Aurimas Cernius
+ *
+ * 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 __SPECIAL_NOTES_APPLICATION_ADDIN_HPP_
+#define __SPECIAL_NOTES_APPLICATION_ADDIN_HPP_
+
+#include "base/macros.hpp"
+#include "notebooks/notebook.hpp"
+#include "sharp/dynamicmodule.hpp"
+#include "applicationaddin.hpp"
+
+namespace specialnotes {
+
+class SpecialNotesModule
+  : public sharp::DynamicModule
+{
+public:
+  SpecialNotesModule();
+};
+
+
+class SpecialNotesApplicationAddin
+  : public gnote::ApplicationAddin
+{
+public:
+  static const char * IFACE_NAME;
+
+  static SpecialNotesApplicationAddin *create()
+    {
+      return new SpecialNotesApplicationAddin;
+    }
+
+  virtual ~SpecialNotesApplicationAddin();
+  virtual void initialize() override;
+  virtual void shutdown() override;
+  virtual bool initialized() override;
+private:
+  SpecialNotesApplicationAddin();
+
+  bool m_initialized;
+  gnote::notebooks::Notebook::Ptr m_notebook;
+};
+
+}
+
+#endif


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