[gnote] Don't create nested links
- From: Aurimas Äernius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Don't create nested links
- Date: Tue, 6 Sep 2011 19:34:04 +0000 (UTC)
commit e8798f6dfe47a0558423ab90d1f70a43d73634f7
Author: Aurimas Äernius <aurisc4 gmail com>
Date: Tue Sep 6 22:22:22 2011 +0300
Don't create nested links
Ported fix of Tomboy bug 627060.
src/notetag.cpp | 6 ++++++
src/notetag.hpp | 2 ++
src/watchers.cpp | 12 ++++++++----
3 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/src/notetag.cpp b/src/notetag.cpp
index 4158eea..fa323d0 100644
--- a/src/notetag.cpp
+++ b/src/notetag.cpp
@@ -533,6 +533,12 @@ namespace gnote {
{
return DepthNoteTag::Ptr::cast_dynamic(tag);
}
+
+
+ bool NoteTagTable::has_link_tag(const Gtk::TextIter & iter)
+ {
+ return iter.has_tag(get_link_tag()) || iter.has_tag(get_url_tag()) || iter.has_tag(get_broken_link_tag());
+ }
DepthNoteTag::Ptr NoteTagTable::get_depth_tag(int depth, Pango::Direction direction)
diff --git a/src/notetag.hpp b/src/notetag.hpp
index ded644d..a05005e 100644
--- a/src/notetag.hpp
+++ b/src/notetag.hpp
@@ -1,6 +1,7 @@
/*
* gnote
*
+ * Copyright (C) 2011 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -268,6 +269,7 @@ public:
static bool tag_is_spell_checkable(const Glib::RefPtr<const Gtk::TextTag> & );
static bool tag_is_activatable(const Glib::RefPtr<Gtk::TextTag> & );
static bool tag_has_depth(const Glib::RefPtr<Gtk::TextBuffer::Tag> & );
+ bool has_link_tag(const Gtk::TextIter & iter);
DepthNoteTag::Ptr get_depth_tag(int depth, Pango::Direction direction);
DynamicNoteTag::Ptr create_dynamic_tag(const std::string & );
void register_dynamic_tag (const std::string & tag_name, const Factory & factory);
diff --git a/src/watchers.cpp b/src/watchers.cpp
index e395687..ef95779 100644
--- a/src/watchers.cpp
+++ b/src/watchers.cpp
@@ -796,7 +796,7 @@ namespace gnote {
}
// Don't create links inside URLs
- if (title_start.has_tag (m_url_tag)) {
+ if(get_note()->get_tag_table()->has_link_tag(title_start)) {
return;
}
@@ -1008,13 +1008,17 @@ namespace gnote {
Glib::ustring segment(p, p + len);
start_cpy.forward_chars (segment.length());
- DBG_OUT("Highlighting wikiword: '%s' at offset %d",
- match.c_str(), segment.length());
-
end = start_cpy;
segment = match;
end.forward_chars (segment.length());
+ if(get_note()->get_tag_table()->has_link_tag(start_cpy)) {
+ break;
+ }
+
+ DBG_OUT("Highlighting wikiword: '%s' at offset %d",
+ match.c_str(), segment.length());
+
if (!manager().find(match)) {
get_buffer()->apply_tag (m_broken_link_tag, start_cpy, end);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]