[gnote] Added NoteOfTheDay addin.
- From: Debarshi Ray <debarshir src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnote] Added NoteOfTheDay addin.
- Date: Mon, 28 Dec 2009 11:46:41 +0000 (UTC)
commit 99e52f861be2a527c4da37b6ccf9df381634c67a
Author: Debarshi Ray <debarshir src gnome org>
Date: Sun Dec 27 17:30:47 2009 +0200
Added NoteOfTheDay addin.
Fixes: https://bugzilla.gnome.org/590589
configure.ac | 1 +
po/POTFILES.in | 2 +
src/Makefile.am | 1 +
src/addinmanager.cpp | 6 +
src/addins/Makefile.am | 1 +
src/addins/noteoftheday/Makefile.am | 15 ++
src/addins/noteoftheday/noteoftheday.cpp | 183 ++++++++++++++++++++
src/addins/noteoftheday/noteoftheday.hpp | 68 +++++++
.../noteoftheday/noteofthedayapplicationaddin.cpp | 123 +++++++++++++
.../noteoftheday/noteofthedayapplicationaddin.hpp | 77 ++++++++
.../noteoftheday/noteofthedaypreferences.cpp | 80 +++++++++
.../noteoftheday/noteofthedaypreferences.hpp | 45 +++++
.../noteofthedaypreferencesfactory.hpp | 36 ++++
src/applicationaddin.cpp | 26 +++
src/applicationaddin.hpp | 2 +
src/sharp/datetime.cpp | 14 ++
src/sharp/datetime.hpp | 2 +
17 files changed, 682 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 88bb195..1c5a77a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -227,6 +227,7 @@ src/addins/bugzilla/Makefile
src/addins/exporttohtml/Makefile
src/addins/fixedwidth/Makefile
src/addins/inserttimestamp/Makefile
+src/addins/noteoftheday/Makefile
src/addins/printnotes/Makefile
src/addins/stickynoteimport/Makefile
src/addins/tomboyimport/Makefile
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 29f5777..6e9fcc8 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -29,6 +29,8 @@ src/addins/fixedwidth/fixedwidthmenuitem.cpp
src/addins/fixedwidth/fixedwidthnoteaddin.cpp
src/addins/inserttimestamp/inserttimestampnoteaddin.cpp
src/addins/inserttimestamp/inserttimestamppreferences.cpp
+src/addins/noteoftheday/noteoftheday.cpp
+src/addins/noteoftheday/noteofthedayapplicationaddin.cpp
src/addins/printnotes/printnotesnoteaddin.cpp
src/addins/stickynoteimport/stickynoteimportnoteaddin.cpp
src/addins/tomboyimport/tomboyimportaddin.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 9d2cc8f..05609e1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -119,6 +119,7 @@ libgnote_a_SOURCES = \
addinmanager.hpp addinmanager.cpp \
addinpreferencefactory.hpp addinpreferencefactory.cpp \
applicationaddin.hpp \
+ applicationaddin.cpp \
contrast.hpp contrast.cpp \
debug.hpp debug.cpp \
importaddin.hpp importaddin.cpp \
diff --git a/src/addinmanager.cpp b/src/addinmanager.cpp
index 062b8a5..0947c55 100644
--- a/src/addinmanager.cpp
+++ b/src/addinmanager.cpp
@@ -162,6 +162,12 @@ namespace gnote {
ImportAddin * factory = dynamic_cast<ImportAddin*>((*f)());
m_import_addins.insert(std::make_pair((*iter)->id(), factory));
}
+
+ f = dmod->query_interface(ApplicationAddin::IFACE_NAME);
+ if(f) {
+ ApplicationAddin * factory = dynamic_cast<ApplicationAddin*>((*f)());
+ m_app_addins.insert(std::make_pair((*iter)->id(), factory));
+ }
}
}
diff --git a/src/addins/Makefile.am b/src/addins/Makefile.am
index e9aeb0f..45b5a82 100644
--- a/src/addins/Makefile.am
+++ b/src/addins/Makefile.am
@@ -6,6 +6,7 @@ SUBDIRS = backlinks \
exporttohtml \
fixedwidth \
inserttimestamp \
+ noteoftheday \
printnotes \
stickynoteimport \
tomboyimport \
diff --git a/src/addins/noteoftheday/Makefile.am b/src/addins/noteoftheday/Makefile.am
new file mode 100644
index 0000000..b28b6b0
--- /dev/null
+++ b/src/addins/noteoftheday/Makefile.am
@@ -0,0 +1,15 @@
+
+include $(builddir)/../addins.mk
+
+addinsdir = $(ADDINSDIR)
+addins_LTLIBRARIES = libnoteoftheday.la
+
+libnoteoftheday_la_SOURCES = \
+ noteoftheday.hpp \
+ noteoftheday.cpp \
+ noteofthedayapplicationaddin.hpp \
+ noteofthedayapplicationaddin.cpp \
+ noteofthedaypreferences.hpp \
+ noteofthedaypreferences.cpp \
+ noteofthedaypreferencesfactory.hpp \
+ $(NULL)
diff --git a/src/addins/noteoftheday/noteoftheday.cpp b/src/addins/noteoftheday/noteoftheday.cpp
new file mode 100644
index 0000000..322feed
--- /dev/null
+++ b/src/addins/noteoftheday/noteoftheday.cpp
@@ -0,0 +1,183 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2009 Debarshi Ray
+ *
+ * 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 "sharp/datetime.hpp"
+#include "debug.hpp"
+#include "notemanager.hpp"
+#include "noteoftheday.hpp"
+#include "tagmanager.hpp"
+#include "utils.hpp"
+
+namespace noteoftheday {
+
+const std::string NoteOfTheDay::s_template_title
+ = _("Today: Template");
+const std::string NoteOfTheDay::s_title_prefix
+ = _("Today: ");
+
+gnote::Note::Ptr NoteOfTheDay::create(gnote::NoteManager & manager,
+ const Glib::Date & date)
+{
+ const std::string title = get_title(date);
+ const std::string xml = get_content(date, manager);
+
+ gnote::Note::Ptr notd;
+ try {
+ notd = manager.create(title, xml);
+ }
+ catch (const sharp::Exception & e) {
+ ERR_OUT("NoteOfTheDay could not create %s: %s",
+ title.c_str(),
+ e.what());
+ return gnote::Note::Ptr();
+ }
+
+ // Automatically tag all new Note of the Day notes
+ notd->add_tag(gnote::TagManager::obj().get_or_create_system_tag(
+ "NoteOfTheDay"));
+
+ return notd;
+}
+
+void NoteOfTheDay::cleanup_old(gnote::NoteManager & manager)
+{
+ gnote::Note::List kill_list;
+ const gnote::Note::List & notes = manager.get_notes();
+
+ Glib::Date date;
+ date.set_time_current(); // time set to 00:00:00
+
+ for (gnote::Note::List::const_iterator iter = notes.begin();
+ notes.end() != iter; iter++) {
+ const std::string & title = (*iter)->get_title();
+ const sharp::DateTime & date_time = (*iter)->create_date();
+
+ if (true == Glib::str_has_prefix(title, s_title_prefix)
+ && s_template_title != title
+ && Glib::Date(
+ date_time.day(),
+ static_cast<Glib::Date::Month>(date_time.month()),
+ date_time.year()) != date
+ && !has_changed(*iter)) {
+ kill_list.push_back(*iter);
+ }
+ }
+
+ for (gnote::Note::List::const_iterator iter = kill_list.begin();
+ kill_list.end() != iter; iter++) {
+ DBG_OUT("NoteOfTheDay: Deleting old unmodified '%s'",
+ (*iter)->get_title().c_str());
+ manager.delete_note(*iter);
+ }
+}
+
+std::string NoteOfTheDay::get_content(
+ const Glib::Date & date,
+ const gnote::NoteManager & manager)
+{
+ const std::string title = get_title(date);
+
+ // Attempt to load content from template
+ const gnote::Note::Ptr template_note = manager.find(
+ s_template_title);
+
+ if (0 != template_note) {
+ std::string xml_content = template_note->xml_content();
+ return xml_content.replace(xml_content.find(s_template_title, 0),
+ s_template_title.length(),
+ title);
+ }
+ else {
+ return get_template_content(title);
+ }
+}
+
+std::string NoteOfTheDay::get_content_without_title(
+ const std::string & content)
+{
+ return (content.empty())
+ ? ""
+ : content.substr(content.find("\n", 0),
+ std::string::npos);
+}
+
+gnote::Note::Ptr NoteOfTheDay::get_note_by_date(
+ gnote::NoteManager & manager,
+ const Glib::Date & date)
+{
+ const gnote::Note::List & notes = manager.get_notes();
+
+ for (gnote::Note::List::const_iterator iter = notes.begin();
+ notes.end() != iter; iter++) {
+ const std::string & title = (*iter)->get_title();
+ const sharp::DateTime & date_time = (*iter)->create_date();
+
+ if (true == Glib::str_has_prefix(title, s_title_prefix)
+ && s_template_title != title
+ && Glib::Date(
+ date_time.day(),
+ static_cast<Glib::Date::Month>(date_time.month()),
+ date_time.year()) == date) {
+ return *iter;
+ }
+ }
+
+ return gnote::Note::Ptr();
+}
+
+std::string NoteOfTheDay::get_template_content(
+ const std::string & title)
+{
+ return Glib::ustring::compose(
+ _("<note-content xmlns:size=\"http://beatniksoftware.com/tomboy/size\">"
+ "<note-title>%1</note-title>\n\n\n\n"
+ "<size:huge>%2</size:huge>\n\n\n"
+ "<size:huge>%3</size:huge>\n\n\n"
+ "</note-content>"),
+ title,
+ _("Tasks"),
+ _("Appointments"));
+}
+
+std::string NoteOfTheDay::get_title(const Glib::Date & date)
+{
+ // Format: "Today: Friday, July 01 2005"
+ return s_title_prefix + date.format_string(_("%A, %B %d %Y"));
+}
+
+bool NoteOfTheDay::has_changed(const gnote::Note::Ptr & note)
+{
+ const sharp::DateTime & date_time = note->create_date();
+ const std::string original_xml
+ = get_content(Glib::Date(
+ date_time.day(),
+ static_cast<Glib::Date::Month>(date_time.month()),
+ date_time.year()),
+ note->manager());
+
+ return get_content_without_title(note->text_content())
+ == get_content_without_title(
+ gnote::utils::XmlDecoder::decode(original_xml))
+ ? false
+ : true;
+}
+
+}
diff --git a/src/addins/noteoftheday/noteoftheday.hpp b/src/addins/noteoftheday/noteoftheday.hpp
new file mode 100644
index 0000000..17c17c1
--- /dev/null
+++ b/src/addins/noteoftheday/noteoftheday.hpp
@@ -0,0 +1,68 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2009 Debarshi Ray
+ *
+ * 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 __NOTE_OF_THE_DAY_HPP_
+#define __NOTE_OF_THE_DAY_HPP_
+
+#include <string>
+
+#include <glibmm.h>
+
+#include "sharp/dynamicmodule.hpp"
+#include "applicationaddin.hpp"
+#include "note.hpp"
+
+namespace gnote {
+
+class NoteManager;
+
+}
+
+namespace noteoftheday {
+
+class NoteOfTheDay
+{
+public:
+
+ static gnote::Note::Ptr create(gnote::NoteManager & manager,
+ const Glib::Date & date);
+ static void cleanup_old(gnote::NoteManager & manager);
+ static std::string get_content(const Glib::Date & date,
+ const gnote::NoteManager & manager);
+ static gnote::Note::Ptr get_note_by_date(
+ gnote::NoteManager & manager,
+ const Glib::Date & date);
+ static std::string get_template_content(
+ const std::string & title);
+ static std::string get_title(const Glib::Date & date);
+ static bool has_changed(const gnote::Note::Ptr & note);
+
+ static const std::string s_template_title;
+
+private:
+
+ static std::string get_content_without_title(
+ const std::string & content);
+
+ static const std::string s_title_prefix;
+};
+
+}
+
+#endif
diff --git a/src/addins/noteoftheday/noteofthedayapplicationaddin.cpp b/src/addins/noteoftheday/noteofthedayapplicationaddin.cpp
new file mode 100644
index 0000000..214e2f8
--- /dev/null
+++ b/src/addins/noteoftheday/noteofthedayapplicationaddin.cpp
@@ -0,0 +1,123 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2009 Debarshi Ray
+ *
+ * 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.h>
+#include <glibmm/i18n.h>
+
+#include "gnote.hpp"
+#include "noteoftheday.hpp"
+#include "noteofthedayapplicationaddin.hpp"
+#include "noteofthedaypreferencesfactory.hpp"
+
+namespace noteoftheday {
+
+DECLARE_MODULE(NoteOfTheDayModule);
+
+NoteOfTheDayModule::NoteOfTheDayModule()
+{
+ ADD_INTERFACE_IMPL(NoteOfTheDayApplicationAddin);
+ ADD_INTERFACE_IMPL(NoteOfTheDayPreferencesFactory);
+}
+const char * NoteOfTheDayModule::id() const
+{
+ return "NoteOfTheDayAddin";
+}
+const char * NoteOfTheDayModule::name() const
+{
+ return _("Note of the Day");
+}
+const char * NoteOfTheDayModule::description() const
+{
+ return _("Automatically creates a \"Today\" note for easily "
+ "jotting down daily thoughts");
+}
+const char * NoteOfTheDayModule::authors() const
+{
+ return _("Debarshi Ray and the Tomboy Project");
+}
+const char * NoteOfTheDayModule::category() const
+{
+ return "Tools";
+}
+const char * NoteOfTheDayModule::version() const
+{
+ return "0.1";
+}
+
+const char * NoteOfTheDayApplicationAddin::IFACE_NAME
+ = "gnote::ApplicationAddin";
+
+NoteOfTheDayApplicationAddin::NoteOfTheDayApplicationAddin()
+ : ApplicationAddin()
+ , m_initialized(false)
+ , m_manager(0)
+ , m_timeout()
+{
+ initialize();
+}
+
+NoteOfTheDayApplicationAddin::~NoteOfTheDayApplicationAddin()
+{
+}
+
+bool NoteOfTheDayApplicationAddin::check_new_day() const
+{
+ Glib::Date date;
+ date.set_time_current();
+
+ if (0 == NoteOfTheDay::get_note_by_date(*m_manager, date)) {
+ NoteOfTheDay::cleanup_old(*m_manager);
+
+ // Create a new NotD if the day has changed
+ NoteOfTheDay::create(*m_manager, date);
+ }
+
+ return true;
+}
+
+void NoteOfTheDayApplicationAddin::initialize()
+{
+ if (!m_timeout) {
+ m_timeout
+ = Glib::signal_timeout().connect_seconds(
+ sigc::mem_fun(*this,
+ &NoteOfTheDayApplicationAddin::check_new_day),
+ 60,
+ Glib::PRIORITY_DEFAULT);
+ }
+
+ m_initialized = true;
+ m_manager = &gnote::Gnote::obj().default_note_manager();
+}
+
+void NoteOfTheDayApplicationAddin::shutdown()
+{
+ if (m_timeout)
+ m_timeout.disconnect();
+
+ m_initialized = false;
+ m_manager = 0;
+}
+
+bool NoteOfTheDayApplicationAddin::initialized()
+{
+ return m_initialized;
+}
+
+}
diff --git a/src/addins/noteoftheday/noteofthedayapplicationaddin.hpp b/src/addins/noteoftheday/noteofthedayapplicationaddin.hpp
new file mode 100644
index 0000000..cf26100
--- /dev/null
+++ b/src/addins/noteoftheday/noteofthedayapplicationaddin.hpp
@@ -0,0 +1,77 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2009 Debarshi Ray
+ *
+ * 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 __NOTE_OF_THE_DAY_APPLICATION_ADDIN_HPP_
+#define __NOTE_OF_THE_DAY_APPLICATION_ADDIN_HPP_
+
+#include <sigc++/sigc++.h>
+
+#include "sharp/dynamicmodule.hpp"
+#include "applicationaddin.hpp"
+
+namespace gnote {
+
+class NoteManager;
+
+}
+
+namespace noteoftheday {
+
+class NoteOfTheDayModule
+ : public sharp::DynamicModule
+{
+public:
+ NoteOfTheDayModule();
+ virtual const char * id() const;
+ virtual const char * name() const;
+ virtual const char * description() const;
+ virtual const char * authors() const;
+ virtual const char * category() const;
+ virtual const char * version() const;
+};
+
+class NoteOfTheDayApplicationAddin
+ : public gnote::ApplicationAddin
+{
+public:
+ static const char * IFACE_NAME;
+
+ static NoteOfTheDayApplicationAddin * create()
+ {
+ return new NoteOfTheDayApplicationAddin;
+ }
+
+ virtual ~NoteOfTheDayApplicationAddin();
+ virtual void initialize();
+ virtual void shutdown();
+ virtual bool initialized();
+
+private:
+
+ NoteOfTheDayApplicationAddin();
+ bool check_new_day() const;
+
+ bool m_initialized;
+ gnote::NoteManager * m_manager;
+ sigc::connection m_timeout;
+};
+
+}
+
+#endif
diff --git a/src/addins/noteoftheday/noteofthedaypreferences.cpp b/src/addins/noteoftheday/noteofthedaypreferences.cpp
new file mode 100644
index 0000000..9759d3d
--- /dev/null
+++ b/src/addins/noteoftheday/noteofthedaypreferences.cpp
@@ -0,0 +1,80 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2009 Debarshi Ray
+ *
+ * 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 "debug.hpp"
+#include "gnote.hpp"
+#include "note.hpp"
+#include "notemanager.hpp"
+#include "noteoftheday.hpp"
+#include "noteofthedaypreferences.hpp"
+#include "notewindow.hpp"
+
+namespace noteoftheday {
+
+NoteOfTheDayPreferences::NoteOfTheDayPreferences()
+ : Gtk::VBox(false, 12)
+ , m_open_template_button(_("_Open Today: Template"), true)
+ , m_label(_("Change the <span weight=\"bold\">Today: Template</span> "
+ "note to customize the text that new Today notes have."))
+{
+ m_label.set_line_wrap(true);
+ m_label.set_use_markup(true);
+ pack_start(m_label, true, true, 0);
+
+ m_open_template_button.set_use_underline(true);
+ m_open_template_button.signal_clicked().connect(
+ sigc::mem_fun(*this,
+ &NoteOfTheDayPreferences::open_template_button_clicked));
+ pack_start(m_open_template_button, false, false, 0);
+
+ show_all();
+}
+
+NoteOfTheDayPreferences::~NoteOfTheDayPreferences()
+{
+}
+
+void NoteOfTheDayPreferences::open_template_button_clicked() const
+{
+ gnote::NoteManager & manager = gnote::Gnote::obj().default_note_manager();
+ gnote::Note::Ptr template_note = manager.find(
+ NoteOfTheDay::s_template_title);
+
+ if (0 == template_note) {
+ try {
+ template_note = manager.create(
+ NoteOfTheDay::s_template_title,
+ NoteOfTheDay::get_template_content(
+ NoteOfTheDay::s_template_title));
+ template_note->queue_save(gnote::Note::CONTENT_CHANGED);
+ }
+ catch (const sharp::Exception & e) {
+ ERR_OUT("NoteOfTheDay could not create %s: %s",
+ NoteOfTheDay::s_template_title.c_str(),
+ e.what());
+ }
+ }
+
+ if (0 != template_note)
+ template_note->get_window()->show();
+}
+
+}
diff --git a/src/addins/noteoftheday/noteofthedaypreferences.hpp b/src/addins/noteoftheday/noteofthedaypreferences.hpp
new file mode 100644
index 0000000..1db9728
--- /dev/null
+++ b/src/addins/noteoftheday/noteofthedaypreferences.hpp
@@ -0,0 +1,45 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2009 Debarshi Ray
+ *
+ * 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 __NOTE_OF_THE_DAY_PREFERENCES_HPP_
+#define __NOTE_OF_THE_DAY_PREFERENCES_HPP_
+
+#include <gtkmm.h>
+
+namespace noteoftheday {
+
+class NoteOfTheDayPreferences
+ : public Gtk::VBox
+{
+public:
+
+ NoteOfTheDayPreferences();
+ ~NoteOfTheDayPreferences();
+
+private:
+
+ void open_template_button_clicked() const;
+
+ Gtk::Button m_open_template_button;
+ Gtk::Label m_label;
+};
+
+}
+
+#endif
diff --git a/src/addins/noteoftheday/noteofthedaypreferencesfactory.hpp b/src/addins/noteoftheday/noteofthedaypreferencesfactory.hpp
new file mode 100644
index 0000000..b3f865e
--- /dev/null
+++ b/src/addins/noteoftheday/noteofthedaypreferencesfactory.hpp
@@ -0,0 +1,36 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2009 Debarshi Ray
+ *
+ * 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 __NOTE_OF_THE_DAY_FACTORY_HPP_
+#define __NOTE_OF_THE_DAY_FACTORY_HPP_
+
+#include "addinpreferencefactory.hpp"
+#include "noteofthedaypreferences.hpp"
+
+namespace noteoftheday {
+
+class NoteOfTheDayPreferencesFactory
+ : public gnote::AddinPreferenceFactory<NoteOfTheDayPreferences>
+{
+
+};
+
+}
+
+#endif
diff --git a/src/applicationaddin.cpp b/src/applicationaddin.cpp
new file mode 100644
index 0000000..6bcc074
--- /dev/null
+++ b/src/applicationaddin.cpp
@@ -0,0 +1,26 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2009 Debarshi Ray
+ *
+ * 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 "applicationaddin.hpp"
+
+namespace gnote {
+
+const char * ApplicationAddin::IFACE_NAME = "gnote::ApplicationAddin";
+
+}
diff --git a/src/applicationaddin.hpp b/src/applicationaddin.hpp
index 55da425..da772dd 100644
--- a/src/applicationaddin.hpp
+++ b/src/applicationaddin.hpp
@@ -32,6 +32,8 @@ class ApplicationAddin
: public AbstractAddin
{
public:
+ static const char * IFACE_NAME;
+
/// <summary>
/// Called when Gnote has started up and is nearly 100% initialized.
/// </summary>
diff --git a/src/sharp/datetime.cpp b/src/sharp/datetime.cpp
index 8a700ed..909791e 100644
--- a/src/sharp/datetime.cpp
+++ b/src/sharp/datetime.cpp
@@ -66,6 +66,20 @@ namespace sharp {
return *this;
}
+ int DateTime::day() const
+ {
+ struct tm result;
+ localtime_r(&m_date.tv_sec, &result);
+ return result.tm_mday;
+ }
+
+ int DateTime::month() const
+ {
+ struct tm result;
+ localtime_r(&m_date.tv_sec, &result);
+ return result.tm_mon + 1;
+ }
+
int DateTime::year() const
{
struct tm result;
diff --git a/src/sharp/datetime.hpp b/src/sharp/datetime.hpp
index 2110638..3a9e375 100644
--- a/src/sharp/datetime.hpp
+++ b/src/sharp/datetime.hpp
@@ -46,6 +46,8 @@ public:
DateTime & add_days(int days);
DateTime & add_hours(int hours);
+ int day() const;
+ int month() const;
int year() const;
int day_of_year() const;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]