[gnote] TOC add-in 0.99.0
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] TOC add-in 0.99.0
- Date: Mon, 10 Jun 2013 19:14:41 +0000 (UTC)
commit 3f621a4b64c39d1a1b2b85de313b30cf50373699
Author: Luc Pionchon <pionchon luc gmail com>
Date: Mon Jun 10 18:33:21 2013 +0300
TOC add-in 0.99.0
Fixes Bug 701942.
2013-06-10
The add-in is globally complete feature-wise.
This will target at the version 1.0
See the TODO file for potential future features/ideas.
- code: s/table of content/table of contents/ everywhere, including file names (*)
- code: s/header/heading/ everywhere
- code: TableofcontentAction class in its own file
- help: added a screenshot
(*) s/Table of Content/Table of Contents/ everywhere, including file/folder names,
modified: configure.ac
modified: src/addins/Makefile.am
renamed: src/addins/tableofcontent/Makefile.am ->
src/addins/tableofcontents/Makefile.am
renamed: src/addins/tableofcontent/NEWS -> src/addins/tableofcontents/NEWS
renamed: src/addins/tableofcontent/TODO -> src/addins/tableofcontents/TODO
renamed: src/addins/tableofcontent/HACKING ->
src/addins/tableofcontents/HACKING
renamed: src/addins/tableofcontent/tableofcontent.hpp ->
src/addins/tableofcontents/tableofcontents.hpp
renamed: src/addins/tableofcontent/tableofcontentaction.cpp ->
src/addins/tableofcontents/tableofcontentsaction.cpp
renamed: src/addins/tableofcontent/tableofcontentaction.hpp ->
src/addins/tableofcontents/tableofcontentsaction.hpp
renamed: src/addins/tableofcontent/tableofcontentmenuitem.cpp ->
src/addins/tableofcontents/tableofcontentsmenuitem.cpp
renamed: src/addins/tableofcontent/tableofcontentmenuitem.hpp ->
src/addins/tableofcontents/tableofcontentsmenuitem.hpp
renamed: src/addins/tableofcontent/tableofcontentnoteaddin.cpp ->
src/addins/tableofcontents/tableofcontentsnoteaddin.cpp
renamed: src/addins/tableofcontent/tableofcontentnoteaddin.hpp ->
src/addins/tableofcontents/tableofcontentsnoteaddin.hpp
renamed: src/addins/tableofcontent/tableofcontent.desktop.in ->
src/addins/tableofcontents/tableofcontents.desktop.in
renamed: help/C/gnote-addin-tableofcontent.page -> help/C/gnote-addin-tableofcontents.page
modified: help/Makefile.am
configure.ac | 2 +-
help/C/figures/gnote-addin-table-of-contents.png | Bin 0 -> 35036 bytes
...ntent.page => gnote-addin-tableofcontents.page} | 10 ++-
help/Makefile.am | 3 +-
src/addins/Makefile.am | 2 +-
src/addins/tableofcontent/Makefile.am | 23 ----
.../tableofcontent/tableofcontentmenuitem.cpp | 131 -------------------
src/addins/tableofcontents/HACKING | 7 +
src/addins/tableofcontents/Makefile.am | 25 ++++
.../{tableofcontent => tableofcontents}/NEWS | 21 ++-
.../{tableofcontent => tableofcontents}/TODO | 68 +++++------
.../tableofcontents.desktop.in} | 6 +-
.../tableofcontents.hpp} | 18 ++--
.../tableofcontents/tableofcontentsaction.cpp | 75 +++++++++++
.../tableofcontentsaction.hpp} | 42 +++---
.../tableofcontents/tableofcontentsmenuitem.cpp | 90 +++++++++++++
.../tableofcontentsmenuitem.hpp} | 34 ++----
.../tableofcontentsnoteaddin.cpp} | 133 ++++++++++----------
.../tableofcontentsnoteaddin.hpp} | 30 +++---
19 files changed, 378 insertions(+), 342 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 7cb6643..12dbf22 100644
--- a/configure.ac
+++ b/configure.ac
@@ -173,7 +173,7 @@ src/addins/printnotes/Makefile
src/addins/replacetitle/Makefile
src/addins/statistics/Makefile
src/addins/stickynoteimport/Makefile
-src/addins/tableofcontent/Makefile
+src/addins/tableofcontents/Makefile
src/addins/tomboyimport/Makefile
src/addins/underline/Makefile
src/addins/webdavsyncservice/Makefile
diff --git a/help/C/figures/gnote-addin-table-of-contents.png
b/help/C/figures/gnote-addin-table-of-contents.png
new file mode 100644
index 0000000..33d8c52
Binary files /dev/null and b/help/C/figures/gnote-addin-table-of-contents.png differ
diff --git a/help/C/gnote-addin-tableofcontent.page b/help/C/gnote-addin-tableofcontents.page
similarity index 95%
rename from help/C/gnote-addin-tableofcontent.page
rename to help/C/gnote-addin-tableofcontents.page
index e9136f0..5087cad 100644
--- a/help/C/gnote-addin-tableofcontent.page
+++ b/help/C/gnote-addin-tableofcontents.page
@@ -24,7 +24,7 @@
<info>
<revision
status="candidate"
- pkgversion="gnote-addin-tableofcontent-version-0.10"
+ pkgversion="gnote-addin-tableofcontents-version-0.99.0"
/>
<!-- Status:
stub contains little to no real content
@@ -106,6 +106,14 @@
</section>
+<section id="screenshot"><title>Screenshot</title>
+ <figure>
+ <title>A structured note with its table of contents</title>
+ <media type="image" src="figures/gnote-addin-table-of-contents.png" mime="image/png">
+ </media>
+ </figure>
+</section>
+
<section id="navigating"><title>Navigating through long notes</title>
diff --git a/help/Makefile.am b/help/Makefile.am
index 4aa87bb..2fc6d52 100644
--- a/help/Makefile.am
+++ b/help/Makefile.am
@@ -5,6 +5,7 @@ HELP_MEDIA = \
figures/add-notebook-search.png \
figures/add-to-notebook.png \
figures/delete-notebook.png \
+ figures/gnote-addin-table-of-contents.png \
figures/gnote-new-note.png \
figures/gnote-pindown.png \
figures/gnote-pinup.png \
@@ -32,7 +33,7 @@ HELP_FILES = \
gnote-addin-replacetitle.page \
gnote-addin-sync-local.page \
gnote-addin-sync-webdav.page \
- gnote-addin-tableofcontent.page \
+ gnote-addin-tableofcontents.page \
gnote-addin-timestamp.page \
gnote-addin-underline.page \
gnote-bulleted-lists.page \
diff --git a/src/addins/Makefile.am b/src/addins/Makefile.am
index 3df3e82..2503cb0 100644
--- a/src/addins/Makefile.am
+++ b/src/addins/Makefile.am
@@ -13,7 +13,7 @@ SUBDIRS = backlinks \
replacetitle \
statistics \
stickynoteimport \
- tableofcontent \
+ tableofcontents \
tomboyimport \
underline \
webdavsyncservice \
diff --git a/src/addins/tableofcontents/HACKING b/src/addins/tableofcontents/HACKING
new file mode 100644
index 0000000..f05f824
--- /dev/null
+++ b/src/addins/tableofcontents/HACKING
@@ -0,0 +1,7 @@
+
+== Little release manual
+ update NEWS
+ + update TODO
+ + .desktop: version field
+ + help topic status/pkgversion
+ ==> commit -m "version x.y")
diff --git a/src/addins/tableofcontents/Makefile.am b/src/addins/tableofcontents/Makefile.am
new file mode 100644
index 0000000..2b208d3
--- /dev/null
+++ b/src/addins/tableofcontents/Makefile.am
@@ -0,0 +1,25 @@
+
+include $(builddir)/../addins.mk
+
+ INTLTOOL_DESKTOP_RULE@
+
+desktop_in_files = tableofcontents.desktop.in
+desktop_files = $(desktop_in_files:.desktop.in=.desktop)
+
+addinsdir = $(ADDINSDIR)
+addins_LTLIBRARIES = tableofcontents.la
+addins_DATA = $(desktop_files)
+
+
+tableofcontents_la_SOURCES = \
+ tableofcontents.hpp \
+ tableofcontentsnoteaddin.hpp \
+ tableofcontentsnoteaddin.cpp \
+ tableofcontentsmenuitem.hpp \
+ tableofcontentsmenuitem.cpp \
+ tableofcontentsaction.hpp \
+ tableofcontentsaction.cpp \
+ $(NULL)
+
+EXTRA_DIST = $(desktop_in_files)
+DISTCLEANFILES = $(desktop_files)
diff --git a/src/addins/tableofcontent/NEWS b/src/addins/tableofcontents/NEWS
similarity index 83%
rename from src/addins/tableofcontent/NEWS
rename to src/addins/tableofcontents/NEWS
index f68bad1..1fc5383 100644
--- a/src/addins/tableofcontent/NEWS
+++ b/src/addins/tableofcontents/NEWS
@@ -1,13 +1,20 @@
-NEWS for Add-in: Table of Content
-=================================
+NEWS for Add-in: Table of Contents
+==================================
-(NOTE: little release manual:
- update NEWS + .desktop version/enabled=false + help topic status/pkgversion ==> commit -m "version x.y")
+== 0.99.0
+ 2013-06-10
+ The add-in is globally complete feature-wise.
+ This will target at the version 1.0
+ See the TODO file for potential future features/ideas.
+
+- code: s/table of content/table of contents/ everywhere, including file names
+- code: s/header/heading/ everywhere
+- code: TableofcontentAction class in its own file
+- help: added a screenshot
== 0.11
- fix: use bit-wise operations to test modifier masks (Ctrl/Alt)
-
== 0.10
- fix: header-2 arrow, 2 chars does not match with some fonts.
Use a single char one.
@@ -60,8 +67,8 @@ NEWS for Add-in: Table of Content
- code cleanup
== 0.3
-- added TableofcontentModule::copyright()
-- used a namespaced-enum for header Levels. New file tableofcontent.hpp
+- added TableofcontentsModule::copyright()
+- used a namespaced-enum for header Levels. New file tableofcontents.hpp
- code review changes (https://bugzilla.gnome.org/show_bug.cgi?id=698059)
== 0.2
diff --git a/src/addins/tableofcontent/TODO b/src/addins/tableofcontents/TODO
similarity index 86%
rename from src/addins/tableofcontent/TODO
rename to src/addins/tableofcontents/TODO
index bbfc97a..eec9bc4 100644
--- a/src/addins/tableofcontent/TODO
+++ b/src/addins/tableofcontents/TODO
@@ -1,25 +1,20 @@
-TODO for Add-in: Table of Content
-=================================
+TODO for Add-in: Table of Contents
+==================================
-== Now
-- header --> heading, also in code
-- rename files before 3.10, tableofcontent_S_
+== NOW
-- Ctrl-1/2 Ctrl-Alt-1 has no effect, before toc is opened once
- gnote bug?
+
+== Later
- check GFDL usage in:
- help/C/gnote-addin-tableofcontent.page:
+ help/C/gnote-addin-tableofcontents.page:
FIXME: is this true? (no invariant, no front, no back?)
FIXME: does the statement have to show in the rendered document?
FIXME: is this true? Is there a (GNOME? Yelp?) common GFDL topic?
-- add a screenshot to the help page (?)
-
-
-
-== Later
+- if the heading is strike-through, reflect this in the toc.
+ same with highlight? italic?
- Huge is not huge enough
There is little visual difference between large and huge
@@ -32,32 +27,32 @@ TODO for Add-in: Table of Content
Could also be: general config options for font sizes/factor (for S/N/L/H)
Could also be: allow any sizes <size:n>, with n = factor (not only S/N/L/H)
-- When no headers, still show the note title in toc
+- When no headers, still show the note title in toc?
this is usefull to jump to the top of a long (unstructured) note
-
-
-== Maybe
-
-- Highlight the header when jumping to it
- ==> More visual, especially when the header does not scroll up to the head of the window
- remove highlight as soon as cursor moved
- (like search results, for example)
-
- Undo as a single user action, when setting headers
Note: tomboy/gnote handles poorly undo/redo,
this item may need to upgrade the undo system
-- Set where the toc menu item appears in the Tools menu
- --> next to "What Links Here?"
- (I think there is a way to say where)
-
- Keyboard shortcuts for jumping between sessions
Jump to next section
Jump to previous section
- Q: What shortcuts? the ones with up/down arrow ar all(?) taken?
+ Q: What shortcuts? the ones with up/down arrow are all(?) taken?
Alt-right and Alt-left, usually used for prev/next, are used for bullet list indentation
- (can this change?)
+ (can this change?)
+
+
+== Maybe
+
+- Print/export the table of contents
+ if Table of Contents is enabled,
+ it could be added to the contents when printing or exporting (to HTML)
+ HTML export:
+ - add toc below title
+ - mark headers as H2 and H3
+ Print
+ - add toc below title
+ - print to PDF (?)
- Customizable header tags
« a header level x is a full line with tags Tx »
@@ -77,15 +72,14 @@ TODO for Add-in: Table of Content
Todo: make code generic + (g)settings + preference UI + help topic
-- Print/export the table of content
- if Table of Content is enabled, it could be added to the content when printing or exporting (to HTML)
- HTML export:
- - add toc below title
- - mark headers as H2 and H3
- Print
- - add toc below title
- - print to PDF (?)
+- Highlight the header when jumping to it
+ ==> More visual, especially when the header does not scroll up to the head of the window
+ remove highlight as soon as cursor moved
+ (like search results, for example)
+- Set where the toc menu item appears in the Tools menu
+ --> next to "What Links Here?"
+ (I think there is a way to say where)
== Maybe not
diff --git a/src/addins/tableofcontent/tableofcontent.desktop.in
b/src/addins/tableofcontents/tableofcontents.desktop.in
similarity index 81%
rename from src/addins/tableofcontent/tableofcontent.desktop.in
rename to src/addins/tableofcontents/tableofcontents.desktop.in
index 67db07b..afcc836 100644
--- a/src/addins/tableofcontent/tableofcontent.desktop.in
+++ b/src/addins/tableofcontents/tableofcontents.desktop.in
@@ -1,10 +1,10 @@
[AddinInfo]
-Id=TableofcontentAddin
+Id=TableofcontentsAddin
_Name=Table of Contents
_Description=Navigate long structured notes. Set section and subsection headings in your note, and the Table
of Contents will show in a menu.
_Authors=Luc Pionchon
Category=Tools
-Version=0.10
+Version=0.99.0
DefaultEnabled=false
-Module=tableofcontent
+Module=tableofcontents
_Copyright=© 2013 Luc Pionchon
diff --git a/src/addins/tableofcontent/tableofcontent.hpp b/src/addins/tableofcontents/tableofcontents.hpp
similarity index 68%
copy from src/addins/tableofcontent/tableofcontent.hpp
copy to src/addins/tableofcontents/tableofcontents.hpp
index 660b576..41b1b11 100644
--- a/src/addins/tableofcontent/tableofcontent.hpp
+++ b/src/addins/tableofcontents/tableofcontents.hpp
@@ -22,22 +22,22 @@
/* Note: the enum is in this file because
- when it was in tableofcontentnoteaddin.hpp,
- I could not use it also in tableofcontentmenuitem.cpp,
+ when it was in tableofcontentsnoteaddin.hpp,
+ I could not use it also in tableofcontentsmenuitem.cpp,
there was a scope error, which I could not solve.
*/
#ifndef __TABLEOFCONTENT_HPP_
#define __TABLEOFCONTENT_HPP_
-namespace tableofcontent {
+namespace tableofcontents {
-namespace Header { // Header level,
- enum Type { // Header::Type (can be used as a type)
- Title, // Header::Title == Note title
- Level_1, // Header::Level_1 == 1st level header == Ctrl-1
- Level_2, // Header::Level_2 == 2nd level header == Ctrl-2
- None // Header::None
+namespace Heading { // Heading level,
+ enum Type { // Heading::Type (can be used as a type)
+ Title, // Heading::Title == Note title
+ Level_1, // Heading::Level_1 == 1st level heading == Ctrl-1
+ Level_2, // Heading::Level_2 == 2nd level heading == Ctrl-2
+ None // Heading::None
};
}
diff --git a/src/addins/tableofcontents/tableofcontentsaction.cpp
b/src/addins/tableofcontents/tableofcontentsaction.cpp
new file mode 100644
index 0000000..2ea96c7
--- /dev/null
+++ b/src/addins/tableofcontents/tableofcontentsaction.cpp
@@ -0,0 +1,75 @@
+/*
+ * "Table of Contents" is a Note add-in for Gnote.
+ * It lists note's table of contents in a menu.
+ *
+ * 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.h>
+#include <glibmm/i18n.h>
+#include <gtkmm.h>
+
+#include "tableofcontentsaction.hpp"
+
+namespace tableofcontents {
+
+
+Glib::RefPtr<Gtk::Action> TableofcontentsAction::create(const sigc::slot<void, Gtk::Menu*> & slot)
+{
+ return Glib::RefPtr<Gtk::Action>(new TableofcontentsAction(slot));
+}
+
+TableofcontentsAction::TableofcontentsAction(const sigc::slot<void, Gtk::Menu*> & slot)
+ : Gtk::Action("TableofcontentsAction", Gtk::Stock::JUMP_TO,
+ _("Table of Contents"),
+ _("Table of Contents")
+ )
+ , m_update_menu_slot(slot)
+{
+}
+
+Gtk::Widget *TableofcontentsAction::create_menu_item_vfunc()
+{
+ m_submenu_built = false;
+ Gtk::ImageMenuItem *menu_item = new Gtk::ImageMenuItem;
+ m_menu = manage(new Gtk::Menu);
+ m_menu->signal_hide().connect(
+ sigc::mem_fun(*this, &TableofcontentsAction::on_menu_hidden));
+ menu_item->set_submenu(*m_menu);
+ return menu_item;
+}
+
+void TableofcontentsAction::on_activate()
+{
+ Gtk::Action::on_activate();
+ update_menu();
+}
+
+void TableofcontentsAction::update_menu()
+{
+ m_update_menu_slot(m_menu);
+ m_submenu_built = true;
+}
+
+void TableofcontentsAction::on_menu_hidden()
+{
+ m_submenu_built = false;
+}
+
+
+
+
+} //namespace
diff --git a/src/addins/tableofcontent/tableofcontent.hpp
b/src/addins/tableofcontents/tableofcontentsaction.hpp
similarity index 50%
rename from src/addins/tableofcontent/tableofcontent.hpp
rename to src/addins/tableofcontents/tableofcontentsaction.hpp
index 660b576..011ce70 100644
--- a/src/addins/tableofcontent/tableofcontent.hpp
+++ b/src/addins/tableofcontents/tableofcontentsaction.hpp
@@ -2,7 +2,7 @@
* "Table of Contents" is a Note add-in for Gnote.
* It lists note's table of contents in a menu.
*
- * Copyright (C) 2013 Luc Pionchon <pionchon luc gmail com>
+ * 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
@@ -18,30 +18,30 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* An enum for different header levels in the toc */
+#ifndef __TABLEOFCONTENT_ACTION_HPP_
+#define __TABLEOFCONTENT_ACTION_HPP_
-/* Note: the enum is in this file because
- when it was in tableofcontentnoteaddin.hpp,
- I could not use it also in tableofcontentmenuitem.cpp,
- there was a scope error, which I could not solve.
- */
-
-#ifndef __TABLEOFCONTENT_HPP_
-#define __TABLEOFCONTENT_HPP_
+namespace tableofcontents {
-namespace tableofcontent {
+class TableofcontentsAction
+ : public Gtk::Action
+{
+public:
+ static Glib::RefPtr<Gtk::Action> create(const sigc::slot<void, Gtk::Menu*> & slot);
+protected:
+ virtual Gtk::Widget *create_menu_item_vfunc();
+ virtual void on_activate();
+private:
+ TableofcontentsAction(const sigc::slot<void, Gtk::Menu*> & slot);
+ void update_menu();
+ void on_menu_hidden();
-namespace Header { // Header level,
- enum Type { // Header::Type (can be used as a type)
- Title, // Header::Title == Note title
- Level_1, // Header::Level_1 == 1st level header == Ctrl-1
- Level_2, // Header::Level_2 == 2nd level header == Ctrl-2
- None // Header::None
- };
-}
+ bool m_submenu_built;
+ Gtk::Menu *m_menu;
+ sigc::slot<void, Gtk::Menu*> m_update_menu_slot;
+};
}
-
-#endif
\ No newline at end of file
+#endif
diff --git a/src/addins/tableofcontents/tableofcontentsmenuitem.cpp
b/src/addins/tableofcontents/tableofcontentsmenuitem.cpp
new file mode 100644
index 0000000..dace129
--- /dev/null
+++ b/src/addins/tableofcontents/tableofcontentsmenuitem.cpp
@@ -0,0 +1,90 @@
+/*
+ * "Table of Contents" is a Note add-in for Gnote.
+ * It lists note's table of contents in a menu.
+ *
+ * Copyright (C) 2013 Luc Pionchon <pionchon luc 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/>.
+ */
+
+/* A subclass of ImageMenuItem to show a toc menu item */
+
+#include <glibmm/i18n.h>
+
+#include <gtkmm/stock.h>
+
+#include "iconmanager.hpp"
+#include "notewindow.hpp"
+
+#include "tableofcontentsmenuitem.hpp"
+#include "tableofcontents.hpp"
+
+namespace tableofcontents {
+
+
+TableofcontentsMenuItem::TableofcontentsMenuItem (
+ const gnote::Note::Ptr & note,
+ const std::string & heading,
+ Heading::Type heading_level,
+ int heading_position)
+ : m_note (note)
+ , m_heading_position (heading_position)
+{
+ //Create a new menu item, with style depending on the heading level:
+ /* +-----------------+
+ |[] NOTE TITLE | <---- Title == note icon + bold note title
+ | > Heading 1 | <---- Level_1 == arrow icon + heading title
+ | > Heading 1 |
+ | → heading 2 | <---- Level_2 == (no icon) + indent string + heading title
+ | → heading 2 |
+ | → heading 2 |
+ | > Heading 1 |
+ +-----------------+
+ */
+
+ set_use_underline (false); //we don't want potential '_' in the heading to be used as mnemonic
+
+ if (heading_level == Heading::Title) {
+ set_image(*manage(new Gtk::Image(gnote::IconManager::obj().get_icon(gnote::IconManager::NOTE, 16))));
+ Gtk::Label *label = (Gtk::Label*)get_child();
+ label->set_markup("<b>" + heading + "</b>");
+ }
+ else if (heading_level == Heading::Level_1) {
+ set_image(*manage(new Gtk::Image(Gtk::Stock::GO_FORWARD, Gtk::ICON_SIZE_MENU)));
+ set_label(heading);
+ }
+ else if (heading_level == Heading::Level_2) {
+ set_label("→ " + heading);
+ }
+}
+
+
+void TableofcontentsMenuItem::on_activate ()
+{
+ if (!m_note) {
+ return;
+ }
+
+ // Scroll the TextView and place the cursor on the heading
+ Gtk::TextIter heading_iter;
+ heading_iter = m_note->get_buffer()->get_iter_at_offset (m_heading_position);
+ m_note->get_window()->editor()->scroll_to (heading_iter,
+ 0.0, //[0.0,0.5] within_margin, margin as a fraction of screen
size.
+ 0.0, //[0.0,1.0] horizontal alignment of mark within visible
area.
+ 0.0);//[0.0,1.0] vertical alignment of mark within visible
area.
+ m_note->get_buffer()->place_cursor (heading_iter);
+}
+
+
+} //namespace
diff --git a/src/addins/tableofcontent/tableofcontentmenuitem.hpp
b/src/addins/tableofcontents/tableofcontentsmenuitem.hpp
similarity index 59%
rename from src/addins/tableofcontent/tableofcontentmenuitem.hpp
rename to src/addins/tableofcontents/tableofcontentsmenuitem.hpp
index 3f13e53..bd5b142 100644
--- a/src/addins/tableofcontent/tableofcontentmenuitem.hpp
+++ b/src/addins/tableofcontents/tableofcontentsmenuitem.hpp
@@ -28,36 +28,19 @@
#include <gtkmm/imagemenuitem.h>
#include "note.hpp"
-#include "tableofcontent.hpp"
+#include "tableofcontents.hpp"
-namespace tableofcontent {
+namespace tableofcontents {
-class TableofcontentAction
- : public Gtk::Action
-{
-public:
- static Glib::RefPtr<Gtk::Action> create(const sigc::slot<void, Gtk::Menu*> & slot);
-protected:
- virtual Gtk::Widget *create_menu_item_vfunc();
- virtual void on_activate();
-private:
- TableofcontentAction(const sigc::slot<void, Gtk::Menu*> & slot);
- void update_menu();
- void on_menu_hidden();
- bool m_submenu_built;
- Gtk::Menu *m_menu;
- sigc::slot<void, Gtk::Menu*> m_update_menu_slot;
-};
-
-class TableofcontentMenuItem : public Gtk::ImageMenuItem
+class TableofcontentsMenuItem : public Gtk::ImageMenuItem
{
public:
- TableofcontentMenuItem ( const gnote::Note::Ptr & note,
- const std::string & header,
- Header::Type header_level,
- int header_position
+ TableofcontentsMenuItem ( const gnote::Note::Ptr & note,
+ const std::string & heading,
+ Heading::Type heading_level,
+ int heading_position
);
protected:
@@ -65,11 +48,10 @@ protected:
private:
gnote::Note::Ptr m_note; //the Note referenced by the menu item
- int m_header_position; //the position of the header in the Note
+ int m_heading_position; //the position of the heading in the Note
// == offset in the GtkTextBuffer
};
}
-
#endif
diff --git a/src/addins/tableofcontent/tableofcontentnoteaddin.cpp
b/src/addins/tableofcontents/tableofcontentsnoteaddin.cpp
similarity index 67%
rename from src/addins/tableofcontent/tableofcontentnoteaddin.cpp
rename to src/addins/tableofcontents/tableofcontentsnoteaddin.cpp
index 6a04393..4e762e5 100644
--- a/src/addins/tableofcontent/tableofcontentnoteaddin.cpp
+++ b/src/addins/tableofcontents/tableofcontentsnoteaddin.cpp
@@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* A subclass of NoteAddin, implementing the Table of Content add-in */
+/* A subclass of NoteAddin, implementing the Table of Contents add-in */
#include <glibmm/i18n.h>
@@ -33,30 +33,31 @@
#include "notebuffer.hpp"
#include "utils.hpp"
-#include "tableofcontent.hpp"
-#include "tableofcontentnoteaddin.hpp"
-#include "tableofcontentmenuitem.hpp"
+#include "tableofcontents.hpp"
+#include "tableofcontentsnoteaddin.hpp"
+#include "tableofcontentsmenuitem.hpp"
+#include "tableofcontentsaction.hpp"
-namespace tableofcontent {
+namespace tableofcontents {
-TableofcontentModule::TableofcontentModule()
+TableofcontentsModule::TableofcontentsModule()
{
- ADD_INTERFACE_IMPL(TableofcontentNoteAddin);
+ ADD_INTERFACE_IMPL(TableofcontentsNoteAddin);
}
-TableofcontentNoteAddin::TableofcontentNoteAddin()
+TableofcontentsNoteAddin::TableofcontentsNoteAddin()
: m_toc_menu (NULL)
, m_toc_menu_built (false)
{
}
-void TableofcontentNoteAddin::initialize () {}
-void TableofcontentNoteAddin::shutdown () {}
+void TableofcontentsNoteAddin::initialize () {}
+void TableofcontentsNoteAddin::shutdown () {}
Gtk::ImageMenuItem * new_toc_menu_item ()
-//create a menu item like: "[]_Table_of_Content______Ctrl-Alt-1__>"
+//create a menu item like: "[]_Table_of_Contents______Ctrl-Alt-1__>"
{
Gtk::ImageMenuItem * menu_item = manage(new Gtk::ImageMenuItem ());
menu_item->set_image(*manage(new Gtk::Image(Gtk::Stock::JUMP_TO, Gtk::ICON_SIZE_MENU)));
@@ -74,45 +75,45 @@ Gtk::ImageMenuItem * new_toc_menu_item ()
}
-void TableofcontentNoteAddin::on_note_opened ()
+void TableofcontentsNoteAddin::on_note_opened ()
{
m_toc_menu = manage(new Gtk::Menu);
m_toc_menu->signal_hide().connect(
- sigc::mem_fun(*this, &TableofcontentNoteAddin::on_menu_hidden));
+ sigc::mem_fun(*this, &TableofcontentsNoteAddin::on_menu_hidden));
- Glib::RefPtr<Gtk::Action> action = TableofcontentAction::create(
- sigc::mem_fun(*this, &TableofcontentNoteAddin::update_menu));
+ Glib::RefPtr<Gtk::Action> action = TableofcontentsAction::create(
+ sigc::mem_fun(*this, &TableofcontentsNoteAddin::update_menu));
add_note_action(action, 600);
// Reacts to key press events
get_note()->get_window()->signal_key_press_event().connect(
- sigc::mem_fun(*this, &TableofcontentNoteAddin::on_key_pressed));
+ sigc::mem_fun(*this, &TableofcontentsNoteAddin::on_key_pressed));
// TOC can show up also in the contextual menu
get_note()->get_window()->editor()->signal_populate_popup().connect(
- sigc::mem_fun(*this, &TableofcontentNoteAddin::on_populate_popup));
+ sigc::mem_fun(*this, &TableofcontentsNoteAddin::on_populate_popup));
- // Header tags
+ // Heading tags
m_tag_bold = get_note()->get_tag_table()->lookup ("bold");
m_tag_large = get_note()->get_tag_table()->lookup ("size:large");
m_tag_huge = get_note()->get_tag_table()->lookup ("size:huge");
}
-void TableofcontentNoteAddin::update_menu(Gtk::Menu *menu)
+void TableofcontentsNoteAddin::update_menu(Gtk::Menu *menu)
{
populate_toc_menu(menu);
}
-void TableofcontentNoteAddin::on_menu_hidden()
+void TableofcontentsNoteAddin::on_menu_hidden()
{
m_toc_menu_built = false; //force the submenu to rebuild next time it's supposed to show
}
-void TableofcontentNoteAddin::populate_toc_menu (Gtk::Menu *toc_menu, bool has_action_entries)
-//populate a menu with Note's table of content
+void TableofcontentsNoteAddin::populate_toc_menu (Gtk::Menu *toc_menu, bool has_action_entries)
+//populate a menu with Note's table of contents
{
// Clear out the old list
std::vector<Gtk::Widget*> menu_items = toc_menu->get_children();
@@ -122,12 +123,12 @@ void TableofcontentNoteAddin::populate_toc_menu (Gtk::Menu *toc_menu, bool has_a
}
// Build a new list
- std::list<TableofcontentMenuItem*> items;
- get_tableofcontent_menu_items(items);
+ std::list<TableofcontentsMenuItem*> items;
+ get_tableofcontents_menu_items(items);
- for(std::list<TableofcontentMenuItem*>::iterator iter = items.begin();
+ for(std::list<TableofcontentsMenuItem*>::iterator iter = items.begin();
iter != items.end(); ++iter) {
- TableofcontentMenuItem *item(*iter);
+ TableofcontentsMenuItem *item(*iter);
item->show_all();
toc_menu->append(*item);
}
@@ -152,18 +153,18 @@ void TableofcontentNoteAddin::populate_toc_menu (Gtk::Menu *toc_menu, bool has_a
item = manage(new Gtk::MenuItem (_("Heading 1")));
item->add_accelerator("activate", get_note()->get_window()->get_accel_group(), GDK_KEY_1,
Gdk::CONTROL_MASK, Gtk::ACCEL_VISIBLE);
- item->signal_activate().connect(sigc::mem_fun(*this, &TableofcontentNoteAddin::on_level_1_activated));
+ item->signal_activate().connect(sigc::mem_fun(*this, &TableofcontentsNoteAddin::on_level_1_activated));
item->show ();
toc_menu->append(*item);
item = manage(new Gtk::MenuItem (_("Heading 2")));
item->add_accelerator("activate", get_note()->get_window()->get_accel_group(), GDK_KEY_2,
Gdk::CONTROL_MASK, Gtk::ACCEL_VISIBLE);
- item->signal_activate().connect(sigc::mem_fun(*this, &TableofcontentNoteAddin::on_level_2_activated));
+ item->signal_activate().connect(sigc::mem_fun(*this, &TableofcontentsNoteAddin::on_level_2_activated));
item->show ();
toc_menu->append(*item);
item = manage(new Gtk::MenuItem (_("Table of Contents Help")));
- item->signal_activate().connect(sigc::mem_fun(*this, &TableofcontentNoteAddin::on_toc_help_activated));
+ item->signal_activate().connect(sigc::mem_fun(*this, &TableofcontentsNoteAddin::on_toc_help_activated));
item->show ();
toc_menu->append(*item);
}
@@ -171,7 +172,7 @@ void TableofcontentNoteAddin::populate_toc_menu (Gtk::Menu *toc_menu, bool has_a
}
-void TableofcontentNoteAddin::on_populate_popup (Gtk::Menu* popup_menu)
+void TableofcontentsNoteAddin::on_populate_popup (Gtk::Menu* popup_menu)
//prepened a toc submenu in the contextual menu
{
Gtk::Menu *toc_menu = manage(new Gtk::Menu());
@@ -189,7 +190,7 @@ void TableofcontentNoteAddin::on_populate_popup (Gtk::Menu* popup_menu)
}
-bool TableofcontentNoteAddin::has_tag_over_range (Glib::RefPtr<Gtk::TextTag> tag, Gtk::TextIter start,
Gtk::TextIter end)
+bool TableofcontentsNoteAddin::has_tag_over_range (Glib::RefPtr<Gtk::TextTag> tag, Gtk::TextIter start,
Gtk::TextIter end)
//return true if tag is set from start to end
{
bool has = false;
@@ -201,36 +202,36 @@ bool TableofcontentNoteAddin::has_tag_over_range (Glib::RefPtr<Gtk::TextTag> tag
}
-Header::Type TableofcontentNoteAddin::get_header_level_for_range (Gtk::TextIter start, Gtk::TextIter end)
-//return the header level from start to end
+Heading::Type TableofcontentsNoteAddin::get_heading_level_for_range (Gtk::TextIter start, Gtk::TextIter end)
+//return the heading level from start to end
{
if (has_tag_over_range (m_tag_bold, start, end)) {
if (has_tag_over_range (m_tag_huge , start, end)) {
- return Header::Level_1;
+ return Heading::Level_1;
}
else if (has_tag_over_range (m_tag_large, start, end)) {
- return Header::Level_2;
+ return Heading::Level_2;
}
else {
- return Header::None;
+ return Heading::None;
}
}
else {
- return Header::None;
+ return Heading::None;
}
}
-void TableofcontentNoteAddin::get_tableofcontent_menu_items(std::list<TableofcontentMenuItem*> & items)
-//go through the note text, and list all lines tagged as header,
-//and for each header, create a new TableofcontentMenuItem.
+void TableofcontentsNoteAddin::get_tableofcontents_menu_items(std::list<TableofcontentsMenuItem*> & items)
+//go through the note text, and list all lines tagged as heading,
+//and for each heading, create a new TableofcontentsMenuItem.
{
- TableofcontentMenuItem *item = NULL;
+ TableofcontentsMenuItem *item = NULL;
- std::string header;
- Header::Type header_level;
- int header_position;
+ std::string heading;
+ Heading::Type heading_level;
+ int heading_position;
Gtk::TextIter iter, iter_end, eol;
@@ -243,34 +244,34 @@ void TableofcontentNoteAddin::get_tableofcontent_menu_items(std::list<Tableofcon
eol = iter;
eol.forward_to_line_end();
- header_level = get_header_level_for_range (iter, eol);
+ heading_level = get_heading_level_for_range (iter, eol);
- if (header_level == Header::Level_1 || header_level == Header::Level_2) {
- header_position = iter.get_offset();
- header = iter.get_text(eol);
+ if (heading_level == Heading::Level_1 || heading_level == Heading::Level_2) {
+ heading_position = iter.get_offset();
+ heading = iter.get_text(eol);
if (items.size() == 0) {
- //It's the first header found,
+ //It's the first heading found,
//we also insert an entry linked to the Note's title:
- item = manage(new TableofcontentMenuItem (get_note(), get_note()->get_title(), Header::Title, 0));
+ item = manage(new TableofcontentsMenuItem (get_note(), get_note()->get_title(), Heading::Title, 0));
items.push_back(item);
}
- item = manage(new TableofcontentMenuItem (get_note(), header, header_level, header_position));
+ item = manage(new TableofcontentsMenuItem (get_note(), heading, heading_level, heading_position));
items.push_back(item);
}
iter.forward_visible_line(); //next line
}
}
-void TableofcontentNoteAddin::on_level_1_activated()
+void TableofcontentsNoteAddin::on_level_1_activated()
{
- headification_switch (Header::Level_1);
+ headification_switch (Heading::Level_1);
}
-void TableofcontentNoteAddin::on_level_2_activated()
+void TableofcontentsNoteAddin::on_level_2_activated()
{
- headification_switch (Header::Level_2);
+ headification_switch (Heading::Level_2);
}
-void TableofcontentNoteAddin::on_toc_popup_activated()
+void TableofcontentsNoteAddin::on_toc_popup_activated()
{
if(m_toc_menu_built == false) {
populate_toc_menu(m_toc_menu, false);
@@ -278,7 +279,7 @@ void TableofcontentNoteAddin::on_toc_popup_activated()
}
m_toc_menu->popup(0, 0);
}
-void TableofcontentNoteAddin::on_toc_help_activated()
+void TableofcontentsNoteAddin::on_toc_help_activated()
{
gnote::NoteWindow* window = get_note()->get_window();
gnote::utils::show_help("gnote", "addin-tableofcontents",
@@ -286,7 +287,7 @@ void TableofcontentNoteAddin::on_toc_help_activated()
}
-bool TableofcontentNoteAddin::on_key_pressed(GdkEventKey *ev)
+bool TableofcontentsNoteAddin::on_key_pressed(GdkEventKey *ev)
//return true if signal handled, false otherwise
//NOTE: if a menu item has an accelerator,
// its entry is needed until the toc menu is built a first time,
@@ -327,8 +328,8 @@ bool TableofcontentNoteAddin::on_key_pressed(GdkEventKey *ev)
}
-void TableofcontentNoteAddin::headification_switch (Header::Type header_request)
-//apply the correct header style to the current line(s) including the selection
+void TableofcontentsNoteAddin::headification_switch (Heading::Type heading_request)
+//apply the correct heading style to the current line(s) including the selection
//switch: Level_1 <--> Level_2 <--> text
{
Glib::RefPtr<gnote::NoteBuffer> buffer = get_note()->get_buffer();
@@ -355,24 +356,24 @@ void TableofcontentNoteAddin::headification_switch (Header::Type header_request)
//expand the selection to complete lines
buffer->select_range (start, end);
- //set the header tags
- Header::Type current_header = get_header_level_for_range (start, end);
+ //set the heading tags
+ Heading::Type current_heading = get_heading_level_for_range (start, end);
buffer->remove_tag (m_tag_bold, start, end);
buffer->remove_tag (m_tag_large, start, end);
buffer->remove_tag (m_tag_huge, start, end);
- if( current_header == Header::Level_1 && header_request == Header::Level_2) { //existing vs requested
+ if( current_heading == Heading::Level_1 && heading_request == Heading::Level_2) { //existing vs requested
buffer->set_active_tag ("bold");
buffer->set_active_tag ("size:large");
}
- else if( current_header == Header::Level_2 && header_request == Header::Level_1) {
+ else if( current_heading == Heading::Level_2 && heading_request == Heading::Level_1) {
buffer->set_active_tag ("bold");
buffer->set_active_tag ("size:huge");
}
- else if( current_header == Header::None) {
+ else if( current_heading == Heading::None) {
buffer->set_active_tag ("bold");
- buffer->set_active_tag ( (header_request == Header::Level_1)?"size:huge":"size:large");
+ buffer->set_active_tag ( (heading_request == Heading::Level_1)?"size:huge":"size:large");
}
//restore selection
diff --git a/src/addins/tableofcontent/tableofcontentnoteaddin.hpp
b/src/addins/tableofcontents/tableofcontentsnoteaddin.hpp
similarity index 74%
rename from src/addins/tableofcontent/tableofcontentnoteaddin.hpp
rename to src/addins/tableofcontents/tableofcontentsnoteaddin.hpp
index c7372db..4f9e71a 100644
--- a/src/addins/tableofcontent/tableofcontentnoteaddin.hpp
+++ b/src/addins/tableofcontents/tableofcontentsnoteaddin.hpp
@@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* A subclass of NoteAddin, implementing the Table of Content add-in */
+/* A subclass of NoteAddin, implementing the Table of Contents add-in */
#ifndef __TABLEOFCONTENT_NOTEADDIN_HPP_
#define __TABLEOFCONTENT_NOTEADDIN_HPP_
@@ -33,29 +33,29 @@
#include "note.hpp"
#include "noteaddin.hpp"
-#include "tableofcontent.hpp"
+#include "tableofcontents.hpp"
-namespace tableofcontent {
+namespace tableofcontents {
-class TableofcontentModule : public sharp::DynamicModule
+class TableofcontentsModule : public sharp::DynamicModule
{
public:
- TableofcontentModule();
+ TableofcontentsModule();
};
-DECLARE_MODULE(TableofcontentModule);
+DECLARE_MODULE(TableofcontentsModule);
-class TableofcontentMenuItem;
+class TableofcontentsMenuItem;
-class TableofcontentNoteAddin : public gnote::NoteAddin
+class TableofcontentsNoteAddin : public gnote::NoteAddin
{
public:
- static TableofcontentNoteAddin *create()
+ static TableofcontentsNoteAddin *create()
{
- return new TableofcontentNoteAddin;
+ return new TableofcontentsNoteAddin;
}
- TableofcontentNoteAddin();
+ TableofcontentsNoteAddin();
virtual void initialize ();
virtual void shutdown ();
@@ -75,16 +75,16 @@ private:
void populate_toc_menu (Gtk::Menu *toc_menu, bool has_action_entries = true);
bool has_tag_over_range (Glib::RefPtr<Gtk::TextTag> tag, Gtk::TextIter start, Gtk::TextIter end);
- Header::Type get_header_level_for_range (Gtk::TextIter start, Gtk::TextIter end);
+ Heading::Type get_heading_level_for_range (Gtk::TextIter start, Gtk::TextIter end);
- void get_tableofcontent_menu_items (std::list<TableofcontentMenuItem*> & items);
+ void get_tableofcontents_menu_items (std::list<TableofcontentsMenuItem*> & items);
- void headification_switch (Header::Type header_request);
+ void headification_switch (Heading::Type heading_request);
Gtk::Menu *m_toc_menu; // the TOC submenu, containing the TOC
bool m_toc_menu_built; // whereas toc_menu is already built
- Glib::RefPtr<Gtk::TextTag> m_tag_bold; // the tags used to mark headers
+ Glib::RefPtr<Gtk::TextTag> m_tag_bold; // the tags used to mark headings
Glib::RefPtr<Gtk::TextTag> m_tag_large;
Glib::RefPtr<Gtk::TextTag> m_tag_huge;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]