faa145703c5aa80c26370961d519cf244f540154
[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 foreach(var w in BuilderApplication.windows) {",
98           "\t \tvar wid = BuilderApplication.windows.index_of(w);",
99           "\t \t// fixme find a better way to display this.",
100           " \t\tif (w.windowstate == null ||",
101           " \t\t\t w.windowstate.file == null || ",
102           " \t\t\t _this.windowstate == null ||",
103           " \t\t\t _this.windowstate.file == null",
104           " \t\t\t ) { ",
105           " \t\t\tcontinue;",
106           "\t\t}",
107           "\t \t",
108           "\t \tif (w.windowstate.file.path == _this.windowstate.file.path) {",
109           "\t \t\tcontinue;",
110           " \t\t}",
111           "",
112           " \t\tGLib.debug(\"add menuitem %s\", w.windowstate.file.path);",
113           "\t \tvar m = new Gtk.MenuItem.with_label(w.windowstate.file.path);",
114           "\t \tm.activate.connect(() => {",
115           "\t \t\t BuilderApplication.windows.get(wid).el.present();",
116           "\t \t});",
117           "\t \tthis.el.popup.append(m);",
118           "\t \tm.show();",
119           "\t \tthis.mitems.add(m);",
120           "\t }",
121           "}"
122          ]
123         },
124         {
125          "$ tooltop_text" : "\"Open File\"",
126          "$ xns" : "Gtk",
127          "* pack" : "add",
128          "bool always_show_image" : true,
129          "id" : "open_projects_btn",
130          "items" : [
131           {
132            "$ xns" : "Gtk",
133            "* pack" : "set_image",
134            "utf8 icon_name" : "system-file-manager",
135            "xtype" : "Image"
136           }
137          ],
138          "listeners" : {
139           "clicked" : [
140            "  ( ) => {",
141            "  \t_this.windowstate.showPopoverFiles(this.el, _this.project, false);",
142            "",
143            "}"
144           ]
145          },
146          "string label" : "Files / Projects",
147          "xtype" : "Button"
148         }
149        ],
150        "xtype" : "Box"
151       }
152      ],
153      "string title" : "Application Builder",
154      "xtype" : "HeaderBar"
155     },
156     {
157      "$ homogeneous" : false,
158      "$ xns" : "Gtk",
159      "* pack" : "add",
160      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
161      "id" : "vbox",
162      "items" : [
163       {
164        "# int lastWidth" : 0,
165        "$ xns" : "Gtk",
166        "* pack" : "pack_start,true,true,0",
167        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
168        "id" : "mainpane",
169        "items" : [
170         {
171          "$ xns" : "Gtk",
172          "* pack" : "add",
173          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
174          "id" : "leftpane",
175          "items" : [
176           {
177            "$ xns" : "Gtk",
178            "* pack" : "pack_start,true,true,0",
179            "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
180            "id" : "editpane",
181            "items" : [
182             {
183              "$ xns" : "Gtk",
184              "* pack" : "add1",
185              "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
186              "id" : "tree",
187              "xtype" : "Box"
188             },
189             {
190              "$ xns" : "Gtk",
191              "* pack" : "add2",
192              "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
193              "id" : "props",
194              "xtype" : "Box"
195             }
196            ],
197            "listeners" : {
198             "accept_position" : [
199              "() => {",
200              "\tGLib.debug(\"Accept postion\");",
201              "\treturn true;",
202              "}"
203             ],
204             "move_handle" : [
205              "(scroll) => {",
206              "\tGLib.debug(\"Move handle\");",
207              "\treturn true;",
208              "}"
209             ]
210            },
211            "xtype" : "Paned"
212           }
213          ],
214          "xtype" : "Box"
215         },
216         {
217          "$ xns" : "Gtk",
218          "* pack" : "add2",
219          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
220          "items" : [
221           {
222            "$ xns" : "Gtk",
223            "* pack" : "add",
224            "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
225            "bool vexpand" : true,
226            "id" : "rooviewbox",
227            "xtype" : "Box"
228           },
229           {
230            "$ xns" : "Gtk",
231            "* pack" : "add",
232            "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
233            "bool vexpand" : true,
234            "id" : "codeeditviewbox",
235            "xtype" : "Box"
236           }
237          ],
238          "xtype" : "Box"
239         }
240        ],
241        "position" : 400,
242        "xtype" : "Paned"
243       },
244       {
245        "$ xns" : "Gtk",
246        "* pack" : "pack_end,false,true,0",
247        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
248        "bool homogeneous" : false,
249        "items" : [
250         {
251          "$ tooltip_text" : "\"Project Details\"",
252          "$ xns" : "Gtk",
253          "* pack" : "add",
254          "bool always_show_image" : true,
255          "items" : [
256           {
257            "$ xns" : "Gtk",
258            "* pack" : "set_image",
259            "utf8 icon_name" : "emblem-system",
260            "xtype" : "Image"
261           }
262          ],
263          "listeners" : {
264           "clicked" : [
265            "  ( ) => {",
266            "     ",
267            "     _this.windowstate.projectPopoverShow(this.el, _this.project);",
268            "   ",
269            "  ",
270            "}"
271           ]
272          },
273          "string label" : "Edit Project Settings",
274          "xtype" : "Button"
275         },
276         {
277          "$ tooltip_text" : "\"File Details\"",
278          "$ xns" : "Gtk",
279          "* pack" : "add",
280          "bool always_show_image" : true,
281          "items" : [
282           {
283            "$ xns" : "Gtk",
284            "* pack" : "set_image",
285            "utf8 icon_name" : "document-properties",
286            "xtype" : "Image"
287           }
288          ],
289          "listeners" : {
290           "clicked" : [
291            "  ( ) => {",
292            "  ",
293            "    // create a new file in project..",
294            "    if (_this.project == null || _this.windowstate.file == null) {",
295            "        return  ;",
296            "    }",
297            "     _this.windowstate.file_details.show(",
298            "        _this.windowstate.file, this.el, false",
299            "    );",
300            "     ",
301            "    return  ;    ",
302            "",
303            "",
304            "}"
305           ]
306          },
307          "string label" : "Edit File Properties",
308          "xtype" : "Button"
309         },
310         {
311          "$ xns" : "Gtk",
312          "* pack" : "add",
313          "bool always_show_image" : true,
314          "items" : [
315           {
316            "$ xns" : "Gtk",
317            "* init" : [
318             "{",
319             "    this.el.show_all();",
320             "}",
321             ""
322            ],
323            "* pack" : "set_popup",
324            "id" : "topbarmenu",
325            "items" : [
326             {
327              "$ xns" : "Gtk",
328              "* pack" : "append",
329              "listeners" : {
330               "activate" : [
331                " ( ) => {",
332                "         Resources.singleton().fetchStart();",
333                "}"
334               ]
335              },
336              "string label" : "Download updated Resources",
337              "xtype" : "MenuItem"
338             },
339             {
340              "$ xns" : "Gtk",
341              "* pack" : "append",
342              "listeners" : {
343               "activate" : [
344                "() => {",
345                "    About.singleton().el.show();",
346                "    }"
347               ]
348              },
349              "string label" : "About the Builder",
350              "xtype" : "MenuItem"
351             }
352            ],
353            "xtype" : "Menu"
354           },
355           {
356            "$ xns" : "Gtk",
357            "* pack" : "set_image",
358            "utf8 icon_name" : "dialog-information",
359            "xtype" : "Image"
360           }
361          ],
362          "string label" : "About",
363          "xtype" : "MenuButton"
364         },
365         {
366          "$ xns" : "Gtk",
367          "* pack" : "pack_start,true,true,0",
368          "string label" : "   ",
369          "xtype" : "Label"
370         },
371         {
372          "$ xns" : "Gtk",
373          "* init" : [
374           "{",
375           "     this.handler_id = Resources.singleton().updateProgress.connect((pos,total) => {",
376           "        if (pos < 1) {",
377           "            this.el.hide();",
378           "            _this.mainpane.el.set_sensitive(true);",
379           "            ",
380           "            return;",
381           "        }",
382           "         _this.mainpane.el.set_sensitive(false);",
383           "         this.el.show();",
384           "         this.el.set_fraction ((1.0f * pos) / (1.0f * total));",
385           "         this.el.set_text(\"Fetching Resource : %s/%s\".printf(pos.to_string(), total.to_string()));",
386           "       ",
387           "     });",
388           "}",
389           ""
390          ],
391          "* pack" : "pack_start,true,true,0",
392          "bool show_text" : true,
393          "id" : "statusbar",
394          "ulong handler_id" : "-1",
395          "xtype" : "ProgressBar"
396         },
397         {
398          "$ xns" : "Gtk",
399          "* pack" : "add",
400          "items" : [
401           {
402            "$ xns" : "Gtk",
403            "* pack" : "add",
404            "id" : "statusbar_compilestatus_label",
405            "string label" : "Compile Status:",
406            "xtype" : "MenuItem"
407           },
408           {
409            "# Json.Object notices" : "new Json.Object() ",
410            "$ xns" : "Gtk",
411            "* pack" : "add",
412            "Xcls_ValaCompileErrors popup" : "",
413            "bool always_show_image" : true,
414            "id" : "statusbar_errors",
415            "items" : [
416             {
417              "$ xns" : "Gtk",
418              "* pack" : "set_image",
419              "utf8 icon_name" : "dialog-error",
420              "xtype" : "Image"
421             }
422            ],
423            "listeners" : {
424             "button_press_event" : [
425              "() => {",
426              "    if (this.popup == null) {",
427              "        this.popup = new Xcls_ValaCompileErrors();",
428              "        this.popup.window = _this;",
429              "    }",
430              "   ",
431              "    ",
432              "    this.popup.show(this.notices, this.el);",
433              "    return true;",
434              "}"
435             ]
436            },
437            "string label" : "Errors",
438            "xtype" : "ImageMenuItem",
439            "| void setNotices" : [
440             "(Json.Object nots, int qty) {",
441             "    this.el.show();",
442             "    this.el.label = qty.to_string() + \" Errors\";",
443             "    this.notices = nots;",
444             "",
445             "}",
446             ""
447            ]
448           },
449           {
450            "# Json.Object notices" : "new Json.Object()",
451            "$ xns" : "Gtk",
452            "* pack" : "add",
453            "Xcls_ValaCompileErrors popup" : "",
454            "bool always_show_image" : true,
455            "id" : "statusbar_warnings",
456            "items" : [
457             {
458              "$ xns" : "Gtk",
459              "* pack" : "set_image",
460              "utf8 icon_name" : "dialog-warning",
461              "xtype" : "Image"
462             }
463            ],
464            "listeners" : {
465             "button_press_event" : [
466              "() => {",
467              "    if (this.popup == null) {",
468              "        this.popup = new Xcls_ValaCompileErrors();",
469              "        this.popup.window = _this;",
470              "    }",
471              "    ",
472              "    this.popup.show(this.notices, this.el);",
473              "    return true;",
474              "}"
475             ]
476            },
477            "string label" : "Warnings",
478            "xtype" : "ImageMenuItem",
479            "| void setNotices" : [
480             "(Json.Object nots, int qty) {",
481             "    this.el.show();",
482             "    this.el.label = qty.to_string() + \" Warnings\";",
483             "    this.notices = nots;",
484             "",
485             "}",
486             ""
487            ]
488           },
489           {
490            "# Json.Object notices" : "new Json.Object()",
491            "$ xns" : "Gtk",
492            "* pack" : "add",
493            "Xcls_ValaCompileErrors popup" : "",
494            "bool always_show_image" : true,
495            "id" : "statusbar_depricated",
496            "items" : [
497             {
498              "$ xns" : "Gtk",
499              "* pack" : "set_image",
500              "utf8 icon_name" : "dialog-information",
501              "xtype" : "Image"
502             }
503            ],
504            "listeners" : {
505             "button_press_event" : [
506              "() => {",
507              "    if (this.popup == null) {",
508              "        this.popup = new Xcls_ValaCompileErrors();",
509              "        this.popup.window = _this;",
510              "    }",
511              "    ",
512              "    ",
513              "    this.popup.show(this.notices, this.el);",
514              "    return true;",
515              "}"
516             ]
517            },
518            "string label" : "Depricated",
519            "xtype" : "ImageMenuItem",
520            "| void setNotices" : [
521             "(Json.Object nots, int qty) {",
522             "    this.el.show();",
523             "    this.el.label = qty.to_string() + \" Depricated\";",
524             "    this.notices = nots;",
525             "",
526             "}",
527             ""
528            ]
529           },
530           {
531            "$ xns" : "Gtk",
532            "* pack" : "add",
533            "Xcls_ValaCompileErrors popup" : "",
534            "bool always_show_image" : true,
535            "id" : "statusbar_run",
536            "items" : [
537             {
538              "$ xns" : "Gtk",
539              "* pack" : "set_image",
540              "utf8 icon_name" : "media-playback-start",
541              "xtype" : "Image"
542             }
543            ],
544            "listeners" : {
545             "button_press_event" : [
546              "() => {",
547              "\tif (_this.windowstate.file == null) {",
548              "\t\treturn true;",
549              "\t}",
550              "\tBuilderApplication.valasource.spawnExecute(_this.windowstate.file);",
551              "\t",
552              "\t_this.windowstate.compile_results.show(this.el,true);",
553              "\t",
554              "\treturn true;",
555              "}"
556             ]
557            },
558            "string label" : "Run",
559            "xtype" : "ImageMenuItem"
560           }
561          ],
562          "xtype" : "MenuBar"
563         },
564         {
565          "$ xns" : "Gtk",
566          "* pack" : "add",
567          "id" : "statusbar_compile_spinner",
568          "string tooltip_text" : "Compiling",
569          "xtype" : "Spinner",
570          "| void start" : [
571           "() {",
572           "  this.el.show();",
573           "  this.el.start();  ",
574           "}",
575           ""
576          ],
577          "| void stop" : [
578           "() {",
579           " this.el.stop();",
580           "  this.el.hide();",
581           "}",
582           ""
583          ]
584         }
585        ],
586        "xtype" : "Box"
587       }
588      ],
589      "xtype" : "Box"
590     }
591    ],
592    "listeners" : {
593     "delete_event" : [
594      "(   event) => {",
595      "    return false;",
596      "} "
597     ],
598     "destroy" : [
599      "() =>  {",
600      " ",
601      " ",
602      " Resources.singleton().disconnect(_this.statusbar.handler_id);",
603      " ",
604      " BuilderApplication.removeWindow(this);",
605      " ",
606      " if (BuilderApplication.windows.size  < 1) {",
607      "",
608      "     Gtk.main_quit();",
609      " }",
610      "}"
611     ],
612     "key_release_event" : [
613      " (event) => {",
614      "    ",
615      "    ",
616      "\t",
617      "\tif (event.keyval == Gdk.Key.n && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
618      "\t\tprint(\"SAVE: ctrl-n  pressed\");",
619      "\t\t_this.windowstate.showPopoverFiles(_this.windowbtn.el, _this.project, true);",
620      "\t\treturn false;",
621      "\t}",
622      "\t",
623      "   // print(event.key.keyval)",
624      "    ",
625      "    return false;",
626      "",
627      "} ",
628      "",
629      ""
630     ],
631     "show" : [
632      "  ( ) => {",
633      "    // hide the file editing..",
634      "   ",
635      "    //this.hideViewEditing();",
636      "    _this.statusbar.el.hide();",
637      "     _this.statusbar_errors.el.hide();",
638      "    _this.statusbar_warnings.el.hide();",
639      "    _this.statusbar_depricated.el.hide();",
640      "    _this.statusbar_compile_spinner.el.hide();",
641      "  ",
642      "    Resources.singleton().checkResources();",
643      "",
644      "}"
645     ]
646    },
647    "xtype" : "Window",
648    "| void initChildren" : [
649     " () {",
650     "    // this needs putting in a better place..",
651     "    this.windowstate = new WindowState(this);",
652     "     ",
653     "",
654     " ",
655     "",
656     "    ",
657     "",
658     "",
659     "",
660     "}",
661     ""
662    ],
663    "| void openNewWindow" : [
664     "() {",
665     " ",
666     "    var w = new Xcls_MainWindow();",
667     "    w.ref();",
668     "\tBuilderApplication.addWindow(w);",
669     "    w.el.show_all();",
670     "    w.initChildren();",
671     "    w.windowstate.showPopoverFiles(w.open_projects_btn.el, _this.project, false);",
672     "     ",
673     "}",
674     ""
675    ],
676    "| void setTitle" : [
677     " (string str) {",
678     "    this.headerbar.el.set_title(this.title + \" - \" + str);",
679     "} ",
680     ""
681    ],
682    "| void show" : [
683     "() {",
684     "   ",
685     "    this.el.show_all();",
686     "",
687     "}"
688    ]
689   }
690  ],
691  "modOrder" : "",
692  "name" : "MainWindow",
693  "parent" : "",
694  "path" : "/home/alan/gitlive/roobuilder/src/Builder4/MainWindow.bjs",
695  "permname" : "",
696  "title" : ""
697 }