Fix #8003 - undo code
[roobuilder] / src / Builder4 / ValaCompileErrors.bjs
index ae4cc99..5ec52a2 100644 (file)
 {
- "name" : "ValaCompileErrors",
- "parent" : "",
- "title" : "",
- "path" : "/home/alan/gitlive/roobuilder/src/Builder4/ValaCompileErrors.bjs",
- "permname" : "",
- "modOrder" : "",
  "build_module" : "builder",
+ "gen_extended" : false,
  "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, -1, 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    // min 450?\n    var new_w = int.min(450, 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",
-   "bool hexpand" : false,
-   "xtype" : "Popover",
+   "# Xcls_MainWindow window" : "",
+   "$ xns" : "Gtk",
+   "* ctor" : "new Gtk.Popover()",
    "Gtk.PositionType position" : "Gtk.PositionType.TOP",
-   "bool active" : false,
+   "bool autohide" : true,
+   "bool loaded" : false,
+   "id" : "ValaCompileErrors",
+   "int height_request" : 800,
    "int width_request" : 900,
-   "$ xns" : "Gtk",
-   "JsRender.JsRender? file" : "",
-   "Json.Object notices" : "",
-   "bool modal" : true,
    "items" : [
     {
-     "id" : "compile_view",
-     "bool hexpand" : false,
-     "xtype" : "Box",
-     "* pack" : "add",
-     "gboolean homogeneous" : false,
      "$ xns" : "Gtk",
+     "* pack" : "set_child",
      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
+     "bool hexpand" : false,
+     "gboolean homogeneous" : false,
+     "id" : "compile_view",
      "items" : [
       {
-       "xtype" : "Box",
-       "* pack" : "pack_start,false,false,0",
        "$ xns" : "Gtk",
-       "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
+       "* init" : [
+        "{",
+        " this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
+        " ",
+        "",
+        "}",
+        ""
+       ],
        "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    print(\"open %s @ %d\\n\", fname, line);\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, line);\n        \n        return false;\n    \n    }\n    \n    var pf = JsRender.JsRender.factory(\"PlainFile\", p, fname);\n    _this.window.windowstate.fileViewOpen(pf,line);\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",
+         "* pack" : "set_child",
+         "bool hexpand" : true,
+         "bool vexpand" : true,
+         "id" : "tree",
          "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"
+           "$ xns" : "Gtk",
+           "* prop" : "model",
+           "id" : "selmodel",
+           "items" : [
+            {
+             "$ xns" : "Gtk",
+             "* prop" : "model",
+             "id" : "sortmodel",
+             "items" : [
+              {
+               "$ xns" : "Gtk",
+               "* ctor" : [
+                "new Gtk.TreeListModel(",
+                "    new GLib.ListStore(typeof(Palete.CompileError)), //..... << that's our store..",
+                "    false, // passthru",
+                "    false, // autexpand",
+                "    (item) => {",
+                "    ",
+                "    \t ",
+                "    \t return ((Palete.CompileError)item).lines;",
+                "    ",
+                "    }",
+                "    ",
+                "    ",
+                ")"
+               ],
+               "* prop" : "model",
+               "id" : "model",
+               "xtype" : "TreeListModel"
+              },
+              {
+               "$ xns" : "Gtk",
+               "* prop" : "sorter",
+               "items" : [
+                {
+                 "$ xns" : "Gtk",
+                 "* prop" : "sorter",
+                 "items" : [
+                  {
+                   "$ xns" : "Gtk",
+                   "* prop" : "expression",
+                   "GLib.Type this_type" : "typeof(Palete.CompileError)",
+                   "string property_name" : "linemsg",
+                   "xtype" : "PropertyExpression"
+                  }
+                 ],
+                 "xtype" : "StringSorter"
+                }
+               ],
+               "xtype" : "TreeListRowSorter"
+              }
+             ],
+             "xtype" : "SortListModel",
+             "| Json.Object getNodeAt" : [
+              "(uint row) {",
+              "",
+              "   var tr = (Gtk.TreeListRow)this.el.get_item(row);",
+              "   ",
+              "  ",
+              "  // GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
+              "  \t",
+              "   ",
+              "   return (Json.Object)tr.get_item();",
+              "\t ",
+              "}"
+             ]
+            }
+           ],
+           "xtype" : "SingleSelection",
+           "| Json.Object getNodeAt" : [
+            "(uint row) {",
+            "",
+            "   var tr = (Gtk.TreeListRow)this.el.get_item(row);",
+            "   ",
+            "   var a = tr.get_item();;   ",
+            "   GLib.debug(\"get_item (2) = %s\", a.get_type().name());",
+            "    ",
+            "   return (Json.Object)tr.get_item();",
+            "\t ",
+            "}"
+           ]
           },
           {
-           "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",
+           "* pack" : "append_column",
+           "bool expand" : true,
+           "bool resizable" : true,
            "items" : [
             {
-             "id" : "renderer",
-             "xtype" : "CellRendererText",
-             "* pack" : "pack_start,true",
-             "$ xns" : "Gtk"
+             "$ xns" : "Gtk",
+             "* prop" : "factory",
+             "listeners" : {
+              "bind" : [
+               "(listitem) => {",
+               "\t //GLib.debug(\"listitme is is %s\", ((Gtk.ListItem)listitem).get_type().name());",
+               "\t",
+               "\t",
+               "\t",
+               "\t//var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();",
+               "\tvar expand = (Gtk.TreeExpander)  ((Gtk.ListItem)listitem).get_child();",
+               "\t  ",
+               " ",
+               "\tvar lbl = (Gtk.Label) expand.child;",
+               "\t",
+               "\t if (lbl.label != \"\") { // do not update",
+               "\t \treturn;",
+               " \t}",
+               "\t",
+               "",
+               "\tvar lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();",
+               "\tvar np = (Palete.CompileError) lr.get_item();",
+               "\t",
+               "\t",
+               "\t//GLib.debug(\"change  %s to %s\", lbl.label, np.name);",
+               "\tlbl.label = np.linemsg;",
+               "\t//lbl.tooltip_markup = np.to_property_option_tooltip();",
+               "\t ",
+               "    expand.set_hide_expander(  np.lines.n_items < 1);",
+               "\texpand.set_list_row(lr);",
+               " ",
+               " \t// expand current file.",
+               " \t// this causes problems? - critical errors?",
+               " \t// maybe do it on show",
+               " \t//if (_this.window.windowstate.file.path == np.file.path &&",
+               " \t//\tnp.line < 0) {",
+               " \t//\tlr.expanded = true;",
+               " \t",
+               "\t//}",
+               " \t ",
+               " \t// bind image...",
+               " \t",
+               "}",
+               ""
+              ],
+              "setup" : [
+               "(listitem) => {",
+               "\t",
+               "\tvar expand = new Gtk.TreeExpander();",
+               "\t ",
+               "\texpand.set_indent_for_depth(true);",
+               "\texpand.set_indent_for_icon(true);",
+               "\t ",
+               "\tvar lbl = new Gtk.Label(\"\");",
+               "\tlbl.use_markup = true;",
+               "\t",
+               "\t",
+               " \tlbl.justify = Gtk.Justification.LEFT;",
+               " \tlbl.xalign = 0;",
+               "",
+               " ",
+               "\texpand.set_child(lbl);",
+               "\t((Gtk.ListItem)listitem).set_child(expand);",
+               "\t((Gtk.ListItem)listitem).activatable = false;",
+               "}",
+               ""
+              ]
+             },
+             "xtype" : "SignalListItemFactory"
             }
-           ]
+           ],
+           "string title" : "Compile Result",
+           "xtype" : "ColumnViewColumn"
+          },
+          {
+           "$ xns" : "Gtk",
+           "listeners" : {
+            "pressed" : [
+             "(n_press, x, y) => {",
+             "\t",
+             "\tif (n_press < 2) { /// doubleclick?",
+             "\t\treturn;",
+             "\t}",
+             " ",
+             "\t",
+             "\t",
+             "\t// use selection?!",
+             "\tvar tr = (Gtk.TreeListRow)_this.selmodel.el.selected_item;",
+             "\t//GLib.debug(\"SELECTED = %s\", tr.item.get_type().name());",
+             "\tvar ce = (Palete.CompileError) tr.item;",
+             "",
+             "\tif (ce.line < 0) {",
+             "\t\t// did not click on a line.",
+             "\t\treturn;",
+             "\t}",
+             "\t ",
+             "\t ",
+             "    var fname  = ce.file;",
+             "  \tvar line = ce.line;  ",
+             "    GLib.debug(\"open %s @ %d\\n\", ce.file.path, ce.line);",
+             "    ",
+             "    ",
+             "   var  bjsf = \"\";",
+             "    try {             ",
+             "       var  regex = new Regex(\"\\\\.vala$\");",
+             "    ",
+             "     ",
+             "        bjsf = regex.replace(fname.path,fname.path.length , 0 , \".bjs\");",
+             "     } catch (GLib.RegexError e) {",
+             "        return;",
+             "    }   ",
+             "    var p = _this.window.project;",
+             "        ",
+             "        ",
+             "        ",
+             "    var jsr = p.getByPath(bjsf);",
+             "    if (jsr != null) {",
+             "        _this.window.windowstate.fileViewOpen(jsr, true, line);",
+             "        ",
+             "        if (jsr.path == _this.window.windowstate.file.path) {",
+             "        ",
+             "    \t}",
+             "    \t_this.el.hide();",
+             "        ",
+             "        return;",
+             "    ",
+             "    }",
+             "  ",
+             "\tvar pf = p.getByPath(fname.path);",
+             "\t_this.el.hide();",
+             "\t_this.window.windowstate.fileViewOpen(pf, true, line);",
+             "",
+             "    ",
+             "}",
+             ""
+            ]
+           },
+           "uint button" : 0,
+           "xtype" : "GestureClick"
           }
-         ]
+         ],
+         "xtype" : "ColumnView"
         }
-       ]
+       ],
+       "xtype" : "ScrolledWindow"
       }
-     ]
+     ],
+     "xtype" : "Box"
     }
+   ],
+   "xtype" : "Popover",
+   "| void show" : [
+    "(   ) {",
+    "\tGLib.debug(\"errors  : show\");",
+    "\t",
+    "\tif (_this.model.el.get_n_items()  < 1) {",
+    "   ",
+    " \t    GLib.debug(\"errors  : none available\");",
+    "    \treturn;",
+    "\t}",
+    " \t//this.el.present();",
+    "    //this.el.popup();",
+    "    ",
+    "     //print(\"looking for %s\\n\", id);",
+    "    // loop through parent childnre",
+    "      ",
+    "    ",
+    "     ; //<< very important!!!",
+    "      ",
+    "   // store.set_sort_column_id(0,Gtk.SortType.ASCENDING);",
+    " ",
+    "    var win = this.window.el;",
+    "    var  w = win.get_width();",
+    "    var h = win.get_height();",
+    "",
+    "   ",
+    "    // left tree = 250, editor area = 500?",
+    "    ",
+    "    // min 450?",
+    "    var new_w = int.min(650, w-100);",
+    "    if (new_w > (w-100)) {",
+    "        new_w = w-100;",
+    "    }",
+    "    GLib.debug(\"set size\");",
+    "    this.el.set_size_request( int.max(100, new_w), int.max(100, h-120));",
+    " ",
+    "",
+    "   // this.el.set_relative_to(onbtn);",
+    "\t//Gtk.Allocation rect;",
+    "\t//onbtn.get_allocation(out rect);",
+    "    //this.el.set_pointing_to(rect);",
+    "\t//this.el.present();",
+    "\t",
+    "\tGLib.debug(\"call popup\");",
+    "    this.el.popup();",
+    "    // only need to load once.",
+    " \t//if (!this.loaded) {",
+    " \t\t ",
+    "\t\t//this.loaded = true;",
+    "\t //}",
+    "\t ",
+    "       ",
+    "   ",
+    "   \t//if (expand != null) {",
+    "    //\t_this.compile_tree.el.expand_row(   store.get_path(expand) , true);",
+    "//\t}",
+    "    ",
+    " //   this.hpane.el.set_position( 0);",
+    "}",
+    ""
+   ],
+   "| void updateNotices" : [
+    "( GLib.ListStore? ls) {",
+    "\tGLib.debug(\"errors  : update\");",
+    "    if (ls == null || ls.get_n_items() < 1) {",
+    " \t//    GLib.debug(\"errors  : none available\");",
+    "    \treturn;",
+    "\t}",
+    "\t",
+    "\t//GLib.debug(\"Loading list into tree\");",
+    "\tthis.tree.el.hide();",
+    "\tvar tm = new Gtk.TreeListModel(",
+    "\t\tls, //..... << that's our store..",
+    "\t\tfalse, // passthru",
+    "\t\tfalse, // autexpand",
+    "\t\t(item) => {",
+    "\t\t",
+    "\t\t\t return ((Palete.CompileError)item).lines;",
+    "\t\t",
+    "\t\t}",
+    "\t\t",
+    "\t);",
+    " ",
+    "\t_this.model.el = tm;",
+    "\t_this.sortmodel.el.set_model(tm);",
+    "\t this.tree.el.show();",
+    "}"
    ]
   }
- ]
+ ],
+ "name" : "ValaCompileErrors"
 }
\ No newline at end of file