fix merge
authorAlan <alan@roojs.com>
Tue, 2 Jan 2024 10:56:15 +0000 (18:56 +0800)
committerAlan <alan@roojs.com>
Tue, 2 Jan 2024 10:56:15 +0000 (18:56 +0800)
src/JsRender/JsonGen.vala
src/JsRender/NodeToVala.vala
src/JsRender/Roo.vala
src/Palete/Gir.vala
src/Palete/Gtk.vala
src/Palete/VapiParser.vala
src/codegen/valaccodeassignmentmodule.vala

index e117c69..07023f1 100644 (file)
@@ -78,14 +78,8 @@ namespace JsRender {
                                case Json.NodeType.VALUE:
                                  size_t sl;
                                  this.generator.set_root(node);
-<<<<<<< HEAD
-                                  var str = this.generator.to_data(out sl);
-                  buffer.append( str );
-=======
                                  var str = this.generator.to_data(out sl);
                                  buffer.append( str );
->>>>>>> wip_alan_T7440_handling_gtk4_and_bad_girs
                                  break;
 
                                case Json.NodeType.ARRAY:
index 0b41826..f92c490 100644 (file)
@@ -838,12 +838,8 @@ public class JsRender.NodeToVala : Object {
                                        // used for label[]  on Notebook
                                        // used for button[]  on Dialog?
                                        // columns[] ?
-<<<<<<< HEAD
-                                       this.packChild(child, i, 0, 0, child.get_prop("* prop").val);  /// fixme - this is a bit speciall...
-=======
                                         
                                        this.packChild(child, childname, 0, 0, child.get_prop("* prop").val);  /// fixme - this is a bit speciall...
->>>>>>> wip_alan_T7440_handling_gtk4_and_bad_girs
                                        continue;
                                }
                                
@@ -941,11 +937,6 @@ public class JsRender.NodeToVala : Object {
                        return;  
                }
                var childcls =  this.file.project.palete.getClass(child.fqn()); // very trusting..
-<<<<<<< HEAD
-               var is_event = childcls.inherits.contains("Gtk.EventController") || childcls.implements.contains("Gtk.EventController");
-               if (is_event) {
-                   this.addLine(this.ipad + "this.el.add_controller(  child_%d.el );".printf(i) );
-=======
                if (childcls == null) {
                  return;
                }
@@ -953,7 +944,6 @@ public class JsRender.NodeToVala : Object {
                var is_event = childcls.inherits.contains("Gtk.EventController") || childcls.implements.contains("Gtk.EventController");
                if (is_event) {
                    this.addLine(this.ipad + "this.el.add_controller(  %s.el );".printf(childname) );
->>>>>>> wip_alan_T7440_handling_gtk4_and_bad_girs
                    return;
                }
                
@@ -1068,11 +1058,7 @@ public class JsRender.NodeToVala : Object {
                        
                        default:
                            // gtk4 uses append!!!! - gtk3 - uses add..
-<<<<<<< HEAD
-                               this.addLine(this.ipad + "this.el.append(  child_" + "%d".printf(i) + ".el );");
-=======
                                this.addLine(this.ipad + "this.el.append( "+ childname + ".el );");
->>>>>>> wip_alan_T7440_handling_gtk4_and_bad_girs
                                return;
                
                
index ab02ee8..e62bbee 100644 (file)
@@ -66,9 +66,7 @@ namespace JsRender {
                 "emptyTitle",
                 "dialogTitle",
                 "modalTitle",
-                "boxLabel",
-                "blankText",
-                "tooltip"
+                "boxLabel"
                 
                 };
             for (var i=0;i<dsp.length;i++) {
index 63406e3..05c731e 100644 (file)
@@ -166,7 +166,7 @@ namespace Palete {
                                
                        }
                        
-                       var ret = cache.get(ns.strip());
+                       var ret = cache.get(ns);
                        
                         
                        
index 291a78f..9d17b09 100644 (file)
@@ -74,251 +74,7 @@ namespace Palete {
 
                public override void  load () 
                {
-<<<<<<< HEAD
-                       
-                       Gir.factory(this.project, "Gtk"); // triggers a load...
-                       var pr = (Project.Gtk) this.project;
-                       
-                       
-                       this.map = new Gee.ArrayList<Usage>();
-                       this.generic_child_widgets = new Gee.ArrayList<string>();
-                       this.generic_widget_children = new Gee.ArrayList<string>();
-                       this.all_no_parent =  new Gee.ArrayList<string>();
-                       var top =   new Gee.ArrayList<string>();
-                       top.add("*top");
-                       foreach(var key in   pr.gir_cache.keys) {
-                               var gir = pr.gir_cache.get(key);
-                               
-                               this.build_generic_children(gir.classes);
-                       }
-                       // add containers.   
-                       this.map.add(new Usage( top,  this.all_no_parent));
-                       var alltop =   new Gee.ArrayList<string>();
-                       alltop.add("*top");
-                       
-                       
-                       foreach(var k in this.generic_containers) {
-                               alltop.add(k);
-                               this.add_special_children(k, "Gtk.Menu", "_menu");
-                       }
-                       var u = new Usage( alltop,  this.generic_child_widgets);
-                       this.map.add(u);
-                       
-                       u = new Usage( this.generic_child_widgets,  this.generic_widget_children);
-                       this.map.add(u);
-                                
-                       foreach(var key in   pr.gir_cache.keys) {
-                               var gir = pr.gir_cache.get(key);
-                               this.build_class_children_from_props(gir.classes);
-                       }
-                       // oddities.
-
-                       this.add_special_children("Gtk.Menu","Gtk.MenuItem", "");
-                       this.add_special_children("Gtk.MenuBar", "Gtk.MenuItem", "");
-                       this.add_special_children("Gtk.Toolbar", "Gtk.ToolItem", "");
-                       this.add_special_children("Gtk.MenuItem","Gtk.Box", "");
-                       this.add_special_children("Gtk.Notebook", "Gtk.Label", "label[]"); //??
-                       this.add_special_children("Gtk.Window","Gtk.HeaderBar", "titlebar");
-               
-                       this.add_special_children("Gtk.Stack","Gtk.Label", "titles[]");
-                       this.add_special_children("Gtk.TreeView","Gtk.TreeViewColumn", ""); // any viewcolum added..
-                       this.add_special_children("Gtk.TreeViewColumn","Gtk.CellRenderer", "");
-                       
-                       this.add_special_children("Gtk.Dialog","Gtk.Button", "buttons[]");
-                       //this.add_special_children("Gtk.Dialog","Gtk.Button", "response_id");
-                       this.add_special_children("Gtk.RadioButton","Gtk.Button", "_group_name"); // fake property
-                       
-                       this.add_special_children("Gtk.ButtonBox","Gtk.Button", "");
-                       
-                       
-                       this.init_node_defaults();
-                   this.init_child_defaults();  
-                   
-                       foreach(var m in this.map) {
-                               GLib.debug("Usage: %s", m.to_string());
-                       }
-                       
-               }
-               
-               
-               
-               
-               // containers that can contain only certial types of children, and should be ignored from the general bulk add.
-               Gee.ArrayList<string> generic_child_widgets;
-               Gee.ArrayList<string> generic_widget_children; // mostly events...
-               Gee.ArrayList<string> all_no_parent;            
-/*
-               string[] special_containers = {
-                       "Gtk.Menu",
-                       "Gtk.MenuBar",
-                       "Gtk.Toolbar", // only toolbarItems.
-                       
-                       "Gtk.Assistant", // needs fake child? including fake page type
-                       "Gtk.Notebook", // needs fake child?
-                       
-               };
-               // children (or anythign that extends this) - that can not be added to a standard widget
-               string[] special_containers_children = {
-                       "Gtk.MenuItem",
-                       "Gtk.ToolbarItem"
-               };
-       */      
-               // widgets that can not be added to anything? - including their children.
-               string[] no_parent = { // except *top
-                       "Gtk.Window",
-                       "Gtk.Dialog",
-               };
-               
-               string[] generic_containers = {
-                       "Gtk.Assistant", 
-                       "Gtk.ActionBar",
-                       "Gtk.AspectFrame",
-                       "Gtk.Frame",
-                       "Gtk.Fixed",
-                       "Gtk.Box",
-                       "Gtk.Dialog",
-                       "Gtk.Expander", // add method is different..
-                       "Gtk.FlowBox",
-                       "Gtk.HeaderBar",
-                       "Gtk.InfoBar",
-                       "Gtk.ListBox",
-                       "Gtk.Overlay",
-                       "Gtk.Paned",
-                       "Gtk.Popover",
-                       "Gtk.PopoverMenu",
-                       "Gtk.Revealer",
-                       "Gtk.ScrolledWindow",
-                       "Gtk.Stack",  // add with name?
-                       "Gtk.ToolItem",
-                       "Gtk.ToolPalette",
-                       "Gtk.Viewport",
-                       "Gtk.Window",
-                       "Gtk.Notebook",
-                       "Gtk.ApplicationWindow",
-                       "Gtk.Grid",
-                       "Gtk.SearchBar",
-                       
-               };
-               
-               string[] widgets_blacklist = {
-                       "Gtk.Arrow", //Depricated
-                       
-                       "Gtk.ShortcutLabel",
-                       "Gtk.ShortcutsGroup",
-                       "Gtk.ShortcutsSection",
-                       "Gtk.ShortcutsShortcut",
-                       "Gtk.ShortcutsWindow",
-                       "Gtk.Socket",
-                       "Gtk.ToolItemGroup",
-                       
-                       //"Gtk.ButtonBox", << why ? 
-                       "Gtk.CellView",
-                       "Gtk.EventBox",
-                       "Gtk.FlowBoxChild",
-                       "Gtk.Invisible",
-                       "Gtk.ListBoxRow",
-                       "Gtk.OffscreenWindow",
-                       "Gtk.Plug",
-                       "Gtk.HSV",
-                       "Gtk.ImageMenuItem", //deprecated? (not sure why it's not been picked up)
-                       
-                       "Gtk.Menu", // it's added as a special only?
-                       "Gtk.MenuItem",
-                       "Gtk.ToolItem",
-                       
-                       "WebKit.WebViewBase",
-                       
-                       "Gtk.HeaderBar",         // only to window
-               };
-                       
-               /**
-                * Gtk's heirachy of parent/children is not particulaly logical
-                * Gtk.Containers - some are not really that good t being containers.  Gtk.Bin (single only) - is a good flag for indicating 
-                * Gtk.Widgets - some are not great at being widgets
-                * Gtk.Menu - should really only contain menuitems, but the API doesnt really restrict this.
-                * The list goes on.
-                * 
-                *
-               */
-               
-               public void build_generic_children(Gee.HashMap<string,GirObject> classes)
-               {
-                       
-                       GLib.debug("Build Generic Children");
-                       foreach(var cls in classes.values) {
-                               
-                               var fqn = cls.fqn();
-                               
-                               if (cls.is_deprecated) {  // don't add depricated to our selection.
-                                       //GLib.debug("Class %s is depricated", cls.fqn());
-                                       continue;
-                               }
-                               var is_widget = cls.inherits.contains("Gtk.Widget") || cls.implements.contains("Gtk.Widget");
-                               var is_event = cls.inherits.contains("Gtk.EventController") || cls.implements.contains("Gtk.EventController");
-                               if (!is_widget && !is_event) {
-                                       continue;
-                               }
-                               if (cls.is_abstract) {
-                                       continue;
-                               }
-                               if (cls.nodetype == "Interface") {
-                                       continue;
-                               }
-                               var is_black = false;
-                               for (var i = 0 ; i < this.widgets_blacklist.length; i++) {
-                                       var black = this.widgets_blacklist[i];
-                                       
-                                       if (fqn == black || cls.implements.contains(black) || cls.inherits.contains(black)) {
-                                               is_black = true;
-                                               break;
-                                       }
-                               }
-                               if (is_black) {
-                                       continue;
-                               }
-                                
-                                
-                               
-                               for (var i = 0 ; i < this.no_parent.length; i++) {
-                                       var black = this.no_parent[i];
-                                       
-                                       if (fqn == black || cls.implements.contains(black) || cls.inherits.contains(black)) {
-                                               is_black = true;
-                                               all_no_parent.add(fqn);
-                                               
-                                               break;
-                                       }
-                                       
-
-                               }
-                               if (is_black) {
-                                       continue;
-                               }
-                               GLib.debug("Build Generic Children - add %s", fqn);
-                               
-                               if (is_event) {
-                                   this.generic_widget_children.add(fqn);
-                               } else {
-                                   this.generic_child_widgets.add(fqn);
-                           }
-                               //this.add_special_children(fqn, "Gtk.Menu", "_menu"); // fake propety
-                       }
-               
-               }
-               
-               public void add_special_children(string parent, string child, string prop)
-               {
-                       this.getClass(parent);
-                       var cls_cn = this.getClass(child);
-                       var localopts_r = new Gee.ArrayList<string>();
-                       var localopts_l = new Gee.ArrayList<string>();
-                       localopts_l.add(parent);
-                       
-                       if (cls_cn == null) {
-=======
                        if (this.loaded) {
->>>>>>> wip_alan_T7440_handling_gtk4_and_bad_girs
                                return;
                        }
                        Gir.factory(this.project, "Gtk"); // triggers a load...
@@ -334,147 +90,7 @@ namespace Palete {
                
                
                
-<<<<<<< HEAD
-               
-               public void build_class_children_from_props(Gee.HashMap<string,GirObject> classes)
-               {
-                       
-                       
-                
-                       foreach(var cls in classes.values) {
-                               
-                               
-                               if (cls.is_deprecated) {  // don't add depricated to our selection.
-                                       //GLib.debug("Class %s is depricated", cls.fqn());
-                                       continue;
-                               }
-                                       
-                                
-                               
-                               // we can still add properties of abstract classes...
-                               
-                               if (cls.is_abstract || cls.nodetype == "Interface") {
-                                       continue;
-                               }
-                                       
-                               if (cls.props.size < 1) {       
-                                       continue;
-                               }                       
-                               
-                               var localopts_r = new Gee.ArrayList<string>();
-                               var localopts_l = new Gee.ArrayList<string>();
-                               localopts_l.add(cls.fqn());
-                               
-                               // we have a class that extends a widget - let's see if we can add the object based properties. here.
-                               
-                               var props = cls.props.values.to_array();
-                               for (var i = 0 ;i < props.length;i++) {
-                                       var prop = props[i];
-                               
-                                       if (!prop.type.contains(".")) {
-                                               // not a namespaced object - ignore
-                                               continue;
-                                       }
-                                       // gtkcontainer child is a abstract method - that can be called multiple times
-                                       // gtkwidget parent - is a similar method 
-                                       if (!prop.is_readable && !prop.is_writable) {
-                                               continue;
-                                       }
-                                       if (prop.is_deprecated) {
-                                               continue;
-                                       }
-                                       
-                                       if (prop.name == "parent" || 
-                                               (prop.name == "child" && cls.fqn() != "Gtk.Popover") ||   // allow child only on popover.
-                                               prop.name == "attached_to" || 
-                                               prop.name == "mnemonic_widget" ||
-                                               prop.name == "application" ||
-                                               prop.name == "transient_for" ||
-                                               prop.name == "screen" || // gtk windows.
-                                               prop.name == "accel_closure" ||
-                                               prop.name == "accel_widget" ||
-                                               prop.name == "label_widget" ||
-                                               prop.name == "align_widget" ||
-                                               prop.name == "icon_widget" ||
-                                               prop.name == "action_target"  ||
-                                               prop.name == "related_action" || // not sure if we should disable this.
-                                               prop.name == "visible_child"  || 
-                                               prop.name == "attach_widget" || // gtk menu
-                                               prop.name == "relative_to"  || // popover
-                                               // gtk4
-                                               prop.name == "default_widget" || 
-                                               prop.name == "focus_widget" || 
-                                               prop.name == "key_capture_widget" || 
-                                               prop.name == "root" || 
-                                               prop.name == "layout_manager" || 
-                                               1 == 0 
-                                               
-                                               ) {
-                                               continue;
-                                       }
-                                       
-                                       
-                                       
-                                       var propcls = this.getClass(prop.type);
-                                       if (propcls == null || propcls.name == "GLib.Object") { // no point in adding generic glib objects
-                                               continue;
-                                       }
-                                       
-                                       
-                                       
-                                       
-                                       // any other weird stuff.
-                                       // Button.image -> can be a Gtk.Widget.. but really only makes sense as a Gtk.Image
-                                       if (prop.name == "image" && propcls.name == "Gtk.Widget") {
-                                               localopts_r.add( "Gtk.Image:image");
-                                               continue;
-                                       
-                                       }
-                                       
-                                       
-                                       // check if propcls is abstract?
-                                       if (!propcls.is_abstract && propcls.nodetype != "Interface") { 
-                                               localopts_r.add( prop.type + ":" + prop.name);
-                                               //GLib.debug("Add Widget Prop %s:%s (%s) - from %s", cls.fqn(), prop.name, prop.type, prop.propertyof);                                         
-                                       }
-
-                                       
-                                       
-                                       //GLib.debug("Add Widget Prop %s:%s (%s) - from %s", cls.fqn(), prop.name, prop.type, prop.propertyof);
-                                       foreach(var impl in propcls.implementations) {
-                                               //GLib.debug("Add Widget Prop %s:%s (%s) - from %s", cls.fqn(), prop.name, prop.type, prop.propertyof);
-                                               // in theory these can not be abstract?
-                                               
-                                               var impcls = this.getClass(impl);
-                                               if (impcls.is_abstract || impcls.nodetype == "Interface") {
-                                                       continue;
-                                               }
-                                               //GLib.debug("Add Widget Prop %s:%s (%s)", cls.fqn(), prop.name, impl);
-                                               localopts_r.add( impl + ":" + prop.name );
-                                       }
-                                       
-                                       
-                                       
-                                       
-                                       // lookup type -> is it an object
-                                       // and not a enum..
-                                       // if so then add it to localopts
-                               
-                               }
-                               if (localopts_r.size > 0) { 
-                                       this.map.add(new Usage(localopts_l, localopts_r));
-                               }
-                       }
-                                               
-                                               
-                                
-                          
-                    
-               }
-=======
          
->>>>>>> wip_alan_T7440_handling_gtk4_and_bad_girs
                
                public string doc(string what) 
                {
@@ -851,39 +467,6 @@ namespace Palete {
                         
                                //gtk box failing
                        //GLib.debug("No. of parmas %s %d", cls, ctor.params.size);
-<<<<<<< HEAD
-                       var m = ar.get(method);
-                       if (m != null) {
-                       
-                           
-                           foreach (var prop in m.paramset.params) {
-                                   string[] opts;
-                                   
-                                   GLib.debug("adding proprty from ctor : %s, %s, %s", cls, prop.name, prop.type);
-
-                                   var sub = this.getClass(prop.type);
-                                   if (sub != null) { // can't add child classes here...
-                                           GLib.debug("skipping ctor argument proprty is an object");
-                                           continue;
-                                   }
-                                   var dval = "";
-                                   switch (prop.type) {
-                                           case "int":
-                                                   dval = "0";break;
-                                           case "string": 
-                                                   dval = ""; break;
-                                           // anything else?
-                                           default:
-                                                   this.typeOptions(cls, prop.name, prop.type, out opts);
-                                                   dval = opts.length > 0 ? opts[0] : "";
-                                                   break;
-                                   }
-                                   
-                                   this.node_defaults.get(cls).add( new JsRender.NodeProp.prop( prop.name, prop.type, dval));
-                           
-                           
-                           }
-=======
                          
                    foreach (var prop in ctor.paramset.params) {
                            string[] opts;
@@ -926,7 +509,6 @@ namespace Palete {
                    
                            
                             
->>>>>>> wip_alan_T7440_handling_gtk4_and_bad_girs
                    }
                }
                
@@ -987,64 +569,6 @@ namespace Palete {
                        this.child_defaults.get(cls).add( new JsRender.NodeProp.prop(propname, type, val));
                
                }
-<<<<<<< HEAD
-               
-               public override void on_child_added(JsRender.Node? parent,JsRender.Node child)
-               {   
-
-                       if (parent != null &&  !child.has("* prop")) { // child has a property - no need for child properties
-                                
-                               if (this.child_defaults.has_key(parent.fqn())) {
-                                       foreach(var k in this.child_defaults.get(parent.fqn())) {
-                                               if (!child.has(k.to_index_key())) { 
-                                                       child.set_prop(k.dupe());
-                                               }
-                                       }
-                               }
-                       }
-                       if (this.node_defaults.has_key(child.fqn())) {
-                               foreach(var k in this.node_defaults.get(child.fqn())) {
-
-                                       if (!child.has(k.to_index_key())) { 
-                                               GLib.debug("Adding Property %s", k.to_tooltip());
-                                               child.set_prop(k.dupe());
-                                       }
-                               }
-                       }
-                       
-                       // if child is a struct 
-                       var childcls = this.getClass(child.fqn());
-                       if (childcls != null && childcls.nodetype == "Struct") {
-                               // then we need to add all the props.
-                               foreach(var prop in childcls.props.values) {
-                                       child.set_prop(prop.toNodeProp());
-                                       
-                                       
-                               }
-                               
-                       
-                       }
-                       // is child a Event - handled by nodetovala...
-                       
-                       // any other combo?
-                       switch(parent.fqn()) {
-                               case "Gtk.Dialog":
-                                       if (child.has("* prop") && child.get_prop("* prop").val == "buttons[]") {
-                                               child.set_prop( new JsRender.NodeProp.special("response_id", "1"));
-                                       }
-                                       break;
-                                       
-                       }
-                       
-                       // not really
-                       //this.fillPack(child, parent);
-                       
-                       
-                       
-                       
-               }
-=======
->>>>>>> wip_alan_T7440_handling_gtk4_and_bad_girs
                 
                public Gee.ArrayList<string> packages(Project.Gtk gproject)
                {
index d8889cd..3d63c2f 100644 (file)
@@ -33,7 +33,7 @@ namespace Palete {
                        }
                         
                        
-                       GLib.debug("parsing namespace %s\n", element.name);
+                       //print("parsing namespace %s\n", element.name);
                        if (element.name == null) {
                                element.accept_children(this); // catch sub namespaces..
                                return;
index 0441b1a..fa2540b 100644 (file)
@@ -226,13 +226,8 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
                store_value (get_parameter_cvalue (param), value, source_reference);
        }
 
-<<<<<<< HEAD
-        public override void store_field (Vala.Field field, Vala.TargetValue? instance, Vala.TargetValue value, Vala.SourceReference? source_reference = null, bool initializer = false) 
-        {
-=======
        public override void store_field (Vala.Field field, Vala.TargetValue? instance, Vala.TargetValue value, Vala.SourceReference? source_reference = null, bool initializer = false)
        {
->>>>>>> wip_alan_T7440_handling_gtk4_and_bad_girs
                var lvalue = get_field_cvalue (field, instance);
                var type = lvalue.value_type;
                if (lvalue.actual_value_type != null) {