src/Builder4/GtkView.bjs
authorAlan Knowles <alan@roojs.com>
Tue, 19 May 2015 06:57:35 +0000 (14:57 +0800)
committerAlan Knowles <alan@roojs.com>
Tue, 19 May 2015 06:57:35 +0000 (14:57 +0800)
src/Builder4/GtkView.vala

src/Builder4/GtkView.bjs
src/Builder4/GtkView.vala

index 10c7434..b7b7f9b 100644 (file)
@@ -70,8 +70,7 @@
         {
          "gboolean show_line_marks" : true,
          "id" : "sourceview",
-         "* init" : "{\n    this.curfname = \"\";\n       var description =   Pango.FontDescription.from_string(\"monospace\");\n    description.set_size(8000);\n    this.el.override_font(description);\n\n    var attrs = new Gtk.SourceMarkAttributes();\n    var  pink = new Gdk.RGBA();\n    pink.parse ( \"pink\");\n    attrs.set_background ( pink);\n    attrs.set_icon_name ( \"process-stop\");    \n    attrs.query_tooltip_text.connect(( mark) => {\n        //print(\"tooltip query? %s\\n\", mark.name);\n        return mark.name;\n    });\n    \n    this.el.set_mark_attributes (\"error\", attrs, 1);\n    \n}\n",
-         "| void loadFile" : "(string fname, int line ) {\n\n    \n    // resize the view...\n    \n    \n    //if (_this.hpane.el.get_position() < 1) {\n        // left tree = 250, editor area = 500?\n         int w,h;\n        _this.window.el.get_size(out w, out h);\n        \n        var new_w = int.min(750, 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        // let it resize, then find out the new size..\n        while(Gtk.events_pending()) { \n            Gtk.main_iteration();\n        }\n        \n        _this.hpane.el.set_position( _this.hpane.el.max_position - 250);\n\n    //}\n\n    var buf = ((Gtk.SourceBuffer)(this.el.get_buffer()));\n      \n    if (this.curfname != fname) {\n        this.curfname = fname;\n        \n        \n        Regex regex = new Regex(\"\\\\.vala$\");\n\n        var bjsf = regex.replace(fname,fname.length , 0 , \".bjs\");\n        \n        var p = _this.window.project;\n        \n        var jsr = p.getByPath(bjsf);\n        \n        if (_this.file != null) {\n            // remove listeners from the file...\n        }\n        \n        _this.file = null;\n        \n        if (jsr != null) {\n            _this.file = jsr;\n            \n           // return;\n        \n        }\n        \n        \n        \n\n        Gtk.TextIter start;\n        Gtk.TextIter end;     \n        buf.get_bounds (out start, out end);\n            \n        buf.remove_source_marks (start, end, null);\n             \n         \n        \n        string str;\n        FileUtils.get_contents(fname, out str);\n\t\t\t\n        buf.set_text(str, str.length);\n        var lm = Gtk.SourceLanguageManager.get_default();\n        \n       \n        buf.set_language(lm.get_language(\"vala\"));\n     \n         \n        this.el.grab_focus();\n\n\n       \n        var lines = _this.notices.get_object_member(fname);\n         \n            \n        lines.foreach_member((obj, line, node) => {\n            \n                 Gtk.TextIter iter;\n        //        print(\"get inter\\n\");\n                var eline = int.parse(line) -1 ;\n                 \n                \n                buf.get_iter_at_line( out iter, eline);\n                //print(\"mark line\\n\");\n                var msg  = \"Line: %d\".printf(eline+1);\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                \n                \n                buf.create_source_mark(msg, \"error\", iter);\n            } );\n    }\n    // jump to the line...\n    Gtk.TextIter liter;\n    buf.get_iter_at_line (out liter,  line);\n    print(\"Scroll to \\n\");\n    this.el.scroll_to_iter (liter, 0.0f, false, 0.0f, 0.5f);\n    print(\"End Scroll to \\n\");\n\n\n}\n",
+         "* init" : "{\n    this.curfname = \"\";\n       var description =   Pango.FontDescription.from_string(\"monospace\");\n    description.set_size(8000);\n    this.el.override_font(description);\n\n    var attrs = new Gtk.SourceMarkAttributes();\n    var  pink = new Gdk.RGBA();\n    pink.parse ( \"pink\");\n    attrs.set_background ( pink);\n    attrs.set_icon_name ( \"process-stop\");    \n    attrs.query_tooltip_text.connect(( mark) => {\n        //print(\"tooltip query? %s\\n\", mark.name);\n        return mark.name;\n    });\n    \n    this.el.set_mark_attributes (\"error\", attrs, 1);\n    \n}\n ",
          "* pack" : "add",
          "xtype" : "SourceView",
          "$ xns" : "Gtk",
index 1defe44..1b6c102 100644 (file)
@@ -354,116 +354,6 @@ public class Xcls_GtkView : Object
         }
 
         // user defined functions
-        public void loadFile (string fname, int line ) {
-        
-            
-            // resize the view...
-            
-            
-            //if (_this.hpane.el.get_position() < 1) {
-                // left tree = 250, editor area = 500?
-                 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));
-                
-                // let it resize, then find out the new size..
-                while(Gtk.events_pending()) { 
-                    Gtk.main_iteration();
-                }
-                
-                _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");
-        
-        
-        }
     }