Ejemplo n.º 1
0
        public void UpdateContent(string html)
        {
            string pixmaps_path = new string [] { SparkleUI.AssetsPath, "pixmaps" }.Combine();
            string icons_path = new string [] { SparkleUI.AssetsPath, "icons", "hicolor", "12x12", "status" }.Combine();

            html = html.Replace("<!-- $a-hover-color -->", "#009ff8");
            html = html.Replace("<!-- $a-color -->", "#0085cf");

            html = html.Replace("<!-- $body-font-family -->", StyleContext.GetFont(StateFlags.Normal).Family);
            html = html.Replace("<!-- $body-font-size -->", (double)(StyleContext.GetFont(StateFlags.Normal).Size / 1024 + 3) + "px");
            html = html.Replace("<!-- $body-color -->", SparkleUIHelpers.RGBAToHex(StyleContext.GetColor(StateFlags.Normal)));
            html = html.Replace("<!-- $body-background-color -->",
                                SparkleUIHelpers.RGBAToHex(new TreeView().StyleContext.GetBackgroundColor(StateFlags.Normal)));

            html = html.Replace("<!-- $day-entry-header-font-size -->", (StyleContext.GetFont(StateFlags.Normal).Size / 1024 + 3) + "px");
            html = html.Replace("<!-- $day-entry-header-background-color -->",
                                SparkleUIHelpers.RGBAToHex(StyleContext.GetBackgroundColor(StateFlags.Normal)));

            html = html.Replace("<!-- $secondary-font-color -->", SparkleUIHelpers.RGBAToHex(StyleContext.GetColor(StateFlags.Insensitive)));

            html = html.Replace("<!-- $small-color -->", SparkleUIHelpers.RGBAToHex(StyleContext.GetColor(StateFlags.Insensitive)));
            html = html.Replace("<!-- $small-font-size -->", "90%");

            html = html.Replace("<!-- $pixmaps-path -->", pixmaps_path);
            html = html.Replace("<!-- $document-added-background-image -->", "file://" + new string [] { icons_path, "document-added.png" }.Combine());
            html = html.Replace("<!-- $document-edited-background-image -->", "file://" + new string [] { icons_path, "document-edited.png" }.Combine());
            html = html.Replace("<!-- $document-deleted-background-image -->", "file://" + new string [] { icons_path, "document-deleted.png" }.Combine());
            html = html.Replace("<!-- $document-moved-background-image -->", "file://" + new string [] { icons_path, "document-moved.png" }.Combine());

            this.spinner.Stop();
            this.scrolled_window.Remove(this.web_view);
            this.web_view.Dispose();

            this.web_view = new WebView()
            {
                Editable = false
            };
            this.web_view.LoadString(html, "text/html", "UTF-8", "file://");
            this.web_view.NavigationRequested += WebViewNavigationRequested;
            this.scrolled_window.Add(this.web_view);

            this.content_wrapper.Remove(this.content_wrapper.Child);
            this.content_wrapper.Add(this.scrolled_window);
            this.scrolled_window.ShowAll();
        }