Fix #7301 - Drag properties with 'special' stuff like buttons - overwrites labels?
authorAlan <alan@roojs.com>
Thu, 7 Jul 2022 04:49:19 +0000 (12:49 +0800)
committerAlan <alan@roojs.com>
Thu, 7 Jul 2022 04:49:19 +0000 (12:49 +0800)
src/Builder4/GladeView.bjs
src/Builder4/GladeView.vala
src/Builder4/WindowLeftTree.bjs
src/Builder4/WindowLeftTree.vala
src/JsRender/Node.vala
src/Palete/Gtk.vala

index 83fb0f0..7d66ea3 100644 (file)
@@ -11,7 +11,6 @@
      "items" : [
       {
        "$ Gtk.Align halign" : "Gtk.Align.CENTER",
-       "$ Gtk.ImageType storage_type" : "Gtk.ImageType.PIXBUF",
        "$ xns" : "Gtk",
        "* prop" : "image",
        "bool has_default" : true,
      "string label" : "Label",
      "xtype" : "Button"
     },
-    {
-     "$ xns" : "Gtk",
-     "* prop" : "buttons[]",
-     "* response_id" : 1,
-     "string label" : "Label",
-     "xtype" : "Button"
-    },
     {
      "$ xns" : "Gtk",
      "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
        "items" : [
         {
          "$ xns" : "Gtk",
-         "string label" : "Label",
+         "string label" : "xxxcc",
+         "xtype" : "Button"
+        },
+        {
+         "$ xns" : "Gtk",
+         "string label" : "xxxcc",
          "xtype" : "Button"
         }
        ],
-       "listeners" : {
-        "delete_event" : [
-         "(event) => {",
-         "",
-         "\treturn bool;",
-         "}",
-         ""
-        ]
-       },
-       "xtype" : "ButtonBox",
-       "| void test1" : [
-        "() {",
-        "",
-        "}"
-       ]
+       "xtype" : "ButtonBox"
       }
      ],
      "xtype" : "Box"
index d9718ba..273e2e0 100644 (file)
@@ -26,11 +26,9 @@ public class GladeView : Object
         // set gobject values
         var child_0 = new Xcls_Button2( _this );
         this.el.add_action_widget( child_0.el, 0);
-        var child_1 = new Xcls_Button4( _this );
-        this.el.add_action_widget( child_1.el, 1);
-        var child_2 = new Xcls_Box5( _this );
-        child_2.ref();
-        this.el.get_content_area().add( child_2.el );
+        var child_1 = new Xcls_Box4( _this );
+        child_1.ref();
+        this.el.get_content_area().add( child_1.el );
     }
 
     // user defined functions
@@ -77,7 +75,6 @@ public class GladeView : Object
             // my vars (dec)
 
             // set gobject values
-            this.el.storage_type = Gtk.ImageType.PIXBUF;
             this.el.has_default = true;
             this.el.halign = Gtk.Align.CENTER;
             this.el.icon_size = 33;
@@ -87,86 +84,80 @@ public class GladeView : Object
     }
 
 
-    public class Xcls_Button4 : Object
+    public class Xcls_Box4 : Object
     {
-        public Gtk.Button el;
+        public Gtk.Box el;
         private GladeView  _this;
 
 
             // my vars (def)
 
         // ctor
-        public Xcls_Button4(GladeView _owner )
+        public Xcls_Box4(GladeView _owner )
         {
             _this = _owner;
-            this.el = new Gtk.Button();
+            this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
 
             // my vars (dec)
 
             // set gobject values
-            this.el.label = "Label";
+            var child_0 = new Xcls_ButtonBox5( _this );
+            child_0.ref();
+            this.el.add(  child_0.el );
         }
 
         // user defined functions
     }
-
-    public class Xcls_Box5 : Object
+    public class Xcls_ButtonBox5 : Object
     {
-        public Gtk.Box el;
+        public Gtk.ButtonBox el;
         private GladeView  _this;
 
 
             // my vars (def)
 
         // ctor
-        public Xcls_Box5(GladeView _owner )
+        public Xcls_ButtonBox5(GladeView _owner )
         {
             _this = _owner;
-            this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
+            this.el = new Gtk.ButtonBox( Gtk.Orientation.HORIZONTAL );
 
             // my vars (dec)
 
             // set gobject values
-            var child_0 = new Xcls_ButtonBox6( _this );
+            var child_0 = new Xcls_Button6( _this );
             child_0.ref();
             this.el.add(  child_0.el );
+            var child_1 = new Xcls_Button7( _this );
+            child_1.ref();
+            this.el.add(  child_1.el );
         }
 
         // user defined functions
     }
-    public class Xcls_ButtonBox6 : Object
+    public class Xcls_Button6 : Object
     {
-        public Gtk.ButtonBox el;
+        public Gtk.Button el;
         private GladeView  _this;
 
 
             // my vars (def)
 
         // ctor
-        public Xcls_ButtonBox6(GladeView _owner )
+        public Xcls_Button6(GladeView _owner )
         {
             _this = _owner;
-            this.el = new Gtk.ButtonBox( Gtk.Orientation.HORIZONTAL );
+            this.el = new Gtk.Button();
 
             // my vars (dec)
 
             // set gobject values
-            var child_0 = new Xcls_Button7( _this );
-            child_0.ref();
-            this.el.add(  child_0.el );
-
-            //listeners
-            this.el.delete_event.connect( (event) => {
-            
-               return bool;
-            });
+            this.el.label = "xxxcc";
         }
 
         // user defined functions
-        public void test1 () {
-        
-        }
     }
+
     public class Xcls_Button7 : Object
     {
         public Gtk.Button el;
@@ -184,7 +175,7 @@ public class GladeView : Object
             // my vars (dec)
 
             // set gobject values
-            this.el.label = "Label";
+            this.el.label = "xxxcc";
         }
 
         // user defined functions
index fff1b6e..7b1ed40 100644 (file)
           "        ",
           "        ",
           "        ",
-          "// load children - if it has any..",
+          "\t\t// load children - if it has any..",
           "      ",
           "        if (node.items.size > 0) {",
           "            this.load(node.items, n_iter);",
           "    var node = this.pathToNode(mod.get_path(old_iter).to_string());",
           "    //console.dump(node);",
           "    if (node == null) {",
-          "        print(\"moveNode: ERROR - node is null?\");",
+          "        GLib.debug(\"moveNode: ERROR - node is null?\");",
           "    }",
           "    ",
           "    ",
           "",
           "    ",
           "    if ((action & Gdk.DragAction.MOVE) > 0) {",
-          "            print(\"REMOVING OLD NODE : \" + target_data + \"\\n\");",
+          "            GLib.debug(\"REMOVING OLD NODE : \" + target_data + \"\\n\");",
           "            node.remove();",
           "            this.dropNode(target_data, node, false);",
           "            this.el.remove(ref old_iter);",
           "            ",
           "                         ",
           "    } else {",
-          "        print(\"DROPPING NODE // copy: \" + target_data + \"\\n\");",
+          "        GLib.debug(\"DROPPING NODE // copy: \" + target_data + \"\\n\");",
           "        node = node.deepClone();",
           "        this.dropNode(target_data, node, false);",
           "    }",
index 5d29c0a..ebee1ee 100644 (file)
@@ -997,7 +997,7 @@ public class Xcls_WindowLeftTree : Object
         {
             _this = _owner;
             _this.model = this;
-            this.el = new Gtk.TreeStore( 4, typeof(string),typeof(string),typeof(Object),typeof(Gdk.Pixbuf) );
+            this.el = new Gtk.TreeStore.newv(  { typeof(string),typeof(string),typeof(Object),typeof(Gdk.Pixbuf) }  );
 
             // my vars (dec)
             this.template_select = null;
@@ -1352,7 +1352,7 @@ public class Xcls_WindowLeftTree : Object
                 
                 
                 
-        // load children - if it has any..
+                       // load children - if it has any..
               
                 if (node.items.size > 0) {
                     this.load(node.items, n_iter);
@@ -1398,7 +1398,7 @@ public class Xcls_WindowLeftTree : Object
             var node = this.pathToNode(mod.get_path(old_iter).to_string());
             //console.dump(node);
             if (node == null) {
-                print("moveNode: ERROR - node is null?");
+                GLib.debug("moveNode: ERROR - node is null?");
             }
             
             
@@ -1408,7 +1408,7 @@ public class Xcls_WindowLeftTree : Object
         
             
             if ((action & Gdk.DragAction.MOVE) > 0) {
-                    print("REMOVING OLD NODE : " + target_data + "\n");
+                    GLib.debug("REMOVING OLD NODE : " + target_data + "\n");
                     node.remove();
                     this.dropNode(target_data, node, false);
                     this.el.remove(ref old_iter);
@@ -1416,7 +1416,7 @@ public class Xcls_WindowLeftTree : Object
                     
                                  
             } else {
-                print("DROPPING NODE // copy: " + target_data + "\n");
+                GLib.debug("DROPPING NODE // copy: " + target_data + "\n");
                 node = node.deepClone();
                 this.dropNode(target_data, node, false);
             }
index 1866b91..e95661a 100644 (file)
@@ -508,6 +508,7 @@ public class JsRender.Node : Object {
        }
 
        public void loadFromJson(Json.Object obj, int version) {
+                
                obj.foreach_member((o , key, value) => {
                        //print(key+"\n");
                        if (key == "items") {
@@ -531,16 +532,19 @@ public class JsRender.Node : Object {
 
                        var rkey = key;
                        var sval = this.jsonNodeAsString(value);
+               
                        if (version == 1) {
                                rkey = this.upgradeKey(key, sval);
                        }
                        var n =  new NodeProp.from_json(rkey, sval);
                                
                        this.props.set(n.to_index_key(),  n );
-                       
+
 
                });
                
+               
+               
 
 
 
index c4fd701..202d2f0 100644 (file)
@@ -818,14 +818,19 @@ namespace Palete {
                                 
                                if (this.child_defaults.has_key(parent.fqn())) {
                                        foreach(var k in this.child_defaults.get(parent.fqn())) {
-                                               child.set_prop(k.dupe());
+                                               if (!child.has(k.to_index_key())) { 
+                                                       child.set_prop(k.dupe());
+                                               }
                                        }
                                }
                        }
                        if (this.node_defaults.has_key(child.fqn())) {
                                foreach(var k in this.node_defaults.get(child.fqn())) {
-                                       GLib.print("Adding Property %s", k.to_tooltip());
-                                       child.set_prop(k.dupe());
+
+                                       if (!child.has(k.to_index_key())) { 
+                                               GLib.debug("Adding Property %s", k.to_tooltip());
+                                               child.set_prop(k.dupe());
+                                       }
                                }
                        }