Beispiel #1
0
 public override void DecidePolicyForNavigation(WebView web_view, NSDictionary action_info,
                                                NSUrlRequest request, WebFrame frame, NSObject decision_token)
 {
     SparkleEventLogController.LinkClicked(request.Url.ToString());
 }
        public SparkleEventLog() : base("")
        {
            SetSizeRequest(480, 640);
            SetPosition(WindowPosition.Center);

            Resizable   = true;
            BorderWidth = 0;

            Title    = _("Recent Events");
            IconName = "folder-sparkleshare";

            DeleteEvent += Close;

            this.size_label = new Label()
            {
                Markup = "<b>Size:</b> " + Controller.Size + "   " +
                         "<b>History:</b> " + Controller.HistorySize
            };

            VBox layout_vertical = new VBox(false, 0);

            this.spinner         = new SparkleSpinner(22);
            this.content_wrapper = new EventBox();
            this.scrolled_window = new ScrolledWindow();

            this.web_view = new WebView()
            {
                Editable = false
            };

            this.web_view.HoveringOverLink += delegate(object o, WebKit.HoveringOverLinkArgs args) {
                this.link_status = args.Link;
            };

            this.web_view.NavigationRequested += delegate(object o, WebKit.NavigationRequestedArgs args) {
                if (args.Request.Uri == this.link_status)
                {
                    SparkleEventLogController.LinkClicked(args.Request.Uri);
                }

                // Don't follow HREFs (as this would cause a page refresh)
                if (!args.Request.Uri.Equals("file:"))
                {
                    args.RetVal = 1;
                }
            };

            this.scrolled_window.Add(this.web_view);
            this.content_wrapper.Add(this.spinner);

            this.spinner.Start();

            this.layout_horizontal = new HBox(false, 0);
            this.layout_horizontal.PackStart(this.size_label, true, true, 0);
            this.layout_horizontal.PackStart(new Label("  "), false, false, 0);

            layout_vertical.PackStart(this.layout_horizontal, false, false, 0);
            layout_vertical.PackStart(CreateShortcutsBar(), false, false, 0);
            layout_vertical.PackStart(this.content_wrapper, true, true, 0);

            Add(layout_vertical);
            ShowAll();

            UpdateChooser(null);
            UpdateContent(null);


            // Hook up the controller events
            Controller.UpdateChooserEvent += delegate(string [] folders) {
                Application.Invoke(delegate {
                    UpdateChooser(folders);
                });
            };

            Controller.UpdateContentEvent += delegate(string html) {
                Application.Invoke(delegate {
                    UpdateContent(html);
                });
            };

            Controller.ContentLoadingEvent += delegate {
                Application.Invoke(delegate {
                    if (this.content_wrapper.Child != null)
                    {
                        this.content_wrapper.Remove(this.content_wrapper.Child);
                    }

                    this.content_wrapper.Add(this.spinner);
                    this.spinner.Start();
                    this.content_wrapper.ShowAll();
                });
            };

            Controller.UpdateSizeInfoEvent += delegate(string size, string history_size) {
                Application.Invoke(delegate {
                    this.size_label.Markup = "<b>Size:</b> " + size + "   " +
                                             "<b>History:</b> " + history_size;

                    this.size_label.ShowAll();
                });
            };
        }