[gnote] Fix paste of link part



commit dc59732e8fee2fdce8ece45353c249c9a9c7e6a5
Author: Aurimas Ä?ernius <aurisc4 gmail com>
Date:   Mon Dec 27 22:36:16 2010 +0200

    Fix paste of link part
    
    Pasting part of link leaves link tag.
    This patch add a check and removes tag if pasted part of link does not
    link to any note.
    Fixes Bug 634026.

 src/watchers.cpp |   12 ++++++++++++
 src/watchers.hpp |    3 +++
 2 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/src/watchers.cpp b/src/watchers.cpp
index 07add29..58ce7ec 100644
--- a/src/watchers.cpp
+++ b/src/watchers.cpp
@@ -688,6 +688,8 @@ namespace gnote {
     }
     get_buffer()->signal_insert().connect(
       sigc::mem_fun(*this, &NoteLinkWatcher::on_insert_text));
+    get_buffer()->signal_apply_tag().connect(
+      sigc::mem_fun(*this, &NoteLinkWatcher::on_apply_tag));
     get_buffer()->signal_erase().connect(
       sigc::mem_fun(*this, &NoteLinkWatcher::on_delete_range));
   }
@@ -877,6 +879,16 @@ namespace gnote {
   }
 
 
+  void NoteLinkWatcher::on_apply_tag(const Glib::RefPtr<Gtk::TextBuffer::Tag> & tag,
+                                     const Gtk::TextIter & start, const Gtk::TextIter &end)
+  {
+    std::string link_name = start.get_text (end);
+    Note::Ptr link = manager().find (link_name);
+    if(!link)
+        unhighlight_in_block(start, end);
+  }
+
+
   bool NoteLinkWatcher::open_or_create_link(const Gtk::TextIter & start,
                                             const Gtk::TextIter & end)
   {
diff --git a/src/watchers.hpp b/src/watchers.hpp
index bdd6af7..95d568a 100644
--- a/src/watchers.hpp
+++ b/src/watchers.hpp
@@ -185,6 +185,9 @@ namespace gnote {
     void unhighlight_in_block(const Gtk::TextIter &,const Gtk::TextIter &);
     void on_delete_range(const Gtk::TextIter &,const Gtk::TextIter &);
     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);
+
     bool open_or_create_link(const Gtk::TextIter &,const Gtk::TextIter &);
     bool on_link_tag_activated(const NoteTag::Ptr &, const NoteEditor &,
                                const Gtk::TextIter &, const Gtk::TextIter &);



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