sync
authorAlan Knowles <alan@roojs.com>
Wed, 1 Jun 2016 02:41:22 +0000 (10:41 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 1 Jun 2016 02:41:22 +0000 (10:41 +0800)
src/Builder4/Editor.bjs
src/Builder4/Editor.vala
src/Builder4/GtkView.bjs
src/Builder4/GtkView.vala
src/Builder4/ValaCompileErrors.bjs
src/Builder4/WindowState.vala
src/Palete/ValaSource.vala

index 152ade2..2479b28 100644 (file)
@@ -9,8 +9,8 @@
  "items" : [
   {
    "# Xcls_MainWindow window" : "null",
-   "|   bool saveContents" : "  ()  {\n    \n    \n    if (_this.file == null) {\n        return true;\n    }\n    \n    \n   \n   \n     \n     var str = _this.buffer.toString();\n     \n     _this.buffer.checkSyntax();\n     \n     \n     \n     // LeftPanel.model.changed(  str , false);\n     _this.dirty = false;\n     _this.save_button.el.sensitive = false;\n     \n    // find the text for the node..\n    if (_this.file.xtype != \"PlainFile\") {\n        if (ptype == \"listener\") {\n            this.node.listeners.set(key,str);\n        \n        } else {\n             this.node.props.set(key,str);\n        }\n    } else {\n        _this.file.setSource(  str );\n     }\n    \n    // call the signal..\n    this.save();\n    \n    return true;\n\n} ",
    "# string activeEditor" : "\"\"",
+   "|   bool saveContents" : "  ()  {\n    \n    \n    if (_this.file == null) {\n        return true;\n    }\n    \n    \n   \n   \n     \n     var str = _this.buffer.toString();\n     \n     _this.buffer.checkSyntax();\n     \n     \n     \n     // LeftPanel.model.changed(  str , false);\n     _this.dirty = false;\n     _this.save_button.el.sensitive = false;\n     \n    // find the text for the node..\n    if (_this.file.xtype != \"PlainFile\") {\n        if (ptype == \"listener\") {\n            this.node.listeners.set(key,str);\n        \n        } else {\n             this.node.props.set(key,str);\n        }\n    } else {\n        _this.file.setSource(  str );\n     }\n    \n    // call the signal..\n    this.save();\n    \n    return true;\n\n} ",
    "| void scroll_to_line" : "(int line) {\n\n\tGLib.Timeout.add(500, () => {\n   \n\t\tvar buf = this.view.el.get_buffer();\n\n\t\tvar sbuf = (Gtk.SourceBuffer) buf;\n\n\n\t\tGtk.TextIter iter;   \n\t\tsbuf.get_iter_at_line(out iter,  line);\n\t\tthis.view.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.5f);\n\t\treturn false;\n\t});   \n}\n",
    "# int pos_root_x" : "",
    "# int pos_root_y" : "",
@@ -53,8 +53,8 @@
       },
       {
        "id" : "key_edit",
-       "* pack" : "pack_end,true,true",
        "xtype" : "Entry",
+       "* pack" : "pack_end,true,true",
        "$ xns" : "Gtk"
       }
      ]
           "changed" : " () => {\n    // check syntax??\n    // ??needed..??\n    _this.save_button.el.sensitive = true;\n    print(\"EDITOR CHANGED\");\n    this.checkSyntax();\n   \n    _this.dirty = true;\n\n    // this.get('/LeftPanel.model').changed(  str , false);\n    return ;\n}\n\n \n"
          },
          "bool check_queued" : false,
-         "int error_line" : "-1",
          "id" : "buffer",
+         "int error_line" : "-1",
          "| bool highlightErrors" : "( Gee.HashMap<int,string> validate_res) {\n         \n        this.error_line = validate_res.size;\n\n        if (this.error_line < 1) {\n              return true;\n        }\n        var tlines = this.el.get_line_count ();\n        Gtk.TextIter iter;\n        var valiter = validate_res.map_iterator();\n        while (valiter.next()) {\n        \n    //        print(\"get inter\\n\");\n            var eline = valiter.get_key();\n            if (eline > tlines) {\n                continue;\n            }\n            this.el.get_iter_at_line( out iter, eline);\n            //print(\"mark line\\n\");\n            this.el.create_source_mark(valiter.get_value(), \"ERR\", iter);\n        }   \n        return false;\n    }",
          "|   string toString" : "  () {\n    \n    Gtk.TextIter s;\n    Gtk.TextIter e;\n    this.el.get_start_iter(out s);\n    this.el.get_end_iter(out e);\n    var ret = this.el.get_text(s,e,true);\n    //print(\"TO STRING? \" + ret);\n    return ret;\n}\n ",
-         "|   bool checkSyntax" : " () {\n \n    if (this.check_running) {\n        print(\"Check is running\\n\");\n        if (this.check_queued) { \n            print(\"Check is already queued\");\n            return true;\n        }\n        this.check_queued = true;\n        print(\"Adding queued Check \");\n        GLib.Timeout.add_seconds(1, () => {\n            this.check_queued = false;\n            \n            this.checkSyntax();\n            return false;\n        });\n    \n\n        return true;\n    }\n    var str = this.toString();\n    \n    // needed???\n    if (this.error_line > 0) {\n         Gtk.TextIter start;\n         Gtk.TextIter end;     \n        this.el.get_bounds (out start, out end);\n\n        this.el.remove_source_marks (start, end, null);\n    }\n    if (str.length < 1) {\n        print(\"checkSyntax - empty string?\\n\");\n        return true;\n    }\n    \n    if (_this.file.xtype == \"PlainFile\") {\n    \n        // assume it's gtk...\n           this.check_running = true;\n\n         if (!_this.window.windowstate.valasource.checkPlainFileSpawn(\n\t   _this.file,\n\t    str\n\t )) {\n            this.check_running = false;\n        }\n\t\n        return true;\n    \n    }\n   if (_this.file == null) {\n       return true;\n   }\n    var p = Palete.factory(_this.file.xtype);   \n    \n\n     \n    this.check_running = true;\n    \n    \n    if (_this.file.language == \"js\") {\n        this.check_running = false;\n        print(\"calling validate javascript\\n\"); \n        return this.highlightErrors(p.validateJavascript(\n            str, \n             _this.key, \n            _this.ptype,\n            _this.file,\n            _this.node\n        ));    \n        \n    }\n        \n        \n    print(\"calling validate vala\\n\");    \n    // clear the buttons.\n \n    \n   if (! _this.window.windowstate.valasource.checkFileWithNodePropChange(\n        _this.file,\n        _this.node,\n         _this.key,        \n         _this.ptype,\n            str\n        )) {\n        this.check_running = false;\n    } \n     \n    \n    \n    //print(\"done mark line\\n\");\n     \n    return true; // at present allow saving - even if it's invalid..\n}\n",
+         "|   bool checkSyntax" : " () {\n \n    if (this.check_running) {\n        print(\"Check is running\\n\");\n        if (this.check_queued) { \n            print(\"Check is already queued\");\n            return true;\n        }\n        this.check_queued = true;\n        print(\"Adding queued Check \");\n        GLib.Timeout.add_seconds(1, () => {\n            this.check_queued = false;\n            \n            this.checkSyntax();\n            return false;\n        });\n    \n\n        return true;\n    }\n    var str = this.toString();\n    \n    // needed???\n    if (this.error_line > 0) {\n         Gtk.TextIter start;\n         Gtk.TextIter end;     \n        this.el.get_bounds (out start, out end);\n\n        this.el.remove_source_marks (start, end, null);\n    }\n    if (str.length < 1) {\n        print(\"checkSyntax - empty string?\\n\");\n        return true;\n    }\n    \n    if (_this.file.xtype == \"PlainFile\") {\n    \n        // assume it's gtk...\n           this.check_running = true;\n \n         if (!_this.window.windowstate.valasource.checkPlainFileSpawn(\n\t   _this.file,\n\t    str\n\t )) {\n            this.check_running = false;\n        }\n\t\n        return true;\n    \n    }\n   if (_this.file == null) {\n       return true;\n   }\n    var p = Palete.factory(_this.file.xtype);   \n    \n\n     \n    this.check_running = true;\n    \n    \n    if (_this.file.language == \"js\") {\n        this.check_running = false;\n        print(\"calling validate javascript\\n\"); \n        return this.highlightErrors(p.validateJavascript(\n            str, \n             _this.key, \n            _this.ptype,\n            _this.file,\n            _this.node\n        ));    \n        \n    }\n        \n        \n    print(\"calling validate vala\\n\");    \n    // clear the buttons.\n \n    \n   if (! _this.window.windowstate.valasource.checkFileWithNodePropChange(\n        _this.file,\n        _this.node,\n         _this.key,        \n         _this.ptype,\n            str\n        )) {\n        this.check_running = false;\n    } \n     \n    \n    \n    //print(\"done mark line\\n\");\n     \n    return true; // at present allow saving - even if it's invalid..\n}\n",
          "* pack" : "set_buffer",
          "xtype" : "SourceBuffer",
          "bool check_running" : false,
index 7f73367..6fb49e8 100644 (file)
@@ -550,7 +550,7 @@ public class Editor : Object
             
                 // assume it's gtk...
                    this.check_running = true;
-        
+         
                  if (!_this.window.windowstate.valasource.checkPlainFileSpawn(
                   _this.file,
                    str
index ac2db46..88f215d 100644 (file)
@@ -9,7 +9,7 @@
  "items" : [
   {
    "listeners" : {
-    "size_allocate" : "(aloc) => {\n\n    this.width = aloc.width;\n    this.height =aloc.height;\n}\n "
+    "size_allocate" : "(aloc) => {\n \n    this.width = aloc.width;\n    this.height =aloc.height;\n}\n "
    },
    "| void scroll_to_line" : "(int line) {\n   this.notebook.el.page = 1;// code preview...\n   \n   GLib.Timeout.add(500, () => {\n   \n   \n\t   \n\t   \n\t\t  var buf = this.sourceview.el.get_buffer();\n\t \n\t\tvar sbuf = (Gtk.SourceBuffer) buf;\n\n\n\t\tGtk.TextIter iter;   \n\t\tsbuf.get_iter_at_line(out iter,  line);\n\t\tthis.sourceview.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.5f);\n\t\treturn false;\n\t});   \n\n   \n}\n",
    "id" : "GtkView",
    "items" : [
     {
      "id" : "notebook",
-     "xtype" : "Notebook",
      "* pack" : "pack_start,true,true,0",
+     "xtype" : "Notebook",
      "$ xns" : "Gtk",
      "items" : [
       {
        "id" : "label_preview",
-       "xtype" : "Label",
        "* pack" : false,
+       "xtype" : "Label",
        "$ xns" : "Gtk",
        "utf8 label" : "Preview"
       },
       {
        "id" : "label_code",
-       "* pack" : false,
        "xtype" : "Label",
+       "* pack" : false,
        "$ xns" : "Gtk",
        "utf8 label" : "Preview Generated Code"
       },
        "items" : [
         {
          "id" : "view_layout",
-         "* pack" : "add",
          "xtype" : "Layout",
+         "* pack" : "add",
          "$ xns" : "Gtk",
          "items" : [
           {
            "id" : "container",
-           "xtype" : "Box",
            "* pack" : "put,10,10",
+           "xtype" : "Box",
            "$ xns" : "Gtk",
            "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL"
           }
index fb13444..9851abb 100644 (file)
@@ -49,7 +49,7 @@ public class Xcls_GtkView : Object
 
         //listeners
         this.el.size_allocate.connect( (aloc) => {
-        
+         
             this.width = aloc.width;
             this.height =aloc.height;
         });
@@ -526,7 +526,7 @@ public class Xcls_GtkView : Object
         public void nodeSelected (JsRender.Node? sel) {
           
             
-               return;
+          
             // this is connected in widnowstate
             print("Roo-view - node selected\n");
             var buf = this.el.get_buffer();
@@ -534,9 +534,9 @@ public class Xcls_GtkView : Object
             var sbuf = (Gtk.SourceBuffer) buf;
         
            
-            //while(Gtk.events_pending()) {
-             //   Gtk.main_iteration();
-            //}
+            while(Gtk.events_pending()) {
+                Gtk.main_iteration();
+            }
             
            
             // clear all the marks..
index 15119fb..07e1661 100644 (file)
@@ -25,8 +25,8 @@
     {
      "id" : "compile_view",
      "bool hexpand" : false,
-     "* pack" : "add",
      "xtype" : "Box",
+     "* pack" : "add",
      "gboolean homogeneous" : false,
      "$ xns" : "Gtk",
      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
@@ -47,8 +47,8 @@
       },
       {
        "* init" : "{\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n\n}\n",
-       "* pack" : "pack_end,true,true,0",
        "xtype" : "ScrolledWindow",
+       "* pack" : "pack_end,true,true,0",
        "$ xns" : "Gtk",
        "items" : [
         {
@@ -79,8 +79,8 @@
            "items" : [
             {
              "id" : "renderer",
-             "xtype" : "CellRendererText",
              "* pack" : "pack_start,true",
+             "xtype" : "CellRendererText",
              "$ xns" : "Gtk"
             }
            ]
@@ -94,4 +94,4 @@
    ]
   }
  ]
-}
\ No newline at end of file
+}
index 0060daa..56aff30 100644 (file)
@@ -508,6 +508,7 @@ public class WindowState : Object
                         
 
        }
        // our project properties is different for Roo and Gtk
        // it would be better to change the above code to use this, 
        public void attachProjectSettings() {
@@ -524,9 +525,16 @@ public class WindowState : Object
                        ctr_p.add(this.vala_projectsettings.el);
                        this.vala_projectsettings.el.show_all();
                }
-       
-       
+    }
+        /*
+       public void fileViewOpenPlain(string fname)
+       {
+               
+               this.switchState (State.CODEONLY); 
+               this.code_editor.showPlainFile(fname);
        }
+ */
+        
        // ---------  webkit view
        public void webkitViewInit()
        {
index f8d05b2..1f5cc67 100644 (file)
@@ -197,6 +197,7 @@ namespace Palete {
                         
                }
                
 
                
                
@@ -252,7 +253,9 @@ namespace Palete {
                * Used to compile a non builder file..
                */
                 
-               public bool checkPlainFileSpawn(  JsRender.JsRender file, string contents )
+                
+               public bool checkPlainFileSpawn( JsRender.JsRender file, string contents )
                {
                        // race condition..
                        if (this.compiler != null) { 
@@ -289,6 +292,10 @@ namespace Palete {
                        DataOutputStream dostream = new DataOutputStream (ostream);
                        dostream.put_string (contents);
                        
+                       var target = pr.firstBuildModule();
+                       if (target.length < 1) {
+                               return false;
+                       }
                        
                        this.file = null;
                        this.line_offset = 0;
@@ -298,6 +305,7 @@ namespace Palete {
                        args += "--project";
                        args +=  file.project.fn;
                        args += "--target";
                        args += pr.firstBuildModule();
                        args += "--add-file";
                        args +=  tmpfile.get_path();
@@ -319,7 +327,7 @@ namespace Palete {
                        return true;
                         
                }
-               
+                
                
                public void spawnResult(int res, string output, string stderr)
                {