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...
-<<<<<<< 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)
{
//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;
->>>>>>> wip_alan_T7440_handling_gtk4_and_bad_girs
}
}
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)
{