Fix #7304 - text align on table cells and file open duplicate code
[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(8000);",
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" : "  typeof(string), typeof(int), typeof(string), typeof(string) ",
69            "gint n_columns" : 4,
70            "id" : "compile_result_store",
71            "xtype" : "TreeStore"
72           },
73           {
74            "$ xns" : "Gtk",
75            "* init" : [
76             "{",
77             "  this.el.add_attribute(_this.renderer.el , \"markup\", 2 );",
78             " ",
79             "}",
80             ""
81            ],
82            "* pack" : "append_column",
83            "items" : [
84             {
85              "$ xns" : "Gtk",
86              "* pack" : "pack_start,true",
87              "id" : "renderer",
88              "xtype" : "CellRendererText"
89             }
90            ],
91            "string id" : "column",
92            "utf8 title" : "Compile output",
93            "xtype" : "TreeViewColumn"
94           }
95          ],
96          "listeners" : {
97           "button_press_event" : [
98            "  ( ev)  => {",
99            " ",
100            "    Gtk.TreeViewColumn col;",
101            "    int cell_x;",
102            "    int cell_y;",
103            "    Gtk.TreePath path;",
104            "    if (!this.el.get_path_at_pos((int)ev.x, (int) ev.y, out path, out col, out cell_x, out cell_y )) {",
105            "        print(\"nothing selected on click\");",
106            "        ",
107            "        return false; //not on a element.",
108            "    }",
109            "    ",
110            "     ",
111            "     // right click.",
112            "     if (ev.type != Gdk.EventType.2BUTTON_PRESS  || ev.button != 1  ) {    ",
113            "        // show popup!.   ",
114            "            ",
115            "         ",
116            "        return false;",
117            "    }",
118            "    Gtk.TreeIter iter;",
119            "     var mod = _this.compile_result_store.el;",
120            "    mod.get_iter (out iter, path);",
121            "    ",
122            "      ",
123            "    ",
124            "    // var val = \"\";",
125            "    GLib.Value value;",
126            "    _this.compile_result_store.el.get_value(iter, 3, out value);",
127            "    var fname = (string)value;",
128            "    GLib.Value lvalue;",
129            "    _this.compile_result_store.el.get_value(iter, 1, out lvalue);",
130            "    var line = (int) lvalue;",
131            "    ",
132            "    print(\"open %s @ %d\\n\", fname, line);",
133            "    ",
134            "    ",
135            "   var  bjsf = \"\";",
136            "    try {             ",
137            "       var  regex = new Regex(\"\\\\.vala$\");",
138            "    ",
139            "     ",
140            "        bjsf = regex.replace(fname,fname.length , 0 , \".bjs\");",
141            "     } catch (GLib.RegexError e) {",
142            "        return false;",
143            "    }   ",
144            "    var p = _this.window.project;",
145            "        ",
146            "        ",
147            "        ",
148            "    var jsr = p.getByPath(bjsf);",
149            "    if (jsr != null) {",
150            "        _this.window.windowstate.fileViewOpen(jsr, true, line);",
151            "        ",
152            "        return false;",
153            "    ",
154            "    }",
155            "    ",
156            "    var pf = JsRender.JsRender.factory(\"PlainFile\", p, fname);",
157            "    _this.window.windowstate.fileViewOpen(pf, true, line);",
158            "    ",
159            "    // try hiding the left nav..",
160            " ",
161            "    return false;",
162            "    ",
163            "  }",
164            "    "
165           ]
166          },
167          "xtype" : "TreeView"
168         }
169        ],
170        "xtype" : "ScrolledWindow"
171       }
172      ],
173      "xtype" : "Box"
174     }
175    ],
176    "xtype" : "Popover",
177    "| void show" : [
178     "(Json.Object tree, Gtk.Widget onbtn) {",
179     "",
180     "    ",
181     "    this.file = null;",
182     "    this.notices = tree;",
183     "   ",
184     "     //print(\"looking for %s\\n\", id);",
185     "    // loop through parent childnre",
186     "      ",
187     "    ",
188     "    var store = this.compile_result_store.el;    ",
189     "    ",
190     "    store.clear();",
191     " ",
192     "    ",
193     "    tree.foreach_member((obj, file, node) => {",
194     "        // id line \"display text\", file",
195     "        ",
196     "        var title = GLib.Path.get_basename(GLib.Path.get_dirname( file)) + \"/\" +  GLib.Path.get_basename( file) ;",
197     "        Gtk.TreeIter iter;",
198     "        print(\"Add file %s\", title);",
199     "        store.append(out iter, null);",
200     "        var lines = tree.get_object_member(file);",
201     "        title += \" (\" + lines.get_size().to_string() + \")\";",
202     "        store.set(iter, 0, file, 1, -1, 2, title, 3, file,-1);",
203     "        ",
204     "        lines.foreach_member((obja, line, nodea) => {",
205     "            var msg  = \"\";",
206     "            var ar = lines.get_array_member(line);",
207     "            for (var i = 0 ; i < ar.get_length(); i++) {",
208     "\t\t    msg += (msg.length > 0) ? \"\\n\" : \"\";",
209     "\t\t    msg += ar.get_string_element(i);",
210     "        }",
211     "            Gtk.TreeIter citer;  ",
212     "            print(\"Add line %s\", line);",
213     "            store.append(out citer, iter);",
214     "            store.set(citer, ",
215     "                0, file + \":\" + line, ",
216     "                1, int.parse(line), ",
217     "                2, GLib.Markup.escape_text(line + \": \" + msg), ",
218     "                3, file,-1);",
219     "        ",
220     "        });",
221     "        ",
222     "        ",
223     "    ",
224     "    });",
225     "        ",
226     "    int w,h;",
227     "    this.window.el.get_size(out w, out h);",
228     "    ",
229     "    // left tree = 250, editor area = 500?",
230     "    ",
231     "    // min 450?",
232     "    var new_w = int.min(450, w-100);",
233     "    if (new_w > (w-100)) {",
234     "        new_w = w-100;",
235     "    }",
236     "    this.el.set_size_request( int.max(100, new_w), int.max(100, h-120));",
237     "",
238     "    ",
239     "",
240     "    if (this.el.relative_to == null) {",
241     "        this.el.set_relative_to(onbtn);",
242     "    }",
243     "    this.el.show_all();",
244     "   ",
245     "    while(Gtk.events_pending()) { ",
246     "            Gtk.main_iteration();",
247     "    }       ",
248     " //   this.hpane.el.set_position( 0);",
249     "}",
250     ""
251    ]
252   }
253  ],
254  "modOrder" : "",
255  "name" : "ValaCompileErrors",
256  "parent" : "",
257  "path" : "/home/alan/gitlive/roobuilder/src/Builder4/ValaCompileErrors.bjs",
258  "permname" : "",
259  "title" : ""
260 }