diff --git a/configure.ac b/configure.ac
index 6c47960..e23f9f1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -169,6 +169,7 @@ src/addins/printnotes/Makefile
 src/addins/replacetitle/Makefile
 src/addins/statistics/Makefile
 src/addins/stickynoteimport/Makefile
+src/addins/tableofcontent/Makefile
 src/addins/tomboyimport/Makefile
 src/addins/underline/Makefile
 src/addins/webdavsyncservice/Makefile
diff --git a/help/C/gnote-addin-tableofcontent.page b/help/C/gnote-addin-tableofcontent.page
new file mode 100644
index 0000000..f33f397
--- /dev/null
+++ b/help/C/gnote-addin-tableofcontent.page
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="utf-8"?>
+<page xmlns="http://projectmallard.org/1.0/"
+      type="topic"
+      id="addin-tableofcontent">
+
+  <info>
+    <link type="guide" xref="index#advanced"/>
+    <link type="topic" xref="addins-preferences"/>
+    <link type="topic" xref="editing-notes"/>
+    <link type="topic" xref="searching-notes"/>
+    <desc>Navigating long structured notes</desc>
+    <license><p>GNU Free Documentation License (GFDL), Version 1.1</p></license>
+    <credit type="author">
+      <name>Luc Pionchon</name>
+      <years>2013</years>
+    </credit>
+    <!-- 
+    <credit type="editor">
+      <name></name>
+      <years></years>
+    </credit> -->
+  </info>
+
+<title>Note's Table of Content</title>
+
+<section id="navigating"><title>Navigating through long notes</title>
+
+<p>
+When writting a long note it may become difficult to navigate through.
+It is then natural to structure the note with headers and sections.
+</p>
+
+<p>
+This add-in makes it easy to navigate through long structured notes.
+Once you have set headers in your note, the Table of Content of the note will show in a menu.
+Then you can jump directly from the menu to the selected header.
+</p>
+
+<note><p>
+  When this add-in is installed, 
+  there will be a <gui>Table of Content</gui> entry in the <gui>Tools</gui> menu.
+  See  <link xref="addins-preferences"/> to know how to activate the add-in.
+</p></note>
+
+</section>
+
+
+<section id="setheaders">
+<title>Structuring your note with headers</title>
+
+<p>
+A header line is simply a complete line with a specific text formatting:
+</p>
+<list>
+  <item><p>Level 1 headers are lines formatted with <gui>Bold</gui> + <gui>Huge  font size</gui> </p></item>
+  <item><p>Level 2 headers are lines formatted with <gui>Bold</gui> + <gui>Large font size</gui> </p></item>
+</list>
+
+
+<p>To format a header line, you can either:</p>
+
+<list>
+  <item>
+    <p>use the commands in the <guiseq><gui>Tools</gui><gui>Table of Content</gui></guiseq> menu: <gui>Level 1 Header</gui> and <gui>Level 2 Header</gui>.</p>
+  </item>
+
+  <item>
+    <p>use keyboard shortcuts: <keyseq><key>Ctrl</key><key>1</key></keyseq> for level 1 headers, and <keyseq><key>Ctrl</key><key>2</key></keyseq> for level 2 headers.</p>
+ </item>
+</list>
+
+<p>Write the header title, select it and activate the command. Alternatively, on a new line, activate the command and enter the header title.</p>
+
+<p>You can actually even use the normal formatting commands from the <gui>Text</gui> menu: 
+    <gui>Bold</gui>, <gui>Large</gui> and <gui>Huge</gui>, and their respective keyboard shortcuts.
+    See <link xref="editing-notes"/> to know how to set text style.
+</p>
+
+</section>
+
+
+<section id="showtable"><title>Showing the Table of Content</title>
+<p>You can access the Table of Content, either:</p>
+<list>
+<item><p>in the <gui>Tools</gui> menu</p></item>
+<item><p>in the <gui>contextual menu</gui>, with your mouse: <keyseq>right-click</keyseq> on the note window</p></item>
+<item><p>in a <gui>popup menu</gui>, with a keyboard shortcut: <keyseq><key>Ctrl</key><key>Alt</key><key>1</key></keyseq>. Then you can navigate up and down with the <gui>arrow keys</gui> and jump to the selected header with <key>enter</key>.</p></item>
+</list>
+
+</section>
+
+
+</page>
\ No newline at end of file
diff --git a/help/Makefile.am b/help/Makefile.am
index 7c36510..4aa87bb 100644
--- a/help/Makefile.am
+++ b/help/Makefile.am
@@ -32,6 +32,7 @@ HELP_FILES = \
 	gnote-addin-replacetitle.page \
 	gnote-addin-sync-local.page \
 	gnote-addin-sync-webdav.page \
+	gnote-addin-tableofcontent.page \
 	gnote-addin-timestamp.page \
 	gnote-addin-underline.page \
 	gnote-bulleted-lists.page \
diff --git a/po/POTFILES.in b/po/POTFILES.in
index f5f2352..ce34cd5 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -31,6 +31,8 @@ src/addins/statistics/statisticsapplicationaddin.cpp
 src/addins/statistics/statisticswidget.cpp
 src/addins/stickynoteimport/stickynoteimport.desktop.in
 src/addins/stickynoteimport/stickynoteimportnoteaddin.cpp
+src/addins/tableofcontent/tableofcontent.desktop.in
+src/addins/tableofcontent/tableofcontentnoteaddin.cpp
 src/addins/tomboyimport/tomboyimport.desktop.in
 src/addins/underline/underline.desktop.in
 src/addins/underline/underlinemenuitem.cpp
diff --git a/src/addins/Makefile.am b/src/addins/Makefile.am
index 6d211d3..3df3e82 100644
--- a/src/addins/Makefile.am
+++ b/src/addins/Makefile.am
@@ -13,6 +13,7 @@ SUBDIRS = backlinks \
 	replacetitle \
 	statistics \
 	stickynoteimport \
+	tableofcontent \
 	tomboyimport \
 	underline \
 	webdavsyncservice \
diff --git a/src/addins/tableofcontent/Makefile.am b/src/addins/tableofcontent/Makefile.am
new file mode 100644
index 0000000..2c87d23
--- /dev/null
+++ b/src/addins/tableofcontent/Makefile.am
@@ -0,0 +1,23 @@
+
+include $(builddir)/../addins.mk
+
+@INTLTOOL_DESKTOP_RULE@
+
+desktop_in_files = tableofcontent.desktop.in
+desktop_files    = $(desktop_in_files:.desktop.in=.desktop)
+
+addinsdir = $(ADDINSDIR)
+addins_LTLIBRARIES = tableofcontent.la
+addins_DATA = $(desktop_files)
+
+
+tableofcontent_la_SOURCES = \
+	tableofcontent.hpp \
+	tableofcontentnoteaddin.hpp \
+	tableofcontentnoteaddin.cpp \
+	tableofcontentmenuitem.hpp  \
+	tableofcontentmenuitem.cpp  \
+	$(NULL)
+
+EXTRA_DIST = $(desktop_in_files)
+DISTCLEANFILES = $(desktop_files)
diff --git a/src/addins/tableofcontent/NEWS b/src/addins/tableofcontent/NEWS
new file mode 100644
index 0000000..2d7f302
--- /dev/null
+++ b/src/addins/tableofcontent/NEWS
@@ -0,0 +1,39 @@
+NEWS for Addin: Table of Content
+================================
+
+== 0.8
+
+== 0.7
+- ported to master/3.9.0 by Aurimas
+- .desktop.in, use unicode ©, set Authors and Copyright not translatable
+- added NEWS file
+- when toc is empty, use just a dummy unsensitive item rather than an explanatory text.
+  explanations will be in the manual/help.
+- added menu entries to set headers level 1 and 2, with Ctrl-1/2 accelerators
+- added menu entry to show the accelerator to open the toc in a popup menu
+- toc action entries set in italic to differentiate from the toc entries
+- "Show in a popup menu" action set unsensitive (it does not make sense to trigger it from a menu)
+- added help page
+
+== 0.6
+- code cleanup from Aurimas review
+
+== 0.5
+- now compiles with gnote-3.6.0
+
+== 0.4
+- fixed segfault and double menu bug (I think so)
+- code cleanup
+
+== 0.3
+- added TableofcontentModule::copyright()
+- used a namespaced-enum for header Levels. New file tableofcontent.hpp
+- code review changes (https://bugzilla.gnome.org/show_bug.cgi?id=698059)
+
+== 0.2
+- add toc submenu in contextual menu
+- Ctrl-Alt-1 opens toc in a popup menu
+
+== 0.1
+- port from Tomboy version, for gnote-0.7.6
+  https://github.com/oluc/tomboy/tree/TableOfContentAddin/Tomboy/Addins/TableOfContent
diff --git a/src/addins/tableofcontent/TODO b/src/addins/tableofcontent/TODO
new file mode 100644
index 0000000..b857e64
--- /dev/null
+++ b/src/addins/tableofcontent/TODO
@@ -0,0 +1,3 @@
+
+- todo: check all FIXMEs, and more code cleanup
+
diff --git a/src/addins/tableofcontent/tableofcontent.desktop.in b/src/addins/tableofcontent/tableofcontent.desktop.in
new file mode 100644
index 0000000..bc0f7e5
--- /dev/null
+++ b/src/addins/tableofcontent/tableofcontent.desktop.in
@@ -0,0 +1,10 @@
+[AddinInfo]
+Id=TableofcontentAddin
+_Name=Table of Content
+_Description=Show the table of content of the current note in a menu. Headers are lines formated with bold/large or bold/huge.
+Authors=Luc Pionchon
+Category=Tools
+Version=0.7
+DefaultEnabled=false
+Module=tableofcontent
+Copyright=© 2013 Luc Pionchon
diff --git a/src/addins/tableofcontent/tableofcontent.hpp b/src/addins/tableofcontent/tableofcontent.hpp
new file mode 100644
index 0000000..fd6d9e3
--- /dev/null
+++ b/src/addins/tableofcontent/tableofcontent.hpp
@@ -0,0 +1,38 @@
+/*
+ *  "Table of Content" is a Note addin for gnote.
+ *    It lists Note's table of contents in a menu.
+ *    Headers are bold/large and bold/huge lines.
+ *
+ *  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/>.
+ */
+
+#ifndef __TABLEOFCONTENT_HPP_
+#define __TABLEOFCONTENT_HPP_
+
+namespace tableofcontent {
+
+namespace Level { // header level
+  enum Type {
+    H1,           // H1 = note title
+    H2,           // H2 = bold/huge lines
+    H3,           // H3 = bold/large lines
+    None
+  };
+};
+
+}
+
+#endif
diff --git a/src/addins/tableofcontent/tableofcontentmenuitem.cpp b/src/addins/tableofcontent/tableofcontentmenuitem.cpp
new file mode 100644
index 0000000..efb6ebe
--- /dev/null
+++ b/src/addins/tableofcontent/tableofcontentmenuitem.cpp
@@ -0,0 +1,87 @@
+/*
+ *  "Table of Content" is a Note addin for gnote.
+ *    It lists Note's table of contents in a menu.
+ *    Headers are bold/large and bold/huge lines.
+ *
+ *  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/>.
+ */
+
+#include <gtkmm/stock.h>
+
+#include "iconmanager.hpp"
+#include "notewindow.hpp"
+
+#include "tableofcontentmenuitem.hpp"
+#include "tableofcontent.hpp"
+
+namespace tableofcontent {
+
+
+TableofcontentMenuItem::TableofcontentMenuItem(
+                            const gnote::Note::Ptr & note,
+                            const std::string      & header,
+                            Level::Type              header_level,
+                            int                      header_position)
+  : m_note(note)
+  , m_header_position(header_position)
+{
+
+  // Set TOC style, depending on the header level
+  /* +------------------+
+     |[] NOTE TITLE     |
+     | > Header H2      |
+     | > Header H2      |
+     |   └→  Header H3  |
+     |   └→  Header H3  |
+     |   └→  Header H3  |
+     | > Header H2      |
+     +------------------+ */
+
+  set_use_underline (false); //we don't want potential '_' in the header to be used as mnemonic
+
+  if (header_level == Level::H1) {
+    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>"+ header + "</b>");
+  }
+  else if (header_level == Level::H2) {
+    set_image(*manage(new Gtk::Image(Gtk::Stock::GO_FORWARD, Gtk::ICON_SIZE_MENU)));
+    set_label(header);
+  }
+  else if (header_level == Level::H3) {
+    set_label("└→  " + header);
+  }
+}
+
+
+void TableofcontentMenuItem::on_activate()
+{
+  if (!m_note) {
+    return;
+  }
+
+  // Scroll the TextView and place the cursor on the header
+  Gtk::TextIter header_iter;
+  header_iter = m_note->get_buffer()->get_iter_at_offset (m_header_position);
+  m_note->get_window()->editor()->scroll_to (header_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 (header_iter);
+}
+
+
+} //namespace
diff --git a/src/addins/tableofcontent/tableofcontentmenuitem.hpp b/src/addins/tableofcontent/tableofcontentmenuitem.hpp
new file mode 100644
index 0000000..34c54c0
--- /dev/null
+++ b/src/addins/tableofcontent/tableofcontentmenuitem.hpp
@@ -0,0 +1,54 @@
+/*
+ *  "Table of Content" is a Note addin for gnote.
+ *    It lists Note's table of contents in a menu.
+ *    Headers are bold/large and bold/huge lines.
+ *
+ *  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/>.
+ */
+
+
+#ifndef __TABLEOFCONTENT_MENU_ITEM_HPP_
+#define __TABLEOFCONTENT_MENU_ITEM_HPP_
+
+#include <string>
+#include <gtkmm/imagemenuitem.h>
+
+#include "note.hpp"
+#include "tableofcontent.hpp"
+
+
+namespace tableofcontent {
+
+class TableofcontentMenuItem : public Gtk::ImageMenuItem
+{
+public:
+  TableofcontentMenuItem( const gnote::Note::Ptr & note,
+                          const std::string      & header,
+                          Level::Type              header_level,
+                          int                      header_position);
+
+protected:
+  virtual void on_activate();
+
+private:
+  gnote::Note::Ptr   m_note;
+  int                m_header_position;
+
+};
+
+}
+
+#endif
diff --git a/src/addins/tableofcontent/tableofcontentnoteaddin.cpp b/src/addins/tableofcontent/tableofcontentnoteaddin.cpp
new file mode 100644
index 0000000..8764aa1
--- /dev/null
+++ b/src/addins/tableofcontent/tableofcontentnoteaddin.cpp
@@ -0,0 +1,363 @@
+/*
+ *  "Table of Content" is a Note addin for gnote.
+ *    It lists Note's table of contents in a menu.
+ *    Headers are bold/large and bold/huge lines.
+ *
+ *  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/>.
+ */
+
+#include <glibmm/i18n.h>
+
+#include <gtkmm/stock.h>
+#include <gtkmm/separatormenuitem.h>
+
+#include "sharp/string.hpp"
+
+#include "tableofcontent.hpp"
+#include "tableofcontentnoteaddin.hpp"
+#include "tableofcontentmenuitem.hpp"
+
+#include "notemanager.hpp"
+#include "notewindow.hpp"
+#include "notebuffer.hpp"
+#include "utils.hpp"
+
+namespace tableofcontent {
+
+TableofcontentModule::TableofcontentModule()
+{
+  ADD_INTERFACE_IMPL(TableofcontentNoteAddin);
+}
+
+
+TableofcontentNoteAddin::TableofcontentNoteAddin()
+  : m_menu_item(NULL)
+  , m_toc_menu(NULL)
+  , m_toc_menu_built(false)
+{
+}
+
+
+void TableofcontentNoteAddin::initialize ()
+{
+}
+
+
+void TableofcontentNoteAddin::shutdown ()
+{
+}
+
+
+void TableofcontentNoteAddin::on_note_opened ()
+{
+  // TOC menu
+  m_toc_menu = manage(new Gtk::Menu());
+  m_toc_menu->signal_hide().connect(
+    sigc::mem_fun(*this, &TableofcontentNoteAddin::on_menu_hidden));
+  m_toc_menu->show_all ();
+
+  // TOC menu entry
+  m_menu_item = manage(new Gtk::ImageMenuItem (_("Table of Content")));
+  m_menu_item->set_image(*manage(new Gtk::Image(Gtk::Stock::JUMP_TO, Gtk::ICON_SIZE_MENU)));
+  m_menu_item->set_submenu(*m_toc_menu);
+  m_menu_item->signal_activate().connect(
+    sigc::mem_fun(*this, &TableofcontentNoteAddin::on_menu_item_activated));
+  m_menu_item->show ();
+
+  add_plugin_menu_item (m_menu_item);
+
+
+  // Reacts to key press events
+  get_note()->get_window()->signal_key_press_event().connect(
+    sigc::mem_fun(*this, &TableofcontentNoteAddin::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));
+
+
+  // Header 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::on_menu_item_activated()
+{
+  if(m_toc_menu_built) {
+    return;
+  }
+  populate_toc_menu(m_toc_menu);
+  m_toc_menu_built = true;
+}
+
+
+void TableofcontentNoteAddin::on_menu_hidden()
+{
+  // Force the submenu to rebuild next time it's supposed to show
+  m_toc_menu_built = false;
+}
+
+
+void TableofcontentNoteAddin::populate_toc_menu(Gtk::Menu *toc_menu)
+//populates a menu with Note's table of content
+{
+  // Clear out the old list
+  std::vector<Gtk::Widget*> menu_items = toc_menu->get_children();
+  for(std::vector<Gtk::Widget*>::reverse_iterator iter = menu_items.rbegin();
+      iter != menu_items.rend(); ++iter) {
+    toc_menu->remove(**iter);
+  }
+
+  // Build a new list
+  std::list<TableofcontentMenuItem*> items;
+  get_tableofcontent_menu_items(items);
+
+  for(std::list<TableofcontentMenuItem*>::iterator iter = items.begin();
+      iter != items.end(); ++iter) {
+    TableofcontentMenuItem * item(*iter);
+    item->show_all();
+    toc_menu->append (*item);
+  }
+
+  // If nothing was found, add an empty item
+  if (toc_menu->get_children().size() == 0) {
+
+    Gtk::MenuItem *item = manage(new Gtk::MenuItem(_("(Empty table of content)")));
+    item->set_sensitive (false);
+    item->show ();
+    toc_menu->append (*item);
+  }
+
+  // Action menu items
+  Gtk::MenuItem *item;
+  Gtk::Label *label;
+
+  item = manage(new Gtk::SeparatorMenuItem ());
+  item->show ();
+  toc_menu->append(*item);
+
+  item = manage(new Gtk::MenuItem (""));
+  label = (Gtk::Label *)item->get_child();
+  label->set_markup(Glib::ustring::compose( "<i>%1</i>", _("Level 1 Header")));
+  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->show ();
+  toc_menu->append(*item);
+
+  item = manage(new Gtk::MenuItem (""));
+  label = (Gtk::Label *)item->get_child();
+  label->set_markup(Glib::ustring::compose( "<i>%1</i>", _("Level 2 Header")));
+  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->show ();
+  toc_menu->append(*item);
+
+  item = manage(new Gtk::MenuItem (""));
+  label = (Gtk::Label *)item->get_child();
+  label->set_markup(Glib::ustring::compose( "<i>%1</i>", _("Show in a popup menu")));
+  item->set_tooltip_text(_(/*TRANSLATORS: this is a tooltip*/"Use the accelerator Ctrl-Alt-1\nto show the Table of Content in a popup menu"));
+  item->add_accelerator("activate", get_note()->get_window()->get_accel_group(), GDK_KEY_1, Gdk::CONTROL_MASK | Gdk::MOD1_MASK, Gtk::ACCEL_VISIBLE);
+  item->signal_activate().connect(sigc::mem_fun(*this, &TableofcontentNoteAddin::on_toc_popup_activated));
+  item->set_sensitive (false);
+  item->show ();
+  toc_menu->append(*item);
+
+}
+
+void TableofcontentNoteAddin::on_populate_popup (Gtk::Menu* popup_menu)
+//prepened a toc submenu in the contextual menu
+{
+  Gtk::Menu *toc_menu = manage(new Gtk::Menu());
+  populate_toc_menu (toc_menu);
+
+  Gtk::SeparatorMenuItem *separator = manage(new Gtk::SeparatorMenuItem ());
+  separator->show ();
+  popup_menu->prepend (*separator);
+
+  Gtk::ImageMenuItem *item;
+  item = manage(new Gtk::ImageMenuItem (_("Table of Content")));
+  item->set_image(*manage(new Gtk::Image(Gtk::Stock::JUMP_TO, Gtk::ICON_SIZE_MENU)));
+  item->set_submenu(*toc_menu);
+  item->show ();
+  popup_menu->prepend (*item);
+}
+
+
+bool TableofcontentNoteAddin::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;
+  Gtk::TextIter iter = start;
+  while (iter.compare(end) != 0 && (has = iter.has_tag(tag))){
+    iter.forward_char();
+  }
+  return has;
+}
+
+
+Level::Type TableofcontentNoteAddin::get_range_level (Gtk::TextIter start, Gtk::TextIter end)
+//return the header 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 Level::H2;
+    }
+    else if (has_tag_over_range (m_tag_large, start, end)) {
+        return Level::H3;
+    }
+    else {
+        return Level::None;
+    }
+  }
+  else {
+      return Level::None;
+  }
+}
+
+
+void TableofcontentNoteAddin::get_tableofcontent_menu_items(std::list<TableofcontentMenuItem*> & items)
+//Go through the note text, and list all lines taged as header
+{
+  TableofcontentMenuItem *item = NULL;
+
+  std::string header;
+  Level::Type header_level;
+  int         header_position;
+
+  Gtk::TextIter iter, iter_end, eol;
+
+  //for each line of the buffer,
+  //check if the full line has bold and (large or huge) tags
+  iter     = get_note()->get_buffer()->begin();
+  iter_end = get_note()->get_buffer()->end();
+
+  while (iter != iter_end) {
+    eol = iter;
+    eol.forward_to_line_end();
+
+    header_level = get_range_level (iter, eol);
+
+    if (header_level == Level::H2 || header_level == Level::H3) {
+      header_position = iter.get_offset();
+      header = iter.get_text(eol);
+
+      if (items.size() == 0) {
+        //It's the first header found,
+        //we also insert an entry linked to the Note's Title:
+        item = manage(new TableofcontentMenuItem (get_note(), get_note()->get_title(), Level::H1, 0));
+        items.push_back(item);
+      }
+      item = manage(new TableofcontentMenuItem (get_note(), header, header_level, header_position));
+      items.push_back(item);
+    }
+    //next line
+    iter.forward_visible_line();
+  }
+}
+
+void TableofcontentNoteAddin::on_level_1_activated()
+{
+  headification_switch (Level::H2);
+}
+void TableofcontentNoteAddin::on_level_2_activated()
+{
+  headification_switch (Level::H3);
+}
+void TableofcontentNoteAddin::on_toc_popup_activated()
+{
+  if(m_toc_menu_built == false) {
+    populate_toc_menu(m_toc_menu);
+    m_toc_menu_built = true;
+  }
+  m_toc_menu->popup(0, 0);
+}
+
+
+bool TableofcontentNoteAddin::on_key_pressed(GdkEventKey *ev)
+//return true if signal handled, false otherwise
+//NOTE: this is needed until the toc menu is built a first time,
+//      then menu item accelerators take the signals
+{
+  switch(ev->keyval) {
+
+  case GDK_KEY_1:
+      if (ev->state == (GDK_CONTROL_MASK | GDK_MOD1_MASK)) {// Ctrl-Alt-1
+        on_toc_popup_activated();
+        return true;
+      }
+      else if (ev->state == GDK_CONTROL_MASK) { // Ctrl-1
+        on_level_1_activated ();
+        return true;
+      }
+      else {
+        return false;
+      }
+  break;
+
+  case GDK_KEY_2:
+      if (ev->state == GDK_CONTROL_MASK) { // Ctrl-2
+        on_level_2_activated ();
+        return true;
+      }
+      else {
+        return false;
+      }
+  break;
+
+  default:
+    return false;
+
+  } //switch
+
+  return false;
+}/* on_key_pressed() */
+
+
+void TableofcontentNoteAddin::headification_switch (Level::Type header_request)
+// Apply the correct header style to the current selection  ==> switch:  H2 <--> H3 <--> text
+{
+
+  Glib::RefPtr<gnote::NoteBuffer> buffer = get_note()->get_buffer();
+  Gtk::TextIter start, end;
+
+  buffer->get_selection_bounds (start, end);
+
+  Level::Type current_header = get_range_level (start, end);
+
+  buffer->remove_all_tags (start, end);//reset all tags
+
+  if( current_header == Level::H2 && header_request == Level::H3) { //existing vs requested
+    buffer->set_active_tag ("bold");
+    buffer->set_active_tag ("size:large");
+  }
+  else if( current_header == Level::H3 && header_request == Level::H2) {
+    buffer->set_active_tag ("bold");
+    buffer->set_active_tag ("size:huge");
+  }
+  else if( current_header == Level::None) {
+    buffer->set_active_tag ("bold");
+    buffer->set_active_tag ( (header_request == Level::H2)?"size:huge":"size:large");
+  }
+
+}
+
+
+} //namespace
diff --git a/src/addins/tableofcontent/tableofcontentnoteaddin.hpp b/src/addins/tableofcontent/tableofcontentnoteaddin.hpp
new file mode 100644
index 0000000..1780dfd
--- /dev/null
+++ b/src/addins/tableofcontent/tableofcontentnoteaddin.hpp
@@ -0,0 +1,93 @@
+/*
+ *  "Table of Content" is a Note addin for gnote.
+ *    It lists Note's table of contents in a menu.
+ *    Headers are bold/large and bold/huge lines.
+ *
+ *  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/>.
+ */
+
+#ifndef __TABLEOFCONTENT_NOTEADDIN_HPP_
+#define __TABLEOFCONTENT_NOTEADDIN_HPP_
+
+#include <list>
+
+#include <gtkmm/imagemenuitem.h>
+#include <gtkmm/menu.h>
+
+#include "sharp/dynamicmodule.hpp"
+#include "note.hpp"
+#include "noteaddin.hpp"
+
+#include "tableofcontent.hpp"
+
+namespace tableofcontent {
+
+class TableofcontentModule
+  : public sharp::DynamicModule
+{
+public:
+  TableofcontentModule();
+};
+
+DECLARE_MODULE(TableofcontentModule);
+
+
+class TableofcontentMenuItem;
+
+class TableofcontentNoteAddin : public gnote::NoteAddin
+{
+public:
+  static TableofcontentNoteAddin *create()
+    {
+      return new TableofcontentNoteAddin;
+    }
+  TableofcontentNoteAddin();
+
+  virtual void initialize ();
+  virtual void shutdown ();
+  virtual void on_note_opened ();
+
+private:
+  void on_menu_item_activated ();
+  void on_menu_hidden ();
+  bool on_key_pressed (GdkEventKey *ev);
+  void on_populate_popup (Gtk::Menu* popup_menu);
+  void on_level_1_activated();
+  void on_level_2_activated();
+  void on_toc_popup_activated();
+
+
+  void populate_toc_menu (Gtk::Menu *toc_menu);
+
+  bool has_tag_over_range (Glib::RefPtr<Gtk::TextTag> tag, Gtk::TextIter start, Gtk::TextIter end);
+  Level::Type get_range_level (Gtk::TextIter start, Gtk::TextIter end);
+  void get_tableofcontent_menu_items (std::list<TableofcontentMenuItem*> & items);
+
+  void headification_switch (Level::Type header_request);
+
+  Gtk::ImageMenuItem *m_menu_item;       // TOC menu entry in the plugin menu
+  Gtk::Menu          *m_toc_menu;        // TOC submenu, containing the TOC
+  bool                m_toc_menu_built;
+
+  Glib::RefPtr<Gtk::TextTag> m_tag_bold;
+  Glib::RefPtr<Gtk::TextTag> m_tag_large;
+  Glib::RefPtr<Gtk::TextTag> m_tag_huge;
+};
+
+} //namespace
+
+#endif
+
