02ba4df3e059af5480ef10f9d5e587576b4fde91
[roobuilder] / src / Builder4 / WindowRooView.vala
1 static Xcls_WindowRooView  _WindowRooView;
2
3 public class Xcls_WindowRooView : Object
4 {
5     public Gtk.Box el;
6     private Xcls_WindowRooView  _this;
7
8     public static Xcls_WindowRooView singleton()
9     {
10         if (_WindowRooView == null) {
11             _WindowRooView= new Xcls_WindowRooView();
12         }
13         return _WindowRooView;
14     }
15     public Xcls_notebook notebook;
16     public Xcls_label_preview label_preview;
17     public Xcls_label_code label_code;
18     public Xcls_paned paned;
19     public Xcls_viewbox viewbox;
20     public Xcls_AutoRedraw AutoRedraw;
21     public Xcls_viewcontainer viewcontainer;
22     public Xcls_view view;
23     public Xcls_inspectorcontainer inspectorcontainer;
24     public Xcls_sourceview sourceview;
25     public Xcls_buffer buffer;
26
27         // my vars (def)
28     public Gtk.Widget lastObj;
29     public int width;
30     public int last_search_end;
31     public Gtk.SourceSearchContext searchcontext;
32     public JsRender.JsRender file;
33     public int height;
34     public Xcls_MainWindow main_window;
35
36     // ctor
37     public Xcls_WindowRooView()
38     {
39         _this = this;
40         this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
41
42         // my vars (dec)
43         this.lastObj = null;
44         this.width = 0;
45         this.last_search_end = 0;
46         this.file = null;
47         this.height = 0;
48
49         // set gobject values
50         this.el.hexpand = true;
51         var child_0 = new Xcls_notebook( _this );
52         child_0.ref();
53         this.el.pack_start (  child_0.el , true,true,0 );
54     }
55
56     // user defined functions
57     public void scroll_to_line (int line) {
58        this.notebook.el.page = 1;// code preview...
59        
60        GLib.Timeout.add(500, () => {
61        
62        
63            
64            
65                   var buf = this.sourceview.el.get_buffer();
66          
67                 var sbuf = (Gtk.SourceBuffer) buf;
68     
69     
70                 Gtk.TextIter iter;   
71                 sbuf.get_iter_at_line(out iter,  line);
72                 this.sourceview.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.5f);
73                 return false;
74         });   
75     
76        
77     }
78     public void createThumb () {
79         
80         
81         if (this.file == null) {
82             return;
83         }
84         if (this.notebook.el.page > 0 ) {
85             return;
86         }
87         
88         var filename = this.file.getIconFileName(false);
89         
90         var  win = this.el.get_parent_window();
91         var width = win.get_width();
92       //  var height = win.get_height();
93         try { 
94             Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, this.paned.el.position);
95             screenshot.save(filename,"png");
96         } catch(Error e) {
97             //noop
98         }
99     
100         
101          
102         
103          
104     }
105     public void loadFile (JsRender.JsRender file)
106     {
107         this.file = file;
108         this.view.renderJS(true);
109         this.notebook.el.page = 0;// gtk preview 
110         this.sourceview.loadFile();   
111         
112     }
113     public int search (string txt) {
114         this.notebook.el.page = 1;
115         var s = new Gtk.SourceSearchSettings();
116         var buf = (Gtk.SourceBuffer) this.sourceview.el.get_buffer();
117         this.searchcontext = new Gtk.SourceSearchContext(buf,s);
118         this.searchcontext.set_highlight(true);
119         s.set_search_text(txt);
120         
121         Gtk.TextIter beg, st,en;
122          
123         buf.get_start_iter(out beg);
124         this.searchcontext.forward(beg, out st, out en);
125         this.last_search_end  = 0;
126         return this.searchcontext.get_occurrences_count();
127     
128        
129     }
130     public void requestRedraw () {
131         this.view.renderJS(false);
132         this.sourceview.loadFile();   
133     }
134     public void forwardSearch (bool change_focus) {
135     
136         if (this.searchcontext == null) {
137                 return;
138         }
139         this.notebook.el.page = 1;
140         Gtk.TextIter beg, st,en, stl;
141         
142         var buf = this.sourceview.el.get_buffer();
143         buf.get_iter_at_offset(out beg, this.last_search_end);
144         if (!this.searchcontext.forward(beg, out st, out en)) {
145                 this.last_search_end = 0;
146                 return;
147         }
148         this.last_search_end = en.get_offset();
149         if (change_focus) {
150                 this.sourceview.el.grab_focus();
151         }
152         buf.place_cursor(st);
153         var ln = st.get_line();
154         buf.get_iter_at_line(out stl,ln);
155          
156         this.sourceview.el.scroll_to_iter(stl,  0.0f, true, 0.0f, 0.5f);
157         
158         // highlight node...
159         
160                 
161         var node = _this.file.lineToNode(ln+1);
162      
163         if (node == null) {
164             //print("can not find node\n");
165             return;
166         }
167         var prop = node.lineToProp(ln+1);
168         print("prop : %s", prop == null ? "???" : prop);
169             
170             
171         // ---------- this selects the tree's node...
172         
173         var ltree = _this.main_window.windowstate.left_tree;
174         var tp = ltree.model.treePathFromNode(node);
175         print("got tree path %s\n", tp);
176         if (tp == "") {
177                 return;
178         }
179         //_this.sourceview.allow_node_scroll = false; /// block node scrolling..
180                
181        
182         //print("changing cursor on tree..\n");
183        
184     
185         
186         // let's try allowing editing on the methods.
187         // a little klunky at present..
188         _this.sourceview.prop_selected = "";
189         if (prop != null) {
190                 //see if we can find it..
191                 var kv = prop.split(":");
192                 if (kv[0] == "p") {
193                 
194                         //var k = prop.get_key(kv[1]);
195                         // fixme -- need to determine if it's an editable property...
196                         _this.sourceview.prop_selected = prop;
197                         
198                 } else if (kv[0] == "l") {
199                          _this.sourceview.prop_selected = prop;
200                         
201                 }
202         }
203         ltree.view.setCursor(tp, "editor");
204        // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); 
205        _this.sourceview.nodeSelected(node,false);
206         
207                 // scrolling is disabled... as node selection calls scroll 10ms after it changes.
208           //      GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {
209           //          this.allow_node_scroll = true;
210           //          return false;
211           //      });
212           //  }
213                 
214                 
215                 
216                 
217                 
218                 
219                 
220                 
221                 
222                  
223     
224     }
225     public class Xcls_notebook : Object
226     {
227         public Gtk.Notebook el;
228         private Xcls_WindowRooView  _this;
229
230
231             // my vars (def)
232
233         // ctor
234         public Xcls_notebook(Xcls_WindowRooView _owner )
235         {
236             _this = _owner;
237             _this.notebook = this;
238             this.el = new Gtk.Notebook();
239
240             // my vars (dec)
241
242             // set gobject values
243             var child_0 = new Xcls_label_preview( _this );
244             child_0.ref();
245             var child_1 = new Xcls_label_code( _this );
246             child_1.ref();
247             var child_2 = new Xcls_paned( _this );
248             child_2.ref();
249             this.el.append_page (  child_2.el , _this.label_preview.el );
250             var child_3 = new Xcls_ScrolledWindow14( _this );
251             child_3.ref();
252             this.el.append_page (  child_3.el , _this.label_code.el );
253         }
254
255         // user defined functions
256     }
257     public class Xcls_label_preview : Object
258     {
259         public Gtk.Label el;
260         private Xcls_WindowRooView  _this;
261
262
263             // my vars (def)
264
265         // ctor
266         public Xcls_label_preview(Xcls_WindowRooView _owner )
267         {
268             _this = _owner;
269             _this.label_preview = this;
270             this.el = new Gtk.Label( "Preview" );
271
272             // my vars (dec)
273
274             // set gobject values
275         }
276
277         // user defined functions
278     }
279
280     public class Xcls_label_code : Object
281     {
282         public Gtk.Label el;
283         private Xcls_WindowRooView  _this;
284
285
286             // my vars (def)
287
288         // ctor
289         public Xcls_label_code(Xcls_WindowRooView _owner )
290         {
291             _this = _owner;
292             _this.label_code = this;
293             this.el = new Gtk.Label( "Preview Generated Code" );
294
295             // my vars (dec)
296
297             // set gobject values
298         }
299
300         // user defined functions
301     }
302
303     public class Xcls_paned : Object
304     {
305         public Gtk.Paned el;
306         private Xcls_WindowRooView  _this;
307
308
309             // my vars (def)
310
311         // ctor
312         public Xcls_paned(Xcls_WindowRooView _owner )
313         {
314             _this = _owner;
315             _this.paned = this;
316             this.el = new Gtk.Paned( Gtk.Orientation.VERTICAL );
317
318             // my vars (dec)
319
320             // set gobject values
321             var child_0 = new Xcls_viewbox( _this );
322             child_0.ref();
323             this.el.pack1 (  child_0.el , true,true );
324             var child_1 = new Xcls_inspectorcontainer( _this );
325             child_1.ref();
326             this.el.pack2 (  child_1.el , true,true );
327         }
328
329         // user defined functions
330     }
331     public class Xcls_viewbox : Object
332     {
333         public Gtk.Box el;
334         private Xcls_WindowRooView  _this;
335
336
337             // my vars (def)
338
339         // ctor
340         public Xcls_viewbox(Xcls_WindowRooView _owner )
341         {
342             _this = _owner;
343             _this.viewbox = this;
344             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
345
346             // my vars (dec)
347
348             // set gobject values
349             this.el.homogeneous = false;
350             var child_0 = new Xcls_Box7( _this );
351             child_0.ref();
352             this.el.pack_start (  child_0.el , false,true,0 );
353             var child_1 = new Xcls_viewcontainer( _this );
354             child_1.ref();
355             this.el.pack_end (  child_1.el , true,true,0 );
356         }
357
358         // user defined functions
359     }
360     public class Xcls_Box7 : Object
361     {
362         public Gtk.Box el;
363         private Xcls_WindowRooView  _this;
364
365
366             // my vars (def)
367
368         // ctor
369         public Xcls_Box7(Xcls_WindowRooView _owner )
370         {
371             _this = _owner;
372             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
373
374             // my vars (dec)
375
376             // set gobject values
377             this.el.homogeneous = true;
378             this.el.height_request = 20;
379             this.el.vexpand = false;
380             var child_0 = new Xcls_Button8( _this );
381             child_0.ref();
382             this.el.pack_start (  child_0.el , false,false,0 );
383             var child_1 = new Xcls_AutoRedraw( _this );
384             child_1.ref();
385             this.el.pack_start (  child_1.el , false,false,0 );
386             var child_2 = new Xcls_Button10( _this );
387             child_2.ref();
388             this.el.pack_start (  child_2.el , false,false,0 );
389         }
390
391         // user defined functions
392     }
393     public class Xcls_Button8 : Object
394     {
395         public Gtk.Button el;
396         private Xcls_WindowRooView  _this;
397
398
399             // my vars (def)
400
401         // ctor
402         public Xcls_Button8(Xcls_WindowRooView _owner )
403         {
404             _this = _owner;
405             this.el = new Gtk.Button();
406
407             // my vars (dec)
408
409             // set gobject values
410             this.el.label = "Redraw";
411
412             //listeners
413             this.el.clicked.connect( ( ) => {
414                 _this.view.renderJS(  true);
415             });
416         }
417
418         // user defined functions
419     }
420
421     public class Xcls_AutoRedraw : Object
422     {
423         public Gtk.CheckButton el;
424         private Xcls_WindowRooView  _this;
425
426
427             // my vars (def)
428
429         // ctor
430         public Xcls_AutoRedraw(Xcls_WindowRooView _owner )
431         {
432             _this = _owner;
433             _this.AutoRedraw = this;
434             this.el = new Gtk.CheckButton();
435
436             // my vars (dec)
437
438             // set gobject values
439             this.el.active = true;
440             this.el.label = "Auto Redraw On";
441
442             //listeners
443             this.el.toggled.connect( (state) => {
444                 this.el.set_label(this.el.active  ? "Auto Redraw On" : "Auto Redraw Off");
445             });
446         }
447
448         // user defined functions
449     }
450
451     public class Xcls_Button10 : Object
452     {
453         public Gtk.Button el;
454         private Xcls_WindowRooView  _this;
455
456
457             // my vars (def)
458
459         // ctor
460         public Xcls_Button10(Xcls_WindowRooView _owner )
461         {
462             _this = _owner;
463             this.el = new Gtk.Button();
464
465             // my vars (dec)
466
467             // set gobject values
468             this.el.label = "Full Redraw";
469
470             //listeners
471             this.el.clicked.connect( () => {
472               _this.view.redraws = 99;
473                 _this.view.el.web_context.clear_cache();  
474               //_this.view.renderJS(true);
475               FakeServerCache.clear();
476               _this.view.reInit();
477             
478             });
479         }
480
481         // user defined functions
482     }
483
484
485     public class Xcls_viewcontainer : Object
486     {
487         public Gtk.ScrolledWindow el;
488         private Xcls_WindowRooView  _this;
489
490
491             // my vars (def)
492
493         // ctor
494         public Xcls_viewcontainer(Xcls_WindowRooView _owner )
495         {
496             _this = _owner;
497             _this.viewcontainer = this;
498             this.el = new Gtk.ScrolledWindow( null, null );
499
500             // my vars (dec)
501
502             // set gobject values
503             this.el.shadow_type = Gtk.ShadowType.IN;
504             var child_0 = new Xcls_view( _this );
505             child_0.ref();
506             this.el.add (  child_0.el  );
507
508             // init method
509
510             this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
511         }
512
513         // user defined functions
514     }
515     public class Xcls_view : Object
516     {
517         public WebKit.WebView el;
518         private Xcls_WindowRooView  _this;
519
520
521             // my vars (def)
522         public string renderedData;
523         public bool refreshRequired;
524         public WebKit.WebInspector inspector;
525         public string runjs;
526         public int redraws;
527         public GLib.DateTime lastRedraw;
528         public string runhtml;
529         public bool pendingRedraw;
530
531         // ctor
532         public Xcls_view(Xcls_WindowRooView _owner )
533         {
534             _this = _owner;
535             _this.view = this;
536             this.el = new WebKit.WebView();
537
538             // my vars (dec)
539             this.renderedData = "";
540             this.refreshRequired = false;
541             this.runjs = "";
542             this.redraws = 0;
543             this.lastRedraw = null;
544             this.runhtml = "";
545             this.pendingRedraw = false;
546
547             // set gobject values
548
549             // init method
550
551             {
552                 // this may not work!?
553                 var settings =  this.el.get_settings();
554                 settings.enable_developer_extras = true;
555                 
556                 
557                 var fs= new FakeServer(this.el);
558                 fs.ref();
559                 // this was an attempt to change the url perms.. did not work..
560                 // settings.enable_file_access_from_file_uris = true;
561                 // settings.enable_offline_web_application_cache - true;
562                 // settings.enable_universal_access_from_file_uris = true;
563                
564                  
565                 
566                 
567                 
568             
569                  // FIXME - base url of script..
570                  // we need it so some of the database features work.
571                 this.el.load_html( "Render not ready" , 
572                         //fixme - should be a config option!
573                         // or should we catch stuff and fix it up..
574                         "http://localhost/app.Builder/"
575                 );
576                     
577                     
578                //this.el.open('file:///' + __script_path__ + '/../builder.html');
579                 /*
580                 Gtk.drag_dest_set
581                 (
582                         this.el,              //
583                         Gtk.DestDefaults.MOTION  | Gtk.DestDefaults.HIGHLIGHT,
584                         null,            // list of targets
585                         Gdk.DragAction.COPY         // what to do with data after dropped 
586                 );
587                                         
588                // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
589                 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
590                 */
591                 GLib.Timeout.add_seconds(1,  ()  =>{
592                      //print("run refresh?");
593                      if (this.el == null) {
594                         return false;
595                      }
596                      this.runRefresh(); 
597                      return true;
598                  });
599                 
600                 
601             }
602
603             //listeners
604             this.el.script_dialog.connect( (dialog) => {
605                 
606                 
607                 if (this.el == null) {
608                     return true;
609                 }
610                 
611                  var msg = dialog.get_message();
612                  if (msg.length < 4) {
613                     return false;
614                  }
615                  if (msg.substring(0,4) != "IPC:") {
616                      return false;
617                  }
618                  var ar = msg.split(":", 3);
619                 if (ar.length < 3) {
620                     return false;
621                 }
622             
623                 switch(ar[1]) {
624                     case "SAVEHTML":
625                         print("GOT saveHTML %d?\n", ar[2].length);
626                         _this.file.saveHTML(ar[2]);
627                         return true;
628                     default:
629                         return false;
630                 }
631                 
632             });
633             this.el.show.connect( ( ) => {
634                 this.initInspector();;
635             });
636             this.el.drag_drop.connect( ( ctx, x, y,time, ud) => {
637                 return false;
638                 /*
639                 print("TARGET: drag-drop");
640                     var is_valid_drop_site = true;
641                     
642                      
643                     Gtk.drag_get_data
644                     (
645                             w,         // will receive 'drag-data-received' signal 
646                             ctx,        /* represents the current state of the DnD 
647                             this.get('/Window').atoms["STRING"],    /* the target type we want 
648                             time            /* time stamp 
649                     );
650                                     
651                                     
652                                     /* No target offered by source => error 
653                                    
654             
655                 return  is_valid_drop_site;
656                 */
657             });
658             this.el.load_changed.connect( (le) => {
659                 if (le != WebKit.LoadEvent.FINISHED) {
660                     return;
661                 }
662                 if (this.runjs.length < 1) {
663                     return;
664                 }
665               //  this.el.run_javascript(this.runjs, null);
666                  FakeServerCache.remove(    this.runjs);
667                 this.runjs = "";
668             });
669         }
670
671         // user defined functions
672         public void reInit () {
673            print("reInit?");
674                  // if this happens destroy the webkit..
675                  // recreate it..
676              this.el.stop_loading();
677                  
678              if (_this.viewbox.el.get_parent() == null) {
679                 return;
680              }
681                  
682                  
683             _this.viewbox.el.remove(_this.viewcontainer.el);
684             _this.paned.el.remove(_this.inspectorcontainer.el);        
685                  
686                  // destory seems to cause problems.
687                  //this.el.destroy();
688                 //_this.viewcontainer.el.destroy();
689                  //_this.inspectorcontainer.el.destroy();
690              var  inv =new Xcls_inspectorcontainer(_this);
691               inv.ref();
692               _this.paned.el.pack2(inv.el,true,true);
693               
694               
695              this.el = null;         
696              var nv =new Xcls_viewcontainer(_this);
697              nv.ref();
698              _this.viewbox.el.pack_end(nv.el,true,true,0);
699                  
700                  
701              inv.el.show_all();
702              nv.el.show_all();
703                  //while(Gtk.events_pending ()) Gtk.main_iteration ();
704                  //_this.view.renderJS(true); 
705              _this.view.refreshRequired  = true;
706         }
707         public void runRefresh () 
708         {
709             // this is run every 2 seconds from the init..
710         
711           
712             
713             if (!this.refreshRequired) {
714                // print("no refresh required");
715                 return;
716             }
717         
718             if (this.lastRedraw != null) {
719                // do not redraw if last redraw was less that 5 seconds ago.
720                if ((int64)(new DateTime.now_local()).difference(this.lastRedraw) < 5000 ) {
721                     return;
722                 }
723             }
724             
725             if (_this.file == null) {
726                 return;
727             }
728             
729             
730              this.refreshRequired = false;
731            //  print("HTML RENDERING");
732              
733              
734              //this.get('/BottomPane').el.show();
735              //this.get('/BottomPane').el.set_current_page(2);// webkit inspector
736             _this.file.webkit_page_id  = this.el.get_page_id();
737             
738             var js = _this.file.toSourcePreview();
739         
740             if (js.length < 1) {
741                 print("no data");
742                 return;
743             }
744         //    var  data = js[0];
745             this.redraws++;
746           
747             var project = _this.file.project;  
748         
749              //print (project.fn);
750              // set it to non-empty.
751              
752         //     runhtml = runhtml.length ?  runhtml : '<script type="text/javascript"></script>'; 
753         
754         
755         //   this.runhtml  = this.runhtml || '';
756          
757          
758             // then we need to reload the browser using
759             // load_html_string..
760         
761             // then trigger a redraw once it's loaded..
762             this.pendingRedraw = true;
763         
764             var runhtml = "<script type=\"text/javascript\">\n" ;
765             string builderhtml;
766             
767             try {
768                 GLib.FileUtils.get_contents(BuilderApplication.configDirectory() + "/resources/roo.builder.js", out builderhtml);
769             } catch (Error e) {
770                 builderhtml = "";
771             }
772         
773             runhtml += builderhtml + "\n";
774             runhtml += "</script>\n" ;
775         
776             // fix to make sure they are the same..
777             this.runhtml = project.runhtml;
778             // need to modify paths
779         
780             string inhtml;
781             var base_template = _this.file.project.base_template;
782             
783             if (base_template.length > 0 && !FileUtils.test(
784                 BuilderApplication.configDirectory() + "/resources/" +  base_template, FileTest.EXISTS)  
785                 ) {
786                    print("invalid base_template name - using default:  %s\n", base_template);
787                    base_template = "";
788             
789             }
790             try {
791                 GLib.FileUtils.get_contents(
792                     BuilderApplication.configDirectory() + "/resources/" + 
793                         (base_template.length > 0 ? base_template :  "roo.builder.html")
794                         , out inhtml);
795             
796             } catch (Error e) {
797                 inhtml = "";
798             }    
799             this.renderedData = js;
800         
801         
802             string js_src = js + "\n" +
803                 "Roo.onReady(function() {\n" +
804                 "if (" + _this.file.name +".show) " +  _this.file.name +".show({});\n" +
805                 "Roo.XComponent.build();\n" +
806                 "});\n";
807                 
808            // print("render js: " + js);
809             //if (!this.ready) {
810           //      console.log('not loaded yet');
811             //}
812             this.lastRedraw = new DateTime.now_local();
813         
814         
815             //this.runjs = js_src;
816             var fc =    FakeServerCache.factory_with_data(js_src);
817             this.runjs = fc.fname;
818             
819                 var html = inhtml.replace("</head>", runhtml + this.runhtml + 
820                     "<script type=\"text/javascript\" src=\"xhttp://localhost" + fc.fname + "\"></script>" +   
821                       //  "<script type=\"text/javascript\">\n" +
822                       //  js_src + "\n" + 
823                       //  "</script>" + 
824                                 
825                 "</head>");
826                 //print("LOAD HTML " + html);
827                 
828                  var rootURL = _this.file.project.rootURL;
829            
830                 
831                 
832                 this.el.load_html( html , 
833                     //fixme - should be a config option!
834                     (rootURL.length > 0 ? rootURL : "xhttp://localhost/roobuilder/")
835                 );
836                 
837             // force the inspector...        
838                //   this.initInspector();
839                 
840                 // - no need for this, the builder javascript will call it when build is complete
841                 //GLib.Timeout.add_seconds(1, () => {
842                 //    this.el.run_javascript("Builder.saveHTML()",null);
843                 //    return false;
844                 //});
845         //     print( "before render" +    this.lastRedraw);
846         //    print( "after render" +    (new Date()));
847             
848         }
849         public void initInspector () {
850             
851            /* if (this.inspector == this.el.get_inspector()) {
852                 this.inspector.show();
853                 this.inspector.open_window();        
854                 print("init inspecter called, and inspector is the same as existing\n");
855                 return;
856             }
857             print("new inspector?\n");
858         */
859             this.inspector = this.el.get_inspector();
860             this.inspector.ref();
861             
862             // got a new inspector...
863                 
864             this.inspector.open_window.connect(() => {
865                  this.inspector = this.el.get_inspector();
866                 print("inspector attach\n");
867                 var wv = this.inspector.get_web_view();
868                 if (wv != null) {
869                     print("got inspector web view\n");
870                     
871                     var cn = _this.inspectorcontainer.el.get_child();
872                     if (cn != null) {
873                          _this.inspectorcontainer.el.remove(cn);
874                      }
875                     
876                     _this.inspectorcontainer.el.add(wv);
877                     wv.show();
878                 } else {
879                     //this.inspector.close();
880                     
881                     //this.inspector = null;
882                    
883          
884                 }
885                 return true;
886                
887             });
888             /*
889             this.inspector.closed.connect(() => {
890                  print("inspector closed?!?");
891                  // if this happens destroy the webkit..
892                  // recreate it..
893                  this.el.stop_loading();
894                  
895                  if (_this.viewbox.el.get_parent() == null) {
896                     return;
897                  }
898                  
899                  
900                 _this.viewbox.el.remove(_this.viewcontainer.el);
901                 _this.el.remove(_this.inspectorcontainer.el);        
902                  
903                  // destory seems to cause problems.
904                  //this.el.destroy();
905                 //_this.viewcontainer.el.destroy();
906                  //_this.inspectorcontainer.el.destroy();
907         
908                  this.el = null;         
909                  var nv =new Xcls_viewcontainer(_this);
910                  nv.ref();
911                  _this.viewbox.el.pack_end(nv.el,true,true,0);
912                  
913                   var  inv =new Xcls_inspectorcontainer(_this);
914                   inv.ref();
915                   _this.el.pack2(inv.el,true,true);
916                  
917                  inv.el.show_all();
918                  nv.el.show_all();
919                  //while(Gtk.events_pending ()) Gtk.main_iteration ();
920                  //_this.view.renderJS(true); 
921                  _this.view.refreshRequired  = true;
922                
923             }); 
924             */
925             
926             this.inspector.show();
927         }
928         public void renderJS (bool force) {
929         
930             // this is the public redraw call..
931             // we refresh in a loop privately..
932             var autodraw = _this.AutoRedraw.el.active;
933             if (!autodraw && !force) {
934                 print("Skipping redraw - no force, and autodraw off");
935                 return;
936             }
937              
938             this.refreshRequired  = true;
939         }
940     }
941
942
943
944     public class Xcls_inspectorcontainer : Object
945     {
946         public Gtk.ScrolledWindow el;
947         private Xcls_WindowRooView  _this;
948
949
950             // my vars (def)
951
952         // ctor
953         public Xcls_inspectorcontainer(Xcls_WindowRooView _owner )
954         {
955             _this = _owner;
956             _this.inspectorcontainer = this;
957             this.el = new Gtk.ScrolledWindow( null, null );
958
959             // my vars (dec)
960
961             // set gobject values
962             this.el.shadow_type = Gtk.ShadowType.IN;
963
964             // init method
965
966             this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
967         }
968
969         // user defined functions
970     }
971
972
973     public class Xcls_ScrolledWindow14 : Object
974     {
975         public Gtk.ScrolledWindow el;
976         private Xcls_WindowRooView  _this;
977
978
979             // my vars (def)
980
981         // ctor
982         public Xcls_ScrolledWindow14(Xcls_WindowRooView _owner )
983         {
984             _this = _owner;
985             this.el = new Gtk.ScrolledWindow( null, null );
986
987             // my vars (dec)
988
989             // set gobject values
990             var child_0 = new Xcls_sourceview( _this );
991             child_0.ref();
992             this.el.add (  child_0.el  );
993         }
994
995         // user defined functions
996     }
997     public class Xcls_sourceview : Object
998     {
999         public Gtk.SourceView el;
1000         private Xcls_WindowRooView  _this;
1001
1002
1003             // my vars (def)
1004         public bool loading;
1005         public bool button_is_pressed;
1006         public string prop_selected;
1007         public bool key_is_pressed;
1008         public JsRender.Node? node_selected;
1009         public int editable_start_pos;
1010
1011         // ctor
1012         public Xcls_sourceview(Xcls_WindowRooView _owner )
1013         {
1014             _this = _owner;
1015             _this.sourceview = this;
1016             this.el = new Gtk.SourceView();
1017
1018             // my vars (dec)
1019             this.loading = true;
1020             this.button_is_pressed = false;
1021             this.prop_selected = "";
1022             this.key_is_pressed = false;
1023             this.node_selected = null;
1024             this.editable_start_pos = -1;
1025
1026             // set gobject values
1027             this.el.editable = false;
1028             this.el.show_line_marks = true;
1029             this.el.show_line_numbers = true;
1030             var child_0 = new Xcls_buffer( _this );
1031             child_0.ref();
1032             this.el.set_buffer (  child_0.el  );
1033
1034             // init method
1035
1036             {
1037                
1038                 var description =   Pango.FontDescription.from_string("monospace");
1039                 description.set_size(8000);
1040                 this.el.override_font(description);
1041             
1042                 this.loading = true;
1043                 //var buf = this.el.get_buffer();
1044                 //buf.notify.connect(this.onCursorChanged);
1045               
1046               
1047               
1048                 var attrs = new Gtk.SourceMarkAttributes();
1049                 var  pink =   Gdk.RGBA();
1050                 pink.parse ( "pink");
1051                 attrs.set_background ( pink);
1052                 attrs.set_icon_name ( "process-stop");    
1053                 attrs.query_tooltip_text.connect(( mark) => {
1054                     //print("tooltip query? %s\n", mark.name);
1055                     return mark.name;
1056                 });
1057                 
1058                 this.el.set_mark_attributes ("ERR", attrs, 1);
1059                 
1060                  var wattrs = new Gtk.SourceMarkAttributes();
1061                 var  blue =   Gdk.RGBA();
1062                 blue.parse ( "#ABF4EB");
1063                 wattrs.set_background ( blue);
1064                 wattrs.set_icon_name ( "process-stop");    
1065                 wattrs.query_tooltip_text.connect(( mark) => {
1066                     //print("tooltip query? %s\n", mark.name);
1067                     return mark.name;
1068                 });
1069                 
1070                 this.el.set_mark_attributes ("WARN", wattrs, 1);
1071                 
1072              
1073                 
1074                  var dattrs = new Gtk.SourceMarkAttributes();
1075                 var  purple =   Gdk.RGBA();
1076                 purple.parse ( "#EEA9FF");
1077                 dattrs.set_background ( purple);
1078                 dattrs.set_icon_name ( "process-stop");    
1079                 dattrs.query_tooltip_text.connect(( mark) => {
1080                     //print("tooltip query? %s\n", mark.name);
1081                     return mark.name;
1082                 });
1083                 
1084                 this.el.set_mark_attributes ("DEPR", dattrs, 1);
1085                 
1086                 
1087                 var gattrs = new Gtk.SourceMarkAttributes();
1088                 var  grey =   Gdk.RGBA();
1089                 grey.parse ( "#ccc");
1090                 gattrs.set_background ( grey);
1091              
1092                 
1093                 this.el.set_mark_attributes ("grey", gattrs, 1);
1094                 
1095                 
1096                 
1097                 
1098                 
1099                 
1100             }
1101
1102             //listeners
1103             this.el.button_release_event.connect( () => {
1104             
1105                 print("BUTTON RELEASE EVENT\n");
1106                 this.onCursorChanged();
1107                 this.button_is_pressed = false;
1108                 return false;
1109             });
1110             this.el.button_press_event.connect( () => {
1111                 
1112                 
1113                 
1114                 
1115                 this.button_is_pressed = true;
1116                 return false;
1117             });
1118             this.el.key_press_event.connect( (src, key) => {
1119                 this.key_is_pressed = true;
1120                 // is it ctrl-G -- find next?
1121                 // which will will still ignore..
1122                  
1123                 if      (key.str == "g" && key.state == Gdk.ModifierType.CONTROL_MASK) {
1124                         this.key_is_pressed = false;
1125                 }
1126                 
1127                 // if cursor postion is 'at start' of editing range, 
1128                 // and backspace is pressed...
1129                 // block it..
1130                 
1131                  var buf = this.el.get_buffer();
1132                 //print("cursor changed : %d\n", buf.cursor_position);
1133                    
1134                 if (buf.cursor_position <= this.editable_start_pos && key.keyval == Gdk.Key.BackSpace) {
1135                         return true; // block...
1136                 }
1137                 // what about 'last line of 'grey...'
1138                 // get the buffer - find the line, find the next line ?? see if it's grey?
1139                 
1140                 
1141                 print("KEY PRESS EVENT \n");
1142                 this.onCursorChanged();
1143                 return false; 
1144             });
1145             this.el.key_release_event.connect( () => { 
1146                 this.key_is_pressed = false;
1147                 return false;
1148             });
1149         }
1150
1151         // user defined functions
1152         public void onCursorChanged (/*ParamSpec ps*/) {
1153         
1154                         if (!this.key_is_pressed && !this.button_is_pressed) {
1155                                 return;
1156                         }
1157         
1158                    if (this.loading) {
1159                     return;
1160                 }
1161                // if (ps.name != "cursor-position") {
1162                //     return;
1163                // }
1164         
1165                 var buf = this.el.get_buffer();
1166                 //print("cursor changed : %d\n", buf.cursor_position);
1167                 Gtk.TextIter cpos;
1168                 buf.get_iter_at_offset(out cpos, buf.cursor_position);
1169                 
1170                 var ln = cpos.get_line();
1171                 
1172                 
1173                 // --- select node at line....
1174                 
1175                 var node = _this.file.lineToNode(ln+1);
1176          
1177                 if (node == null) {
1178                     print("can not find node\n");
1179                     return;
1180                 }
1181                 var prop = node.lineToProp(ln+1);
1182                 print("prop : %s", prop == null ? "???" : prop);
1183                 
1184                 
1185                 // ---------- this selects the tree's node...
1186                 
1187                 var ltree = _this.main_window.windowstate.left_tree;
1188                 var tp = ltree.model.treePathFromNode(node);
1189                 print("got tree path %s\n", tp);
1190                 if (tp != "") {
1191                          
1192                        
1193                         //print("changing cursor on tree..\n");
1194                        
1195          
1196                     
1197                     // let's try allowing editing on the methods.
1198                     // a little klunky at present..
1199                     this.prop_selected = "";
1200                     if (prop != null) {
1201                                 //see if we can find it..
1202                                 var kv = prop.split(":");
1203                                 if (kv[0] == "p") {
1204                                 
1205                                         //var k = prop.get_key(kv[1]);
1206                                         // fixme -- need to determine if it's an editable property...
1207                                         this.prop_selected = prop;
1208                                         
1209                                 } else if (kv[0] == "l") {
1210                                          this.prop_selected = prop;
1211                                         
1212                                 }
1213                     }
1214                     ltree.view.setCursor(tp, "editor");
1215                    // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); 
1216                    this.nodeSelected(node,false);
1217                     
1218                     // scrolling is disabled... as node selection calls scroll 10ms after it changes.
1219                      
1220                 }
1221                 
1222                 // highlight the node..
1223         }
1224         public void clearGreySelection () {
1225          // clear all the marks..
1226             var sbuf = (Gtk.SourceBuffer)this.el.buffer;
1227             
1228             Gtk.TextIter start;
1229             Gtk.TextIter end;     
1230                 
1231             sbuf.get_bounds (out start, out end);
1232             sbuf.remove_source_marks (start, end, "grey");
1233             
1234             
1235         }
1236         public void nodeSelected (JsRender.Node? sel, bool scroll ) {
1237           
1238             
1239                 
1240             // this is connected in widnowstate
1241         
1242         
1243                 // not sure why....   
1244             while(Gtk.events_pending()) {
1245                 Gtk.main_iteration();
1246             }
1247             
1248             this.node_selected = sel;
1249             
1250             this.updateGreySelection(scroll);
1251             
1252             
1253             
1254         }
1255         public string toString () {
1256            Gtk.TextIter s;
1257             Gtk.TextIter e;
1258             this.el.get_buffer().get_start_iter(out s);
1259             this.el.get_buffer().get_end_iter(out e);
1260             var ret = this.el.get_buffer().get_text(s,e,true);
1261             //print("TO STRING? " + ret);
1262             return ret;
1263         }
1264         public void loadFile ( ) {
1265             this.loading = true;
1266             
1267             
1268             // get the cursor and scroll position....
1269             var buf = this.el.get_buffer();
1270                 var cpos = buf.cursor_position;
1271             
1272            print("BEFORE LOAD cursor = %d\n", cpos);
1273            
1274             var vadj_pos = this.el.get_vadjustment().get_value();
1275            
1276             
1277          
1278             buf.set_text("",0);
1279             var sbuf = (Gtk.SourceBuffer) buf;
1280         
1281             
1282         
1283             if (_this.file == null || _this.file.xtype != "Roo") {
1284                 print("xtype != Roo");
1285                 this.loading = false;
1286                 return;
1287             }
1288             
1289             // get the string from the rendered tree...
1290              
1291              var str = _this.file.toSource();
1292              
1293         //    print("setting str %d\n", str.length);
1294             buf.set_text(str, str.length);
1295             var lm = Gtk.SourceLanguageManager.get_default();
1296              
1297             //?? is javascript going to work as js?
1298             
1299             ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));
1300           
1301             
1302             Gtk.TextIter start;
1303             Gtk.TextIter end;     
1304                 
1305             sbuf.get_bounds (out start, out end);
1306             sbuf.remove_source_marks (start, end, null); // remove all marks..
1307             
1308              GLib.Timeout.add(500, () => {
1309         
1310                 print("RESORTING cursor to = %d\n", cpos);
1311                         Gtk.TextIter cpos_iter;
1312                         buf.get_iter_at_offset(out cpos_iter, cpos);
1313                         buf.place_cursor(cpos_iter); 
1314                         
1315                         this.el.get_vadjustment().set_value(vadj_pos);;
1316                         
1317         
1318                         this.onCursorChanged();
1319                         
1320                         
1321                         _this.buffer.checkSyntax();
1322                         return false;
1323                 });
1324                         
1325             this.loading = false; 
1326             _this.buffer.dirty = false;
1327         }
1328         public void updateGreySelection (bool scroll) { 
1329                 var sel = this.node_selected;
1330                 print("node selected\n");
1331             var buf = this.el.get_buffer();
1332             var sbuf = (Gtk.SourceBuffer) buf;
1333         
1334            
1335            this.clearGreySelection();
1336            
1337            
1338            
1339              if (sel == null) {
1340                      print("no selected node\n");
1341                 // no highlighting..
1342                 return;
1343             }
1344             
1345             print("highlight region %d to %d\n", sel.line_start,sel.line_end);
1346             Gtk.TextIter iter;   
1347             sbuf.get_iter_at_line(out iter,  sel.line_start);
1348             
1349             
1350             Gtk.TextIter cur_iter;
1351             sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);
1352            
1353             var cursor_at_line = cur_iter.get_line();
1354             
1355             
1356             //var cur_line = cur_iter.get_line();
1357             //if (cur_line > sel.line_start && cur_line < sel.line_end) {
1358             
1359             //} else {
1360             if (scroll) {
1361                         print("scrolling to node -- should occur on node picking.\n");
1362                 this.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.5f);
1363                 }
1364             
1365             var start_line = sel.line_start;
1366             var end_line = sel.line_end;
1367             
1368             
1369             this.el.editable = false;
1370             
1371             //var colon_pos = 0;
1372             
1373             this.editable_start_pos = -1;
1374             
1375             // now if we have selected a property...
1376             if (this.prop_selected.length> 0 ) {
1377         
1378                         int nstart, nend;
1379                         if (sel.getPropertyRange(this.prop_selected, out nstart, out nend) && nend > nstart) {
1380                                 start_line = nstart;
1381                                 end_line = nend;
1382                                 this.el.editable = true;
1383                                 print("start line = %d, end line = %d\n", start_line, end_line);
1384                                 
1385                                         // see if we are 'right of ':'
1386                                         // get an iter for the start of the line.
1387                                 Gtk.TextIter start_first_line_iter,end_first_line_iter;
1388                                 this.el.buffer.get_iter_at_line(out start_first_line_iter, start_line -1);
1389                                 this.el.buffer.get_iter_at_line(out end_first_line_iter, start_line -1);
1390                                  
1391                                 
1392                                 
1393                                 
1394                                 if (end_first_line_iter.forward_to_line_end()) {
1395                                         var first_line  = this.el.buffer.get_text(start_first_line_iter, end_first_line_iter, false);
1396                                         
1397                                         print("first line = %s\n", first_line);
1398                                         if (first_line.contains(":")) {
1399                                                 this.editable_start_pos = start_first_line_iter.get_offset() + first_line.index_of(":") + 1;
1400                                                 print("colon_pos  = %d\n", this.editable_start_pos);
1401                                         }
1402                                         
1403         
1404                                         //Gtk.TextIter colon_iter;
1405                                         //sbuf.get_iter_at_offset (out colon_iter, colon_pos);
1406                                         //sbuf.create_source_mark(null, "active_text", colon_iter);
1407                                 }
1408                                 
1409                                 
1410                                 
1411                                 //print("is cursor at line? %d ?= %d\n", start_line -1 , cursor_at_line);
1412                                 //if (start_line - 1 == cursor_at_line) {
1413                                 // should be ok - current_posssion can not be less than '-1'...
1414                                 if (sbuf.cursor_position < this.editable_start_pos) {
1415                                 
1416                                         print("cursor is before start pos.. - turn off editable...\n");
1417                                         //var before_cursor_string = this.el.buffer.get_text(start_line_iter, cur_iter, false);
1418                                         //print("before cursor string =  %s\n", before_cursor_string);
1419                                         //if (!before_cursor_string.contains(":")) {
1420                                                 this.el.editable = false;
1421                                         //}
1422                                         
1423                                 }
1424                                  
1425                                  
1426         
1427                                  
1428                         }
1429                         print("propSelected = %s range  %d -> %d\n", this.prop_selected, start_line, end_line);         
1430                         
1431                         
1432             }
1433             
1434                 print("checking selection\n");
1435             
1436             
1437             // check selection - if it's out of 'bounds'
1438             if (this.el.editable && sbuf.get_has_selection()) {
1439                         Gtk.TextIter sel_start_iter, sel_end_iter;
1440                         sbuf.get_selection_bounds(out sel_start_iter, out sel_end_iter);
1441                         
1442                         if (sel_start_iter.get_line() < start_line || sel_end_iter.get_line() > end_line ||
1443                                 sel_start_iter.get_line() > end_line   || sel_end_iter.get_line() < start_line                  ) {
1444                                 // save?
1445                                 this.el.editable = false;
1446                         }
1447                         if (this.editable_start_pos > 0 &&
1448                                 (sel_start_iter.get_offset() < this.editable_start_pos || sel_end_iter.get_offset() < this.editable_start_pos)
1449                                 
1450                         ) {
1451                                 this.el.editable = false;
1452                         }
1453                         
1454                          
1455             
1456             }
1457             
1458             
1459             
1460             
1461             for (var i = 0; i < buf.get_line_count();i++) {
1462                 if (i < (start_line -1) || i > (end_line -1)) {
1463                    
1464                     sbuf.get_iter_at_line(out iter, i);
1465                     sbuf.create_source_mark(null, "grey", iter);
1466                     
1467                 }
1468             
1469             }
1470             if (scroll && (cursor_at_line > end_line || cursor_at_line < start_line)) {
1471                     Gtk.TextIter cpos_iter;
1472                         buf.get_iter_at_line(out cpos_iter, start_line);
1473                         
1474                         buf.place_cursor(cpos_iter); 
1475                 }
1476         
1477         
1478         }
1479         public void highlightErrorsJson (string type, Json.Object obj) {
1480                // this is a hook for the vala code - it has no value in javascript 
1481                // as we only have one error ususally....
1482                 return  ;
1483             
1484          
1485         
1486         
1487         }
1488     }
1489     public class Xcls_buffer : Object
1490     {
1491         public Gtk.SourceBuffer el;
1492         private Xcls_WindowRooView  _this;
1493
1494
1495             // my vars (def)
1496         public bool dirty;
1497         public int error_line;
1498
1499         // ctor
1500         public Xcls_buffer(Xcls_WindowRooView _owner )
1501         {
1502             _this = _owner;
1503             _this.buffer = this;
1504             this.el = new Gtk.SourceBuffer( null );
1505
1506             // my vars (dec)
1507             this.dirty = false;
1508             this.error_line = -1;
1509
1510             // set gobject values
1511
1512             //listeners
1513             this.el.changed.connect( () => {
1514              
1515             
1516                 // check syntax??
1517                 // ??needed..??
1518                // _this.save_button.el.sensitive = true;
1519                 ///?? has changed occured during loading?
1520                 
1521                 // only trigger this if 
1522                 
1523                 
1524                 
1525                 
1526                 if (_this.sourceview.loading) {
1527                         return;
1528                 }
1529                 
1530             
1531                 
1532                 print("- PREVIEW EDITOR CHANGED--");
1533             
1534                 this.dirty = true;  
1535                 this.checkSyntax(); // this calls backs and highlights errors.. in theory...  
1536             
1537             
1538             
1539                 if (!_this.sourceview.button_is_pressed && !_this.sourceview.key_is_pressed) {
1540                         print("button or key not pressed to generate change?!\n");
1541                         return;
1542                 }
1543                         
1544                 
1545                 // what are we editing??
1546                 if (null == _this.sourceview.node_selected || _this.sourceview.prop_selected.length  < 1) {
1547                         return;
1548                 }
1549                 
1550                 // find the colon on the first line...
1551                 
1552                 if (_this.sourceview.editable_start_pos > -1) {
1553                         
1554                         var buf = (Gtk.SourceBuffer)_this.sourceview.el.get_buffer();
1555                         
1556                     //print("cursor changed : %d\n", buf.cursor_position);
1557                     Gtk.TextIter spos,epos;
1558                     buf.get_iter_at_offset(out spos, _this.sourceview.editable_start_pos);
1559                     buf.get_iter_at_offset(out epos, _this.sourceview.editable_start_pos); // initialize epos..
1560                     
1561                     var gotit= false;
1562                     var line = spos.get_line();
1563                     var endline = buf.get_line_count();
1564                     while (line < endline) {
1565                                 line++;
1566                         buf.get_iter_at_line(out epos, line);
1567                         if (buf.get_source_marks_at_line(line, "grey").length() > 0) {
1568                                 buf.get_iter_at_line(out epos, line);                   
1569                                 gotit=true;
1570                                 break;
1571                                 }
1572                         }
1573                     
1574                         if (gotit) {
1575                                 print("End Offset = %d/%d\n", epos.get_line(), epos.get_offset());
1576                                 // get the pos...
1577                                 // in theory the last char will be '}' or '},' .. or ','
1578                                 // we should chop the ',' of the end...
1579                                 var str = buf.get_text(spos, epos, false);
1580                                 print("got string\n%s\n", str);
1581                         
1582                         }
1583                 }
1584                 return ;
1585             });
1586         }
1587
1588         // user defined functions
1589         public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
1590                  
1591             this.error_line = validate_res.size;
1592                 
1593             if (this.error_line < 1) {
1594                   return true;
1595             }
1596             var tlines = this.el.get_line_count ();
1597             Gtk.TextIter iter;
1598             var valiter = validate_res.map_iterator();
1599             while (valiter.next()) {
1600             
1601         //        print("get inter\n");
1602                 var eline = valiter.get_key();
1603                 if (eline > tlines) {
1604                     continue;
1605                 }
1606                 this.el.get_iter_at_line( out iter, eline);
1607                 //print("mark line\n");
1608                 this.el.create_source_mark(valiter.get_value(), "ERR", iter);
1609             }   
1610             return false;
1611         }
1612         public   string toString () {
1613             
1614             Gtk.TextIter s;
1615             Gtk.TextIter e;
1616             this.el.get_start_iter(out s);
1617             this.el.get_end_iter(out e);
1618             var ret = this.el.get_text(s,e,true);
1619             //print("TO STRING? " + ret);
1620             return ret;
1621         }
1622         public   bool checkSyntax () {
1623          
1624            
1625             var str = this.toString();
1626             
1627             // needed???
1628             if (this.error_line > 0) {
1629                  Gtk.TextIter start;
1630                  Gtk.TextIter end;     
1631                 this.el.get_bounds (out start, out end);
1632         
1633                 this.el.remove_source_marks (start, end, "WARN");
1634                 this.el.remove_source_marks (start, end, "ERR");        
1635         
1636             }
1637             
1638             if (str.length < 1) {
1639                 print("checkSyntax - empty string?\n");
1640                 return false;
1641             }
1642             
1643            if (_this.file == null) {
1644                return false;
1645            }
1646             var p = _this.file.project.palete;
1647             
1648          
1649             if (_this.file.language != "js") {
1650                         return false; // fake syntax error.
1651                 }
1652                 
1653             //Gee.HashMap<int,string> ret_x;
1654         
1655                 return p.javascriptHasErrors(
1656                         _this.main_window.windowstate,
1657                 str, 
1658                  "", // _this.key, 
1659                 "file", //_this.ptype,
1660                 _this.file, 
1661                 null
1662             );    
1663              
1664         }
1665     }
1666
1667
1668
1669
1670 }