src/Builder4/ValaCompileResults.bjs
[app.Builder.js] / src / Builder4 / ValaCompileResults.vala
1 static Xcls_ValaCompileResults  _ValaCompileResults;
2
3 public class Xcls_ValaCompileResults : Object
4 {
5     public Gtk.Popover el;
6     private Xcls_ValaCompileResults  _this;
7
8     public static Xcls_ValaCompileResults singleton()
9     {
10         if (_ValaCompileResults == null) {
11             _ValaCompileResults= new Xcls_ValaCompileResults();
12         }
13         return _ValaCompileResults;
14     }
15     public Xcls_compile_view compile_view;
16
17         // my vars (def)
18     public Xcls_MainWindow window;
19     public bool active;
20     public JsRender.JsRender? file;
21     public Json.Object notices;
22
23     // ctor
24     public Xcls_ValaCompileResults()
25     {
26         _this = this;
27         this.el = new Gtk.Popover( null );
28
29         // my vars (dec)
30         this.active = false;
31
32         // set gobject values
33         this.el.width_request = 900;
34         this.el.height_request = 800;
35         this.el.modal = true;
36         this.el.position = Gtk.PositionType.TOP;
37         var child_0 = new Xcls_compile_view( _this );
38         child_0.ref();
39         this.el.add (  child_0.el  );
40     }
41
42     // user defined functions
43     public void show (Json.Object tree, Gtk.Widget onbtn) {
44     
45             
46             this.file = null;
47             this.notices = tree;
48            
49              //print("looking for %s\n", id);
50             // loop through parent childnre
51               
52             
53             var store = this.compile_result_store.el;    
54             
55             store.clear();
56          
57             
58             tree.foreach_member((obj, file, node) => {
59                 // id line "display text", file
60                 
61                 var title = GLib.Path.get_basename(GLib.Path.get_dirname( file)) + "/" +  GLib.Path.get_basename( file) ;
62                 Gtk.TreeIter iter;
63                 print("Add file %s", title);
64                 store.append(out iter, null);
65                 var lines = tree.get_object_member(file);
66                 title += " (" + lines.get_size().to_string() + ")";
67                 store.set(iter, 0, file, 1, 0, 2, title, 3, file,-1);
68                 
69                 lines.foreach_member((obja, line, nodea) => {
70                     var msg  = "";
71                     var ar = lines.get_array_member(line);
72                     for (var i = 0 ; i < ar.get_length(); i++) {
73                             msg += (msg.length > 0) ? "\n" : "";
74                             msg += ar.get_string_element(i);
75                 }
76                     Gtk.TreeIter citer;  
77                     print("Add line %s", line);
78                     store.append(out citer, iter);
79                     store.set(citer, 
80                         0, file + ":" + line, 
81                         1, int.parse(line), 
82                         2, GLib.Markup.escape_text(line + ": " + msg), 
83                         3, file,-1);
84                 
85                 });
86                 
87                 
88             
89             });
90             
91         int w,h;
92         this.window.el.get_size(out w, out h);
93         
94         // left tree = 250, editor area = 500?
95         
96         var new_w = int.min(250, w-100);
97         if (new_w > (w-100)) {
98             new_w = w-100;
99         }
100         this.el.set_size_request( int.max(100, new_w), int.max(100, h-120));
101     
102         
103     
104         if (this.el.relative_to == null) {
105             this.el.set_relative_to(onbtn);
106         }
107         this.el.show_all();
108        
109         while(Gtk.events_pending()) { 
110                 Gtk.main_iteration();
111         }       
112      //   this.hpane.el.set_position( 0);
113     }
114     public class Xcls_compile_view : Object
115     {
116         public Gtk.Box el;
117         private Xcls_ValaCompileResults  _this;
118
119
120             // my vars (def)
121
122         // ctor
123         public Xcls_compile_view(Xcls_ValaCompileResults _owner )
124         {
125             _this = _owner;
126             _this.compile_view = this;
127             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
128
129             // my vars (dec)
130
131             // set gobject values
132             this.el.homogeneous = false;
133             var child_0 = new Xcls_ScrolledWindow3( _this );
134             child_0.ref();
135             this.el.pack_end (  child_0.el , true,true,0 );
136         }
137
138         // user defined functions
139     }
140     public class Xcls_ScrolledWindow3 : Object
141     {
142         public Gtk.ScrolledWindow el;
143         private Xcls_ValaCompileResults  _this;
144
145
146             // my vars (def)
147
148         // ctor
149         public Xcls_ScrolledWindow3(Xcls_ValaCompileResults _owner )
150         {
151             _this = _owner;
152             this.el = new Gtk.ScrolledWindow( null, null );
153
154             // my vars (dec)
155
156             // set gobject values
157
158             // init method
159
160             {
161              this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
162              
163             
164             }
165         }
166
167         // user defined functions
168     }
169
170
171 }