src/Builder4/WindowLeftProps.bjs
authorAlan Knowles <alan@roojs.com>
Tue, 10 Mar 2015 04:12:06 +0000 (12:12 +0800)
committerAlan Knowles <alan@roojs.com>
Tue, 10 Mar 2015 04:12:06 +0000 (12:12 +0800)
src/Builder4/WindowLeftProps.vala

src/Builder4/WindowLeftProps.bjs
src/Builder4/WindowLeftProps.vala

index 871b6e8..afc40cd 100644 (file)
@@ -8,8 +8,8 @@
  "items" : [
   {
    "# bool allow_edit" : false,
-   "id" : "LeftProps",
    "|              void before_edit" : "()\n{\n\n    print(\"before edit - stop editing\\n\");\n    \n  // these do not appear to trigger save...\n    _this.keyrender.el.stop_editing(false);\n    _this.keyrender.el.editable  =false;\n\n    _this.valrender.el.stop_editing(false);\n    _this.valrender.el.editable  =false;    \n    \n    \n// technicall stop the popup editor..\n\n}\n",
+   "id" : "LeftProps",
    "|              string keySortFormat" : "(string key) {\n    // listeners first - with 0\n    // specials\n    if (key[0] == '*') {\n        return \"1 \" + key;\n    }\n    // functions\n    \n    var bits = key.split(\" \");\n    \n    if (key[0] == '|') {\n        return \"2 \" + bits[bits.length -1];\n    }\n    // signals\n    if (key[0] == '@') {\n        return \"3 \" + bits[bits.length -1];\n    }\n        \n    // props\n    if (key[0] == '#') {\n        return \"4 \" + bits[bits.length -1];\n    }\n    // the rest..\n    return \"5 \" + bits[bits.length -1];    \n\n\n\n}",
    "|              void finish_editing" : "() {\n     // \n    this.before_edit();\n}",
    "|              bool startEditingValue" : "( Gtk.TreePath path) {\n\n    // ONLY return true if editing is allowed - eg. combo..\n    \n            print(\"start editing?\\n\");\n            if (!this.stop_editor()) {\n                print(\"stop editor failed\\n\");\n                return false;\n            }\n            \n            Gtk.TreeIter iter;\n\n            var mod = this.model.el;\n            mod.get_iter (out iter, path);\n             \n            /*\n                m.set(iter, \n                        0, \"listener\",\n                        1, miter.get_key(),\n                        2, \"<b>\" + miter.get_key() + \"</b>\",\n                        3, miter.get_value()\n                    ); \n             \n            */\n            GLib.Value gval;\n            mod.get_value(iter, 3 , out gval);\n            var val = (string)gval;\n        \n            mod.get_value(iter, 1 , out gval);\n            var key = (string)gval;\n            var type_ar = key.split(\" \");\n            \n            \n            \n            mod.get_value(iter, 0 , out gval);\n            var type = (string)gval;\n            \n           \n            \n            var use_textarea = false;\n\n            //------------ things that require the text editor...\n            \n            if (type == \"listener\") {\n                use_textarea = true;\n            }\n            if (key.length > 0 && key[0] == '|') { // user defined method\n                use_textarea = true;\n            }\n            if (key.length > 0 && key[0] == '$') { // raw string\n                use_textarea = true;\n            }\n            if (key.length > 0 && key == \"* init\") {\n                use_textarea = true;\n            }\n            if (val.length > 40) { // long value...\n                use_textarea = true;\n            }\n            \n            \n            \n            if (use_textarea) {\n                print(\"Call show editor\\n\");\n                GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {\n                    this.view.el.get_selection().select_path(path);\n                    \n                    this.show_editor(file, node, type, key);\n                    \n                    return false;\n                });\n               \n                \n                return false;\n            }\n            // others... - fill in options for true/false?\n           print(\"turn on editing %s \\n\" , mod.get_path(iter).to_string());\n           \n               print (type_ar[0].up());\n                if (type_ar.length > 1 && (\n                        type_ar[0].up() == \"BOOLEAN\"\n                        ||\n                        type_ar[0].up() == \"BOOL\"                        \n                    )) {\n                        print(\"start editing try/false)???\");\n                        this.valrender.el.has_entry = false;\n                        string[] opts =  { \"true\", \"false\" };\n                        this.valrender.setOptions(opts);\n                        \n                        this.valrender.el.has_entry = false;\n                        this.valrender.el.editable = true;\n                         this.allow_edit  = true;\n                         GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {\n                             this.view.el.set_cursor_on_cell(\n                                path,\n                                this.valcol.el,\n                                this.valrender.el,\n                                true\n                            );\n                            return false;\n                        });\n                        return true;\n                }\n                                      \n                \n           \n             string[] opts =  {  };\n            this.valrender.setOptions(opts);\n           \n           GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => {\n                \n                // at this point - work out the type...\n                // if its' a combo... then show the options..\n                this.valrender.el.has_entry = true;\n                \n                this.valrender.el.editable = true;            \n            \n                \n                this.allow_edit  = true;\n                \n                \n                \n                \n\n                this.view.el.set_cursor_on_cell(\n                    path,\n                    this.valcol.el,\n                    this.valrender.el,\n                    true\n                );\n                return false;\n            });\n            return false;\n        }\n",
          "$ xns" : "Gtk",
          "items" : [
           {
+           "$ stock" : "Gtk.STOCK_ADD",
            "* pack" : "add",
            "xtype" : "Image",
-           "$ stock" : "Gtk.STOCK_ADD",
            "$ xns" : "Gtk",
            "$ icon_size" : "Gtk.IconSize.MENU"
           },
           {
            "label" : "Other",
-           "xtype" : "Label",
            "* pack" : "add",
+           "xtype" : "Label",
            "$ xns" : "Gtk"
           }
          ]
         },
         {
          "id" : "AddPropertyPopup",
-         "xtype" : "Menu",
          "* pack" : false,
+         "xtype" : "Menu",
          "$ xns" : "Gtk",
          "items" : [
           {
@@ -74,8 +74,8 @@
             "activate" : " ()  => {\n    _this.addProp( \"prop\", \"id\", \"\", \"\");\n}"
            },
            "label" : "id: _this.{ID} (Vala)",
-           "xtype" : "MenuItem",
            "* pack" : "append",
+           "xtype" : "MenuItem",
            "tooltip_markup" : "Using _this.{ID} will map to this element",
            "$ xns" : "Gtk"
           },
@@ -84,8 +84,8 @@
             "activate" : "  ( ) => {\n\n    _this.addProp( \"prop\", \"pack\",\"add\", \"*\");\n}"
            },
            "label" : "pack: Pack method (Vala)",
-           "* pack" : "append",
            "xtype" : "MenuItem",
+           "* pack" : "append",
            "tooltip_markup" : "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element",
            "$ xns" : "Gtk"
           },
@@ -94,8 +94,8 @@
             "activate" : "  ( ) => {\n\n    _this.addProp( \"prop\", \"ctor\",\"\", \"*\");\n}"
            },
            "label" : "ctor: Alterative to default contructor",
-           "xtype" : "MenuItem",
            "* pack" : "append",
+           "xtype" : "MenuItem",
            "tooltip_markup" : "eg. \n\nnew Clutter.Image.from_file(.....)",
            "$ xns" : "Gtk"
           },
             "activate" : "  ( ) => {\n\n    _this.addProp( \"prop\",  \"init\", \"{\\n\\n}\\n\", \"*\" );\n}"
            },
            "label" : "init: initialziation code (vala)",
-           "xtype" : "MenuItem",
            "* pack" : "append",
+           "xtype" : "MenuItem",
            "tooltip_markup" : "This code is called after the ctor",
            "$ xns" : "Gtk"
           },
             "activate" : "  (self) => {\n\n    _this.addProp( \"prop\", \"XXXX\", \"\",\"string\");\n\n}"
            },
            "label" : "String",
-           "xtype" : "MenuItem",
            "* pack" : "append",
+           "xtype" : "MenuItem",
            "tooltip_markup" : "Add a user defined string property",
            "$ xns" : "Gtk"
           },
             "activate" : "  ( ) =>{\n\n    _this.addProp(\"prop\",  \"XXX\", \"0\", \"int\");\n}"
            },
            "label" : "Number",
-           "xtype" : "MenuItem",
            "* pack" : "append",
+           "xtype" : "MenuItem",
            "tooltip_markup" : "Add a user defined number property",
            "$ xns" : "Gtk"
           },
             "activate" : "  ( ) =>{\n\n    _this.addProp( \"prop\", \"XXX\", \"true\", \"bool\");\n}"
            },
            "label" : "Boolean",
-           "xtype" : "MenuItem",
            "* pack" : "append",
+           "xtype" : "MenuItem",
            "tooltip_markup" : "Add a user defined boolean property",
            "$ xns" : "Gtk"
           },
             "activate" : "  ( ) =>{\n\n    _this.addProp(\"prop\",  \"XXXX\", \"function() { }\", \"| function\");\n}"
            },
            "label" : "Javascript Function",
-           "xtype" : "MenuItem",
            "* pack" : "append",
+           "xtype" : "MenuItem",
            "tooltip_markup" : "Add a user function boolean property",
            "$ xns" : "Gtk"
           },
             "activate" : "  ( ) =>{\n\n    _this.addProp( \"prop\", \"XXXX\", \"() {\\n\\n}\\n\", \"| return_type\");\n}"
            },
            "label" : "Vala Method",
-           "* pack" : "append",
            "xtype" : "MenuItem",
+           "* pack" : "append",
            "tooltip_markup" : "Add a user function boolean property",
            "$ xns" : "Gtk"
           },
             "activate" : "  ( ) =>{\n\n    _this.addProp( \"prop\", \"XXXX\", \"()\", \"@ void\");\n}"
            },
            "label" : "Vala Signal",
-           "xtype" : "MenuItem",
            "* pack" : "append",
+           "xtype" : "MenuItem",
            "tooltip_markup" : "Add a vala signal",
            "$ xns" : "Gtk"
+          },
+          {
+           "* pack" : "add",
+           "xtype" : "SeparatorMenuItem",
+           "$ xns" : "Gtk"
+          },
+          {
+           "listeners" : {
+            "activate" : "  ( ) =>{\n\n    _this.addProp(\"prop\",  \"XXXX\", \"function() { }\", \"| function\");\n}"
+           },
+           "label" : "Flexy - Foreach",
+           "xtype" : "MenuItem",
+           "* pack" : "append",
+           "tooltip_markup" : "Add a user function boolean property",
+           "$ xns" : "Gtk"
           }
          ]
         }
             "edited" : "  (path, newtext) => {\n        print(\"Keyrender  - signal:edited\\n\");\n    \n    this.el.editable = false;\n  \n \n\n        Gtk.TreeIter  iter;\n        _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));\n        GLib.Value gval;\n        \n         _this.model.el.get_value(iter,1, out gval);\n        var oldval = (string)gval;\n        \n         _this.model.el.get_value(iter,0, out gval);\n        var ktype = (string)gval;\n       \n        _this.model.el.set_value(iter, 1, newtext);\n        \n        if (oldval == newtext) {\n            return;\n        }\n        \n        \n        print(\"ktype: %s\\n\",ktype);\n        switch(ktype) {\n            case \"listener\":\n                var ov = _this.node.listeners.get(oldval);\n                _this.node.listeners.set(newtext, ov);\n                _this.node.listeners.remove(oldval);\n                \n                _this.updateIter(iter,  ktype, newtext, ov);\n                \n                break;\n            case \"props\":\n                var ov = _this.node.props.get(oldval);\n                _this.node.props.set(newtext, ov);\n                _this.node.props.remove(oldval);\n                _this.updateIter(iter,  ktype, newtext, ov);\n                break;\n         }\n         _this.changed();\n          \n}"
            },
            "id" : "keyrender",
-           "* pack" : "pack_start,false",
            "xtype" : "CellRendererText",
+           "* pack" : "pack_start,false",
            "$ xns" : "Gtk"
           }
          ]
             "edited" : "  (path, newtext) => {\n    print(\"Valrender  - signal:edited\\n\");\n  \n        this.el.editable = false;\n/*  \n m.set(iter, \n                0, \"listener\",\n                1, miter.get_key(),\n                2, \"<b>\" + miter.get_key() + \"</b>\",\n                3, miter.get_value(),\n                4, display_value(short);\n            ); \n\n  */      \n\n        Gtk.TreeIter  iter;\n        _this.model.el.get_iter(out iter, new Gtk.TreePath.from_string(path));\n        GLib.Value gval;\n        \n         _this.model.el.get_value(iter,0, out gval);\n        var ktype = (string)gval;\n        \n        \n         _this.model.el.get_value(iter,3, out gval);\n        var oldval = (string)gval;\n        \n         _this.model.el.get_value(iter,1, out gval);\n        var key = (string)gval;\n        \n         \n        \n        switch(ktype) {\n            case \"listener\":\n                _this.node.listeners.set(key, newtext);\n                _this.updateIter(iter,ktype,key,newtext);\n                break;\n            case \"props\":\n                _this.node.props.set(key,newtext);\n                _this.updateIter(iter,ktype, key,newtext);                \n                break;\n         }\n//         _this.load(_this.file,_this.node);\n         _this.changed();\n          \n}"
            },
            "id" : "valrender",
-           "xtype" : "CellRendererCombo",
            "* pack" : "pack_start,true",
+           "xtype" : "CellRendererCombo",
            "$ editable" : false,
            "$ has_entry" : true,
            "$ xns" : "Gtk",
            "items" : [
             {
              "id" : "valrendermodel",
-             "xtype" : "ListStore",
              "* pack" : false,
+             "xtype" : "ListStore",
              "$ columns" : "typeof(string)",
              "n_columns" : 1,
              "$ xns" : "Gtk",
         },
         {
          "id" : "ContextMenu",
-         "* pack" : false,
          "xtype" : "Menu",
+         "* pack" : false,
          "$ xns" : "Gtk",
          "items" : [
           {
             "activate" : "  ( )  =>{\n  \n    var s = _this.view.el.get_selection();\n    Gtk.TreeIter iter;\n    Gtk.TreeModel model;\n    s.get_selected (out  model, out  iter);\n    _this.startEditingKey(model.get_path(iter));\n}"
            },
            "label" : "Edit",
-           "* pack" : "append",
            "xtype" : "MenuItem",
+           "* pack" : "append",
            "$ xns" : "Gtk"
           },
           {
             "activate" : "  ( )  =>{\n\t_this.deleteSelected();\n}"
            },
            "label" : "Delete",
-           "* pack" : "append",
            "xtype" : "MenuItem",
+           "* pack" : "append",
            "$ xns" : "Gtk"
           }
          ]
index 7ca8dcc..7c73db7 100644 (file)
@@ -718,6 +718,12 @@ public class Xcls_LeftProps : Object
             var child_11 = new Xcls_MenuItem19( _this );
             child_11.ref();
             this.el.append (  child_11.el  );
+            var child_12 = new Xcls_SeparatorMenuItem20( _this );
+            child_12.ref();
+            this.el.add (  child_12.el  );
+            var child_13 = new Xcls_MenuItem21( _this );
+            child_13.ref();
+            this.el.append (  child_13.el  );
         }
 
         // user defined functions 
@@ -1054,6 +1060,56 @@ public class Xcls_LeftProps : Object
 
         // user defined functions 
     }
+    public class Xcls_SeparatorMenuItem20 : Object 
+    {
+        public Gtk.SeparatorMenuItem el;
+        private Xcls_LeftProps  _this;
+
+
+            // my vars (def)
+
+        // ctor 
+        public Xcls_SeparatorMenuItem20(Xcls_LeftProps _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.SeparatorMenuItem();
+
+            // my vars (dec)
+
+            // set gobject values
+        }
+
+        // user defined functions 
+    }
+    public class Xcls_MenuItem21 : Object 
+    {
+        public Gtk.MenuItem el;
+        private Xcls_LeftProps  _this;
+
+
+            // my vars (def)
+
+        // ctor 
+        public Xcls_MenuItem21(Xcls_LeftProps _owner )
+        {
+            _this = _owner;
+            this.el = new Gtk.MenuItem();
+
+            // my vars (dec)
+
+            // set gobject values
+            this.el.tooltip_markup = "Add a user function boolean property";
+            this.el.label = "Flexy - Foreach";
+
+            // listeners 
+            this.el.activate.connect( ( ) =>{
+            
+                _this.addProp("prop",  "XXXX", "function() { }", "| function");
+            });
+        }
+
+        // user defined functions 
+    }
     public class Xcls_EditProps : Object 
     {
         public Gtk.ScrolledWindow el;
@@ -1084,7 +1140,8 @@ public class Xcls_LeftProps : Object
             {
               
                this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
-            }        }
+            }
+        }
 
         // user defined functions 
     }
@@ -1132,6 +1189,7 @@ public class Xcls_LeftProps : Object
                 description.set_size(8000);
                 this.el.modify_font(description);
             }
+
             // listeners 
             this.el.button_press_event.connect( ( ev)  => {
              
@@ -1291,7 +1349,8 @@ public class Xcls_LeftProps : Object
             // init method 
 
             this.el.add_attribute(_this.keyrender.el , "markup", 2 );
-             this.el.add_attribute(_this.keyrender.el , "text", 1 );        }
+             this.el.add_attribute(_this.keyrender.el , "text", 1 );
+        }
 
         // user defined functions 
     }
@@ -1418,7 +1477,8 @@ public class Xcls_LeftProps : Object
                       // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
             
              //        this.get('/LeftPanel').editableColumn= this;
-            }        }
+            }
+        }
 
         // user defined functions 
     }
@@ -1581,20 +1641,20 @@ public class Xcls_LeftProps : Object
             // my vars (dec)
 
             // set gobject values
-            var child_0 = new Xcls_MenuItem29( _this );
+            var child_0 = new Xcls_MenuItem31( _this );
             child_0.ref();
             this.el.append (  child_0.el  );
-            var child_1 = new Xcls_SeparatorMenuItem30( _this );
+            var child_1 = new Xcls_SeparatorMenuItem32( _this );
             child_1.ref();
             this.el.append (  child_1.el  );
-            var child_2 = new Xcls_MenuItem31( _this );
+            var child_2 = new Xcls_MenuItem33( _this );
             child_2.ref();
             this.el.append (  child_2.el  );
         }
 
         // user defined functions 
     }
-    public class Xcls_MenuItem29 : Object 
+    public class Xcls_MenuItem31 : Object 
     {
         public Gtk.MenuItem el;
         private Xcls_LeftProps  _this;
@@ -1603,7 +1663,7 @@ public class Xcls_LeftProps : Object
             // my vars (def)
 
         // ctor 
-        public Xcls_MenuItem29(Xcls_LeftProps _owner )
+        public Xcls_MenuItem31(Xcls_LeftProps _owner )
         {
             _this = _owner;
             this.el = new Gtk.MenuItem();
@@ -1626,7 +1686,7 @@ public class Xcls_LeftProps : Object
 
         // user defined functions 
     }
-    public class Xcls_SeparatorMenuItem30 : Object 
+    public class Xcls_SeparatorMenuItem32 : Object 
     {
         public Gtk.SeparatorMenuItem el;
         private Xcls_LeftProps  _this;
@@ -1635,7 +1695,7 @@ public class Xcls_LeftProps : Object
             // my vars (def)
 
         // ctor 
-        public Xcls_SeparatorMenuItem30(Xcls_LeftProps _owner )
+        public Xcls_SeparatorMenuItem32(Xcls_LeftProps _owner )
         {
             _this = _owner;
             this.el = new Gtk.SeparatorMenuItem();
@@ -1647,7 +1707,7 @@ public class Xcls_LeftProps : Object
 
         // user defined functions 
     }
-    public class Xcls_MenuItem31 : Object 
+    public class Xcls_MenuItem33 : Object 
     {
         public Gtk.MenuItem el;
         private Xcls_LeftProps  _this;
@@ -1656,7 +1716,7 @@ public class Xcls_LeftProps : Object
             // my vars (def)
 
         // ctor 
-        public Xcls_MenuItem31(Xcls_LeftProps _owner )
+        public Xcls_MenuItem33(Xcls_LeftProps _owner )
         {
             _this = _owner;
             this.el = new Gtk.MenuItem();