[gnote] Underline addin.
- From: Hubert Figuière <hub src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnote] Underline addin.
- Date: Wed, 22 Jul 2009 02:47:20 +0000 (UTC)
commit f6840e5b69f7a2536e25892b6f21aeb3be23db27
Author: Hubert Figuiere <hub figuiere net>
Date: Sun Jul 19 11:00:57 2009 -0400
Underline addin.
configure.ac | 1 +
src/addins/Makefile.am | 1 +
src/addins/underline/Makefile.am | 11 +++
src/addins/underline/underlinemenuitem.cpp | 67 ++++++++++++++++++
src/addins/underline/underlinemenuitem.hpp | 56 +++++++++++++++
src/addins/underline/underlinenoteaddin.cpp | 98 +++++++++++++++++++++++++++
src/addins/underline/underlinenoteaddin.hpp | 72 ++++++++++++++++++++
src/addins/underline/underlinetag.hpp | 50 ++++++++++++++
8 files changed, 356 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 87b8d52..4f5c7e7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -228,6 +228,7 @@ src/addins/inserttimestamp/Makefile
src/addins/printnotes/Makefile
src/addins/stickynoteimport/Makefile
src/addins/tomboyimport/Makefile
+src/addins/underline/Makefile
src/dbus/Makefile
po/Makefile.in
po/Makefile
diff --git a/src/addins/Makefile.am b/src/addins/Makefile.am
index 7bbfbe2..e9aeb0f 100644
--- a/src/addins/Makefile.am
+++ b/src/addins/Makefile.am
@@ -9,4 +9,5 @@ SUBDIRS = backlinks \
printnotes \
stickynoteimport \
tomboyimport \
+ underline \
$(NULL)
\ No newline at end of file
diff --git a/src/addins/underline/Makefile.am b/src/addins/underline/Makefile.am
new file mode 100644
index 0000000..504a3c2
--- /dev/null
+++ b/src/addins/underline/Makefile.am
@@ -0,0 +1,11 @@
+
+include $(builddir)/../addins.mk
+
+addinsdir = $(ADDINSDIR)
+addins_LTLIBRARIES = underline.la
+
+
+underline_la_SOURCES = underlinenoteaddin.hpp underlinenoteaddin.cpp \
+ underlinetag.hpp \
+ underlinemenuitem.hpp underlinemenuitem.cpp \
+ $(NULL)
diff --git a/src/addins/underline/underlinemenuitem.cpp b/src/addins/underline/underlinemenuitem.cpp
new file mode 100644
index 0000000..f43a9f4
--- /dev/null
+++ b/src/addins/underline/underlinemenuitem.cpp
@@ -0,0 +1,67 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2009 Hubert Figuiere
+ *
+ * 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 "noteaddin.hpp"
+#include "notewindow.hpp"
+
+#include "underlinemenuitem.hpp"
+
+
+namespace underline {
+
+ UnderlineMenuItem::UnderlineMenuItem(gnote::NoteAddin *addin)
+ : Gtk::CheckMenuItem(Glib::ustring("<u>")
+ + _("_Underline") + "</u>", true)
+ , m_note_addin(addin)
+ , m_event_freeze(false)
+ {
+ gnote::NoteTextMenu::markup_label(*this);
+ m_note_addin->get_window()->text_menu()->signal_show().connect(
+ sigc::mem_fun(*this, &UnderlineMenuItem::menu_shown));
+
+ add_accelerator ("activate",
+ addin->get_window()->get_accel_group(),
+ GDK_U,
+ Gdk::CONTROL_MASK,
+ Gtk::ACCEL_VISIBLE);
+
+ show_all();
+ }
+
+
+ void UnderlineMenuItem::on_activate()
+ {
+ if (!m_event_freeze)
+ m_note_addin->get_buffer()->toggle_active_tag ("underline");
+ }
+
+
+ void UnderlineMenuItem::menu_shown()
+ {
+ m_event_freeze = true;
+ set_active(m_note_addin->get_buffer()->is_active_tag ("underline"));
+ m_event_freeze = false;
+ }
+
+
+}
diff --git a/src/addins/underline/underlinemenuitem.hpp b/src/addins/underline/underlinemenuitem.hpp
new file mode 100644
index 0000000..df8097f
--- /dev/null
+++ b/src/addins/underline/underlinemenuitem.hpp
@@ -0,0 +1,56 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2009 Hubert Figuiere
+ *
+ * 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 __UNDERLINE_MENUITEM_HPP_
+#define __UNDERLINE_MENUITEM_HPP_
+
+#include <gtkmm/checkmenuitem.h>
+
+namespace gnote {
+ class NoteAddin;
+}
+
+
+namespace underline {
+
+
+class UnderlineMenuItem
+ : public Gtk::CheckMenuItem
+{
+public:
+ UnderlineMenuItem(gnote::NoteAddin *);
+
+protected:
+ virtual void on_activate();
+
+private:
+ void menu_shown();
+
+ gnote::NoteAddin * m_note_addin;
+ bool m_event_freeze;
+};
+
+
+
+}
+
+
+#endif
diff --git a/src/addins/underline/underlinenoteaddin.cpp b/src/addins/underline/underlinenoteaddin.cpp
new file mode 100644
index 0000000..15c2c9d
--- /dev/null
+++ b/src/addins/underline/underlinenoteaddin.cpp
@@ -0,0 +1,98 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2009 Hubert Figuiere
+ * Original C# file
+ * (C) 2009 Mark Wakim <markwakim gmail com>
+ *
+ * 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/>.
+ */
+
+
+// Translated from UnderlineNoteAddin.cs:
+
+#include <glibmm/i18n.h>
+
+#include "sharp/modulefactory.hpp"
+#include "underlinemenuitem.hpp"
+#include "underlinenoteaddin.hpp"
+#include "underlinetag.hpp"
+
+
+namespace underline {
+
+ UnderlineModule::UnderlineModule()
+ {
+ ADD_INTERFACE_IMPL(UnderlineNoteAddin);
+ }
+
+ const char * UnderlineModule::id() const
+ {
+ return "UnderlineAddin";
+ }
+ const char * UnderlineModule::name() const
+ {
+ // this is the name of the plugin.
+ return _("Underline");
+ }
+ const char * UnderlineModule::description() const
+ {
+ return _("Adds ability to underline text.");
+ }
+ const char * UnderlineModule::authors() const
+ {
+ return _("Hubert Figuière and the Tomboy Project");
+ }
+ const char * UnderlineModule::category() const
+ {
+ return "Formatting";
+ }
+ const char * UnderlineModule::version() const
+ {
+ return "0.1";
+ }
+
+
+
+ void UnderlineNoteAddin::initialize ()
+ {
+ // If a tag of this name already exists, don't install.
+ if (!get_note()->get_tag_table()->lookup ("underline")) {
+ m_tag = Glib::RefPtr<Gtk::TextTag>(new UnderlineTag ());
+ get_note()->get_tag_table()->add (m_tag);
+ }
+
+ }
+
+
+ void UnderlineNoteAddin::shutdown ()
+ {
+ // Remove the tag only if we installed it.
+ if (m_tag) {
+ get_note()->get_tag_table()->remove (m_tag);
+ }
+ }
+
+
+ void UnderlineNoteAddin::on_note_opened ()
+ {
+ // Add here instead of in Initialize to avoid creating unopened
+ // notes' windows/buffers.
+ add_text_menu_item (new UnderlineMenuItem (this));
+ }
+
+
+
+}
+
diff --git a/src/addins/underline/underlinenoteaddin.hpp b/src/addins/underline/underlinenoteaddin.hpp
new file mode 100644
index 0000000..ac4a07a
--- /dev/null
+++ b/src/addins/underline/underlinenoteaddin.hpp
@@ -0,0 +1,72 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2009 Hubert Figuiere
+ * Original C# file
+ * (C) 2009 Mark Wakim <markwakim gmail com>
+ *
+ * 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/>.
+ */
+
+
+// Translated from UnderlineNoteAddin.cs:
+
+
+#ifndef __ADDIN_UNDERLINENOTEADDIN_H_
+#define __ADDIN_UNDERLINENOTEADDIN_H_
+
+#include <gtkmm/texttag.h>
+
+#include "sharp/dynamicmodule.hpp"
+#include "noteaddin.hpp"
+
+namespace underline {
+
+ class UnderlineModule
+ : public sharp::DynamicModule
+ {
+ public:
+ UnderlineModule();
+ 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;
+ };
+
+
+ DECLARE_MODULE(UnderlineModule);
+
+ class UnderlineNoteAddin
+ : public gnote::NoteAddin
+ {
+ public:
+ static UnderlineNoteAddin* create()
+ {
+ return new UnderlineNoteAddin();
+ }
+ virtual void initialize ();
+ virtual void shutdown ();
+ virtual void on_note_opened ();
+ private:
+ Glib::RefPtr<Gtk::TextTag> m_tag;
+ };
+
+
+}
+
+
+#endif
+
diff --git a/src/addins/underline/underlinetag.hpp b/src/addins/underline/underlinetag.hpp
new file mode 100644
index 0000000..7af82b8
--- /dev/null
+++ b/src/addins/underline/underlinetag.hpp
@@ -0,0 +1,50 @@
+/*
+ * gnote
+ *
+ * Copyright (C) 2009 Hubert Figuiere
+ *
+ * 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 __ADDIN_UNDERLINE_TAG_HPP_
+#define __ADDIN_UNDERLINE_TAG_HPP_
+
+#include <string>
+
+#include "notetag.hpp"
+
+
+namespace underline {
+
+
+class UnderlineTag
+ : public gnote::NoteTag
+{
+public:
+ UnderlineTag()
+ : gnote::NoteTag("underline", CAN_GROW | CAN_UNDO)
+ {
+ property_underline() = Pango::UNDERLINE_SINGLE;
+ }
+};
+
+
+
+}
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]