[gnote] Fix paste of URL part



commit 7fb63a2bbf3f1f8b57219609c298a6209dbb524f
Author: Aurimas Ä?ernius <aurisc4 gmail com>
Date:   Mon Dec 27 22:30:47 2010 +0200

    Fix paste of URL part
    
    Copy paste of part of URL marks pasted part as URL.
    This patch add a check on the pasted part and removed tag, if it's
    not URL.
    Fixes Bug 633951.

 src/watchers.cpp |   17 +++++++++++++++++
 src/watchers.hpp |    3 +++
 2 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/src/watchers.cpp b/src/watchers.cpp
index 476d05b..07add29 100644
--- a/src/watchers.cpp
+++ b/src/watchers.cpp
@@ -1,6 +1,7 @@
 /*
  * gnote
  *
+ * Copyright (C) 2010 Aurimas Cernius
  * Copyright (C) 2010 Debarshi Ray
  * Copyright (C) 2009 Hubert Figuiere
  *
@@ -431,6 +432,8 @@ namespace gnote {
 
     get_buffer()->signal_insert().connect(
       sigc::mem_fun(*this, &NoteUrlWatcher::on_insert_text));
+    get_buffer()->signal_apply_tag().connect(
+      sigc::mem_fun(*this, &NoteUrlWatcher::on_apply_tag));
     get_buffer()->signal_erase().connect(
       sigc::mem_fun(*this, &NoteUrlWatcher::on_delete_range));
 
@@ -545,6 +548,20 @@ namespace gnote {
     apply_url_to_block (start, pos);
   }
 
+  void NoteUrlWatcher::on_apply_tag(const Glib::RefPtr<Gtk::TextBuffer::Tag> & tag,
+                                    const Gtk::TextIter & start, const Gtk::TextIter & end)
+  {
+    if(tag != m_url_tag)
+      return;
+    std::string s(start.get_slice(end));
+    std::string match1;
+    const char *p = s.c_str();
+    pcrecpp::StringPiece input(p);
+    if(!m_regex.FindAndConsume(&input, &match1))
+      get_buffer()->remove_tag (m_url_tag, start, end);
+  }
+
+
 
   bool NoteUrlWatcher::on_button_press(GdkEventButton *ev)
   {
diff --git a/src/watchers.hpp b/src/watchers.hpp
index 1a934bc..bdd6af7 100644
--- a/src/watchers.hpp
+++ b/src/watchers.hpp
@@ -1,6 +1,7 @@
 /*
  * gnote
  *
+ * Copyright (C) 2010 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -145,6 +146,8 @@ namespace gnote {
     bool on_url_tag_activated(const NoteTag::Ptr &, const NoteEditor &,
                               const Gtk::TextIter &, const Gtk::TextIter &);
     void apply_url_to_block (Gtk::TextIter start, Gtk::TextIter end);
+    void on_apply_tag(const Glib::RefPtr<Gtk::TextBuffer::Tag> & tag,
+                      const Gtk::TextIter & start, const Gtk::TextIter &end);
     void on_delete_range(const Gtk::TextIter &,const Gtk::TextIter &);
     void on_insert_text(const Gtk::TextIter &, const Glib::ustring &, int);
     bool on_button_press(GdkEventButton *);



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