Fix #7423 - tidy up open file list
[roobuilder] / src / Builder4 / MainWindow.bjs
1 {
2  "build_module" : "builder",
3  "items" : [
4   {
5    "# Project.Project project" : "null",
6    "# WindowState windowstate" : "",
7    "# string title" : "\"Roo Application Builder\"",
8    "$ type" : "Gtk.WindowType.TOPLEVEL",
9    "$ xns" : "Gtk",
10    "* init" : [
11     " ",
12     " ",
13     "     this.el.set_icon_name(\"roobuilder\");",
14     " "
15    ],
16    "border_width" : 0,
17    "default_height" : 850,
18    "default_width" : 1200,
19    "id" : "MainWindow",
20    "items" : [
21     {
22      "$ xns" : "Gtk",
23      "* pack" : "set_titlebar",
24      "bool show_close_button" : true,
25      "id" : "headerbar",
26      "items" : [
27       {
28        "$ xns" : "Gtk",
29        "* pack" : "pack_start",
30        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
31        "items" : [
32         {
33          "# Gee.ArrayList<Gtk.MenuItem> mitems" : "",
34          "$ Gtk.Align halign" : "Gtk.Align.START",
35          "$ Gtk.ArrowType direction" : "Gtk.ArrowType.DOWN",
36          "$ xns" : "Gtk",
37          "* init" : [
38           "{",
39           "\tthis.mitems = new Gee.ArrayList<Gtk.MenuItem>();",
40           "\t",
41           "}",
42           ""
43          ],
44          "bool always_show_image" : true,
45          "bool use_popover" : false,
46          "id" : "windowbtn",
47          "int margin_end" : 4,
48          "items" : [
49           {
50            "$ xns" : "Gtk",
51            "* pack" : "set_image",
52            "utf8 icon_name" : "window-new",
53            "xtype" : "Image"
54           },
55           {
56            "$ xns" : "Gtk",
57            "* init" : [
58             " ",
59             "  this.el.show_all();",
60             " "
61            ],
62            "* prop" : "popup",
63            "items" : [
64             {
65              "$ xns" : "Gtk",
66              "* pack" : "append",
67              "listeners" : {
68               "activate" : [
69                "( ) => {",
70                "",
71                "\t_this.windowstate.showPopoverFiles(_this.windowbtn.el, _this.project, true);",
72                "}",
73                ""
74               ]
75              },
76              "string label" : "New Window",
77              "xtype" : "MenuItem"
78             },
79             {
80              "$ xns" : "Gtk",
81              "* pack" : "append",
82              "xtype" : "SeparatorMenuItem"
83             }
84            ],
85            "xtype" : "Menu"
86           }
87          ],
88          "string label" : "Windows",
89          "xtype" : "MenuButton",
90          "| void updateMenu" : [
91           "() {",
92           "\t foreach(var m in  this.mitems) {",
93           "\t \t this.el.popup.remove(m);",
94           "\t }",
95           "\t this.mitems.clear();",
96           "\t ",
97           "\t BuilderApplication.windows.sort((a,b) => {",
98           "\t \tif (a.windowstate == null ||",
99           " \t\t\t a.windowstate.file == null || ",
100           " \t\t\t b.windowstate == null ||",
101           " \t\t\t b.windowstate.file == null",
102           " \t\t\t ) { ",
103           " \t\t\treturn 0;",
104           "\t\t}",
105           "",
106           "\t \tvar ap = a.windowstate.file.project.name;",
107           "\t \tvar bp = b.windowstate.file.project.name;",
108           "\t \t",
109           "",
110           "\t \t",
111           "\t \tif (ap != bp) {",
112           "\t \t\treturn ap.collate(bp);",
113           "\t \t}",
114           "\t \tvar af = a.windowstate.file.getTitle();",
115           "\t \tvar bf = b.windowstate.file.getTitle();\t \t",
116           "\t\treturn af.collate(bf);",
117           "\t ",
118           "\t });",
119           "\t ",
120           "\t var p = \"\";",
121           "\t foreach(var w in BuilderApplication.windows) {",
122           "\t \tvar wid = BuilderApplication.windows.index_of(w);",
123           "\t \t// fixme find a better way to display this.",
124           " \t\tif (w.windowstate == null ||",
125           " \t\t\t w.windowstate.file == null || ",
126           " \t\t\t _this.windowstate == null ||",
127           " \t\t\t _this.windowstate.file == null",
128           " \t\t\t ) { ",
129           " \t\t\tcontinue;",
130           "\t\t}",
131           "\t \t// should not happen...",
132           "\t \tif (w.windowstate.file.path == _this.windowstate.file.path) {",
133           "\t \t\tcontinue;",
134           " \t\t}",
135           " \t\tif (w.windowstate.file.project.name != p || p != \"\") {",
136           " \t\t\tvar ms = new Gtk.SeparatorMenuItem();",
137           " \t\t\tthis.el.popup.append(ms);",
138           "\t\t \tms.show();",
139           "\t\t \tthis.mitems.add(ms);",
140           " \t\t}",
141           " \t\t",
142           " \t\tp = w.windowstate.file.project.name;",
143           " \t\t",
144           "",
145           " \t\tGLib.debug(\"add menuitem %s\", w.windowstate.file.path);",
146           " \t\t",
147           " \t\t",
148           " \t\t",
149           "\t \tvar m = new Gtk.MenuItem.with_label(",
150           "\t\t \tw.windowstate.file.project.name + \" : \" + w.windowstate.file.getTitle()",
151           "\t \t);",
152           "\t \t",
153           "\t \t//w.windowstate.file.path);",
154           "\t \tm.activate.connect(() => {",
155           "\t \t\t BuilderApplication.windows.get(wid).el.present();",
156           "\t \t});",
157           "\t \tthis.el.popup.append(m);",
158           "\t \tm.show();",
159           "\t \tthis.mitems.add(m);",
160           "\t }",
161           "}"
162          ]
163         },
164         {
165          "$ tooltop_text" : "\"Open File\"",
166          "$ xns" : "Gtk",
167          "* pack" : "add",
168          "bool always_show_image" : true,
169          "id" : "open_projects_btn",
170          "items" : [
171           {
172            "$ xns" : "Gtk",
173            "* pack" : "set_image",
174            "utf8 icon_name" : "system-file-manager",
175            "xtype" : "Image"
176           }
177          ],
178          "listeners" : {
179           "clicked" : [
180            "  ( ) => {",
181            "  \t_this.windowstate.showPopoverFiles(this.el, _this.project, false);",
182            "",
183            "}"
184           ]
185          },
186          "string label" : "Files / Projects",
187          "xtype" : "Button"
188         }
189        ],
190        "xtype" : "Box"
191       }
192      ],
193      "string title" : "Application Builder",
194      "xtype" : "HeaderBar"
195     },
196     {
197      "$ homogeneous" : false,
198      "$ xns" : "Gtk",
199      "* pack" : "add",
200      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
201      "id" : "vbox",
202      "items" : [
203       {
204        "# int lastWidth" : 0,
205        "$ xns" : "Gtk",
206        "* pack" : "pack_start,true,true,0",
207        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
208        "id" : "mainpane",
209        "items" : [
210         {
211          "$ xns" : "Gtk",
212          "* pack" : "add",
213          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
214          "id" : "leftpane",
215          "items" : [
216           {
217            "$ xns" : "Gtk",
218            "* pack" : "pack_start,true,true,0",
219            "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
220            "id" : "editpane",
221            "items" : [
222             {
223              "$ xns" : "Gtk",
224              "* pack" : "add1",
225              "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
226              "id" : "tree",
227              "xtype" : "Box"
228             },
229             {
230              "$ xns" : "Gtk",
231              "* pack" : "add2",
232              "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
233              "id" : "props",
234              "xtype" : "Box"
235             }
236            ],
237            "listeners" : {
238             "accept_position" : [
239              "() => {",
240              "\tGLib.debug(\"Accept postion\");",
241              "\treturn true;",
242              "}"
243             ],
244             "move_handle" : [
245              "(scroll) => {",
246              "\tGLib.debug(\"Move handle\");",
247              "\treturn true;",
248              "}"
249             ]
250            },
251            "xtype" : "Paned"
252           }
253          ],
254          "xtype" : "Box"
255         },
256         {
257          "$ xns" : "Gtk",
258          "* pack" : "add2",
259          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
260          "items" : [
261           {
262            "$ xns" : "Gtk",
263            "* pack" : "add",
264            "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
265            "bool vexpand" : true,
266            "id" : "rooviewbox",
267            "xtype" : "Box"
268           },
269           {
270            "$ xns" : "Gtk",
271            "* pack" : "add",
272            "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
273            "bool vexpand" : true,
274            "id" : "codeeditviewbox",
275            "xtype" : "Box"
276           }
277          ],
278          "xtype" : "Box"
279         }
280        ],
281        "position" : 400,
282        "xtype" : "Paned"
283       },
284       {
285        "$ xns" : "Gtk",
286        "* pack" : "pack_end,false,true,0",
287        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
288        "bool homogeneous" : false,
289        "items" : [
290         {
291          "$ tooltip_text" : "\"Project Details\"",
292          "$ xns" : "Gtk",
293          "* pack" : "add",
294          "bool always_show_image" : true,
295          "items" : [
296           {
297            "$ xns" : "Gtk",
298            "* pack" : "set_image",
299            "utf8 icon_name" : "emblem-system",
300            "xtype" : "Image"
301           }
302          ],
303          "listeners" : {
304           "clicked" : [
305            "  ( ) => {",
306            "     ",
307            "     _this.windowstate.projectPopoverShow(this.el, _this.project);",
308            "   ",
309            "  ",
310            "}"
311           ]
312          },
313          "string label" : "Edit Project Settings",
314          "xtype" : "Button"
315         },
316         {
317          "$ tooltip_text" : "\"File Details\"",
318          "$ xns" : "Gtk",
319          "* pack" : "add",
320          "bool always_show_image" : true,
321          "items" : [
322           {
323            "$ xns" : "Gtk",
324            "* pack" : "set_image",
325            "utf8 icon_name" : "document-properties",
326            "xtype" : "Image"
327           }
328          ],
329          "listeners" : {
330           "clicked" : [
331            "  ( ) => {",
332            "  ",
333            "    // create a new file in project..",
334            "    if (_this.project == null || _this.windowstate.file == null) {",
335            "        return  ;",
336            "    }",
337            "     _this.windowstate.file_details.show(",
338            "        _this.windowstate.file, this.el, false",
339            "    );",
340            "     ",
341            "    return  ;    ",
342            "",
343            "",
344            "}"
345           ]
346          },
347          "string label" : "Edit File Properties",
348          "xtype" : "Button"
349         },
350         {
351          "$ xns" : "Gtk",
352          "* pack" : "add",
353          "bool always_show_image" : true,
354          "items" : [
355           {
356            "$ xns" : "Gtk",
357            "* init" : [
358             "{",
359             "    this.el.show_all();",
360             "}",
361             ""
362            ],
363            "* pack" : "set_popup",
364            "id" : "topbarmenu",
365            "items" : [
366             {
367              "$ xns" : "Gtk",
368              "* pack" : "append",
369              "listeners" : {
370               "activate" : [
371                " ( ) => {",
372                "         Resources.singleton().fetchStart();",
373                "}"
374               ]
375              },
376              "string label" : "Download updated Resources",
377              "xtype" : "MenuItem"
378             },
379             {
380              "$ xns" : "Gtk",
381              "* pack" : "append",
382              "listeners" : {
383               "activate" : [
384                "() => {",
385                "    About.singleton().el.show();",
386                "    }"
387               ]
388              },
389              "string label" : "About the Builder",
390              "xtype" : "MenuItem"
391             }
392            ],
393            "xtype" : "Menu"
394           },
395           {
396            "$ xns" : "Gtk",
397            "* pack" : "set_image",
398            "utf8 icon_name" : "dialog-information",
399            "xtype" : "Image"
400           }
401          ],
402          "string label" : "About",
403          "xtype" : "MenuButton"
404         },
405         {
406          "$ xns" : "Gtk",
407          "* pack" : "pack_start,true,true,0",
408          "string label" : "   ",
409          "xtype" : "Label"
410         },
411         {
412          "$ xns" : "Gtk",
413          "* init" : [
414           "{",
415           "     this.handler_id = Resources.singleton().updateProgress.connect((pos,total) => {",
416           "        if (pos < 1) {",
417           "            this.el.hide();",
418           "            _this.mainpane.el.set_sensitive(true);",
419           "            ",
420           "            return;",
421           "        }",
422           "         _this.mainpane.el.set_sensitive(false);",
423           "         this.el.show();",
424           "         this.el.set_fraction ((1.0f * pos) / (1.0f * total));",
425           "         this.el.set_text(\"Fetching Resource : %s/%s\".printf(pos.to_string(), total.to_string()));",
426           "       ",
427           "     });",
428           "}",
429           ""
430          ],
431          "* pack" : "pack_start,true,true,0",
432          "bool show_text" : true,
433          "id" : "statusbar",
434          "ulong handler_id" : "-1",
435          "xtype" : "ProgressBar"
436         },
437         {
438          "$ xns" : "Gtk",
439          "* pack" : "add",
440          "items" : [
441           {
442            "$ xns" : "Gtk",
443            "* pack" : "add",
444            "id" : "statusbar_compilestatus_label",
445            "string label" : "Compile Status:",
446            "xtype" : "MenuItem"
447           },
448           {
449            "# Json.Object notices" : "new Json.Object() ",
450            "$ xns" : "Gtk",
451            "* pack" : "add",
452            "Xcls_ValaCompileErrors popup" : "",
453            "id" : "statusbar_errors",
454            "items" : [
455             {
456              "$ xns" : "Gtk",
457              "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
458              "int spacing" : 2,
459              "items" : [
460               {
461                "$ xns" : "Gtk",
462                "utf8 icon_name" : "dialog-error",
463                "xtype" : "Image"
464               },
465               {
466                "$ xns" : "Gtk",
467                "id" : "statusbar_errors_label",
468                "string label" : "Errors",
469                "xtype" : "Label"
470               }
471              ],
472              "xtype" : "Box"
473             }
474            ],
475            "listeners" : {
476             "button_press_event" : [
477              "() => {",
478              "    if (this.popup == null) {",
479              "        this.popup = new Xcls_ValaCompileErrors();",
480              "        this.popup.window = _this;",
481              "    }",
482              "   ",
483              "    ",
484              "    this.popup.show(this.notices, this.el);",
485              "    return true;",
486              "}"
487             ]
488            },
489            "xtype" : "MenuItem",
490            "| void setNotices" : [
491             "(Json.Object nots, int qty) {",
492             "    this.el.show_all();",
493             "    _this.statusbar_errors_label.el.label = qty.to_string() + \" Errors\";",
494             "    this.notices = nots;",
495             "",
496             "}",
497             ""
498            ]
499           },
500           {
501            "# Json.Object notices" : "new Json.Object()",
502            "$ xns" : "Gtk",
503            "* pack" : "add",
504            "Xcls_ValaCompileErrors popup" : "",
505            "id" : "statusbar_warnings",
506            "items" : [
507             {
508              "$ xns" : "Gtk",
509              "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
510              "int spacing" : 2,
511              "items" : [
512               {
513                "$ xns" : "Gtk",
514                "utf8 icon_name" : "dialog-warning",
515                "xtype" : "Image"
516               },
517               {
518                "$ xns" : "Gtk",
519                "id" : "statusbar_warnings_label",
520                "string label" : "Errors",
521                "xtype" : "Label"
522               }
523              ],
524              "xtype" : "Box"
525             }
526            ],
527            "listeners" : {
528             "button_press_event" : [
529              "() => {",
530              "    if (this.popup == null) {",
531              "        this.popup = new Xcls_ValaCompileErrors();",
532              "        this.popup.window = _this;",
533              "    }",
534              "    ",
535              "    this.popup.show(this.notices, this.el);",
536              "    return true;",
537              "}"
538             ]
539            },
540            "xtype" : "MenuItem",
541            "| void setNotices" : [
542             "(Json.Object nots, int qty) {",
543             "    this.el.show_all();",
544             "    _this.statusbar_warnings_label.el.label = qty.to_string() + \" Warnings\";",
545             "    this.notices = nots;",
546             "",
547             "}",
548             ""
549            ]
550           },
551           {
552            "# Json.Object notices" : "new Json.Object()",
553            "$ xns" : "Gtk",
554            "* pack" : "add",
555            "Xcls_ValaCompileErrors popup" : "",
556            "id" : "statusbar_depricated",
557            "items" : [
558             {
559              "$ xns" : "Gtk",
560              "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
561              "int spacing" : 2,
562              "items" : [
563               {
564                "$ xns" : "Gtk",
565                "utf8 icon_name" : "dialog-information",
566                "xtype" : "Image"
567               },
568               {
569                "$ xns" : "Gtk",
570                "id" : "statusbar_depricated_label",
571                "string label" : "Errors",
572                "xtype" : "Label"
573               }
574              ],
575              "xtype" : "Box"
576             }
577            ],
578            "listeners" : {
579             "button_press_event" : [
580              "() => {",
581              "    if (this.popup == null) {",
582              "        this.popup = new Xcls_ValaCompileErrors();",
583              "        this.popup.window = _this;",
584              "    }",
585              "    ",
586              "    ",
587              "    this.popup.show(this.notices, this.el);",
588              "    return true;",
589              "}"
590             ]
591            },
592            "xtype" : "MenuItem",
593            "| void setNotices" : [
594             "(Json.Object nots, int qty) {",
595             "    this.el.show_all();",
596             "    _this.statusbar_depricated_label.el.label = qty.to_string() + \" Depricated\";",
597             "    this.notices = nots;",
598             "",
599             "}",
600             ""
601            ]
602           },
603           {
604            "$ xns" : "Gtk",
605            "* pack" : "add",
606            "Xcls_ValaCompileErrors popup" : "",
607            "id" : "statusbar_run",
608            "items" : [
609             {
610              "$ xns" : "Gtk",
611              "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
612              "int spacing" : 2,
613              "items" : [
614               {
615                "$ xns" : "Gtk",
616                "utf8 icon_name" : "media-playback-start",
617                "xtype" : "Image"
618               },
619               {
620                "$ xns" : "Gtk",
621                "string label" : "Run",
622                "xtype" : "Label"
623               }
624              ],
625              "xtype" : "Box"
626             }
627            ],
628            "listeners" : {
629             "button_press_event" : [
630              "() => {",
631              "\tif (_this.windowstate.file == null) {",
632              "\t\treturn true;",
633              "\t}",
634              "\tBuilderApplication.valasource.spawnExecute(_this.windowstate.file);",
635              "\t",
636              "\t_this.windowstate.compile_results.show(this.el,true);",
637              "\t",
638              "\treturn true;",
639              "}"
640             ]
641            },
642            "xtype" : "MenuItem"
643           }
644          ],
645          "xtype" : "MenuBar"
646         },
647         {
648          "$ xns" : "Gtk",
649          "* pack" : "add",
650          "id" : "statusbar_compile_spinner",
651          "string tooltip_text" : "Compiling",
652          "xtype" : "Spinner",
653          "| void start" : [
654           "() {",
655           "  this.el.show();",
656           "  this.el.start();  ",
657           "}",
658           ""
659          ],
660          "| void stop" : [
661           "() {",
662           " this.el.stop();",
663           "  this.el.hide();",
664           "}",
665           ""
666          ]
667         }
668        ],
669        "xtype" : "Box"
670       }
671      ],
672      "xtype" : "Box"
673     }
674    ],
675    "listeners" : {
676     "delete_event" : [
677      "(   event) => {",
678      "    return false;",
679      "} "
680     ],
681     "destroy" : [
682      "() =>  {",
683      " ",
684      " ",
685      " Resources.singleton().disconnect(_this.statusbar.handler_id);",
686      " ",
687      " BuilderApplication.removeWindow(this);",
688      " ",
689      " if (BuilderApplication.windows.size  < 1) {",
690      "",
691      "     Gtk.main_quit();",
692      " }",
693      "}"
694     ],
695     "key_release_event" : [
696      " (event) => {",
697      "    ",
698      "    ",
699      "\t",
700      "\tif (event.keyval == Gdk.Key.n && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
701      "\t\tprint(\"SAVE: ctrl-n  pressed\");",
702      "\t\t_this.windowstate.showPopoverFiles(_this.windowbtn.el, _this.project, true);",
703      "\t\treturn false;",
704      "\t}",
705      "\t",
706      "   // print(event.key.keyval)",
707      "    ",
708      "    return false;",
709      "",
710      "} ",
711      "",
712      ""
713     ],
714     "show" : [
715      "  ( ) => {",
716      "    // hide the file editing..",
717      "   ",
718      "    //this.hideViewEditing();",
719      "    _this.statusbar.el.hide();",
720      "     _this.statusbar_errors.el.hide();",
721      "    _this.statusbar_warnings.el.hide();",
722      "    _this.statusbar_depricated.el.hide();",
723      "    _this.statusbar_compile_spinner.el.hide();",
724      "  ",
725      "    Resources.singleton().checkResources();",
726      "",
727      "}"
728     ]
729    },
730    "xtype" : "Window",
731    "| void initChildren" : [
732     " () {",
733     "    // this needs putting in a better place..",
734     "    this.windowstate = new WindowState(this);",
735     "     ",
736     "",
737     " ",
738     "",
739     "    ",
740     "",
741     "",
742     "",
743     "}",
744     ""
745    ],
746    "| void openNewWindow" : [
747     "() {",
748     " ",
749     "    var w = new Xcls_MainWindow();",
750     "    w.ref();",
751     "\tBuilderApplication.addWindow(w);",
752     "    w.el.show_all();",
753     "    w.initChildren();",
754     "    w.windowstate.showPopoverFiles(w.open_projects_btn.el, _this.project, false);",
755     "     ",
756     "}",
757     ""
758    ],
759    "| void setTitle" : [
760     " (string str) {",
761     "    this.headerbar.el.set_title(this.title + \" - \" + str);",
762     "} ",
763     ""
764    ],
765    "| void show" : [
766     "() {",
767     "   ",
768     "    this.el.show_all();",
769     "",
770     "}"
771    ]
772   }
773  ],
774  "modOrder" : "",
775  "name" : "MainWindow",
776  "parent" : "",
777  "path" : "/home/alan/gitlive/roobuilder/src/Builder4/MainWindow.bjs",
778  "permname" : "",
779  "title" : ""
780 }