check not null first.
[roobuilder] / src / Builder4 / ValaCompileErrors.bjs
1 {
2  "build_module" : "builder",
3  "items" : [
4   {
5    "$ xns" : "Gtk",
6    "Gtk.PositionType position" : "Gtk.PositionType.TOP",
7    "JsRender.JsRender? file" : "",
8    "Json.Object notices" : "",
9    "Xcls_MainWindow window" : "",
10    "bool active" : false,
11    "bool hexpand" : false,
12    "bool modal" : true,
13    "id" : "ValaCompileErrors",
14    "int height_request" : 800,
15    "int width_request" : 900,
16    "items" : [
17     {
18      "$ xns" : "Gtk",
19      "* pack" : "add",
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        "* pack" : "pack_start,false,false,0",
28        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
29        "items" : [
30         {
31          "$ xns" : "Gtk",
32          "* pack" : "pack_start,true,true,0",
33          "utf8 label" : "Compile and Run ",
34          "xtype" : "Button"
35         }
36        ],
37        "xtype" : "Box"
38       },
39       {
40        "$ xns" : "Gtk",
41        "* init" : [
42         "{",
43         " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
44         " ",
45         "",
46         "}",
47         ""
48        ],
49        "* pack" : "pack_end,true,true,0",
50        "items" : [
51         {
52          "$ xns" : "Gtk",
53          "* init" : [
54           "{",
55           " var description = new Pango.FontDescription();",
56           "    description.set_size(10000);",
57           "    this.el.override_font(description);",
58           "",
59           "}",
60           ""
61          ],
62          "* pack" : "add",
63          "id" : "compile_tree",
64          "items" : [
65           {
66            "$ xns" : "Gtk",
67            "* pack" : "set_model",
68            "columns" : [
69             "  typeof(string), ",
70             "  typeof(int),",
71             "   typeof(string),",
72             "    typeof(string) "
73            ],
74            "gint n_columns" : 4,
75            "id" : "compile_result_store",
76            "xtype" : "TreeStore"
77           },
78           {
79            "$ xns" : "Gtk",
80            "* init" : [
81             "{",
82             "  this.el.add_attribute(_this.renderer.el , \"markup\", 2 );",
83             " ",
84             "}",
85             ""
86            ],
87            "* pack" : "append_column",
88            "items" : [
89             {
90              "$ xns" : "Gtk",
91              "* pack" : "pack_start,true",
92              "id" : "renderer",
93              "xtype" : "CellRendererText"
94             }
95            ],
96            "string id" : "column",
97            "utf8 title" : "Compile output",
98            "xtype" : "TreeViewColumn"
99           }
100          ],
101          "listeners" : {
102           "button_press_event" : [
103            "  ( ev)  => {",
104            " ",
105            "    Gtk.TreeViewColumn col;",
106            "    int cell_x;",
107            "    int cell_y;",
108            "    Gtk.TreePath path;",
109            "    if (!this.el.get_path_at_pos((int)ev.x, (int) ev.y, out path, out col, out cell_x, out cell_y )) {",
110            "        print(\"nothing selected on click\");",
111            "        ",
112            "        return false; //not on a element.",
113            "    }",
114            "    ",
115            "     ",
116            "     // right click.",
117            "     if (ev.type != Gdk.EventType.2BUTTON_PRESS  || ev.button != 1  ) {    ",
118            "        // show popup!.   ",
119            "            ",
120            "         ",
121            "        return false;",
122            "    }",
123            "    Gtk.TreeIter iter;",
124            "     var mod = _this.compile_result_store.el;",
125            "    mod.get_iter (out iter, path);",
126            "    ",
127            "      ",
128            "    ",
129            "    // var val = \"\";",
130            "    GLib.Value value;",
131            "    _this.compile_result_store.el.get_value(iter, 3, out value);",
132            "    var fname = (string)value;",
133            "    GLib.Value lvalue;",
134            "    _this.compile_result_store.el.get_value(iter, 1, out lvalue);",
135            "    var line = (int) lvalue;",
136            "    ",
137            "    print(\"open %s @ %d\\n\", fname, line);",
138            "    ",
139            "    ",
140            "   var  bjsf = \"\";",
141            "    try {             ",
142            "       var  regex = new Regex(\"\\\\.vala$\");",
143            "    ",
144            "     ",
145            "        bjsf = regex.replace(fname,fname.length , 0 , \".bjs\");",
146            "     } catch (GLib.RegexError e) {",
147            "        return false;",
148            "    }   ",
149            "    var p = _this.window.project;",
150            "        ",
151            "        ",
152            "        ",
153            "    var jsr = p.getByPath(bjsf);",
154            "    if (jsr != null) {",
155            "        _this.window.windowstate.fileViewOpen(jsr, true, line);",
156            "        ",
157            "        return false;",
158            "    ",
159            "    }",
160            "    ",
161            "    var pf = JsRender.JsRender.factory(\"PlainFile\", p, fname);",
162            "    _this.window.windowstate.fileViewOpen(pf, true, line);",
163            "    ",
164            "    // try hiding the left nav..",
165            " ",
166            "    return false;",
167            "    ",
168            "  }",
169            "    "
170           ]
171          },
172          "xtype" : "TreeView"
173         }
174        ],
175        "xtype" : "ScrolledWindow"
176       }
177      ],
178      "xtype" : "Box"
179     }
180    ],
181    "xtype" : "Popover",
182    "| void show" : [
183     "(Json.Object tree, Gtk.Widget onbtn) {",
184     "",
185     "    ",
186     "    this.file = null;",
187     "    this.notices = tree;",
188     "   ",
189     "     //print(\"looking for %s\\n\", id);",
190     "    // loop through parent childnre",
191     "      ",
192     "    ",
193     "    var store = this.compile_result_store.el;    ",
194     "    ",
195     "    store.clear();",
196     " ",
197     "    ",
198     "    tree.foreach_member((obj, file, node) => {",
199     "        // id line \"display text\", file",
200     "        ",
201     "        var title = GLib.Path.get_basename(GLib.Path.get_dirname( file)) + \"/\" +  GLib.Path.get_basename( file) ;",
202     "        Gtk.TreeIter iter;",
203     "        print(\"Add file %s\", title);",
204     "        store.append(out iter, null);",
205     "        var lines = tree.get_object_member(file);",
206     "        title += \" (\" + lines.get_size().to_string() + \")\";",
207     "        store.set(iter, ",
208     "        \t0, file, ",
209     "        \t1, -1, ",
210     "        \t2, title, ",
211     "        \t3, file,",
212     "    \t-1);",
213     "        ",
214     "        lines.foreach_member((obja, line, nodea) => {",
215     "            var msg  = \"\";",
216     "            var ar = lines.get_array_member(line);",
217     "            for (var i = 0 ; i < ar.get_length(); i++) {",
218     "\t\t\t\tmsg += (msg.length > 0) ? \"\\n\" : \"\";",
219     "\t\t\t\tmsg += ar.get_string_element(i);",
220     "\t\t    }",
221     "\t\t    Gtk.TreeIter citer;  ",
222     "\t\t    print(\"Add line %s\", line);",
223     "\t\t    store.append(out citer, iter);",
224     "\t\t    store.set(citer, ",
225     "\t\t            0, file + \":\" + line, ",
226     "\t\t            1, int.parse(line), ",
227     "\t\t            2, GLib.Markup.escape_text(line + \": \" + msg), ",
228     "\t\t            3, file, ",
229     "\t\t            -1);",
230     "        ",
231     "        });",
232     "         ",
233     "    ",
234     "    });",
235     "      ",
236     "    store.set_sort_column_id(0,Gtk.SortType.ASCENDING);",
237     "",
238     "        ",
239     "    int w,h;",
240     "    this.window.el.get_size(out w, out h);",
241     "    ",
242     "    // left tree = 250, editor area = 500?",
243     "    ",
244     "    // min 450?",
245     "    var new_w = int.min(450, w-100);",
246     "    if (new_w > (w-100)) {",
247     "        new_w = w-100;",
248     "    }",
249     "    this.el.set_size_request( int.max(100, new_w), int.max(100, h-120));",
250     "",
251     "    ",
252     "",
253     "    if (this.el.relative_to == null) {",
254     "        this.el.set_relative_to(onbtn);",
255     "    }",
256     "    this.el.show_all();",
257     "   ",
258     "    while(Gtk.events_pending()) { ",
259     "            Gtk.main_iteration();",
260     "    }       ",
261     " //   this.hpane.el.set_position( 0);",
262     "}",
263     ""
264    ]
265   }
266  ],
267  "modOrder" : "",
268  "name" : "ValaCompileErrors",
269  "parent" : "",
270  "path" : "/home/alan/gitlive/roobuilder/src/Builder4/ValaCompileErrors.bjs",
271  "permname" : "",
272  "title" : ""
273 }