[gnote] Avoid a lookup for the TextTag when loading addons.
- From: Hubert Figuière <hub src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnote] Avoid a lookup for the TextTag when loading addons.
- Date: Fri, 17 Jul 2009 23:44:57 +0000 (UTC)
commit cebb08c5010224f2284750ba837c4754b39698ef
Author: Hubert Figuiere <hub figuiere net>
Date: Fri Jul 17 13:29:35 2009 -0400
Avoid a lookup for the TextTag when loading addons.
src/notetag.cpp | 3 +++
src/notetag.hpp | 18 ++++++++++++++++++
src/watchers.cpp | 13 +++++--------
3 files changed, 26 insertions(+), 8 deletions(-)
---
diff --git a/src/notetag.cpp b/src/notetag.cpp
index 46eea2c..e929a51 100644
--- a/src/notetag.cpp
+++ b/src/notetag.cpp
@@ -438,16 +438,19 @@ namespace gnote {
tag->property_underline() = Pango::UNDERLINE_SINGLE;
tag->set_palette_foreground(CONTRAST_COLOR_GREY);
add (tag);
+ m_broken_link_tag = tag;
tag = NoteTag::create("link:internal", NoteTag::CAN_ACTIVATE);
tag->property_underline() = Pango::UNDERLINE_SINGLE;
tag->set_palette_foreground(CONTRAST_COLOR_BLUE);
add (tag);
+ m_link_tag = tag;
tag = NoteTag::create("link:url", NoteTag::CAN_ACTIVATE);
tag->property_underline() = Pango::UNDERLINE_SINGLE;
tag->set_palette_foreground(CONTRAST_COLOR_BLUE);
add (tag);
+ m_url_tag = tag;
}
diff --git a/src/notetag.hpp b/src/notetag.hpp
index f2022ea..61dc93b 100644
--- a/src/notetag.hpp
+++ b/src/notetag.hpp
@@ -272,6 +272,20 @@ public:
void register_dynamic_tag (const std::string & tag_name, const Factory & factory);
bool is_dynamic_tag_registered(const std::string &);
+
+ NoteTag::Ptr get_url_tag() const
+ {
+ return m_url_tag;
+ }
+ NoteTag::Ptr get_link_tag() const
+ {
+ return m_link_tag;
+ }
+ NoteTag::Ptr get_broken_link_tag() const
+ {
+ return m_broken_link_tag;
+ }
+
protected:
NoteTagTable()
{
@@ -288,6 +302,10 @@ private:
static NoteTagTable::Ptr s_instance;
std::map<std::string, Factory> m_tag_types;
std::list<Glib::RefPtr<Gtk::TextTag> > m_added_tags;
+
+ NoteTag::Ptr m_url_tag;
+ NoteTag::Ptr m_link_tag;
+ NoteTag::Ptr m_broken_link_tag;
};
diff --git a/src/watchers.cpp b/src/watchers.cpp
index d86f69b..cbea675 100644
--- a/src/watchers.cpp
+++ b/src/watchers.cpp
@@ -401,7 +401,7 @@ namespace gnote {
void NoteUrlWatcher::initialize ()
{
- m_url_tag = NoteTag::Ptr::cast_dynamic(get_note()->get_tag_table()->lookup("link:url"));
+ m_url_tag = get_note()->get_tag_table()->get_url_tag();
}
@@ -638,12 +638,9 @@ namespace gnote {
m_on_note_renamed_cid = manager().signal_note_renamed.connect(
sigc::mem_fun(*this, &NoteLinkWatcher::on_note_renamed));
- m_url_tag = NoteTag::Ptr::cast_dynamic(get_note()
- ->get_tag_table()->lookup ("link:url"));
- m_link_tag = NoteTag::Ptr::cast_dynamic(get_note()
- ->get_tag_table()->lookup ("link:internal"));
- m_broken_link_tag = NoteTag::Ptr::cast_dynamic(get_note()
- ->get_tag_table()->lookup ("link:broken"));
+ m_url_tag = get_note()->get_tag_table()->get_url_tag();
+ m_link_tag = get_note()->get_tag_table()->get_link_tag();
+ m_broken_link_tag = get_note()->get_tag_table()->get_broken_link_tag();
}
@@ -938,7 +935,7 @@ namespace gnote {
void NoteWikiWatcher::initialize ()
{
- m_broken_link_tag = get_note()->get_tag_table()->lookup ("link:broken");
+ m_broken_link_tag = get_note()->get_tag_table()->get_broken_link_tag();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]