src/Builder4/Editor.bjs
authorAlan Knowles <alan@roojs.com>
Tue, 19 Mar 2024 14:17:03 +0000 (22:17 +0800)
committerAlan Knowles <alan@roojs.com>
Tue, 19 Mar 2024 14:17:03 +0000 (22:17 +0800)
src/Builder4/Editor.vala

src/Builder4/Editor.bjs
src/Builder4/Editor.vala

index f4dae7e..82c2079 100644 (file)
          "string name" : "editor-navigation",
          "xtype" : "ColumnView",
          "| Gtk.Widget? getWidgetAtRow" : [
-          "() {",
+          "(uint row) {",
+          "/*",
+          "    \t",
+          "from    \thttps://discourse.gnome.org/t/gtk4-finding-a-row-data-on-gtkcolumnview/8465",
+          "    \tvar colview = gesture.widget;",
+          "    \tvar line_no = check_list_widget(colview, x,y);",
+          "         if (line_no > -1) {",
+          "    \t\tvar item = colview.model.get_item(line_no);",
+          "    \t\t ",
+          "    \t}",
+          "    \t*/",
+          "\t\t//GLib.debug(\"Get Widget At Row %d\", (int)row);",
+          "        var  child = this.el.get_first_child(); ",
+          "    \tvar line_no = -1; ",
+          "    \tvar reading_header = true;",
+          "\t ",
+          "    \twhile (child != null) {",
+          "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
+          "    \t   ",
+          "    \t   if (reading_header) {",
+          "\t\t\t\t",
           "",
-          "}"
+          "\t\t\t\tif (child.get_type().name() != \"GtkColumnListView\") {",
+          "\t\t\t\t   ",
+          "\t\t\t\t\tchild = child.get_next_sibling();",
+          "\t\t\t\t\tcontinue;",
+          "\t\t\t\t}",
+          "\t\t\t\t// should be columnlistview",
+          "\t\t\t\tchild = child.get_first_child(); ",
+          "\t\t\t ",
+          "\t\t\t ",
+          "\t\t\t\t",
+          "\t\t\t\treading_header = false;",
+          "\t\t\t\tcontinue;",
+          "\t\t    }",
+          "\t\t    ",
+          "\t\t  ",
+          "    \t    ",
+          "\t\t    line_no++;",
+          "\t\t\tif (line_no == row) {",
+          "\t\t\t\t//GLib.debug(\"Returning widget %s\", child.get_type().name());",
+          "\t\t\t    return (Gtk.Widget)child;",
+          "\t\t    }",
+          "\t        child = child.get_next_sibling(); ",
+          "    \t}",
+          "\t\t//GLib.debug(\"Rturning null\");",
+          "        return null;",
+          "",
+          " }"
          ],
          "| int getRowAt" : [
           "(double x,  double  y, out string pos) {",
index 021f749..b837a22 100644 (file)
@@ -1782,9 +1782,55 @@ public class Editor : Object
                }
 
                // user defined functions
-               public Gtk.Widget? getWidgetAtRow () {
+               public Gtk.Widget? getWidgetAtRow (uint row) {
+               /*
+                       
+               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 %d", (int)row);
+                       var  child = this.el.get_first_child(); 
+                       var line_no = -1; 
+                       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;
+                                   }
+                                   
+                                 
+                           
+                                   line_no++;
+                                       if (line_no == row) {
+                                               //GLib.debug("Returning widget %s", child.get_type().name());
+                                           return (Gtk.Widget)child;
+                                   }
+                               child = child.get_next_sibling(); 
+                       }
+                               //GLib.debug("Rturning null");
+                       return null;
+               
+                }
                public void show (Gee.ArrayList<Lsp.DocumentSymbol> syms) {
                        _this.navigationwindow.el.show();
                        _this.navliststore.el.remove_all();