src/Builder4/WindowLeftProps.bjs
authorAlan Knowles <alan@roojs.com>
Mon, 1 Jun 2015 09:42:33 +0000 (17:42 +0800)
committerAlan Knowles <alan@roojs.com>
Mon, 1 Jun 2015 09:42:33 +0000 (17:42 +0800)
src/Builder4/WindowLeftProps.vala

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

index 2634067..cf3486b 100644 (file)
@@ -30,7 +30,7 @@
    "$ homogeneous" : "false   ",
    "# Xcls_MainWindow main_window" : "null",
    "|              void addProp" : " (string in_type, string key, string value, string value_type) {\n      // info includes key, val, skel, etype..\n      //console.dump(info);\n        //type = info.type.toLowerCase();\n        //var data = this.toJS();\n          \n    var type = in_type == \"signals\" ? \"listener\" : in_type;\n      \n    var fkey = (value_type.length > 0 ? value_type + \" \" : \"\") + key;\n              \n    if (type == \"listener\") {\n        if (this.node.listeners.has_key(key)) {\n            return;\n        }\n        this.node.listeners.set(key,value);\n    } else  {\n    \n        if (this.node.props.has_key(fkey)) {\n            return;\n        }\n        this.node.props.set(fkey,value);\n    }\n            \n      \n    // add a row???\n    this.load(this.file, this.node);\n    \n    \n    \n    /// need to find the row which I've just added..\n    \n    \n    var s = this.view.el.get_selection();\n    s.unselect_all();\n    \n    print(\"trying to find new iter\");\n  \n    this.model.el.foreach((model, path, iter) => {\n        GLib.Value gval;\n    \n        this.model.el.get_value(iter, 0 , out gval);\n        if ((string)gval != type) {\n            print(\"not type: %s = %s\\n\", (string)gval , type);\n            return false;\n        }\n        this.model.el.get_value(iter, 1 , out gval);\n        if ((string)gval != fkey) {\n            print(\"not key: %s = %s\\n\", (string)gval , fkey);\n            return false;\n        }\n        // delay this?\n        GLib.Timeout.add_full(GLib.Priority.DEFAULT,40 , () => {\n        \n            this.startEditingValue(this.model.el.get_path(iter));\n            return false;\n        });\n        //s.select_iter(iter);\n        return true; \n    });\n    \n    \n    \n              \n}\n",
-   "|              void updateIter" : "(Gtk.TreeIter iter,  string type, string key, string kvalue) {\n\n    print(\"update Iter %s, %s\\n\", key,kvalue);\n    //typeof(string),  // 0 key type\n     //typeof(string),  // 1 key\n     //typeof(string),  // 2 key (display)\n     //typeof(string),  // 3 value\n     //typeof(string),  // 4 value (display)\n     //typeof(string),  // 5 both (tooltip)\n     //typeof(string),  // 6 key (sort)\n    \n    var dl = kvalue.strip().split(\"\\n\");\n\n    var dis_val = dl.length > 1 ? (dl[0].strip()+ \"...\") : dl[0];\n    \n    if (type == \"listener\") {\n     \n       \n        \n        this.model.el.set(iter, \n                0, type,\n            1, key,\n            2, this.keyFormat(key ,type),\n            3, kvalue,\n            4, dis_val,\n            5, \"<tt>\" +  GLib.Markup.escape_text(key + \" \" +kvalue) + \"</tt>\",\n            6,  \"0 \" + key\n        ); \n        return;\n    }\n    \n\n\n    this.model.el.set(iter, \n            0, \"props\",\n            1, key,\n            2,  this.keyFormat(key , \"prop\"),\n            3, kvalue,\n            4, dis_val,\n             5, \"<tt>\" + GLib.Markup.escape_text(key + \" \" + kvalue) + \"</tt>\",\n             6,  this.keySortFormat(key)\n        ); \n}",
+   "|              void updateIter" : "(Gtk.TreeIter iter,  string type, string key, string kvalue) {\n\n    print(\"update Iter %s, %s\\n\", key,value);\n    //typeof(string),  // 0 key type\n     //typeof(string),  // 1 key\n     //typeof(string),  // 2 key (display)\n     //typeof(string),  // 3 value\n     //typeof(string),  // 4 value (display)\n     //typeof(string),  // 5 both (tooltip)\n     //typeof(string),  // 6 key (sort)\n    \n    var dl = value.strip().split(\"\\n\");\n\n    var dis_val = dl.length > 1 ? (dl[0].strip()+ \"...\") : dl[0];\n    \n    if (type == \"listener\") {\n     \n       \n        \n        this.model.el.set(iter, \n                0, type,\n            1, key,\n            2, this.keyFormat(key ,type),\n            3, kvalue,\n            4, dis_val,\n            5, \"<tt>\" +  GLib.Markup.escape_text(key + \" \" +value) + \"</tt>\",\n            6,  \"0 \" + key\n        ); \n        return;\n    }\n    \n\n\n    this.model.el.set(iter, \n            0, \"props\",\n            1, key,\n            2,  this.keyFormat(key , \"prop\"),\n            3, kvalue,\n            4, dis_val,\n             5, \"<tt>\" + GLib.Markup.escape_text(key + \" \" + value) + \"</tt>\",\n             6,  this.keySortFormat(key)\n        ); \n}",
    "# JsRender.Node node" : "",
    "items" : [
     {
@@ -44,8 +44,8 @@
         "button_press_event" : "  (self, ev) => {\n    _this.before_edit();\n    \n        \n    var p = _this.AddPropertyPopup;\n    p.el.set_screen(Gdk.Screen.get_default());\n    p.el.show_all();\n     p.el.popup(null, null, null, ev.button, ev.time);\n     return true;\n}"
        },
        "bool hexpand" : true,
-       "* pack" : "add",
        "xtype" : "Button",
+       "* pack" : "add",
        "$ xns" : "Gtk",
        "items" : [
         {
          "items" : [
           {
            "$ Gtk.Stock stock" : "Gtk.Stock.ADD",
-           "xtype" : "Image",
            "* pack" : "add",
+           "xtype" : "Image",
            "$ xns" : "Gtk",
            "$ icon_size" : "Gtk.IconSize.MENU"
           },
           {
            "label" : "Other",
-           "* pack" : "add",
            "xtype" : "Label",
+           "* pack" : "add",
            "$ xns" : "Gtk"
           }
          ]
         },
         {
          "id" : "AddPropertyPopup",
-         "* pack" : false,
          "xtype" : "Menu",
+         "* pack" : false,
          "$ xns" : "Gtk",
          "items" : [
           {
@@ -80,8 +80,8 @@
             "activate" : " ()  => {\n    _this.addProp( \"prop\", \"id\", \"\", \"\");\n}"
            },
            "label" : "id: _this.{ID} (Vala)",
-           "* pack" : "append",
            "xtype" : "MenuItem",
+           "* pack" : "append",
            "tooltip_markup" : "Using _this.{ID} will map to this element",
            "$ xns" : "Gtk"
           },
@@ -90,8 +90,8 @@
             "activate" : "  ( ) => {\n\n    _this.addProp( \"prop\", \"pack\",\"add\", \"*\");\n}"
            },
            "label" : "pack: Pack method (Vala)",
-           "xtype" : "MenuItem",
            "* pack" : "append",
+           "xtype" : "MenuItem",
            "tooltip_markup" : "how to pack this element onto parent, (method, 2nd arg, 3rd arg) .. the 1st argument is filled by the element",
            "$ xns" : "Gtk"
           },
             "activate" : "  ( ) => {\n\n    _this.addProp( \"prop\", \"ctor\",\"\", \"*\");\n}"
            },
            "label" : "ctor: Alterative to default contructor",
-           "* pack" : "append",
            "xtype" : "MenuItem",
+           "* pack" : "append",
            "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)",
-           "* pack" : "append",
            "xtype" : "MenuItem",
+           "* pack" : "append",
            "tooltip_markup" : "This code is called after the ctor",
            "$ xns" : "Gtk"
           },
             "activate" : "  (self) => {\n\n    _this.addProp( \"prop\", \"XXXX\", \"\",\"string\");\n\n}"
            },
            "label" : "String",
-           "* pack" : "append",
            "xtype" : "MenuItem",
+           "* pack" : "append",
            "tooltip_markup" : "Add a user defined string property",
            "$ xns" : "Gtk"
           },
             "activate" : "  ( ) =>{\n\n    _this.addProp(\"prop\",  \"XXX\", \"0\", \"int\");\n}"
            },
            "label" : "Number",
-           "* pack" : "append",
            "xtype" : "MenuItem",
+           "* pack" : "append",
            "tooltip_markup" : "Add a user defined number property",
            "$ xns" : "Gtk"
           },
             "activate" : "  ( ) =>{\n\n    _this.addProp( \"prop\", \"XXX\", \"true\", \"bool\");\n}"
            },
            "label" : "Boolean",
-           "* pack" : "append",
            "xtype" : "MenuItem",
+           "* pack" : "append",
            "tooltip_markup" : "Add a user defined boolean property",
            "$ xns" : "Gtk"
           },
             "activate" : "  ( ) =>{\n\n    _this.addProp(\"prop\",  \"XXXX\", \"function() { }\", \"| function\");\n}"
            },
            "label" : "Javascript Function",
-           "* pack" : "append",
            "xtype" : "MenuItem",
+           "* pack" : "append",
            "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",
-           "xtype" : "MenuItem",
            "* pack" : "append",
+           "xtype" : "MenuItem",
            "tooltip_markup" : "Add a user function boolean property",
            "$ xns" : "Gtk"
           },
             "activate" : "  ( ) =>{\n\n    _this.addProp( \"prop\", \"XXXX\", \"()\", \"@ void\");\n}"
            },
            "label" : "Vala Signal",
-           "* pack" : "append",
            "xtype" : "MenuItem",
+           "* pack" : "append",
            "tooltip_markup" : "Add a vala signal",
            "$ xns" : "Gtk"
           },
             "activate" : "  ( ) =>{\n\n    _this.addProp(\"prop\",  \"flexy:if\", \"value_or_condition\", \"string\");\n}"
            },
            "label" : "Flexy - If",
-           "* pack" : "append",
            "xtype" : "MenuItem",
+           "* pack" : "append",
            "tooltip_markup" : "Add a flexy if (for HTML templates)",
            "$ xns" : "Gtk"
           },
             "activate" : "  ( ) =>{\n\n    _this.addProp(\"prop\",  \"flexy:include\", \"name_of_file.html\", \"string\");\n}"
            },
            "label" : "Flexy - Include",
-           "xtype" : "MenuItem",
            "* pack" : "append",
+           "xtype" : "MenuItem",
            "tooltip_markup" : "Add a flexy include (for HTML templates)",
            "$ xns" : "Gtk"
           },
             "activate" : "  ( ) =>{\n\n    _this.addProp(\"prop\",  \"flexy:foreach\", \"array,key,value\", \"string\");\n}"
            },
            "label" : "Flexy - Foreach",
-           "xtype" : "MenuItem",
            "* pack" : "append",
+           "xtype" : "MenuItem",
            "tooltip_markup" : "Add a flexy foreach (for HTML templates)",
            "$ 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.unset(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.unset(oldval);\n                _this.updateIter(iter,  ktype, newtext, ov);\n                break;\n         }\n         _this.changed();\n          \n}"
            },
            "id" : "keyrender",
-           "xtype" : "CellRendererText",
            "* pack" : "pack_start,false",
+           "xtype" : "CellRendererText",
            "$ 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",
-           "* pack" : "pack_start,true",
            "xtype" : "CellRendererCombo",
+           "* pack" : "pack_start,true",
            "$ editable" : false,
            "$ has_entry" : true,
            "$ xns" : "Gtk",
            "items" : [
             {
              "id" : "valrendermodel",
-             "* pack" : false,
              "xtype" : "ListStore",
+             "* pack" : false,
              "$ columns" : "typeof(string)",
              "n_columns" : 1,
              "$ xns" : "Gtk",
         },
         {
          "id" : "ContextMenu",
-         "xtype" : "Menu",
          "* pack" : false,
+         "xtype" : "Menu",
          "$ 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",
-           "xtype" : "MenuItem",
            "* pack" : "append",
+           "xtype" : "MenuItem",
            "$ xns" : "Gtk"
           },
           {
             "activate" : "  ( )  =>{\n\t_this.deleteSelected();\n}"
            },
            "label" : "Delete",
-           "xtype" : "MenuItem",
            "* pack" : "append",
+           "xtype" : "MenuItem",
            "$ xns" : "Gtk"
           }
          ]
index 9707464..56ce6df 100644 (file)
@@ -530,7 +530,7 @@ public class Xcls_LeftProps : Object
     }
     public              void updateIter (Gtk.TreeIter iter,  string type, string key, string kvalue) {
     
-        print("update Iter %s, %s\n", key,kvalue);
+        print("update Iter %s, %s\n", key,value);
         //typeof(string),  // 0 key type
          //typeof(string),  // 1 key
          //typeof(string),  // 2 key (display)
@@ -539,7 +539,7 @@ public class Xcls_LeftProps : Object
          //typeof(string),  // 5 both (tooltip)
          //typeof(string),  // 6 key (sort)
         
-        var dl = kvalue.strip().split("\n");
+        var dl = value.strip().split("\n");
     
         var dis_val = dl.length > 1 ? (dl[0].strip()+ "...") : dl[0];
         
@@ -553,7 +553,7 @@ public class Xcls_LeftProps : Object
                 2, this.keyFormat(key ,type),
                 3, kvalue,
                 4, dis_val,
-                5, "<tt>" +  GLib.Markup.escape_text(key + " " +kvalue) + "</tt>",
+                5, "<tt>" +  GLib.Markup.escape_text(key + " " +value) + "</tt>",
                 6,  "0 " + key
             ); 
             return;
@@ -567,7 +567,7 @@ public class Xcls_LeftProps : Object
                 2,  this.keyFormat(key , "prop"),
                 3, kvalue,
                 4, dis_val,
-                 5, "<tt>" + GLib.Markup.escape_text(key + " " + kvalue) + "</tt>",
+                 5, "<tt>" + GLib.Markup.escape_text(key + " " + value) + "</tt>",
                  6,  this.keySortFormat(key)
             ); 
     }