expanding tree when error buttons pressed
[roobuilder] / src / Builder4 / ValaCompileErrors.bjs
1 {
2  "build_module" : "builder",
3  "gen_extended" : false,
4  "items" : [
5   {
6    "# Gee.HashMap<string,Gtk.TreeListRow>? rows" : "null",
7    "# Xcls_MainWindow window" : "",
8    "$ xns" : "Gtk",
9    "* ctor" : "new Gtk.Popover()",
10    "Gtk.PositionType position" : "Gtk.PositionType.TOP",
11    "bool autohide" : true,
12    "bool loaded" : false,
13    "id" : "ValaCompileErrors",
14    "int height_request" : 800,
15    "int width_request" : 900,
16    "items" : [
17     {
18      "$ xns" : "Gtk",
19      "* pack" : "set_child",
20      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
21      "bool hexpand" : false,
22      "gboolean homogeneous" : false,
23      "id" : "compile_view",
24      "items" : [
25       {
26        "$ xns" : "Gtk",
27        "* init" : [
28         "{",
29         " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
30         " ",
31         "",
32         "}",
33         ""
34        ],
35        "items" : [
36         {
37          "$ xns" : "Gtk",
38          "* pack" : "set_child",
39          "bool hexpand" : true,
40          "bool vexpand" : true,
41          "id" : "tree",
42          "items" : [
43           {
44            "$ xns" : "Gtk",
45            "* prop" : "model",
46            "id" : "selmodel",
47            "items" : [
48             {
49              "$ xns" : "Gtk",
50              "* prop" : "model",
51              "id" : "sortmodel",
52              "items" : [
53               {
54                "$ xns" : "Gtk",
55                "* ctor" : [
56                 "new Gtk.TreeListModel(",
57                 "    new GLib.ListStore(typeof(Palete.CompileError)), //..... << that's our store..",
58                 "    false, // passthru",
59                 "    false, // autexpand",
60                 "    (item) => {",
61                 "    ",
62                 "    \t ",
63                 "    \t return ((Palete.CompileError)item).lines;",
64                 "    ",
65                 "    }",
66                 "    ",
67                 "    ",
68                 ")"
69                ],
70                "* prop" : "model",
71                "id" : "model",
72                "xtype" : "TreeListModel"
73               },
74               {
75                "$ xns" : "Gtk",
76                "* prop" : "sorter",
77                "items" : [
78                 {
79                  "$ xns" : "Gtk",
80                  "* prop" : "sorter",
81                  "items" : [
82                   {
83                    "$ xns" : "Gtk",
84                    "* prop" : "expression",
85                    "GLib.Type this_type" : "typeof(Palete.CompileError)",
86                    "string property_name" : "linemsg",
87                    "xtype" : "PropertyExpression"
88                   }
89                  ],
90                  "xtype" : "StringSorter"
91                 }
92                ],
93                "xtype" : "TreeListRowSorter"
94               }
95              ],
96              "xtype" : "SortListModel",
97              "| Json.Object getNodeAt" : [
98               "(uint row) {",
99               "",
100               "   var tr = (Gtk.TreeListRow)this.el.get_item(row);",
101               "   ",
102               "  ",
103               "  // GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
104               "  \t",
105               "   ",
106               "   return (Json.Object)tr.get_item();",
107               "\t ",
108               "}"
109              ]
110             }
111            ],
112            "xtype" : "SingleSelection",
113            "| Json.Object getNodeAt" : [
114             "(uint row) {",
115             "",
116             "   var tr = (Gtk.TreeListRow)this.el.get_item(row);",
117             "   ",
118             "   var a = tr.get_item();;   ",
119             "   GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
120             "    ",
121             "   return (Json.Object)tr.get_item();",
122             "\t ",
123             "}"
124            ]
125           },
126           {
127            "$ xns" : "Gtk",
128            "* pack" : "append_column",
129            "bool expand" : true,
130            "bool resizable" : true,
131            "items" : [
132             {
133              "$ xns" : "Gtk",
134              "* prop" : "factory",
135              "listeners" : {
136               "bind" : [
137                "(listitem) => {",
138                "\t //GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
139                "\t",
140                "\t",
141                "\t",
142                "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
143                "\tvar expand = (Gtk.TreeExpander)  ((Gtk.ListItem)listitem).get_child();",
144                "\t  ",
145                " ",
146                "\tvar lbl = (Gtk.Label) expand.child;",
147                "\t",
148                "\t if (lbl.label != \"\") { // do not update",
149                "\t \treturn;",
150                " \t}",
151                "\t",
152                "",
153                "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
154                "\tvar np = (Palete.CompileError) lr.get_item();",
155                "\t",
156                "\tif (np.diag == null) {",
157                "\t\t_this.rows.set(np.file.path, lr);",
158                "\t",
159                "\t}",
160                "",
161                "\t",
162                "\t//GLib.debug(\"change  %s to %s\", lbl.label, np.name);",
163                "\tlbl.label = np.linemsg;",
164                "\t//lbl.tooltip_markup = np.to_property_option_tooltip();",
165                "\t ",
166                "    expand.set_hide_expander(  np.lines.n_items < 1);",
167                "\texpand.set_list_row(lr);",
168                " ",
169                " \t// expand current file.",
170                " \t// this causes problems? - critical errors?",
171                " \t// maybe do it on show",
172                " \t//if (_this.window.windowstate.file.path == np.file.path &&",
173                " \t//\tnp.line < 0) {",
174                " \t//\tlr.expanded = true;",
175                " \t",
176                "\t//}",
177                " \t ",
178                " \t// bind image...",
179                " \t",
180                "}",
181                ""
182               ],
183               "setup" : [
184                "(listitem) => {",
185                "\t",
186                "\tvar expand = new Gtk.TreeExpander();",
187                "\t ",
188                "\texpand.set_indent_for_depth(true);",
189                "\texpand.set_indent_for_icon(true);",
190                "\t ",
191                "\tvar lbl = new Gtk.Label(\"\");",
192                "\tlbl.use_markup = true;",
193                "\t",
194                "\t",
195                " \tlbl.justify = Gtk.Justification.LEFT;",
196                " \tlbl.xalign = 0;",
197                "",
198                " ",
199                "\texpand.set_child(lbl);",
200                "\t((Gtk.ListItem)listitem).set_child(expand);",
201                "\t((Gtk.ListItem)listitem).activatable = false;",
202                "}",
203                ""
204               ]
205              },
206              "xtype" : "SignalListItemFactory"
207             }
208            ],
209            "string title" : "Compile Result",
210            "xtype" : "ColumnViewColumn"
211           },
212           {
213            "$ xns" : "Gtk",
214            "listeners" : {
215             "pressed" : [
216              "(n_press, x, y) => {",
217              "\t",
218              "\tif (n_press < 2) { /// doubleclick?",
219              "\t\treturn;",
220              "\t}",
221              " ",
222              "\t",
223              "\t",
224              "\t// use selection?!",
225              "\tvar tr = (Gtk.TreeListRow)_this.selmodel.el.selected_item;",
226              "\t//GLib.debug(\"SELECTED = %s\", tr.item.get_type().name());",
227              "\tvar ce = (Palete.CompileError) tr.item;",
228              "",
229              "\tif (ce.line < 0) {",
230              "\t\t// did not click on a line.",
231              "\t\treturn;",
232              "\t}",
233              "\t ",
234              "\t ",
235              "    var fname  = ce.file;",
236              "  \tvar line = ce.line;  ",
237              "    GLib.debug(\"open %s @ %d\\n\", ce.file.path, ce.line);",
238              "    ",
239              "    ",
240              "   var  bjsf = \"\";",
241              "    try {             ",
242              "       var  regex = new Regex(\"\\\\.vala$\");",
243              "    ",
244              "     ",
245              "        bjsf = regex.replace(fname.path,fname.path.length , 0 , \".bjs\");",
246              "     } catch (GLib.RegexError e) {",
247              "        return;",
248              "    }   ",
249              "    var p = _this.window.project;",
250              "        ",
251              "        ",
252              "        ",
253              "    var jsr = p.getByPath(bjsf);",
254              "    if (jsr != null) {",
255              "        _this.window.windowstate.fileViewOpen(jsr, true, line);",
256              "        ",
257              "        if (jsr.path == _this.window.windowstate.file.path) {",
258              "        ",
259              "    \t}",
260              "    \t_this.el.hide();",
261              "        ",
262              "        return;",
263              "    ",
264              "    }",
265              "  ",
266              "\tvar pf = p.getByPath(fname.path);",
267              "\t_this.el.hide();",
268              "\t_this.window.windowstate.fileViewOpen(pf, true, line);",
269              "",
270              "    ",
271              "}",
272              ""
273             ]
274            },
275            "uint button" : 0,
276            "xtype" : "GestureClick"
277           }
278          ],
279          "xtype" : "ColumnView"
280         }
281        ],
282        "xtype" : "ScrolledWindow"
283       }
284      ],
285      "xtype" : "Box"
286     }
287    ],
288    "xtype" : "Popover",
289    "| void show" : [
290     "(   ) {",
291     "\tGLib.debug(\"errors  : show\");",
292     "\t",
293     "\tif (_this.model.el.get_n_items()  < 1) {",
294     "   ",
295     " \t    GLib.debug(\"errors  : none available\");",
296     "    \treturn;",
297     "\t}",
298     " \t ",
299     "    var win = this.window.el;",
300     "    var  w = win.get_width();",
301     "    var h = win.get_height();",
302     "",
303     "   ",
304     "    // left tree = 250, editor area = 500?",
305     "    ",
306     "    // min 450?",
307     "    var new_w = int.min(650, w-100);",
308     "    if (new_w > (w-100)) {",
309     "        new_w = w-100;",
310     "    }",
311     "    GLib.debug(\"set size\");",
312     "    this.el.set_size_request( int.max(100, new_w), int.max(100, h-120));",
313     " ",
314     " ",
315     "\t",
316     "\tGLib.debug(\"call popup\");",
317     "    this.el.popup();",
318     "    if (this.rows.has_key(this.window.windowstate.file.path)) {",
319     "    \tthis.rows.get(this.window.windowstate.file.path).expanded = true;",
320     "    }",
321     "}",
322     ""
323    ],
324    "| void updateNotices" : [
325     "( GLib.ListStore? ls) {",
326     "\tGLib.debug(\"errors  : update\");",
327     "    if (ls == null || ls.get_n_items() < 1) {",
328     " \t//    GLib.debug(\"errors  : none available\");",
329     "    \treturn;",
330     "\t}",
331     "\t",
332     "\t//GLib.debug(\"Loading list into tree\");",
333     "\tthis.tree.el.hide();",
334     "\tvar tm = new Gtk.TreeListModel(",
335     "\t\tls, //..... << that's our store..",
336     "\t\tfalse, // passthru",
337     "\t\tfalse, // autexpand",
338     "\t\t(item) => {",
339     "\t\t",
340     "\t\t\t return ((Palete.CompileError)item).lines;",
341     "\t\t",
342     "\t\t}",
343     "\t\t",
344     "\t);",
345     "\tthis.rows = new Gee.HashMap<string,Gtk.TreeListRow>();",
346     "\t_this.model.el = tm;",
347     "\t_this.sortmodel.el.set_model(tm);",
348     "\t this.tree.el.show();",
349     "\t if (this.rows.has_key(this.window.windowstate.file.path)) {",
350     "    \tthis.rows.get(this.window.windowstate.file.path).expanded = true;",
351     "    }",
352     "}"
353    ]
354   }
355  ],
356  "name" : "ValaCompileErrors"
357 }