[blam] Adapt to some new WebKit changes



commit 4a5c831d181661640c3421685997da1349c36946
Author: Carlos Martín Nieto <carlos cmartin tk>
Date:   Wed Nov 11 15:43:11 2009 +0100

    Adapt to some new WebKit changes

 src/ItemView.cs          |   13 +++++++++++--
 themes/blam/theme.html   |    2 +-
 themes/pimped/theme.html |    3 +--
 themes/planet/theme.html |    2 +-
 4 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/src/ItemView.cs b/src/ItemView.cs
index a7b007a..8097f64 100644
--- a/src/ItemView.cs
+++ b/src/ItemView.cs
@@ -25,6 +25,7 @@ namespace Imendio.Blam {
         private WebSettings webSettings;
 #endif
 	private Imendio.Blam.Item currentItem;
+    private string baseDir = null;
 
 	public bool PageLoaded;
 
@@ -67,7 +68,13 @@ namespace Imendio.Blam {
 
 		webView.NavigationRequested += delegate (object sender, NavigationRequestedArgs args) {
         try {
+            /* Allow our local files to be downloaded. Needed to load the theme */
+            if(args.Request.Uri.StartsWith(baseDir)){
+                    args.RetVal = NavigationResponse.Accept;
+                    return;
+            }
             Gnome.Url.Show(args.Request.Uri);
+                    args.RetVal = NavigationResponse.Ignore;
         }
         catch (Exception e) {
             Console.Error.WriteLine("Couldn't show URL: " + args.Request.Uri + e.Message);
@@ -119,6 +126,7 @@ namespace Imendio.Blam {
             string text    = HtmlUtils.EncodeUnicode(HtmlUtils.FixMarkup(currentItem.Text));
             string title   = HtmlUtils.Escape(currentItem.Title);
             string url     = currentItem.Link;
+            baseDir        = "file://" + theme.Path;
 
             string[] replaces = {
                 "author", author,
@@ -126,10 +134,11 @@ namespace Imendio.Blam {
                 "pubdate", pubdate,
                 "text", text,
                 "title", title,
-                "url", url
+                "url", url,
+                "localbase", baseDir
             };
 
-						webView.LoadString (theme.Render(replaces), "text/html", "utf8", "file://" + theme.Path + "/");
+			webView.LoadString(theme.Render(replaces), null, null, baseDir);
 	}
 
         private void SetFonts ()
diff --git a/themes/blam/theme.html b/themes/blam/theme.html
index 2a41912..2dbc50f 100644
--- a/themes/blam/theme.html
+++ b/themes/blam/theme.html
@@ -1,7 +1,7 @@
 <html>
   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
-	<link rel="stylesheet" href="blam.css" type="text/css">
+	<link rel="stylesheet" href="${localbase}/blam.css" type="text/css">
     <title>${title}</title>
     <base href="${url}" />
   </head>
diff --git a/themes/pimped/theme.html b/themes/pimped/theme.html
index 4e5e29a..681bdad 100644
--- a/themes/pimped/theme.html
+++ b/themes/pimped/theme.html
@@ -1,12 +1,11 @@
 <html>
   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
-    <link rel="stylesheet" href="pimped.css" type="text/css">
     <title>${title}</title>
+    <link rel="stylesheet" href="${localbase}/pimped.css" type="text/css">
     <base href="${url}" />
   </head>
   <body>
-
     <div id="body">
       ${text}
     </div>
diff --git a/themes/planet/theme.html b/themes/planet/theme.html
index bf936f8..849e6da 100644
--- a/themes/planet/theme.html
+++ b/themes/planet/theme.html
@@ -2,7 +2,7 @@
 <html>
 <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
-    <link rel="stylesheet" href="planet.css" type="text/css">
+    <link rel="stylesheet" href="${localbase}/planet.css" type="text/css">
     <base href="${url}" />
 </head>
 <body>



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