[pan2/testing: 2/279] Make higlighting of URIs optional.



commit 43005b72aa859ad53a1c817528f088ed31047fab
Author: K. Haley <haleykd users sf net>
Date:   Wed Feb 9 00:39:01 2011 -0700

    Make higlighting of URIs optional.
    
    Add menu item and pref to toggle highlighting URIs in the body pane.

 pan/gui/actions.cc   |    1 +
 pan/gui/body-pane.cc |   21 +++++++++++++--------
 pan/gui/pan.ui.h     |    1 +
 3 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/pan/gui/actions.cc b/pan/gui/actions.cc
index b65f1e2..ba34b77 100644
--- a/pan/gui/actions.cc
+++ b/pan/gui/actions.cc
@@ -617,6 +617,7 @@ namespace
     { "size-pictures-to-fit",     NULL, N_("Size Pictures to _Fit"),          NULL, NULL, G_CALLBACK(prefs_toggle_callback_impl), true },
     { "monospace-font-enabled",   NULL, N_("Use _Monospace Font"),             "C", NULL, G_CALLBACK(prefs_toggle_callback_impl), false },
     { "focus-on-image",           NULL, N_("Set Focus to Images"),            NULL, NULL, G_CALLBACK(prefs_toggle_callback_impl), true },
+    { "highlight-urls",           NULL, N_("Highlight _URLs"),                 NULL, NULL, G_CALLBACK(prefs_toggle_callback_impl), true },
 
 
     { "work-online", "ICON_ONLINE", N_("_Work Online"), "L", NULL, G_CALLBACK(do_work_online), true },
diff --git a/pan/gui/body-pane.cc b/pan/gui/body-pane.cc
index 42070a6..348d122 100644
--- a/pan/gui/body-pane.cc
+++ b/pan/gui/body-pane.cc
@@ -671,7 +671,8 @@ namespace
                              const StringView    & body_in,
                              bool                  mute_quotes,
                              bool                  show_smilies,
-                             bool                  do_markup)
+                             bool                  do_markup,
+                             bool                  do_urls)
   {
     g_return_if_fail (buffer!=0);
     g_return_if_fail (GTK_IS_TEXT_BUFFER(buffer));
@@ -792,11 +793,13 @@ namespace
     }
     
     // colorize urls
-    StringView area;
-    StringView march (v_all);
-    while ((url_find (march, area))) {
-      set_section_tag (buffer, &start, v_all, area, "url", REPLACE);
-      march = march.substr (area.str + area.len, 0);
+    if (do_urls) {
+      StringView area;
+      StringView march (v_all);
+      while ((url_find (march, area))) {
+        set_section_tag (buffer, &start, v_all, area, "url", REPLACE);
+        march = march.substr (area.str + area.len, 0);
+      }
     }
 
     // do this last, since it alters the text instead of just marking it up
@@ -948,7 +951,8 @@ BodyPane :: append_part (GMimeObject * obj, GtkAllocation * widget_size)
     const bool do_mute (_prefs.get_flag ("mute-quoted-text", false));
     const bool do_smilies (_prefs.get_flag ("show-smilies-as-graphics", true));
     const bool do_markup (_prefs.get_flag ("show-text-markup", true));
-    append_text_buffer_nolock (&_tm, _buffer, str, do_mute, do_smilies, do_markup);
+    const bool do_urls (_prefs.get_flag ("highlight-urls", true));
+    append_text_buffer_nolock (&_tm, _buffer, str, do_mute, do_smilies, do_markup, do_urls);
     is_done = true;
   }
 
@@ -1728,7 +1732,8 @@ BodyPane :: on_prefs_flag_changed (const StringView& key, bool value G_GNUC_UNUS
 
   if ((key=="wrap-article-body") || (key=="mute-quoted-text") ||
       (key=="show-smilies-as-graphics") || (key=="show-all-headers") ||
-      (key=="size-pictures-to-fit") || (key=="show-text-markup"))
+      (key=="size-pictures-to-fit") || (key=="show-text-markup") ||
+      (key=="highlight-urls") )
     refresh ();
 }
 
diff --git a/pan/gui/pan.ui.h b/pan/gui/pan.ui.h
index b1e1824..1b8d14b 100644
--- a/pan/gui/pan.ui.h
+++ b/pan/gui/pan.ui.h
@@ -65,6 +65,7 @@ const char * fallback_ui_file =
 "        <menuitem action='monospace-font-enabled' />\n"
 "        <menuitem action='show-smilies-as-graphics' />\n"
 "        <menuitem action='show-text-markup'/>\n"
+"        <menuitem action='highlight-urls'/>\n"
 "        <menuitem action='rot13-selected-text' />\n"
 "        <separator />\n"
 "        <menuitem action='size-pictures-to-fit'/>\n"



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