Fix #8003 - undo code
[roobuilder] / src / Builder4 / WindowLeftTree.bjs
index fad8976..641f61d 100644 (file)
@@ -3,7 +3,7 @@
  "gen_extended" : false,
  "items" : [
   {
-   "# Xcls_MainWindow main_window" : "null",
+   "# Xcls_MainWindow? main_window" : "null",
    "$ xns" : "Gtk",
    "@ bool before_node_change" : "()",
    "@ void changed" : "()",
            "    \tGLib.warning(\"No node found at row %d\", row);",
            "    \treturn;",
            "\t}",
+           "\t",
+           "\t",
            "\t_this.model.selectNode(node);",
            "     ",
            "     ",
          },
          "xtype" : "EventControllerKey"
         },
+        {
+         "$ xns" : "Gtk",
+         "id" : "keystate",
+         "int is_shift" : 0,
+         "listeners" : {
+          "key_pressed" : [
+           "(keyval, keycode, state) => {",
+           "",
+           " \tif (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {",
+           " \t\tthis.is_shift = 1;",
+           "\t}",
+           "\treturn true;",
+           "}",
+           ""
+          ],
+          "key_released" : [
+           "(keyval, keycode, state) => {",
+           "\tGLib.debug(\"key release %d, %d, %d\" , (int) keyval, (int)  keycode, state);",
+           " \tif (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {",
+           " \t\tthis.is_shift = 0;",
+           "\t}",
+           "\t//GLib.debug(\"set state %d , shift = %d\", (int)this.el.get_current_event_state(), Gdk.ModifierType.SHIFT_MASK);",
+           "",
+           "",
+           " ",
+           "}"
+          ]
+         },
+         "xtype" : "EventControllerKey"
+        },
         {
          "$ xns" : "Gtk",
          "* ctor" : [
            "\t\t",
            "\t\t var m = (GLib.ListStore) _this.model.el.model;",
            "     \t_this.main_window.windowstate.file.tree = dropNode;  ",
-           "    ",
+           "    \tdropNode.updated_count++;",
            "   ",
            "\t\tm.append(dropNode);",
            "\t\t_this.model.selectNode(dropNode); \t",
            "\t\t \t\t_this.view.dragNode.remove();",
            "\t \t\t}",
            "\t \t\t\t",
-           "\t \t\t",
+           "\t \t\tdropNode.updated_count++;",
            " \t\t\t_this.model.selectNode(dropNode); ",
            " \t\t\t",
            " \t\t\t_this.changed();\t\t\t\t \t\t",
            "\t\t \t\t_this.model.selectNode(null); \t \t\t",
            "\t\t \t\t_this.view.dragNode.remove();",
            "\t \t\t}",
-           "\t",
+           "\t\t\tdropNode.updated_count++;",
            " \t\t\t_this.model.selectNode(dropNode); \t\t\t",
            " \t\t\t_this.changed();",
            " \t\t\treturn true;",
            "\t",
            " \t\t\t",
            " \t\t\tnode.parent.insertAfter(dropNode, node);",
+           " \t\t\tdropNode.updated_count++;",
            " \t\t\t_this.model.selectNode(dropNode);\t",
            " \t\t\t_this.changed();",
            " \t\t\t// select it",
             "\tfor (var i = 0; i < s.n_items; i++) {",
             "\t\t//GLib.debug(\"check node %s\", s.get_item(i).get_type().name());",
             "\t\tvar lr = s.get_item(i) as Gtk.TreeListRow;",
-            "\t\tGLib.debug(\"check node %s\", lr.get_item().get_type().name());",
+            "\t\t//GLib.debug(\"check node %s\", lr.get_item().get_type().name());",
             "\t\tif ((lr.get_item() as JsRender.Node).oid == node.oid) {",
             "\t\t\treturn i;",
             "\t\t\t",
          ],
          "string title" : "Add",
          "xtype" : "ColumnViewColumn"
-        },
-        {
-         "$ xns" : "Gtk",
-         "id" : "keystate",
-         "int is_shift" : 0,
-         "listeners" : {
-          "key_pressed" : [
-           "(keyval, keycode, state) => {",
-           "",
-           " \tif (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {",
-           " \t\tthis.is_shift = 1;",
-           "\t}",
-           "\treturn true;",
-           "}",
-           ""
-          ],
-          "key_released" : [
-           "(keyval, keycode, state) => {",
-           "\tGLib.debug(\"key release %d, %d, %d\" , (int) keyval, (int)  keycode, state);",
-           " \tif (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {",
-           " \t\tthis.is_shift = 0;",
-           "\t}",
-           "\t//GLib.debug(\"set state %d , shift = %d\", (int)this.el.get_current_event_state(), Gdk.ModifierType.SHIFT_MASK);",
-           "",
-           "",
-           " ",
-           "}"
-          ]
-         },
-         "xtype" : "EventControllerKey"
         }
        ],
        "string name" : "left-tree-view",
         "\t\t\t\theader_height =  h;",
         "\t\t\t\t",
         "\t\t\t\treading_header = false;",
-        "\t\t\t\t",
+        "\t\t\t\tcontinue;",
         "\t        }",
         "\t\t    line_no++;",
         "",
         "",
         "\t\t\tvar hh = child.get_height();",
         "\t\t\t//GLib.debug(\"got cell xy = %d,%d  w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
-        "",
+        "\t\t\tif (child.has_css_class(\"node-err\") || ",
+        "\t\t\t\tchild.has_css_class(\"node-warn\") || ",
+        "\t\t\t\tchild.has_css_class(\"node-depr\")) {",
+        "\t\t\t\thh += 10;",
+        "\t\t\t",
+        "\t\t\t}\t",
         "\t\t    if (y > curr_y && y <= header_height + hh + curr_y ) {",
         "\t\t\t    return (Gtk.Widget)child;",
         "\t\t    }",
         "    \tvar reading_header = true;",
         "\t ",
         "    \twhile (child != null) {",
-        "\t\t\tGLib.debug(\"Got %s\", child.get_type().name());",
+        "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
         "    \t   ",
         "    \t   if (reading_header) {",
         "\t\t\t\t",
         "\t\t\t ",
         "\t\t\t\t",
         "\t\t\t\treading_header = false;",
-        "\t\t\t\t ",
+        "\t\t\t\tcontinue;",
         "\t\t    }",
         "\t\t    ",
         "\t\t  ",
        ],
        "| int getColAt" : [
         "(double x,  double y) {",
-        "/*",
-        "    \t",
-        "from    \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
-        "    \t  ",
-        "    \t*/",
-        "\t\t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
-        "\t\t//GLib.debug(\"Cehck %d, %d\", x,y);",
-        "        var  child = this.el.get_first_child(); ",
-        "    \t ",
-        "    \tvar col = 0;",
-        "    \tvar offx = 0;",
-        "    \twhile (child != null) {",
-        "\t\t\t",
-        "\t\t\tif (child.get_type().name() == \"GtkColumnViewRowWidget\") {",
-        "\t\t\t\tchild = child.get_first_child();",
-        "\t\t\t\tcontinue;",
-        "\t\t\t}",
+        "\t/*",
         "\t\t\t",
-        "\t\t\t//child.get_allocation(out alloc);",
-        "\t\t\tif (x <  (child.get_width() + offx)) {",
-        "\t\t\t\treturn col;",
-        "\t\t\t}",
-        "\t\t\treturn 1;",
-        "\t\t\t//offx += child.get_width();",
-        "\t\t\t//col++;",
-        "\t\t\t//child = child.get_next_sibling();",
+        "\tfrom    \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
+        "    \t  ",
+        "\t*/",
+        "\t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
+        "\t//GLib.debug(\"Cehck %d, %d\", x,y);",
+        "    var  child = this.el.get_first_child(); ",
+        "\t ",
+        "\tvar col = 0;",
+        "\tvar offx = 0;",
+        "\twhile (child != null) {",
+        "\t\t",
+        "\t\tif (child.get_type().name() == \"GtkColumnViewRowWidget\") {",
+        "\t\t\tchild = child.get_first_child();",
+        "\t\t\tcontinue;",
         "\t\t}",
-        "    \t     ",
-        "\t\t\t  ",
-        "        return -1;",
+        "\t\t",
+        "\t\t//child.get_allocation(out alloc);",
+        "\t\tif (x <  (child.get_width() + offx)) {",
+        "\t\t\treturn col;",
+        "\t\t}",
+        "\t\treturn 1;",
+        "\t\t//offx += child.get_width();",
+        "\t\t//col++;",
+        "\t\t//child = child.get_next_sibling();",
+        "\t}",
+        "\t     ",
+        "\t\t  ",
+        "    return -1;",
         "",
         " }"
        ],
         "    \t*/",
         " \t\t ",
         " \t\t",
-        " \t\t//GLib.debug(\"offset = %d  y = %d\", (int) voff, (int) in_y);",
+        " \t\tGLib.debug(\"get Widget At Row x = %d  y = %d\", (int) x, (int) in_y);",
         "    \tvar y = in_y + _this.viewwin.el.vadjustment.value; ",
         "        var  child = this.el.get_first_child(); ",
         "    \t//Gtk.Allocation alloc = { 0, 0, 0, 0 };",
         "\t\t\t\t}",
         "\t\t\t\t// should be columnlistview",
         "\t\t\t\tchild = child.get_first_child(); ",
-        "\t\t\t    GLib.debug(\"header height=%d\", h);",
+        "\t\t\t    //GLib.debug(\"header height=%d\", h);",
         "\t\t\t\theader_height =  h;",
         "\t\t\t\t",
         "\t\t\t\treading_header = false;",
+        "\t\t\t\tcontinue;",
         "\t\t\t\t",
         "\t        }",
         "\t        ",
         "\t\t    ",
         "\t\t    line_no++;",
         "\t\t\tvar hh = child.get_height();",
+        "\t\t\t",
+        "\t\t\tif (child.has_css_class(\"node-err\") || ",
+        "\t\t\t\tchild.has_css_class(\"node-warn\") || ",
+        "\t\t\t\tchild.has_css_class(\"node-depr\")) {",
+        "\t\t\t\thh += 10;",
+        "\t\t\t",
+        "\t\t\t}",
         "\t\t\t//child.get_allocation(out alloc);",
         "\t\t\t//GLib.debug(\"got cell xy = %d,%d  w,h= %d,%d\", alloc.x, alloc.y, alloc.width, alloc.height);",
         "\t\t\t//GLib.debug(\"row %d y= %d %s\", line_no, (int) (header_height + alloc.y),",
     "\tvar reading_header = true;",
     " ",
     "\twhile (child != null) {",
-    "\t\tGLib.debug(\"Got %s\", child.get_type().name());",
+    "\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
     "\t   ",
     "\t   if (reading_header) {",
     "\t\t\t",
     "\t\t ",
     "\t\t\t",
     "\t\t\treading_header = false;",
-    "\t\t\t ",
+    "\t\t\t continue;",
     "\t    }",
     "\t    ",
-    "\t  \tif (!child.has_css_class(\"node-err\")) {",
+    "\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\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\tif (child.has_css_class(\"node-depr\")) {",
     "\t\t\tchild.remove_css_class(\"node-depr\");",
     "\t\t}",
     "\t\t",
    "| void updateErrors" : [
     "() {",
     "\tvar file = this.getActiveFile();",
+    "\tif (file == null) {",
+    "\t\treturn;",
+    "\t}",
+    "\t",
     "\tvar ar = file.getErrors();",
-    "\tif (ar.size < 1) {",
-    "\t\tthis.removeErrors();",
+    "\tif (ar == null || ar.size < 1) {",
+    "\t\tif (this.last_error_counter != file.error_counter) {",
+    "\t\t\tthis.removeErrors();",
+    "\t\t}",
+    "\t",
     "\t\tthis.last_error_counter = file.error_counter ;",
     "",
     "\t\treturn;",