[gnote/gnome-3-10] Fix internal links merging with other links



commit 330a1815f448fcd7df6097a518d4f24d74ae716b
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Wed Oct 9 23:17:54 2013 +0300

    Fix internal links merging with other links

 src/watchers.cpp |   14 +++++++++++++-
 src/watchers.hpp |    2 ++
 2 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/src/watchers.cpp b/src/watchers.cpp
index 3caa976..69b209f 100644
--- a/src/watchers.cpp
+++ b/src/watchers.cpp
@@ -26,6 +26,7 @@
 
 #include <string.h>
 
+#include <boost/bind.hpp>
 #include <boost/format.hpp>
 
 #include <glibmm/i18n.h>
@@ -789,10 +790,21 @@ namespace gnote {
     DBG_OUT ("Matching Note title '%s' at %d-%d...",
              hit.key().c_str(), hit.start(), hit.end());
 
-    get_buffer()->remove_tag (m_broken_link_tag, title_start, title_end);
+    get_note()->get_tag_table()->foreach(
+      boost::bind(sigc::mem_fun(*this, &NoteLinkWatcher::remove_link_tag),
+                  _1, title_start, title_end));
     get_buffer()->apply_tag (m_link_tag, title_start, title_end);
   }
 
+  void NoteLinkWatcher::remove_link_tag(const Glib::RefPtr<Gtk::TextTag> & tag,
+                                        const Gtk::TextIter & start, const Gtk::TextIter & end)
+  {
+    NoteTag::Ptr note_tag = NoteTag::Ptr::cast_dynamic(tag);
+    if (note_tag && note_tag->can_activate()) {
+      get_buffer()->remove_tag(note_tag, start, end);
+    }
+  }
+
   void NoteLinkWatcher::highlight_note_in_block (const Note::Ptr & find_note, 
                                                  const Gtk::TextIter & start,
                                                  const Gtk::TextIter & end)
diff --git a/src/watchers.hpp b/src/watchers.hpp
index 2a14f06..09b153a 100644
--- a/src/watchers.hpp
+++ b/src/watchers.hpp
@@ -185,6 +185,8 @@ namespace gnote {
     void on_insert_text(const Gtk::TextIter &, const Glib::ustring &, int);
     void on_apply_tag(const Glib::RefPtr<Gtk::TextBuffer::Tag> & tag,
                       const Gtk::TextIter & start, const Gtk::TextIter &end);
+    void remove_link_tag(const Glib::RefPtr<Gtk::TextTag> & tag,
+                         const Gtk::TextIter & start, const Gtk::TextIter & end);
 
     bool open_or_create_link(const NoteEditor &, const Gtk::TextIter &,const Gtk::TextIter &);
     bool on_link_tag_activated(const NoteEditor &,


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