Fix #7298 - combo box text enry support
[roobuilder] / src / Builder4 / ValaProjectSettingsPopover.bjs
1 {
2  "build_module" : "builder",
3  "items" : [
4   {
5    "$ xns" : "Gtk",
6    "Gtk.PositionType position" : "Gtk.PositionType.RIGHT",
7    "Project.Gtk project" : "null",
8    "Xcls_MainWindow window" : "null",
9    "bool done" : false,
10    "bool modal" : true,
11    "items" : [
12     {
13      "$ xns" : "Gtk",
14      "* pack" : "add",
15      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
16      "bool hexpand" : true,
17      "bool vexpand" : true,
18      "items" : [
19       {
20        "$ xns" : "Gtk",
21        "* pack" : "add",
22        "string title" : "Change Vala Project Compile settings",
23        "xtype" : "HeaderBar"
24       },
25       {
26        "$ xns" : "Gtk",
27        "* pack" : "pack_start,true,true,0",
28        "items" : [
29         {
30          "$ xns" : "Gtk",
31          "* pack" : false,
32          "id" : "label_global",
33          "utf8 label" : "Global",
34          "xtype" : "Label"
35         },
36         {
37          "$ xns" : "Gtk",
38          "* pack" : false,
39          "id" : "label_targets",
40          "utf8 label" : "Targets",
41          "xtype" : "Label"
42         },
43         {
44          "$ xns" : "Gtk",
45          "* pack" : "append_page,_this.label_global.el",
46          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
47          "gboolean homogeneous" : false,
48          "items" : [
49           {
50            "$ xns" : "Gtk",
51            "* pack" : "pack_start,false,false,0",
52            "utf8 label" : "compile flags",
53            "xtype" : "Label"
54           },
55           {
56            "$ xns" : "Gtk",
57            "* pack" : "pack_start,false,false,0",
58            "id" : "compile_flags",
59            "listeners" : {
60             "changed" : [
61              "() => {",
62              "    ",
63              "   _this.project.compilegroups.get(\"_default_\").compile_flags = this.el.text;",
64              "   _this.project.writeConfig();",
65              "//    _this.project.save();",
66              "",
67              "}"
68             ]
69            },
70            "utf8 placeholder_text" : "eg. -g --valasrc $BASEDIR ",
71            "xtype" : "Entry"
72           },
73           {
74            "$ xns" : "Gtk",
75            "* pack" : "pack_start,true,true,0",
76            "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
77            "int position" : 300,
78            "items" : [
79             {
80              "$ xns" : "Gtk",
81              "* pack" : "add",
82              "bool hexpand" : true,
83              "items" : [
84               {
85                "$ xns" : "Gtk",
86                "* pack" : "add",
87                "gboolean headers_visible" : true,
88                "items" : [
89                 {
90                  "$ columns" : [
91                   "    typeof(string),  // 0 key type",
92                   "      typeof(bool)"
93                  ],
94                  "$ n_columns" : 2,
95                  "$ xns" : "Gtk",
96                  "* pack" : "set_model",
97                  "id" : "default_packages_tree_store",
98                  "xtype" : "ListStore",
99                  "| void load" : [
100                   "() {",
101                   " ",
102                   "    var def = _this.project.compilegroups.get(\"_default_\");",
103                   "    var items  = def.packages;",
104                   "    ",
105                   "    this.el.clear();",
106                   "    var pal = (Palete.Gtk) _this.project.palete;",
107                   "    var pkgs = pal.packages(_this.project);",
108                   "    print(\"ValaProjectSettings:packages load %d\\n\", pkgs.size);",
109                   "",
110                   "    Gtk.TreeIter citer;",
111                   "",
112                   "    for(var i =0 ; i < pkgs.size; i++) {",
113                   "         this.el.append(out citer);   ",
114                   "         ",
115                   "        this.el.set_value(citer, 0,   pkgs.get(i) ); // title ",
116                   "        this.el.set_value(citer, 1,   items.contains(pkgs.get(i)) );",
117                   "    }",
118                   "    this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);",
119                   "    ",
120                   "}",
121                   ""
122                  ]
123                 },
124                 {
125                  "$ xns" : "Gtk",
126                  "* init" : [
127                   " ",
128                   " this.el.add_attribute(_this.packages_render.el , \"text\", 0 );",
129                   "  "
130                  ],
131                  "* pack" : "append_column",
132                  "gboolean expand" : true,
133                  "gboolean resizable" : true,
134                  "items" : [
135                   {
136                    "$ xns" : "Gtk",
137                    "* pack" : "pack_start,false",
138                    "id" : "packages_render",
139                    "xtype" : "CellRendererText"
140                   }
141                  ],
142                  "utf8 title" : "package name",
143                  "xtype" : "TreeViewColumn"
144                 },
145                 {
146                  "$ xns" : "Gtk",
147                  "* init" : [
148                   "{",
149                   " this.el.add_attribute(_this.packages_render_use.el , \"active\", 1 );",
150                   " }"
151                  ],
152                  "* pack" : "append_column",
153                  "gboolean resizable" : false,
154                  "gint fixed_width" : 50,
155                  "items" : [
156                   {
157                    "$ xns" : "Gtk",
158                    "* pack" : "pack_start,false",
159                    "gboolean activatable" : true,
160                    "id" : "packages_render_use",
161                    "listeners" : {
162                     "toggled" : [
163                      "(  path_string) =>  { ",
164                      "    var m = _this.default_packages_tree_store.el;",
165                      "   Gtk.TreeIter iter;",
166                      "   Gtk.TreePath path = new Gtk.TreePath.from_string (path_string);",
167                      "   m.get_iter (out iter, path);",
168                      "   GLib.Value val;",
169                      "   m.get_value(iter, 1, out val);",
170                      "   m.set_value(iter, 1,  ((bool) val) ? false :true); ",
171                      "     GLib.Value fval;  ",
172                      "   m.get_value(iter, 0, out fval);",
173                      "   var fn = (string)fval;",
174                      "    ",
175                      "    var def = _this.project.compilegroups.get(\"_default_\");",
176                      "    var items  = def.packages;",
177                      "    if ((bool)val) {",
178                      "        // renive",
179                      "        items.remove(fn);",
180                      "    } else {",
181                      "        items.add(fn);",
182                      "    }",
183                      "    ",
184                      "}"
185                     ]
186                    },
187                    "xtype" : "CellRendererToggle"
188                   }
189                  ],
190                  "utf8 title" : "use",
191                  "xtype" : "TreeViewColumn"
192                 }
193                ],
194                "string id" : "default_packages_tree",
195                "xtype" : "TreeView"
196               }
197              ],
198              "xtype" : "ScrolledWindow"
199             },
200             {
201              "$ xns" : "Gtk",
202              "* pack" : "add2",
203              "bool hexpand" : true,
204              "items" : [
205               {
206                "$ xns" : "Gtk",
207                "* pack" : "add",
208                "gboolean headers_visible" : true,
209                "id" : "default_directory_tree",
210                "items" : [
211                 {
212                  "$ columns" : [
213                   "    typeof(string)",
214                   "     "
215                  ],
216                  "$ n_columns" : 1,
217                  "$ xns" : "Gtk",
218                  "* pack" : "set_model",
219                  "id" : "default_directory_tree_store",
220                  "xtype" : "ListStore",
221                  "| void load" : [
222                   "() {",
223                   " ",
224                   "  this.el.clear();",
225                   "  ",
226                   "    ",
227                   "     var def = _this.project.compilegroups.get(\"_default_\");",
228                   "     var items  = def.sources;",
229                   "     ",
230                   " ",
231                   "    Gtk.TreeIter citer;",
232                   "",
233                   "    for(var i =0 ; i < items.size; i++) {",
234                   "         this.el.append(out citer);   ",
235                   "         ",
236                   "        this.el.set_value(citer, 0,   items.get(i) ); // title ",
237                   "        //this.el.set_value(citer, 1,   items.get(i) );",
238                   "    }",
239                   "    this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);",
240                   "    ",
241                   "}",
242                   ""
243                  ]
244                 },
245                 {
246                  "$ xns" : "Gtk",
247                  "* init" : [
248                   "",
249                   " this.el.add_attribute(_this.directory_render.el , \"text\", 0 );",
250                   "   "
251                  ],
252                  "* pack" : "append_column",
253                  "gboolean resizable" : true,
254                  "items" : [
255                   {
256                    "$ xns" : "Gtk",
257                    "* pack" : "pack_start,false",
258                    "id" : "directory_render",
259                    "xtype" : "CellRendererText"
260                   }
261                  ],
262                  "utf8 title" : "Available Directories (right click to add)",
263                  "xtype" : "TreeViewColumn"
264                 }
265                ],
266                "listeners" : {
267                 "button_press_event" : [
268                  " ( ev) => {",
269                  "    //console.log(\"button press?\");",
270                  "   ",
271                  "    ",
272                  "    if (ev.type != Gdk.EventType.BUTTON_PRESS  || ev.button != 3) {",
273                  "        //print(\"click\" + ev.type);",
274                  "        return false;",
275                  "    }",
276                  "    //Gtk.TreePath res;",
277                  "    //if (!this.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) {",
278                  "    //    return true;",
279                  "    //}",
280                  "     ",
281                  "  //  this.el.get_selection().select_path(res);",
282                  "     ",
283                  "      //if (!this.get('/LeftTreeMenu').el)  { ",
284                  "      //      this.get('/LeftTreeMenu').init(); ",
285                  "      //  }",
286                  "        ",
287                  "     _this.default_directory_menu.el.set_screen(Gdk.Screen.get_default());",
288                  "     _this.default_directory_menu.el.show_all();",
289                  "      _this.default_directory_menu.el.popup(null, null, null,  3, ev.time);",
290                  "     //   print(\"click:\" + res.path.to_string());",
291                  "      return true;",
292                  "}"
293                 ]
294                },
295                "xtype" : "TreeView"
296               },
297               {
298                "$ xns" : "Gtk",
299                "id" : "default_directory_menu",
300                "items" : [
301                 {
302                  "$ xns" : "Gtk",
303                  "* pack" : "add",
304                  "listeners" : {
305                   "activate" : [
306                    "()  => {",
307                    "    ",
308                    "    var  chooser = new Gtk.FileChooserDialog (",
309                    "\t\"Add a directory\", _this.window.el, Gtk.FileChooserAction.SELECT_FOLDER ,",
310                    "\t\"_Cancel\",",
311                    "\tGtk.ResponseType.CANCEL,",
312                    "\t\"_Add\",",
313                    "\tGtk.ResponseType.ACCEPT);",
314                    "    if (chooser.run () != Gtk.ResponseType.ACCEPT) {",
315                    "        chooser.close ();",
316                    "           return;",
317                    "       }",
318                    "       chooser.close ();",
319                    "       // add the directory..",
320                    "       var fn = _this.project.relPath(chooser.get_filename());",
321                    "       _this.project.compilegroups.get(\"_default_\").sources.add(fn);",
322                    "       _this.default_directory_tree_store.load();",
323                    "}"
324                   ]
325                  },
326                  "utf8 label" : "Add Directory",
327                  "xtype" : "MenuItem"
328                 },
329                 {
330                  "$ xns" : "Gtk",
331                  "* pack" : "add",
332                  "listeners" : {
333                   "activate" : [
334                    "()  => {",
335                    "    ",
336                    "    var  chooser = new Gtk.FileChooserDialog (",
337                    "\t\"Add a directory\", _this.window.el, Gtk.FileChooserAction.OPEN ,",
338                    "\t\"_Cancel\",",
339                    "\tGtk.ResponseType.CANCEL,",
340                    "\t\"_Add\",",
341                    "\tGtk.ResponseType.ACCEPT);",
342                    "    if (chooser.run () != Gtk.ResponseType.ACCEPT) {",
343                    "        chooser.close ();",
344                    "           return;",
345                    "       }",
346                    "       chooser.close ();",
347                    "       // add the directory..",
348                    "       var fn = _this.project.relPath(chooser.get_filename());",
349                    "       _this.project.compilegroups.get(\"_default_\").sources.add(fn);",
350                    "       _this.default_directory_tree_store.load();",
351                    "}"
352                   ]
353                  },
354                  "utf8 label" : "Add File",
355                  "xtype" : "MenuItem"
356                 },
357                 {
358                  "$ xns" : "Gtk",
359                  "* pack" : "add",
360                  "xtype" : "SeparatorMenuItem"
361                 },
362                 {
363                  "$ xns" : "Gtk",
364                  "* pack" : "add",
365                  "listeners" : {
366                   "activate" : [
367                    "()  => {",
368                    "    ",
369                    "     //",
370                    "        Gtk.TreeModel mod;",
371                    "        Gtk.TreeIter iter;",
372                    "        if (!_this.default_directory_tree.el.get_selection().get_selected(out mod, out iter)) {",
373                    "               print(\"nothing selected\\n\");",
374                    "            return;",
375                    "        }",
376                    "",
377                    "            ",
378                    "       // add the directory..",
379                    "       ",
380                    "       ",
381                    "       GLib.Value val;",
382                    "        mod.get_value(iter,0, out val);",
383                    "       var fn =  (string) val;",
384                    "       ",
385                    "       print(\"remove: %s\\n\", fn);",
386                    "       if (!_this.project.compilegroups.get(\"_default_\").sources.remove(fn)) {",
387                    "                  print(\"remove failed\");",
388                    "              }",
389                    "       _this.default_directory_tree_store.load();",
390                    "}"
391                   ]
392                  },
393                  "utf8 label" : "Remove File/Directory",
394                  "xtype" : "MenuItem"
395                 }
396                ],
397                "xtype" : "Menu"
398               }
399              ],
400              "xtype" : "ScrolledWindow"
401             }
402            ],
403            "xtype" : "Paned"
404           }
405          ],
406          "xtype" : "Box"
407         },
408         {
409          "$ xns" : "Gtk",
410          "* pack" : "append_page,_this.label_targets.el",
411          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
412          "gint position" : 300,
413          "items" : [
414           {
415            "$ xns" : "Gtk",
416            "* init" : [
417             "{  ",
418             "this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
419             "",
420             "}",
421             ""
422            ],
423            "* pack" : "add1",
424            "items" : [
425             {
426              "$ xns" : "Gtk",
427              "* pack" : "add",
428              "id" : "targets_tree_menu",
429              "items" : [
430               {
431                "$ xns" : "Gtk",
432                "* pack" : "add",
433                "listeners" : {
434                 "activate" : [
435                  "()  => {",
436                  "    ",
437                  "       if (_this.project.compilegroups.has_key(\"NEW GROUP\")) {",
438                  "        return;",
439                  "    }",
440                  "      ",
441                  "       // add the directory..",
442                  "       ",
443                  "       _this.project.compilegroups.set(\"NEW GROUP\", new Project.GtkValaSettings(\"NEW GROUP\"));",
444                  "       _this.targets_tree_store.load();",
445                  "}"
446                 ]
447                },
448                "utf8 label" : "Add Compile Target",
449                "xtype" : "MenuItem"
450               },
451               {
452                "$ xns" : "Gtk",
453                "* pack" : "add",
454                "xtype" : "SeparatorMenuItem"
455               },
456               {
457                "$ xns" : "Gtk",
458                "* pack" : "add",
459                "listeners" : {
460                 "activate" : [
461                  "()  => {",
462                  "    ",
463                  "     //",
464                  "        Gtk.TreeModel mod;",
465                  "        Gtk.TreeIter iter;",
466                  "        if (!_this.targets_tree.el.get_selection().get_selected(out mod, out iter)) {",
467                  "               print(\"nothing selected\\n\");",
468                  "            return;",
469                  "        }",
470                  "",
471                  "            ",
472                  "       // add the directory..",
473                  "       ",
474                  "       ",
475                  "       GLib.Value val;",
476                  "        mod.get_value(iter,0, out val);",
477                  "       var fn =  (string) val;",
478                  "       ",
479                  "       print(\"remove: %s\\n\", fn);",
480                  "       if (!_this.project.compilegroups.unset(fn)) {",
481                  "                  print(\"remove failed\");",
482                  "      }",
483                  "       _this.targets_tree_store.load();",
484                  "}"
485                 ]
486                },
487                "utf8 label" : "Remove Target",
488                "xtype" : "MenuItem"
489               }
490              ],
491              "xtype" : "Menu"
492             },
493             {
494              "# string cursor" : "",
495              "$ xns" : "Gtk",
496              "* pack" : "add",
497              "id" : "targets_tree",
498              "items" : [
499               {
500                "$ columns" : [
501                 "    typeof(string),  // 0 key type",
502                 "     typeof(string) // ??",
503                 "     "
504                ],
505                "$ n_columns" : 2,
506                "$ xns" : "Gtk",
507                "* pack" : "set_model",
508                "id" : "targets_tree_store",
509                "xtype" : "ListStore",
510                "| void load" : [
511                 "() {",
512                 " ",
513                 "  this.el.clear();",
514                 "  ",
515                 "    ",
516                 "     var cg = _this.project.compilegroups;",
517                 "     ",
518                 "   _this.targets_tree.cursor = \"\";",
519                 "    Gtk.TreeIter citer;",
520                 "    var iter = cg.map_iterator();",
521                 "   while(iter.next()) {",
522                 "        var key = iter.get_key();",
523                 "        if (key == \"_default_\") {",
524                 "            continue;",
525                 "        }",
526                 "    ",
527                 "         this.el.append(out citer);   ",
528                 "         ",
529                 "        this.el.set_value(citer, 0,   key ); // title ",
530                 "        //this.el.set_value(citer, 1,   items.get(i) );",
531                 "    };",
532                 "    this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);",
533                 "    _this.set_vbox.el.hide();",
534                 "}",
535                 ""
536                ]
537               },
538               {
539                "$ xns" : "Gtk",
540                "* init" : [
541                 " {",
542                 "     this.el.add_attribute(_this.targets_render.el , \"text\", 0 );",
543                 " }"
544                ],
545                "* pack" : "append_column",
546                "gboolean resizable" : true,
547                "items" : [
548                 {
549                  "$ xns" : "Gtk",
550                  "* pack" : "pack_start,false",
551                  "gboolean editable" : true,
552                  "id" : "targets_render",
553                  "listeners" : {
554                   "edited" : [
555                    "  (path, newtext) => {",
556                    "     ",
557                    "     Gtk.TreeIter  iter;",
558                    "        _this.targets_tree_store.el.get_iter(out iter, new Gtk.TreePath.from_string(path));",
559                    "       GLib.Value gval;",
560                    "        _this.targets_tree_store.el.get_value(iter,0, out gval);",
561                    "        var oldval = (string)gval;",
562                    "       if (oldval == newtext) {",
563                    "          return;",
564                    "        }",
565                    "         var cg = _this.project.compilegroups.get(oldval);",
566                    "        cg.name = newtext;",
567                    "        _this.project.compilegroups.unset(oldval);",
568                    "        _this.project.compilegroups.set(newtext, cg);",
569                    "       _this.targets_tree_store.load();",
570                    "  }"
571                   ]
572                  },
573                  "xtype" : "CellRendererText"
574                 }
575                ],
576                "utf8 title" : "name",
577                "xtype" : "TreeViewColumn"
578               }
579              ],
580              "listeners" : {
581               "button_press_event" : [
582                " ( ev) => {",
583                "    //console.log(\"button press?\");",
584                "   ",
585                "    ",
586                "    if (ev.type != Gdk.EventType.BUTTON_PRESS  || ev.button != 3) {",
587                "        //print(\"click\" + ev.type);",
588                "        return false;",
589                "    }",
590                "    //Gtk.TreePath res;",
591                "    //if (!this.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) {",
592                "    //    return true;",
593                "    //}",
594                "     ",
595                "  //  this.el.get_selection().select_path(res);",
596                "     ",
597                "      //if (!this.get('/LeftTreeMenu').el)  { ",
598                "      //      this.get('/LeftTreeMenu').init(); ",
599                "      //  }",
600                "        ",
601                "     _this.targets_tree_menu.el.set_screen(Gdk.Screen.get_default());",
602                "     _this.targets_tree_menu.el.show_all();",
603                "      _this.targets_tree_menu.el.popup(null, null, null,  3, ev.time);",
604                "     //   print(\"click:\" + res.path.to_string());",
605                "      return true;",
606                "}"
607               ],
608               "cursor_changed" : [
609                " ( ) => {",
610                "",
611                "    if (this.cursor != \"\") {",
612                "         // save the values..",
613                "     }",
614                "     ",
615                "     // load the new values.",
616                "     ",
617                "",
618                "         Gtk.TreeModel mod;",
619                "        Gtk.TreeIter iter;",
620                "        if (!this.el.get_selection().get_selected(out mod, out iter)) {",
621                "            print(\"nothing selected\\n\");",
622                "            // should disable the right hand side..",
623                "            _this.set_vbox.el.hide();",
624                "            return;",
625                "        }",
626                "        _this.set_vbox.el.show();",
627                "            ",
628                "       // add the directory..",
629                "       ",
630                "       ",
631                "       GLib.Value val;",
632                "        mod.get_value(iter,0, out val);",
633                "       var fn =  (string) val;",
634                "       ",
635                "       this.cursor = fn;",
636                "       var cg = _this.project.compilegroups.get(fn);",
637                "       ",
638                "       _this.build_pack_target.el.set_text(cg.target_bin);",
639                "       _this.build_compile_flags.el.set_text(cg.compile_flags);",
640                "\t\t_this.build_execute_args.el.set_text(cg.execute_args);",
641                "       ",
642                "       _this.set_vbox.cgroup = cg;",
643                "       _this.files_tree_store.update();",
644                "       ",
645                "       // load the srouces",
646                "",
647                "",
648                "  }"
649               ]
650              },
651              "xtype" : "TreeView"
652             }
653            ],
654            "xtype" : "ScrolledWindow"
655           },
656           {
657            "# Project.GtkValaSettings cgroup" : "null",
658            "$ xns" : "Gtk",
659            "* pack" : "add2",
660            "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
661            "gboolean homogeneous" : false,
662            "id" : "set_vbox",
663            "items" : [
664             {
665              "$ xns" : "Gtk",
666              "* pack" : "pack_start,false,false,0",
667              "utf8 label" : "target filename",
668              "xtype" : "Label"
669             },
670             {
671              "$ xns" : "Gtk",
672              "* pack" : "pack_start,false,false,0",
673              "id" : "build_pack_target",
674              "listeners" : {
675               "changed" : [
676                "()  => {",
677                "        if (_this.targets_tree.cursor.length < 1) {",
678                "        return;",
679                "    }",
680                "    _this.project.compilegroups.get(_this.targets_tree.cursor).target_bin = this.el.text;",
681                "}"
682               ]
683              },
684              "xtype" : "Entry"
685             },
686             {
687              "$ xns" : "Gtk",
688              "* pack" : "pack_start,false,false,0",
689              "utf8 label" : "compile flags",
690              "xtype" : "Label"
691             },
692             {
693              "$ xns" : "Gtk",
694              "* pack" : "pack_start,false,false,0",
695              "id" : "build_compile_flags",
696              "listeners" : {
697               "changed" : [
698                "() => {",
699                "    if (_this.targets_tree.cursor.length < 1) {",
700                "        return;",
701                "    }",
702                "    _this.project.compilegroups.get(_this.targets_tree.cursor).compile_flags = this.el.text;",
703                "}"
704               ]
705              },
706              "xtype" : "Entry"
707             },
708             {
709              "$ xns" : "Gtk",
710              "* pack" : "pack_start,false,false,0",
711              "utf8 label" : "test argments - when run after a build",
712              "xtype" : "Label"
713             },
714             {
715              "$ xns" : "Gtk",
716              "* pack" : "pack_start,false,false,0",
717              "id" : "build_execute_args",
718              "listeners" : {
719               "changed" : [
720                "() => {",
721                "    if (_this.targets_tree.cursor.length < 1) {",
722                "        return;",
723                "    }",
724                "    _this.project.compilegroups.get(_this.targets_tree.cursor).execute_args = this.el.text;",
725                "}"
726               ]
727              },
728              "string placeholder_text" : "eg.  -f somefile -g ",
729              "xtype" : "Entry"
730             },
731             {
732              "$ xns" : "Gtk",
733              "* pack" : "pack_start,false,false,0",
734              "utf8 label" : "Files to compile",
735              "xtype" : "Label"
736             },
737             {
738              "$ xns" : "Gtk",
739              "* pack" : "pack_start,true,true,0",
740              "items" : [
741               {
742                "$ xns" : "Gtk",
743                "* pack" : "add",
744                "items" : [
745                 {
746                  "$ columns" : [
747                   "    typeof(string),  // 0 file name",
748                   "        typeof(string),  // 0 basename",
749                   "     typeof(string), // type (dir orfile)",
750                   "     typeof(bool)  // is checked.",
751                   "     "
752                  ],
753                  "$ n_columns" : 4,
754                  "$ xns" : "Gtk",
755                  "* pack" : "set_model",
756                  "id" : "files_tree_store",
757                  "xtype" : "ListStore",
758                  "| void load" : [
759                   "() {",
760                   " ",
761                   "      this.el.clear();",
762                   "  ",
763                   "    ",
764                   "     var def = _this.project.compilegroups.get(\"_default_\");",
765                   "     var items  = def.sources;",
766                   "     ",
767                   "     ",
768                   "     ",
769                   "     ",
770                   " ",
771                   "    Gtk.TreeIter citer;",
772                   "",
773                   "    for(var i =0 ; i < items.size; i++) {",
774                   "    ",
775                   "         var files = _this.project.filesForCompile(items.get(i), false);",
776                   "         if (files.size < 1) {",
777                   "            continue;",
778                   "         }",
779                   "    ",
780                   "         this.el.append(out citer);   ",
781                   "         ",
782                   "        this.el.set_value(citer, 0,   items.get(i) ); // title ",
783                   "        this.el.set_value(citer, 1,   \"<span foreground=\\\"green\\\" font_weight=\\\"bold\\\">\" + ",
784                   "                    GLib.Markup.escape_text(items.get(i)) + \"</span>\"",
785                   "            ); // title ",
786                   "        print(\"ADD item %s\", items.get(i));",
787                   "        this.el.set_value(citer, 2,   \"dir\"); // type         ",
788                   "        this.el.set_value(citer, 3,   false ); // checked ",
789                   "",
790                   "       ",
791                   "        ",
792                   "         for(var j =0 ; j < files.size; j++) {",
793                   "            this.el.append(out citer);   ",
794                   "             print(\"ADD item %s\", files.get(j));",
795                   "            this.el.set_value(citer, 0,   files.get(j) ); // title ",
796                   "            this.el.set_value(citer, 1,   GLib.Markup.escape_text( Path.get_basename (files.get(j))) ); // title             ",
797                   "            this.el.set_value(citer, 2,   \"file\"); // type         ",
798                   "            this.el.set_value(citer, 3,   false ); // checked ",
799                   "",
800                   "        }",
801                   "        ",
802                   "        ",
803                   "        //this.el.set_value(citer, 1,   items.get(i) );",
804                   "    }",
805                   "    this.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);",
806                   "    if (_this.set_vbox.cgroup == null) {",
807                   "\t\t_this.set_vbox.el.set_sensitive(false);",
808                   "    ",
809                   "    }",
810                   "}",
811                   " "
812                  ],
813                  "| void update" : [
814                   "() {",
815                   "",
816                   "",
817                   "    Gtk.TreeIter citer;",
818                   "",
819                   "    for(var i =0 ; i < this.el.iter_n_children(null); i++) {",
820                   "        this.el.iter_nth_child(out citer,null,i);",
821                   "",
822                   "        GLib.Value val;",
823                   "        this.el.get_value(citer,0, out val);",
824                   "        var fn = (string) val;",
825                   "        ",
826                   "        var active = false;",
827                   "        if (_this.set_vbox.cgroup.sources.contains(fn)) {",
828                   "            active = true;",
829                   "        }",
830                   "        ",
831                   "        this.el.set_value(citer, 3,   active ); // checked ",
832                   "    }",
833                   "",
834                   "     _this.set_vbox.el.set_sensitive(true);",
835                   "}",
836                   ""
837                  ],
838                  "| void updateDir" : [
839                   "(string dname, bool bval) {",
840                   "  ",
841                   "  Gtk.TreeIter citer;",
842                   "",
843                   "    var cg =   _this.set_vbox.cgroup;",
844                   "  for(var i =0 ; i < this.el.iter_n_children(null); i++) {",
845                   "        this.el.iter_nth_child(out citer,null,i);",
846                   "",
847                   "        GLib.Value val;",
848                   "        this.el.get_value(citer,0, out val);",
849                   "        var fn = (string) val;",
850                   "        ",
851                   "        if ( Path.get_dirname (fn) == dname) {",
852                   "        ",
853                   "            this.el.set_value(citer, 3,   bval ); // checked ",
854                   "           ",
855                   "     ",
856                   "     ",
857                   "            if (!bval) {",
858                   "                // renive",
859                   "                if (cg.sources.contains(fn)) {",
860                   "                    cg.sources.remove(fn);",
861                   "                }",
862                   "            } else {",
863                   "                if (!cg.sources.contains(fn)) {",
864                   "                    cg.sources.add(fn);",
865                   "                }",
866                   "            }",
867                   "            ",
868                   "            ",
869                   "        }",
870                   "    }",
871                   "",
872                   "}",
873                   ""
874                  ]
875                 },
876                 {
877                  "$ xns" : "Gtk",
878                  "* init" : [
879                   "",
880                   " this.el.add_attribute(_this.files_render.el , \"markup\", 1 ); // basnemae",
881                   " ",
882                   "/*  this.el.add_attribute(_this.files_render.el , \"markup\", 2 );",
883                   "*/"
884                  ],
885                  "* pack" : "append_column",
886                  "gboolean resizable" : true,
887                  "items" : [
888                   {
889                    "$ xns" : "Gtk",
890                    "* pack" : "pack_start,false",
891                    "id" : "files_render",
892                    "xtype" : "CellRendererText"
893                   }
894                  ],
895                  "utf8 title" : "name",
896                  "xtype" : "TreeViewColumn"
897                 },
898                 {
899                  "$ xns" : "Gtk",
900                  "* init" : [
901                   "{",
902                   " this.el.add_attribute(_this.files_render_use.el , \"active\", 3 );",
903                   " }"
904                  ],
905                  "* pack" : "append_column",
906                  "gboolean resizable" : false,
907                  "gint fixed_width" : 50,
908                  "items" : [
909                   {
910                    "$ xns" : "Gtk",
911                    "* pack" : "pack_start,false",
912                    "gboolean activatable" : true,
913                    "id" : "files_render_use",
914                    "listeners" : {
915                     "toggled" : [
916                      "(  path_string) =>  { ",
917                      "",
918                      "",
919                      "",
920                      "    var m = _this.files_tree_store.el;",
921                      "   Gtk.TreeIter iter;",
922                      "   Gtk.TreePath path = new Gtk.TreePath.from_string (path_string);",
923                      "   m.get_iter (out iter, path);",
924                      "   GLib.Value val;",
925                      "   m.get_value(iter, 3, out val);",
926                      "   m.set_value(iter, 3,  ((bool) val) ? false :true); ",
927                      "   ",
928                      "   // type.",
929                      "   GLib.Value ftval;  ",
930                      "   m.get_value(iter, 2, out ftval);",
931                      "   var ftype = (string)ftval;   ",
932                      "   ",
933                      "   // full name...  ",
934                      "   GLib.Value fval;     ",
935                      "   m.get_value(iter, 0, out fval);",
936                      "   var fn = (string)fval;",
937                      "    ",
938                      "    ",
939                      "    var cg =   _this.set_vbox.cgroup;",
940                      "    // what's the sleected target?",
941                      "    // update the list..",
942                      "    // if ftype is a dir == then toggle all the bellow.",
943                      "    ",
944                      "    if (ftype == \"dir\") {",
945                      "        _this.files_tree_store.updateDir(fn,  ((bool) val) ? false :true);",
946                      "    }",
947                      "    ",
948                      "    // if ftype is a file .. see if all the files in that directory are check and check the dir.",
949                      "",
950                      "     ",
951                      "    if ((bool)val) {",
952                      "        // renive",
953                      "        cg.sources.remove(fn);",
954                      "    } else {",
955                      "        cg.sources.add(fn);",
956                      "    }",
957                      "    ",
958                      "}"
959                     ]
960                    },
961                    "xtype" : "CellRendererToggle"
962                   }
963                  ],
964                  "utf8 title" : "use",
965                  "xtype" : "TreeViewColumn"
966                 }
967                ],
968                "string id" : "files_tree",
969                "xtype" : "TreeView"
970               }
971              ],
972              "xtype" : "ScrolledWindow"
973             }
974            ],
975            "xtype" : "Box"
976           }
977          ],
978          "xtype" : "Paned"
979         }
980        ],
981        "xtype" : "Notebook"
982       },
983       {
984        "$ xns" : "Gtk",
985        "* pack" : "add",
986        "int margin_bottom" : 4,
987        "int margin_left" : 4,
988        "int margin_right" : 4,
989        "int margin_top" : 4,
990        "items" : [
991         {
992          "$ xns" : "Gtk",
993          "* pack" : "add",
994          "listeners" : {
995           "clicked" : [
996            "() => { ",
997            "",
998            "  _this.done = true;",
999            "    _this.el.hide(); ",
1000            "}"
1001           ]
1002          },
1003          "string label" : "Cancel",
1004          "xtype" : "Button"
1005         },
1006         {
1007          "$ xns" : "Gtk",
1008          "* pack" : "add",
1009          "id" : "save_btn",
1010          "listeners" : {
1011           "clicked" : [
1012            "( ) =>  { ",
1013            "",
1014            " ",
1015            "_this.project.writeConfig(); ",
1016            " ",
1017            "\t// what about .js ?",
1018            "   _this.done = true;",
1019            "\t_this.el.hide();",
1020            "",
1021            "// hopefull this will work with bjs files..",
1022            "\t",
1023            " ",
1024            "   ",
1025            "}"
1026           ]
1027          },
1028          "string label" : "Save",
1029          "xtype" : "Button"
1030         }
1031        ],
1032        "xtype" : "HButtonBox"
1033       }
1034      ],
1035      "xtype" : "Box"
1036     }
1037    ],
1038    "listeners" : {
1039     "closed" : [
1040      "( ) => {",
1041      "  if (!this.done) {",
1042      "    _this.el.show_all();",
1043      "  ",
1044      "  }",
1045      "",
1046      "}",
1047      ""
1048     ],
1049     "hide" : [
1050      "() => {",
1051      "\t  if (!this.done) {",
1052      "    _this.el.show();",
1053      "  ",
1054      "  }",
1055      "}"
1056     ]
1057    },
1058    "uint border_width" : 0,
1059    "xtype" : "Popover",
1060    "| void save" : [
1061     "()  {",
1062     "    this.project.writeConfig(); ",
1063     "}"
1064    ],
1065    "| void show" : [
1066     "(Gtk.Widget btn, Project.Gtk project) {",
1067     "     ",
1068     "    //print(\"ValaProjectSettings show\\n\");",
1069     "    ",
1070     "    this.project=  project;",
1071     "",
1072     "    this.compile_flags.el.text = _this.project.compilegroups.get(\"_default_\").compile_flags;",
1073     "    ",
1074     "    this.default_directory_tree_store.load();    ",
1075     "    this.default_packages_tree_store.load();            ",
1076     "    this.targets_tree_store.load();",
1077     "    this.files_tree_store.load();",
1078     "",
1079     "",
1080     "\tthis.el.set_modal(true);",
1081     "\tthis.el.set_relative_to(btn);",
1082     "",
1083     "\tthis.el.set_position(Gtk.PositionType.RIGHT);",
1084     "",
1085     "\t// window + header?",
1086     "\t// print(\"SHOWALL - POPIP\\n\");",
1087     "\tthis.el.set_size_request(800,500);",
1088     "\tthis.el.show_all();",
1089     "\t//this.view.el.grab_focus();",
1090     "",
1091     "}",
1092     ""
1093    ]
1094   }
1095  ],
1096  "modOrder" : "",
1097  "name" : "ValaProjectSettingsPopover",
1098  "parent" : "",
1099  "path" : "/home/alan/gitlive/roobuilder/src/Builder4/ValaProjectSettingsPopover.bjs",
1100  "permname" : "",
1101  "title" : ""
1102 }