~ubuntu-branches/ubuntu/saucy/monodevelop/saucy-proposed

« back to all changes in this revision

Viewing changes to src/core/Mono.Texteditor/Mono.TextEditor/Gui/GtkWorkarounds.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2012-06-22 20:35:35 UTC
  • mfrom: (10.3.2)
  • Revision ID: package-import@ubuntu.com-20120622203535-zrozwvcf6kfk6l6i
Tags: 3.0.3.2+dfsg-1
* [3fd89ae] Imported Upstream version 3.0.3.2+dfsg
* [379a680] Remove old patches we haven't used for ages from git.
* [d71161d] Remove correct_paths_in_monodevelop-core-addins.pc.patch.
  Upstream claim to have fixed this by moving assembly install locations.
* [15dbfb9] Fix install location for MonoDevelop.Gettext.dll.config.
* [26eb434] Fix install location for MonoDevelop.SourceEditor2.dll.config.
* [4169974] Upstream commit 53282c9 which finally reconciles the 
  MonoDevelop.Gettext.dll install location with the 
  monodevelop-core-addins.pc location.

Show diffs side-by-side

added added

removed removed

Lines of Context:
780
780
                
781
781
                [DllImport("gtksharpglue-2", CallingConvention=CallingConvention.Cdecl)]
782
782
                static extern void gtksharp_container_override_forall (IntPtr gtype, ForallDelegate cb);
 
783
 
 
784
                public static string MarkupLinks (string text)
 
785
                {
 
786
                        if (Mono.TextEditor.GtkWorkarounds.GtkMinorVersion < 18)
 
787
                                return text;
 
788
                        return HighlightUrlSemanticRule.UrlRegex.Replace (text, MatchToUrl);
 
789
                }
 
790
 
 
791
                static string MatchToUrl (System.Text.RegularExpressions.Match m)
 
792
                {
 
793
                        var s = m.ToString ();
 
794
                        return String.Format ("<a href='{0}'>{1}</a>", s, s.Replace ("_", "__"));
 
795
                }
 
796
 
 
797
                public static void SetLinkHandler (this Gtk.Label label, Action<string> urlHandler)
 
798
                {
 
799
                        if (Mono.TextEditor.GtkWorkarounds.GtkMinorVersion >= 18)
 
800
                                new UrlHandlerClosure (urlHandler).ConnectTo (label);
 
801
                }
 
802
 
 
803
                //create closure manually so we can apply ConnectBefore
 
804
                class UrlHandlerClosure
 
805
                {
 
806
                        Action<string> urlHandler;
 
807
 
 
808
                        public UrlHandlerClosure (Action<string> urlHandler)
 
809
                        {
 
810
                                this.urlHandler = urlHandler;
 
811
                        }
 
812
 
 
813
                        [GLib.ConnectBefore]
 
814
                        void HandleLink (object sender, ActivateLinkEventArgs args)
 
815
                        {
 
816
                                urlHandler (args.Url);
 
817
                                args.RetVal = true;
 
818
                        }
 
819
 
 
820
                        public void ConnectTo (Gtk.Label label)
 
821
                        {
 
822
                                var signal = GLib.Signal.Lookup (label, "activate-link", typeof(ActivateLinkEventArgs));
 
823
                                signal.AddDelegate (new EventHandler<ActivateLinkEventArgs> (HandleLink));
 
824
                        }
 
825
 
 
826
                        class ActivateLinkEventArgs : GLib.SignalArgs
 
827
                        {
 
828
                                public string Url { get { return (string)base.Args [0]; } }
 
829
                        }
 
830
                }
783
831
        }
784
832
        
785
833
        public struct KeyboardShortcut : IEquatable<KeyboardShortcut>