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