From 760553f374bd21a7d858332de9c6b757c739ed12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Guchens?= Date: Wed, 13 May 2009 23:56:55 +0200 Subject: [PATCH] Store speed dial as JSON instead of actual HTML source This will make it possible to change the layout of the page without losing shortcuts. --- data/mootools.js | 112 ++++++++++++++++++++++++++------- data/speeddial-body.html | 65 ------------------- data/speeddial-head.html | 131 +++++++++++++++++++++++++++++++++------ data/speeddial.json | 1 + midori/midori-browser.c | 92 ++++++++++++++------------- midori/midori-view.c | 39 ++++++------ wscript | 2 +- 7 files changed, 270 insertions(+), 172 deletions(-) delete mode 100644 data/speeddial-body.html create mode 100644 data/speeddial.json diff --git a/data/mootools.js b/data/mootools.js index 19f9ba1b..f60d1562 100644 --- a/data/mootools.js +++ b/data/mootools.js @@ -1,3 +1,5 @@ +//MooTools, , My Object Oriented (JavaScript) Tools. Copyright (c) 2006-2009 Valerio Proietti, , MIT Style License. + var MooTools={version:"1.2.2",build:"f0491d62fbb7e906789aa3733d6a67d43e5af7c9"};var Native=function(k){k=k||{};var a=k.name;var i=k.legacy;var b=k.protect; var c=k.implement;var h=k.generics;var f=k.initialize;var g=k.afterImplement||function(){};var d=f||i;h=h!==false;d.constructor=Native;d.$family={name:"native"}; if(i&&f){d.prototype=i.prototype;}d.prototype.constructor=d;if(a){var e=a.toLowerCase();d.prototype.$family={name:e};Native.typize(d,e);}var j=function(n,l,o,m){if(!b||m||!n.prototype[l]){n.prototype[l]=o; @@ -86,7 +88,27 @@ break;case"mouseout":l=a.relatedTarget||a.toElement;}if(!(function(){while(l&&l. }}}}return $extend(this,{event:a,type:j,page:i,client:c,rightClick:e,wheel:h,relatedTarget:l,target:g,code:b,key:m,shift:a.shiftKey,control:a.ctrlKey,alt:a.altKey,meta:a.metaKey}); }});Event.Keys=new Hash({enter:13,up:38,down:40,left:37,right:39,esc:27,space:32,backspace:8,tab:9,"delete":46});Event.implement({stop:function(){return this.stopPropagation().preventDefault(); },stopPropagation:function(){if(this.event.stopPropagation){this.event.stopPropagation();}else{this.event.cancelBubble=true;}return this;},preventDefault:function(){if(this.event.preventDefault){this.event.preventDefault(); -}else{this.event.returnValue=false;}return this;}});var Element=new Native({name:"Element",legacy:window.Element,initialize:function(a,b){var c=Element.Constructors.get(a); +}else{this.event.returnValue=false;}return this;}});function Class(b){if(b instanceof Function){b={initialize:b};}var a=function(){Object.reset(this);if(a._prototyping){return this; +}this._current=$empty;var c=(this.initialize)?this.initialize.apply(this,arguments):this;delete this._current;delete this.caller;return c;}.extend(this); +a.implement(b);a.constructor=Class;a.prototype.constructor=a;return a;}Function.prototype.protect=function(){this._protected=true;return this;};Object.reset=function(a,c){if(c==null){for(var e in a){Object.reset(a,e); +}return a;}delete a[c];switch($type(a[c])){case"object":var d=function(){};d.prototype=a[c];var b=new d;a[c]=Object.reset(b);break;case"array":a[c]=$unlink(a[c]); +break;}return a;};new Native({name:"Class",initialize:Class}).extend({instantiate:function(b){b._prototyping=true;var a=new b;delete b._prototyping;return a; +},wrap:function(a,b,c){if(c._origin){c=c._origin;}return function(){if(c._protected&&this._current==null){throw new Error('The method "'+b+'" cannot be called.'); +}var e=this.caller,f=this._current;this.caller=f;this._current=arguments.callee;var d=c.apply(this,arguments);this._current=f;this.caller=e;return d;}.extend({_owner:a,_origin:c,_name:b}); +}});Class.implement({implement:function(a,d){if($type(a)=="object"){for(var e in a){this.implement(e,a[e]);}return this;}var f=Class.Mutators[a];if(f){d=f.call(this,d); +if(d==null){return this;}}var c=this.prototype;switch($type(d)){case"function":if(d._hidden){return this;}c[a]=Class.wrap(this,a,d);break;case"object":var b=c[a]; +if($type(b)=="object"){$mixin(b,d);}else{c[a]=$unlink(d);}break;case"array":c[a]=$unlink(d);break;default:c[a]=d;}return this;}});Class.Mutators={Extends:function(a){this.parent=a; +this.prototype=Class.instantiate(a);this.implement("parent",function(){var b=this.caller._name,c=this.caller._owner.parent.prototype[b];if(!c){throw new Error('The method "'+b+'" has no parent.'); +}return c.apply(this,arguments);}.protect());},Implements:function(a){$splat(a).each(function(b){if(b instanceof Function){b=Class.instantiate(b);}this.implement(b); +},this);}};var Chain=new Class({$chain:[],chain:function(){this.$chain.extend(Array.flatten(arguments));return this;},callChain:function(){return(this.$chain.length)?this.$chain.shift().apply(this,arguments):false; +},clearChain:function(){this.$chain.empty();return this;}});var Events=new Class({$events:{},addEvent:function(c,b,a){c=Events.removeOn(c);if(b!=$empty){this.$events[c]=this.$events[c]||[]; +this.$events[c].include(b);if(a){b.internal=true;}}return this;},addEvents:function(a){for(var b in a){this.addEvent(b,a[b]);}return this;},fireEvent:function(c,b,a){c=Events.removeOn(c); +if(!this.$events||!this.$events[c]){return this;}this.$events[c].each(function(d){d.create({bind:this,delay:a,"arguments":b})();},this);return this;},removeEvent:function(b,a){b=Events.removeOn(b); +if(!this.$events[b]){return this;}if(!a.internal){this.$events[b].erase(a);}return this;},removeEvents:function(c){var d;if($type(c)=="object"){for(d in c){this.removeEvent(d,c[d]); +}return this;}if(c){c=Events.removeOn(c);}for(d in this.$events){if(c&&c!=d){continue;}var b=this.$events[d];for(var a=b.length;a--;a){this.removeEvent(d,b[a]); +}}return this;}});Events.removeOn=function(a){return a.replace(/^on([A-Z])/,function(b,c){return c.toLowerCase();});};var Options=new Class({setOptions:function(){this.options=$merge.run([this.options].extend(arguments)); +if(!this.addEvent){return this;}for(var a in this.options){if($type(this.options[a])!="function"||!(/^on[A-Z]/).test(a)){continue;}this.addEvent(a,this.options[a]); +delete this.options[a];}return this;}});var Element=new Native({name:"Element",legacy:window.Element,initialize:function(a,b){var c=Element.Constructors.get(a); if(c){return c(b);}if(typeof a=="string"){return document.newElement(a,b);}return $(a).set(b);},afterImplement:function(a,b){Element.Prototype[a]=b;if(Array[a]){return; }Elements.implement(a,function(){var c=[],g=true;for(var e=0,d=this.length;e1),cash:!g});}});Element.implement({match:function(b){if(!b||(b==this)){return true;}var d=Selectors.Utils.parseTagAndID(b); var a=d[0],e=d[1];if(!Selectors.Filters.byID(this,e)||!Selectors.Filters.byTag(this,a)){return false;}var c=Selectors.Utils.parseSelector(b);return(c)?Selectors.Utils.filter(this,c,{}):true; @@ -242,4 +245,69 @@ while((b=b.previousSibling)){if(b.nodeType!=1){continue;}f++;var a=e.positions[$ },encode:function(b){switch($type(b)){case"string":return'"'+b.replace(/[\x00-\x1f\\"]/g,JSON.$replaceChars)+'"';case"array":return"["+String(b.map(JSON.encode).filter($defined))+"]"; case"object":case"hash":var a=[];Hash.each(b,function(e,d){var c=JSON.encode(e);if(c){a.push(JSON.encode(d)+":"+c);}});return"{"+a+"}";case"number":case"boolean":return String(b); case false:return"null";}return null;},decode:function(string,secure){if($type(string)!="string"||!string.length){return null;}if(secure&&!(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,""))){return null; -}return eval("("+string+")");}});Native.implement([Hash,Array,String,Number],{toJSON:function(){return JSON.encode(this);}}); +}return eval("("+string+")");}});Native.implement([Hash,Array,String,Number],{toJSON:function(){return JSON.encode(this);}});var Cookie=new Class({Implements:Options,options:{path:false,domain:false,duration:false,secure:false,document:document},initialize:function(b,a){this.key=b; +this.setOptions(a);},write:function(b){b=encodeURIComponent(b);if(this.options.domain){b+="; domain="+this.options.domain;}if(this.options.path){b+="; path="+this.options.path; +}if(this.options.duration){var a=new Date();a.setTime(a.getTime()+this.options.duration*24*60*60*1000);b+="; expires="+a.toGMTString();}if(this.options.secure){b+="; secure"; +}this.options.document.cookie=this.key+"="+b;return this;},read:function(){var a=this.options.document.cookie.match("(?:^|;)\\s*"+this.key.escapeRegExp()+"=([^;]*)"); +return(a)?decodeURIComponent(a[1]):null;},dispose:function(){new Cookie(this.key,$merge(this.options,{duration:-1})).write("");return this;}});Cookie.write=function(b,c,a){return new Cookie(b,a).write(c); +};Cookie.read=function(a){return new Cookie(a).read();};Cookie.dispose=function(b,a){return new Cookie(b,a).dispose();};var Fx=new Class({Implements:[Chain,Events,Options],options:{fps:50,unit:false,duration:500,link:"ignore"},initialize:function(a){this.subject=this.subject||this; +this.setOptions(a);this.options.duration=Fx.Durations[this.options.duration]||this.options.duration.toInt();var b=this.options.wait;if(b===false){this.options.link="cancel"; +}},getTransition:function(){return function(a){return -(Math.cos(Math.PI*a)-1)/2;};},step:function(){var a=$time();if(a=(7-4*d)/11){e=c*c-Math.pow((11-6*d-11*f)/4,2); +break;}}return e;},Elastic:function(b,a){return Math.pow(2,10*--b)*Math.cos(20*b*Math.PI*(a[0]||1)/3);}});["Quad","Cubic","Quart","Quint"].each(function(b,a){Fx.Transitions[b]=new Fx.Transition(function(c){return Math.pow(c,[a+2]); +});});var Request=new Class({Implements:[Chain,Events,Options],options:{url:"",data:"",headers:{"X-Requested-With":"XMLHttpRequest",Accept:"text/javascript, text/html, application/xml, text/xml, */*"},async:true,format:false,method:"post",link:"ignore",isSuccess:null,emulation:true,urlEncoded:true,encoding:"utf-8",evalScripts:false,evalResponse:false,noCache:false},initialize:function(a){this.xhr=new Browser.Request(); +this.setOptions(a);this.options.isSuccess=this.options.isSuccess||this.isSuccess;this.headers=new Hash(this.options.headers);},onStateChange:function(){if(this.xhr.readyState!=4||!this.running){return; +}this.running=false;this.status=0;$try(function(){this.status=this.xhr.status;}.bind(this));if(this.options.isSuccess.call(this,this.status)){this.response={text:this.xhr.responseText,xml:this.xhr.responseXML}; +this.success(this.response.text,this.response.xml);}else{this.response={text:null,xml:null};this.failure();}this.xhr.onreadystatechange=$empty;},isSuccess:function(){return((this.status>=200)&&(this.status<300)); +},processScripts:function(a){if(this.options.evalResponse||(/(ecma|java)script/).test(this.getHeader("Content-type"))){return $exec(a);}return a.stripScripts(this.options.evalScripts); +},success:function(b,a){this.onSuccess(this.processScripts(b),a);},onSuccess:function(){this.fireEvent("complete",arguments).fireEvent("success",arguments).callChain(); +},failure:function(){this.onFailure();},onFailure:function(){this.fireEvent("complete").fireEvent("failure",this.xhr);},setHeader:function(a,b){this.headers.set(a,b); +return this;},getHeader:function(a){return $try(function(){return this.xhr.getResponseHeader(a);}.bind(this));},check:function(){if(!this.running){return true; +}switch(this.options.link){case"cancel":this.cancel();return true;case"chain":this.chain(this.caller.bind(this,arguments));return false;}return false;},send:function(j){if(!this.check(j)){return this; +}this.running=true;var h=$type(j);if(h=="string"||h=="element"){j={data:j};}var d=this.options;j=$extend({data:d.data,url:d.url,method:d.method},j);var f=j.data,b=j.url,a=j.method; +switch($type(f)){case"element":f=$(f).toQueryString();break;case"object":case"hash":f=Hash.toQueryString(f);}if(this.options.format){var i="format="+this.options.format; +f=(f)?i+"&"+f:i;}if(this.options.emulation&&["put","delete"].contains(a)){var g="_method="+a;f=(f)?g+"&"+f:g;a="post";}if(this.options.urlEncoded&&a=="post"){var c=(this.options.encoding)?"; charset="+this.options.encoding:""; +this.headers.set("Content-type","application/x-www-form-urlencoded"+c);}if(this.options.noCache){var e="noCache="+new Date().getTime();f=(f)?e+"&"+f:e; +}if(f&&a=="get"){b=b+(b.contains("?")?"&":"?")+f;f=null;}this.xhr.open(a.toUpperCase(),b,this.options.async);this.xhr.onreadystatechange=this.onStateChange.bind(this); +this.headers.each(function(l,k){try{this.xhr.setRequestHeader(k,l);}catch(m){this.fireEvent("exception",[k,l]);}},this);this.fireEvent("request");this.xhr.send(f); +if(!this.options.async){this.onStateChange();}return this;},cancel:function(){if(!this.running){return this;}this.running=false;this.xhr.abort();this.xhr.onreadystatechange=$empty; +this.xhr=new Browser.Request();this.fireEvent("cancel");return this;}});(function(){var a={};["get","post","put","delete","GET","POST","PUT","DELETE"].each(function(b){a[b]=function(){var c=Array.link(arguments,{url:String.type,data:$defined}); +return this.send($extend(c,{method:b.toLowerCase()}));};});Request.implement(a);})(); \ No newline at end of file diff --git a/data/speeddial-body.html b/data/speeddial-body.html deleted file mode 100644 index d0b3852b..00000000 --- a/data/speeddial-body.html +++ /dev/null @@ -1,65 +0,0 @@ - -
-
- -

1

-
-

-
-
- -

2

-
-

-
-
- -

3

-
-

-
-
- -

4

-
-

-
-
- -

5

-
-

-
-
- -

6

-
-

-
-
- -

7

-
-

-
-
- -

8

-
-

-
-
- -

9

-
-

-
-
-
- - - diff --git a/data/speeddial-head.html b/data/speeddial-head.html index a2811f3a..48ee2aff 100644 --- a/data/speeddial-head.html +++ b/data/speeddial-head.html @@ -11,6 +11,12 @@ @@ -255,4 +341,9 @@ onblur="javascript:if(this.value=='') this.value='{search_title}';" /> +
+
+ + + diff --git a/data/speeddial.json b/data/speeddial.json new file mode 100644 index 00000000..0bb63f32 --- /dev/null +++ b/data/speeddial.json @@ -0,0 +1 @@ +'{"shortcuts": [ { "id": "s1", "href": "#", "title": "", "img": "" }, { "id": "s2", "href": "#", "title": "", "img": "" }, { "id": "s3", "href": "#", "title": "", "img": "" }, { "id": "s4", "href": "#", "title": "", "img": "" }, { "id": "s5", "href": "#", "title": "", "img": "" }, { "id": "s6", "href": "#", "title": "", "img": "" }, { "id": "s7", "href": "#", "title": "", "img": "" }, { "id": "s8", "href": "#", "title": "", "img": "" }, { "id": "s9", "href": "#", "title": "", "img": "" } ] }' diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 29d018b9..34c5aef9 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -874,33 +874,45 @@ midori_view_save_as_cb (GtkWidget* menuitem, static gchar* midori_browser_speed_dial_get_next_free_slot (void) { + GRegex* regex; + GMatchInfo* match_info; gchar* speed_dial_body; gchar* body_fname; gchar* slot_id = NULL; - gchar* p = NULL; body_fname = g_build_filename (sokoke_set_config_dir (NULL), - "speeddial-body.html", NULL); + "speeddial.json", NULL); + if (!g_file_test (body_fname, G_FILE_TEST_EXISTS)) { - g_file_get_contents (DATADIR "/midori/res/speeddial-body.html", - &speed_dial_body, NULL, NULL); - g_file_set_contents (body_fname, speed_dial_body, -1, NULL); + if (g_file_get_contents (DATADIR "/midori/res/speeddial.json", + &speed_dial_body, NULL, NULL)) + { + g_file_set_contents (body_fname, speed_dial_body, -1, NULL); + + g_free (speed_dial_body); + } + g_free (body_fname); + return g_strdup ("s1"); } else g_file_get_contents (body_fname, &speed_dial_body, NULL, NULL); - p = g_strstr_len (speed_dial_body, -1, "

"); + regex = g_regex_new ("\"id\":[ \t]*\"(s[0-9])\"[ \t]*,[ \t]*\"href\":\"#\"", + G_REGEX_MULTILINE, 0, NULL); - if (p != NULL) + if (g_regex_match (regex, speed_dial_body, 0, &match_info)) { - p = g_strndup ((p+4), 1); - slot_id = g_strdup_printf ("s%s", p); - g_free (p); + slot_id = g_match_info_fetch (match_info, 1); + g_match_info_free (match_info); } + if (!g_strcmp0 (slot_id, "")) + g_free (slot_id); + g_free (body_fname); g_free (speed_dial_body); + g_free (regex); return slot_id; } @@ -954,45 +966,37 @@ midori_browser_add_speed_dial (MidoriBrowser* browser) gsize sz; body_fname = g_build_filename (sokoke_set_config_dir (NULL), - "speeddial-body.html", NULL); + "speeddial.json", NULL); - g_file_get_contents (body_fname, &speed_dial_body, NULL, NULL); + if (g_file_get_contents (body_fname, &speed_dial_body, NULL, NULL)) + { + img = gdk_pixbuf_new_from_file_at_scale (filename, 160, 107, FALSE, NULL); + gdk_pixbuf_save_to_buffer (img, &file_content, &sz, "png", NULL, NULL); + encoded = g_base64_encode ((guchar *)file_content, sz); - img = gdk_pixbuf_new_from_file_at_scale (filename, 160, 107, FALSE, NULL); - gdk_pixbuf_save_to_buffer (img, &file_content, &sz, "png", NULL, NULL); - encoded = g_base64_encode ((guchar *)file_content, sz); + replace_from = g_strdup_printf ( + "\\{[ \t]*\"id\"[ \t]*:[ \t]*\"%s\"[ \t]*,[ \t]*\"href\"[ \t]*"\ + "[ \t]*:[ \t]*\"#\"[ \t]*,[ \t]*\"title\"[ \t]*:[ \t]*\"\"[ \t]*,"\ + "\"img\"[ \t]*:[ \t]*\"\"[ \t]*\\}", slot_id); + replace_by = g_strdup_printf ( + "{\"id\":\"%s\",\"href\":\"%s\",\"title\":\"%s\",\"img\":\"%s\"}", + slot_id, uri, title, encoded); - replace_from = g_strdup_printf ( - "
[ \r\n\t]*"\ - "[ \r\n\t]*

"\ - "%s

.+

[ \r\n\t]*
[ \r\n\t]*

[ ]*

[ \r\t\n]*
", - slot_id, slot_id, (slot_id+1)); + regex = g_regex_new (replace_from, G_REGEX_MULTILINE, 0, NULL); + replace = g_regex_replace (regex, speed_dial_body, -1, + 1, replace_by, 0, NULL); + g_file_set_contents (body_fname, replace, -1, NULL); - replace_by = g_strdup_printf ( - "
"\ - "
x

%s

", - slot_id, slot_id, uri, slot_id, encoded, slot_id, title); - - regex = g_regex_new (replace_from, G_REGEX_MULTILINE, 0, NULL); - replace = g_regex_replace (regex, speed_dial_body, -1, - 1, replace_by, 0, NULL); - - g_file_set_contents (body_fname, replace, -1, NULL); - - g_object_unref (img); - g_regex_unref (regex); - g_free (encoded); - g_free (file_content); + g_object_unref (img); + g_regex_unref (regex); + g_free (encoded); + g_free (file_content); + g_free (speed_dial_body); + g_free (replace_from); + g_free (replace_by); + g_free (replace); + } g_free (body_fname); - g_free (speed_dial_body); - g_free (replace_by); - g_free (replace_from); - g_free (replace); } g_free (thumb); diff --git a/midori/midori-view.c b/midori/midori-view.c index 744a4578..f60880f6 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -185,7 +185,9 @@ midori_view_speed_dial_get_thumb (GtkWidget* web_view, MidoriView* view); static void -midori_view_speed_dial_save (GtkWidget* web_view); +midori_view_speed_dial_save (GtkWidget* web_view, + const gchar* message); + static void midori_view_class_init (MidoriViewClass* class) @@ -1470,7 +1472,7 @@ webkit_web_view_console_message_cb (GtkWidget* web_view, if (!strncmp (message, "speed_dial-get-thumbnail", 22)) midori_view_speed_dial_get_thumb (web_view, message, view); else if (!strncmp (message, "speed_dial-save", 13)) - midori_view_speed_dial_save (web_view); + midori_view_speed_dial_save (web_view, message); else g_signal_emit (view, signals[CONSOLE_MESSAGE], 0, message, line, source_id); return TRUE; @@ -1980,7 +1982,6 @@ midori_view_set_uri (MidoriView* view, gchar* res_root; gchar* speed_dial_head; gchar* speed_dial_body; - gchar* speed_dial_html; gchar* body_fname; gchar* location_entry_search; gchar* stock_root; @@ -1995,25 +1996,27 @@ midori_view_set_uri (MidoriView* view, res_root = g_strdup_printf ("http://localhost:%d/res", port); stock_root = g_strdup_printf ("http://localhost:%d/stock", port); body_fname = g_build_filename (sokoke_set_config_dir (NULL), - "speeddial-body.html", NULL); + "speeddial.json", NULL); if (!g_file_test (body_fname, G_FILE_TEST_EXISTS)) { - g_file_get_contents (DATADIR "/midori/res/speeddial-body.html", - &speed_dial_body, NULL, NULL ); - g_file_set_contents (body_fname, speed_dial_body, -1, NULL ); + if (g_file_get_contents (DATADIR "/midori/res/speeddial.json", + &speed_dial_body, NULL, NULL)) + g_file_set_contents (body_fname, speed_dial_body, -1, NULL); + else + speed_dial_body = g_strdup (""); } else g_file_get_contents (body_fname, &speed_dial_body, NULL, NULL); - speed_dial_html = g_strconcat (speed_dial_head, speed_dial_body, NULL); g_object_get (view->settings, "location-entry-search", &location_entry_search, NULL); - data = sokoke_replace_variables (speed_dial_html, + data = sokoke_replace_variables (speed_dial_head, "{res}", res_root, "{stock}", stock_root, + "{json_data}", speed_dial_body, "{title}", _("Blank page"), "{search_uri}", location_entry_search, "{search_title}", _("Search"), @@ -2036,7 +2039,6 @@ midori_view_set_uri (MidoriView* view, g_free (res_root); g_free (stock_root); g_free (data); - g_free (speed_dial_html); g_free (speed_dial_head); g_free (speed_dial_body); g_free (body_fname); @@ -2956,7 +2958,7 @@ midori_view_speed_dial_inject_thumb (MidoriView* view, return; img = gdk_pixbuf_new_from_file_at_scale (filename, 160, 107, FALSE, NULL); - gdk_pixbuf_save_to_buffer (img, &file_content, &sz, "png", NULL, NULL); + gdk_pixbuf_save_to_buffer (img, &file_content, &sz, "png", NULL, "compression", "7", NULL); encoded = g_base64_encode ( (guchar *)file_content, sz ); /* Call Javascript function to replace shortcut's content */ @@ -2965,8 +2967,6 @@ midori_view_speed_dial_inject_thumb (MidoriView* view, free (js); g_object_unref (img); - midori_view_speed_dial_save (view->web_view); - g_free (url); g_free (dom_id); g_free (encoded); @@ -3018,14 +3018,13 @@ midori_view_speed_dial_get_thumb (GtkWidget* web_view, * **/ static void -midori_view_speed_dial_save (GtkWidget* web_view) +midori_view_speed_dial_save (GtkWidget* web_view, + const gchar* message) { - JSContextRef js_context = webkit_web_frame_get_global_context ( - webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view))); - gchar* newdom = sokoke_js_script_eval (js_context,"getSpeeddialContent()", NULL); + gchar* json = g_strdup (message + 15); gchar* fname = g_build_filename (sokoke_set_config_dir (NULL), - "speeddial-body.html", NULL); - g_file_set_contents (fname, newdom, -1, NULL); + "speeddial.json", NULL); + g_file_set_contents (fname, json, -1, NULL); g_free (fname); - g_free (newdom); + g_free (json); } diff --git a/wscript b/wscript index 4fcb61c9..bdca1030 100644 --- a/wscript +++ b/wscript @@ -340,7 +340,7 @@ def build (bld): Utils.pprint ('BLUE', "logo-shade could not be rasterized.") bld.install_files ('${DATADIR}/' + APPNAME + '/res', 'data/error.html') bld.install_files ('${DATADIR}/' + APPNAME + '/res', 'data/speeddial-head.html') - bld.install_files ('${DATADIR}/' + APPNAME + '/res', 'data/speeddial-body.html') + bld.install_files ('${DATADIR}/' + APPNAME + '/res', 'data/speeddial.json') bld.install_files ('${DATADIR}/' + APPNAME + '/res', 'data/mootools.js') if Options.commands['check']: