src/Builder4/config1.builder
[app.Builder.js] / src / Builder4 / ValaCompileErrors.vala
index a72676c..7989b43 100644 (file)
@@ -1,6 +1,6 @@
 static Xcls_ValaCompileErrors  _ValaCompileErrors;
 
-public class Xcls_ValaCompileErrors : Object 
+public class Xcls_ValaCompileErrors : Object
 {
     public Gtk.Popover el;
     private Xcls_ValaCompileErrors  _this;
@@ -13,9 +13,6 @@ public class Xcls_ValaCompileErrors : Object
         return _ValaCompileErrors;
     }
     public Xcls_compile_view compile_view;
-    public Xcls_save_btn save_btn;
-    public Xcls_hpane hpane;
-    public Xcls_sourceview sourceview;
     public Xcls_compile_tree compile_tree;
     public Xcls_compile_result_store compile_result_store;
     public Xcls_renderer renderer;
@@ -26,7 +23,7 @@ public class Xcls_ValaCompileErrors : Object
     public JsRender.JsRender? file;
     public Json.Object notices;
 
-    // ctor 
+    // ctor
     public Xcls_ValaCompileErrors()
     {
         _this = this;
@@ -38,29 +35,21 @@ public class Xcls_ValaCompileErrors : Object
         // set gobject values
         this.el.width_request = 900;
         this.el.height_request = 800;
-        this.el.modal = false;
+        this.el.hexpand = false;
+        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  );
-
-        // listeners 
-        this.el.closed.connect( () => {
-            if (this.active) {
-                this.el.show();
-                return;
-            }
-           
-        });
     }
 
-    // user defined functions 
+    // user defined functions
     public void show (Json.Object tree, Gtk.Widget onbtn) {
     
             
             this.file = null;
             this.notices = tree;
-            this.active = true;
+           
              //print("looking for %s\n", id);
             // loop through parent childnre
               
@@ -79,7 +68,7 @@ public class Xcls_ValaCompileErrors : Object
                 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);
+                store.set(iter, 0, file, 1, -1, 2, title, 3, file,-1);
                 
                 lines.foreach_member((obja, line, nodea) => {
                     var msg  = "";
@@ -115,55 +104,60 @@ public class Xcls_ValaCompileErrors : Object
         this.el.set_size_request( int.max(100, new_w), int.max(100, h-120));
     
         
-        this.hpane.el.set_position( 0);
-       if (this.el.relative_to == null) {
+    
+        if (this.el.relative_to == null) {
             this.el.set_relative_to(onbtn);
         }
         this.el.show_all();
-        this.save_btn.el.hide();          
-    
+       
+        while(Gtk.events_pending()) { 
+                Gtk.main_iteration();
+        }       
+     //   this.hpane.el.set_position( 0);
     }
-    public class Xcls_compile_view : Object 
+    public class Xcls_compile_view : Object
     {
-        public Gtk.VBox el;
+        public Gtk.Box el;
         private Xcls_ValaCompileErrors  _this;
 
 
             // my vars (def)
 
-        // ctor 
+        // ctor
         public Xcls_compile_view(Xcls_ValaCompileErrors _owner )
         {
             _this = _owner;
             _this.compile_view = this;
-            this.el = new Gtk.VBox( false, 0 );
+            this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
 
             // my vars (dec)
 
             // set gobject values
-            var child_0 = new Xcls_HBox3( _this );
+            this.el.homogeneous = false;
+            this.el.hexpand = 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_hpane( _this );
+            var child_1 = new Xcls_ScrolledWindow5( _this );
             child_1.ref();
-            this.el.pack_start (  child_1.el , true,true,0 );
+            this.el.pack_end (  child_1.el , true,true,0 );
         }
 
-        // user defined functions 
+        // user defined functions
     }
-    public class Xcls_HBox3 : Object 
+    public class Xcls_Box3 : Object
     {
-        public Gtk.HBox el;
+        public Gtk.Box el;
         private Xcls_ValaCompileErrors  _this;
 
 
             // my vars (def)
 
-        // ctor 
-        public Xcls_HBox3(Xcls_ValaCompileErrors _owner )
+        // ctor
+        public Xcls_Box3(Xcls_ValaCompileErrors _owner )
         {
             _this = _owner;
-            this.el = new Gtk.HBox( true, 0 );
+            this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
 
             // my vars (dec)
 
@@ -171,17 +165,11 @@ public class Xcls_ValaCompileErrors : Object
             var child_0 = new Xcls_Button4( _this );
             child_0.ref();
             this.el.pack_start (  child_0.el , true,true,0 );
-            var child_1 = new Xcls_Button5( _this );
-            child_1.ref();
-            this.el.pack_start (  child_1.el , true,true,0 );
-            var child_2 = new Xcls_save_btn( _this );
-            child_2.ref();
-            this.el.pack_start (  child_2.el , true,true,0 );
         }
 
-        // user defined functions 
+        // user defined functions
     }
-    public class Xcls_Button4 : Object 
+    public class Xcls_Button4 : Object
     {
         public Gtk.Button el;
         private Xcls_ValaCompileErrors  _this;
@@ -189,7 +177,7 @@ public class Xcls_ValaCompileErrors : Object
 
             // my vars (def)
 
-        // ctor 
+        // ctor
         public Xcls_Button4(Xcls_ValaCompileErrors _owner )
         {
             _this = _owner;
@@ -198,111 +186,14 @@ public class Xcls_ValaCompileErrors : Object
             // my vars (dec)
 
             // set gobject values
-            this.el.label = "Compile and Run";
+            this.el.label = "Compile and Run ";
         }
 
-        // user defined functions 
+        // user defined functions
     }
-    public class Xcls_Button5 : Object 
-    {
-        public Gtk.Button el;
-        private Xcls_ValaCompileErrors  _this;
-
-
-            // my vars (def)
 
-        // ctor 
-        public Xcls_Button5(Xcls_ValaCompileErrors _owner )
-        {
-            _this = _owner;
-            this.el = new Gtk.Button();
-
-            // my vars (dec)
-
-            // set gobject values
-            this.el.label = "Edit";
-
-            // listeners 
-            this.el.clicked.connect( () => {
-                // is the file managed by the builder?
-                
-                var f = _this.sourceview.curfname;
-                
-                Regex regex = new Regex("\\.vala$");
-            
-                var bjsf = regex.replace(f,f.length , 0 , ".bjs");
-                
-                var p = _this.window.project;
-                
-                
-                
-                var jsr = p.getByPath(bjsf);
-                if (jsr != null) {
-                    _this.window.windowstate.fileViewOpen(jsr);
-                    
-                    return;
-                
-                }
-            
-            
-            });
-        }
 
-        // user defined functions 
-    }
-    public class Xcls_save_btn : Object 
-    {
-        public Gtk.Button el;
-        private Xcls_ValaCompileErrors  _this;
-
-
-            // my vars (def)
-
-        // ctor 
-        public Xcls_save_btn(Xcls_ValaCompileErrors _owner )
-        {
-            _this = _owner;
-            _this.save_btn = this;
-            this.el = new Gtk.Button();
-
-            // my vars (dec)
-
-            // set gobject values
-            this.el.label = "Save";
-            this.el.visible = false;
-        }
-
-        // user defined functions 
-    }
-    public class Xcls_hpane : Object 
-    {
-        public Gtk.HPaned el;
-        private Xcls_ValaCompileErrors  _this;
-
-
-            // my vars (def)
-
-        // ctor 
-        public Xcls_hpane(Xcls_ValaCompileErrors _owner )
-        {
-            _this = _owner;
-            _this.hpane = this;
-            this.el = new Gtk.HPaned();
-
-            // my vars (dec)
-
-            // set gobject values
-            var child_0 = new Xcls_ScrolledWindow8( _this );
-            child_0.ref();
-            this.el.add (  child_0.el  );
-            var child_1 = new Xcls_ScrolledWindow10( _this );
-            child_1.ref();
-            this.el.add (  child_1.el  );
-        }
-
-        // user defined functions 
-    }
-    public class Xcls_ScrolledWindow8 : Object 
+    public class Xcls_ScrolledWindow5 : Object
     {
         public Gtk.ScrolledWindow el;
         private Xcls_ValaCompileErrors  _this;
@@ -310,185 +201,8 @@ public class Xcls_ValaCompileErrors : Object
 
             // my vars (def)
 
-        // ctor 
-        public Xcls_ScrolledWindow8(Xcls_ValaCompileErrors _owner )
-        {
-            _this = _owner;
-            this.el = new Gtk.ScrolledWindow( null, null );
-
-            // my vars (dec)
-
-            // set gobject values
-            var child_0 = new Xcls_sourceview( _this );
-            child_0.ref();
-            this.el.add (  child_0.el  );
-        }
-
-        // user defined functions 
-    }
-    public class Xcls_sourceview : Object 
-    {
-        public Gtk.SourceView el;
-        private Xcls_ValaCompileErrors  _this;
-
-
-            // my vars (def)
-        public string curfname;
-
-        // ctor 
-        public Xcls_sourceview(Xcls_ValaCompileErrors _owner )
-        {
-            _this = _owner;
-            _this.sourceview = this;
-            this.el = new Gtk.SourceView();
-
-            // my vars (dec)
-
-            // set gobject values
-            this.el.editable = false;
-            this.el.show_line_marks = true;
-            this.el.show_line_numbers = true;
-
-            // init method 
-
-            {
-                this.curfname = "";
-                   var description =   Pango.FontDescription.from_string("monospace");
-                description.set_size(8000);
-                this.el.override_font(description);
-            
-                var attrs = new Gtk.SourceMarkAttributes();
-                var  pink = new Gdk.RGBA();
-                pink.parse ( "pink");
-                attrs.set_background ( pink);
-                attrs.set_icon_name ( "process-stop");    
-                attrs.query_tooltip_text.connect(( mark) => {
-                    //print("tooltip query? %s\n", mark.name);
-                    return mark.name;
-                });
-                
-                this.el.set_mark_attributes ("error", attrs, 1);
-                
-            }
-        }
-
-        // user defined functions 
-        public void loadFile (string fname, int line ) {
-        
-            
-            // resize the view...
-            
-            // left tree = 250, editor area = 500?
-            
-            if (_this.hpane.el.get_position() < 1) {
-                 int w,h;
-                _this.window.el.get_size(out w, out h);
-                
-                var new_w = int.min(750, 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));
-             
-                _this.hpane.el.set_position( _this.hpane.el.max_position - 250);
-        
-            }
-        
-            var buf = ((Gtk.SourceBuffer)(this.el.get_buffer()));
-              
-            if (this.curfname != fname) {
-                this.curfname = fname;
-                
-                
-                Regex regex = new Regex("\\.vala$");
-        
-                var bjsf = regex.replace(fname,fname.length , 0 , ".bjs");
-                
-                var p = _this.window.project;
-                
-                var jsr = p.getByPath(bjsf);
-                
-                if (_this.file != null) {
-                    // remove listeners from the file...
-                }
-                
-                _this.file = null;
-                
-                if (jsr != null) {
-                    _this.file = jsr;
-                    
-                    return;
-                
-                }
-                
-                
-                
-        
-                Gtk.TextIter start;
-                Gtk.TextIter end;     
-                buf.get_bounds (out start, out end);
-                    
-                buf.remove_source_marks (start, end, null);
-                     
-                 
-                
-                string str;
-                FileUtils.get_contents(fname, out str);
-                               
-                buf.set_text(str, str.length);
-                var lm = Gtk.SourceLanguageManager.get_default();
-                
-               
-                buf.set_language(lm.get_language("vala"));
-             
-                 
-                this.el.grab_focus();
-        
-        
-               
-                var lines = _this.notices.get_object_member(fname);
-                 
-                    
-                lines.foreach_member((obj, line, node) => {
-                    
-                         Gtk.TextIter iter;
-                //        print("get inter\n");
-                        var eline = int.parse(line) -1 ;
-                         
-                        
-                        buf.get_iter_at_line( out iter, eline);
-                        //print("mark line\n");
-                        var msg  = "Line: %d".printf(eline+1);
-                        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);
-                       }
-                        
-                        
-                        buf.create_source_mark(msg, "error", iter);
-                    } );
-            }
-            // jump to the line...
-            Gtk.TextIter liter;
-            buf.get_iter_at_line (out liter,  line);
-            print("Scroll to \n");
-            this.el.scroll_to_iter (liter, 0.0f, false, 0.0f, 0.5f);
-            print("End Scroll to \n");
-        
-        
-        }
-    }
-    public class Xcls_ScrolledWindow10 : Object 
-    {
-        public Gtk.ScrolledWindow el;
-        private Xcls_ValaCompileErrors  _this;
-
-
-            // my vars (def)
-
-        // ctor 
-        public Xcls_ScrolledWindow10(Xcls_ValaCompileErrors _owner )
+        // ctor
+        public Xcls_ScrolledWindow5(Xcls_ValaCompileErrors _owner )
         {
             _this = _owner;
             this.el = new Gtk.ScrolledWindow( null, null );
@@ -500,7 +214,7 @@ public class Xcls_ValaCompileErrors : Object
             child_0.ref();
             this.el.add (  child_0.el  );
 
-            // init method 
+            // init method
 
             {
              this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
@@ -509,9 +223,9 @@ public class Xcls_ValaCompileErrors : Object
             }
         }
 
-        // user defined functions 
+        // user defined functions
     }
-    public class Xcls_compile_tree : Object 
+    public class Xcls_compile_tree : Object
     {
         public Gtk.TreeView el;
         private Xcls_ValaCompileErrors  _this;
@@ -519,7 +233,7 @@ public class Xcls_ValaCompileErrors : Object
 
             // my vars (def)
 
-        // ctor 
+        // ctor
         public Xcls_compile_tree(Xcls_ValaCompileErrors _owner )
         {
             _this = _owner;
@@ -536,42 +250,41 @@ public class Xcls_ValaCompileErrors : Object
             child_1.ref();
             this.el.append_column (  child_1.el  );
 
-            // init method 
+            // init method
 
             {
              var description = new Pango.FontDescription();
                 description.set_size(8000);
-                this.el.modify_font(description);
+                this.el.override_font(description);
             
             }
 
-            // listeners 
-            this.el.cursor_changed.connect( () => {
-                var sel = this.el.get_selection();
-            
-                if (sel.count_selected_rows() < 1) {
-            
-                    print("selected rows < 1\n");
-                    //??this.mo 
-                    return  ;
-                }
+            //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");
                     
-                    //console.log('changed');
-                 
-                 Gtk.TreeIter iter;
-                 Gtk.TreeModel mod;
-                sel.get_selected(out mod, out iter);
-                /*
-                 store.set(citer, 
-                        0, file + ":" + line, 
-                        1, int.parse(line), 
-                        2, GLib.Markup.escape_text(line + ": " + msg), 
-                        3, file,-1);
-                
-                });
-                */
+                    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;
@@ -581,24 +294,43 @@ public class Xcls_ValaCompileErrors : Object
                 _this.compile_result_store.el.get_value(iter, 1, out lvalue);
                 var line = (int) lvalue;
                 
+                print("open %s @ %d\n", fname, line);
                 
                 
-             
+               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, line);
+                    
+                    return false;
                 
-                print ("loadfile %s : %d", fname,line);
+                }
                 
-                _this.sourceview.loadFile(fname, line);
+                var pf = JsRender.JsRender.factory("PlainFile", p, fname);
+                _this.window.windowstate.fileViewOpen(pf,line);
                 
+                // try hiding the left nav..
+             
+                return false;
                 
-                        
-                        
-            });
+              });
         }
 
-        // user defined functions 
+        // user defined functions
     }
-    public class Xcls_compile_result_store : Object 
+    public class Xcls_compile_result_store : Object
     {
         public Gtk.TreeStore el;
         private Xcls_ValaCompileErrors  _this;
@@ -606,7 +338,7 @@ public class Xcls_ValaCompileErrors : Object
 
             // my vars (def)
 
-        // ctor 
+        // ctor
         public Xcls_compile_result_store(Xcls_ValaCompileErrors _owner )
         {
             _this = _owner;
@@ -618,9 +350,10 @@ public class Xcls_ValaCompileErrors : Object
             // set gobject values
         }
 
-        // user defined functions 
+        // user defined functions
     }
-    public class Xcls_column : Object 
+
+    public class Xcls_column : Object
     {
         public Gtk.TreeViewColumn el;
         private Xcls_ValaCompileErrors  _this;
@@ -628,7 +361,7 @@ public class Xcls_ValaCompileErrors : Object
 
             // my vars (def)
 
-        // ctor 
+        // ctor
         public Xcls_column(Xcls_ValaCompileErrors _owner )
         {
             _this = _owner;
@@ -642,7 +375,7 @@ public class Xcls_ValaCompileErrors : Object
             child_0.ref();
             this.el.pack_start (  child_0.el , true );
 
-            // init method 
+            // init method
 
             {
               this.el.add_attribute(_this.renderer.el , "markup", 2 );
@@ -650,9 +383,9 @@ public class Xcls_ValaCompileErrors : Object
             }
         }
 
-        // user defined functions 
+        // user defined functions
     }
-    public class Xcls_renderer : Object 
+    public class Xcls_renderer : Object
     {
         public Gtk.CellRendererText el;
         private Xcls_ValaCompileErrors  _this;
@@ -660,7 +393,7 @@ public class Xcls_ValaCompileErrors : Object
 
             // my vars (def)
 
-        // ctor 
+        // ctor
         public Xcls_renderer(Xcls_ValaCompileErrors _owner )
         {
             _this = _owner;
@@ -672,6 +405,11 @@ public class Xcls_ValaCompileErrors : Object
             // set gobject values
         }
 
-        // user defined functions 
+        // user defined functions
     }
+
+
+
+
+
 }