From d52bd242863f1e2c264ad7346671e930ab723085 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Sun, 4 Feb 2024 13:18:08 +0800 Subject: [PATCH] change property type dialog to use dropdown (has bug with popover autohide, but added close button for now --- src/Builder4/MainWindow.bjs | 1 - src/Builder4/MainWindow.vala | 1 - src/Builder4/PopoverProperty.bjs | 280 ++++++++------------ src/Builder4/PopoverProperty.vala | 423 +++++++++++------------------- src/Builder4/WindowLeftTree.bjs | 3 + src/Builder4/WindowLeftTree.vala | 81 +++--- src/JsRender/NodeProp.vala | 46 ++++ src/JsRender/NodeToGlade.vala | 5 +- 8 files changed, 368 insertions(+), 472 deletions(-) diff --git a/src/Builder4/MainWindow.bjs b/src/Builder4/MainWindow.bjs index c5d391694..8c49c04d4 100644 --- a/src/Builder4/MainWindow.bjs +++ b/src/Builder4/MainWindow.bjs @@ -1345,7 +1345,6 @@ "\t", " \t_this.treeselmodel.el.selected = Gtk.INVALID_LIST_POSITION;", "\t", - " ", "}" ] }, diff --git a/src/Builder4/MainWindow.vala b/src/Builder4/MainWindow.vala index fce2b1f7e..6b62b112d 100644 --- a/src/Builder4/MainWindow.vala +++ b/src/Builder4/MainWindow.vala @@ -1469,7 +1469,6 @@ public class Xcls_MainWindow : Object _this.treeselmodel.el.selected = Gtk.INVALID_LIST_POSITION; - } } public class Xcls_filesearch : Object diff --git a/src/Builder4/PopoverProperty.bjs b/src/Builder4/PopoverProperty.bjs index d584d28f3..347c3c9a7 100644 --- a/src/Builder4/PopoverProperty.bjs +++ b/src/Builder4/PopoverProperty.bjs @@ -26,121 +26,141 @@ "items" : [ { "$ xns" : "Gtk", - "bool show_title_buttons" : false, + "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", "id" : "header", "items" : [ { "$ xns" : "Gtk", - "* prop" : "title_widget", + "bool always_show_image" : true, + "bool hexpand" : true, + "id" : "cancelbtn", + "listeners" : { + "clicked" : [ + "() => {", + "\t_this.prop = null;", + "\t_this.is_new = false;", + "\t_this.kname.el.set_text(\"Cancel\");", + "\t_this.el.hide();", + "\t", + "}" + ] + }, + "string label" : "Cancel", + "xtype" : "Button" + }, + { + "$ xns" : "Gtk", + "bool hexpand" : true, "id" : "headertitle", "string label" : "Add / Edit property", "xtype" : "Label" + }, + { + "$ xns" : "Gtk", + "bool always_show_image" : true, + "bool hexpand" : true, + "id" : "savebtn", + "listeners" : { + "clicked" : [ + "() => {", + "\tif (!_this.is_new) {", + "\t\t_this.el.hide();", + "\t}", + "\t", + "\t// check if text is not empty..", + "\tif ( _this.kname.el.get_text().strip().length < 1) {", + "\t", + "\t\t// error should already be showing?", + "\t\treturn;", + "\t}", + "\t ", + "\t// since we can't add listeners?!?!?", + "\t// only check props.", + "\t// check if property already exists in node.\t", + "", + "", + "\tvar prop = new JsRender.NodeProp(", + "\t\t_this.kname.el.get_text().strip(),", + "\t\t_this.ptype.getValue(),", + "\t\t_this.ktype.el.get_text().strip(),", + "\t\t_this.prop.val", + "\t);", + "", + "\tif (_this.node.props.has_key(prop.to_index_key())) {", + "\t\t_this.error.setError(\"Property already exists\");", + "\t\treturn;\t", + "\t}", + "\t", + "\t", + "\t", + "\t_this.node.add_prop(prop);", + "\t// hide self", + "\t_this.prop = null; // skip checks..", + "\t_this.is_new = false;", + "\t_this.el.hide();", + " \t_this.mainwindow.windowstate.left_props.changed();", + "\t_this.mainwindow.windowstate.left_props.view.editProp(prop);", + "", + "\t", + "\t", + "}" + ] + }, + "string label" : "Add Property", + "xtype" : "Button" } ], - "xtype" : "HeaderBar" + "xtype" : "Box" + }, + { + "$ visible" : true, + "$ xns" : "Gtk", + "Gtk.Align halign" : "Gtk.Align.START", + "Gtk.Justification justify" : "Gtk.Justification.LEFT", + "int margin_top" : 12, + "label" : "Property Type (eg. property or method)", + "x_options" : 4, + "xtype" : "Label" }, { "$ xns" : "Gtk", - "bool show_row_separators" : true, - "bool show_separators" : true, + "bool show_arrow" : true, "id" : "ptype", "items" : [ { + "$ strings" : "JsRender.NodePropType.get_pulldown_list()", "$ xns" : "Gtk", "* prop" : "model", - "id" : "pselmodel", - "items" : [ - { - "$ xns" : "GLib", - "* ctor" : "new GLib.ListStore(typeof(JsRender.NodeProp));", - "* init" : [ - "{", - "", - "", - "\tthis.el.append( new JsRender.NodeProp.prop(\"\"));", - "\tthis.el.append( new JsRender.NodeProp.raw(\"\"));", - "\tthis.el.append( new JsRender.NodeProp.valamethod(\"\"));", - "\tthis.el.append( new JsRender.NodeProp.special(\"\"));\t", - "\tthis.el.append( new JsRender.NodeProp.listener(\"\"));\t\t", - "\tthis.el.append( new JsRender.NodeProp.user(\"\"));\t", - "\tthis.el.append( new JsRender.NodeProp.sig(\"\"));\t", - "\t", - "", - "}", - "" - ], - "* prop" : "model", - "id" : "pmodel", - "xtype" : "ListStore" - } - ], - "xtype" : "SingleSelection" - }, - { - "$ xns" : "Gtk", - "* pack" : "append_column", - "items" : [ - { - "$ xns" : "Gtk", - "* prop" : "factory", - "listeners" : { - "bind" : [ - "(listitem) => {", - "", - " \tvar lbl = (Gtk.Label) ((Gtk.ListItem)listitem).get_child(); ", - " \tvar np = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item();", - " ", - "\t", - " ", - "\tlbl.label = np.ptype.to_name();", - " \t ", - "}", - "" - ], - "setup" : [ - "(listitem) => {", - "", - "\t ", - "\tvar label = new Gtk.Label(\"\");", - "\tlabel.xalign = 0;", - "\t ", - "\t((Gtk.ListItem)listitem).set_child(label);", - "\t((Gtk.ListItem)listitem).activatable = false;", - "\t", - "}", - "" - ] - }, - "xtype" : "SignalListItemFactory" - } - ], - "string title" : "Property Type", - "xtype" : "ColumnViewColumn" + "xtype" : "StringList" } ], - "xtype" : "ColumnView", + "listeners" : { + "notify[\"selected\"]" : [ + "() => {", + "", + "\t_this.el.grab_focus(); // stop prevent autohide breaking.", + " }" + ] + }, + "xtype" : "DropDown", "| JsRender.NodePropType getValue" : [ "() {", - "\t", - "\tvar li = (JsRender.NodeProp) _this.pmodel.el.get_item(", - "\t\t_this.pselmodel.el.get_selected()", - "\t\t);", - "\treturn li.ptype;", - "", + "\tvar sl = this.el.model as Gtk.StringList;", + "\tvar str = sl.get_string(this.el.selected);", + "\treturn JsRender.NodePropType.nameToType(str);", "}" ], "| void setValue" : [ - "(JsRender.NodePropType pt) ", - "{", - " \tfor (var i = 0; i < _this.pmodel.el.n_items; i++) {", - "\t \tvar li = (JsRender.NodeProp) _this.pmodel.el.get_item(i);", - " \t\tif (li.ptype == pt) {", - " \t\t\t_this.pselmodel.el.set_selected(i);", - " \t\t\treturn;", + "(JsRender.NodePropType ty) {", + "\tvar str = ty.to_name();", + "\tvar sl = this.el.model as Gtk.StringList;", + "\tfor(var i = 0; i < sl.get_n_items(); i++) {", + "\t\tif(sl.get_string(i) == str) {", + "\t\t\tthis.el.set_selected(i);", + "\t\t\tbreak;", "\t\t}", "\t}", - "\tGLib.debug(\"failed to set selected ptype\");", - "\t_this.pselmodel.el.set_selected(0);", + "\t", "}" ] }, @@ -239,82 +259,6 @@ "}", "" ] - }, - { - "$ xns" : "Gtk", - "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", - "id" : "buttonbar", - "int margin_top" : 20, - "items" : [ - { - "$ xns" : "Gtk", - "bool always_show_image" : true, - "bool hexpand" : true, - "listeners" : { - "clicked" : [ - "() => {", - "\t_this.prop = null;", - "\t_this.is_new = false;", - "\t_this.kname.el.set_text(\"Cancel\");", - "\t_this.el.hide();", - "\t", - "}" - ] - }, - "string label" : "Cancel", - "xtype" : "Button" - }, - { - "$ xns" : "Gtk", - "bool always_show_image" : true, - "bool hexpand" : true, - "listeners" : { - "clicked" : [ - "() => {", - "\t// check if text is not empty..", - "\tif ( _this.kname.el.get_text().strip().length < 1) {", - "\t", - "\t\t// error should already be showing?", - "\t\treturn;", - "\t}", - "\t ", - "\t// since we can't add listeners?!?!?", - "\t// only check props.", - "\t// check if property already exists in node.\t", - "", - "", - "\tvar prop = new JsRender.NodeProp(", - "\t\t_this.kname.el.get_text().strip(),", - "\t\t_this.ptype.getValue(),", - "\t\t_this.ktype.el.get_text().strip(),", - "\t\t_this.prop.val", - "\t);", - "", - "\tif (_this.node.props.has_key(prop.to_index_key())) {", - "\t\t_this.error.setError(\"Property already exists\");", - "\t\treturn;\t", - "\t}", - "\t", - "\t", - "\t", - "\t_this.node.add_prop(prop);", - "\t// hide self", - "\t_this.prop = null; // skip checks..", - "\t_this.is_new = false;", - "\t_this.el.hide();", - " \t_this.mainwindow.windowstate.left_props.changed();", - "\t_this.mainwindow.windowstate.left_props.view.editProp(prop);", - "", - "\t", - "\t", - "}" - ] - }, - "string label" : "Add Property", - "xtype" : "Button" - } - ], - "xtype" : "Box" } ], "xtype" : "Box" @@ -441,9 +385,11 @@ "\t GLib.debug(\"SHOWALL - POPIP\\n\");", "\t", "\tthis.kname.el.grab_focus();", - "\tthis.buttonbar.el.hide();", + "\tthis.savebtn.el.set_label(\"Save\");", + "\tthis.cancelbtn.el.visible = false;", "\tif (this.is_new) {", - "\t\tthis.buttonbar.el.show();", + "\t\tthis.savebtn.el.set_label(\"Add Property\");", + "\t\tthis.cancelbtn.el.visible = true;", "\t}", "\tthis.error.setError(\"\");", "\tthis.el.show();", diff --git a/src/Builder4/PopoverProperty.vala b/src/Builder4/PopoverProperty.vala index bc4df8167..7de01f9f9 100644 --- a/src/Builder4/PopoverProperty.vala +++ b/src/Builder4/PopoverProperty.vala @@ -13,25 +13,24 @@ public class Xcls_PopoverProperty : Object return _PopoverProperty; } public Xcls_header header; + public Xcls_cancelbtn cancelbtn; public Xcls_headertitle headertitle; + public Xcls_savebtn savebtn; public Xcls_ptype ptype; - public Xcls_pselmodel pselmodel; - public Xcls_pmodel pmodel; public Xcls_ktype ktype; public Xcls_kname kname; public Xcls_error error; - public Xcls_buttonbar buttonbar; // my vars (def) public bool is_new; public Gtk.PositionType position; public signal void success (Project.Project pr, JsRender.JsRender file); public string key_type; - public JsRender.NodeProp? prop; - public bool done; public Xcls_MainWindow mainwindow; public JsRender.Node node; public JsRender.NodeProp? original_prop; + public JsRender.NodeProp? prop; + public bool done; public string old_keyname; // ctor @@ -43,14 +42,14 @@ public class Xcls_PopoverProperty : Object // my vars (dec) this.is_new = false; this.position = Gtk.PositionType.RIGHT; - this.prop = null; - this.done = false; this.mainwindow = null; this.original_prop = null; + this.prop = null; + this.done = false; // set gobject values this.el.autohide = true; - var child_1 = new Xcls_Box2( _this ); + var child_1 = new Xcls_Box1( _this ); child_1.ref(); this.el.set_child ( child_1.el ); @@ -182,16 +181,18 @@ public class Xcls_PopoverProperty : Object GLib.debug("SHOWALL - POPIP\n"); this.kname.el.grab_focus(); - this.buttonbar.el.hide(); + this.savebtn.el.set_label("Save"); + this.cancelbtn.el.visible = false; if (this.is_new) { - this.buttonbar.el.show(); + this.savebtn.el.set_label("Add Property"); + this.cancelbtn.el.visible = true; } this.error.setError(""); this.el.show(); //this.success = c.success; } - public class Xcls_Box2 : Object + public class Xcls_Box1 : Object { public Gtk.Box el; private Xcls_PopoverProperty _this; @@ -200,7 +201,7 @@ public class Xcls_PopoverProperty : Object // my vars (def) // ctor - public Xcls_Box2(Xcls_PopoverProperty _owner ) + public Xcls_Box1(Xcls_PopoverProperty _owner ) { _this = _owner; this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); @@ -211,29 +212,30 @@ public class Xcls_PopoverProperty : Object this.el.homogeneous = false; new Xcls_header( _this ); this.el.append( _this.header.el ); + var child_2 = new Xcls_Label4( _this ); + child_2.ref(); + this.el.append( child_2.el ); new Xcls_ptype( _this ); this.el.append( _this.ptype.el ); - var child_3 = new Xcls_Label10( _this ); - child_3.ref(); - this.el.append( child_3.el ); + var child_4 = new Xcls_Label7( _this ); + child_4.ref(); + this.el.append( child_4.el ); new Xcls_ktype( _this ); this.el.append( _this.ktype.el ); - var child_5 = new Xcls_Label12( _this ); - child_5.ref(); - this.el.append( child_5.el ); + var child_6 = new Xcls_Label9( _this ); + child_6.ref(); + this.el.append( child_6.el ); new Xcls_kname( _this ); this.el.append( _this.kname.el ); new Xcls_error( _this ); this.el.append( _this.error.el ); - new Xcls_buttonbar( _this ); - this.el.append( _this.buttonbar.el ); } // user defined functions } public class Xcls_header : Object { - public Gtk.HeaderBar el; + public Gtk.Box el; private Xcls_PopoverProperty _this; @@ -244,224 +246,250 @@ public class Xcls_PopoverProperty : Object { _this = _owner; _this.header = this; - this.el = new Gtk.HeaderBar(); + this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); // my vars (dec) // set gobject values - this.el.show_title_buttons = false; + new Xcls_cancelbtn( _this ); + this.el.append( _this.cancelbtn.el ); new Xcls_headertitle( _this ); - this.el.title_widget = _this.headertitle.el; + this.el.append( _this.headertitle.el ); + new Xcls_savebtn( _this ); + this.el.append( _this.savebtn.el ); } // user defined functions } - public class Xcls_headertitle : Object + public class Xcls_cancelbtn : Object { - public Gtk.Label el; + public Gtk.Button el; private Xcls_PopoverProperty _this; // my vars (def) + public bool always_show_image; // ctor - public Xcls_headertitle(Xcls_PopoverProperty _owner ) + public Xcls_cancelbtn(Xcls_PopoverProperty _owner ) { _this = _owner; - _this.headertitle = this; - this.el = new Gtk.Label( "Add / Edit property" ); + _this.cancelbtn = this; + this.el = new Gtk.Button(); // my vars (dec) + this.always_show_image = true; // set gobject values + this.el.hexpand = true; + this.el.label = "Cancel"; + + //listeners + this.el.clicked.connect( () => { + _this.prop = null; + _this.is_new = false; + _this.kname.el.set_text("Cancel"); + _this.el.hide(); + + }); } // user defined functions } - - public class Xcls_ptype : Object + public class Xcls_headertitle : Object { - public Gtk.ColumnView el; + public Gtk.Label el; private Xcls_PopoverProperty _this; // my vars (def) - public bool show_separators; // ctor - public Xcls_ptype(Xcls_PopoverProperty _owner ) + public Xcls_headertitle(Xcls_PopoverProperty _owner ) { _this = _owner; - _this.ptype = this; - new Xcls_pselmodel( _this ); - this.el = new Gtk.ColumnView( _this.pselmodel.el ); + _this.headertitle = this; + this.el = new Gtk.Label( "Add / Edit property" ); // my vars (dec) - this.show_separators = true; // set gobject values - this.el.show_row_separators = true; - var child_2 = new Xcls_ColumnViewColumn8( _this ); - child_2.ref(); - this.el.append_column ( child_2.el ); + this.el.hexpand = true; } // user defined functions - public JsRender.NodePropType getValue () { - - var li = (JsRender.NodeProp) _this.pmodel.el.get_item( - _this.pselmodel.el.get_selected() - ); - return li.ptype; - - } - public void setValue (JsRender.NodePropType pt) - { - for (var i = 0; i < _this.pmodel.el.n_items; i++) { - var li = (JsRender.NodeProp) _this.pmodel.el.get_item(i); - if (li.ptype == pt) { - _this.pselmodel.el.set_selected(i); - return; - } - } - GLib.debug("failed to set selected ptype"); - _this.pselmodel.el.set_selected(0); - } } - public class Xcls_pselmodel : Object + + public class Xcls_savebtn : Object { - public Gtk.SingleSelection el; + public Gtk.Button el; private Xcls_PopoverProperty _this; // my vars (def) + public bool always_show_image; // ctor - public Xcls_pselmodel(Xcls_PopoverProperty _owner ) + public Xcls_savebtn(Xcls_PopoverProperty _owner ) { _this = _owner; - _this.pselmodel = this; - new Xcls_pmodel( _this ); - this.el = new Gtk.SingleSelection( _this.pmodel.el ); + _this.savebtn = this; + this.el = new Gtk.Button(); // my vars (dec) + this.always_show_image = true; // set gobject values + this.el.hexpand = true; + this.el.label = "Add Property"; + + //listeners + this.el.clicked.connect( () => { + if (!_this.is_new) { + _this.el.hide(); + } + + // check if text is not empty.. + if ( _this.kname.el.get_text().strip().length < 1) { + + // error should already be showing? + return; + } + + // since we can't add listeners?!?!? + // only check props. + // check if property already exists in node. + + + var prop = new JsRender.NodeProp( + _this.kname.el.get_text().strip(), + _this.ptype.getValue(), + _this.ktype.el.get_text().strip(), + _this.prop.val + ); + + if (_this.node.props.has_key(prop.to_index_key())) { + _this.error.setError("Property already exists"); + return; + } + + + + _this.node.add_prop(prop); + // hide self + _this.prop = null; // skip checks.. + _this.is_new = false; + _this.el.hide(); + _this.mainwindow.windowstate.left_props.changed(); + _this.mainwindow.windowstate.left_props.view.editProp(prop); + + + + }); } // user defined functions } - public class Xcls_pmodel : Object + + + public class Xcls_Label4 : Object { - public GLib.ListStore el; + public Gtk.Label el; private Xcls_PopoverProperty _this; // my vars (def) // ctor - public Xcls_pmodel(Xcls_PopoverProperty _owner ) + public Xcls_Label4(Xcls_PopoverProperty _owner ) { _this = _owner; - _this.pmodel = this; - this.el = new GLib.ListStore(typeof(JsRender.NodeProp));; + this.el = new Gtk.Label( "Property Type (eg. property or method)" ); // my vars (dec) // set gobject values - - // init method - - { - - - this.el.append( new JsRender.NodeProp.prop("")); - this.el.append( new JsRender.NodeProp.raw("")); - this.el.append( new JsRender.NodeProp.valamethod("")); - this.el.append( new JsRender.NodeProp.special("")); - this.el.append( new JsRender.NodeProp.listener("")); - this.el.append( new JsRender.NodeProp.user("")); - this.el.append( new JsRender.NodeProp.sig("")); - - - } + this.el.halign = Gtk.Align.START; + this.el.justify = Gtk.Justification.LEFT; + this.el.margin_top = 12; + this.el.visible = true; } // user defined functions } - - public class Xcls_ColumnViewColumn8 : Object + public class Xcls_ptype : Object { - public Gtk.ColumnViewColumn el; + public Gtk.DropDown el; private Xcls_PopoverProperty _this; // my vars (def) // ctor - public Xcls_ColumnViewColumn8(Xcls_PopoverProperty _owner ) + public Xcls_ptype(Xcls_PopoverProperty _owner ) { _this = _owner; - var child_1 = new Xcls_SignalListItemFactory9( _this ); + _this.ptype = this; + var child_1 = new Xcls_StringList6( _this ); child_1.ref(); - this.el = new Gtk.ColumnViewColumn( "Property Type", child_1.el ); + this.el = new Gtk.DropDown( child_1.el, null ); // my vars (dec) // set gobject values + this.el.show_arrow = true; + + //listeners + this.el.notify["selected"].connect( () => { + + _this.el.grab_focus(); // stop prevent autohide breaking. + }); } // user defined functions + public JsRender.NodePropType getValue () { + var sl = this.el.model as Gtk.StringList; + var str = sl.get_string(this.el.selected); + return JsRender.NodePropType.nameToType(str); + } + public void setValue (JsRender.NodePropType ty) { + var str = ty.to_name(); + var sl = this.el.model as Gtk.StringList; + for(var i = 0; i < sl.get_n_items(); i++) { + if(sl.get_string(i) == str) { + this.el.set_selected(i); + break; + } + } + + } } - public class Xcls_SignalListItemFactory9 : Object + public class Xcls_StringList6 : Object { - public Gtk.SignalListItemFactory el; + public Gtk.StringList el; private Xcls_PopoverProperty _this; // my vars (def) // ctor - public Xcls_SignalListItemFactory9(Xcls_PopoverProperty _owner ) + public Xcls_StringList6(Xcls_PopoverProperty _owner ) { _this = _owner; - this.el = new Gtk.SignalListItemFactory(); + this.el = new Gtk.StringList( JsRender.NodePropType.get_pulldown_list() ); // my vars (dec) // set gobject values - - //listeners - this.el.setup.connect( (listitem) => { - - - var label = new Gtk.Label(""); - label.xalign = 0; - - ((Gtk.ListItem)listitem).set_child(label); - ((Gtk.ListItem)listitem).activatable = false; - - }); - this.el.bind.connect( (listitem) => { - - var lbl = (Gtk.Label) ((Gtk.ListItem)listitem).get_child(); - var np = (JsRender.NodeProp)((Gtk.ListItem)listitem).get_item(); - - - - lbl.label = np.ptype.to_name(); - - }); } // user defined functions } - - public class Xcls_Label10 : Object + public class Xcls_Label7 : Object { public Gtk.Label el; private Xcls_PopoverProperty _this; @@ -470,7 +498,7 @@ public class Xcls_PopoverProperty : Object // my vars (def) // ctor - public Xcls_Label10(Xcls_PopoverProperty _owner ) + public Xcls_Label7(Xcls_PopoverProperty _owner ) { _this = _owner; this.el = new Gtk.Label( "Type or Return Type" ); @@ -511,7 +539,7 @@ public class Xcls_PopoverProperty : Object // user defined functions } - public class Xcls_Label12 : Object + public class Xcls_Label9 : Object { public Gtk.Label el; private Xcls_PopoverProperty _this; @@ -520,7 +548,7 @@ public class Xcls_PopoverProperty : Object // my vars (def) // ctor - public Xcls_Label12(Xcls_PopoverProperty _owner ) + public Xcls_Label9(Xcls_PopoverProperty _owner ) { _this = _owner; this.el = new Gtk.Label( "Name" ); @@ -557,17 +585,17 @@ public class Xcls_PopoverProperty : Object // set gobject values this.el.visible = true; - var child_1 = new Xcls_EventControllerFocus14( _this ); + var child_1 = new Xcls_EventControllerFocus11( _this ); child_1.ref(); this.el.add_controller( child_1.el ); - var child_2 = new Xcls_EventControllerKey15( _this ); + var child_2 = new Xcls_EventControllerKey12( _this ); child_2.ref(); this.el.add_controller( child_2.el ); } // user defined functions } - public class Xcls_EventControllerFocus14 : Object + public class Xcls_EventControllerFocus11 : Object { public Gtk.EventControllerFocus el; private Xcls_PopoverProperty _this; @@ -576,7 +604,7 @@ public class Xcls_PopoverProperty : Object // my vars (def) // ctor - public Xcls_EventControllerFocus14(Xcls_PopoverProperty _owner ) + public Xcls_EventControllerFocus11(Xcls_PopoverProperty _owner ) { _this = _owner; this.el = new Gtk.EventControllerFocus(); @@ -600,7 +628,7 @@ public class Xcls_PopoverProperty : Object // user defined functions } - public class Xcls_EventControllerKey15 : Object + public class Xcls_EventControllerKey12 : Object { public Gtk.EventControllerKey el; private Xcls_PopoverProperty _this; @@ -609,7 +637,7 @@ public class Xcls_PopoverProperty : Object // my vars (def) // ctor - public Xcls_EventControllerKey15(Xcls_PopoverProperty _owner ) + public Xcls_EventControllerKey12(Xcls_PopoverProperty _owner ) { _this = _owner; this.el = new Gtk.EventControllerKey(); @@ -672,136 +700,5 @@ public class Xcls_PopoverProperty : Object } } - public class Xcls_buttonbar : Object - { - public Gtk.Box el; - private Xcls_PopoverProperty _this; - - - // my vars (def) - - // ctor - public Xcls_buttonbar(Xcls_PopoverProperty _owner ) - { - _this = _owner; - _this.buttonbar = this; - this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.margin_top = 20; - var child_1 = new Xcls_Button18( _this ); - child_1.ref(); - this.el.append( child_1.el ); - var child_2 = new Xcls_Button19( _this ); - child_2.ref(); - this.el.append( child_2.el ); - } - - // user defined functions - } - public class Xcls_Button18 : Object - { - public Gtk.Button el; - private Xcls_PopoverProperty _this; - - - // my vars (def) - public bool always_show_image; - - // ctor - public Xcls_Button18(Xcls_PopoverProperty _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - this.always_show_image = true; - - // set gobject values - this.el.hexpand = true; - this.el.label = "Cancel"; - - //listeners - this.el.clicked.connect( () => { - _this.prop = null; - _this.is_new = false; - _this.kname.el.set_text("Cancel"); - _this.el.hide(); - - }); - } - - // user defined functions - } - - public class Xcls_Button19 : Object - { - public Gtk.Button el; - private Xcls_PopoverProperty _this; - - - // my vars (def) - public bool always_show_image; - - // ctor - public Xcls_Button19(Xcls_PopoverProperty _owner ) - { - _this = _owner; - this.el = new Gtk.Button(); - - // my vars (dec) - this.always_show_image = true; - - // set gobject values - this.el.hexpand = true; - this.el.label = "Add Property"; - - //listeners - this.el.clicked.connect( () => { - // check if text is not empty.. - if ( _this.kname.el.get_text().strip().length < 1) { - - // error should already be showing? - return; - } - - // since we can't add listeners?!?!? - // only check props. - // check if property already exists in node. - - - var prop = new JsRender.NodeProp( - _this.kname.el.get_text().strip(), - _this.ptype.getValue(), - _this.ktype.el.get_text().strip(), - _this.prop.val - ); - - if (_this.node.props.has_key(prop.to_index_key())) { - _this.error.setError("Property already exists"); - return; - } - - - - _this.node.add_prop(prop); - // hide self - _this.prop = null; // skip checks.. - _this.is_new = false; - _this.el.hide(); - _this.mainwindow.windowstate.left_props.changed(); - _this.mainwindow.windowstate.left_props.view.editProp(prop); - - - - }); - } - - // user defined functions - } - - } diff --git a/src/Builder4/WindowLeftTree.bjs b/src/Builder4/WindowLeftTree.bjs index 641f61d00..4af302ea1 100644 --- a/src/Builder4/WindowLeftTree.bjs +++ b/src/Builder4/WindowLeftTree.bjs @@ -1563,6 +1563,7 @@ "items" : [ { "$ xns" : "Gtk", + "bool has_frame" : false, "label" : "Delete Element", "listeners" : { "clicked" : [ @@ -1577,6 +1578,7 @@ }, { "$ xns" : "Gtk", + "bool has_frame" : false, "label" : "Save as Template", "listeners" : { "clicked" : [ @@ -1596,6 +1598,7 @@ }, { "$ xns" : "Gtk", + "bool has_frame" : false, "label" : "Save as Module", "listeners" : { "clicked" : [ diff --git a/src/Builder4/WindowLeftTree.vala b/src/Builder4/WindowLeftTree.vala index e486653f4..322f5ffb2 100644 --- a/src/Builder4/WindowLeftTree.vala +++ b/src/Builder4/WindowLeftTree.vala @@ -41,7 +41,7 @@ public class Xcls_WindowLeftTree : Object // set gobject values this.el.hexpand = true; this.el.vexpand = true; - var child_1 = new Xcls_ListView2( _this ); + var child_1 = new Xcls_ListView1( _this ); child_1.ref(); this.el.append( child_1.el ); new Xcls_viewwin( _this ); @@ -161,7 +161,7 @@ public class Xcls_WindowLeftTree : Object public JsRender.JsRender getActiveFile () { return this.main_window.windowstate.file; } - public class Xcls_ListView2 : Object + public class Xcls_ListView1 : Object { public Gtk.ListView el; private Xcls_WindowLeftTree _this; @@ -170,10 +170,10 @@ public class Xcls_WindowLeftTree : Object // my vars (def) // ctor - public Xcls_ListView2(Xcls_WindowLeftTree _owner ) + public Xcls_ListView1(Xcls_WindowLeftTree _owner ) { _this = _owner; - var child_1 = new Xcls_SignalListItemFactory3( _this ); + var child_1 = new Xcls_SignalListItemFactory2( _this ); child_1.ref(); this.el = new Gtk.ListView( null, child_1.el ); @@ -184,7 +184,7 @@ public class Xcls_WindowLeftTree : Object // user defined functions } - public class Xcls_SignalListItemFactory3 : Object + public class Xcls_SignalListItemFactory2 : Object { public Gtk.SignalListItemFactory el; private Xcls_WindowLeftTree _this; @@ -193,7 +193,7 @@ public class Xcls_WindowLeftTree : Object // my vars (def) // ctor - public Xcls_SignalListItemFactory3(Xcls_WindowLeftTree _owner ) + public Xcls_SignalListItemFactory2(Xcls_WindowLeftTree _owner ) { _this = _owner; this.el = new Gtk.SignalListItemFactory(); @@ -270,16 +270,16 @@ public class Xcls_WindowLeftTree : Object this.el.name = "left-tree-view"; this.el.hexpand = false; this.el.vexpand = true; - var child_2 = new Xcls_GestureClick6( _this ); + var child_2 = new Xcls_GestureClick5( _this ); child_2.ref(); this.el.add_controller( child_2.el ); - var child_3 = new Xcls_GestureClick7( _this ); + var child_3 = new Xcls_GestureClick6( _this ); child_3.ref(); this.el.add_controller( child_3.el ); - var child_4 = new Xcls_DragSource8( _this ); + var child_4 = new Xcls_DragSource7( _this ); child_4.ref(); this.el.add_controller( child_4.el ); - var child_5 = new Xcls_EventControllerKey9( _this ); + var child_5 = new Xcls_EventControllerKey8( _this ); child_5.ref(); this.el.add_controller( child_5.el ); new Xcls_keystate( _this ); @@ -288,7 +288,7 @@ public class Xcls_WindowLeftTree : Object this.el.add_controller( _this.drop.el ); new Xcls_maincol( _this ); this.el.append_column ( _this.maincol.el ); - var child_9 = new Xcls_ColumnViewColumn16( _this ); + var child_9 = new Xcls_ColumnViewColumn15( _this ); child_9.ref(); this.el.append_column ( child_9.el ); @@ -595,7 +595,7 @@ public class Xcls_WindowLeftTree : Object } } - public class Xcls_GestureClick6 : Object + public class Xcls_GestureClick5 : Object { public Gtk.GestureClick el; private Xcls_WindowLeftTree _this; @@ -604,7 +604,7 @@ public class Xcls_WindowLeftTree : Object // my vars (def) // ctor - public Xcls_GestureClick6(Xcls_WindowLeftTree _owner ) + public Xcls_GestureClick5(Xcls_WindowLeftTree _owner ) { _this = _owner; this.el = new Gtk.GestureClick(); @@ -681,7 +681,7 @@ public class Xcls_WindowLeftTree : Object // user defined functions } - public class Xcls_GestureClick7 : Object + public class Xcls_GestureClick6 : Object { public Gtk.GestureClick el; private Xcls_WindowLeftTree _this; @@ -690,7 +690,7 @@ public class Xcls_WindowLeftTree : Object // my vars (def) // ctor - public Xcls_GestureClick7(Xcls_WindowLeftTree _owner ) + public Xcls_GestureClick6(Xcls_WindowLeftTree _owner ) { _this = _owner; this.el = new Gtk.GestureClick(); @@ -752,7 +752,7 @@ public class Xcls_WindowLeftTree : Object // user defined functions } - public class Xcls_DragSource8 : Object + public class Xcls_DragSource7 : Object { public Gtk.DragSource el; private Xcls_WindowLeftTree _this; @@ -761,7 +761,7 @@ public class Xcls_WindowLeftTree : Object // my vars (def) // ctor - public Xcls_DragSource8(Xcls_WindowLeftTree _owner ) + public Xcls_DragSource7(Xcls_WindowLeftTree _owner ) { _this = _owner; this.el = new Gtk.DragSource(); @@ -842,7 +842,7 @@ public class Xcls_WindowLeftTree : Object // user defined functions } - public class Xcls_EventControllerKey9 : Object + public class Xcls_EventControllerKey8 : Object { public Gtk.EventControllerKey el; private Xcls_WindowLeftTree _this; @@ -851,7 +851,7 @@ public class Xcls_WindowLeftTree : Object // my vars (def) // ctor - public Xcls_EventControllerKey9(Xcls_WindowLeftTree _owner ) + public Xcls_EventControllerKey8(Xcls_WindowLeftTree _owner ) { _this = _owner; this.el = new Gtk.EventControllerKey(); @@ -1721,7 +1721,7 @@ public class Xcls_WindowLeftTree : Object { _this = _owner; _this.maincol = this; - var child_1 = new Xcls_SignalListItemFactory15( _this ); + var child_1 = new Xcls_SignalListItemFactory14( _this ); child_1.ref(); this.el = new Gtk.ColumnViewColumn( "Property", child_1.el ); @@ -1735,7 +1735,7 @@ public class Xcls_WindowLeftTree : Object // user defined functions } - public class Xcls_SignalListItemFactory15 : Object + public class Xcls_SignalListItemFactory14 : Object { public Gtk.SignalListItemFactory el; private Xcls_WindowLeftTree _this; @@ -1744,7 +1744,7 @@ public class Xcls_WindowLeftTree : Object // my vars (def) // ctor - public Xcls_SignalListItemFactory15(Xcls_WindowLeftTree _owner ) + public Xcls_SignalListItemFactory14(Xcls_WindowLeftTree _owner ) { _this = _owner; this.el = new Gtk.SignalListItemFactory(); @@ -1845,7 +1845,7 @@ public class Xcls_WindowLeftTree : Object } - public class Xcls_ColumnViewColumn16 : Object + public class Xcls_ColumnViewColumn15 : Object { public Gtk.ColumnViewColumn el; private Xcls_WindowLeftTree _this; @@ -1854,10 +1854,10 @@ public class Xcls_WindowLeftTree : Object // my vars (def) // ctor - public Xcls_ColumnViewColumn16(Xcls_WindowLeftTree _owner ) + public Xcls_ColumnViewColumn15(Xcls_WindowLeftTree _owner ) { _this = _owner; - var child_1 = new Xcls_SignalListItemFactory17( _this ); + var child_1 = new Xcls_SignalListItemFactory16( _this ); child_1.ref(); this.el = new Gtk.ColumnViewColumn( "Add", child_1.el ); @@ -1869,7 +1869,7 @@ public class Xcls_WindowLeftTree : Object // user defined functions } - public class Xcls_SignalListItemFactory17 : Object + public class Xcls_SignalListItemFactory16 : Object { public Gtk.SignalListItemFactory el; private Xcls_WindowLeftTree _this; @@ -1878,7 +1878,7 @@ public class Xcls_WindowLeftTree : Object // my vars (def) // ctor - public Xcls_SignalListItemFactory17(Xcls_WindowLeftTree _owner ) + public Xcls_SignalListItemFactory16(Xcls_WindowLeftTree _owner ) { _this = _owner; this.el = new Gtk.SignalListItemFactory(); @@ -1941,13 +1941,13 @@ public class Xcls_WindowLeftTree : Object // my vars (dec) // set gobject values - var child_1 = new Xcls_Box19( _this ); + var child_1 = new Xcls_Box18( _this ); this.el.child = child_1.el; } // user defined functions } - public class Xcls_Box19 : Object + public class Xcls_Box18 : Object { public Gtk.Box el; private Xcls_WindowLeftTree _this; @@ -1956,7 +1956,7 @@ public class Xcls_WindowLeftTree : Object // my vars (def) // ctor - public Xcls_Box19(Xcls_WindowLeftTree _owner ) + public Xcls_Box18(Xcls_WindowLeftTree _owner ) { _this = _owner; this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); @@ -1964,20 +1964,20 @@ public class Xcls_WindowLeftTree : Object // my vars (dec) // set gobject values - var child_1 = new Xcls_Button20( _this ); + var child_1 = new Xcls_Button19( _this ); child_1.ref(); this.el.append( child_1.el ); - var child_2 = new Xcls_Button21( _this ); + var child_2 = new Xcls_Button20( _this ); child_2.ref(); this.el.append( child_2.el ); - var child_3 = new Xcls_Button22( _this ); + var child_3 = new Xcls_Button21( _this ); child_3.ref(); this.el.append( child_3.el ); } // user defined functions } - public class Xcls_Button20 : Object + public class Xcls_Button19 : Object { public Gtk.Button el; private Xcls_WindowLeftTree _this; @@ -1986,7 +1986,7 @@ public class Xcls_WindowLeftTree : Object // my vars (def) // ctor - public Xcls_Button20(Xcls_WindowLeftTree _owner ) + public Xcls_Button19(Xcls_WindowLeftTree _owner ) { _this = _owner; this.el = new Gtk.Button(); @@ -1994,6 +1994,7 @@ public class Xcls_WindowLeftTree : Object // my vars (dec) // set gobject values + this.el.has_frame = false; this.el.label = "Delete Element"; //listeners @@ -2007,7 +2008,7 @@ public class Xcls_WindowLeftTree : Object // user defined functions } - public class Xcls_Button21 : Object + public class Xcls_Button20 : Object { public Gtk.Button el; private Xcls_WindowLeftTree _this; @@ -2016,7 +2017,7 @@ public class Xcls_WindowLeftTree : Object // my vars (def) // ctor - public Xcls_Button21(Xcls_WindowLeftTree _owner ) + public Xcls_Button20(Xcls_WindowLeftTree _owner ) { _this = _owner; this.el = new Gtk.Button(); @@ -2024,6 +2025,7 @@ public class Xcls_WindowLeftTree : Object // my vars (dec) // set gobject values + this.el.has_frame = false; this.el.label = "Save as Template"; //listeners @@ -2042,7 +2044,7 @@ public class Xcls_WindowLeftTree : Object // user defined functions } - public class Xcls_Button22 : Object + public class Xcls_Button21 : Object { public Gtk.Button el; private Xcls_WindowLeftTree _this; @@ -2051,7 +2053,7 @@ public class Xcls_WindowLeftTree : Object // my vars (def) // ctor - public Xcls_Button22(Xcls_WindowLeftTree _owner ) + public Xcls_Button21(Xcls_WindowLeftTree _owner ) { _this = _owner; this.el = new Gtk.Button(); @@ -2059,6 +2061,7 @@ public class Xcls_WindowLeftTree : Object // my vars (dec) // set gobject values + this.el.has_frame = false; this.el.label = "Save as Module"; //listeners diff --git a/src/JsRender/NodeProp.vala b/src/JsRender/NodeProp.vala index fed051f43..edb5e1769 100644 --- a/src/JsRender/NodeProp.vala +++ b/src/JsRender/NodeProp.vala @@ -86,6 +86,43 @@ public enum JsRender.NodePropType } } + public static NodePropType[] alltypes() + { + return { + PROP, + USER, + RAW, + METHOD, + SIGNAL, + + SPECIAL, + LISTENER + // CTOR, + + }; + } + public static NodePropType nameToType(string str) + { + foreach(var np in alltypes()) { + if (np.to_name() == str) { + return np; + } + } + return NONE; + + } + public static string[] get_pulldown_list() + { + // eventually it needs to be smarter.... - but i did not have internet so could not use listmodels for the dropdown + + string[] ret = {}; + foreach(var np in alltypes()) { + ret += np.to_name(); + } + return ret; + + } + } @@ -94,6 +131,10 @@ public enum JsRender.NodePropType public class JsRender.NodeProp : Object { + + + + private string _name = ""; public string name { get { @@ -217,6 +258,10 @@ public class JsRender.NodeProp : Object { this.childstore = new GLib.ListStore( typeof(NodeProp)); } + public string ptype_as_string { + get { return this.ptype.to_string(); } + private set {} + } public bool equals(NodeProp p) @@ -640,6 +685,7 @@ public class JsRender.NodeProp : Object { this.childstore.append(child); } + /** could use enums.. but basically. diff --git a/src/JsRender/NodeToGlade.vala b/src/JsRender/NodeToGlade.vala index d9534130d..874983f10 100644 --- a/src/JsRender/NodeToGlade.vala +++ b/src/JsRender/NodeToGlade.vala @@ -153,8 +153,11 @@ public class JsRender.NodeToGlade : Object { val = bits[bits.length-1].down(); } } - + // value for model seems to cause problems...(it's ok as a property?) + if (k == "model") { + continue; + } var domprop = this.create_element("property"); -- 2.39.2