src/Builder4/ValaProjectSettings.bjs
[app.Builder.js] / src / Builder4 / ValaProjectSettings.bjs
1 {
2  "name" : "ValaProjectSettings",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/ValaProjectSettings.bjs",
6  "permname" : "",
7  "modOrder" : "",
8  "items" : [
9   {
10    "# Project.Gtk project" : "null",
11    "# Xcls_MainWindow window" : "null",
12    "| void show" : "(Project.Gtk project) {\n    \n    \n    print(\"ValaProjectSettings show\\n\");\n    \n    this.project=  project;\n\n    this.compile_flags.el.text = _this.project.compilegroups.get(\"_default_\").compile_flags;\n    \n    this.default_directory_tree_store.load();    \n    this.default_packages_tree_store.load();            \n    this.targets_tree_store.load();\n    this.files_tree_store.load();\n\n}\n",
13    "xtype" : "VBox",
14    "string id" : "ValaProjectSettings",
15    "| void save" : "()  {\n    this.project.writeConfig();\n}",
16    "$ xns" : "Gtk",
17    "items" : [
18     {
19      "* pack" : "pack_start,true,true,0",
20      "xtype" : "Notebook",
21      "$ xns" : "Gtk",
22      "items" : [
23       {
24        "id" : "label_global",
25        "* pack" : false,
26        "xtype" : "Label",
27        "$ xns" : "Gtk",
28        "utf8 label" : "Global"
29       },
30       {
31        "id" : "label_targets",
32        "xtype" : "Label",
33        "* pack" : false,
34        "$ xns" : "Gtk",
35        "utf8 label" : "Targets"
36       },
37       {
38        "xtype" : "VBox",
39        "* pack" : "append_page,_this.label_global.el",
40        "gboolean homogeneous" : false,
41        "$ xns" : "Gtk",
42        "items" : [
43         {
44          "xtype" : "Label",
45          "* pack" : "pack_start,false,false,0",
46          "$ xns" : "Gtk",
47          "utf8 label" : "compile flags"
48         },
49         {
50          "listeners" : {
51           "changed" : "() => {\n    \n   _this.project.compilegroups.get(\"_default_\").compile_flags = this.el.text;\n   _this.project.writeConfig();\n//    _this.project.save();\n\n}"
52          },
53          "id" : "compile_flags",
54          "* pack" : "pack_start,false,false,0",
55          "xtype" : "Entry",
56          "$ xns" : "Gtk",
57          "utf8 placeholder_text" : "eg. -g --valasrc $BASEDIR "
58         },
59         {
60          "xtype" : "Label",
61          "* pack" : "pack_start,false,false,0",
62          "$ xns" : "Gtk",
63          "utf8 label" : "packages"
64         },
65         {
66          "* pack" : "pack_start,true,true,0",
67          "xtype" : "ScrolledWindow",
68          "$ xns" : "Gtk",
69          "items" : [
70           {
71            "gboolean headers_visible" : false,
72            "xtype" : "TreeView",
73            "* pack" : "add",
74            "string id" : "default_packages_tree",
75            "$ xns" : "Gtk",
76            "items" : [
77             {
78              "id" : "default_packages_tree_store",
79              "xtype" : "ListStore",
80              "* pack" : "set_model",
81              "$ n_columns" : 2,
82              "| void load" : "() {\n \n    var def = _this.project.compilegroups.get(\"_default_\");\n    var items  = def.packages;\n    \n    this.el.clear();\n    var pal = (Palete.Gtk) Palete.factory(\"Gtk\");\n    var pkgs = pal.packages();\n    print(\"ValaProjectSettings:packages load %d\\n\", pkgs.size);\n\n    Gtk.TreeIter citer;\n\n    for(var i =0 ; i < pkgs.size; i++) {\n         this.el.append(out citer);   \n         \n        this.el.set_value(citer, 0,   pkgs.get(i) ); // title \n        this.el.set_value(citer, 1,   items.contains(pkgs.get(i)) );\n    }\n    this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);\n    \n}\n",
83              "$ columns" : "    typeof(string),  // 0 key type\n      typeof(bool)",
84              "$ xns" : "Gtk"
85             },
86             {
87              "utf8 title" : "name",
88              "* init" : " \n this.el.add_attribute(_this.packages_render.el , \"text\", 0 );\n  ",
89              "* pack" : "append_column",
90              "xtype" : "TreeViewColumn",
91              "gboolean resizable" : true,
92              "gboolean expand" : true,
93              "$ xns" : "Gtk",
94              "items" : [
95               {
96                "id" : "packages_render",
97                "xtype" : "CellRendererText",
98                "* pack" : "pack_start,false",
99                "$ xns" : "Gtk"
100               }
101              ]
102             },
103             {
104              "utf8 title" : "use",
105              "* init" : "{\n this.el.add_attribute(_this.packages_render_use.el , \"active\", 1 );\n }",
106              "* pack" : "append_column",
107              "xtype" : "TreeViewColumn",
108              "gboolean resizable" : false,
109              "$ xns" : "Gtk",
110              "gint fixed_width" : 50,
111              "items" : [
112               {
113                "listeners" : {
114                 "toggled" : "(  path_string) =>  { \n    var m = _this.default_packages_tree_store.el;\n   Gtk.TreeIter iter;\n   Gtk.TreePath path = new Gtk.TreePath.from_string (path_string);\n   m.get_iter (out iter, path);\n   GLib.Value val;\n   m.get_value(iter, 1, out val);\n   m.set_value(iter, 1,  ((bool) val) ? false :true); \n     GLib.Value fval;  \n   m.get_value(iter, 0, out fval);\n   var fn = (string)fval;\n    \n    var def = _this.project.compilegroups.get(\"_default_\");\n    var items  = def.packages;\n    if ((bool)val) {\n        // renive\n        items.remove(fn);\n    } else {\n        items.add(fn);\n    }\n    \n}"
115                },
116                "id" : "packages_render_use",
117                "* pack" : "pack_start,false",
118                "xtype" : "CellRendererToggle",
119                "$ xns" : "Gtk",
120                "gboolean activatable" : true
121               }
122              ]
123             }
124            ]
125           }
126          ]
127         },
128         {
129          "xtype" : "Label",
130          "* pack" : "pack_start,false,false,0",
131          "$ xns" : "Gtk",
132          "utf8 label" : "Available Directories"
133         },
134         {
135          "* pack" : "pack_start,true,true,0",
136          "xtype" : "ScrolledWindow",
137          "$ xns" : "Gtk",
138          "items" : [
139           {
140            "listeners" : {
141             "button_press_event" : " ( ev) => {\n    //console.log(\"button press?\");\n   \n    \n    if (ev.type != Gdk.EventType.BUTTON_PRESS  || ev.button != 3) {\n        //print(\"click\" + ev.type);\n        return false;\n    }\n    //Gtk.TreePath res;\n    //if (!this.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) {\n    //    return true;\n    //}\n     \n  //  this.el.get_selection().select_path(res);\n     \n      //if (!this.get('/LeftTreeMenu').el)  { \n      //      this.get('/LeftTreeMenu').init(); \n      //  }\n        \n     _this.default_directory_menu.el.set_screen(Gdk.Screen.get_default());\n     _this.default_directory_menu.el.show_all();\n      _this.default_directory_menu.el.popup(null, null, null,  3, ev.time);\n     //   print(\"click:\" + res.path.to_string());\n      return true;\n}"
142            },
143            "gboolean headers_visible" : false,
144            "id" : "default_directory_tree",
145            "* pack" : "add",
146            "xtype" : "TreeView",
147            "$ xns" : "Gtk",
148            "items" : [
149             {
150              "id" : "default_directory_tree_store",
151              "xtype" : "ListStore",
152              "* pack" : "set_model",
153              "$ n_columns" : 1,
154              "| void load" : "() {\n \n  this.el.clear();\n  \n    \n     var def = _this.project.compilegroups.get(\"_default_\");\n     var items  = def.sources;\n     \n \n    Gtk.TreeIter citer;\n\n    for(var i =0 ; i < items.size; i++) {\n         this.el.append(out citer);   \n         \n        this.el.set_value(citer, 0,   items.get(i) ); // title \n        //this.el.set_value(citer, 1,   items.get(i) );\n    }\n    this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);\n    \n}\n",
155              "$ columns" : "    typeof(string)\n     ",
156              "$ xns" : "Gtk"
157             },
158             {
159              "utf8 title" : "name",
160              "* init" : "\n this.el.add_attribute(_this.directory_render.el , \"text\", 0 );\n  ",
161              "* pack" : "append_column",
162              "xtype" : "TreeViewColumn",
163              "gboolean resizable" : true,
164              "$ xns" : "Gtk",
165              "items" : [
166               {
167                "id" : "directory_render",
168                "xtype" : "CellRendererText",
169                "* pack" : "pack_start,false",
170                "$ xns" : "Gtk"
171               }
172              ]
173             }
174            ]
175           },
176           {
177            "id" : "default_directory_menu",
178            "xtype" : "Menu",
179            "$ xns" : "Gtk",
180            "items" : [
181             {
182              "listeners" : {
183               "activate" : "()  => {\n    \n    var  chooser = new Gtk.FileChooserDialog (\n\t\"Add a directory\", _this.window.el, Gtk.FileChooserAction.SELECT_FOLDER ,\n\t\"_Cancel\",\n\tGtk.ResponseType.CANCEL,\n\t\"_Add\",\n\tGtk.ResponseType.ACCEPT);\n    if (chooser.run () != Gtk.ResponseType.ACCEPT) {\n        chooser.close ();\n           return;\n       }\n       chooser.close ();\n       // add the directory..\n       var fn = _this.project.relPath(chooser.get_filename());\n       _this.project.compilegroups.get(\"_default_\").sources.add(fn);\n       _this.default_directory_tree_store.load();\n}"
184              },
185              "* pack" : "add",
186              "xtype" : "MenuItem",
187              "$ xns" : "Gtk",
188              "utf8 label" : "Add Directory"
189             },
190             {
191              "listeners" : {
192               "activate" : "()  => {\n    \n    var  chooser = new Gtk.FileChooserDialog (\n\t\"Add a directory\", _this.window.el, Gtk.FileChooserAction.OPEN ,\n\t\"_Cancel\",\n\tGtk.ResponseType.CANCEL,\n\t\"_Add\",\n\tGtk.ResponseType.ACCEPT);\n    if (chooser.run () != Gtk.ResponseType.ACCEPT) {\n        chooser.close ();\n           return;\n       }\n       chooser.close ();\n       // add the directory..\n       var fn = _this.project.relPath(chooser.get_filename());\n       _this.project.compilegroups.get(\"_default_\").sources.add(fn);\n       _this.default_directory_tree_store.load();\n}"
193              },
194              "* pack" : "add",
195              "xtype" : "MenuItem",
196              "$ xns" : "Gtk",
197              "utf8 label" : "Add File"
198             },
199             {
200              "* pack" : "add",
201              "xtype" : "SeparatorMenuItem",
202              "$ xns" : "Gtk"
203             },
204             {
205              "listeners" : {
206               "activate" : "()  => {\n    \n     //\n        Gtk.TreeModel mod;\n        Gtk.TreeIter iter;\n        if (!_this.default_directory_tree.el.get_selection().get_selected(out mod, out iter)) {\n               print(\"nothing selected\\n\");\n            return;\n        }\n\n            \n       // add the directory..\n       \n       \n       GLib.Value val;\n        mod.get_value(iter,0, out val);\n       var fn =  (string) val;\n       \n       print(\"remove: %s\\n\", fn);\n       if (!_this.project.compilegroups.get(\"_default_\").sources.remove(fn)) {\n                  print(\"remove failed\");\n              }\n       _this.default_directory_tree_store.load();\n}"
207              },
208              "* pack" : "add",
209              "xtype" : "MenuItem",
210              "$ xns" : "Gtk",
211              "utf8 label" : "Remove File/Directory"
212             }
213            ]
214           }
215          ]
216         }
217        ]
218       },
219       {
220        "gint position" : 300,
221        "* pack" : "append_page,_this.label_targets.el",
222        "xtype" : "HPaned",
223        "$ xns" : "Gtk",
224        "items" : [
225         {
226          "* init" : "{  \nthis.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n\n}\n",
227          "* pack" : "add1",
228          "xtype" : "ScrolledWindow",
229          "$ xns" : "Gtk",
230          "items" : [
231           {
232            "id" : "targets_tree_menu",
233            "xtype" : "Menu",
234            "* pack" : "add",
235            "$ xns" : "Gtk",
236            "items" : [
237             {
238              "listeners" : {
239               "activate" : "()  => {\n    \n       if (_this.project.compilegroups.has_key(\"NEW GROUP\")) {\n        return;\n    }\n      \n       // add the directory..\n       \n       _this.project.compilegroups.set(\"NEW GROUP\", new Project.GtkValaSettings(\"NEW GROUP\"));\n       _this.targets_tree_store.load();\n}"
240              },
241              "* pack" : "add",
242              "xtype" : "MenuItem",
243              "$ xns" : "Gtk",
244              "utf8 label" : "Add Compile Target"
245             },
246             {
247              "* pack" : "add",
248              "xtype" : "SeparatorMenuItem",
249              "$ xns" : "Gtk"
250             },
251             {
252              "listeners" : {
253               "activate" : "()  => {\n    \n     //\n        Gtk.TreeModel mod;\n        Gtk.TreeIter iter;\n        if (!_this.targets_tree.el.get_selection().get_selected(out mod, out iter)) {\n               print(\"nothing selected\\n\");\n            return;\n        }\n\n            \n       // add the directory..\n       \n       \n       GLib.Value val;\n        mod.get_value(iter,0, out val);\n       var fn =  (string) val;\n       \n       print(\"remove: %s\\n\", fn);\n       if (!_this.project.compilegroups.unset(fn)) {\n                  print(\"remove failed\");\n      }\n       _this.targets_tree_store.load();\n}"
254              },
255              "* pack" : "add",
256              "xtype" : "MenuItem",
257              "$ xns" : "Gtk",
258              "utf8 label" : "Remove Target"
259             }
260            ]
261           },
262           {
263            "listeners" : {
264             "button_press_event" : " ( ev) => {\n    //console.log(\"button press?\");\n   \n    \n    if (ev.type != Gdk.EventType.BUTTON_PRESS  || ev.button != 3) {\n        //print(\"click\" + ev.type);\n        return false;\n    }\n    //Gtk.TreePath res;\n    //if (!this.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) {\n    //    return true;\n    //}\n     \n  //  this.el.get_selection().select_path(res);\n     \n      //if (!this.get('/LeftTreeMenu').el)  { \n      //      this.get('/LeftTreeMenu').init(); \n      //  }\n        \n     _this.targets_tree_menu.el.set_screen(Gdk.Screen.get_default());\n     _this.targets_tree_menu.el.show_all();\n      _this.targets_tree_menu.el.popup(null, null, null,  3, ev.time);\n     //   print(\"click:\" + res.path.to_string());\n      return true;\n}",
265             "cursor_changed" : " ( ) => {\n\n    if (this.cursor != \"\") {\n         // save the values..\n     }\n     \n     // load the new values.\n     \n\n         Gtk.TreeModel mod;\n        Gtk.TreeIter iter;\n        if (!this.el.get_selection().get_selected(out mod, out iter)) {\n               print(\"nothing selected\\n\");\n            return;\n        }\n\n            \n       // add the directory..\n       \n       \n       GLib.Value val;\n        mod.get_value(iter,0, out val);\n       var fn =  (string) val;\n       \n       this.cursor = fn;\n       var cg = _this.project.compilegroups.get(fn);\n       _this.build_pack_target.el.set_text(cg.target_bin);\n       _this.build_compile_flags.el.set_text(cg.compile_flags);\n       // load the srouces\n\n\n  }"
266            },
267            "id" : "targets_tree",
268            "# string cursor" : "",
269            "* pack" : "add",
270            "xtype" : "TreeView",
271            "$ xns" : "Gtk",
272            "items" : [
273             {
274              "id" : "targets_tree_store",
275              "* pack" : "set_model",
276              "xtype" : "ListStore",
277              "$ n_columns" : 2,
278              "| void load" : "() {\n \n  this.el.clear();\n  \n    \n     var cg = _this.project.compilegroups;\n     \n   _this.targets_tree.cursor = \"\";\n    Gtk.TreeIter citer;\n    var iter = cg.map_iterator();\n   while(iter.next()) {\n        var key = iter.get_key();\n        if (key == \"_default_\") {\n            continue;\n        }\n    \n         this.el.append(out citer);   \n         \n        this.el.set_value(citer, 0,   key ); // title \n        //this.el.set_value(citer, 1,   items.get(i) );\n    };\n    this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);\n    \n}\n",
279              "$ columns" : "    typeof(string),  // 0 key type\n     typeof(string) // ??\n     ",
280              "$ xns" : "Gtk"
281             },
282             {
283              "utf8 title" : "name",
284              "* init" : " {\n     this.el.add_attribute(_this.targets_render.el , \"text\", 0 );\n }",
285              "* pack" : "append_column",
286              "xtype" : "TreeViewColumn",
287              "gboolean resizable" : true,
288              "$ xns" : "Gtk",
289              "items" : [
290               {
291                "listeners" : {
292                 "edited" : "  (path, newtext) => {\n     \n     Gtk.TreeIter  iter;\n        _this.targets_tree_store.el.get_iter(out iter, new Gtk.TreePath.from_string(path));\n       GLib.Value gval;\n        _this.targets_tree_store.el.get_value(iter,0, out gval);\n        var oldval = (string)gval;\n       if (oldval == newtext) {\n          return;\n        }\n         var cg = _this.project.compilegroups.get(oldval);\n        cg.name = newtext;\n        _this.project.compilegroups.unset(oldval);\n        _this.project.compilegroups.set(newtext, cg);\n    _this.targets_tree_store.load();\n  }"
293                },
294                "id" : "targets_render",
295                "* pack" : "pack_start,false",
296                "xtype" : "CellRendererText",
297                "$ xns" : "Gtk",
298                "gboolean editable" : true
299               }
300              ]
301             }
302            ]
303           }
304          ]
305         },
306         {
307          "xtype" : "VBox",
308          "* pack" : "add2",
309          "string id" : "set_vbox",
310          "gboolean homogeneous" : false,
311          "$ xns" : "Gtk",
312          "items" : [
313           {
314            "xtype" : "Label",
315            "* pack" : "pack_start,false,false,0",
316            "$ xns" : "Gtk",
317            "utf8 label" : "target filename"
318           },
319           {
320            "listeners" : {
321             "changed" : "()  => {\n        if (_this.targets_tree.cursor.length < 1) {\n        return;\n    }\n    _this.project.compilegroups.get(_this.targets_tree.cursor).target_bin = this.el.text;\n}"
322            },
323            "id" : "build_pack_target",
324            "* pack" : "pack_start,false,false,0",
325            "xtype" : "Entry",
326            "$ xns" : "Gtk"
327           },
328           {
329            "xtype" : "Label",
330            "* pack" : "pack_start,false,false,0",
331            "$ xns" : "Gtk",
332            "utf8 label" : "compile flags"
333           },
334           {
335            "listeners" : {
336             "changed" : "() => {\n    if (_this.targets_tree.cursor.length < 1) {\n        return;\n    }\n    _this.project.compilegroups.get(_this.targets_tree.cursor).compile_flags = this.el.text;\n}"
337            },
338            "id" : "build_compile_flags",
339            "* pack" : "pack_start,false,false,0",
340            "xtype" : "Entry",
341            "$ xns" : "Gtk"
342           },
343           {
344            "xtype" : "Label",
345            "* pack" : "pack_start,false,false,0",
346            "$ xns" : "Gtk",
347            "utf8 label" : "Files to compile"
348           },
349           {
350            "* pack" : "pack_start,true,true,0",
351            "xtype" : "ScrolledWindow",
352            "$ xns" : "Gtk",
353            "items" : [
354             {
355              "xtype" : "TreeView",
356              "string id" : "files_tree",
357              "$ xns" : "Gtk",
358              "items" : [
359               {
360                "id" : "files_tree_store",
361                "* pack" : "set_model",
362                "xtype" : "ListStore",
363                "$ n_columns" : 2,
364                "| void load" : "() {\n \n  this.el.clear();\n  \n    \n     var def = _this.project.compilegroups.get(\"_default_\");\n     var items  = def.sources;\n     \n \n    Gtk.TreeIter citer;\n\n    for(var i =0 ; i < items.size; i++) {\n         this.el.append(out citer);   \n         \n        this.el.set_value(citer, 0,   items.get(i) ); // title \n        this.el.set_value(citer, 1,   \"dir\"); // type         \n        this.el.set_value(citer, 2,   false ); // checked \n        /*\n        var files = def.files(items.get(i));\n        \n         for(var j =0 ; j < files.size; j++) {\n            this.el.append(out citer);   \n         \n            this.el.set_value(citer, 0,   files.get(j) ); // title \n            this.el.set_value(citer, 1,   \"file\"); // type         \n            this.el.set_value(citer, 2,   false ); // checked \n\n        }\n        */\n        \n        //this.el.set_value(citer, 1,   items.get(i) );\n    }\n    this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);\n    \n}\n ",
365                "$ columns" : "    typeof(string),  // 0 file name\n     typeof(string), // type (dir orfile)\n     typeof(bool)  // is checked.\n     ",
366                "$ xns" : "Gtk"
367               },
368               {
369                "utf8 title" : "name",
370                "* init" : "/* this.el.add_attribute(_this.files_render.el , \"markup\", 2 );\n// this.el.add_attribute(_this.files_render.el , \"text\", 1 ); */\n \n",
371                "* pack" : "append_column",
372                "xtype" : "TreeViewColumn",
373                "gboolean resizable" : true,
374                "$ xns" : "Gtk",
375                "items" : [
376                 {
377                  "id" : "files_render",
378                  "xtype" : "CellRendererText",
379                  "* pack" : "pack_start,false",
380                  "$ xns" : "Gtk"
381                 }
382                ]
383               },
384               {
385                "utf8 title" : "use",
386                "* init" : "/*\n\n this.el.add_attribute(_this.packages_render_use.el , \"active\", 1 );\n \n */\n ",
387                "* pack" : "append_column",
388                "xtype" : "TreeViewColumn",
389                "gboolean resizable" : false,
390                "$ xns" : "Gtk",
391                "gint fixed_width" : 50,
392                "items" : [
393                 {
394                  "listeners" : {
395                   "toggled" : "(  path_string) =>  { \n    var m = _this.default_packages_tree_store.el;\n   Gtk.TreeIter iter;\n   Gtk.TreePath path = new Gtk.TreePath.from_string (path_string);\n   m.get_iter (out iter, path);\n   GLib.Value val;\n   m.get_value(iter, 1, out val);\n   m.set_value(iter, 1,  ((bool) val) ? false :true); \n     GLib.Value fval;  \n   m.get_value(iter, 0, out fval);\n   var fn = (string)fval;\n    \n    var def = _this.project.compilegroups.get(\"_default_\");\n    var items  = def.packages;\n    if ((bool)val) {\n        // renive\n        items.remove(fn);\n    } else {\n        items.add(fn);\n    }\n    \n}"
396                  },
397                  "id" : "files_render_use",
398                  "* pack" : "pack_start,false",
399                  "xtype" : "CellRendererToggle",
400                  "$ xns" : "Gtk",
401                  "gboolean activatable" : true
402                 }
403                ]
404               }
405              ]
406             }
407            ]
408           }
409          ]
410         }
411        ]
412       }
413      ]
414     }
415    ]
416   }
417  ]
418 }