Fix #8025 - move css to resources
[roobuilder] / src / Builder4 / WindowLeftTree.vala
index e486653..0260e7b 100644 (file)
@@ -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 );
@@ -160,8 +160,9 @@ 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 +171,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 +185,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 +194,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 +271,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,14 +289,14 @@ 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  );
 
                        // init method
 
                        {
-                        
+                        /*
                          this.css = new Gtk.CssProvider();
                        //      try {
                                        this.css.load_from_string("
@@ -349,7 +350,7 @@ public class Xcls_WindowLeftTree : Object
                                        this.css,
                                        Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
                                );
-                               
+                               */
                                  
                        }
                }
@@ -437,165 +438,69 @@ public class Xcls_WindowLeftTree : Object
                    return -1;
                
                 }
-               public int getRowAt (double x,  double in_y, out string pos) {
-               
+               public int getRowAt (double x,  double  y, out string pos) {
                
+                       var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
+                       //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
+                       if (w == null) {
+                               return -1;
+                       }
+                       
+                       var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
+                       if (row == null) {
+                               return -1;
+                       }
+                       
+                       //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
                         
-               
-               /*
-                       
-               from            https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
-                       var colview = gesture.widget;
-                       var line_no = check_list_widget(colview, x,y);
-                        if (line_no > -1) {
-                               var item = colview.model.get_item(line_no);
-                                
-                       }
-                       */
-                                
-                               
-                               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 };
-                       var line_no = -1; 
-                       var reading_header = true;
-                       var real_y = 0;
-                       var header_height  = 0;
-                       pos = "none";
-                       var h = 0;
-                       while (child != null) {
-                                       //GLib.debug("Got %s", child.get_type().name());
-                           if (reading_header) {
-                                               
-               
-                                               if (child.get_type().name() != "GtkColumnListView") {
-                                               h += child.get_height();
-                                                       child = child.get_next_sibling();
-                                                       continue;
-                                               }
-                                               // should be columnlistview
-                                               child = child.get_first_child(); 
-                                           //GLib.debug("header height=%d", h);
-                                               header_height =  h;
-                                               
-                                               reading_header = false;
-                                               continue;
-                                               
-                               }
-                               
-                                   if (child.get_type().name() != "GtkColumnViewRowWidget") {
-                                   child = child.get_next_sibling();
-                                   continue;
-                                   }
-                                   
-                                       if (y < header_height) {
-                                       return -1;
-                               }
-                                   
-                                   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),
-                                       
-                                       //      child.visible ? "VIS" : "hidden");
-               
-                                   if (y >  (header_height + real_y) && y <= (header_height +  real_y + hh) ) {
-                                       if (y > ( header_height + real_y + (hh * 0.8))) {
-                                               pos = "below";
-                                       } else if (y > ( header_height + real_y + (hh * 0.2))) {
-                                               pos = "over";
-                                       } else {
-                                               pos = "above";
-                                               }
-                                        GLib.debug("getRowAt return : %d, %s", line_no, pos);
-                                           return line_no;
-                                   }
-                
-               
-                                   if (real_y + hh > y) {
-                                       return -1;
-                               }
-                               real_y += hh;
-                               child = child.get_next_sibling(); 
-                       }
-                       return -1;
-               
+                       var rn = 0;
+                       var cr = row;
+                        
+                       while (cr.get_prev_sibling() != null) {
+                               rn++;
+                               cr = cr.get_prev_sibling();
+                       }
+                       
+                       //GLib.debug("row number is %d", rn);
+                       //GLib.debug("click %d, %d", (int)x, (int)y);
+                       // above or belw
+                       Graphene.Rect  bounds;
+                       row.compute_bounds(this.el, out bounds);
+                       //GLib.debug("click x=%d, y=%d, w=%d, h=%d", 
+                       //      (int)bounds.get_x(), (int)bounds.get_y(),
+                       //      (int)bounds.get_width(), (int)bounds.get_height()
+                       //      );
+                       var ypos = y - bounds.get_y();
+                       //GLib.debug("rel ypos = %d", (int)ypos);       
+                       var rpos = 100.0 * (ypos / bounds.get_height());
+                       //GLib.debug("rel pos = %d %%", (int)rpos);
+                       pos = "over";
+                       
+                       if (rpos > 80) {
+                               pos = "below";
+                       } else if (rpos < 20) {
+                               pos = "above";
+                       } 
+                       return rn;
                 }
-               public Gtk.Widget? getWidgetAt (double x,  double in_y) {
-               /*
-                       
-               from            https://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465
-                       var colview = gesture.widget;
-                       var line_no = check_list_widget(colview, x,y);
-                        if (line_no > -1) {
-                               var item = colview.model.get_item(line_no);
-                                
-                       }
-                       */
-                       var y = in_y + _this.viewwin.el.vadjustment.value; 
-                       var  child = this.el.get_first_child(); 
-                       //Gtk.Allocation alloc = { 0, 0, 0, 0 };
-                       var line_no = -1; 
-                       var reading_header = true;
-                       var curr_y = 0;
-                       var header_height  = 0;
-                       var h = 0;
-                       while (child != null) {
-                                       //GLib.debug("Got %s", child.get_type().name());
-                               if (reading_header) {
-                                               
-               
-                                               if (child.get_type().name() != "GtkColumnListView") {
-                                               h += child.get_height();
-                                                       child = child.get_next_sibling();
-                                                       continue;
-                                               }
-                                               // should be columnlistview
-                                               child = child.get_first_child(); 
-                                           GLib.debug("header height=%d", h);
-                                               header_height =  h;
-                                               
-                                               reading_header = false;
-                                               continue;
-                               }
-                                   line_no++;
-               
-                                       if (y < header_height) {
-                                       return null;
-                               }
+               public Gtk.Widget? getWidgetAt (double x,  double  y) {
                
-                                       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;
-                                   }
-                                   curr_y +=  hh ;
-               
-                                   if (curr_y > y) {
-                                       return null;
-                               }
-                               child = child.get_next_sibling(); 
-                       }
-                       return null;
+                       var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
+                       //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
+                       if (w == null) {
+                               return null;
+                       }
+                       
+                       var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
+                       if (row == null) {
+                               return null;
+                       }
+                       return row;
+                
                
                 }
        }
-       public class Xcls_GestureClick6 : Object
+       public class Xcls_GestureClick5 : Object
        {
                public Gtk.GestureClick el;
                private Xcls_WindowLeftTree  _this;
@@ -604,7 +509,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 +586,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 +595,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 +657,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 +666,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 +747,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 +756,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 +1626,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 +1640,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 +1649,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();
@@ -1826,8 +1731,8 @@ public class Xcls_WindowLeftTree : Object
                            expand.set_hide_expander( !node.hasChildren() );
                                expand.set_list_row(lr);
                                
-                               node.bind_property("iconFilename",
-                                           img, "file",
+                               node.bind_property("iconResourceName",
+                                           img, "resource",
                                           GLib.BindingFlags.SYNC_CREATE);
                                
                                node.bind_property("nodeTitleProp",
@@ -1845,7 +1750,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 +1759,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 +1774,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 +1783,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 +1846,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 +1861,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 +1869,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 +1891,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 +1899,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 +1913,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 +1922,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 +1930,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 +1949,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 +1958,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 +1966,7 @@ public class Xcls_WindowLeftTree : Object
                        // my vars (dec)
 
                        // set gobject values
+                       this.el.has_frame = false;
                        this.el.label = "Save as Module";
 
                        //listeners