src/Builder4/ValaCompileResults.bjs
authorAlan Knowles <alan@roojs.com>
Thu, 28 May 2015 08:18:44 +0000 (16:18 +0800)
committerAlan Knowles <alan@roojs.com>
Thu, 28 May 2015 08:18:44 +0000 (16:18 +0800)
src/Builder4/ValaCompileResults.vala

src/Builder4/ValaCompileResults.bjs
src/Builder4/ValaCompileResults.vala [new file with mode: 0644]

index 2c6a8ad..7033c6f 100644 (file)
@@ -7,5 +7,89 @@
  "modOrder" : "",
  "build_module" : "",
  "items" : [
+  {
+   "int height_request" : 800,
+   "id" : "ValaCompileErrors",
+   "Xcls_MainWindow window" : "",
+   "| void show" : "(Json.Object tree, Gtk.Widget onbtn) {\n\n        \n        this.file = null;\n        this.notices = tree;\n       \n         //print(\"looking for %s\\n\", id);\n        // loop through parent childnre\n          \n        \n        var store = this.compile_result_store.el;    \n        \n        store.clear();\n     \n        \n        tree.foreach_member((obj, file, node) => {\n            // id line \"display text\", file\n            \n            var title = GLib.Path.get_basename(GLib.Path.get_dirname( file)) + \"/\" +  GLib.Path.get_basename( file) ;\n            Gtk.TreeIter iter;\n            print(\"Add file %s\", title);\n            store.append(out iter, null);\n            var lines = tree.get_object_member(file);\n            title += \" (\" + lines.get_size().to_string() + \")\";\n            store.set(iter, 0, file, 1, 0, 2, title, 3, file,-1);\n            \n            lines.foreach_member((obja, line, nodea) => {\n                var msg  = \"\";\n                var ar = lines.get_array_member(line);\n                for (var i = 0 ; i < ar.get_length(); i++) {\n    \t\t    msg += (msg.length > 0) ? \"\\n\" : \"\";\n    \t\t    msg += ar.get_string_element(i);\n\t        }\n                Gtk.TreeIter citer;  \n                print(\"Add line %s\", line);\n                store.append(out citer, iter);\n                store.set(citer, \n                    0, file + \":\" + line, \n                    1, int.parse(line), \n                    2, GLib.Markup.escape_text(line + \": \" + msg), \n                    3, file,-1);\n            \n            });\n            \n            \n        \n        });\n        \n    int w,h;\n    this.window.el.get_size(out w, out h);\n    \n    // left tree = 250, editor area = 500?\n    \n    var new_w = int.min(250, w-100);\n    if (new_w > (w-100)) {\n        new_w = w-100;\n    }\n    this.el.set_size_request( int.max(100, new_w), int.max(100, h-120));\n\n    \n\n    if (this.el.relative_to == null) {\n        this.el.set_relative_to(onbtn);\n    }\n    this.el.show_all();\n   \n    while(Gtk.events_pending()) { \n            Gtk.main_iteration();\n    }       \n //   this.hpane.el.set_position( 0);\n}\n",
+   "xtype" : "Popover",
+   "Gtk.PositionType position" : "Gtk.PositionType.TOP",
+   "bool active" : false,
+   "int width_request" : 900,
+   "$ xns" : "Gtk",
+   "JsRender.JsRender? file" : "",
+   "Json.Object notices" : "",
+   "bool modal" : true,
+   "items" : [
+    {
+     "id" : "compile_view",
+     "* pack" : "add",
+     "xtype" : "Box",
+     "gboolean homogeneous" : false,
+     "$ xns" : "Gtk",
+     "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
+     "items" : [
+      {
+       "xtype" : "Box",
+       "* pack" : "pack_start,false,false,0",
+       "$ xns" : "Gtk",
+       "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
+       "items" : [
+        {
+         "* pack" : "pack_start,true,true,0",
+         "xtype" : "Button",
+         "$ xns" : "Gtk",
+         "utf8 label" : "Compile and Run "
+        }
+       ]
+      },
+      {
+       "* init" : "{\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n\n}\n",
+       "* pack" : "pack_end,true,true,0",
+       "xtype" : "ScrolledWindow",
+       "$ xns" : "Gtk",
+       "items" : [
+        {
+         "listeners" : {
+          "button_press_event" : "  ( ev)  => {\n \n    Gtk.TreeViewColumn col;\n    int cell_x;\n    int cell_y;\n    Gtk.TreePath path;\n    if (!this.el.get_path_at_pos((int)ev.x, (int) ev.y, out path, out col, out cell_x, out cell_y )) {\n        print(\"nothing selected on click\");\n        \n        return false; //not on a element.\n    }\n    \n     \n     // right click.\n     if (ev.type != Gdk.EventType.2BUTTON_PRESS  || ev.button != 1  ) {    \n        // show popup!.   \n            \n         \n        return false;\n    }\n    Gtk.TreeIter iter;\n     var mod = _this.compile_result_store.el;\n    mod.get_iter (out iter, path);\n    \n      \n    \n    // var val = \"\";\n    GLib.Value value;\n    _this.compile_result_store.el.get_value(iter, 3, out value);\n    var fname = (string)value;\n    //GLib.Value lvalue;\n    //_this.compile_result_store.el.get_value(iter, 1, out lvalue);\n    //var line = (int) lvalue;\n    \n    \n   var  bjsf = \"\";\n    try {             \n       var  regex = new Regex(\"\\\\.vala$\");\n    \n     \n        bjsf = regex.replace(fname,fname.length , 0 , \".bjs\");\n     } catch (GLib.RegexError e) {\n        return false;\n    }   \n    var p = _this.window.project;\n        \n        \n        \n    var jsr = p.getByPath(bjsf);\n    if (jsr != null) {\n        _this.window.windowstate.fileViewOpen(jsr);\n        \n        return false;\n    \n    }\n    \n    var pf = JsRender.JsRender.factory(\"PlainFile\", p, fname);\n    _this.window.windowstate.fileViewOpen(pf);\n    \n    // try hiding the left nav..\n \n    return false;\n    \n  }\n    "
+         },
+         "id" : "compile_tree",
+         "* init" : "{\n var description = new Pango.FontDescription();\n    description.set_size(8000);\n    this.el.override_font(description);\n\n}\n",
+         "* pack" : "add",
+         "xtype" : "TreeView",
+         "$ xns" : "Gtk",
+         "items" : [
+          {
+           "gint n_columns" : 4,
+           "id" : "compile_result_store",
+           "columns" : "  typeof(string), typeof(int), typeof(string), typeof(string) ",
+           "* pack" : "set_model",
+           "xtype" : "TreeStore",
+           "$ xns" : "Gtk"
+          },
+          {
+           "utf8 title" : "Compile output",
+           "* init" : "{\n  this.el.add_attribute(_this.renderer.el , \"markup\", 2 );\n \n}\n",
+           "xtype" : "TreeViewColumn",
+           "* pack" : "append_column",
+           "string id" : "column",
+           "$ xns" : "Gtk",
+           "items" : [
+            {
+             "id" : "renderer",
+             "xtype" : "CellRendererText",
+             "* pack" : "pack_start,true",
+             "$ xns" : "Gtk"
+            }
+           ]
+          }
+         ]
+        }
+       ]
+      }
+     ]
+    }
+   ]
+  }
  ]
 }
\ No newline at end of file
diff --git a/src/Builder4/ValaCompileResults.vala b/src/Builder4/ValaCompileResults.vala
new file mode 100644 (file)
index 0000000..ca26071
--- /dev/null
@@ -0,0 +1,411 @@
+static Xcls_ValaCompileErrors  _ValaCompileErrors;
+
+public class Xcls_ValaCompileErrors : Object
+{
+    public Gtk.Popover el;
+    private Xcls_ValaCompileErrors  _this;
+
+    public static Xcls_ValaCompileErrors singleton()
+    {
+        if (_ValaCompileErrors == null) {
+            _ValaCompileErrors= new Xcls_ValaCompileErrors();
+        }
+        return _ValaCompileErrors;
+    }
+    public Xcls_compile_view compile_view;
+    public Xcls_compile_tree compile_tree;
+    public Xcls_compile_result_store compile_result_store;
+    public Xcls_renderer renderer;
+
+        // my vars (def)
+    public Xcls_MainWindow window;
+    public bool active;
+    public JsRender.JsRender? file;
+    public Json.Object notices;
+
+    // ctor
+    public Xcls_ValaCompileErrors()
+    {
+        _this = this;
+        this.el = new Gtk.Popover( null );
+
+        // my vars (dec)
+        this.active = false;
+
+        // set gobject values
+        this.el.width_request = 900;
+        this.el.height_request = 800;
+        this.el.modal = true;
+        this.el.position = Gtk.PositionType.TOP;
+        var child_0 = new Xcls_compile_view( _this );
+        child_0.ref();
+        this.el.add (  child_0.el  );
+    }
+
+    // user defined functions
+    public void show (Json.Object tree, Gtk.Widget onbtn) {
+    
+            
+            this.file = null;
+            this.notices = tree;
+           
+             //print("looking for %s\n", id);
+            // loop through parent childnre
+              
+            
+            var store = this.compile_result_store.el;    
+            
+            store.clear();
+         
+            
+            tree.foreach_member((obj, file, node) => {
+                // id line "display text", file
+                
+                var title = GLib.Path.get_basename(GLib.Path.get_dirname( file)) + "/" +  GLib.Path.get_basename( file) ;
+                Gtk.TreeIter iter;
+                print("Add file %s", title);
+                store.append(out iter, null);
+                var lines = tree.get_object_member(file);
+                title += " (" + lines.get_size().to_string() + ")";
+                store.set(iter, 0, file, 1, 0, 2, title, 3, file,-1);
+                
+                lines.foreach_member((obja, line, nodea) => {
+                    var msg  = "";
+                    var ar = lines.get_array_member(line);
+                    for (var i = 0 ; i < ar.get_length(); i++) {
+                           msg += (msg.length > 0) ? "\n" : "";
+                           msg += ar.get_string_element(i);
+               }
+                    Gtk.TreeIter citer;  
+                    print("Add line %s", line);
+                    store.append(out citer, iter);
+                    store.set(citer, 
+                        0, file + ":" + line, 
+                        1, int.parse(line), 
+                        2, GLib.Markup.escape_text(line + ": " + msg), 
+                        3, file,-1);
+                
+                });
+                
+                
+            
+            });
+            
+        int w,h;
+        this.window.el.get_size(out w, out h);
+        
+        // left tree = 250, editor area = 500?
+        
+        var new_w = int.min(250, w-100);
+        if (new_w > (w-100)) {
+            new_w = w-100;
+        }
+        this.el.set_size_request( int.max(100, new_w), int.max(100, h-120));
+    
+        
+    
+        if (this.el.relative_to == null) {
+            this.el.set_relative_to(onbtn);
+        }
+        this.el.show_all();
+       
+        while(Gtk.events_pending()) { 
+                Gtk.main_iteration();
+        }       
+     //   this.hpane.el.set_position( 0);
+    }
+    public class Xcls_compile_view : Object
+    {
+        public Gtk.Box el;
+        private Xcls_ValaCompileErrors  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_compile_view(Xcls_ValaCompileErrors _owner )
+        {
+            _this = _owner;
+            _this.compile_view = this;
+            this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.homogeneous = false;
+            var child_0 = new Xcls_Box3( _this );
+            child_0.ref();
+            this.el.pack_start (  child_0.el , false,false,0 );
+            var child_1 = new Xcls_ScrolledWindow5( _this );
+            child_1.ref();
+            this.el.pack_end (  child_1.el , true,true,0 );
+        }
+
+        // user defined functions
+    }
+    public class Xcls_Box3 : Object
+    {
+        public Gtk.Box el;
+        private Xcls_ValaCompileErrors  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_Box3(Xcls_ValaCompileErrors _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
+
+            // my vars (dec)
+
+            // set gobject values
+            var child_0 = new Xcls_Button4( _this );
+            child_0.ref();
+            this.el.pack_start (  child_0.el , true,true,0 );
+        }
+
+        // user defined functions
+    }
+    public class Xcls_Button4 : Object
+    {
+        public Gtk.Button el;
+        private Xcls_ValaCompileErrors  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_Button4(Xcls_ValaCompileErrors _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.Button();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.label = "Compile and Run ";
+        }
+
+        // user defined functions
+    }
+
+
+    public class Xcls_ScrolledWindow5 : Object
+    {
+        public Gtk.ScrolledWindow el;
+        private Xcls_ValaCompileErrors  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_ScrolledWindow5(Xcls_ValaCompileErrors _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.ScrolledWindow( null, null );
+
+            // my vars (dec)
+
+            // set gobject values
+            var child_0 = new Xcls_compile_tree( _this );
+            child_0.ref();
+            this.el.add (  child_0.el  );
+
+            // init method
+
+            {
+             this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
+             
+            
+            }
+        }
+
+        // user defined functions
+    }
+    public class Xcls_compile_tree : Object
+    {
+        public Gtk.TreeView el;
+        private Xcls_ValaCompileErrors  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_compile_tree(Xcls_ValaCompileErrors _owner )
+        {
+            _this = _owner;
+            _this.compile_tree = this;
+            this.el = new Gtk.TreeView();
+
+            // my vars (dec)
+
+            // set gobject values
+            var child_0 = new Xcls_compile_result_store( _this );
+            child_0.ref();
+            this.el.set_model (  child_0.el  );
+            var child_1 = new Xcls_column( _this );
+            child_1.ref();
+            this.el.append_column (  child_1.el  );
+
+            // init method
+
+            {
+             var description = new Pango.FontDescription();
+                description.set_size(8000);
+                this.el.override_font(description);
+            
+            }
+
+            //listeners
+            this.el.button_press_event.connect( ( ev)  => {
+             
+                Gtk.TreeViewColumn col;
+                int cell_x;
+                int cell_y;
+                Gtk.TreePath path;
+                if (!this.el.get_path_at_pos((int)ev.x, (int) ev.y, out path, out col, out cell_x, out cell_y )) {
+                    print("nothing selected on click");
+                    
+                    return false; //not on a element.
+                }
+                
+                 
+                 // right click.
+                 if (ev.type != Gdk.EventType.2BUTTON_PRESS  || ev.button != 1  ) {    
+                    // show popup!.   
+                        
+                     
+                    return false;
+                }
+                Gtk.TreeIter iter;
+                 var mod = _this.compile_result_store.el;
+                mod.get_iter (out iter, path);
+                
+                  
+                
+                // var val = "";
+                GLib.Value value;
+                _this.compile_result_store.el.get_value(iter, 3, out value);
+                var fname = (string)value;
+                //GLib.Value lvalue;
+                //_this.compile_result_store.el.get_value(iter, 1, out lvalue);
+                //var line = (int) lvalue;
+                
+                
+               var  bjsf = "";
+                try {             
+                   var  regex = new Regex("\\.vala$");
+                
+                 
+                    bjsf = regex.replace(fname,fname.length , 0 , ".bjs");
+                 } catch (GLib.RegexError e) {
+                    return false;
+                }   
+                var p = _this.window.project;
+                    
+                    
+                    
+                var jsr = p.getByPath(bjsf);
+                if (jsr != null) {
+                    _this.window.windowstate.fileViewOpen(jsr);
+                    
+                    return false;
+                
+                }
+                
+                var pf = JsRender.JsRender.factory("PlainFile", p, fname);
+                _this.window.windowstate.fileViewOpen(pf);
+                
+                // try hiding the left nav..
+             
+                return false;
+                
+              });
+        }
+
+        // user defined functions
+    }
+    public class Xcls_compile_result_store : Object
+    {
+        public Gtk.TreeStore el;
+        private Xcls_ValaCompileErrors  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_compile_result_store(Xcls_ValaCompileErrors _owner )
+        {
+            _this = _owner;
+            _this.compile_result_store = this;
+            this.el = new Gtk.TreeStore( 4,   typeof(string), typeof(int), typeof(string), typeof(string)  );
+
+            // my vars (dec)
+
+            // set gobject values
+        }
+
+        // user defined functions
+    }
+
+    public class Xcls_column : Object
+    {
+        public Gtk.TreeViewColumn el;
+        private Xcls_ValaCompileErrors  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_column(Xcls_ValaCompileErrors _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.TreeViewColumn();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.title = "Compile output";
+            var child_0 = new Xcls_renderer( _this );
+            child_0.ref();
+            this.el.pack_start (  child_0.el , true );
+
+            // init method
+
+            {
+              this.el.add_attribute(_this.renderer.el , "markup", 2 );
+             
+            }
+        }
+
+        // user defined functions
+    }
+    public class Xcls_renderer : Object
+    {
+        public Gtk.CellRendererText el;
+        private Xcls_ValaCompileErrors  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_renderer(Xcls_ValaCompileErrors _owner )
+        {
+            _this = _owner;
+            _this.renderer = this;
+            this.el = new Gtk.CellRendererText();
+
+            // my vars (dec)
+
+            // set gobject values
+        }
+
+        // user defined functions
+    }
+
+
+
+
+
+}