tidy up add other property menu
[roobuilder] / src / Builder4 / WindowLeftProps.bjs
index 369cd6a..736d2df 100644 (file)
@@ -18,6 +18,7 @@
    "bool loading" : false,
    "bool vexpand" : true,
    "id" : "LeftProps",
+   "int last_error_counter" : "-1",
    "items" : [
     {
      "$ xns" : "Gtk",
       },
       {
        "$ xns" : "Gtk",
-       "bool always_show_image" : true,
-       "bool hexpand" : true,
        "items" : [
         {
          "$ xns" : "Gtk",
-         "* pack" : false,
-         "bool autohide" : true,
-         "id" : "AddPropertyPopup",
+         "* prop" : "popover",
+         "id" : "addpop",
          "items" : [
           {
            "$ xns" : "Gtk",
            "items" : [
             {
              "$ xns" : "Gtk",
-             "label" : "id: _this.{ID} (Vala)",
+             "bool has_frame" : false,
+             "items" : [
+              {
+               "$ xns" : "Gtk",
+               "* prop" : "child",
+               "Gtk.Align halign" : "Gtk.Align.START",
+               "string label" : "id: _this.{ID} (Vala)",
+               "string tooltip_text" : "Using _this.{ID} will map to this element",
+               "xtype" : "Label"
+              }
+             ],
              "listeners" : {
               "clicked" : [
                " ()  => {",
-               " \t_this.AddPropertyPopup.el.hide();",
+               " \t_this.addpop.el.hide();",
                " \t// is this userdef or special??",
                " \tvar add = new JsRender.NodeProp.prop(\"id\");",
                " \tif (_this.node.has_prop_key(add)) {",
                " \t",
                " \t_this.view.editProp( add );",
                " \t",
-               "\t",
                "}"
               ]
              },
-             "tooltip_markup" : "Using _this.{ID} will map to this element",
              "xtype" : "Button"
             },
             {
              "$ xns" : "Gtk",
-             "label" : "pack: Pack method (Vala)",
+             "bool has_frame" : false,
+             "items" : [
+              {
+               "$ xns" : "Gtk",
+               "* prop" : "child",
+               "Gtk.Align halign" : "Gtk.Align.START",
+               "string label" : "pack: Pack method (Vala)",
+               "string tooltip_text" : "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element",
+               "xtype" : "Label"
+              }
+             ],
              "listeners" : {
               "clicked" : [
                "  ( ) => {",
                " ",
                "",
-               "\t_this.AddPropertyPopup.el.hide();",
+               "  \t_this.addpop.el.hide();",
                " \t// is this userdef or special??",
                " \tvar add = new JsRender.NodeProp.special(\"pack\", \"add\");",
                " \tif (_this.node.has_prop_key(add)) {",
                "}"
               ]
              },
-             "tooltip_markup" : "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element",
              "xtype" : "Button"
             },
             {
              "$ xns" : "Gtk",
-             "label" : "ctor: Alterative to default contructor (Vala)",
+             "bool has_frame" : false,
+             "items" : [
+              {
+               "$ xns" : "Gtk",
+               "* prop" : "child",
+               "Gtk.Align halign" : "Gtk.Align.START",
+               "string label" : "ctor: Alterative to default contructor (Vala)",
+               "string tooltip_text" : [
+                "eg. ",
+                "",
+                "new Clutter.Image.from_file(.....)"
+               ],
+               "xtype" : "Label"
+              }
+             ],
              "listeners" : {
               "clicked" : [
                "  ( ) => {",
                "   ",
-               " _this.AddPropertyPopup.el.hide();",
+               "  \t_this.addpop.el.hide();",
                " \t// is this userdef or special??",
                " \tvar add = new JsRender.NodeProp.special(\"ctor\");",
                " \tif (_this.node.has_prop_key(add)) {",
                "}"
               ]
              },
-             "tooltip_markup" : [
-              "eg. ",
-              "",
-              "new Clutter.Image.from_file(.....)"
-             ],
              "xtype" : "Button"
             },
             {
              "$ xns" : "Gtk",
-             "label" : "init: initialziation code (vala)",
+             "bool has_frame" : false,
+             "items" : [
+              {
+               "$ xns" : "Gtk",
+               "* prop" : "child",
+               "Gtk.Align halign" : "Gtk.Align.START",
+               "string label" : "init: initialziation code (vala)",
+               "string tooltip_text" : "This code is called after the ctor",
+               "xtype" : "Label"
+              }
+             ],
              "listeners" : {
               "clicked" : [
                "  ( ) => {",
                "    ",
-               " _this.AddPropertyPopup.el.hide();",
+               "  \t_this.addpop.el.hide();",
                " \t// is this userdef or special??",
                " \tvar add =  new JsRender.NodeProp.special(\"init\",\"{\\n\\n}\\n\" ) ;",
                " \tif (_this.node.has_prop_key(add)) {",
                "}"
               ]
              },
-             "tooltip_markup" : "This code is called after the ctor",
              "xtype" : "Button"
             },
             {
              "$ xns" : "Gtk",
-             "label" : "cms-id: (Roo JS/Pman library)",
+             "bool has_frame" : false,
+             "items" : [
+              {
+               "$ xns" : "Gtk",
+               "* prop" : "child",
+               "Gtk.Align halign" : "Gtk.Align.START",
+               "string label" : "cms-id: (Roo JS/Pman library)",
+               "string tooltip_text" : [
+                "set the cms-id for this element, when converted to javascript, the html value will be wrapped with Pman.Cms.content({cms-id},{original-html})",
+                ""
+               ],
+               "xtype" : "Label"
+              }
+             ],
              "listeners" : {
               "clicked" : [
                " ()  => {",
-               "   ",
-               " _this.AddPropertyPopup.el.hide();",
+               "    \t_this.addpop.el.hide();",
+               " ",
                " \t// is this userdef or special??",
                " \tvar add =   new JsRender.NodeProp.prop(\"cms-id\",\"string\", \"\" ) ;",
                " \tif (_this.node.has_prop_key(add)) {",
                "}"
               ]
              },
-             "tooltip_markup" : [
-              "set the cms-id for this element, when converted to javascript, the html value will be wrapped with Pman.Cms.content({cms-id},{original-html})",
-              ""
-             ],
              "xtype" : "Button"
             },
             {
             },
             {
              "$ xns" : "Gtk",
-             "label" : "String",
+             "bool has_frame" : false,
+             "items" : [
+              {
+               "$ xns" : "Gtk",
+               "* prop" : "child",
+               "Gtk.Align halign" : "Gtk.Align.START",
+               "string label" : "String",
+               "string tooltip_text" : "Add a user defined string property",
+               "xtype" : "Label"
+              }
+             ],
              "listeners" : {
               "clicked" : [
                "(self) => {",
-               "     _this.AddPropertyPopup.el.hide();",
+               "  \t_this.addpop.el.hide();",
                "\t_this.view.popover.show(",
                "\t\t_this.view.el, ",
                "\t\t_this.node, ",
                "}"
               ]
              },
-             "tooltip_markup" : "Add a user defined string property",
              "xtype" : "Button"
             },
             {
              "$ xns" : "Gtk",
-             "label" : "Number",
+             "bool has_frame" : false,
+             "items" : [
+              {
+               "$ xns" : "Gtk",
+               "* prop" : "child",
+               "Gtk.Align halign" : "Gtk.Align.START",
+               "string label" : "Number",
+               "string tooltip_text" : "Add a user defined number property",
+               "xtype" : "Label"
+              }
+             ],
              "listeners" : {
               "clicked" : [
                "  ( ) =>{",
-               "      _this.AddPropertyPopup.el.hide();",
-               "      ",
+               " ",
+               "       \t_this.addpop.el.hide();",
                "       _this.view.popover.show(",
                "\t\t_this.view.el, ",
                "\t\t_this.node, ",
                "}"
               ]
              },
-             "tooltip_markup" : "Add a user defined number property",
              "xtype" : "Button"
             },
             {
              "$ xns" : "Gtk",
-             "label" : "Boolean",
+             "bool has_frame" : false,
+             "items" : [
+              {
+               "$ xns" : "Gtk",
+               "* prop" : "child",
+               "Gtk.Align halign" : "Gtk.Align.START",
+               "string label" : "Boolean",
+               "string tooltip_text" : "Add a user defined boolean property",
+               "xtype" : "Label"
+              }
+             ],
              "listeners" : {
               "clicked" : [
                "  ( ) =>{",
                "  ",
-               "  \t     _this.AddPropertyPopup.el.hide();",
+               "  \t_this.addpop.el.hide();",
                "   _this.view.popover.show(",
                "\t\t_this.view.el, ",
                "\t\t_this.node, ",
                "}"
               ]
              },
-             "tooltip_markup" : "Add a user defined boolean property",
              "xtype" : "Button"
             },
             {
             },
             {
              "$ xns" : "Gtk",
-             "label" : "Javascript Function",
+             "bool has_frame" : false,
+             "items" : [
+              {
+               "$ xns" : "Gtk",
+               "* prop" : "child",
+               "Gtk.Align halign" : "Gtk.Align.START",
+               "string label" : "Javascript Function",
+               "string tooltip_text" : "Add a javascript  function",
+               "xtype" : "Label"
+              }
+             ],
              "listeners" : {
               "clicked" : [
                "  ( ) =>{",
-               "  _this.AddPropertyPopup.el.hide(); ",
+               "  \t_this.addpop.el.hide();",
                "   _this.view.popover.show(",
                "\t\t_this.view.el, ",
                "\t\t_this.node, ",
                "}"
               ]
              },
-             "tooltip_markup" : "Add a user function boolean property",
              "xtype" : "Button"
             },
             {
              "$ xns" : "Gtk",
-             "label" : "Vala Method",
+             "bool has_frame" : false,
+             "items" : [
+              {
+               "$ xns" : "Gtk",
+               "* prop" : "child",
+               "Gtk.Align halign" : "Gtk.Align.START",
+               "string label" : "Vala Method",
+               "string tooltip_text" : "Add a user defined method to a object",
+               "xtype" : "Label"
+              }
+             ],
              "listeners" : {
               "clicked" : [
                "  ( ) =>{",
-               "_this.AddPropertyPopup.el.hide();",
+               "  \t_this.addpop.el.hide();",
                "    _this.view.popover.show(",
                "\t\t_this.view.el, ",
                "\t\t_this.node, ",
                "}"
               ]
              },
-             "tooltip_markup" : "Add a user function boolean property",
              "xtype" : "Button"
             },
             {
              "$ xns" : "Gtk",
-             "label" : "Vala Signal",
+             "bool has_frame" : false,
+             "items" : [
+              {
+               "$ xns" : "Gtk",
+               "* prop" : "child",
+               "Gtk.Align halign" : "Gtk.Align.START",
+               "string label" : "Vala Signal",
+               "string tooltip_text" : "Add a user defined signal to a object",
+               "xtype" : "Label"
+              }
+             ],
              "listeners" : {
               "clicked" : [
                "  ( ) =>{",
-               "  _this.AddPropertyPopup.el.hide();",
+               " \t_this.addpop.el.hide(); ",
                "  _this.view.popover.show(",
                "\t\t_this.view.el, ",
                "\t\t_this.node, ",
                "}"
               ]
              },
-             "tooltip_markup" : "Add a vala signal",
              "xtype" : "Button"
             },
             {
             },
             {
              "$ xns" : "Gtk",
-             "label" : "Flexy - If",
+             "bool has_frame" : false,
+             "items" : [
+              {
+               "$ xns" : "Gtk",
+               "* prop" : "child",
+               "Gtk.Align halign" : "Gtk.Align.START",
+               "string label" : "Flexy - If",
+               "string tooltip_text" : "Add a flexy if (for HTML templates)",
+               "xtype" : "Label"
+              }
+             ],
              "listeners" : {
               "clicked" : [
                "  ( ) =>{",
-               " \t_this.AddPropertyPopup.el.hide();",
+               "  \t_this.addpop.el.hide();",
                " \t_this.view.popover.show(",
                "\t\t_this.view.el, ",
                "\t\t_this.node, ",
                "}"
               ]
              },
-             "tooltip_markup" : "Add a flexy if (for HTML templates)",
              "xtype" : "Button"
             },
             {
              "$ xns" : "Gtk",
-             "label" : "Flexy - Include",
+             "bool has_frame" : false,
+             "items" : [
+              {
+               "$ xns" : "Gtk",
+               "* prop" : "child",
+               "Gtk.Align halign" : "Gtk.Align.START",
+               "string label" : "Flexy - Include",
+               "string tooltip_text" : "Add a flexy include (for HTML templates)",
+               "xtype" : "Label"
+              }
+             ],
              "listeners" : {
               "clicked" : [
                "  ( ) =>{",
-               " \t_this.AddPropertyPopup.el.hide();",
+               "  \t_this.addpop.el.hide();",
                " \t_this.view.popover.show(",
                "\t\t_this.view.el, ",
                "\t\t_this.node, ",
                "}"
               ]
              },
-             "tooltip_markup" : "Add a flexy include (for HTML templates)",
              "xtype" : "Button"
             },
             {
              "$ xns" : "Gtk",
-             "label" : "Flexy - Foreach",
+             "bool has_frame" : false,
+             "items" : [
+              {
+               "$ xns" : "Gtk",
+               "* prop" : "child",
+               "Gtk.Align halign" : "Gtk.Align.START",
+               "string label" : "Flexy - Foreach",
+               "string tooltip_text" : "Add a flexy foreach (for HTML templates)",
+               "xtype" : "Label"
+              }
+             ],
              "listeners" : {
               "clicked" : [
                "  ( ) =>{",
-               " \t_this.AddPropertyPopup.el.hide();",
+               "  \t_this.addpop.el.hide();",
                " \t_this.view.popover.show(",
                "\t\t_this.view.el, ",
                "\t\t_this.node, ",
          "xtype" : "Popover"
         }
        ],
-       "listeners" : {
-        "clicked" : [
-         "( ) => {",
-         "  //_this.before_edit();",
-         "  ",
-         "        ",
-         "    var p = _this.AddPropertyPopup;",
-         "    ",
-         " //\tGtk.Allocation rect;",
-         "\t//this.el.get_allocation(out rect);",
-         "\tif (p.el.parent == null) {",
-         "\t\t p.el.set_parent(this.el);",
-         "\t }",
-         "    //p.el.set_pointing_to(rect);",
-         "\tp.el.show();",
-         "\tp.el.set_position(Gtk.PositionType.BOTTOM);",
-         "\tp.el.autohide = true;",
-         "     return;",
-         "",
-         "}",
-         ""
-        ]
-       },
-       "string icon_name" : "list-add",
        "string label" : "Other",
-       "xtype" : "Button"
+       "xtype" : "MenuButton"
       }
      ],
      "xtype" : "Box"
           "\t ",
           "}"
          ],
+         "| int propToRow" : [
+          "(JsRender.NodeProp prop) {",
+          "\tfor (var i = 0 ; i < this.el.n_items; i++) {",
+          "\t\tvar r = (JsRender.NodeProp)this.el.get_item(i);",
+          "\t\tif (r.equals(prop)) {",
+          "\t\t\treturn i;",
+          "\t\t\t",
+          "\t\t}",
+          "\t}",
+          "\treturn -1;",
+          "\t ",
+          "}"
+         ],
          "| void selectProp" : [
           "(JsRender.NodeProp prop) {",
           "\tfor (var i = 0 ; i < this.el.n_items; i++) {",
         "\t\t\t\t}",
         "\t\t\t\tchild = child.get_first_child(); ",
         "\t\t\t\treading_header = false;",
+        "\t\t\t\tcontinue;",
         "\t        }",
         "\t\t    if (child.get_type().name() != \"GtkColumnViewRowWidget\") {",
         "    \t\t    child = child.get_next_sibling();",
     "   ",
     "   \tthis.loading = false;",
     "    this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);",
+    "    this.updateErrors();",
     "   // clear selection?",
     "  //this.model.el.set_sort_column_id(4,Gtk.SortType.ASCENDING); // sort by real key..",
     "   ",
     "   ",
     "}",
     ""
+   ],
+   "| void removeErrors" : [
+    "() {",
+    "\tvar  child = this.view.el.get_first_child(); ",
+    " ",
+    "\tvar reading_header = true;",
+    " ",
+    "\twhile (child != null) {",
+    "\t\tGLib.debug(\"Got %s\", child.get_type().name());",
+    "\t   ",
+    "\t   if (reading_header) {",
+    "\t\t\t",
+    "",
+    "\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
+    "\t\t\t   ",
+    "\t\t\t\tchild = child.get_next_sibling();",
+    "\t\t\t\tcontinue;",
+    "\t\t\t}",
+    "\t\t\t// should be columnlistview",
+    "\t\t\tchild = child.get_first_child(); ",
+    "\t\t ",
+    "\t\t ",
+    "\t\t\t",
+    "\t\t\treading_header = false;",
+    "\t\t\t ",
+    "\t    }",
+    "\t    ",
+    "\t  \tif (child.has_css_class(\"node-err\")) {",
+    "\t\t\tchild.remove_css_class(\"node-err\");",
+    "\t\t}",
+    "\t\tif (child.has_css_class(\"node-warn\")) {",
+    "\t\t\tchild.remove_css_class(\"node-warn\");",
+    "\t\t}",
+    "\t\t",
+    "\t\tif (child.has_css_class(\"node-depr\")) {",
+    "\t\t\tchild.remove_css_class(\"node-depr\");",
+    "\t\t}",
+    "\t\t",
+    "        child = child.get_next_sibling(); ",
+    "\t}",
+    "\t//GLib.debug(\"Rturning null\");",
+    "     ",
+    "}"
+   ],
+   "| void updateErrors" : [
+    "() {",
+    "\tvar file = this.file;",
+    "\tvar ar = file.getErrors();",
+    "\tif (ar.size < 1) {",
+    "\t\tthis.removeErrors();",
+    "\t\tthis.last_error_counter = file.error_counter ;",
+    "",
+    "\t\treturn;",
+    "\t}",
+    " \tif (this.last_error_counter == file.error_counter) {",
+    "\t\treturn;",
+    "\t}",
+    "\tthis.removeErrors();",
+    "\t",
+    "\tforeach(var diag in ar) { ",
+    "\t",
+    "\t\t ",
+    "//        print(\"get inter\\n\");",
+    "\t    var node= file.lineToNode( (int)diag.range.start.line) ;",
+    "\t    if (node == null || node.oid != this.node.oid) {",
+    "\t    \tcontinue;",
+    "    \t}",
+    "    \tvar prop = node.lineToProp( (int)diag.range.start.line) ;",
+    "    \t",
+    "    \tvar row = _this.selmodel.propToRow(prop);",
+    "    \tif (row < 0) {",
+    "    \t\tcontinue;",
+    "\t\t}",
+    "    \tvar w = this.view.getWidgetAtRow(row);",
+    "    \tif (w == null) {",
+    "    \t\treturn;",
+    "\t\t}",
+    "\t  \t\tvar ed = diag.category.down();",
+    "\t\tif (ed != \"err\" && w.has_css_class(\"node-err\")) {",
+    "\t\t\tcontinue;",
+    "\t\t}",
+    "\t\tif (ed == \"err\" && w.has_css_class(\"node-warn\")) {",
+    "\t\t\tw.remove_css_class(\"node-warn\");",
+    "\t\t}",
+    "\t\tif (ed == \"err\" && w.has_css_class(\"node-depr\")) {",
+    "\t\t\tw.remove_css_class(\"node-depr\");",
+    "\t\t}",
+    "\t\tif (!w.has_css_class(\"node-\"+ ed)) {",
+    "\t\t\tw.add_css_class(\"node-\" + ed);",
+    "\t\t}",
+    "\t\t",
+    "\t}",
+    "\t",
+    "}"
    ]
   }
  ],