}
public Xcls_viewwin viewwin;
public Xcls_view view;
+ public Xcls_keystate keystate;
public Xcls_drop drop;
public Xcls_selmodel selmodel;
public Xcls_model model;
// my vars (def)
public signal bool before_node_change ();
- public Xcls_MainWindow main_window;
+ public Xcls_MainWindow? main_window;
+ public int last_error_counter;
public signal void changed ();
public signal void node_selected (JsRender.Node? node);
// my vars (dec)
this.main_window = null;
+ this.last_error_counter = -1;
// set gobject values
this.el.hexpand = true;
}
// user defined functions
+ public void updateErrors () {
+ var file = this.getActiveFile();
+ if (file == null) {
+ return;
+ }
+
+ var ar = file.getErrors();
+ if (ar == null || ar.size < 1) {
+ if (this.last_error_counter != file.error_counter) {
+ this.removeErrors();
+ }
+
+ this.last_error_counter = file.error_counter ;
+
+ return;
+ }
+ if (this.last_error_counter == file.error_counter) {
+ return;
+ }
+ this.removeErrors();
+
+ foreach(var diag in ar) {
+
+
+ // print("get inter\n");
+ var node= file.lineToNode( (int)diag.range.start.line) ;
+ if (node == null) {
+ continue;
+ }
+ var row = _this.model.nodeToRow(node);
+ if (row < 0) {
+ continue;
+ }
+ var w = this.view.getWidgetAtRow(row);
+ if (w == null) {
+ return;
+ }
+ // always show errors.
+ var ed = diag.category.down();
+ if (ed != "err" && w.has_css_class("node-err")) {
+ continue;
+ }
+ if (ed == "err" && w.has_css_class("node-warn")) {
+ w.remove_css_class("node-warn");
+ }
+ if (ed == "err" && w.has_css_class("node-depr")) {
+ w.remove_css_class("node-depr");
+ }
+ if (!w.has_css_class("node-"+ ed)) {
+ w.add_css_class("node-" + ed);
+ }
+
+ }
+
+ }
public void onresize () {
//GLib.debug("Got allocation width of scrolled view %d", allocation.width );
// _this.maincol.el.set_max_width( _this.viewwin.el.get_width() - 32 );
+ }
+ public void removeErrors () {
+ var child = this.view.el.get_first_child();
+
+ var reading_header = true;
+
+ while (child != null) {
+ //GLib.debug("Got %s", child.get_type().name());
+
+ if (reading_header) {
+
+
+ if (child.get_type().name() != "GtkColumnListView") {
+
+ child = child.get_next_sibling();
+ continue;
+ }
+ // should be columnlistview
+ child = child.get_first_child();
+
+
+
+ reading_header = false;
+ continue;
+ }
+
+ if (child.has_css_class("node-err")) {
+ child.remove_css_class("node-err");
+ }
+ if (child.has_css_class("node-warn")) {
+ child.remove_css_class("node-warn");
+ }
+
+ if (child.has_css_class("node-depr")) {
+ child.remove_css_class("node-depr");
+ }
+
+ child = child.get_next_sibling();
+ }
+ //GLib.debug("Rturning null");
+
}
public JsRender.Node? getActiveElement () { // return path to actie node.
// my vars (dec)
// set gobject values
+ this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
this.el.has_frame = true;
this.el.hexpand = true;
this.el.vexpand = true;
+ this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
new Xcls_view( _this );
this.el.child = _this.view.el;
new Xcls_LeftTreeMenu( _this );
-
- // init method
-
- this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
}
// user defined functions
public string lastEventSource;
public bool button_is_pressed;
public Gtk.CssProvider css;
+ public JsRender.Node? dragNode;
// ctor
public Xcls_view(Xcls_WindowLeftTree _owner )
this.headers_visible = false;
this.lastEventSource = "";
this.button_is_pressed = false;
+ this.dragNode = null;
// set gobject values
this.el.name = "left-tree-view";
var child_5 = new Xcls_EventControllerKey9( _this );
child_5.ref();
this.el.add_controller( child_5.el );
+ new Xcls_keystate( _this );
+ this.el.add_controller( _this.keystate.el );
new Xcls_drop( _this );
this.el.add_controller( _this.drop.el );
new Xcls_maincol( _this );
this.el.append_column ( _this.maincol.el );
- var child_8 = new Xcls_ColumnViewColumn15( _this );
- child_8.ref();
- this.el.append_column ( child_8.el );
+ var child_9 = new Xcls_ColumnViewColumn16( _this );
+ child_9.ref();
+ this.el.append_column ( child_9.el );
// init method
border-top-style: solid;
border-top-color: #88a3bc;
}
+ .node-err {
+ border-top-width: 5px;
+ border-top-style: solid;
+ border-top-color: red;
+ border-bottom-width: 5px;
+ border-bottom-style: solid;
+ border-bottom-color: red;
+ }
+ .node-warn {
+ border-top-width: 5px;
+ border-top-style: solid;
+ border-top-color: #ABF4EB;
+ border-bottom-width: 5px;
+ border-bottom-style: solid;
+ border-bottom-color: #ABF4EB;
+ }
+ .node-depr {
+ border-top-width: 5px;
+ border-top-style: solid;
+ border-top-color: #EEA9FF;
+ border-bottom-width: 5px;
+ border-bottom-style: solid;
+ border-bottom-color: #EEA9FF;
+ }
+
#left-tree-view indent {
-gtk-icon-size : 2px;
}
var reading_header = true;
while (child != null) {
- GLib.debug("Got %s", child.get_type().name());
+ //GLib.debug("Got %s", child.get_type().name());
if (reading_header) {
reading_header = false;
-
+ continue;
}
}
public int getColAt (double x, double y) {
- /*
-
- from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
-
- */
- //Gtk.Allocation alloc = { 0, 0, 0, 0 };
- //GLib.debug("Cehck %d, %d", x,y);
- var child = this.el.get_first_child();
-
- var col = 0;
- var offx = 0;
- while (child != null) {
+ /*
- if (child.get_type().name() == "GtkColumnViewRowWidget") {
- child = child.get_first_child();
- continue;
- }
-
- //child.get_allocation(out alloc);
- if (x < (child.get_width() + offx)) {
- return col;
- }
- return 1;
- //offx += child.get_width();
- //col++;
- //child = child.get_next_sibling();
+ from https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
+
+ */
+ //Gtk.Allocation alloc = { 0, 0, 0, 0 };
+ //GLib.debug("Cehck %d, %d", x,y);
+ var child = this.el.get_first_child();
+
+ var col = 0;
+ var offx = 0;
+ while (child != null) {
+
+ if (child.get_type().name() == "GtkColumnViewRowWidget") {
+ child = child.get_first_child();
+ continue;
}
-
-
- return -1;
+
+ //child.get_allocation(out alloc);
+ if (x < (child.get_width() + offx)) {
+ return col;
+ }
+ return 1;
+ //offx += child.get_width();
+ //col++;
+ //child = child.get_next_sibling();
+ }
+
+
+ return -1;
}
public int getRowAt (double x, double in_y, out string pos) {
*/
- //GLib.debug("offset = %d y = %d", (int) voff, (int) in_y);
+ GLib.debug("get Widget At Row x = %d y = %d", (int) x, (int) in_y);
var y = in_y + _this.viewwin.el.vadjustment.value;
var child = this.el.get_first_child();
//Gtk.Allocation alloc = { 0, 0, 0, 0 };
}
// should be columnlistview
child = child.get_first_child();
- GLib.debug("header height=%d", h);
+ //GLib.debug("header height=%d", h);
header_height = h;
reading_header = false;
+ continue;
}
line_no++;
var hh = child.get_height();
+
+ if (child.has_css_class("node-err") ||
+ child.has_css_class("node-warn") ||
+ child.has_css_class("node-depr")) {
+ hh += 10;
+
+ }
//child.get_allocation(out alloc);
//GLib.debug("got cell xy = %d,%d w,h= %d,%d", alloc.x, alloc.y, alloc.width, alloc.height);
//GLib.debug("row %d y= %d %s", line_no, (int) (header_height + alloc.y),
header_height = h;
reading_header = false;
-
+ continue;
}
line_no++;
var hh = child.get_height();
//GLib.debug("got cell xy = %d,%d w,h= %d,%d", alloc.x, alloc.y, alloc.width, alloc.height);
-
+ if (child.has_css_class("node-err") ||
+ child.has_css_class("node-warn") ||
+ child.has_css_class("node-depr")) {
+ hh += 10;
+
+ }
if (y > curr_y && y <= header_height + hh + curr_y ) {
return (Gtk.Widget)child;
}
GLib.warning("No node found at row %d", row);
return;
}
+
+
_this.model.selectNode(node);
this.el.actions = Gdk.DragAction.COPY | Gdk.DragAction.MOVE ;
//listeners
+ this.el.drag_cancel.connect( (drag, reason) => {
+
+ _this.view.dragNode = null;
+ return true;
+ });
this.el.prepare.connect( (x, y) => {
GLib.debug("SOURCE: drag-begin");
// find what is selected in our tree...
- var data = _this.selmodel.getSelectedNode();
+ var data = _this.selmodel.getSelectedNode();
if (data == null) {
return ;
}
-
+ _this.view.dragNode = data;
var xname = data.fqn();
GLib.debug ("XNAME IS %s", xname);
this.el.set_icon(paintable, 0,0);
+ });
+ this.el.drag_end.connect( (drag, delete_data) => {
+
+ _this.view.dragNode = null;
});
}
// user defined functions
}
+ public class Xcls_keystate : Object
+ {
+ public Gtk.EventControllerKey el;
+ private Xcls_WindowLeftTree _this;
+
+
+ // my vars (def)
+ public int is_shift;
+
+ // ctor
+ public Xcls_keystate(Xcls_WindowLeftTree _owner )
+ {
+ _this = _owner;
+ _this.keystate = this;
+ this.el = new Gtk.EventControllerKey();
+
+ // my vars (dec)
+ this.is_shift = 0;
+
+ // set gobject values
+
+ //listeners
+ this.el.key_released.connect( (keyval, keycode, state) => {
+ GLib.debug("key release %d, %d, %d" , (int) keyval, (int) keycode, state);
+ if (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {
+ this.is_shift = 0;
+ }
+ //GLib.debug("set state %d , shift = %d", (int)this.el.get_current_event_state(), Gdk.ModifierType.SHIFT_MASK);
+
+
+
+ });
+ this.el.key_pressed.connect( (keyval, keycode, state) => {
+
+ if (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {
+ this.is_shift = 1;
+ }
+ return true;
+ });
+ }
+
+ // user defined functions
+ }
+
public class Xcls_drop : Object
{
public Gtk.DropTarget el;
});
this.el.motion.connect( ( x, y) => {
+ var is_shift = _this.keystate.is_shift > 0;
+
+ GLib.debug("shift is %s", _this.keystate.is_shift > 0 ? "SHIFT" : "-");
string pos; // over / before / after..
- GLib.debug("got drag motion");
+ //GLib.debug("got drag motion");
GLib.Value v = GLib.Value(typeof(string));
//var str = drop.read_text( [ "text/plain" ] 0);
return Gdk.DragAction.COPY;
}
-
- GLib.debug("got %s", v.get_string());
+
+ //GLib.debug("got %s", v.get_string());
if (this.lastDragString != v.get_string() || this.lastDragNode == null) {
// still dragging same node
pos = "over";
} else {
GLib.debug("drop contains %s - using %s" , node.parent.fqn(), pos);
+ if (_this.view.dragNode != null && is_shift) {
+ if (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {
+ GLib.debug("shift drop not self not allowed");
+ this.addHighlight(null, "");
+ return Gdk.DragAction.COPY;
+ }
+
+ }
+
}
+
+
+
}
+
}
if (pos == "over") {
if (!drop_on_to.contains(node.fqn())) {
GLib.debug("drop on does not contain %s - try center" , node.fqn());
this.addHighlight(null, "");
- return Gdk.DragAction.COPY;
+ return is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;
}
+ if (_this.view.dragNode != null && is_shift) {
+ if (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {
+ GLib.debug("shift drop not self not allowed");
+ this.addHighlight(null, "");
+ return Gdk.DragAction.COPY;
+ }
+ }
+
}
// _this.view.highlightDropPath("", (Gtk.TreeViewDropPosition)0);
var w = _this.view.getWidgetAt(x,y);
this.addHighlight(w, pos);
- return Gdk.DragAction.COPY;
+ return is_shift ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY;
});
this.el.leave.connect( ( ) => {
this.addHighlight(null,"");
this.addHighlight(null,"");
-
+ var is_shift = _this.keystate.is_shift > 0;
var pos = "";
// -- get position..
var m = (GLib.ListStore) _this.model.el.model;
_this.main_window.windowstate.file.tree = dropNode;
-
+ dropNode.updated_count++;
m.append(dropNode);
_this.model.selectNode(dropNode);
pos = "over";
} else {
GLib.debug("drop contains %s - using %s" , node.parent.fqn(), pos);
+ if (_this.view.dragNode != null && is_shift) {
+ if (node.parent.oid == _this.view.dragNode.oid || node.parent.has_parent(_this.view.dragNode)) {
+ GLib.debug("shift drop not self not allowed");
+ return false;
+ }
+
+ }
+
+
}
}
return false;
}
+ if (node.oid == _this.view.dragNode.oid || node.has_parent(_this.view.dragNode)) {
+ GLib.debug("shift drop not self not allowed");
+ return false;
+ }
}
switch(pos) {
case "over":
node.appendChild(dropNode);
+ if (is_shift && _this.view.dragNode != null) {
+ _this.model.selectNode(null);
+ _this.view.dragNode.remove();
+ }
+
+ dropNode.updated_count++;
_this.model.selectNode(dropNode);
+
_this.changed();
return true;
case "above":
GLib.debug("Above - insertBefore");
- node.parent.insertBefore(dropNode, node);
+ node.parent.insertBefore(dropNode, node);
+ if (is_shift && _this.view.dragNode != null) {
+ _this.model.selectNode(null);
+ _this.view.dragNode.remove();
+ }
+ dropNode.updated_count++;
_this.model.selectNode(dropNode);
_this.changed();
return true;
case "below":
GLib.debug("Below - insertAfter");
+ if (is_shift && _this.view.dragNode != null) {
+ _this.model.selectNode(null);
+ _this.view.dragNode.remove();
+ }
+
+
node.parent.insertAfter(dropNode, node);
+ dropNode.updated_count++;
_this.model.selectNode(dropNode);
_this.changed();
// select it
_this.main_window.windowstate.leftTreeNodeSelected(null);
// needed???
_this.main_window.windowstate.file = f;
-
+ _this.last_error_counter = -1;
if (f.tree == null) {
try {
// if it's still null?
if (f.tree == null) {
_this.main_window.windowstate.showAddObject(_this.view.el, null);
-
+ _this.updateErrors();
return;
}
m.append(f.tree);
- // expand???
-
- /*
- if (f.tree.readItems().size < 1) {
- // single item..
-
- //this.get('/Window.leftvpaned').el.set_position(80);
- // select first...
- _this.view.el.set_cursor(
- new Gtk.TreePath.from_string("0"), null, false);
-
-
- } else {
- //this.get('/Window.leftvpaned').el.set_position(200);
- }
- */
-
-
-
- //_this.maincol.el.set_max_width(_this.viewwin.el.get_allocated_width() - 32);
+ _this.updateErrors();
_this.selmodel.el.set_selected(Gtk.INVALID_LIST_POSITION);
return;
+ }
+ public int nodeToRow (JsRender.Node node)
+ {
+ var row = -1;
+ var s = _this.view.el.model as Gtk.SingleSelection;
+ for (var i = 0; i < s.n_items; i++) {
+ //GLib.debug("check node %s", s.get_item(i).get_type().name());
+ var lr = s.get_item(i) as Gtk.TreeListRow;
+ //GLib.debug("check node %s", lr.get_item().get_type().name());
+ if ((lr.get_item() as JsRender.Node).oid == node.oid) {
+ return i;
+
+ }
+ }
+ return -1;
+
+
}
public void deleteSelected () {
}
public void selectNode (JsRender.Node node)
{
- var row = -1;
- var s = (Gtk.SingleSelection)_this.view.el.model;
- for (var i = 0; i < s.n_items; i++) {
- //GLib.debug("check node %s", s.get_item(i).get_type().name());
- var lr = (Gtk.TreeListRow)s.get_item(i);
- GLib.debug("check node %s", lr.get_item().get_type().name());
- if (((JsRender.Node)lr.get_item()).oid == node.oid) {
- row = i;
- break;
- }
- }
+ var row = this.nodeToRow(node);
+ var s = _this.view.el.model as Gtk.SingleSelection;
+
if (row < 0) {
// select none?
GLib.debug("Could not find node");
{
_this = _owner;
_this.maincol = this;
- var child_1 = new Xcls_SignalListItemFactory14( _this );
+ var child_1 = new Xcls_SignalListItemFactory15( _this );
child_1.ref();
this.el = new Gtk.ColumnViewColumn( "Property", child_1.el );
// user defined functions
}
- public class Xcls_SignalListItemFactory14 : Object
+ public class Xcls_SignalListItemFactory15 : Object
{
public Gtk.SignalListItemFactory el;
private Xcls_WindowLeftTree _this;
// my vars (def)
// ctor
- public Xcls_SignalListItemFactory14(Xcls_WindowLeftTree _owner )
+ public Xcls_SignalListItemFactory15(Xcls_WindowLeftTree _owner )
{
_this = _owner;
this.el = new Gtk.SignalListItemFactory();
}
- public class Xcls_ColumnViewColumn15 : Object
+ public class Xcls_ColumnViewColumn16 : Object
{
public Gtk.ColumnViewColumn el;
private Xcls_WindowLeftTree _this;
// my vars (def)
// ctor
- public Xcls_ColumnViewColumn15(Xcls_WindowLeftTree _owner )
+ public Xcls_ColumnViewColumn16(Xcls_WindowLeftTree _owner )
{
_this = _owner;
- var child_1 = new Xcls_SignalListItemFactory16( _this );
+ var child_1 = new Xcls_SignalListItemFactory17( _this );
child_1.ref();
this.el = new Gtk.ColumnViewColumn( "Add", child_1.el );
// user defined functions
}
- public class Xcls_SignalListItemFactory16 : Object
+ public class Xcls_SignalListItemFactory17 : Object
{
public Gtk.SignalListItemFactory el;
private Xcls_WindowLeftTree _this;
// my vars (def)
// ctor
- public Xcls_SignalListItemFactory16(Xcls_WindowLeftTree _owner )
+ public Xcls_SignalListItemFactory17(Xcls_WindowLeftTree _owner )
{
_this = _owner;
this.el = new Gtk.SignalListItemFactory();
// my vars (dec)
// set gobject values
- var child_1 = new Xcls_Box18( _this );
+ var child_1 = new Xcls_Box19( _this );
this.el.child = child_1.el;
}
// user defined functions
}
- public class Xcls_Box18 : Object
+ public class Xcls_Box19 : Object
{
public Gtk.Box el;
private Xcls_WindowLeftTree _this;
// my vars (def)
// ctor
- public Xcls_Box18(Xcls_WindowLeftTree _owner )
+ public Xcls_Box19(Xcls_WindowLeftTree _owner )
{
_this = _owner;
this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
// my vars (dec)
// set gobject values
- var child_1 = new Xcls_Button19( _this );
+ var child_1 = new Xcls_Button20( _this );
child_1.ref();
this.el.append( child_1.el );
- var child_2 = new Xcls_Button20( _this );
+ var child_2 = new Xcls_Button21( _this );
child_2.ref();
this.el.append( child_2.el );
- var child_3 = new Xcls_Button21( _this );
+ var child_3 = new Xcls_Button22( _this );
child_3.ref();
this.el.append( child_3.el );
}
// user defined functions
}
- public class Xcls_Button19 : Object
+ public class Xcls_Button20 : Object
{
public Gtk.Button el;
private Xcls_WindowLeftTree _this;
// my vars (def)
// ctor
- public Xcls_Button19(Xcls_WindowLeftTree _owner )
+ public Xcls_Button20(Xcls_WindowLeftTree _owner )
{
_this = _owner;
this.el = new Gtk.Button();
// user defined functions
}
- public class Xcls_Button20 : Object
+ public class Xcls_Button21 : Object
{
public Gtk.Button el;
private Xcls_WindowLeftTree _this;
// my vars (def)
// ctor
- public Xcls_Button20(Xcls_WindowLeftTree _owner )
+ public Xcls_Button21(Xcls_WindowLeftTree _owner )
{
_this = _owner;
this.el = new Gtk.Button();
// user defined functions
}
- public class Xcls_Button21 : Object
+ public class Xcls_Button22 : Object
{
public Gtk.Button el;
private Xcls_WindowLeftTree _this;
// my vars (def)
// ctor
- public Xcls_Button21(Xcls_WindowLeftTree _owner )
+ public Xcls_Button22(Xcls_WindowLeftTree _owner )
{
_this = _owner;
this.el = new Gtk.Button();