Пример #1
0
        public ItemView(ItemList list)
            : base()
        {
            itemList = list;
            itemList.PropertyChanged += ItemListPropertyChanged;
            this.webView = new WebView ();
            #if ENABLE_FONTS
            this.webSettings = new WebSettings ();
            webView.Settings = webSettings;
            #endif
                        ScrolledWindow sw = new ScrolledWindow ();
                        sw.Add(webView);
            Add(sw);

            Conf.AddNotify (Preference.FONT_PATH,
                                        new NotifyEventHandler (FontNotifyHandler));
            SetFonts ();

            ProxyUpdatedCb ();
            Proxy.Updated += ProxyUpdatedCb;

            webView.NavigationRequested += delegate (object sender, NavigationRequestedArgs args) {
            try {
            /*
             * If last_link is the same as args.Request.Uri, the user clicked on a link
             * (as we know he was hovering). Thus, try to open it on the browser
             */
            if(args.Request.Uri.Equals(last_link)){
                args.RetVal = NavigationResponse.Ignore;
                GtkBeans.Global.ShowUri(null, args.Request.Uri);
            } else {
                /* Otherwise, it's part of the post, so accept it (like the facebook iframe) */
                args.RetVal = NavigationResponse.Accept;
            }
            }
            catch (Exception e) {
            Console.Error.WriteLine("Couldn't show URL: " + args.Request.Uri + e.Message);
            }
            };

            webView.HoveringOverLink += delegate (object sender, HoveringOverLinkArgs args) {
                if (OnUrl != null)
                  OnUrl (args.Link);
                  last_link = args.Link;
            };

            webView.Show ();
            PageLoaded = false;
        }