a6638b88148f238d4c9cf7baa28a38cdcbd96245
[roobuilder] / src / Application.vala
1
2  
3         public class AppSettings : Object
4         {
5
6                 
7                 
8                 // what are we going to have as settings?
9                 public string roo_html_dir { get; set; }
10
11                 public AppSettings()
12                 {
13                         this.notify.connect(() => {
14                                 this.save();
15                         });
16                 }
17  
18                 public static AppSettings factory()
19                 {
20                          
21                         var setting_file = BuilderApplication.configDirectory() + "/builder.settings";
22                         
23                         if (!FileUtils.test(setting_file, FileTest.EXISTS)) {
24                                  return new AppSettings();
25                         }
26                         string data; 
27                         try { 
28                                 FileUtils.get_contents(setting_file, out data);
29                                 return Json.gobject_from_data (typeof (AppSettings), data) as AppSettings;
30                         } catch (Error e) {
31                         }
32                         return new AppSettings();
33                 }
34                 public void save()
35                 {
36                         var dirname = GLib.Environment.get_home_dir() + "/.Builder";
37                         var setting_file = dirname + "/builder.settings";
38                         string data = Json.gobject_to_data (this, null);
39                         GLib.debug("saving application settings\n");
40                         try {
41                                 FileUtils.set_contents(setting_file,   data);
42                         } catch (Error e) {
43                                 print("Error saving app settings");
44                         }
45                 }
46
47                 
48         }
49         
50         
51         public static BuilderApplication application = null;
52         
53         public class BuilderApplication : Gtk.Application
54         {
55                 
56                 // options - used when builder is run as a compiler
57                 // we have to spawn ourself as a compiler as just running libvala
58                 // as a task to check syntax causes memory leakage..
59                 // 
60                 const OptionEntry[] options = {
61                 
62                         
63                         { "project", 0, 0, OptionArg.STRING, ref opt_compile_project, "select a project", null },
64                         { "target", 0, 0, OptionArg.STRING, ref opt_compile_target, "Target to build", null },
65                         { "skip-linking", 0, 0, OptionArg.NONE, ref opt_skip_linking, "Do not link the files and make a binary - used to do syntax checking", null },
66                         { "skip-file", 0, 0, OptionArg.STRING, ref opt_compile_skip ,"For test compiles do not add this (usually used in conjunction with add-file ", null },
67                         { "add-file", 0, 0, OptionArg.STRING, ref opt_compile_add, "Add this file to compile list", null },
68                         { "output", 0, 0, OptionArg.STRING, ref opt_compile_output, "output binary file path", null },
69                         { "debug", 0, 0, OptionArg.NONE, ref opt_debug, "Show debug messages for non-ui, or crash on warnings for gdb ", null },
70                         { "pull-resources", 0, 0, OptionArg.NONE, ref opt_pull_resources, "Fetch the online resources", null },                 
71             
72             // some testing code.
73             { "list-projects", 0, 0,  OptionArg.NONE, ref opt_list_projects, "List Projects", null },
74             { "list-files", 0, 0,  OptionArg.NONE, ref  opt_list_files, "List Files (in a project", null},
75             { "bjs", 0, 0, OptionArg.STRING, ref opt_bjs_compile, "convert bjs file (use all to convert all of them and compare output)", null },
76             { "bjs-glade", 0, 0, OptionArg.NONE, ref opt_bjs_compile_glade, "output glade", null },
77             { "bjs-test-all", 0, 0, OptionArg.NONE, ref opt_bjs_test, "Test all the BJS files to see if the new parser/writer would change anything", null },            
78             { "bjs-target", 0, 0, OptionArg.STRING, ref opt_bjs_compile_target, "convert bjs file to tareet  : vala / js", null },
79             { "test", 0, 0, OptionArg.STRING, ref opt_test, "run a test use 'help' to list the available tests", null },
80             { "language-server", 0, 0, OptionArg.STRING, ref opt_language_server, "run language server on this file", null },
81             { "drop-list", 0, 0, OptionArg.STRING, ref opt_drop_list, "show droplist / children for a Gtk type (eg. Gtk.Widget)", null },
82             
83             
84                         { null }
85                 };
86                 public static string opt_compile_project;
87                 public static string opt_compile_target;
88                 public static string opt_compile_skip;
89                 public static string opt_compile_add;
90                 public static string opt_compile_output;
91                 public static string opt_bjs_compile;
92                 public static string opt_bjs_compile_target;
93                 public static string opt_test;  
94                 public static string opt_drop_list;
95                 public static string opt_language_server;
96         
97         public static bool opt_skip_linking = false;
98                 public static bool opt_debug = false;
99                 public static bool opt_list_projects = false;
100                 public static bool opt_list_files = false;
101                 public static bool opt_pull_resources = false;
102                 public static bool opt_bjs_compile_glade = false;
103         public static bool opt_bjs_test = false;                
104                 public static string _self;
105                 
106                 public enum Target {
107                     INT32,
108                     STRING,
109                     ROOTWIN
110                 }
111
112 /*
113                 public const Gtk.TargetEntry[] targetList = {
114                     { "INTEGER",    0, Target.INT32 },
115                     { "STRING",     0, Target.STRING },
116                     { "application/json",     0, Target.STRING },                       
117                     { "text/plain", 0, Target.STRING },
118                     { "application/x-rootwindow-drop", 0, Target.ROOTWIN }
119                 };
120                 */
121                 public AppSettings settings = null;
122
123
124
125                 //public static Palete.ValaCompileQueue valacompilequeue;
126
127         
128                 public BuilderApplication (  string[] args)
129                 {
130                         
131                         try {
132                                 _self = FileUtils.read_link("/proc/self/exe");
133                         } catch (Error e) {
134                                 // this should nto happen!!?
135                                 GLib.error("could not read /proc/self/exe");
136                         }
137                         GLib.debug("SELF = %s", _self);
138                         var f =  File.new_for_path(_self);
139                         var dt = "0000";
140                         try {
141                                 var fi = f.query_info("*",0);
142                                 dt = fi.get_creation_date_time().to_unix().to_string();
143                         } catch (GLib.Error e) {
144                                 // skip.
145                         }
146                         
147                         Object(
148                                 application_id: "org.roojs.%s.ver%s".printf( GLib.Path.get_basename(_self),dt),
149                                 flags: ApplicationFlags.FLAGS_NONE
150                         );
151                         BuilderApplication.windows = new        Gee.ArrayList<Xcls_MainWindow>();
152                         //BuilderApplication.valacompilequeue = new Palete.ValaCompileQueue();
153                         
154                         
155                         configDirectory();
156                         this.settings = AppSettings.factory();  
157                         var opt_context = new OptionContext ("Application Builder");
158                         
159                         try {
160                                 opt_context.set_help_enabled (true);
161                                 opt_context.add_main_entries (options, null);
162                                 opt_context.parse (ref args);
163                                  
164                                 
165                         } catch (OptionError e) {
166                                 stdout.printf ("error: %s\n", e.message);
167                                 stdout.printf ("Run '%s --help' to see a full list of available command line options.\n %s", 
168                                                          args[0], opt_context.get_help(true,null));
169                                 GLib.Process.exit(Posix.EXIT_FAILURE);
170                                  
171                         }
172                         this.initDebug();
173                         this.runTests();                        
174                         this.pullResources();
175                         
176                 Project.Project.loadAll();
177                         this.listProjects();
178                         var cur_project = this.compileProject();
179                         this.dropList(cur_project); // --drop-list
180                         this.languageServer(cur_project); // --language-server                  
181                         this.listFiles(cur_project);
182                         this.testBjs(cur_project);
183                         this.languageServer(cur_project);
184                         this.compileBjs(cur_project);
185                         //this.compileVala();
186
187                 }
188
189
190                 
191                 public static BuilderApplication  singleton(  string[]? args)
192                 {
193                         if (application==null && args != null) {
194                                 application = new BuilderApplication(  args);
195  
196                         
197                         }
198                         return application;
199                 }
200
201                 
202                 public static string configDirectory()
203                 {
204                         var dirname = GLib.Environment.get_home_dir() + "/.Builder";
205                 
206                         if (!FileUtils.test(dirname,FileTest.IS_DIR)) {
207                                 var dir = File.new_for_path(dirname);
208                                 try {
209                                         dir.make_directory();   
210                                 } catch (Error e) {
211                                         GLib.error("Failed to make directory %s", dirname);
212                                 } 
213                         }
214                         if (!FileUtils.test(dirname + "/resources",FileTest.IS_DIR)) {
215                                 var dir = File.new_for_path(dirname + "/resources");
216                                 try {
217                                         dir.make_directory();   
218                                 } catch (Error e) {
219                                         GLib.error("Failed to make directory %s", dirname + "/resources");
220                                 } 
221                         }
222
223                 
224                         return dirname;
225                 }
226                 
227                 
228                 // --------------- non static...
229                 
230                 void initDebug() 
231                 {
232                          
233                         
234                         if (BuilderApplication.opt_debug  || BuilderApplication.opt_compile_project == null) {
235                                 GLib.Log.set_default_handler( 
236                                 //      GLib.LogLevelFlags.LEVEL_DEBUG | GLib.LogLevelFlags.LEVEL_WARNING | GLib.LogLevelFlags.LEVEL_CRITICAL, 
237                                         (dom, lvl, msg) => {
238
239                                         print("%s: %s : %s\n", (new DateTime.now_local()).format("%H:%M:%S.%f"), lvl.to_string(), msg);
240                                         
241                                         if (dom== "GtkSourceView") { // seems to be some critical wanrings comming from gtksourceview related to insert?
242                                                 return;
243                                         }
244                                         //if (msg.contains("gdk_popup_present")) { // seems to be problems with the popup present on gtksourceview competion.
245                                         //      return;
246                                         //}
247                                         if (BuilderApplication.opt_debug && lvl ==  GLib.LogLevelFlags.LEVEL_CRITICAL) {
248                                                 GLib.error(msg);
249                                         }
250                                 });
251                         }
252                         
253                         
254                 
255                 }
256                 void listProjects()
257                 {
258                         if (!BuilderApplication.opt_list_projects) {
259                                 return;
260                         }
261                         print("Projects\n %s\n", Project.Project.listAllToString());
262                         GLib.Process.exit(Posix.EXIT_SUCCESS);
263                 
264                 }
265                 Project.Project? compileProject()
266                 {
267                         
268                         if (BuilderApplication.opt_compile_project == null) {
269                                 return null;
270                          }
271                         Project.Project cur_project = null;
272                         cur_project = Project.Project.getProjectByPath( BuilderApplication.opt_compile_project);
273                         
274
275                         
276                         if (cur_project == null) {
277                                 GLib.error("invalid project %s, use --list-projects to show project ids",BuilderApplication.opt_compile_project);
278                         }
279                         cur_project.load();
280
281                         
282
283                         return cur_project;
284                 
285                 }
286                 
287                 void dropList(Project.Project? cur_project) {
288
289
290                         if (cur_project== null || BuilderApplication.opt_drop_list == null) {
291                                 return;
292                         }
293                         
294                         if (BuilderApplication.opt_compile_project == null) {
295                                 GLib.error("need a project %s, to use --drop-list",BuilderApplication.opt_compile_project);
296                          }
297                           if (cur_project.xtype != "Gtk") {
298                                 GLib.error("need a Gtk project %s, to use --drop-list",BuilderApplication.opt_compile_project);
299                          }
300                          var p = (Palete.Gtk) cur_project.palete;
301                         
302                          print("\n\nDropList:\n%s", geeArrayToString(p.getDropList(BuilderApplication.opt_drop_list)));
303                          print("\n\nChildList:\n%s", geeArrayToString(p.getChildList(BuilderApplication.opt_drop_list, false)));
304                          print("\n\nChildList \n(with props): %s", geeArrayToString(p.getChildList(BuilderApplication.opt_drop_list, true)));   
305                          
306                          
307                          print("\n\nPropsList: %s", this.girArrayToString(p.getPropertiesFor( BuilderApplication.opt_drop_list, JsRender.NodePropType.PROP)));
308                          print("\n\nSignalList: %s", this.girArrayToString(p.getPropertiesFor( BuilderApplication.opt_drop_list, JsRender.NodePropType.LISTENER)));
309                          
310                          // ctor.
311                           print("\n\nCtor Values: %s", p.fqnToNode(BuilderApplication.opt_drop_list).toJsonString());
312                          
313                           GLib.Process.exit(Posix.EXIT_SUCCESS);
314                         
315                 }
316                 string geeArrayToString(Gee.ArrayList<string> ar) 
317                 {
318                         var ret = "";
319                         foreach(var n in ar) {
320                                 ret +=   n + "\n";
321                          }
322                          return ret;
323                 }
324                 string girArrayToString(Gee.HashMap<string,Palete.GirObject> map) 
325                 {
326                         var ret = "";
327                         foreach(var gi in map.values) {
328                                  ret += "%s %s (%s)\n".printf(gi.type, gi.name, gi.propertyof);
329                         
330                         }
331                         return ret;
332                 
333                 }
334                  
335                 
336                 void listFiles(Project.Project? cur_project)
337                 {
338                         if (!BuilderApplication.opt_list_files) {
339                                 return;
340                         }
341                         if (cur_project == null) {
342                                 GLib.error("missing project, use --project to select which project");
343                         }
344                         print("Files for %s\n %s\n", cur_project.name, cur_project.listAllFilesToString());
345                         GLib.Process.exit(Posix.EXIT_SUCCESS);
346                         
347                 }
348                 
349                 /**
350                  Test to see if the internal BJS reader/writer still outputs the same files.
351                  -- probably need this for the generator as well.
352                 */
353                 
354                 void testBjs(Project.Project? cur_project)
355                 {
356                         if (!BuilderApplication.opt_bjs_test) {
357                                 return;
358                         }
359                         if (cur_project == null) {
360                                 GLib.error("missing project, use --project to select which project");
361                         }
362                         print("Checking files\n");
363                         try { 
364                                 var ar = cur_project.sortedFiles();
365                                 foreach(var file in ar) {
366                                         string oldstr;
367
368                                         file.loadItems();
369                                         GLib.FileUtils.get_contents(file.path, out oldstr);                             
370                                         var outstr = file.toJsonString();
371                                         if (outstr != oldstr) { 
372                                                 
373                                                 GLib.FileUtils.set_contents("/tmp/" + file.name ,   outstr);
374                                                 print("meld  %s /tmp/%s\n", file.path,  file.name);
375                                                 //GLib.Process.exit(Posix.EXIT_SUCCESS);                
376                                         }
377                                         print("# Files match %s\n", file.name);
378                                         
379                                 }
380                         } catch (FileError e) {
381                                 GLib.debug("Got error %s", e.message);
382                         } catch (Error e) {
383                                 GLib.debug("Got error %s", e.message);
384                         }
385                                 
386                         print("All files pass");
387                         GLib.Process.exit(Posix.EXIT_SUCCESS);
388                 }
389                 
390                 void compileBjs(Project.Project? cur_project)
391                 {
392                         if (BuilderApplication.opt_bjs_compile == null) {
393                                 return;
394                         }
395                         if (cur_project == null) {
396                                 GLib.error("missing project, use --project to select which project");
397                         }
398                         
399                         if (BuilderApplication.opt_bjs_compile == "all") {
400                                 try { 
401                                         var ar = cur_project.sortedFiles();
402                                         
403                                         foreach(var file in ar) {
404                                         
405                                                 if (file is JsRender.PlainFile) {
406                                                         continue;
407                                                 }
408                         
409
410                                                 file.loadItems();
411                                                 var oldfn = file.targetName();
412                                                 
413                                                 print("\n\n\n\nFile : %s\n", oldfn);
414                                                 
415                                                                                 
416                                                 var outstr = file.toSourceCode();
417                                                 
418                                                 /* line number checking
419                                                 var bad = false;
420                                                 // check line numbers:
421                                                 var bits = outstr.split("\n");
422                                                 var end = bits.length;
423                                                 for(var i = 0;i < end; i++) {
424                                                         print("%i : %s\n", i+1 , bits[i]);
425                                                         if (!bad && bits[i].has_prefix("/*") && !bits[i].has_prefix(("/*%d*" +"/").printf(i+1))) {
426                                                                 end = i + 5 > bits.length ? bits.length: (i + 5);
427                                                                 print ("^^^^ mismatch\null");
428                                                                 bad = true;
429                                                         }
430
431                                                 
432                                                 }
433                                                 if (bad) {
434                                                         GLib.error("got bad file");
435                                                 }
436                                                 */
437                                                 // compare files. 
438                                                 string oldstr;
439                                                 GLib.FileUtils.get_contents(oldfn, out oldstr);
440                                                 if (outstr != oldstr) { 
441                                                         
442                                                         GLib.FileUtils.set_contents("/tmp/" + file.name   + ".out",   outstr);
443                                                         print("meld   %s /tmp/%s\n", oldfn,  file.name + ".out");
444                                                         //GLib.Process.exit(Posix.EXIT_SUCCESS);                
445                                                 }                                               
446                                                 //print("# Files match %s\n", file.name);
447                                         }               
448                                 } catch (FileError e) {
449                                         GLib.debug("Got error %s", e.message);
450                                 } catch (Error e) {
451                                         GLib.debug("got error %s", e.message);
452                                 }
453                                 
454                                 GLib.Process.exit(Posix.EXIT_SUCCESS);
455                         
456                         }
457                         
458                         
459                         
460                         var file = cur_project.getByRelPath(BuilderApplication.opt_bjs_compile);
461                         if (file == null) {
462                                 // then compile them all, and compare them...
463                                 
464                          
465                         
466                                 GLib.error("missing file %s in project %s", BuilderApplication.opt_bjs_compile, cur_project.name);
467                         }
468                         try {
469                                 file.loadItems();
470                         } catch(Error e) {
471                                 GLib.debug("Load items failed");
472                         }
473                                         
474                         if (BuilderApplication.opt_bjs_compile_glade) {
475                                 var str = file.toGlade();
476                                 print("%s", str);
477                                 GLib.Process.exit(Posix.EXIT_SUCCESS);
478                         }
479                         
480                         //BuilderApplication.compileBjs();
481
482                         var str = file.toSourceCode();
483                           
484                           
485                         if (!BuilderApplication.opt_debug) {
486                                 print("%s", str);
487                                 GLib.Process.exit(Posix.EXIT_SUCCESS);
488                         }
489                         
490                         // dump the node tree
491                         file.tree.dumpProps();
492                         
493                         
494                         
495                         
496                         
497                         var str_ar = str.split("\n");
498                         for(var i =0;i<str_ar.length;i++) {
499                                 var node = file.tree.lineToNode(i+1);
500                                 var prop = node == null ? null : node.lineToProp(i+1);
501                                 print("%d: %s   :  %s\n", 
502                                         i+1, 
503                                         node == null ? "......"  : (prop == null ? "????????" : prop.name),
504                                         str_ar[i]
505                                 );
506                         }
507                         
508                         GLib.Process.exit(Posix.EXIT_SUCCESS);
509                 }
510                 void languageServer(Project.Project? cur_project)
511                 {
512                         if (BuilderApplication.opt_language_server == null) {
513                                 return;
514                         }
515                         if (cur_project == null) {
516                                 GLib.error("missing project, use --project to select which project");
517                         }
518                         var file = cur_project.getByRelPath(BuilderApplication.opt_language_server);
519                         if (file == null) {
520                                 // then compile them all, and compare them...
521                                  GLib.error("missing file %s in project %s", BuilderApplication.opt_language_server, cur_project.name);
522                         }
523                         
524                         var ls = file.getLanguageServer();
525                         if (ls == null) {
526                                 GLib.error("No langauge server returned for file:%s", file.relpath);
527                         }
528                         
529                         //GLib.debug("started server - sleep 30 secs so you can gdb attach");
530                         //Posix.sleep( 30 );
531                         var loop = new MainLoop();
532                         GLib.Timeout.add_seconds(1, () => {
533                          
534                                 GLib.debug("Sending document_open");
535                                 // it's ready..
536                                  
537                                 ls.document_open(file);
538                                 ls.document_save(file);
539                                 
540                                 //ls.syntax.begin(file, (obj,res) => {
541                                 //      ls.syntax.end(res);
542                                 
543                                 //});
544                                 
545                                 
546                                 return false;
547                                 
548                         });
549                         
550                          
551                         loop.run();
552                         GLib.Process.exit(Posix.EXIT_SUCCESS);
553                 }
554                         
555         /*      
556                 void compileVala()
557                 {
558                         if (BuilderApplication.opt_compile_target == null) {
559                                 return;
560                         }
561                         Palete.ValaSourceCompiler.buildApplication();
562                 
563                         GLib.Process.exit(Posix.EXIT_SUCCESS);
564         
565                 }
566                 */
567                 void pullResources()
568                 {
569                         if (!opt_pull_resources) {
570                                 return;
571                         }
572                         var loop = new MainLoop();
573                         Resources.singleton().updateProgress.connect((p,t) => {
574                                 print("Got %d/%d", (int) p,(int)t);
575                                 if (p == t) {
576                                         loop.quit();
577                                 }
578                         });
579                         Resources.singleton().fetchStart();     
580                         loop.run();
581                         GLib.Process.exit(Posix.EXIT_SUCCESS);
582                 }
583                 
584                 
585                 void runTests()
586                 {
587                         if (opt_test == null) {
588                                 return;
589                         }
590                         switch(opt_test) {
591                                 case "help":
592                                         print("""
593 help             - list available tests
594 flutter-project  -  was try and read flutter data (but desnt work.)
595 """);           
596                                         break;
597                                 case "flutter-project":
598                                 Project.Project.loadAll();
599                                         //var p =   Project.Project.factory("Flutter", "/tmp/test-flutter");
600                                         /*var pa = p.palete as Palete.Flutter;
601                                         pa.dumpusage();
602                                          var ar = pa.getChildList("material.Scaffold");
603                                         GLib.debug("childlist for material.Scaffold is %s", 
604                                                 string.joinv( "\n-- ", ar)
605                                         );
606                                         ar = pa.getDropList("material.MaterialApp");
607                                         GLib.debug("droplist for material.MaterialApp is %s", 
608                                                 string.joinv( "\n-- ", ar)
609                                         );
610                                         */
611                                         break;
612                                         
613                                  
614                                         
615                                         
616                                 default:
617                                         print("Invalid test\n");
618                                         break;
619
620
621                         }
622                         GLib.Process.exit(Posix.EXIT_SUCCESS);          
623                 }
624                 
625                 
626                 // move to 'window colletction?
627                 public static Gee.ArrayList<Xcls_MainWindow> windows;
628                 
629                 public static void addWindow(Xcls_MainWindow w)
630                 {
631                          
632                         BuilderApplication.windows.add(w);
633                         BuilderApplication.updateWindows();
634   
635                         
636                 }
637                 
638                 public static void removeWindow(Xcls_MainWindow w)
639                 {
640                         //GLib.debug("remove window before = %d", BuilderApplication.windows.size);
641                         BuilderApplication.windows.remove(w);
642                         BuilderApplication.updateWindows();
643                                 
644                         w.el.hide();
645                         w.el.close();
646                         w.el.destroy();
647                         //GLib.debug("remove window after = %d", BuilderApplication.windows.size);
648                         
649                         
650                 }
651                 public static void updateWindows()
652                 {
653                         foreach(var ww in BuilderApplication.windows) {
654                                 ww.windowbtn.updateMenu();
655                         }
656                 }
657                 public static Xcls_MainWindow? getWindow(JsRender.JsRender file)
658                 {
659                         foreach(var ww in BuilderApplication.windows) {
660                                 if (ww.windowstate != null && ww.windowstate.file != null &&  ww.windowstate.file.path == file.path) {
661                                         return ww;
662                                 }
663                         }
664                         return null;
665                 
666                 }
667                 
668                 public static void newWindow(JsRender.JsRender file, int line)
669                 {
670                     var w = new Xcls_MainWindow();
671                         w.ref();
672                         BuilderApplication.addWindow(w);
673                         w.initChildren();
674                         w.windowstate.fileViewOpen(file, false, line);
675                         w.el.present();
676                          
677                 
678                 }
679                 
680                 static int queue_update_compile_countdown = -1;
681                 static uint queue_update_compile_id = 0;
682                 
683                 public static void updateCompileResults( )
684                 {
685                         queue_update_compile_countdown = 4; // 1 second after last call.
686                         if (queue_update_compile_id == 0) {
687                                 queue_update_compile_id = GLib.Timeout.add(250, () => {
688                                         if (queue_update_compile_countdown < 0) {
689                                                 return true;
690                                         }
691                                         queue_update_compile_countdown--;
692                                         if (queue_update_compile_countdown < 0) {
693                                                 realUpdateCompileResults();
694                                         }
695                                         
696                                         return true;
697                                 });
698                         }
699                 }
700                 
701                 
702                 public static void realUpdateCompileResults( )
703                 {
704                         
705                         
706                         
707                         foreach(var ww in BuilderApplication.windows) {
708                                 if (ww == null || ww.windowstate == null || ww.windowstate.project ==null) {
709                                         continue;
710                                 }
711
712                                 ww.windowstate.updateErrorMarksAll();
713                                  
714                                 GLib.debug("calling udate Errors of window %s", ww.windowstate.file.targetName());
715                                 ww.updateErrors();
716                                 
717                                 
718                         }
719                 
720                 }
721                 
722                 public static void showSpinnerLspLog(Palete.LanguageClientAction action, string message) {
723                         
724                         var msg = action.to_string() + " " + message;
725                         switch(action) {
726                         
727                                         case Palete.LanguageClientAction.INIT:
728                                         case Palete.LanguageClientAction.LAUNCH:
729                                         case Palete.LanguageClientAction.ACCEPT:
730                                                 BuilderApplication.showSpinner( "software-update-available", msg );
731                                                 return;
732                                                 
733                                         case Palete.LanguageClientAction.DIAG:
734                                                 BuilderApplication.showSpinner( "format-justify-fill", msg);                                    
735                                                 return;
736
737                                         case Palete.LanguageClientAction.OPEN:
738                                                 BuilderApplication.showSpinner( "document-open", msg);                                  
739                                                 return;
740                                         case Palete.LanguageClientAction.SAVE:
741                                                 BuilderApplication.showSpinner( "document-save", msg);                                  
742                                                 return;
743                                         case Palete.LanguageClientAction.CLOSE:
744                                                 BuilderApplication.showSpinner( "window.close", msg);                                   
745                                                 return;
746                                         case Palete.LanguageClientAction.CHANGE:
747                                                 BuilderApplication.showSpinner( "format-text-direction-ltr", msg);
748                                                 return;                                         
749                                         case Palete.LanguageClientAction.TERM:
750                                                 BuilderApplication.showSpinner( "media-playback-stop", msg);
751                                                 return;                                         
752                                         case Palete.LanguageClientAction.COMPLETE:
753                                                 BuilderApplication.showSpinner( "mail-send-recieve", msg);
754                                                 return;
755                                         
756                                         case Palete.LanguageClientAction.COMPLETE_REPLY:
757                                                 BuilderApplication.showSpinner( "face-cool", msg);
758                                                 return;
759                                                 
760                                         case Palete.LanguageClientAction.RESTART:
761                                         case Palete.LanguageClientAction.ERROR:
762                                         case Palete.LanguageClientAction.ERROR_START:
763                                         case Palete.LanguageClientAction.ERROR_RPC:
764                                         case Palete.LanguageClientAction.ERROR_REPLY:
765                                                 BuilderApplication.showSpinner( "software-update-urgent", msg );
766                                                 return;
767
768                                         case Palete.LanguageClientAction.EXIT:
769                                                 BuilderApplication.showSpinner( "face-sick", msg);
770                                                 return;
771                                         
772                         
773                         }
774                 }
775                 
776                 public static  void showSpinner(string icon, string tooltip = "")
777                 {
778
779                         // events:
780                         // doc change send: - spinner - 
781                         
782                         
783                         // ?? restart = software-update-urgent - crash?
784
785                         
786                         foreach (var win in BuilderApplication.windows) {
787                                 if (icon != "") {
788                                         win.statusbar_compile_spinner.start(icon, tooltip);
789                                 }  else {
790                                         win.statusbar_compile_spinner.stop();
791                                 }
792                         }
793                 }
794                 
795                 
796                 
797          
798         }
799         
800         
801                 
802
803  
804