X-Git-Url: http://git.roojs.org/?p=app.Builder.js;a=blobdiff_plain;f=src%2FBuilder4%2FWindowLeftProps.vala;h=6e585e48fd542dd49ff293fbdda2b53aaabe0315;hp=9b7f113eae3adedf74792813ecaf754529f09787;hb=HEAD;hpb=77363d86e6d05b596f31f216503ff432a1b68396 diff --git a/src/Builder4/WindowLeftProps.vala b/src/Builder4/WindowLeftProps.vala index 9b7f113ea..6e585e48f 100644 --- a/src/Builder4/WindowLeftProps.vala +++ b/src/Builder4/WindowLeftProps.vala @@ -54,6 +54,38 @@ public class Xcls_LeftProps : Object } // user defined functions + public void updateKey (string oldkey, string type, string key ) { + + + + _this.model.el.foreach((mod, path, iter) => { + + + + + GLib.Value gvaltype, gval,kvalue; + mod.get_value(iter, 1 , out gval); // one is key.. + + mod.get_value(iter,0, out gvaltype); + + mod.get_value(iter,3, out kvalue); + + if (oldkey == ((string)gval) && type == ((string)gvaltype)) { + + //print("update iter type=%s, key=%s value=%s\n", type, key,(string) kvalue); + + this.updateIter(iter, type, key, (string)kvalue); + return true; + } + + + return false; + }); + + this.changed(); + + + } public void before_edit () { @@ -104,138 +136,103 @@ public class Xcls_LeftProps : Object } public bool startEditingValue ( Gtk.TreePath path) { - // ONLY return true if editing is allowed - eg. combo.. + // ONLY return true if editing is allowed - eg. combo.. + + print("start editing?\n"); + if (!this.stop_editor()) { + print("stop editor failed\n"); + return false; + } - print("start editing?\n"); - if (!this.stop_editor()) { - print("stop editor failed\n"); - return false; - } - - Gtk.TreeIter iter; + Gtk.TreeIter iter; - var mod = this.model.el; - mod.get_iter (out iter, path); - - /* - m.set(iter, - 0, "listener", - 1, miter.get_key(), - 2, "" + miter.get_key() + "", - 3, miter.get_value() - ); - - */ - GLib.Value gval; - mod.get_value(iter, 3 , out gval); - var val = (string)gval; - - mod.get_value(iter, 1 , out gval); - var key = (string)gval; - var type_ar = key.split(" "); - - string kname, kflag, ktype; - this.node.normalize_key(key, out kname, out kflag, out ktype); - - - mod.get_value(iter, 0 , out gval); - var type = (string)gval; // listerner or prop.. - - - - var use_textarea = false; + var mod = this.model.el; + mod.get_iter (out iter, path); + + /* + m.set(iter, + 0, "listener", + 1, miter.get_key(), + 2, "" + miter.get_key() + "", + 3, miter.get_value() + ); + + */ + GLib.Value gval; + mod.get_value(iter, 3 , out gval); + var val = (string)gval; - //------------ things that require the text editor... - - if (type == "listener") { - use_textarea = true; - } - if (key.length > 0 && key[0] == '|') { // user defined method - use_textarea = true; - } - if (key.length > 0 && key[0] == '$') { // raw string - use_textarea = true; - } - if (key.length > 0 && key == "* init") { - use_textarea = true; - } - if (val.length > 40) { // long value... - use_textarea = true; - } - - - - if (use_textarea) { - print("Call show editor\n"); - GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => { - this.view.el.get_selection().select_path(path); - - this.show_editor(file, node, type, key); - - return false; - }); - - - return false; - } - - var pal = Palete.factory(this.file.project.xtype); - - string[] opts; - var has_opts = pal.typeOptions(this.node.fqn(), kname, ktype, out opts); - + mod.get_value(iter, 1 , out gval); + var key = (string)gval; + + + string kname, kflag, ktype; + this.node.normalize_key(key, out kname, out kflag, out ktype); + + + mod.get_value(iter, 0 , out gval); + var type = (string)gval; // listerner or prop.. + + + + var use_textarea = false; + + //------------ things that require the text editor... + + if (type == "listener") { + use_textarea = true; + } + if (key.length > 0 && key[0] == '|') { // user defined method + use_textarea = true; + } + if (key.length > 0 && key[0] == '$') { // raw string + use_textarea = true; + } + if (key.length > 0 && key == "* init") { + use_textarea = true; + } + if (val.length > 40) { // long value... + use_textarea = true; + } + + + + if (use_textarea) { + print("Call show editor\n"); + GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => { + this.view.el.get_selection().select_path(path); + this.show_editor(file, node, type, key); - // others... - fill in options for true/false? - print("turn on editing %s \n" , mod.get_path(iter).to_string()); - - print (ktype.up()); - if (has_opts) { - print("start editing try/false)???"); - this.valrender.el.has_entry = false; - - this.valrender.setOptions(opts); - - this.valrender.el.has_entry = false; - this.valrender.el.editable = true; - this.allow_edit = true; - GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => { - this.view.el.set_cursor_on_cell( - path, - this.valcol.el, - this.valrender.el, - true - ); - return false; - }); - return true; - } - - // see if type is a Enum. - - - - - - opts = { }; + return false; + }); + + + return false; + } + + var pal = Palete.factory(this.file.project.xtype); + + string[] opts; + var has_opts = pal.typeOptions(this.node.fqn(), kname, ktype, out opts); + + + + // others... - fill in options for true/false? + print("turn on editing %s \n" , mod.get_path(iter).to_string()); + + print (ktype.up()); + if (has_opts) { + print("start editing try/false)???"); + this.valrender.el.has_entry = false; + this.valrender.setOptions(opts); - - GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => { - - // at this point - work out the type... - // if its' a combo... then show the options.. - this.valrender.el.has_entry = true; - - this.valrender.el.editable = true; - - this.allow_edit = true; - - - - - - this.view.el.set_cursor_on_cell( + this.valrender.el.has_entry = false; + this.valrender.el.editable = true; + this.allow_edit = true; + GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => { + this.view.el.set_cursor_on_cell( path, this.valcol.el, this.valrender.el, @@ -243,8 +240,43 @@ public class Xcls_LeftProps : Object ); return false; }); - return false; - } + return true; + } + + // see if type is a Enum. + + + + + + opts = { }; + this.valrender.setOptions(opts); + + GLib.Timeout.add_full(GLib.Priority.DEFAULT,10 , () => { + + // at this point - work out the type... + // if its' a combo... then show the options.. + this.valrender.el.has_entry = true; + + this.valrender.el.editable = true; + + + this.allow_edit = true; + + + + + + this.view.el.set_cursor_on_cell( + path, + this.valcol.el, + this.valrender.el, + true + ); + return false; + }); + return false; + } public void load (JsRender.JsRender file, JsRender.Node? node) { print("load leftprops\n"); @@ -457,7 +489,7 @@ public class Xcls_LeftProps : Object } this.node.props.set(fkey,value); } - + // add a row??? this.load(this.file, this.node); @@ -499,9 +531,9 @@ public class Xcls_LeftProps : Object } - public void updateIter (Gtk.TreeIter iter, string type, string key, string value) { + public void updateIter (Gtk.TreeIter iter, string type, string key, string kvalue) { - print("update Iter %s, %s\n", key,value); + //print("update Iter %s, %s\n", key,kvalue); //typeof(string), // 0 key type //typeof(string), // 1 key //typeof(string), // 2 key (display) @@ -510,7 +542,7 @@ public class Xcls_LeftProps : Object //typeof(string), // 5 both (tooltip) //typeof(string), // 6 key (sort) - var dl = value.strip().split("\n"); + var dl = kvalue.strip().split("\n"); var dis_val = dl.length > 1 ? (dl[0].strip()+ "...") : dl[0]; @@ -522,9 +554,9 @@ public class Xcls_LeftProps : Object 0, type, 1, key, 2, this.keyFormat(key ,type), - 3, value, + 3, kvalue, 4, dis_val, - 5, "" + GLib.Markup.escape_text(key + " " +value) + "", + 5, "" + GLib.Markup.escape_text(key + " " +kvalue) + "", 6, "0 " + key ); return; @@ -536,9 +568,9 @@ public class Xcls_LeftProps : Object 0, "props", 1, key, 2, this.keyFormat(key , "prop"), - 3, value, + 3, kvalue, 4, dis_val, - 5, "" + GLib.Markup.escape_text(key + " " + value) + "", + 5, "" + GLib.Markup.escape_text(key + " " + kvalue) + "", 6, this.keySortFormat(key) ); } @@ -583,6 +615,7 @@ public class Xcls_LeftProps : Object // my vars (dec) // set gobject values + this.el.hexpand = true; var child_0 = new Xcls_Box4( _this ); child_0.ref(); this.el.add ( child_0.el ); @@ -648,7 +681,7 @@ public class Xcls_LeftProps : Object // my vars (dec) // set gobject values - this.el.stock = Gtk.STOCK_ADD; + this.el.stock = Gtk.Stock.ADD; this.el.icon_size = Gtk.IconSize.MENU; } @@ -708,42 +741,45 @@ public class Xcls_LeftProps : Object var child_3 = new Xcls_MenuItem11( _this ); child_3.ref(); this.el.append ( child_3.el ); - var child_4 = new Xcls_SeparatorMenuItem12( _this ); + var child_4 = new Xcls_MenuItem12( _this ); child_4.ref(); - this.el.add ( child_4.el ); - var child_5 = new Xcls_MenuItem13( _this ); + this.el.append ( child_4.el ); + var child_5 = new Xcls_SeparatorMenuItem13( _this ); child_5.ref(); - this.el.append ( child_5.el ); + this.el.add ( child_5.el ); var child_6 = new Xcls_MenuItem14( _this ); child_6.ref(); this.el.append ( child_6.el ); var child_7 = new Xcls_MenuItem15( _this ); child_7.ref(); this.el.append ( child_7.el ); - var child_8 = new Xcls_SeparatorMenuItem16( _this ); + var child_8 = new Xcls_MenuItem16( _this ); child_8.ref(); - this.el.add ( child_8.el ); - var child_9 = new Xcls_MenuItem17( _this ); + this.el.append ( child_8.el ); + var child_9 = new Xcls_SeparatorMenuItem17( _this ); child_9.ref(); - this.el.append ( child_9.el ); + this.el.add ( child_9.el ); var child_10 = new Xcls_MenuItem18( _this ); child_10.ref(); this.el.append ( child_10.el ); var child_11 = new Xcls_MenuItem19( _this ); child_11.ref(); this.el.append ( child_11.el ); - var child_12 = new Xcls_SeparatorMenuItem20( _this ); + var child_12 = new Xcls_MenuItem20( _this ); child_12.ref(); - this.el.add ( child_12.el ); - var child_13 = new Xcls_MenuItem21( _this ); + this.el.append ( child_12.el ); + var child_13 = new Xcls_SeparatorMenuItem21( _this ); child_13.ref(); - this.el.append ( child_13.el ); + this.el.add ( child_13.el ); var child_14 = new Xcls_MenuItem22( _this ); child_14.ref(); this.el.append ( child_14.el ); var child_15 = new Xcls_MenuItem23( _this ); child_15.ref(); this.el.append ( child_15.el ); + var child_16 = new Xcls_MenuItem24( _this ); + child_16.ref(); + this.el.append ( child_16.el ); } // user defined functions @@ -825,7 +861,7 @@ public class Xcls_LeftProps : Object // set gobject values this.el.tooltip_markup = "eg. \n\nnew Clutter.Image.from_file(.....)"; - this.el.label = "ctor: Alterative to default contructor"; + this.el.label = "ctor: Alterative to default contructor (Vala)"; //listeners this.el.activate.connect( ( ) => { @@ -867,7 +903,36 @@ public class Xcls_LeftProps : Object // user defined functions } - public class Xcls_SeparatorMenuItem12 : Object + public class Xcls_MenuItem12 : Object + { + public Gtk.MenuItem el; + private Xcls_LeftProps _this; + + + // my vars (def) + + // ctor + public Xcls_MenuItem12(Xcls_LeftProps _owner ) + { + _this = _owner; + this.el = new Gtk.MenuItem(); + + // my vars (dec) + + // set gobject values + this.el.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})\n"; + this.el.label = "cms-id: (Roo JS/Pman library)"; + + //listeners + this.el.activate.connect( () => { + _this.addProp( "prop", "cms-id", "", "string"); + }); + } + + // user defined functions + } + + public class Xcls_SeparatorMenuItem13 : Object { public Gtk.SeparatorMenuItem el; private Xcls_LeftProps _this; @@ -876,7 +941,7 @@ public class Xcls_LeftProps : Object // my vars (def) // ctor - public Xcls_SeparatorMenuItem12(Xcls_LeftProps _owner ) + public Xcls_SeparatorMenuItem13(Xcls_LeftProps _owner ) { _this = _owner; this.el = new Gtk.SeparatorMenuItem(); @@ -889,7 +954,7 @@ public class Xcls_LeftProps : Object // user defined functions } - public class Xcls_MenuItem13 : Object + public class Xcls_MenuItem14 : Object { public Gtk.MenuItem el; private Xcls_LeftProps _this; @@ -898,7 +963,7 @@ public class Xcls_LeftProps : Object // my vars (def) // ctor - public Xcls_MenuItem13(Xcls_LeftProps _owner ) + public Xcls_MenuItem14(Xcls_LeftProps _owner ) { _this = _owner; this.el = new Gtk.MenuItem(); @@ -920,7 +985,7 @@ public class Xcls_LeftProps : Object // user defined functions } - public class Xcls_MenuItem14 : Object + public class Xcls_MenuItem15 : Object { public Gtk.MenuItem el; private Xcls_LeftProps _this; @@ -929,7 +994,7 @@ public class Xcls_LeftProps : Object // my vars (def) // ctor - public Xcls_MenuItem14(Xcls_LeftProps _owner ) + public Xcls_MenuItem15(Xcls_LeftProps _owner ) { _this = _owner; this.el = new Gtk.MenuItem(); @@ -950,7 +1015,7 @@ public class Xcls_LeftProps : Object // user defined functions } - public class Xcls_MenuItem15 : Object + public class Xcls_MenuItem16 : Object { public Gtk.MenuItem el; private Xcls_LeftProps _this; @@ -959,7 +1024,7 @@ public class Xcls_LeftProps : Object // my vars (def) // ctor - public Xcls_MenuItem15(Xcls_LeftProps _owner ) + public Xcls_MenuItem16(Xcls_LeftProps _owner ) { _this = _owner; this.el = new Gtk.MenuItem(); @@ -980,7 +1045,7 @@ public class Xcls_LeftProps : Object // user defined functions } - public class Xcls_SeparatorMenuItem16 : Object + public class Xcls_SeparatorMenuItem17 : Object { public Gtk.SeparatorMenuItem el; private Xcls_LeftProps _this; @@ -989,7 +1054,7 @@ public class Xcls_LeftProps : Object // my vars (def) // ctor - public Xcls_SeparatorMenuItem16(Xcls_LeftProps _owner ) + public Xcls_SeparatorMenuItem17(Xcls_LeftProps _owner ) { _this = _owner; this.el = new Gtk.SeparatorMenuItem(); @@ -1002,7 +1067,7 @@ public class Xcls_LeftProps : Object // user defined functions } - public class Xcls_MenuItem17 : Object + public class Xcls_MenuItem18 : Object { public Gtk.MenuItem el; private Xcls_LeftProps _this; @@ -1011,7 +1076,7 @@ public class Xcls_LeftProps : Object // my vars (def) // ctor - public Xcls_MenuItem17(Xcls_LeftProps _owner ) + public Xcls_MenuItem18(Xcls_LeftProps _owner ) { _this = _owner; this.el = new Gtk.MenuItem(); @@ -1032,7 +1097,7 @@ public class Xcls_LeftProps : Object // user defined functions } - public class Xcls_MenuItem18 : Object + public class Xcls_MenuItem19 : Object { public Gtk.MenuItem el; private Xcls_LeftProps _this; @@ -1041,7 +1106,7 @@ public class Xcls_LeftProps : Object // my vars (def) // ctor - public Xcls_MenuItem18(Xcls_LeftProps _owner ) + public Xcls_MenuItem19(Xcls_LeftProps _owner ) { _this = _owner; this.el = new Gtk.MenuItem(); @@ -1062,7 +1127,7 @@ public class Xcls_LeftProps : Object // user defined functions } - public class Xcls_MenuItem19 : Object + public class Xcls_MenuItem20 : Object { public Gtk.MenuItem el; private Xcls_LeftProps _this; @@ -1071,7 +1136,7 @@ public class Xcls_LeftProps : Object // my vars (def) // ctor - public Xcls_MenuItem19(Xcls_LeftProps _owner ) + public Xcls_MenuItem20(Xcls_LeftProps _owner ) { _this = _owner; this.el = new Gtk.MenuItem(); @@ -1092,7 +1157,7 @@ public class Xcls_LeftProps : Object // user defined functions } - public class Xcls_SeparatorMenuItem20 : Object + public class Xcls_SeparatorMenuItem21 : Object { public Gtk.SeparatorMenuItem el; private Xcls_LeftProps _this; @@ -1101,7 +1166,7 @@ public class Xcls_LeftProps : Object // my vars (def) // ctor - public Xcls_SeparatorMenuItem20(Xcls_LeftProps _owner ) + public Xcls_SeparatorMenuItem21(Xcls_LeftProps _owner ) { _this = _owner; this.el = new Gtk.SeparatorMenuItem(); @@ -1114,7 +1179,7 @@ public class Xcls_LeftProps : Object // user defined functions } - public class Xcls_MenuItem21 : Object + public class Xcls_MenuItem22 : Object { public Gtk.MenuItem el; private Xcls_LeftProps _this; @@ -1123,7 +1188,7 @@ public class Xcls_LeftProps : Object // my vars (def) // ctor - public Xcls_MenuItem21(Xcls_LeftProps _owner ) + public Xcls_MenuItem22(Xcls_LeftProps _owner ) { _this = _owner; this.el = new Gtk.MenuItem(); @@ -1144,7 +1209,7 @@ public class Xcls_LeftProps : Object // user defined functions } - public class Xcls_MenuItem22 : Object + public class Xcls_MenuItem23 : Object { public Gtk.MenuItem el; private Xcls_LeftProps _this; @@ -1153,7 +1218,7 @@ public class Xcls_LeftProps : Object // my vars (def) // ctor - public Xcls_MenuItem22(Xcls_LeftProps _owner ) + public Xcls_MenuItem23(Xcls_LeftProps _owner ) { _this = _owner; this.el = new Gtk.MenuItem(); @@ -1174,7 +1239,7 @@ public class Xcls_LeftProps : Object // user defined functions } - public class Xcls_MenuItem23 : Object + public class Xcls_MenuItem24 : Object { public Gtk.MenuItem el; private Xcls_LeftProps _this; @@ -1183,7 +1248,7 @@ public class Xcls_LeftProps : Object // my vars (def) // ctor - public Xcls_MenuItem23(Xcls_LeftProps _owner ) + public Xcls_MenuItem24(Xcls_LeftProps _owner ) { _this = _owner; this.el = new Gtk.MenuItem(); @@ -1249,6 +1314,7 @@ public class Xcls_LeftProps : Object // my vars (def) + public Xcls_PopoverProperty popover; // ctor public Xcls_view(Xcls_LeftProps _owner ) @@ -1258,6 +1324,7 @@ public class Xcls_LeftProps : Object this.el = new Gtk.TreeView(); // my vars (dec) + this.popover = null; // set gobject values this.el.tooltip_column = 5; @@ -1306,20 +1373,37 @@ public class Xcls_LeftProps : Object } - // right click. + // double click on name.. if (ev.type == Gdk.EventType.2BUTTON_PRESS && ev.button == 1 && col.title == "Name") { // show popup!. + if (this.popover == null) { + this.popover = new Xcls_PopoverProperty(); + this.popover.mainwindow = _this.main_window; + } + _this.before_edit(); - + _this.stop_editor(); + _this.keyrender.el.stop_editing(false); _this.keyrender.el.editable =false; _this.valrender.el.stop_editing(false); _this.valrender.el.editable =false; + Gtk.TreeIter iter; + var mod = this.el.get_model(); + mod.get_iter (out iter, path); + + + GLib.Value gvaltype, gval; + mod.get_value(iter, 1 , out gval); // one is key.. + + mod.get_value(iter,0, out gvaltype); + + this.popover.show(this.el, _this.node, (string)gvaltype, (string)gval); - _this.startEditingKey(path); + // _this.startEditingKey(path); return false; } @@ -1744,20 +1828,20 @@ public class Xcls_LeftProps : Object // my vars (dec) // set gobject values - var child_0 = new Xcls_MenuItem33( _this ); + var child_0 = new Xcls_MenuItem34( _this ); child_0.ref(); this.el.append ( child_0.el ); - var child_1 = new Xcls_SeparatorMenuItem34( _this ); + var child_1 = new Xcls_SeparatorMenuItem35( _this ); child_1.ref(); this.el.append ( child_1.el ); - var child_2 = new Xcls_MenuItem35( _this ); + var child_2 = new Xcls_MenuItem36( _this ); child_2.ref(); this.el.append ( child_2.el ); } // user defined functions } - public class Xcls_MenuItem33 : Object + public class Xcls_MenuItem34 : Object { public Gtk.MenuItem el; private Xcls_LeftProps _this; @@ -1766,7 +1850,7 @@ public class Xcls_LeftProps : Object // my vars (def) // ctor - public Xcls_MenuItem33(Xcls_LeftProps _owner ) + public Xcls_MenuItem34(Xcls_LeftProps _owner ) { _this = _owner; this.el = new Gtk.MenuItem(); @@ -1774,23 +1858,49 @@ public class Xcls_LeftProps : Object // my vars (dec) // set gobject values - this.el.label = "Edit"; + this.el.label = "Edit (double click)"; //listeners this.el.activate.connect( ( ) =>{ var s = _this.view.el.get_selection(); Gtk.TreeIter iter; - Gtk.TreeModel model; - s.get_selected (out model, out iter); - _this.startEditingKey(model.get_path(iter)); + Gtk.TreeModel mod; + s.get_selected (out mod, out iter); + + if (_this.view.popover == null) { + _this.view.popover = new Xcls_PopoverProperty(); + _this.view.popover.mainwindow = _this.main_window; + } + + + _this.before_edit(); + _this.stop_editor(); + + _this.keyrender.el.stop_editing(false); + _this.keyrender.el.editable =false; + + _this.valrender.el.stop_editing(false); + _this.valrender.el.editable =false; + + + GLib.Value gvaltype, gval; + mod.get_value(iter, 1 , out gval); // one is key.. + + mod.get_value(iter,0, out gvaltype); + + _this.view.popover.show(_this.view.el, _this.node, (string)gvaltype, (string)gval); + + + + // _this.startEditingKey(model.get_path(iter)); }); } // user defined functions } - public class Xcls_SeparatorMenuItem34 : Object + public class Xcls_SeparatorMenuItem35 : Object { public Gtk.SeparatorMenuItem el; private Xcls_LeftProps _this; @@ -1799,7 +1909,7 @@ public class Xcls_LeftProps : Object // my vars (def) // ctor - public Xcls_SeparatorMenuItem34(Xcls_LeftProps _owner ) + public Xcls_SeparatorMenuItem35(Xcls_LeftProps _owner ) { _this = _owner; this.el = new Gtk.SeparatorMenuItem(); @@ -1812,7 +1922,7 @@ public class Xcls_LeftProps : Object // user defined functions } - public class Xcls_MenuItem35 : Object + public class Xcls_MenuItem36 : Object { public Gtk.MenuItem el; private Xcls_LeftProps _this; @@ -1821,7 +1931,7 @@ public class Xcls_LeftProps : Object // my vars (def) // ctor - public Xcls_MenuItem35(Xcls_LeftProps _owner ) + public Xcls_MenuItem36(Xcls_LeftProps _owner ) { _this = _owner; this.el = new Gtk.MenuItem();