From bb10b19eb0275c6459a571e10f1ee77c6411f29f Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Thu, 25 Jan 2024 22:58:57 +0800 Subject: [PATCH] fix language server save, node edit trigger compile, render update on gtkview source --- src/Application.vala | 12 +- src/Builder4/GtkView.bjs | 4 +- src/Builder4/GtkView.vala | 4 +- src/Builder4/PopoverProperty.bjs | 22 +- src/Builder4/PopoverProperty.vala | 1563 ++++++++++++++-------------- src/JsRender/Gtk.vala | 2 + src/JsRender/NodeProp.vala | 18 +- src/Palete/LanguageClientVala.vala | 43 +- 8 files changed, 857 insertions(+), 811 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 7584337cf..84260d572 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -521,6 +521,9 @@ if (ls == null) { GLib.error("No langauge server returned for file:%s", file.relpath); } + + //GLib.debug("started server - sleep 30 secs so you can gdb attach"); + //Posix.sleep( 30 ); var loop = new MainLoop(); GLib.Timeout.add_seconds(1, () => { @@ -528,11 +531,14 @@ // it's ready.. ls.document_open(file); + ls.document_save(file); + + //ls.syntax.begin(file, (obj,res) => { + // ls.syntax.end(res); + + //}); - ls.syntax.begin(file, (obj,res) => { - ls.syntax.end(res); - }); return false; }); diff --git a/src/Builder4/GtkView.bjs b/src/Builder4/GtkView.bjs index 9ec00016c..1184e246d 100644 --- a/src/Builder4/GtkView.bjs +++ b/src/Builder4/GtkView.bjs @@ -313,7 +313,7 @@ " this.loading = false;", " return;", " }", - " ", + " /*", " var valafn = \"\";", " try { ", " var regex = new Regex(\"\\\\.bjs$\");", @@ -340,6 +340,8 @@ " this.loading = false;", " return ;", " }", + " */", + " var str = _this.file.toSource();", "", "// print(\"setting str %d\\n\", str.length);", " buf.set_text(str, str.length);", diff --git a/src/Builder4/GtkView.vala b/src/Builder4/GtkView.vala index a56758564..44304406d 100644 --- a/src/Builder4/GtkView.vala +++ b/src/Builder4/GtkView.vala @@ -779,7 +779,7 @@ public class Xcls_GtkView : Object this.loading = false; return; } - + /* var valafn = ""; try { var regex = new Regex("\\.bjs$"); @@ -806,6 +806,8 @@ public class Xcls_GtkView : Object this.loading = false; return ; } + */ + var str = _this.file.toSource(); // print("setting str %d\n", str.length); buf.set_text(str, str.length); diff --git a/src/Builder4/PopoverProperty.bjs b/src/Builder4/PopoverProperty.bjs index dcc161630..d584d28f3 100644 --- a/src/Builder4/PopoverProperty.bjs +++ b/src/Builder4/PopoverProperty.bjs @@ -3,13 +3,16 @@ "gen_extended" : false, "items" : [ { - "# JsRender.NodeProp? prop" : "", + "# Gtk.PositionType position" : "Gtk.PositionType.RIGHT", + "# JsRender.Node node" : "", + "# JsRender.NodeProp? original_prop" : "null", + "# JsRender.NodeProp? prop" : "null", + "# Xcls_MainWindow mainwindow" : "null", + "# string key_type" : "", + "# string old_keyname" : "", "$ xns" : "Gtk", "* ctor" : "new Gtk.Popover()", "@ void success" : "(Project.Project pr, JsRender.JsRender file)", - "Gtk.PositionType position" : "Gtk.PositionType.RIGHT", - "JsRender.Node node" : "", - "Xcls_MainWindow mainwindow" : "null", "bool autohide" : true, "bool done" : false, "bool is_new" : false, @@ -299,7 +302,7 @@ "\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", @@ -356,12 +359,15 @@ "\t\treturn;", "", "\t}", + "\tif (this.original_prop != null && !this.prop.equals(this.original_prop)) {", + "\t\t// this is convoluted..", + "\t\t_this.mainwindow.windowstate.left_props.changed(); ", + "\t}", + "\t", "\t", "}" ] }, - "string key_type" : "", - "string old_keyname" : "", "xtype" : "Popover", "| void show" : [ "(", @@ -373,7 +379,7 @@ "\t ) ", "{", "\t", - " ", + " this.original_prop = prop.dupe();", "\tthis.is_new = is_new; ", "\tvar pref = is_new ? \"Add \" : \"Modify \";", "\tif (prop.ptype == JsRender.NodePropType.LISTENER) {", diff --git a/src/Builder4/PopoverProperty.vala b/src/Builder4/PopoverProperty.vala index 10e98cd6f..bc4df8167 100644 --- a/src/Builder4/PopoverProperty.vala +++ b/src/Builder4/PopoverProperty.vala @@ -1,798 +1,807 @@ - static Xcls_PopoverProperty _PopoverProperty; - - public class Xcls_PopoverProperty : Object - { - public Gtk.Popover el; - private Xcls_PopoverProperty _this; - - public static Xcls_PopoverProperty singleton() - { - if (_PopoverProperty == null) { - _PopoverProperty= new Xcls_PopoverProperty(); - } - return _PopoverProperty; - } - public Xcls_header header; - public Xcls_headertitle headertitle; - 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 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 string old_keyname; - - // ctor - public Xcls_PopoverProperty() - { - _this = this; - this.el = new Gtk.Popover(); - - // my vars (dec) - this.is_new = false; - this.done = false; - this.mainwindow = null; - - // set gobject values - this.el.autohide = true; - this.el.position = Gtk.PositionType.RIGHT; - var child_1 = new Xcls_Box2( _this ); - child_1.ref(); - this.el.set_child ( child_1.el ); - - //listeners - this.el.closed.connect( () => { - - GLib.debug("popover closed"); - if (_this.is_new) { - // dont allow hiding if we are creating a new one. - // on.hide will reshow it. - return; - } - if (_this.prop == null) { - // hide and dont update. - return; - } - if (this.kname.el.get_text().strip().length < 1) { - return; - } - - - - - this.updateProp(); - - - - - - }); - this.el.hide.connect( () => { - GLib.debug("popover hidden"); - if (_this.is_new || this.kname.el.get_text().strip().length < 1) { - // dont allow hiding if we are creating a new one. - GLib.debug("prevent hiding as its new or text is empty"); - this.el.show(); - return; - - } - - }); - } - - // user defined functions - public void updateProp () { - GLib.debug("updateProp called"); - - - - _this.prop.name = this.kname.el.get_text().strip(); - _this.prop.ptype = this.ptype.getValue(); - _this.prop.rtype = this.ktype.el.get_text().strip(); - - - } - public void show ( - Gtk.Widget btn, - JsRender.Node node, - JsRender.NodeProp prop, - int y, - bool is_new = false - ) - { - - - this.is_new = is_new; - var pref = is_new ? "Add " : "Modify "; - if (prop.ptype == JsRender.NodePropType.LISTENER) { - this.headertitle.el.label = pref + "Event Listener"; // cant really happen yet? - } else { - this.headertitle.el.label = pref + "Property"; - } - this.prop = prop; - this.node = node; - - _this.kname.el.set_text(prop.name); - _this.ktype.el.set_text(prop.rtype); - - _this.ptype.setValue(prop.ptype); - // does node have this property... - - - _this.node = node; - //console.log('show all'); - - GLib.debug("set parent = %s", btn.get_type().name()); - var par = btn.get_parent(); - - if (par == null) { - GLib.debug("parent of that is null - not showing"); - return; - } - if (this.el.parent == null) { - this.el.set_parent(btn); - } - var r = Gdk.Rectangle() { - x = btn.get_width(), // align left... - y = 0, - width = 1, - height = 1 - }; - //Gtk.Allocation rect; - //btn.get_allocation(out rect); - this.el.set_pointing_to(r); - - - - if (y > -1) { - - r = Gdk.Rectangle() { - x = btn.get_width(), // align left... - y = y, - width = 1, - height = 1 - }; - this.el.set_pointing_to( r); - } - - - - //this.el.set_position(Gtk.PositionType.TOP); - - // window + header? - GLib.debug("SHOWALL - POPIP\n"); - - this.kname.el.grab_focus(); - this.buttonbar.el.hide(); - if (this.is_new) { - this.buttonbar.el.show(); - } - this.error.setError(""); - this.el.show(); - //this.success = c.success; - - } - public class Xcls_Box2 : Object - { - public Gtk.Box el; - private Xcls_PopoverProperty _this; - - - // my vars (def) - - // ctor - public Xcls_Box2(Xcls_PopoverProperty _owner ) - { - _this = _owner; - this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); - - // my vars (dec) - - // set gobject values - this.el.homogeneous = false; - new Xcls_header( _this ); - this.el.append( _this.header.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 ); - 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 ); - 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; - private Xcls_PopoverProperty _this; - - - // my vars (def) - - // ctor - public Xcls_header(Xcls_PopoverProperty _owner ) - { - _this = _owner; - _this.header = this; - this.el = new Gtk.HeaderBar(); - - // my vars (dec) - - // set gobject values - this.el.show_title_buttons = false; - new Xcls_headertitle( _this ); - this.el.title_widget = _this.headertitle.el; - } - - // user defined functions - } - public class Xcls_headertitle : Object - { - public Gtk.Label el; - private Xcls_PopoverProperty _this; - - - // my vars (def) - - // ctor - public Xcls_headertitle(Xcls_PopoverProperty _owner ) - { - _this = _owner; - _this.headertitle = this; - this.el = new Gtk.Label( "Add / Edit property" ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - - - public class Xcls_ptype : Object - { - public Gtk.ColumnView el; - private Xcls_PopoverProperty _this; - - - // my vars (def) - public bool show_separators; - - // ctor - public Xcls_ptype(Xcls_PopoverProperty _owner ) - { - _this = _owner; - _this.ptype = this; - new Xcls_pselmodel( _this ); - this.el = new Gtk.ColumnView( _this.pselmodel.el ); - - // 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 ); - } - - // 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 Gtk.SingleSelection el; - private Xcls_PopoverProperty _this; - - - // my vars (def) - - // ctor - public Xcls_pselmodel(Xcls_PopoverProperty _owner ) - { - _this = _owner; - _this.pselmodel = this; - new Xcls_pmodel( _this ); - this.el = new Gtk.SingleSelection( _this.pmodel.el ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - public class Xcls_pmodel : Object - { - public GLib.ListStore el; - private Xcls_PopoverProperty _this; - - - // my vars (def) - - // ctor - public Xcls_pmodel(Xcls_PopoverProperty _owner ) - { - _this = _owner; - _this.pmodel = this; - this.el = new GLib.ListStore(typeof(JsRender.NodeProp));; - - // 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("")); - - - } - } - - // user defined functions - } - - - public class Xcls_ColumnViewColumn8 : Object - { - public Gtk.ColumnViewColumn el; - private Xcls_PopoverProperty _this; - - - // my vars (def) - - // ctor - public Xcls_ColumnViewColumn8(Xcls_PopoverProperty _owner ) - { - _this = _owner; - var child_1 = new Xcls_SignalListItemFactory9( _this ); - child_1.ref(); - this.el = new Gtk.ColumnViewColumn( "Property Type", child_1.el ); - - // my vars (dec) - - // set gobject values - } - - // user defined functions - } - public class Xcls_SignalListItemFactory9 : Object - { - public Gtk.SignalListItemFactory el; - private Xcls_PopoverProperty _this; - - - // my vars (def) - - // ctor - public Xcls_SignalListItemFactory9(Xcls_PopoverProperty _owner ) - { - _this = _owner; - this.el = new Gtk.SignalListItemFactory(); +static Xcls_PopoverProperty _PopoverProperty; + +public class Xcls_PopoverProperty : Object +{ + public Gtk.Popover el; + private Xcls_PopoverProperty _this; + + public static Xcls_PopoverProperty singleton() + { + if (_PopoverProperty == null) { + _PopoverProperty= new Xcls_PopoverProperty(); + } + return _PopoverProperty; + } + public Xcls_header header; + public Xcls_headertitle headertitle; + 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 string old_keyname; + + // ctor + public Xcls_PopoverProperty() + { + _this = this; + this.el = new Gtk.Popover(); + + // 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; + + // set gobject values + this.el.autohide = true; + var child_1 = new Xcls_Box2( _this ); + child_1.ref(); + this.el.set_child ( child_1.el ); + + //listeners + this.el.closed.connect( () => { + + GLib.debug("popover closed"); + if (_this.is_new) { + // dont allow hiding if we are creating a new one. + // on.hide will reshow it. + return; + } + if (_this.prop == null) { + // hide and dont update. + return; + } + if (this.kname.el.get_text().strip().length < 1) { + return; + } + + + + + this.updateProp(); + + + + + + }); + this.el.hide.connect( () => { + GLib.debug("popover hidden"); + if (_this.is_new || this.kname.el.get_text().strip().length < 1) { + // dont allow hiding if we are creating a new one. + GLib.debug("prevent hiding as its new or text is empty"); + this.el.show(); + return; + + } + if (this.original_prop != null && !this.prop.equals(this.original_prop)) { + // this is convoluted.. + _this.mainwindow.windowstate.left_props.changed(); + } + + + }); + } + + // user defined functions + public void updateProp () { + GLib.debug("updateProp called"); + + + + _this.prop.name = this.kname.el.get_text().strip(); + _this.prop.ptype = this.ptype.getValue(); + _this.prop.rtype = this.ktype.el.get_text().strip(); + + + } + public void show ( + Gtk.Widget btn, + JsRender.Node node, + JsRender.NodeProp prop, + int y, + bool is_new = false + ) + { + + this.original_prop = prop.dupe(); + this.is_new = is_new; + var pref = is_new ? "Add " : "Modify "; + if (prop.ptype == JsRender.NodePropType.LISTENER) { + this.headertitle.el.label = pref + "Event Listener"; // cant really happen yet? + } else { + this.headertitle.el.label = pref + "Property"; + } + this.prop = prop; + this.node = node; + + _this.kname.el.set_text(prop.name); + _this.ktype.el.set_text(prop.rtype); + + _this.ptype.setValue(prop.ptype); + // does node have this property... + + + _this.node = node; + //console.log('show all'); + + GLib.debug("set parent = %s", btn.get_type().name()); + var par = btn.get_parent(); + + if (par == null) { + GLib.debug("parent of that is null - not showing"); + return; + } + if (this.el.parent == null) { + this.el.set_parent(btn); + } + var r = Gdk.Rectangle() { + x = btn.get_width(), // align left... + y = 0, + width = 1, + height = 1 + }; + //Gtk.Allocation rect; + //btn.get_allocation(out rect); + this.el.set_pointing_to(r); + + + + if (y > -1) { + + r = Gdk.Rectangle() { + x = btn.get_width(), // align left... + y = y, + width = 1, + height = 1 + }; + this.el.set_pointing_to( r); + } + + + + //this.el.set_position(Gtk.PositionType.TOP); + + // window + header? + GLib.debug("SHOWALL - POPIP\n"); + + this.kname.el.grab_focus(); + this.buttonbar.el.hide(); + if (this.is_new) { + this.buttonbar.el.show(); + } + this.error.setError(""); + this.el.show(); + //this.success = c.success; + + } + public class Xcls_Box2 : Object + { + public Gtk.Box el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_Box2(Xcls_PopoverProperty _owner ) + { + _this = _owner; + this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 ); + + // my vars (dec) + + // set gobject values + this.el.homogeneous = false; + new Xcls_header( _this ); + this.el.append( _this.header.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 ); + 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 ); + 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; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_header(Xcls_PopoverProperty _owner ) + { + _this = _owner; + _this.header = this; + this.el = new Gtk.HeaderBar(); + + // my vars (dec) + + // set gobject values + this.el.show_title_buttons = false; + new Xcls_headertitle( _this ); + this.el.title_widget = _this.headertitle.el; + } + + // user defined functions + } + public class Xcls_headertitle : Object + { + public Gtk.Label el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_headertitle(Xcls_PopoverProperty _owner ) + { + _this = _owner; + _this.headertitle = this; + this.el = new Gtk.Label( "Add / Edit property" ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + + + public class Xcls_ptype : Object + { + public Gtk.ColumnView el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + public bool show_separators; + + // ctor + public Xcls_ptype(Xcls_PopoverProperty _owner ) + { + _this = _owner; + _this.ptype = this; + new Xcls_pselmodel( _this ); + this.el = new Gtk.ColumnView( _this.pselmodel.el ); + + // 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 ); + } + + // 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 Gtk.SingleSelection el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_pselmodel(Xcls_PopoverProperty _owner ) + { + _this = _owner; + _this.pselmodel = this; + new Xcls_pmodel( _this ); + this.el = new Gtk.SingleSelection( _this.pmodel.el ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_pmodel : Object + { + public GLib.ListStore el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_pmodel(Xcls_PopoverProperty _owner ) + { + _this = _owner; + _this.pmodel = this; + this.el = new GLib.ListStore(typeof(JsRender.NodeProp));; + + // 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("")); + + + } + } + + // user defined functions + } + + + public class Xcls_ColumnViewColumn8 : Object + { + public Gtk.ColumnViewColumn el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_ColumnViewColumn8(Xcls_PopoverProperty _owner ) + { + _this = _owner; + var child_1 = new Xcls_SignalListItemFactory9( _this ); + child_1.ref(); + this.el = new Gtk.ColumnViewColumn( "Property Type", child_1.el ); + + // my vars (dec) + + // set gobject values + } + + // user defined functions + } + public class Xcls_SignalListItemFactory9 : Object + { + public Gtk.SignalListItemFactory el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_SignalListItemFactory9(Xcls_PopoverProperty _owner ) + { + _this = _owner; + this.el = new Gtk.SignalListItemFactory(); - // my vars (dec) + // my vars (dec) - // set gobject values + // 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(); - - }); - } + //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 - } + // user defined functions + } - - public class Xcls_Label10 : Object - { - public Gtk.Label el; - private Xcls_PopoverProperty _this; + + public class Xcls_Label10 : Object + { + public Gtk.Label el; + private Xcls_PopoverProperty _this; - // my vars (def) - - // ctor - public Xcls_Label10(Xcls_PopoverProperty _owner ) - { - _this = _owner; - this.el = new Gtk.Label( "Type or Return Type" ); - - // my vars (dec) - - // set gobject values - this.el.halign = Gtk.Align.START; - this.el.justify = Gtk.Justification.LEFT; - this.el.margin_top = 12; - this.el.visible = true; - } + // my vars (def) + + // ctor + public Xcls_Label10(Xcls_PopoverProperty _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Type or Return Type" ); + + // my vars (dec) + + // set gobject values + this.el.halign = Gtk.Align.START; + this.el.justify = Gtk.Justification.LEFT; + this.el.margin_top = 12; + this.el.visible = true; + } - // user defined functions - } + // user defined functions + } - public class Xcls_ktype : Object - { - public Gtk.Entry el; - private Xcls_PopoverProperty _this; + public class Xcls_ktype : Object + { + public Gtk.Entry el; + private Xcls_PopoverProperty _this; - // my vars (def) - - // ctor - public Xcls_ktype(Xcls_PopoverProperty _owner ) - { - _this = _owner; - _this.ktype = this; - this.el = new Gtk.Entry(); - - // my vars (dec) - - // set gobject values - this.el.visible = true; - } - - // user defined functions - } - - public class Xcls_Label12 : Object - { - public Gtk.Label el; - private Xcls_PopoverProperty _this; + // my vars (def) + + // ctor + public Xcls_ktype(Xcls_PopoverProperty _owner ) + { + _this = _owner; + _this.ktype = this; + this.el = new Gtk.Entry(); + + // my vars (dec) + + // set gobject values + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_Label12 : Object + { + public Gtk.Label el; + private Xcls_PopoverProperty _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_Label12(Xcls_PopoverProperty _owner ) - { - _this = _owner; - this.el = new Gtk.Label( "Name" ); - - // my vars (dec) - - // set gobject values - this.el.halign = Gtk.Align.START; - this.el.justify = Gtk.Justification.LEFT; - this.el.tooltip_text = "center, north, south, east, west"; - this.el.margin_top = 12; - this.el.visible = true; - } - - // user defined functions - } - - public class Xcls_kname : Object - { - public Gtk.Entry el; - private Xcls_PopoverProperty _this; + // ctor + public Xcls_Label12(Xcls_PopoverProperty _owner ) + { + _this = _owner; + this.el = new Gtk.Label( "Name" ); + + // my vars (dec) + + // set gobject values + this.el.halign = Gtk.Align.START; + this.el.justify = Gtk.Justification.LEFT; + this.el.tooltip_text = "center, north, south, east, west"; + this.el.margin_top = 12; + this.el.visible = true; + } + + // user defined functions + } + + public class Xcls_kname : Object + { + public Gtk.Entry el; + private Xcls_PopoverProperty _this; - // my vars (def) + // my vars (def) - // ctor - public Xcls_kname(Xcls_PopoverProperty _owner ) - { - _this = _owner; - _this.kname = this; - this.el = new Gtk.Entry(); + // ctor + public Xcls_kname(Xcls_PopoverProperty _owner ) + { + _this = _owner; + _this.kname = this; + this.el = new Gtk.Entry(); - // my vars (dec) + // my vars (dec) - // set gobject values - this.el.visible = true; - var child_1 = new Xcls_EventControllerFocus14( _this ); - child_1.ref(); - this.el.add_controller( child_1.el ); - var child_2 = new Xcls_EventControllerKey15( _this ); - child_2.ref(); - this.el.add_controller( child_2.el ); - } + // set gobject values + this.el.visible = true; + var child_1 = new Xcls_EventControllerFocus14( _this ); + child_1.ref(); + this.el.add_controller( child_1.el ); + var child_2 = new Xcls_EventControllerKey15( _this ); + child_2.ref(); + this.el.add_controller( child_2.el ); + } - // user defined functions - } - public class Xcls_EventControllerFocus14 : Object - { - public Gtk.EventControllerFocus el; - private Xcls_PopoverProperty _this; - - - // my vars (def) - - // ctor - public Xcls_EventControllerFocus14(Xcls_PopoverProperty _owner ) - { - _this = _owner; - this.el = new Gtk.EventControllerFocus(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.leave.connect( ( ) => { - - _this.error.setError(""); - var val = _this.kname.el.get_text().strip(); - if (val.length < 1) { - _this.error.setError("Name can not be empty"); - } - - }); - } - - // user defined functions - } - - public class Xcls_EventControllerKey15 : Object - { - public Gtk.EventControllerKey el; - private Xcls_PopoverProperty _this; - - - // my vars (def) - - // ctor - public Xcls_EventControllerKey15(Xcls_PopoverProperty _owner ) - { - _this = _owner; - this.el = new Gtk.EventControllerKey(); - - // my vars (dec) - - // set gobject values - - //listeners - this.el.key_released.connect( (keyval, keycode, state) => { - - _this.error.setError(""); - var val = _this.kname.el.get_text().strip(); - if (val.length < 1) { - _this.error.setError("Name can not be empty"); - } - - }); - } - - // user defined functions - } - - - public class Xcls_error : Object - { - public Gtk.Label el; - private Xcls_PopoverProperty _this; - - - // my vars (def) - - // ctor - public Xcls_error(Xcls_PopoverProperty _owner ) - { - _this = _owner; - _this.error = this; - this.el = new Gtk.Label( "Error Message" ); - - // my vars (dec) - - // set gobject values - this.el.halign = Gtk.Align.START; - this.el.justify = Gtk.Justification.LEFT; - this.el.tooltip_text = "center, north, south, east, west"; - this.el.margin_top = 0; - this.el.visible = true; - this.el.use_markup = true; - } - - // user defined functions - public void setError (string err) { - if (err == "") { - this.el.label = ""; - } else { - - - this.el.label = "" + err + ""; - } - } - } - - 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.view.editProp(prop); - - - - }); - } - - // user defined functions - } - - - - } + // user defined functions + } + public class Xcls_EventControllerFocus14 : Object + { + public Gtk.EventControllerFocus el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_EventControllerFocus14(Xcls_PopoverProperty _owner ) + { + _this = _owner; + this.el = new Gtk.EventControllerFocus(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.leave.connect( ( ) => { + + _this.error.setError(""); + var val = _this.kname.el.get_text().strip(); + if (val.length < 1) { + _this.error.setError("Name can not be empty"); + } + + }); + } + + // user defined functions + } + + public class Xcls_EventControllerKey15 : Object + { + public Gtk.EventControllerKey el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_EventControllerKey15(Xcls_PopoverProperty _owner ) + { + _this = _owner; + this.el = new Gtk.EventControllerKey(); + + // my vars (dec) + + // set gobject values + + //listeners + this.el.key_released.connect( (keyval, keycode, state) => { + + _this.error.setError(""); + var val = _this.kname.el.get_text().strip(); + if (val.length < 1) { + _this.error.setError("Name can not be empty"); + } + + }); + } + + // user defined functions + } + + + public class Xcls_error : Object + { + public Gtk.Label el; + private Xcls_PopoverProperty _this; + + + // my vars (def) + + // ctor + public Xcls_error(Xcls_PopoverProperty _owner ) + { + _this = _owner; + _this.error = this; + this.el = new Gtk.Label( "Error Message" ); + + // my vars (dec) + + // set gobject values + this.el.halign = Gtk.Align.START; + this.el.justify = Gtk.Justification.LEFT; + this.el.tooltip_text = "center, north, south, east, west"; + this.el.margin_top = 0; + this.el.visible = true; + this.el.use_markup = true; + } + + // user defined functions + public void setError (string err) { + if (err == "") { + this.el.label = ""; + } else { + + + this.el.label = "" + err + ""; + } + } + } + + 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/JsRender/Gtk.vala b/src/JsRender/Gtk.vala index 57ce6446d..caee6c71b 100644 --- a/src/JsRender/Gtk.vala +++ b/src/JsRender/Gtk.vala @@ -153,8 +153,10 @@ namespace JsRender { public override string toSourceCode() // no seed support currently. { if (this.version == this.last_source_version) { + GLib.debug("toSource - using Cache"); return this.last_source; } + GLib.debug("toSource - generating"); this.last_source = NodeToVala.mungeFile(this); this.last_source_version = this.version; return this.last_source; diff --git a/src/JsRender/NodeProp.vala b/src/JsRender/NodeProp.vala index 1cf7d32b5..fed051f43 100644 --- a/src/JsRender/NodeProp.vala +++ b/src/JsRender/NodeProp.vala @@ -104,7 +104,8 @@ public class JsRender.NodeProp : Object { return; } this._name = value; - + + this.updated_count++; if (this.parent != null) { // causes props/ listeners array to get updated. this.parent.updated_count++; @@ -141,8 +142,7 @@ public class JsRender.NodeProp : Object { if (this.parent != null) { this.parent.updated_count++; } - this.to_display_name_prop = ""; - this.to_tooltip_name_prop = ""; + this.updated_count++; } } // return or type @@ -161,10 +161,7 @@ public class JsRender.NodeProp : Object { if (this.parent != null) { this.parent.updated_count++; } - this.val_short = ""; - this.val_tooltip = ""; this.updated_count++; - } } @@ -177,9 +174,12 @@ public class JsRender.NodeProp : Object { set { // set things that are used to display values. - this.to_display_name_prop = ""; - this.to_tooltip_name_prop = ""; - this. _updated_count = value; + this.to_display_name_prop = value.to_string(); + this.to_tooltip_name_prop = value.to_string(); + + this.val_short = value.to_string(); + this.val_tooltip = value.to_string(); + this._updated_count = value; } } // changes to this trigger updates on the tree.. diff --git a/src/Palete/LanguageClientVala.vala b/src/Palete/LanguageClientVala.vala index f35f74fdd..fc6d25b32 100644 --- a/src/Palete/LanguageClientVala.vala +++ b/src/Palete/LanguageClientVala.vala @@ -196,6 +196,13 @@ namespace Palete { this.in_close = false; } + public async void restartServer() + { + this.startServer(); + foreach(var f in this.open_files) { + this.document_open(f); + } + } public bool isReady() { @@ -204,10 +211,11 @@ namespace Palete { GLib.debug("server stopped = restarting"); this.initialized = false; this.closed = false; - this.startServer(); - foreach(var f in this.open_files) { - this.document_open(f); - } + GLib.MainLoop loop = new GLib.MainLoop (); + this.restartServer.begin ((obj, async_res) => { + this.restartServer.end(async_res); + loop.quit (); + }); return false; // can't do an operation yet? } @@ -221,7 +229,7 @@ namespace Palete { return false; } // restart server.. - + return true; @@ -306,17 +314,28 @@ namespace Palete { if (!this.isReady()) { return; } + // save only really flags the file on the server - to actually force a change update - we need to + // flag it as changed. + this.document_change_force(file, file.toSource()); + this.change_queue_file = null; GLib.debug ("LS send save"); try { + + var args = this.buildDict ( + textDocument : this.buildDict ( ///TextDocumentItem; + uri: new GLib.Variant.string (file.to_url()), + version : new GLib.Variant.uint64 ( (uint64) file.version) + ) + ); + + //GLib.debug ("textDocument/save send with %s", Json.to_string (Json.gvariant_serialize (args), true)); + + + this.jsonrpc_client.send_notification ( - "textDocument/didChange", - this.buildDict ( - textDocument : this.buildDict ( ///TextDocumentItem; - uri: new GLib.Variant.string (file.to_url()), - version : new GLib.Variant.uint64 ( (uint64) file.version) - ) - ), + "textDocument/didSave", + args, null ); this.log(LanguageClientAction.SAVE, file.path); -- 2.39.2