Fix #7242 - see if i can get the parent child tree.. from vala
authorAlan <alan@roojs.com>
Thu, 2 Jun 2022 07:13:07 +0000 (15:13 +0800)
committerAlan <alan@roojs.com>
Thu, 2 Jun 2022 07:13:07 +0000 (15:13 +0800)
38 files changed:
.gitignore
configure.ac
src/Application.vala
src/Builder4/About.bjs
src/Builder4/DialogNewComponent.bjs
src/Builder4/DialogNewComponent.vala
src/Builder4/EditProject.bjs
src/Builder4/Editor.bjs
src/Builder4/Editor.vala
src/Builder4/GladeView.bjs
src/Builder4/GladeView.vala
src/Builder4/GladeuiView.bjs [new file with mode: 0644]
src/Builder4/GladeuiView.vala [new file with mode: 0644]
src/Builder4/GtkView.bjs
src/Builder4/GtkView.vala
src/Builder4/MainWindow.bjs
src/Builder4/MainWindow.vala
src/Builder4/PopoverFiles.bjs
src/Builder4/PopoverFiles.vala
src/Builder4/WindowLeftProps.bjs
src/Builder4/WindowLeftProps.vala
src/Builder4/WindowLeftTree.bjs
src/Builder4/WindowLeftTree.vala
src/Builder4/WindowState.vala
src/Builder4/config1.builder
src/Builder4/sample_working_gladeui.vala [new file with mode: 0644]
src/JsRender/Gtk.vala
src/JsRender/JsRender.vala
src/JsRender/NodeToGlade.vala
src/JsRender/PlainFile.vala
src/JsRender/Roo.vala
src/Main.vala
src/Makefile.am
src/Palete/Gir.vala
src/Palete/GirObject.vala
src/Palete/Gtk.vala
src/Palete/VapiParser.vala
src/Project/Project.vala

index 217a60b..c6a4c21 100644 (file)
@@ -50,3 +50,5 @@ debian/roobuilder
 debian/auto*
 debian/debhelper*
 debian/files
+
+.gdb_history
index 6434020..c6b650f 100644 (file)
@@ -31,7 +31,7 @@ PKG_CHECK_MODULES(ROOBUILDER, [ zlib
                 json-glib-1.0
                 gee-0.8
                 libxml-2.0
-                libsoup-2.4,
+                libsoup-2.4 
                 roojspacker-1.4
 ]) 
 
index d9feb73..f5246a7 100644 (file)
@@ -64,6 +64,7 @@
             { "list-projects", 0, 0,  OptionArg.NONE, ref opt_list_projects, "List Projects", null },
             { "list-files", 0, 0,  OptionArg.NONE, ref  opt_list_files, "List Files (in a project", null},
             { "bjs", 0, 0, OptionArg.STRING, ref opt_bjs_compile, "convert bjs file", null },
+            { "bjs-glade", 0, 0, OptionArg.NONE, ref opt_bjs_compile_glade, "output glade", null },
             { "bjs-target", 0, 0, OptionArg.STRING, ref opt_bjs_compile_target, "convert bjs file to tareet  : vala / js", null },
             { "test", 0, 0, OptionArg.STRING, ref opt_test, "run a test use 'help' to list the available tests", null },
             
@@ -80,7 +81,8 @@
                public static bool opt_debug = false;
                public static bool opt_list_projects = false;
                public static bool opt_list_files = false;
-               public static bool opt_pull_resources = false;          
+               public static bool opt_pull_resources = false;
+               public static bool opt_bjs_compile_glade = false;
                
                public static string _self;
                
                        if (file == null) {
                                GLib.error("missing file %s in project %s", BuilderApplication.opt_bjs_compile, cur_project.name);
                        }
-                       //BuilderApplication.compileBjs();
                        file.loadItems();
+                                               
+                       if (BuilderApplication.opt_bjs_compile_glade) {
+                               var str = file.toGlade();
+                               print("%s", str);
+                               GLib.Process.exit(Posix.EXIT_SUCCESS);
+                       }
+                       
+                       //BuilderApplication.compileBjs();
+
                        var str = file.toSourceCode();
                          
                          
index 8209ffd..0c8615c 100644 (file)
@@ -10,8 +10,7 @@
      "(rid) => {",
      "    this.el.hide();",
      "    ",
-     "}",
-     "  "
+     "}"
     ]
    },
    "program_name" : "roobuilder",
@@ -25,8 +24,7 @@
     "    this.el.set_transient_for(parent);",
     "    this.el.modal = true;",
     "    this.el.show();",
-    "}",
-    " "
+    "}"
    ]
   }
  ],
index 8015afa..f49aefa 100644 (file)
 {
- "name" : "DialogNewComponent",
- "parent" : "",
- "title" : "",
- "path" : "/home/alan/gitlive/roobuilder/src/Builder4/DialogNewComponent.bjs",
- "permname" : "",
- "modOrder" : "",
  "build_module" : "",
  "items" : [
   {
-   "listeners" : {
-    "delete_event" : "(self, event) => {\n    this.el.hide();\n    return true; \n    //test  \n}\n ",
-    "response" : " (self, response_id) =>  { \n  \n\tif (response_id < 1) { // cancel!\n            this.el.hide();\n            return;\n        }\n\n\n\n        if (_this.name.el.get_text().length  < 1) {\n            StandardErrorDialog.show(\n                this.el,\n                \"You have to set Component name \"\n            );\n             \n            return;\n        }\n        // what does this do?\n        \n        var isNew = _this.file.name.length  > 0 ? false : true;\n        /*\n        if (!isNew && this.file.name != _this.name.el.get_text()) {\n            Xcls_StandardErrorDialog.singleton().show(\n                this.el,\n                \"Sorry changing names does not work yet. \"\n            );\n             \n            return;\n        }\n        */\n         \n        \n      \n        // FIXME - this may be more complicated...\n        //for (var i in this.def) {\n        //    this.file[i] =  this.get(i).el.get_text();\n        //}\n\n        if (!isNew) {\n            try {\n                 this.updateFileFromEntry();\n             } catch( JsRender.Error.RENAME_FILE_EXISTS er) {\n                  Xcls_StandardErrorDialog.singleton().show(\n                    this.el,\n                    \"The name you used already exists \"\n                );\n                return;\n                 \n             }\n                                                        \n        \n            _this.file.save();\n            this.el.hide();\n            return;\n        }\n        var fn = this.name.el.get_text();\n        var dir = _this.project.firstPath();\n       \n        if (GLib.FileUtils.test(dir + \"/\" + fn + \".bjs\", GLib.FileTest.EXISTS)) {\n            Xcls_StandardErrorDialog.singleton().show(\n                this.el,\n                \"That file already exists\"\n            ); \n            return;\n        }\n       \n       var f =  JsRender.JsRender.factory(\n                _this.file.project.xtype,  \n                _this.file.project, \n                dir + \"/\" + fn + \".bjs\");\n\n        _this.file = f;\n        \n\n        \n        this.updateFileFromEntry();\n        _this.file.save();\n        _this.file.project.addFile(_this.file);\n        \n\t \n        // what about .js ?\n       \n        this.el.hide();\n        \n        \n        //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue());\n         \n        //var nf = _this.project.create(dir + \"/\" + _this.file.name + \".bjs\");\n        //for (var i in this.file) {\n        //    nf[i] = this.file[i];\n        //}\n        _this.success(_this.project, _this.file);\n        /*\n\n        -- fixme -- needs to be a signal..\n        if (DialogNewComponent.success != null) {\n            DialogNewComponent.success(_this.project, nf);\n        }\n        */\n}",
-    "show" : "(self)  => {\n  this.el.show_all();\n  //test\n}"
-   },
-   "|   void updateFileFromEntry" : "() {\n\n        _this.file.title = _this.title.el.get_text();\n        _this.file.region = _this.region.el.get_text();            \n        _this.file.parent = _this.parent.el.get_text();                        \n        _this.file.permname = _this.permname.el.get_text();                                    \n        _this.file.modOrder = _this.modOrder.el.get_text();\n        \n        if (_this.file.name.length  > 0 && _this.file.name != _this.name.el.get_text()) {\n            _this.file.renameTo(_this.name.el.get_text());\n        }\n        // store the module...\n        _this.file.build_module = \"\";        \n         Gtk.TreeIter iter; \n        if (_this.build_module.el.get_active_iter (out iter)) {\n             Value vfname;\n             this.dbmodel.el.get_value (iter, 0, out vfname);\n             if (((string)vfname).length > 0) {\n                 _this.file.build_module = (string)vfname;\n             }\n    \n        }\n        \n        \n\n                                                    \n}    ",
-   "@ void success" : "(Project.Project pr, JsRender.JsRender file)",
-   "id" : "DialogNewComponent",
-   "default_width" : 500,
-   "$ deletable" : true,
-   "# Project.Project project" : "",
-   "title" : "New Component",
-   "xtype" : "Dialog",
-   "|   void show" : "(JsRender.JsRender c) \n{\n    this.project = c.project;\n    \n    //if (!this.el) {\n        //this.init();\n     //}\n    \n    _this.name.el.set_text(c.name);\n    _this.title.el.set_text(c.title);\n    _this.parent.el.set_text(c.parent);    \n    _this.region.el.set_text(c.region);\n    _this.modOrder.el.set_text(c.modOrder);\n     _this.permname.el.set_text(c.permname);\n    \n    if (c.path.length > 0) {\n        this.el.set_title(\"Edit File Details - \" + c.name);\n    } else {\n        this.el.set_title(\"Create New File\");\n    }\n    \n     var ar = new Gee.ArrayList<string>();\n     _this.dbmodel.loadData(ar,\"\");\n    // load the modules... if relivant..\n    if (this.project.xtype == \"Gtk\") {\n        var p = (Project.Gtk)c.project;\n          var cg = p.compilegroups;\n\n        var iter = cg.map_iterator();\n       while(iter.next()) {\n            var key = iter.get_key();\n            if (key == \"_default_\") {\n                continue;\n            }\n            ar.add(key);\n        };\n        _this.dbmodel.loadData(ar, c.build_module);\n\n    } \n     \n    _this.file = c;\n    //console.log('show all');\n    this.el.show_all();\n    \n    //this.success = c.success;\n    \n    \n}",
    "# JsRender.JsRender file" : "null",
-   "default_height" : 200,
+   "# Project.Project project" : "",
+   "$ deletable" : true,
    "$ modal" : true,
    "$ xns" : "Gtk",
+   "@ void success" : "(Project.Project pr, JsRender.JsRender file)",
+   "default_height" : 200,
+   "default_width" : 500,
+   "id" : "DialogNewComponent",
    "items" : [
     {
-     "xtype" : "VBox",
      "$ pack" : "get_content_area().add",
      "$ xns" : "Gtk",
+     "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
      "items" : [
       {
-       "* pack" : "pack_start,false,false,0",
-       "xtype" : "Table",
-       "n_columns" : 2,
-       "$ xns" : "Gtk",
-       "n_rows" : 3,
        "$ homogeneous" : true,
+       "$ xns" : "Gtk",
+       "* pack" : "pack_start,false,false,0",
        "items" : [
         {
-         "label" : "Component Name",
-         "xalign" : 0.90000000000000002,
+         "$ xns" : "Gtk",
          "* pack" : "attach_defaults,0,1,0,1",
-         "xtype" : "Label",
-         "$ justify" : "Gtk.Justification.RIGHT",
+         "Gtk.Justification justify" : "Gtk.Justification.RIGHT",
+         "label" : "Component Name",
          "x_options" : 4,
-         "$ xns" : "Gtk"
+         "xalign" : 0.90000000000000002,
+         "xtype" : "Label"
         },
         {
-         "id" : "name",
          "$ visible" : true,
-         "xtype" : "Entry",
+         "$ xns" : "Gtk",
          "* pack" : "attach_defaults,1,2,0,1",
-         "$ xns" : "Gtk"
+         "id" : "name",
+         "xtype" : "Entry"
         },
         {
-         "label" : "Title",
+         "$ justify" : "Gtk.Justification.RIGHT",
          "$ visible" : true,
-         "xalign" : 0.90000000000000002,
+         "$ xns" : "Gtk",
          "* pack" : "attach_defaults,0,1,1,2",
-         "xtype" : "Label",
-         "$ justify" : "Gtk.Justification.RIGHT",
+         "Gtk.Justification justify" : "Gtk.Justification.RIGHT",
+         "label" : "Title",
          "x_options" : 4,
-         "$ xns" : "Gtk"
+         "xalign" : 0.90000000000000002,
+         "xtype" : "Label"
         },
         {
-         "id" : "title",
          "$ visible" : true,
-         "xtype" : "Entry",
+         "$ xns" : "Gtk",
          "* pack" : "attach_defaults,1,2,1,2",
-         "$ xns" : "Gtk"
+         "id" : "title",
+         "xtype" : "Entry"
         },
         {
-         "label" : "Region",
-         "tooltip_text" : "center, north, south, east, west",
+         "$ justify" : "Gtk.Justification.RIGHT",
          "$ visible" : true,
-         "xalign" : 0.90000000000000002,
+         "$ xns" : "Gtk",
          "* pack" : "attach_defaults,0,1,2,3",
-         "xtype" : "Label",
-         "$ justify" : "Gtk.Justification.RIGHT",
+         "label" : "Region",
+         "tooltip_text" : "center, north, south, east, west",
          "x_options" : 4,
-         "$ xns" : "Gtk"
+         "xalign" : 0.90000000000000002,
+         "xtype" : "Label"
         },
         {
-         "id" : "region",
          "$ visible" : true,
-         "xtype" : "Entry",
+         "$ xns" : "Gtk",
          "* pack" : "attach_defaults,1,2,2,3",
-         "$ xns" : "Gtk"
+         "id" : "region",
+         "xtype" : "Entry"
         },
         {
-         "label" : "Parent Name",
+         "$ justify" : "Gtk.Justification.RIGHT",
          "$ visible" : true,
-         "xalign" : 0.90000000000000002,
+         "$ xns" : "Gtk",
          "* pack" : "attach_defaults,0,1,3,4",
-         "xtype" : "Label",
-         "$ justify" : "Gtk.Justification.RIGHT",
+         "label" : "Parent Name",
          "x_options" : 4,
-         "$ xns" : "Gtk"
+         "xalign" : 0.90000000000000002,
+         "xtype" : "Label"
         },
         {
-         "id" : "parent",
          "$ visible" : true,
-         "xtype" : "Entry",
+         "$ xns" : "Gtk",
          "* pack" : "attach_defaults,1,2,3,4",
-         "$ xns" : "Gtk"
+         "id" : "parent",
+         "xtype" : "Entry"
         },
         {
-         "label" : "Permission Name",
+         "$ justify" : "Gtk.Justification.RIGHT",
          "$ visible" : true,
-         "xalign" : 0.90000000000000002,
+         "$ xns" : "Gtk",
          "* pack" : "attach_defaults,0,1,4,5",
-         "xtype" : "Label",
-         "$ justify" : "Gtk.Justification.RIGHT",
+         "label" : "Permission Name",
          "x_options" : 4,
-         "$ xns" : "Gtk"
+         "xalign" : 0.90000000000000002,
+         "xtype" : "Label"
         },
         {
-         "id" : "permname",
          "$ visible" : true,
-         "xtype" : "Entry",
+         "$ xns" : "Gtk",
          "* pack" : "attach_defaults,1,2,4,5",
-         "$ xns" : "Gtk"
+         "id" : "permname",
+         "xtype" : "Entry"
         },
         {
-         "label" : "Order (for tabs)",
+         "$ justify" : "Gtk.Justification.RIGHT",
          "$ visible" : true,
-         "xalign" : 0.90000000000000002,
+         "$ xns" : "Gtk",
          "* pack" : "attach_defaults,0,1,5,6",
-         "xtype" : "Label",
-         "$ justify" : "Gtk.Justification.RIGHT",
+         "label" : "Order (for tabs)",
          "x_options" : 4,
-         "$ xns" : "Gtk"
+         "xalign" : 0.90000000000000002,
+         "xtype" : "Label"
         },
         {
-         "id" : "modOrder",
          "$ visible" : true,
-         "xtype" : "Entry",
+         "$ xns" : "Gtk",
          "* pack" : "attach_defaults,1,2,5,6",
-         "$ xns" : "Gtk"
+         "id" : "modOrder",
+         "xtype" : "Entry"
         },
         {
-         "label" : "Module to build (Vala only)",
+         "$ justify" : "Gtk.Justification.RIGHT",
          "$ visible" : true,
-         "xalign" : 0.90000000000000002,
+         "$ xns" : "Gtk",
          "* pack" : "attach_defaults,0,1,6,7",
-         "xtype" : "Label",
-         "$ justify" : "Gtk.Justification.RIGHT",
+         "label" : "Module to build (Vala only)",
          "x_options" : 4,
-         "$ xns" : "Gtk"
+         "xalign" : 0.90000000000000002,
+         "xtype" : "Label"
         },
         {
-         "id" : "build_module",
+         "$ xns" : "Gtk",
          "* init" : "this.el.add_attribute(_this.dbcellrenderer.el , \"markup\", 1 );",
          "* pack" : "attach_defaults,1,2,6,7",
-         "xtype" : "ComboBox",
-         "$ xns" : "Gtk",
+         "id" : "build_module",
          "items" : [
           {
-           "id" : "dbcellrenderer",
+           "$ xns" : "Gtk",
            "* pack" : "pack_start,true",
-           "xtype" : "CellRendererText",
-           "$ xns" : "Gtk"
+           "id" : "dbcellrenderer",
+           "xtype" : "CellRendererText"
           },
           {
-           "id" : "dbmodel",
-           "* pack" : "set_model",
-           "xtype" : "ListStore",
            "$ columns" : "typeof(string),typeof(string)",
-           "n_columns" : 2,
            "$ xns" : "Gtk",
-           "| void loadData" : "  (Gee.ArrayList<string> data, string cur) {\n    this.el.clear();                                    \n    Gtk.TreeIter iter;\n    var el = this.el;\n    \n   /// el.append(out iter);\n    \n     \n   // el.set_value(iter, 0, \"\");\n   // el.set_value(iter, 1, \"aaa  - Just add Element - aaa\");\n\n    el.append(out iter);\n\n    \n    el.set_value(iter, 0, \"\");\n    el.set_value(iter, 1, \"-- select a module --\");\n    _this.build_module.el.set_active_iter(iter);\n    \n    for (var i = 0; i < data.size;i++) {\n    \n\n        el.append(out iter);\n        \n        el.set_value(iter, 0, data.get(i));\n        el.set_value(iter, 1, data.get(i));\n        \n        if (data.get(i) == cur) {\n            _this.build_module.el.set_active_iter(iter);\n        }\n        \n    }\n     this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          \n                                     \n}\n"
+           "* pack" : "set_model",
+           "id" : "dbmodel",
+           "n_columns" : 2,
+           "xtype" : "ListStore",
+           "| void loadData" : [
+            "  (Gee.ArrayList<string> data, string cur) {",
+            "    this.el.clear();                                    ",
+            "    Gtk.TreeIter iter;",
+            "    var el = this.el;",
+            "    ",
+            "   /// el.append(out iter);",
+            "    ",
+            "     ",
+            "   // el.set_value(iter, 0, \"\");",
+            "   // el.set_value(iter, 1, \"aaa  - Just add Element - aaa\");",
+            "",
+            "    el.append(out iter);",
+            "",
+            "    ",
+            "    el.set_value(iter, 0, \"\");",
+            "    el.set_value(iter, 1, \"-- select a module --\");",
+            "    _this.build_module.el.set_active_iter(iter);",
+            "    ",
+            "    for (var i = 0; i < data.size;i++) {",
+            "    ",
+            "",
+            "        el.append(out iter);",
+            "        ",
+            "        el.set_value(iter, 0, data.get(i));",
+            "        el.set_value(iter, 1, data.get(i));",
+            "        ",
+            "        if (data.get(i) == cur) {",
+            "            _this.build_module.el.set_active_iter(iter);",
+            "        }",
+            "        ",
+            "    }",
+            "     this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          ",
+            "                                     ",
+            "}",
+            ""
+           ]
           }
-         ]
+         ],
+         "xtype" : "ComboBox"
         }
-       ]
+       ],
+       "n_columns" : 2,
+       "n_rows" : 3,
+       "xtype" : "Table"
       }
-     ]
+     ],
+     "xtype" : "Box"
     },
     {
-     "label" : "Cancel",
+     "$ xns" : "Gtk",
      "* pack" : "add_action_widget,0",
-     "xtype" : "Button",
-     "$ xns" : "Gtk"
+     "label" : "Cancel",
+     "xtype" : "Button"
     },
     {
-     "label" : "OK",
+     "$ xns" : "Gtk",
      "* pack" : "add_action_widget,1",
-     "xtype" : "Button",
-     "$ xns" : "Gtk"
+     "label" : "OK",
+     "xtype" : "Button"
     }
+   ],
+   "listeners" : {
+    "delete_event" : [
+     "(self, event) => {",
+     "    this.el.hide();",
+     "    return true; ",
+     "    //test  ",
+     "}",
+     " "
+    ],
+    "response" : [
+     " (self, response_id) =>  { ",
+     "  ",
+     "\tif (response_id < 1) { // cancel!",
+     "            this.el.hide();",
+     "            return;",
+     "        }",
+     "",
+     "",
+     "",
+     "        if (_this.name.el.get_text().length  < 1) {",
+     "            StandardErrorDialog.show(",
+     "                this.el,",
+     "                \"You have to set Component name \"",
+     "            );",
+     "             ",
+     "            return;",
+     "        }",
+     "        // what does this do?",
+     "        ",
+     "        var isNew = _this.file.name.length  > 0 ? false : true;",
+     "        /*",
+     "        if (!isNew && this.file.name != _this.name.el.get_text()) {",
+     "            Xcls_StandardErrorDialog.singleton().show(",
+     "                this.el,",
+     "                \"Sorry changing names does not work yet. \"",
+     "            );",
+     "             ",
+     "            return;",
+     "        }",
+     "        */",
+     "         ",
+     "        ",
+     "      ",
+     "        // FIXME - this may be more complicated...",
+     "        //for (var i in this.def) {",
+     "        //    this.file[i] =  this.get(i).el.get_text();",
+     "        //}",
+     "",
+     "        if (!isNew) {",
+     "            try {",
+     "                 this.updateFileFromEntry();",
+     "             } catch( JsRender.Error.RENAME_FILE_EXISTS er) {",
+     "                  Xcls_StandardErrorDialog.singleton().show(",
+     "                    this.el,",
+     "                    \"The name you used already exists \"",
+     "                );",
+     "                return;",
+     "                 ",
+     "             }",
+     "                                                        ",
+     "        ",
+     "            _this.file.save();",
+     "            this.el.hide();",
+     "            return;",
+     "        }",
+     "        var fn = this.name.el.get_text();",
+     "        var dir = _this.project.firstPath();",
+     "       ",
+     "        if (GLib.FileUtils.test(dir + \"/\" + fn + \".bjs\", GLib.FileTest.EXISTS)) {",
+     "            Xcls_StandardErrorDialog.singleton().show(",
+     "                this.el,",
+     "                \"That file already exists\"",
+     "            ); ",
+     "            return;",
+     "        }",
+     "       ",
+     "       var f =  JsRender.JsRender.factory(",
+     "                _this.file.project.xtype,  ",
+     "                _this.file.project, ",
+     "                dir + \"/\" + fn + \".bjs\");",
+     "",
+     "        _this.file = f;",
+     "        ",
+     "",
+     "        ",
+     "        this.updateFileFromEntry();",
+     "        _this.file.save();",
+     "        _this.file.project.addFile(_this.file);",
+     "        ",
+     "\t ",
+     "        // what about .js ?",
+     "       ",
+     "        this.el.hide();",
+     "        ",
+     "        ",
+     "        //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue());",
+     "         ",
+     "        //var nf = _this.project.create(dir + \"/\" + _this.file.name + \".bjs\");",
+     "        //for (var i in this.file) {",
+     "        //    nf[i] = this.file[i];",
+     "        //}",
+     "        _this.success(_this.project, _this.file);",
+     "        /*",
+     "",
+     "        -- fixme -- needs to be a signal..",
+     "        if (DialogNewComponent.success != null) {",
+     "            DialogNewComponent.success(_this.project, nf);",
+     "        }",
+     "        */",
+     "}"
+    ],
+    "show" : [
+     "(self)  => {",
+     "  this.el.show_all();",
+     "  //test",
+     "}"
+    ]
+   },
+   "title" : "New Component",
+   "xtype" : "Dialog",
+   "|   void show" : [
+    "(JsRender.JsRender c) ",
+    "{",
+    "    this.project = c.project;",
+    "    ",
+    "    //if (!this.el) {",
+    "        //this.init();",
+    "     //}",
+    "    ",
+    "    _this.name.el.set_text(c.name);",
+    "    _this.title.el.set_text(c.title);",
+    "    _this.parent.el.set_text(c.parent);    ",
+    "    _this.region.el.set_text(c.region);",
+    "    _this.modOrder.el.set_text(c.modOrder);",
+    "     _this.permname.el.set_text(c.permname);",
+    "    ",
+    "    if (c.path.length > 0) {",
+    "        this.el.set_title(\"Edit File Details - \" + c.name);",
+    "    } else {",
+    "        this.el.set_title(\"Create New File\");",
+    "    }",
+    "    ",
+    "     var ar = new Gee.ArrayList<string>();",
+    "     _this.dbmodel.loadData(ar,\"\");",
+    "    // load the modules... if relivant..",
+    "    if (this.project.xtype == \"Gtk\") {",
+    "        var p = (Project.Gtk)c.project;",
+    "          var cg = p.compilegroups;",
+    "",
+    "        var iter = cg.map_iterator();",
+    "       while(iter.next()) {",
+    "            var key = iter.get_key();",
+    "            if (key == \"_default_\") {",
+    "                continue;",
+    "            }",
+    "            ar.add(key);",
+    "        };",
+    "        _this.dbmodel.loadData(ar, c.build_module);",
+    "",
+    "    } ",
+    "     ",
+    "    _this.file = c;",
+    "    //console.log('show all');",
+    "    this.el.show_all();",
+    "    ",
+    "    //this.success = c.success;",
+    "    ",
+    "    ",
+    "}"
+   ],
+   "|   void updateFileFromEntry" : [
+    "() {",
+    "",
+    "        _this.file.title = _this.title.el.get_text();",
+    "        _this.file.region = _this.region.el.get_text();            ",
+    "        _this.file.parent = _this.parent.el.get_text();                        ",
+    "        _this.file.permname = _this.permname.el.get_text();                                    ",
+    "        _this.file.modOrder = _this.modOrder.el.get_text();",
+    "        ",
+    "        if (_this.file.name.length  > 0 && _this.file.name != _this.name.el.get_text()) {",
+    "            _this.file.renameTo(_this.name.el.get_text());",
+    "        }",
+    "        // store the module...",
+    "        _this.file.build_module = \"\";        ",
+    "         Gtk.TreeIter iter; ",
+    "        if (_this.build_module.el.get_active_iter (out iter)) {",
+    "             Value vfname;",
+    "             this.dbmodel.el.get_value (iter, 0, out vfname);",
+    "             if (((string)vfname).length > 0) {",
+    "                 _this.file.build_module = (string)vfname;",
+    "             }",
+    "    ",
+    "        }",
+    "        ",
+    "        ",
+    "",
+    "                                                    ",
+    "}    "
    ]
   }
- ]
+ ],
+ "modOrder" : "",
+ "name" : "DialogNewComponent",
+ "parent" : "",
+ "path" : "/home/alan/gitlive/roobuilder/src/Builder4/DialogNewComponent.bjs",
+ "permname" : "",
+ "title" : ""
 }
\ No newline at end of file
index 319c7f5..394e4e6 100644 (file)
@@ -42,7 +42,7 @@ public class Xcls_DialogNewComponent : Object
         this.el.default_width = 500;
         this.el.deletable = true;
         this.el.modal = true;
-        var child_0 = new Xcls_VBox2( _this );
+        var child_0 = new Xcls_Box2( _this );
         child_0.ref();
         this.el.get_content_area().add (  child_0.el  );
         var child_1 = new Xcls_Button20( _this );
@@ -240,19 +240,19 @@ public class Xcls_DialogNewComponent : Object
         
         
     }
-    public class Xcls_VBox2 : Object
+    public class Xcls_Box2 : Object
     {
-        public Gtk.VBox el;
+        public Gtk.Box el;
         private Xcls_DialogNewComponent  _this;
 
 
             // my vars (def)
 
         // ctor
-        public Xcls_VBox2(Xcls_DialogNewComponent _owner )
+        public Xcls_Box2(Xcls_DialogNewComponent _owner )
         {
             _this = _owner;
-            this.el = new Gtk.VBox( true, 0 );
+            this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
 
             // my vars (dec)
 
index 5b87580..92ab2ba 100644 (file)
 {
- "name" : "EditProject",
- "parent" : "",
- "title" : "",
- "path" : "/home/alan/gitlive/roobuilder/src/Builder4/EditProject.bjs",
- "permname" : "",
- "modOrder" : "",
  "build_module" : "builder",
  "items" : [
   {
-   "listeners" : {
-    "destroy_event" : "(self, event) => {\n\tthis.el.response(0);\n//     this.el.hide();\n    return false;\n}"
-   },
-   "default_width" : 600,
    "$ deletable" : true,
-   "title" : "Project Properties",
-   "xtype" : "Dialog",
-   "default_height" : 500,
-   "| Project.Project? show" : "() {\n      \n\n    //[ 'xtype'  ].forEach(function(k) {\n    //    _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]);\n    //});\n\t// shouild set path..\n    _this.model.loadData();\n    this.el.show_all();\n    \n    var err_dialog = StandardErrorDialog.singleton();\n\n    var id = -1;\n    while (id < 0) {\n         id =  this.el.run();\n         if (id < 1) {\n                this.el.hide();\n                return null;\n        }\n \n         \n      if (_this.xtype.getValue().length < 1) {\n           \n            err_dialog.show(_this.el,\"You have to set Project type\");             \n            id = -1;\n            continue;\n        }\n        if (_this.dir.el.get_filename().length < 1) {\n\n            err_dialog.show(_this.el,\"You have to select a folder\");             \n            id = -1;\n            continue;\n        }\n           \n    }\n    \n    this.el.hide();\n    \n    \n    \n \n    var fn = _this.dir.el.get_filename();\n    print(\"add %s\\n\" , fn);\n    \n    var project = Project.Project.factory(_this.xtype.getValue(), fn);\n    project.save();\n    Project.projects.set(project.name,project);\n    \n    //var pr = imports.Builder.Provider.ProjectManager.ProjectManager.update(this.project);\n    \n    return project;\n\n    \n    //this.success = c.success;\n}\n",
    "$ modal" : true,
    "$ xns" : "Gtk",
    "border_width" : 3,
-   "name" : "EditProject",
+   "default_height" : 500,
+   "default_width" : 600,
    "items" : [
     {
-     "bool expand" : true,
-     "xtype" : "Box",
-     "$ pack" : " get_content_area().add \n \n",
+     "$ homogeneous" : false,
+     "$ pack" : [
+      " get_content_area().add ",
+      " ",
+      ""
+     ],
      "$ xns" : "Gtk",
      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
-     "$ homogeneous" : false,
+     "bool expand" : true,
      "items" : [
       {
-       "xtype" : "Box",
-       "* pack" : "pack_start,false,true,3",
+       "$ homogeneous" : false,
        "$ xns" : "Gtk",
+       "* pack" : "pack_start,false,true,3",
        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
-       "$ homogeneous" : false,
        "items" : [
         {
-         "label" : "Project type :",
-         "xtype" : "Label",
+         "$ xns" : "Gtk",
          "* pack" : "pack_start,false,true,3",
-         "$ xns" : "Gtk"
+         "label" : "Project type :",
+         "xtype" : "Label"
         },
         {
-         "| string getValue" : " () {\n     var ix = this.el.get_active();\n        if (ix < 0 ) {\n            return \"\";\n        }\n        switch(ix) {\n            case 0:\n                return \"Roo\";\n            case 1:\n                return \"Gtk\";\n           case 2:\n                return \"Flutter\";\n        }\n        return \"\";\n}\n",
-         "id" : "xtype",
-         "* init" : " this.el.add_attribute(_this.cellrender.el , \"markup\", 1 );  \n  ",
-         "xtype" : "ComboBox",
-         "* pack" : "pack_end,true,true,3",
          "$ xns" : "Gtk",
+         "* init" : [
+          " this.el.add_attribute(_this.cellrender.el , \"markup\", 1 );  ",
+          "  "
+         ],
+         "* pack" : "pack_end,true,true,3",
+         "id" : "xtype",
          "items" : [
           {
-           "id" : "cellrender",
+           "$ xns" : "Gtk",
            "* pack" : "pack_start,true",
-           "xtype" : "CellRendererText",
-           "$ xns" : "Gtk"
+           "id" : "cellrender",
+           "xtype" : "CellRendererText"
           },
           {
-           "id" : "model",
-           "xtype" : "ListStore",
-           "* pack" : "set_model",
            "$ columns" : "typeof(string),typeof(string)",
-           "n_columns" : 2,
            "$ xns" : "Gtk",
-           "| void loadData" : "  ( ) {\n        this.el.clear();\n                      \n        Gtk.TreeIter iter;\n                \n        el.append(out iter);\n        el.set_value(iter, 0, \"Roo\");\n        el.set_value(iter, 1, \"Roo Project\");\n        \n        el.append(out iter);\n        el.set_value(iter, 0, \"Gtk\");\n        el.set_value(iter, 1, \"Gtk Project\");\n         \n        el.append(out iter);\n        el.set_value(iter, 0, \"Flutter\");\n        el.set_value(iter, 1, \"Flutter Project\");\n              \n                                     \n}\n"
+           "* pack" : "set_model",
+           "id" : "model",
+           "n_columns" : 2,
+           "xtype" : "ListStore",
+           "| void loadData" : [
+            "  ( ) {",
+            "        this.el.clear();",
+            "                      ",
+            "        Gtk.TreeIter iter;",
+            "                ",
+            "        el.append(out iter);",
+            "        el.set_value(iter, 0, \"Roo\");",
+            "        el.set_value(iter, 1, \"Roo Project\");",
+            "        ",
+            "        el.append(out iter);",
+            "        el.set_value(iter, 0, \"Gtk\");",
+            "        el.set_value(iter, 1, \"Gtk Project\");",
+            "         ",
+            "        el.append(out iter);",
+            "        el.set_value(iter, 0, \"Flutter\");",
+            "        el.set_value(iter, 1, \"Flutter Project\");",
+            "              ",
+            "                                     ",
+            "}",
+            ""
+           ]
           }
+         ],
+         "xtype" : "ComboBox",
+         "| string getValue" : [
+          " () {",
+          "     var ix = this.el.get_active();",
+          "        if (ix < 0 ) {",
+          "            return \"\";",
+          "        }",
+          "        switch(ix) {",
+          "            case 0:",
+          "                return \"Roo\";",
+          "            case 1:",
+          "                return \"Gtk\";",
+          "           case 2:",
+          "                return \"Flutter\";",
+          "        }",
+          "        return \"\";",
+          "}",
+          ""
          ]
         }
-       ]
+       ],
+       "xtype" : "Box"
       },
       {
-       "$ create_folders" : false,
-       "id" : "dir",
        "$ action" : "Gtk.FileChooserAction.SELECT_FOLDER",
-       "bool expand" : true,
-       "* pack" : "pack_end,true,true,5",
-       "xtype" : "FileChooserWidget",
+       "$ create_folders" : false,
+       "$ select_multiple" : false,
        "$ xns" : "Gtk",
-       "$ select_multiple" : false
+       "* pack" : "pack_end,true,true,5",
+       "bool expand" : true,
+       "id" : "dir",
+       "xtype" : "FileChooserWidget"
       }
-     ]
+     ],
+     "xtype" : "Box"
     },
     {
-     "label" : "OK",
+     "$ xns" : "Gtk",
      "* pack" : "add_action_widget,1",
-     "xtype" : "Button",
-     "$ xns" : "Gtk"
+     "label" : "OK",
+     "xtype" : "Button"
     },
     {
-     "label" : "Cancel",
-     "xtype" : "Button",
+     "$ xns" : "Gtk",
      "* pack" : "add_action_widget,0",
-     "$ xns" : "Gtk"
+     "label" : "Cancel",
+     "xtype" : "Button"
     }
+   ],
+   "listeners" : {
+    "destroy_event" : [
+     "(self, event) => {",
+     "\tthis.el.response(0);",
+     "//     this.el.hide();",
+     "    return false;",
+     "}"
+    ]
+   },
+   "name" : "EditProject",
+   "title" : "Project Properties",
+   "xtype" : "Dialog",
+   "| Project.Project? show" : [
+    "() {",
+    "      ",
+    "",
+    "    //[ 'xtype'  ].forEach(function(k) {",
+    "    //    _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]);",
+    "    //});",
+    "\t// shouild set path..",
+    "    _this.model.loadData();",
+    "    this.el.show_all();",
+    "    ",
+    "    var err_dialog = StandardErrorDialog.singleton();",
+    "",
+    "    var id = -1;",
+    "    while (id < 0) {",
+    "         id =  this.el.run();",
+    "         if (id < 1) {",
+    "                this.el.hide();",
+    "                return null;",
+    "        }",
+    " ",
+    "         ",
+    "      if (_this.xtype.getValue().length < 1) {",
+    "           ",
+    "            err_dialog.show(_this.el,\"You have to set Project type\");             ",
+    "            id = -1;",
+    "            continue;",
+    "        }",
+    "        if (_this.dir.el.get_filename().length < 1) {",
+    "",
+    "            err_dialog.show(_this.el,\"You have to select a folder\");             ",
+    "            id = -1;",
+    "            continue;",
+    "        }",
+    "           ",
+    "    }",
+    "    ",
+    "    this.el.hide();",
+    "    ",
+    "    ",
+    "    ",
+    " ",
+    "    var fn = _this.dir.el.get_filename();",
+    "    print(\"add %s\\n\" , fn);",
+    "    ",
+    "    var project = Project.Project.factory(_this.xtype.getValue(), fn);",
+    "    project.save();",
+    "    Project.projects.set(project.name,project);",
+    "    ",
+    "    //var pr = imports.Builder.Provider.ProjectManager.ProjectManager.update(this.project);",
+    "    ",
+    "    return project;",
+    "",
+    "    ",
+    "    //this.success = c.success;",
+    "}",
+    ""
    ]
   }
- ]
+ ],
+ "modOrder" : "",
+ "name" : "EditProject",
+ "parent" : "",
+ "path" : "/home/alan/gitlive/roobuilder/src/Builder4/EditProject.bjs",
+ "permname" : "",
+ "title" : ""
 }
\ No newline at end of file
index 200de80..cc2c996 100644 (file)
@@ -2,7 +2,7 @@
  "build_module" : "builder",
  "items" : [
   {
-   "# JsRender.JsRender file" : "null",
+   "# JsRender.JsRender? file" : "null",
    "# JsRender.Node node" : "null",
    "# Xcls_MainWindow window" : "null",
    "# bool dirty" : false,
    "|   void show" : [
     "(JsRender.JsRender file, JsRender.Node? node, string ptype, string key)",
     "{",
+    "    this.reset();",
     "    this.file = file;    ",
-    "    this.ptype = \"\";",
-    "    this.key  = \"\";",
-    "    this.node = null;",
-    "\tthis.searchcontext = null;",
     "    ",
     "    if (file.xtype != \"PlainFile\") {",
     "    ",
     "}",
     ""
    ],
+   "| void reset" : [
+    "() {",
+    "\t this.file = null;    ",
+    "    this.ptype = \"\";",
+    "    this.key  = \"\";",
+    "    this.node = null;",
+    "\tthis.searchcontext = null;",
+    "  ",
+    "}",
+    ""
+   ],
    "| void scroll_to_line" : [
     "(int line) {",
     "",
index 116ac42..95cc02a 100644 (file)
@@ -25,9 +25,9 @@ public class Editor : Object
     public int pos_root_y;
     public string ptype;
     public int last_search_end;
+    public JsRender.JsRender? file;
     public string key;
     public Gtk.SourceSearchContext searchcontext;
-    public JsRender.JsRender file;
     public bool pos;
     public bool dirty;
     public signal void save ();
@@ -44,9 +44,9 @@ public class Editor : Object
         this.activeEditor = "";
         this.ptype = "";
         this.last_search_end = 0;
+        this.file = null;
         this.key = "";
         this.searchcontext = null;
-        this.file = null;
         this.pos = false;
         this.dirty = false;
         this.node = null;
@@ -139,11 +139,8 @@ public class Editor : Object
     }
     public   void show (JsRender.JsRender file, JsRender.Node? node, string ptype, string key)
     {
+        this.reset();
         this.file = file;    
-        this.ptype = "";
-        this.key  = "";
-        this.node = null;
-       this.searchcontext = null;
         
         if (file.xtype != "PlainFile") {
         
@@ -189,6 +186,14 @@ public class Editor : Object
                this.view.el.scroll_to_iter(st,  0.1f, true, 0.0f, 0.5f);
        }
      
+    }
+    public void reset () {
+        this.file = null;    
+        this.ptype = "";
+        this.key  = "";
+        this.node = null;
+       this.searchcontext = null;
+      
     }
     public class Xcls_Box2 : Object
     {
index c59b8e4..0c4f9bb 100644 (file)
@@ -1,19 +1,79 @@
 {
-    "name" : "GladeView",
-    "parent" : "",
-    "title" : "",
-    "path" : "/home/alan/gitlive/app.Builder.js/Builder4/GladeView.bjs",
-    "permname" : "",
-    "modOrder" : "",
-    "items" : [
-        {
-            "* ctor" : "new Glade.DesignView(new Glade.Project())",
-            "id" : "GladeView",
-            "| void createThumb" : "() {\n    \n    \n    if (this.file == null) {\n        return;\n    }\n    var filename = this.file.getIconFileName(false);\n    \n    var  win = this.el.get_parent_window();\n    var width = win.get_width();\n    var height = win.get_height();\n\n    Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?\n\n    screenshot.save(filename,\"png\");\n    return;\n    \n    \n    \n    \n    \n     \n    \n    // should we hold until it's printed...\n    \n      \n\n    \n    \n\n\n    \n     \n}\n",
-            "| void loadFile" : "(JsRender.JsRender file)\n{\n    \n\n    this.file = file;\n    \n\n        // clear existing elements from project?\n        \n        var  p = this.el.get_project();\n        var    li = p.get_objects().copy();\n        // should remove all..\n        for (var i =0;    i < li.length(); i++) {   \n            p.remove_object(li.nth_data(i)); \n        }\n\n        if (file.tree == null) {\n            return;\n        }\n\n//        print(\"%s\\n\",tf.tree.toJsonString());\n\tvar x = new JsRender.NodeToGlade(file.tree,  \"\");\n\n\t \n\tFileIOStream iostream;\n\tvar  f = File.new_tmp (\"tpl-XXXXXX.glade\", out iostream);\n\tvar ostream = iostream.output_stream;\n\tvar dostream = new DataOutputStream (ostream);\n\tdostream.put_string (x.munge());\n\tthis.el.show();\n\t print(\"LOADING %s\\n\",f.get_path ());\n        p.load_from_file(f.get_path ());\n        \n \n\n}",
-            "xtype" : "DesignView",
-            "# JsRender.JsRender file" : "null",
-            "$ xns" : "Glade"
-        }
-    ]
+ "build_module" : "",
+ "items" : [
+  {
+   "# JsRender.JsRender file" : "null",
+   "$ xns" : "Glade",
+   "* ctor" : "new Glade.DesignView(new Glade.Project())",
+   "id" : "GladeView",
+   "xtype" : "DesignView",
+   "| void createThumb" : [
+    "() {",
+    "    ",
+    "    ",
+    "    if (this.file == null) {",
+    "        return;",
+    "    }",
+    "    var filename = this.file.getIconFileName(false);",
+    "    ",
+    "    var  win = this.el.get_parent_window();",
+    "    var width = win.get_width();",
+    "    var height = win.get_height();",
+    "",
+    "    Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?",
+    "",
+    "    screenshot.save(filename,\"png\");",
+    "    return;",
+    "    ",
+    "    ",
+    "     ",
+    "}",
+    ""
+   ],
+   "| void loadFile" : [
+    "(JsRender.JsRender file)",
+    "{",
+    "    ",
+    "",
+    "    this.file = file;",
+    "    ",
+    "",
+    "        // clear existing elements from project?",
+    "        ",
+    "        var  p = this.el.get_project();",
+    "        var    li = p.get_objects().copy();",
+    "        // should remove all..",
+    "        for (var i =0;    i < li.length(); i++) {   ",
+    "            p.remove_object(li.nth_data(i)); ",
+    "        }",
+    "",
+    "        if (file.tree == null) {",
+    "            return;",
+    "        }",
+    "",
+    "//        print(\"%s\\n\",tf.tree.toJsonString());",
+    "\tvar x =  JsRender.NodeToGlade(file.project, file.tree,  null);",
+    "",
+    "\t ",
+    "",
+    "\tvar  f = File.new_tmp (\"tpl-XXXXXX.glade\", out iostream);",
+    "\tvar ostream = iostream.output_stream;",
+    "\tvar dostream = new DataOutputStream (ostream);",
+    "\tdostream.put_string (x.munge());",
+    "\tthis.el.show();",
+    "\t print(\"LOADING %s\\n\",f.get_path ());",
+    "      p.load_from_file(f.get_path ());",
+    "        ",
+    " ",
+    "",
+    "}"
+   ]
+  }
+ ],
+ "modOrder" : "",
+ "name" : "GladeView",
+ "parent" : "",
+ "path" : "/home/alan/gitlive/roobuilder/src/Builder4/GladeView.bjs",
+ "permname" : "",
+ "title" : ""
 }
\ No newline at end of file
index 921ac96..e0ee544 100644 (file)
@@ -1,6 +1,6 @@
 static Xcls_GladeView  _GladeView;
 
-public class Xcls_GladeView : Object 
+public class Xcls_GladeView : Object
 {
     public Glade.DesignView el;
     private Xcls_GladeView  _this;
@@ -16,7 +16,7 @@ public class Xcls_GladeView : Object
         // my vars (def)
     public JsRender.JsRender file;
 
-    // ctor 
+    // ctor
     public Xcls_GladeView()
     {
         _this = this;
@@ -28,7 +28,7 @@ public class Xcls_GladeView : Object
         // set gobject values
     }
 
-    // user defined functions 
+    // user defined functions
     public void createThumb () {
         
         
@@ -47,20 +47,6 @@ public class Xcls_GladeView : Object
         return;
         
         
-        
-        
-        
-         
-        
-        // should we hold until it's printed...
-        
-          
-    
-        
-        
-    
-    
-        
          
     }
     public void loadFile (JsRender.JsRender file)
@@ -84,17 +70,17 @@ public class Xcls_GladeView : Object
             }
     
     //        print("%s\n",tf.tree.toJsonString());
-       var x = new JsRender.NodeToGlade(file.tree,  "");
+       var x =  JsRender.NodeToGlade(file.project, file.tree,  null);
     
         
-       FileIOStream iostream;
+    
        var  f = File.new_tmp ("tpl-XXXXXX.glade", out iostream);
        var ostream = iostream.output_stream;
        var dostream = new DataOutputStream (ostream);
        dostream.put_string (x.munge());
        this.el.show();
         print("LOADING %s\n",f.get_path ());
-            p.load_from_file(f.get_path ());
+          p.load_from_file(f.get_path ());
             
      
     
diff --git a/src/Builder4/GladeuiView.bjs b/src/Builder4/GladeuiView.bjs
new file mode 100644 (file)
index 0000000..e86094a
--- /dev/null
@@ -0,0 +1,609 @@
+{
+ "build_module" : "",
+ "items" : [
+  {
+   "# Gtk.Widget lastObj" : "null",
+   "# JsRender.JsRender file" : "null",
+   "# Xcls_MainWindow main_window" : "",
+   "$ xns" : "Gtk",
+   "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
+   "Gtk.SourceSearchContext searchcontext" : "",
+   "bool hexpand" : true,
+   "bool vexpand" : true,
+   "id" : "GladeuiView",
+   "int height" : 0,
+   "int last_search_end" : 0,
+   "int width" : 0,
+   "items" : [
+    {
+     "$ xns" : "Gtk",
+     "* pack" : "pack_start,true,true,0",
+     "id" : "notebook",
+     "items" : [
+      {
+       "$ xns" : "Gtk",
+       "* pack" : false,
+       "id" : "label_preview",
+       "utf8 label" : "Preview",
+       "xtype" : "Label"
+      },
+      {
+       "$ xns" : "Gtk",
+       "* pack" : false,
+       "id" : "label_code",
+       "utf8 label" : "Preview Generated Code",
+       "xtype" : "Label"
+      },
+      {
+       "# JsRender.JsRender file" : "null",
+       "$ xns" : "Glade",
+       "* ctor" : "_this.main_window == null ? null : new Glade.DesignView(_this.main_window.gladeproject)",
+       "* init" : [
+        " ",
+        "this.el.show();",
+        ""
+       ],
+       "* pack" : false,
+       "id" : "designview",
+       "xtype" : "DesignView",
+       "| void createThumb" : [
+        "() {",
+        "    ",
+        "    ",
+        "    if (this.file == null) {",
+        "        return;",
+        "    }",
+        "    var filename = this.file.getIconFileName(false);",
+        "    ",
+        "    var  win = this.el.get_parent_window();",
+        "    var width = win.get_width();",
+        "    var height = win.get_height();",
+        "",
+        "    Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?",
+        "",
+        "    screenshot.save(filename,\"png\");",
+        "    return;",
+        "    ",
+        "    ",
+        "     ",
+        "}",
+        ""
+       ]
+      },
+      {
+       "$ xns" : "Gtk",
+       "* init" : [
+        "{",
+        "   ",
+        "    var description =   Pango.FontDescription.from_string(\"monospace\");",
+        "    description.set_size(8000);",
+        "    this.el.override_font(description);",
+        "",
+        "    this.loading = true;",
+        "    var buf = this.el.get_buffer();",
+        "    buf.notify.connect((ps) => {",
+        "        if (this.loading) {",
+        "            return;",
+        "        }",
+        "        if (ps.name != \"cursor-position\") {",
+        "            return;",
+        "        }",
+        "        print(\"cursor changed : %d\\n\", buf.cursor_position);",
+        "        Gtk.TextIter cpos;",
+        "        buf.get_iter_at_offset(out cpos, buf.cursor_position);",
+        "        ",
+        "        var ln = cpos.get_line();",
+        " ",
+        "        var node = _this.file.lineToNode(ln);",
+        " ",
+        "        if (node == null) {",
+        "            print(\"can not find node\\n\");",
+        "            return;",
+        "        }",
+        "        var ltree = _this.main_window.windowstate.left_tree;",
+        "        var tp = ltree.model.treePathFromNode(node);",
+        "        print(\"got tree path %s\\n\", tp);",
+        "        if (tp != \"\") {",
+        "\t       this.allow_node_scroll = false;        ",
+        "\t       print(\"changing cursor on tree..\\n\");",
+        "            ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false);",
+        "            // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
+        "            GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {",
+        "\t            this.allow_node_scroll = true;",
+        "\t            return false;",
+        "            });",
+        "        }",
+        "        ",
+        "        // highlight the node..",
+        "        ",
+        "    });",
+        "  ",
+        "  ",
+        "  ",
+        "    var attrs = new Gtk.SourceMarkAttributes();",
+        "    var  pink =   Gdk.RGBA();",
+        "    pink.parse ( \"pink\");",
+        "    attrs.set_background ( pink);",
+        "    attrs.set_icon_name ( \"process-stop\");    ",
+        "    attrs.query_tooltip_text.connect(( mark) => {",
+        "        //print(\"tooltip query? %s\\n\", mark.name);",
+        "        return mark.name;",
+        "    });",
+        "    ",
+        "    this.el.set_mark_attributes (\"ERR\", attrs, 1);",
+        "    ",
+        "     var wattrs = new Gtk.SourceMarkAttributes();",
+        "    var  blue =   Gdk.RGBA();",
+        "    blue.parse ( \"#ABF4EB\");",
+        "    wattrs.set_background ( blue);",
+        "    wattrs.set_icon_name ( \"process-stop\");    ",
+        "    wattrs.query_tooltip_text.connect(( mark) => {",
+        "        //print(\"tooltip query? %s\\n\", mark.name);",
+        "        return mark.name;",
+        "    });",
+        "    ",
+        "    this.el.set_mark_attributes (\"WARN\", wattrs, 1);",
+        "    ",
+        " ",
+        "    ",
+        "     var dattrs = new Gtk.SourceMarkAttributes();",
+        "    var  purple =   Gdk.RGBA();",
+        "    purple.parse ( \"#EEA9FF\");",
+        "    dattrs.set_background ( purple);",
+        "    dattrs.set_icon_name ( \"process-stop\");    ",
+        "    dattrs.query_tooltip_text.connect(( mark) => {",
+        "        //print(\"tooltip query? %s\\n\", mark.name);",
+        "        return mark.name;",
+        "    });",
+        "    ",
+        "    this.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
+        "    ",
+        "    ",
+        "    var gattrs = new Gtk.SourceMarkAttributes();",
+        "    var  grey =   Gdk.RGBA();",
+        "    grey.parse ( \"#ccc\");",
+        "    gattrs.set_background ( grey);",
+        " ",
+        "    ",
+        "    this.el.set_mark_attributes (\"grey\", gattrs, 1);",
+        "    ",
+        "    ",
+        "    ",
+        "    ",
+        "    ",
+        "    ",
+        "}",
+        " "
+       ],
+       "* pack" : "append_page,_this.label_code.el",
+       "bool allow_node_scroll" : true,
+       "bool loading" : true,
+       "gboolean editable" : false,
+       "gboolean show_line_marks" : true,
+       "gboolean show_line_numbers" : true,
+       "id" : "sourceview",
+       "xtype" : "SourceView",
+       "| string toString" : [
+        "() {",
+        "   Gtk.TextIter s;",
+        "    Gtk.TextIter e;",
+        "    this.el.get_buffer().get_start_iter(out s);",
+        "    this.el.get_buffer().get_end_iter(out e);",
+        "    var ret = this.el.get_buffer().get_text(s,e,true);",
+        "    //print(\"TO STRING? \" + ret);",
+        "    return ret;",
+        "}",
+        ""
+       ],
+       "| void highlightErrorsJson" : [
+        " (string type, Json.Object obj) {",
+        "      Gtk.TextIter start;",
+        "     Gtk.TextIter end;   ",
+        "     ",
+        "     var buf =  this.el.get_buffer();",
+        "       var sbuf = (Gtk.SourceBuffer)buf;",
+        "        buf.get_bounds (out start, out end);",
+        "        ",
+        "        sbuf.remove_source_marks (start, end, type);",
+        "                 ",
+        "     ",
+        "     // we should highlight other types of errors..",
+        "    ",
+        "    if (!obj.has_member(type)) {",
+        "        print(\"Return has no errors\\n\");",
+        "        return  ;",
+        "    }",
+        "    var err = obj.get_object_member(type);",
+        "    ",
+        "    if (_this.file == null) { ",
+        "        return; // just in case the file has not loaded yet?",
+        "    }",
+        " ",
+        "",
+        "    var valafn = \"\";",
+        "      try {             ",
+        "           var  regex = new Regex(\"\\\\.bjs$\");",
+        "        ",
+        "         ",
+        "            valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
+        "         } catch (GLib.RegexError e) {",
+        "            return;",
+        "        }   ",
+        "",
+        "   if (!err.has_member(valafn)) {",
+        "        print(\"File path has no errors\\n\");",
+        "        return  ;",
+        "    }",
+        "    var lines = err.get_object_member(valafn);",
+        "    ",
+        "   ",
+        "    ",
+        "    var tlines = buf.get_line_count () +1;",
+        "    ",
+        "    lines.foreach_member((obj, line, node) => {",
+        "        ",
+        "             Gtk.TextIter iter;",
+        "    //        print(\"get inter\\n\");",
+        "            var eline = int.parse(line) -1  ;",
+        "            print(\"GOT ERROR on line %s -- converted to %d\\n\", line,eline);",
+        "            ",
+        "            ",
+        "            if (eline > tlines || eline < 0) {",
+        "                return;",
+        "            }",
+        "            sbuf.get_iter_at_line( out iter, eline);",
+        "            //print(\"mark line\\n\");",
+        "            var msg  = type + \" on line: %d - %s\".printf(eline+1, valafn);",
+        "            var ar = lines.get_array_member(line);",
+        "            for (var i = 0 ; i < ar.get_length(); i++) {",
+        "\t\t    msg += (msg.length > 0) ? \"\\n\" : \"\";",
+        "\t\t    msg += ar.get_string_element(i);",
+        "\t    }",
+        "            ",
+        "            ",
+        "            sbuf.create_source_mark(msg, type, iter);",
+        "        } );",
+        "        return  ;",
+        "    ",
+        " ",
+        "",
+        "",
+        "}"
+       ],
+       "| void loadFile" : [
+        "( ) {",
+        "",
+        "    ",
+        "    this.loading = true;",
+        "    var buf = this.el.get_buffer();",
+        "    buf.set_text(\"\",0);",
+        "    var sbuf = (Gtk.SourceBuffer) buf;",
+        "",
+        "    ",
+        "",
+        "    if (_this.file == null || _this.file.xtype != \"Gtk\") {",
+        "        print(\"xtype != Gtk\");",
+        "        this.loading = false;",
+        "        return;",
+        "    }",
+        "    ",
+        "    var valafn = \"\";",
+        "      try {             ",
+        "           var  regex = new Regex(\"\\\\.bjs$\");",
+        "        ",
+        "         ",
+        "            valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
+        "         } catch (GLib.RegexError e) {",
+        "             this.loading = false;",
+        "            return;",
+        "        }   ",
+        "    ",
+        "",
+        "   if (!FileUtils.test(valafn,FileTest.IS_REGULAR) ) {",
+        "        print(\"File path has no errors\\n\");",
+        "        this.loading = false;",
+        "        return  ;",
+        "    }",
+        "    ",
+        "    string str;",
+        "    try {",
+        "    ",
+        "        GLib.FileUtils.get_contents (valafn, out str);",
+        "    } catch (Error e) {",
+        "        this.loading = false;",
+        "        return  ;",
+        "    }",
+        "",
+        "//    print(\"setting str %d\\n\", str.length);",
+        "    buf.set_text(str, str.length);",
+        "    var lm = Gtk.SourceLanguageManager.get_default();",
+        "     ",
+        "    //?? is javascript going to work as js?",
+        "    ",
+        "    ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));",
+        "  ",
+        "    ",
+        "    Gtk.TextIter start;",
+        "    Gtk.TextIter end;     ",
+        "        ",
+        "    sbuf.get_bounds (out start, out end);",
+        "    sbuf.remove_source_marks (start, end, null); // remove all marks..",
+        "    ",
+        "    ",
+        "    if (_this.main_window.windowstate.last_compile_result != null) {",
+        "        var obj = _this.main_window.windowstate.last_compile_result;",
+        "        this.highlightErrorsJson(\"ERR\", obj);",
+        "        this.highlightErrorsJson(\"WARN\", obj);",
+        "        this.highlightErrorsJson(\"DEPR\", obj);\t\t\t",
+        "    }",
+        "    //while (Gtk.events_pending()) {",
+        "     //   Gtk.main_iteration();",
+        "   // }",
+        "    ",
+        "    this.loading = false; ",
+        "}",
+        ""
+       ],
+       "| void nodeSelected" : [
+        "(JsRender.Node? sel) {",
+        "  ",
+        "    ",
+        "  ",
+        "    // this is connected in widnowstate",
+        "    print(\"Roo-view - node selected\\n\");",
+        "    var buf = this.el.get_buffer();",
+        " ",
+        "    var sbuf = (Gtk.SourceBuffer) buf;",
+        "",
+        "   ",
+        "    while(Gtk.events_pending()) {",
+        "        Gtk.main_iteration();",
+        "    }",
+        "    ",
+        "   ",
+        "    // clear all the marks..",
+        "     Gtk.TextIter start;",
+        "    Gtk.TextIter end;     ",
+        "        ",
+        "    sbuf.get_bounds (out start, out end);",
+        "    sbuf.remove_source_marks (start, end, \"grey\");",
+        "    ",
+        "    ",
+        "     if (sel == null) {",
+        "        // no highlighting..",
+        "        return;",
+        "    }",
+        "    Gtk.TextIter iter;   ",
+        "    sbuf.get_iter_at_line(out iter,  sel.line_start);",
+        "    ",
+        "    ",
+        "    Gtk.TextIter cur_iter;",
+        "    sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
+        "    ",
+        "    //var cur_line = cur_iter.get_line();",
+        "    //if (cur_line > sel.line_start && cur_line < sel.line_end) {",
+        "    ",
+        "    //} else {",
+        "    if (this.allow_node_scroll) {",
+        "\t\t ",
+        "    \tthis.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.5f);",
+        "\t}",
+        "    ",
+        "     ",
+        "    ",
+        "    for (var i = 0; i < buf.get_line_count();i++) {",
+        "        if (i < sel.line_start || i > sel.line_end) {",
+        "           ",
+        "            sbuf.get_iter_at_line(out iter, i);",
+        "            sbuf.create_source_mark(null, \"grey\", iter);",
+        "            ",
+        "        }",
+        "    ",
+        "    }",
+        "    ",
+        "",
+        "}",
+        ""
+       ]
+      }
+     ],
+     "xtype" : "Notebook"
+    }
+   ],
+   "listeners" : {
+    "size_allocate" : [
+     "(aloc) => {",
+     " ",
+     "    this.width = aloc.width;",
+     "    this.height =aloc.height;",
+     "}",
+     " "
+    ]
+   },
+   "xtype" : "Box",
+   "| int search" : [
+    "(string txt) {",
+    "\tthis.notebook.el.page = 1;",
+    " \tvar s = new Gtk.SourceSearchSettings();",
+    "\tvar buf = (Gtk.SourceBuffer) this.sourceview.el.get_buffer();",
+    "\tthis.searchcontext = new Gtk.SourceSearchContext(buf,s);",
+    "\tthis.searchcontext.set_highlight(true);",
+    "\ts.set_search_text(txt);",
+    "\t",
+    "\tGtk.TextIter beg, st,en;",
+    "\t ",
+    "\tbuf.get_start_iter(out beg);",
+    "\tthis.searchcontext.forward(beg, out st, out en);",
+    "\tthis.last_search_end  = 0;",
+    "\treturn this.searchcontext.get_occurrences_count();",
+    "",
+    "   ",
+    "}",
+    ""
+   ],
+   "| void createThumb" : [
+    "() {",
+    "    ",
+    "    ",
+    "    if (this.file == null) {",
+    "        return;",
+    "    }",
+    "    // only screenshot the gtk preview..",
+    "    if (this.notebook.el.page > 0 ) {",
+    "        return;",
+    "    }",
+    "    ",
+    "    ",
+    "    var filename = this.file.getIconFileName(false);",
+    "    ",
+    "    var  win = this.designview.el.get_parent_window();",
+    "    var width = win.get_width();",
+    "    var height = win.get_height();",
+    "    try {",
+    "         Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?",
+    "         screenshot.save(filename,\"png\");",
+    "    } catch (Error e) {",
+    "        ",
+    "    }",
+    "",
+    "   ",
+    "    return;",
+    "    ",
+    "    ",
+    "     ",
+    "     ",
+    "    ",
+    "    // should we hold until it's printed...",
+    "    ",
+    "      ",
+    "",
+    "    ",
+    "    ",
+    "",
+    "",
+    "    ",
+    "     ",
+    "}",
+    ""
+   ],
+   "| void forwardSearch" : [
+    "(bool change_focus) {",
+    "",
+    "\tif (this.searchcontext == null) {",
+    "\t\treturn;",
+    "\t}",
+    "\tthis.notebook.el.page = 1;",
+    "\tGtk.TextIter beg, st,en, stl;",
+    "\t",
+    "\tvar buf = this.sourceview.el.get_buffer();",
+    "\tbuf.get_iter_at_offset(out beg, this.last_search_end);",
+    "\tif (!this.searchcontext.forward(beg, out st, out en)) {",
+    "\t\tthis.last_search_end = 0;",
+    "\t} else { ",
+    "\t\tthis.last_search_end = en.get_offset();",
+    "\t\tif (change_focus) {",
+    "\t\t\tthis.sourceview.el.grab_focus();\t",
+    "\t\t}",
+    "\t\tbuf.place_cursor(st);",
+    "\t\tvar ln = st.get_line();",
+    "\t\tbuf.get_iter_at_line(out stl,ln);",
+    "\t\t ",
+    "\t\tthis.sourceview.el.scroll_to_iter(stl,  0.0f, true, 0.0f, 0.5f);",
+    "\t}",
+    "",
+    "}",
+    ""
+   ],
+   "| void initGlade" : [
+    "() {",
+    "\t _this.designview =  new Xcls_designview( _this );",
+    "\t ",
+    "\t var box = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);",
+    "\t ",
+    "\t _this.notebook.el.append_page(box, _this.label_preview.el);",
+    "\t     Glade.App.set_window(this.main_window.el);",
+    "\t// var  pal = new Glade.Palette();",
+    "    //var ins = new Glade.Inspector();",
+    "",
+    "\t box.pack_start(_this.designview.el);",
+    "\t// box.pack_start(pal);",
+    "\t //box.pack_start(ins);",
+    "\t  // pal.show();",
+    "   // ins.show();",
+    "    _this.designview.el.show();",
+    "\t box.show_all();\t ",
+    "\t ",
+    "} ",
+    ""
+   ],
+   "| void loadFile" : [
+    "(JsRender.JsRender file)",
+    "{",
+    "    ",
+    "",
+    "    this.file = file;",
+    "    ",
+    "",
+    "        // clear existing elements from project?",
+    "        ",
+    "        var  p = this.designview.el.get_project();",
+    "        var    li = p.get_objects().copy();",
+    "        // should remove all..",
+    "        for (var i =0;    i < li.length(); i++) {   ",
+    "            p.remove_object(li.nth_data(i)); ",
+    "        }",
+    "",
+    "        if (file.tree == null) {",
+    "            return;",
+    "        }",
+    "",
+    "//        print(\"%s\\n\",tf.tree.toJsonString());",
+    "\tvar x =  new JsRender.NodeToGlade((Project.Gtk) file.project, file.tree,  null);",
+    "    Glade.App.set_window(_this.main_window.el); // see if setting it again forces it to go to the irght locations.",
+    "\t ",
+    "FileIOStream iostream;",
+    "\tvar  f = File.new_tmp (\"tpl-XXXXXX.glade\", out iostream);",
+    "\tvar ostream = iostream.output_stream;",
+    "\tvar dostream = new DataOutputStream (ostream);",
+    "\tdostream.put_string (x.munge());",
+    "\tthis.el.show();",
+    "\t print(\"LOADING %s\\n\",f.get_path ());",
+    "      //p.load_from_file(f.get_path ());",
+    "        ",
+    "     p.load_from_file(\"/tmp/glade.xml\");",
+    "",
+    "}"
+   ],
+   "| void scroll_to_line" : [
+    "(int line) {",
+    "   this.notebook.el.page = 1;// code preview...",
+    "   ",
+    "   GLib.Timeout.add(500, () => {",
+    "   ",
+    "   ",
+    "\t   ",
+    "\t   ",
+    "\t\t  var buf = this.sourceview.el.get_buffer();",
+    "\t ",
+    "\t\tvar sbuf = (Gtk.SourceBuffer) buf;",
+    "",
+    "",
+    "\t\tGtk.TextIter iter;   ",
+    "\t\tsbuf.get_iter_at_line(out iter,  line);",
+    "\t\tthis.sourceview.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.5f);",
+    "\t\treturn false;",
+    "\t});   ",
+    "",
+    "   ",
+    "}",
+    ""
+   ]
+  }
+ ],
+ "modOrder" : "",
+ "name" : "GladeuiView",
+ "parent" : "",
+ "path" : "/home/alan/gitlive/roobuilder/src/Builder4/GladeuiView.bjs",
+ "permname" : "",
+ "title" : ""
+}
\ No newline at end of file
diff --git a/src/Builder4/GladeuiView.vala b/src/Builder4/GladeuiView.vala
new file mode 100644 (file)
index 0000000..fcb43e0
--- /dev/null
@@ -0,0 +1,690 @@
+static Xcls_GladeuiView  _GladeuiView;
+
+public class Xcls_GladeuiView : Object
+{
+    public Gtk.Box el;
+    private Xcls_GladeuiView  _this;
+
+    public static Xcls_GladeuiView singleton()
+    {
+        if (_GladeuiView == null) {
+            _GladeuiView= new Xcls_GladeuiView();
+        }
+        return _GladeuiView;
+    }
+    public Xcls_notebook notebook;
+    public Xcls_label_preview label_preview;
+    public Xcls_label_code label_code;
+    public Xcls_designview designview;
+    public Xcls_sourceview sourceview;
+
+        // my vars (def)
+    public Gtk.Widget lastObj;
+    public int last_search_end;
+    public int width;
+    public Gtk.SourceSearchContext searchcontext;
+    public JsRender.JsRender file;
+    public int height;
+    public Xcls_MainWindow main_window;
+
+    // ctor
+    public Xcls_GladeuiView()
+    {
+        _this = this;
+        this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
+
+        // my vars (dec)
+        this.lastObj = null;
+        this.last_search_end = 0;
+        this.width = 0;
+        this.file = null;
+        this.height = 0;
+
+        // set gobject values
+        this.el.hexpand = true;
+        this.el.vexpand = true;
+        var child_0 = new Xcls_notebook( _this );
+        child_0.ref();
+        this.el.pack_start (  child_0.el , true,true,0 );
+
+        //listeners
+        this.el.size_allocate.connect( (aloc) => {
+         
+            this.width = aloc.width;
+            this.height =aloc.height;
+        });
+    }
+
+    // user defined functions
+    public void scroll_to_line (int line) {
+       this.notebook.el.page = 1;// code preview...
+       
+       GLib.Timeout.add(500, () => {
+       
+       
+          
+          
+                 var buf = this.sourceview.el.get_buffer();
+        
+               var sbuf = (Gtk.SourceBuffer) buf;
+    
+    
+               Gtk.TextIter iter;   
+               sbuf.get_iter_at_line(out iter,  line);
+               this.sourceview.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.5f);
+               return false;
+       });   
+    
+       
+    }
+    public int search (string txt) {
+       this.notebook.el.page = 1;
+       var s = new Gtk.SourceSearchSettings();
+       var buf = (Gtk.SourceBuffer) this.sourceview.el.get_buffer();
+       this.searchcontext = new Gtk.SourceSearchContext(buf,s);
+       this.searchcontext.set_highlight(true);
+       s.set_search_text(txt);
+       
+       Gtk.TextIter beg, st,en;
+        
+       buf.get_start_iter(out beg);
+       this.searchcontext.forward(beg, out st, out en);
+       this.last_search_end  = 0;
+       return this.searchcontext.get_occurrences_count();
+    
+       
+    }
+    public void createThumb () {
+        
+        
+        if (this.file == null) {
+            return;
+        }
+        // only screenshot the gtk preview..
+        if (this.notebook.el.page > 0 ) {
+            return;
+        }
+        
+        
+        var filename = this.file.getIconFileName(false);
+        
+        var  win = this.designview.el.get_parent_window();
+        var width = win.get_width();
+        var height = win.get_height();
+        try {
+             Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?
+             screenshot.save(filename,"png");
+        } catch (Error e) {
+            
+        }
+    
+       
+        return;
+        
+        
+         
+         
+        
+        // should we hold until it's printed...
+        
+          
+    
+        
+        
+    
+    
+        
+         
+    }
+    public void loadFile (JsRender.JsRender file)
+    {
+        
+    
+        this.file = file;
+        
+    
+            // clear existing elements from project?
+            
+            var  p = this.designview.el.get_project();
+            var    li = p.get_objects().copy();
+            // should remove all..
+            for (var i =0;    i < li.length(); i++) {   
+                p.remove_object(li.nth_data(i)); 
+            }
+    
+            if (file.tree == null) {
+                return;
+            }
+    
+    //        print("%s\n",tf.tree.toJsonString());
+       var x =  new JsRender.NodeToGlade((Project.Gtk) file.project, file.tree,  null);
+        Glade.App.set_window(_this.main_window.el); // see if setting it again forces it to go to the irght locations.
+        
+    FileIOStream iostream;
+       var  f = File.new_tmp ("tpl-XXXXXX.glade", out iostream);
+       var ostream = iostream.output_stream;
+       var dostream = new DataOutputStream (ostream);
+       dostream.put_string (x.munge());
+       this.el.show();
+        print("LOADING %s\n",f.get_path ());
+          //p.load_from_file(f.get_path ());
+            
+         p.load_from_file("/tmp/glade.xml");
+    
+    }
+    public void forwardSearch (bool change_focus) {
+    
+       if (this.searchcontext == null) {
+               return;
+       }
+       this.notebook.el.page = 1;
+       Gtk.TextIter beg, st,en, stl;
+       
+       var buf = this.sourceview.el.get_buffer();
+       buf.get_iter_at_offset(out beg, this.last_search_end);
+       if (!this.searchcontext.forward(beg, out st, out en)) {
+               this.last_search_end = 0;
+       } else { 
+               this.last_search_end = en.get_offset();
+               if (change_focus) {
+                       this.sourceview.el.grab_focus();        
+               }
+               buf.place_cursor(st);
+               var ln = st.get_line();
+               buf.get_iter_at_line(out stl,ln);
+                
+               this.sourceview.el.scroll_to_iter(stl,  0.0f, true, 0.0f, 0.5f);
+       }
+    
+    }
+    public void initGlade () {
+        _this.designview =  new Xcls_designview( _this );
+        
+        var box = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
+        
+        _this.notebook.el.append_page(box, _this.label_preview.el);
+            Glade.App.set_window(this.main_window.el);
+       // var  pal = new Glade.Palette();
+        //var ins = new Glade.Inspector();
+    
+        box.pack_start(_this.designview.el);
+       // box.pack_start(pal);
+        //box.pack_start(ins);
+         // pal.show();
+       // ins.show();
+        _this.designview.el.show();
+        box.show_all();         
+        
+    }
+    public class Xcls_notebook : Object
+    {
+        public Gtk.Notebook el;
+        private Xcls_GladeuiView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_notebook(Xcls_GladeuiView _owner )
+        {
+            _this = _owner;
+            _this.notebook = this;
+            this.el = new Gtk.Notebook();
+
+            // my vars (dec)
+
+            // set gobject values
+            var child_0 = new Xcls_label_preview( _this );
+            child_0.ref();
+            var child_1 = new Xcls_label_code( _this );
+            child_1.ref();
+            var child_2 = new Xcls_designview( _this );
+            child_2.ref();
+            var child_3 = new Xcls_sourceview( _this );
+            child_3.ref();
+            this.el.append_page (  child_3.el , _this.label_code.el );
+        }
+
+        // user defined functions
+    }
+    public class Xcls_label_preview : Object
+    {
+        public Gtk.Label el;
+        private Xcls_GladeuiView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_label_preview(Xcls_GladeuiView _owner )
+        {
+            _this = _owner;
+            _this.label_preview = this;
+            this.el = new Gtk.Label( "Preview" );
+
+            // my vars (dec)
+
+            // set gobject values
+        }
+
+        // user defined functions
+    }
+
+    public class Xcls_label_code : Object
+    {
+        public Gtk.Label el;
+        private Xcls_GladeuiView  _this;
+
+
+            // my vars (def)
+
+        // ctor
+        public Xcls_label_code(Xcls_GladeuiView _owner )
+        {
+            _this = _owner;
+            _this.label_code = this;
+            this.el = new Gtk.Label( "Preview Generated Code" );
+
+            // my vars (dec)
+
+            // set gobject values
+        }
+
+        // user defined functions
+    }
+
+    public class Xcls_designview : Object
+    {
+        public Glade.DesignView el;
+        private Xcls_GladeuiView  _this;
+
+
+            // my vars (def)
+        public JsRender.JsRender file;
+
+        // ctor
+        public Xcls_designview(Xcls_GladeuiView _owner )
+        {
+            _this = _owner;
+            _this.designview = this;
+            this.el = _this.main_window == null ? null : new Glade.DesignView(_this.main_window.gladeproject);
+
+            // my vars (dec)
+            this.file = null;
+
+            // set gobject values
+
+            // init method
+
+            this.el.show();
+        }
+
+        // user defined functions
+        public void createThumb () {
+            
+            
+            if (this.file == null) {
+                return;
+            }
+            var filename = this.file.getIconFileName(false);
+            
+            var  win = this.el.get_parent_window();
+            var width = win.get_width();
+            var height = win.get_height();
+        
+            Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?
+        
+            screenshot.save(filename,"png");
+            return;
+            
+            
+             
+        }
+    }
+
+    public class Xcls_sourceview : Object
+    {
+        public Gtk.SourceView el;
+        private Xcls_GladeuiView  _this;
+
+
+            // my vars (def)
+        public bool loading;
+        public bool allow_node_scroll;
+
+        // ctor
+        public Xcls_sourceview(Xcls_GladeuiView _owner )
+        {
+            _this = _owner;
+            _this.sourceview = this;
+            this.el = new Gtk.SourceView();
+
+            // my vars (dec)
+            this.loading = true;
+            this.allow_node_scroll = true;
+
+            // set gobject values
+            this.el.editable = false;
+            this.el.show_line_marks = true;
+            this.el.show_line_numbers = true;
+
+            // init method
+
+            {
+               
+                var description =   Pango.FontDescription.from_string("monospace");
+                description.set_size(8000);
+                this.el.override_font(description);
+            
+                this.loading = true;
+                var buf = this.el.get_buffer();
+                buf.notify.connect((ps) => {
+                    if (this.loading) {
+                        return;
+                    }
+                    if (ps.name != "cursor-position") {
+                        return;
+                    }
+                    print("cursor changed : %d\n", buf.cursor_position);
+                    Gtk.TextIter cpos;
+                    buf.get_iter_at_offset(out cpos, buf.cursor_position);
+                    
+                    var ln = cpos.get_line();
+             
+                    var node = _this.file.lineToNode(ln);
+             
+                    if (node == null) {
+                        print("can not find node\n");
+                        return;
+                    }
+                    var ltree = _this.main_window.windowstate.left_tree;
+                    var tp = ltree.model.treePathFromNode(node);
+                    print("got tree path %s\n", tp);
+                    if (tp != "") {
+                      this.allow_node_scroll = false;        
+                      print("changing cursor on tree..\n");
+                        ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false);
+                        // scrolling is disabled... as node selection calls scroll 10ms after it changes.
+                        GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {
+                           this.allow_node_scroll = true;
+                           return false;
+                        });
+                    }
+                    
+                    // highlight the node..
+                    
+                });
+              
+              
+              
+                var attrs = new Gtk.SourceMarkAttributes();
+                var  pink =   Gdk.RGBA();
+                pink.parse ( "pink");
+                attrs.set_background ( pink);
+                attrs.set_icon_name ( "process-stop");    
+                attrs.query_tooltip_text.connect(( mark) => {
+                    //print("tooltip query? %s\n", mark.name);
+                    return mark.name;
+                });
+                
+                this.el.set_mark_attributes ("ERR", attrs, 1);
+                
+                 var wattrs = new Gtk.SourceMarkAttributes();
+                var  blue =   Gdk.RGBA();
+                blue.parse ( "#ABF4EB");
+                wattrs.set_background ( blue);
+                wattrs.set_icon_name ( "process-stop");    
+                wattrs.query_tooltip_text.connect(( mark) => {
+                    //print("tooltip query? %s\n", mark.name);
+                    return mark.name;
+                });
+                
+                this.el.set_mark_attributes ("WARN", wattrs, 1);
+                
+             
+                
+                 var dattrs = new Gtk.SourceMarkAttributes();
+                var  purple =   Gdk.RGBA();
+                purple.parse ( "#EEA9FF");
+                dattrs.set_background ( purple);
+                dattrs.set_icon_name ( "process-stop");    
+                dattrs.query_tooltip_text.connect(( mark) => {
+                    //print("tooltip query? %s\n", mark.name);
+                    return mark.name;
+                });
+                
+                this.el.set_mark_attributes ("DEPR", dattrs, 1);
+                
+                
+                var gattrs = new Gtk.SourceMarkAttributes();
+                var  grey =   Gdk.RGBA();
+                grey.parse ( "#ccc");
+                gattrs.set_background ( grey);
+             
+                
+                this.el.set_mark_attributes ("grey", gattrs, 1);
+                
+                
+                
+                
+                
+                
+            }
+        }
+
+        // user defined functions
+        public string toString () {
+           Gtk.TextIter s;
+            Gtk.TextIter e;
+            this.el.get_buffer().get_start_iter(out s);
+            this.el.get_buffer().get_end_iter(out e);
+            var ret = this.el.get_buffer().get_text(s,e,true);
+            //print("TO STRING? " + ret);
+            return ret;
+        }
+        public void nodeSelected (JsRender.Node? sel) {
+          
+            
+          
+            // this is connected in widnowstate
+            print("Roo-view - node selected\n");
+            var buf = this.el.get_buffer();
+         
+            var sbuf = (Gtk.SourceBuffer) buf;
+        
+           
+            while(Gtk.events_pending()) {
+                Gtk.main_iteration();
+            }
+            
+           
+            // clear all the marks..
+             Gtk.TextIter start;
+            Gtk.TextIter end;     
+                
+            sbuf.get_bounds (out start, out end);
+            sbuf.remove_source_marks (start, end, "grey");
+            
+            
+             if (sel == null) {
+                // no highlighting..
+                return;
+            }
+            Gtk.TextIter iter;   
+            sbuf.get_iter_at_line(out iter,  sel.line_start);
+            
+            
+            Gtk.TextIter cur_iter;
+            sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);
+            
+            //var cur_line = cur_iter.get_line();
+            //if (cur_line > sel.line_start && cur_line < sel.line_end) {
+            
+            //} else {
+            if (this.allow_node_scroll) {
+                        
+               this.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.5f);
+               }
+            
+             
+            
+            for (var i = 0; i < buf.get_line_count();i++) {
+                if (i < sel.line_start || i > sel.line_end) {
+                   
+                    sbuf.get_iter_at_line(out iter, i);
+                    sbuf.create_source_mark(null, "grey", iter);
+                    
+                }
+            
+            }
+            
+        
+        }
+        public void loadFile ( ) {
+        
+            
+            this.loading = true;
+            var buf = this.el.get_buffer();
+            buf.set_text("",0);
+            var sbuf = (Gtk.SourceBuffer) buf;
+        
+            
+        
+            if (_this.file == null || _this.file.xtype != "Gtk") {
+                print("xtype != Gtk");
+                this.loading = false;
+                return;
+            }
+            
+            var valafn = "";
+              try {             
+                   var  regex = new Regex("\\.bjs$");
+                
+                 
+                    valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
+                 } catch (GLib.RegexError e) {
+                     this.loading = false;
+                    return;
+                }   
+            
+        
+           if (!FileUtils.test(valafn,FileTest.IS_REGULAR) ) {
+                print("File path has no errors\n");
+                this.loading = false;
+                return  ;
+            }
+            
+            string str;
+            try {
+            
+                GLib.FileUtils.get_contents (valafn, out str);
+            } catch (Error e) {
+                this.loading = false;
+                return  ;
+            }
+        
+        //    print("setting str %d\n", str.length);
+            buf.set_text(str, str.length);
+            var lm = Gtk.SourceLanguageManager.get_default();
+             
+            //?? is javascript going to work as js?
+            
+            ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));
+          
+            
+            Gtk.TextIter start;
+            Gtk.TextIter end;     
+                
+            sbuf.get_bounds (out start, out end);
+            sbuf.remove_source_marks (start, end, null); // remove all marks..
+            
+            
+            if (_this.main_window.windowstate.last_compile_result != null) {
+                var obj = _this.main_window.windowstate.last_compile_result;
+                this.highlightErrorsJson("ERR", obj);
+                this.highlightErrorsJson("WARN", obj);
+                this.highlightErrorsJson("DEPR", obj);                 
+            }
+            //while (Gtk.events_pending()) {
+             //   Gtk.main_iteration();
+           // }
+            
+            this.loading = false; 
+        }
+        public void highlightErrorsJson (string type, Json.Object obj) {
+              Gtk.TextIter start;
+             Gtk.TextIter end;   
+             
+             var buf =  this.el.get_buffer();
+               var sbuf = (Gtk.SourceBuffer)buf;
+                buf.get_bounds (out start, out end);
+                
+                sbuf.remove_source_marks (start, end, type);
+                         
+             
+             // we should highlight other types of errors..
+            
+            if (!obj.has_member(type)) {
+                print("Return has no errors\n");
+                return  ;
+            }
+            var err = obj.get_object_member(type);
+            
+            if (_this.file == null) { 
+                return; // just in case the file has not loaded yet?
+            }
+         
+        
+            var valafn = "";
+              try {             
+                   var  regex = new Regex("\\.bjs$");
+                
+                 
+                    valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
+                 } catch (GLib.RegexError e) {
+                    return;
+                }   
+        
+           if (!err.has_member(valafn)) {
+                print("File path has no errors\n");
+                return  ;
+            }
+            var lines = err.get_object_member(valafn);
+            
+           
+            
+            var tlines = buf.get_line_count () +1;
+            
+            lines.foreach_member((obj, line, node) => {
+                
+                     Gtk.TextIter iter;
+            //        print("get inter\n");
+                    var eline = int.parse(line) -1  ;
+                    print("GOT ERROR on line %s -- converted to %d\n", line,eline);
+                    
+                    
+                    if (eline > tlines || eline < 0) {
+                        return;
+                    }
+                    sbuf.get_iter_at_line( out iter, eline);
+                    //print("mark line\n");
+                    var msg  = type + " on line: %d - %s".printf(eline+1, valafn);
+                    var ar = lines.get_array_member(line);
+                    for (var i = 0 ; i < ar.get_length(); i++) {
+                           msg += (msg.length > 0) ? "\n" : "";
+                           msg += ar.get_string_element(i);
+                   }
+                    
+                    
+                    sbuf.create_source_mark(msg, type, iter);
+                } );
+                return  ;
+            
+         
+        
+        
+        }
+    }
+
+
+}
index 34dc1dc..1b18540 100644 (file)
     "        ",
     "        ",
     "\tvar x = new JsRender.NodeToGtk((Project.Gtk) file.project, file.tree);",
-    "        var obj = x.munge() as Gtk.Widget;",
-    "        this.lastObj = null;",
+    "    var obj = x.munge() as Gtk.Widget;",
+    "    this.lastObj = null;",
     "\tif (obj == null) {",
     "        \treturn;",
     "\t}",
index 7d9ffee..446e6fb 100644 (file)
@@ -21,8 +21,8 @@ public class Xcls_GtkView : Object
 
         // my vars (def)
     public Gtk.Widget lastObj;
-    public int width;
     public int last_search_end;
+    public int width;
     public Gtk.SourceSearchContext searchcontext;
     public JsRender.JsRender file;
     public int height;
@@ -36,8 +36,8 @@ public class Xcls_GtkView : Object
 
         // my vars (dec)
         this.lastObj = null;
-        this.width = 0;
         this.last_search_end = 0;
+        this.width = 0;
         this.file = null;
         this.height = 0;
 
@@ -77,6 +77,23 @@ public class Xcls_GtkView : Object
        });   
     
        
+    }
+    public int search (string txt) {
+       this.notebook.el.page = 1;
+       var s = new Gtk.SourceSearchSettings();
+       var buf = (Gtk.SourceBuffer) this.sourceview.el.get_buffer();
+       this.searchcontext = new Gtk.SourceSearchContext(buf,s);
+       this.searchcontext.set_highlight(true);
+       s.set_search_text(txt);
+       
+       Gtk.TextIter beg, st,en;
+        
+       buf.get_start_iter(out beg);
+       this.searchcontext.forward(beg, out st, out en);
+       this.last_search_end  = 0;
+       return this.searchcontext.get_occurrences_count();
+    
+       
     }
     public void createThumb () {
         
@@ -162,8 +179,8 @@ public class Xcls_GtkView : Object
             
             
        var x = new JsRender.NodeToGtk((Project.Gtk) file.project, file.tree);
-            var obj = x.munge() as Gtk.Widget;
-            this.lastObj = null;
+        var obj = x.munge() as Gtk.Widget;
+        this.lastObj = null;
        if (obj == null) {
                return;
        }
@@ -174,23 +191,6 @@ public class Xcls_GtkView : Object
             
              
             
-    }
-    public int search (string txt) {
-       this.notebook.el.page = 1;
-       var s = new Gtk.SourceSearchSettings();
-       var buf = (Gtk.SourceBuffer) this.sourceview.el.get_buffer();
-       this.searchcontext = new Gtk.SourceSearchContext(buf,s);
-       this.searchcontext.set_highlight(true);
-       s.set_search_text(txt);
-       
-       Gtk.TextIter beg, st,en;
-        
-       buf.get_start_iter(out beg);
-       this.searchcontext.forward(beg, out st, out en);
-       this.last_search_end  = 0;
-       return this.searchcontext.get_occurrences_count();
-    
-       
     }
     public void forwardSearch (bool change_focus) {
     
@@ -524,6 +524,15 @@ public class Xcls_GtkView : Object
         }
 
         // user defined functions
+        public string toString () {
+           Gtk.TextIter s;
+            Gtk.TextIter e;
+            this.el.get_buffer().get_start_iter(out s);
+            this.el.get_buffer().get_end_iter(out e);
+            var ret = this.el.get_buffer().get_text(s,e,true);
+            //print("TO STRING? " + ret);
+            return ret;
+        }
         public void nodeSelected (JsRender.Node? sel) {
           
             
@@ -581,15 +590,6 @@ public class Xcls_GtkView : Object
             }
             
         
-        }
-        public string toString () {
-           Gtk.TextIter s;
-            Gtk.TextIter e;
-            this.el.get_buffer().get_start_iter(out s);
-            this.el.get_buffer().get_end_iter(out e);
-            var ret = this.el.get_buffer().get_text(s,e,true);
-            //print("TO STRING? " + ret);
-            return ret;
         }
         public void loadFile ( ) {
             this.loading = true;
index ea58dae..916fe06 100644 (file)
    "$ xns" : "Gtk",
    "* init" : [
     " ",
-    "\t  ",
-    "    //this.el.show_all();",
-    "    //try {",
-    "         this.el.set_icon_name(\"roobuilder\");",
-    "\t//} catch (Exception e) {",
-    "\t//\tprint(\"no icon found\");",
-    "//\t}"
+    " ",
+    "     this.el.set_icon_name(\"roobuilder\");",
+    " "
    ],
    "border_width" : 0,
    "default_height" : 850,
index 95d111a..e75b51b 100644 (file)
@@ -65,12 +65,7 @@ public class Xcls_MainWindow : Object
 
         // init method
 
-        //this.el.show_all();
-            //try {
-                 this.el.set_icon_name("roobuilder");
-               //} catch (Exception e) {
-               //      print("no icon found");
-        //     }
+        this.el.set_icon_name("roobuilder");
 
         //listeners
         this.el.delete_event.connect( (   event) => {
index 4c7cc66..aed8ec9 100644 (file)
@@ -57,7 +57,6 @@
              "    */",
              "    return  ;    ",
              "",
-             "",
              "}"
             ]
            },
            "listeners" : {
             "item_activated" : [
              "(path) => {",
-             "",
+             "    ",
+             "    _this.win.windowstate.project = _this.selectedProject;",
+             "    _this.el.hide();",
+             "    ",
+             "    ",
              " \tGtk.TreeIter iter;",
              "   ",
              "            ",
              "",
              "    this.el.model.get_value(iter, 0 , out gval);",
              "    var file = (JsRender.JsRender)gval;",
+             "    ",
+             "    ",
              "    _this.win.windowstate.fileViewOpen(file);",
-             "    _this.el.hide();",
+             "",
              "    ",
              "    ",
              "}"
              "    if (fn.length < 1) {",
              "    \treturn;",
              "\t}",
-             "    ",
+             "    _this.win.windowstate.project = _this.selectedProject;",
+             "     _this.el.hide();",
              "    ",
              "    var f = JsRender.JsRender.factory(\"PlainFile\", _this.selectedProject, fn);",
              "   ",
+             "   ",
              "    _this.win.windowstate.fileViewOpen(f);",
-             "    _this.el.hide();",
+             "   ",
              "    ",
              "}"
             ]
index 093a4db..9210b7f 100644 (file)
@@ -411,7 +411,6 @@ public class Xcls_PopoverFiles : Object
                 */
                 return  ;    
             
-            
             });
         }
 
@@ -826,7 +825,11 @@ public class Xcls_PopoverFiles : Object
 
             //listeners
             this.el.item_activated.connect( (path) => {
-            
+                
+                _this.win.windowstate.project = _this.selectedProject;
+                _this.el.hide();
+                
+                
                Gtk.TreeIter iter;
                
                         
@@ -836,8 +839,10 @@ public class Xcls_PopoverFiles : Object
             
                 this.el.model.get_value(iter, 0 , out gval);
                 var file = (JsRender.JsRender)gval;
+                
+                
                 _this.win.windowstate.fileViewOpen(file);
-                _this.el.hide();
+            
                 
                 
             });
@@ -956,12 +961,14 @@ public class Xcls_PopoverFiles : Object
                 if (fn.length < 1) {
                        return;
                }
-                
+                _this.win.windowstate.project = _this.selectedProject;
+                 _this.el.hide();
                 
                 var f = JsRender.JsRender.factory("PlainFile", _this.selectedProject, fn);
                
+               
                 _this.win.windowstate.fileViewOpen(f);
-                _this.el.hide();
+               
                 
             });
             this.el.cursor_changed.connect( () => {
index c84955e..520d94d 100644 (file)
             "activate" : [
              "  (self) => {",
              "",
-             "    _this.addProp( \"prop\", \"XXXX\", \"\",\"string\");",
+             "    _this.addProp( \"prop\", \"XXXX\", \"\",\"string\");",
              "",
              "}"
             ]
             "activate" : [
              "  ( ) =>{",
              "",
-             "    _this.addProp( \"prop\", \"XXXX\", \"() {\\n\\n}\\n\", \"| return_type\");",
+             "    _this.addProp( \"prop\", \"XXXX\", \"() {\\n\\n}\\n\", \"| void\");",
              "}"
             ]
            },
index af860e0..02aa9d6 100644 (file)
@@ -953,7 +953,7 @@ public class Xcls_LeftProps : Object
             //listeners
             this.el.activate.connect( (self) => {
             
-                _this.addProp( "prop", "XXXX", "","string");
+                _this.addProp( "prop", "XXXX", "","string");
             
             });
         }
@@ -1096,7 +1096,7 @@ public class Xcls_LeftProps : Object
             //listeners
             this.el.activate.connect( ( ) =>{
             
-                _this.addProp( "prop", "XXXX", "() {\n\n}\n", "| return_type");
+                _this.addProp( "prop", "XXXX", "() {\n\n}\n", "| void");
             });
         }
 
index c8f7fc7..d7a9906 100644 (file)
          "       return true;",
          "    }",
          "    ",
-         "",
+         "\t",
          "    ",
          "    if (ev.type != Gdk.EventType.BUTTON_PRESS  || ev.button != 3) {",
          "        //print(\"click\" + ev.type);",
          "    if (!_this.view.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) {",
          "        return true;",
          "    }",
+         "    ",
+         "",
+         "    _this.main_window.windowstate.leftTreeBeforeChange();",
+         "",
+         "    ",
          "     ",
          "    this.el.get_selection().select_path(res);",
          "     ",
index 9631367..61924aa 100644 (file)
@@ -254,7 +254,7 @@ public class Xcls_WindowLeftTree : Object
                    return true;
                 }
                 
-            
+               
                 
                 if (ev.type != Gdk.EventType.BUTTON_PRESS  || ev.button != 3) {
                     //print("click" + ev.type);
@@ -264,6 +264,11 @@ public class Xcls_WindowLeftTree : Object
                 if (!_this.view.el.get_path_at_pos((int)ev.x,(int)ev.y, out res, null, null, null) ) {
                     return true;
                 }
+                
+            
+                _this.main_window.windowstate.leftTreeBeforeChange();
+            
+                
                  
                 this.el.get_selection().select_path(res);
                  
index d2cf5a6..cabaf46 100644 (file)
@@ -12,12 +12,8 @@ public class WindowState : Object
        public enum State {
                NONE,
                PREVIEW,
-               //OBJECT,
-               //PROP,
-               //LISTENER,
-               //CODE,    // code editor.
-               CODEONLY //,
-               //FILES //,
+               CODE,
+               CODEONLY  
          
        }  
 
@@ -34,7 +30,7 @@ public class WindowState : Object
        public Xcls_RooProjectSettings roo_projectsettings_pop;
        public Xcls_ValaProjectSettingsPopover  vala_projectsettings_pop;
        public Xcls_PopoverAddObject     rightpalete;
-       public Xcls_PopoverEditor               code_editor_popover;
+       //public Xcls_PopoverEditor               code_editor_popover;
        public Editor                                    code_editor_tab; 
        public Xcls_WindowRooView   window_rooview;
        public Xcls_GtkView         window_gladeview;
@@ -70,7 +66,7 @@ public class WindowState : Object
                // on clutter space...
                this.projectEditInit();
                this.codeEditInit();
-               this.codePopoverEditInit();
+               //this.codePopoverEditInit();
                //this.projectListInit();
                //this.fileViewInit();
 
@@ -168,6 +164,12 @@ public class WindowState : Object
                // in theory code editor has to hide before tree change occurs.
                //if (this.state != State.CODE) {
                        this.left_props.finish_editing();
+                       
+                       if (this.state == State.CODE) {
+                               this.code_editor_tab.saveContents();
+                               this.switchState(State.PREVIEW);
+                       }
+                       
                        return true;
                //}
 
@@ -329,9 +331,10 @@ public class WindowState : Object
                this.left_props.el.show_all();
        
                this.left_props.show_editor.connect( (file, node, type,  key) => {
-                       //this.switchState(State.CODE);
-                       this.code_editor_popover.show(
-                               this.left_props.el,
+                       this.switchState(State.CODE);
+                       
+                       
+                       this.code_editor_tab.show(
                                file,
                                node,
                                type,
@@ -339,19 +342,17 @@ public class WindowState : Object
                        );
                        
                        
+                       
                });
 
                // not sure if this is needed - as closing the popvoer should save it.
                this.left_props.stop_editor.connect( () => {
-                       //if (this.state != State.CODE) {
-                       //      return true;
-                       //}
-       
-                       var ret =  this.code_editor_popover.editor.saveContents();
+                       var ret =  this.code_editor_tab.saveContents();
                        if (!ret) {
                                return false;
                        }
-                       //this.switchState(State.PREVIEW);
+                       this.switchState(State.PREVIEW);
+                        
                        return ret;
                });
        
@@ -409,6 +410,7 @@ public class WindowState : Object
                 });
 
        }
+       
        public void projectPopoverShow(Gtk.Widget btn, Project.Project? pr) 
        { 
                if (pr == null) {
@@ -528,6 +530,7 @@ public class WindowState : Object
                });
                
        }
+       /*
        public void codePopoverEditInit()
        {
                this.code_editor_popover  = new  Xcls_PopoverEditor();
@@ -548,6 +551,7 @@ public class WindowState : Object
                });
                
        }
+       */
        // ----------- list of projects on left
        /*
        public void  projectListInit() 
@@ -710,9 +714,13 @@ public class WindowState : Object
 
        public void gtkViewInit()
        {
-               this.window_gladeview  =new Xcls_GtkView();
+
+               
+               
+               this.window_gladeview  =new Xcls_GtkView( );
                this.window_gladeview.ref();
                this.window_gladeview.main_window = this.win;
        }
        
 
@@ -765,19 +773,18 @@ public class WindowState : Object
                        return;
                }
                
-               // stop werid stuff happening
-               
-               //if (this.state == State.FILES 
-                       //&& new_state == State.FILEPROJECT 
-               //      && this.left_projects.getSelectedProject() == null) {
-               //      return;
-               //}
-               // save the easing state of everything..
-
+               // anything to do beforehand?
                
                switch (this.state) {
-
+                        
+                
+                       
                        case State.PREVIEW:
+                               // stop editing the editor tab.
+                               // always save before calling switch state to preview?
+                               
+                               this.code_editor_tab.reset();
+                                
                                if (this.left_tree.getActiveFile() != null) {
                                         if (this.left_tree.getActiveFile().xtype == "Roo" ) {
                                                 this.window_rooview.createThumb();
@@ -795,12 +802,7 @@ public class WindowState : Object
                         
                 
                                
-               
-               this.win.rooviewbox.el.hide();
-          this.win.codeeditviewbox.el.hide();
-          
-          
-               var oldstate  =this.state;
+                
                this.state = new_state;
                
                
@@ -811,33 +813,30 @@ public class WindowState : Object
                switch (this.state) {
                        
                        case State.PREVIEW:  // this is the default state when working...
-                                this.win.editpane.el.show(); // holder for tree and properties..
-                                
-                        
-                               // this.left_projects.el.hide(); 
-                               // if (oldstate != State.FILES) {
-                                       // it's handled above..
-                               //      print ("changing state to preview from NOT files..");
-                                        
-                                       this.win.rooviewbox.el.show();
-                               // }
-                          
-                               break;
+                               this.win.leftpane.el.show();
+                               this.win.editpane.el.show(); // holder for tree and properties..
+                           this.win.rooviewbox.el.show();
+                               this.win.codeeditviewbox.el.hide();
+                               break;
+                               
+                       case State.CODE:
+                               this.win.leftpane.el.show();
+                               this.win.editpane.el.show();
+
+                           this.win.rooviewbox.el.hide();
+                               this.win.codeeditviewbox.el.show();
+                               this.code_editor_tab.el.show_all();
+                               break;
+                  
                   
                        case State.CODEONLY:
                                
                                this.win.leftpane.el.hide();
                                this.win.codeeditviewbox.el.show();
-                               
-                               
+                               this.win.rooviewbox.el.hide();
                                this.code_editor_tab.el.show_all();
-                           
-
-
-                               break;
+                           break;
+                       
 
                }
 
index c7c9a44..4dd4b08 100644 (file)
             "../Builder4/PopoverAddObject.vala",
             "../Builder4/PopoverEditor.vala",
             "../Builder4/Editor.vala",
-            "../Builder4/PopoverFiles.vala"
+            "../Builder4/PopoverFiles.vala",
+            "../JsRender/NodeToGlade.vala"
         ],
         "packages" : []
     },
diff --git a/src/Builder4/sample_working_gladeui.vala b/src/Builder4/sample_working_gladeui.vala
new file mode 100644 (file)
index 0000000..7bbaab1
--- /dev/null
@@ -0,0 +1,47 @@
+/** 
+
+ compile:
+valac src/Builder4/sample_working_gladeui.vala --pkg gladeui-2.0  --pkg gtk+-3.0 -o /tmp/test_glade --vapidir src/vapi
+
+This works fine. - however when I added it to the builder - the gtkwindows seperated themselves from the display
+- I think it tries to get clever and does something with gtk_plug which doesnt really work.
+
+There are some downsides to using glade anyway - so probably dont think about it next time.
+* the UI mouse menu introduces quite a few things that may be difficult to handle.
+* the drag drop into the view, needs the paleate from glade - which is not really compatible with our one.
+
+*/
+
+using Glade;
+using Gtk;
+static int main (string[] args)
+{
+    Gtk.init(ref args);
+    Window win = new Window(WindowType.TOPLEVEL);
+   
+    Project proj = new Project();
+
+    //Palette pal = new Palette();
+    //Inspector ins = new Inspector();
+    DesignView dv = new DesignView(proj);
+    //pal.project = proj;
+    //ins.project = proj;
+    HBox box = new HBox(false,0);
+    //box.pack_start(pal);
+    //box.pack_start(ins);
+    box.pack_start(dv);
+    win.add(box);
+    dv.show();
+    //pal.show();
+    //ins.show();
+    win.set_size_request(300,300);
+    win.show_all();
+     App.set_window(win);
+    App.add_project(proj);     
+    proj.load_from_file("/tmp/glade.xml");
+    
+    Gtk.main();
+    return 0;
+}
index 37dda47..432bf3c 100644 (file)
@@ -251,7 +251,10 @@ namespace JsRender {
                        // not yet..
                }
 
-           
+               public override string toGlade() 
+               {
+                       return  NodeToGlade.mungeFile(this);
+               }
          
 
        
index a783cf2..a6d658d 100644 (file)
@@ -389,7 +389,9 @@ namespace JsRender {
                public abstract void setSource(string str);
                public abstract string toSourcePreview() ;
                public abstract void removeFiles() ;
-                public abstract void  findTransStrings(Node? node );
+               public abstract void  findTransStrings(Node? node );
+               public abstract string toGlade();
+               
        } 
 
 }
index 0a96797..f42279b 100644 (file)
 /*
-
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
-<interface>
-  <requires lib="gtk+" version="3.12"/>
-  <object class="GtkBox" id="box1">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="orientation">vertical</property>
-    <child>
-      <object class="GtkButton" id="button1">
-        <property name="label" translatable="yes">button</property>
-        <property name="visible">True</property>
-        <property name="can_focus">True</property>
-        <property name="receives_default">True</property>
-      </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="fill">True</property>
-        <property name="position">0</property>
-      </packing>
-    </child>
-    <child>
-      <placeholder/>
-    </child>
-    <child>
-      <object class="GtkToggleButton" id="togglebutton1">
-        <property name="label" translatable="yes">togglebutton</property>
-        <property name="visible">True</property>
-        <property name="can_focus">True</property>
-        <property name="receives_default">True</property>
-      </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="fill">True</property>
-        <property name="position">2</property>
-      </packing>
-    </child>
-  </object>
-</interface>
+ This kind of works - however there are issues with embedding gladeui that do not seem fixable.
+ - rendering is borked for windows - they detach for some reason.
+ - selecting stuff and drag etc. would probably be complicated...
 */
 public class JsRender.NodeToGlade : Object {
 
        Node node;
-       string pad;
-       Gee.ArrayList<string> els;
-        //Gee.ArrayList<string> skip;
-       Gee.HashMap<string,string> ar_props;
-       public static int vcnt = 0; 
-
-       public NodeToGlade( Project.Gtk, Node node,   string pad) 
+       Project.Gtk project;
+       Xml.Node* parent;
+       
+       public NodeToGlade( Project.Gtk project, Node node, Xml.Node* parent) 
        {
+               
+               this.parent = parent;
+               this.project = project;
                this.node = node;
-               this.pad = pad;
-               this.els = new Gee.ArrayList<string>(); 
-               //this.skip = new Gee.ArrayList<string>();
-               this.ar_props = new Gee.HashMap<string,string>();
+               
+       }
+       
+       public static string mungeFile(JsRender file) 
+       {
+               if (file.tree == null) {
+                       return "";
+               }
+
+               var n = new NodeToGlade(  (Project.Gtk) file.project, file.tree,  null);
+       
+               ///n.toValaName(file.tree);
+               
+               
+               GLib.debug("top cls %s / xlcs %s\n ",file.tree.xvala_cls,file.tree.xvala_cls); 
+               //n.cls = file.tree.xvala_cls;
+               //n.xcls = file.tree.xvala_xcls;
+               return n.munge();
+               
 
        }
        
        public string munge ( )
        {
 
-                
-               this.pad += "    ";
 
-               var cls = this.node.fqn().replace(".", "");
-               string res = "";
-               switch(cls) {
-                       // things we can not do yet...
-                       case "GtkDialog": // top level.. - named and referenced
-                       case "GtkAboutDialog":
-                       case "GtkMessageDialog":
-                       case "GtkWindow": // top level.. - named and referenced
-                               res =  this.mungeOuter(true);
-                               break;
-                       default:
-                               res = this.mungeOuter(false);
-                               break;
-               }
-                               
-               
-               if (res.length < 1) {
-                       return "";
-               }
-               return  "<?xml version=\"1.0\" encoding=\"UTF-8\"?> 
-                       <!-- Generated with appBuilder 4.1 -->
-                       <interface> 
-                               <requires lib=\"gtk+\" version=\"3.12\"/>
-                               <!-- <requires lib=\"gtksourceview\" version=\"3.0\"/> -->
-                       " +
-                       res +
-                       "</interface>\n";
+               var doc = this.mungeNode ();
+               string ret;
+               int len;
+        doc->dump_memory_format (out ret, out len, true);
+
+               return ret;
+       
           
                     
        }
-       public string mungeChild(string pad ,  Node cnode, bool with_packing = false)
+       public Xml.Doc* mungeChild( Node cnode , Xml.Node* cdom)
        {
-               var x = new  NodeToGlade(cnode,  pad);
-               return x.mungeNode(with_packing);
+               var x = new  NodeToGlade(this.project, cnode,  cdom);
+               return x.mungeNode();
        }
+       public static Xml.Ns* ns = null;
+       
        
-       public string mungeNode(bool with_packing)
+       public  Xml.Node* create_element(string n)
        {
-               var pad = this.pad;
+               if (NodeToGlade.ns == null) {
+                       Xml.Ns* ns = new Xml.Ns (null, "", "");
+               ns->type = Xml.ElementType.ELEMENT_NODE;
+               }
+               Xml.Node* nn =  new Xml.Node (ns, n);
+       return nn;
+       
+       }
+       
+       public Xml.Doc* mungeNode()
+       {
+               Xml.Doc* doc;
+               if (this.parent == null) {
+                       doc = new Xml.Doc("1.0");
+
+                       var inf = this.create_element("interface");
+                       doc->set_root_element(inf);
+                       var req = this.create_element("requires");
+                       req->set_prop("lib", "gtk+");
+                       req->set_prop("version", "3.12");
+                       inf->add_child(req);
+                       this.parent = inf;
+               } else {
+                       doc = this.parent->doc;
+               }
                var cls = this.node.fqn().replace(".", "");
                
-               var b = new global::Gtk.Builder();
+               var girdata = Palete.Gir.factoryFqn(this.project, this.node.fqn());
+               
+               
+               
+               /// check if it's a GtkWidget?
+               // maybe not?
+               // how are models handled?
+               
+               
+               //var b = new global::Gtk.Builder();
 
-               var gtype = b.get_type_from_name(cls);
-               print("Type: %s ?= %s\n", this.node.fqn(), gtype.name());
+               // this might be needed if we are using non-Gtk elements?
+               //var gtype = b.get_type_from_name(cls);
+               //GLib.debug ("Type: %s ?= %s\n", this.node.fqn(), gtype.name());
 
                
-               
+               /*
                var ns = this.node.fqn().split(".")[0];
                if (ns == "Clutter") {
                        return "";
@@ -123,19 +117,12 @@ public class JsRender.NodeToGlade : Object {
                if (ns == "WebKit") {
                        return "";
                }
+               */
+               /*
+               
                switch(cls) {
                        // things we can not do yet...
-                       /*case "GtkDialog": // top level.. - named and referenced
-                       case "GtkAboutDialog":
-                       case "GtkWindow": // top level.. - named and referenced
-                               return this.mungeWindow();
-                               
-                                       
-                               if (this.node.items.size > 0) {
-                                       return this.mungeChild(pad + "        " , this.node.items.get(0), false );
-                               }
-                               return "";
-                       */
+                       
                        //case "GtkView": // SourceView?
                        case "GtkTreeStore": // top level.. - named and referenced
                        case "GtkListStore": // top level.. - named and referenced
@@ -147,30 +134,44 @@ public class JsRender.NodeToGlade : Object {
                        ///case "GtkClutterEmbed"://fixme..
                                return "";
                }
-
+               */
                
+               // should really use GXml... 
+               var obj = this.create_element("object");
                var id = this.node.uid();
-               var ret = @"$pad<object class=\"$cls\" id=\"$id\">\n";
+               obj->set_prop("class", cls);
+               obj->set_prop("id", id);
+               this.parent->add_child(obj);
                // properties..
                var props = Palete.Gir.factoryFqn(this.project, this.node.fqn()).props;
-               //var props =  Palete.factory("Gtk").getPropertiesFor(this.node.fqn(), "props");
               
-               var pviter = props.map_iterator();
+               var pviter = props.map_iterator();
                while (pviter.next()) {
                        
-                               // print("Check: " +cls + "::(" + pviter.get_value().propertyof + ")" + pviter.get_key() + " " );
-                               
-                       // skip items we have already handled..
-                       if  (!this.node.has(pviter.get_key())) {
+                       GLib.debug ("Check: " +cls + "::(" + pviter.get_value().propertyof + ")" + pviter.get_key() + " " );
+                       
+               // skip items we have already handled..
+               if  (!this.node.has(pviter.get_key())) {
                                continue;
                        }
                        var k = pviter.get_key();
-                       var val = GLib.Markup.escape_text(this.node.get(pviter.get_key()).strip());
-                       ret += @"$pad    <property name=\"$k\">$val</property>\n"; // es
-
-                }
+                       var val = this.node.get(pviter.get_key()).strip();
+                       var prop = this.create_element("property");
+                       prop->set_prop("name", k);
+                       switch (k) { 
+                               case "orientation":
+                                       var bits = val.split(".");
+                                       val = bits.length > 2 ? bits[2].down() : "vertical"; // ??
+                                       break;
+                       }
+                       
+                       
+                       prop->add_child(new Xml.Node.text(val));
+                       obj->add_child(prop); 
+        }
                // packing???
-
+/*
                var pack = "";
                
                if (with_packing   ) {
@@ -178,33 +179,33 @@ public class JsRender.NodeToGlade : Object {
                        pack = this.packString();
                        
 
-               }       
+               
+               }       */
                // children..
 
-               if (this.node.items.size < 1) {
-                       return ret + @"$pad</object>\n" + pack;
-               }
                
                for (var i = 0; i < this.node.items.size; i++ ) {
-
-                       var add = this.mungeChild(pad + "        " , this.node.items.get(i) , true);
-                       if (add.length < 1) {
-                               continue;
+                       var cn = this.node.items.get(i);
+                       var child  = this.create_element("child");
+                       if (cls == "GtkWindow" && cn.fqn() == "Gtk.HeaderBar") {
+                               child->set_prop("type", "titlebar");
                        }
                        
-                       ret += @"$pad    <child>\n";
-                       ret += add;
-                       ret += @"$pad    </child>\n";
+                       
+                       this.mungeChild(cn, child);
+                       if (child->child_element_count()  < 1) {
+                               continue;
+                       }
+                       obj->add_child(child);
+                        
                }
-               
-               return ret + @"$pad</object>\n" + pack;
-               
+               return doc;
 
                 
 
        }
         
-        
+        /*
        public string packString()
        {
                
@@ -242,7 +243,7 @@ public class JsRender.NodeToGlade : Object {
                var cls = gir.classes.get(p_parts[1]);
                var mdef = cls.methods.get(pk[0]);
                if (mdef == null) {
-                       print("could not find method : %s\n", pk[0]);
+                       GLib.debug ("could not find method : %s\n", pk[0]);
                        return "";
                }
                /*
@@ -253,8 +254,9 @@ public class JsRender.NodeToGlade : Object {
                generator.indent = 4;
                generator.pretty = true;
                    
-               print(generator.to_data(null));
+               GLib.debug print(generator.to_data(null));
                */
+               /*
                string[]  pbody  = {};
                switch(pk[0]) {
 
@@ -277,16 +279,16 @@ public class JsRender.NodeToGlade : Object {
                                return pack;
                 
                        case "set_model":
-                               print ("set_model not handled yet..");
+                               GLib.debug ("set_model not handled yet..");
                                return "";
                        
                        default:
-                               print ("unknown pack type: %s", pk[0]);
+                               GLib.debug  ("unknown pack type: %s", pk[0]);
                                return "";
                                
                }
                        
-               var pad = this.pad;
+
                 
                for (var i = 2; i < mdef.paramset.params.size; i++) {
                        var poff = i - 1;
@@ -309,8 +311,9 @@ public class JsRender.NodeToGlade : Object {
                        generator.pretty = true;
                            
                        print(generator.to_data(null));
-                       */
-                       print("skip - packing - no arguments (" + pk[0] + ")\n");
+                       */ 
+                       /*
+                       GLib.debug ("skip - packing - no arguments (" + pk[0] + ")\n");
                        return "";
                }
                
@@ -320,90 +323,8 @@ public class JsRender.NodeToGlade : Object {
                return pack;
 
        }
-       public string  mungeOuter(bool with_window)
-       {
-               var label = this.node.fqn() + ": " + 
-                       (this.node.has("title") ? this.node.get("title") : "No-title");
-               
-               var ret = "";
-               ret+= "
-<object class=\"GtkBox\" id=\"fake-window1\">
-       <property name=\"visible\">True</property>
-       <property name=\"can_focus\">False</property>
-       <property name=\"orientation\">vertical</property>
-";
-               if (with_window) {              
-                       ret+="
-       <child>
-               <object class=\"GtkLabel\" id=\"fake-window-label-1\">
-                       <property name=\"visible\">True</property>
-                       <property name=\"can_focus\">False</property>
-                       <property name=\"label\" translatable=\"yes\">" + label + "</property>
-               </object>
-               <packing>
-                       <property name=\"expand\">False</property>
-                       <property name=\"fill\">True</property>
-                       <property name=\"position\">0</property>
-               </packing>
-       </child>
-       ";
-               }
-               
-               ret+=" 
-               <child>
-               ";
-               if (with_window) {
-                       var children = "";
-                       if (this.node.items.size > 0) {
-                       
-                               children =  this.mungeChild(pad + "        " , this.node.items.get(0), false);
-                         
-
-                       } 
-                       children += (children.length > 0) ? "<packing>
-                               <property name=\"expand\">True</property>
-                               <property name=\"fill\">True</property>
-                               <property name=\"position\">1</property>
-                     </packing>" : "";
-                       
-                       ret+= (children.length < 1 ) ? "<placeholder/>" : children;
-                       
-                       
-                       
-
-               } else {
-                       ret+= this.mungeNode (true);
-               }
-
-               ret+="
-                   </child>
-           ";
-       if (with_window) {
-               ret+="
-                   <child>
-                     <object class=\"GtkBox\" id=\"fake-footer\">
-                       <property name=\"visible\">True</property>
-                       <property name=\"can_focus\">False</property>
-                       <child>
-                         <placeholder/>
-                       </child>
-                       <child>
-                         <placeholder/>
-                       </child>
-                     </object>
-                     <packing>
-                       <property name=\"expand\">False</property>
-                       <property name=\"fill\">True</property>
-                       <property name=\"position\">2</property>
-                     </packing>
-                   </child>
-           ";
-       }
-               ret +="
-       </object>"; 
+       */
 
-       return ret;
-       }
 
                
 }
\ No newline at end of file
index bbbe832..b5b05be 100644 (file)
@@ -148,7 +148,10 @@ namespace JsRender {
                        // not yet..
                }
        
-        
+        public override string toGlade() 
+               {
+                       return "Roo files do not convert to glade";
+               }
          
 
                
index 290591f..e1f6ec0 100644 (file)
@@ -813,7 +813,10 @@ namespace JsRender {
         {
             return "http://www.roojs.com/roojs1/docs/symbols/" + cls + ".html";
         }
-                
+                public override string toGlade() 
+               {
+                       return "Roo files do not convert to glade";
+               }
      
     }
 }
index d689849..132e0df 100644 (file)
@@ -15,7 +15,7 @@ int main (string[] args) {
          
     Gtk.init (ref args);
 
-       
+
        
        // not sure why this was done?? - it caused crash bugs on gtk_Box_gadget so removed critical.
        // GLib.Log.set_always_fatal(LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL); 
index 2bce601..80360a9 100644 (file)
@@ -155,6 +155,7 @@ roobuilder_PKGS = --pkg glib-2.0  \
                --pkg libsoup-2.4 \
                --pkg javascriptcore \
                --pkg roojspacker-1.4 \
+               --pkg gladeui-2.0 \
                $(roobuilder_LIBVALA) \
                $(roobuilder_GDA) \
                $(roobuilder_WEBKKIT) \
@@ -173,6 +174,7 @@ BUIDERJSRENDER = JsRender/Gtk.vala \
                JsRender/NodeToGtk.vala \
                JsRender/NodeToJs.vala \
                JsRender/NodeToVala.vala \
+               JsRender/NodeToGlade.vala \             
                JsRender/Node.vala \
                JsRender/Roo.vala
 
index 3a9080a..1e8e0eb 100644 (file)
@@ -58,7 +58,7 @@ namespace Palete {
                public static void checkParamOverride(GirObject c)
                {
                        
-                       GLib.debug("checkParamOverride :check %s\n", c.name);
+                       //GLib.debug("checkParamOverride :check %s", c.name);
                        var parset = c.gparent;
                        if (parset == null || parset.nodetype != "Paramset") {
                                print("skip parent not Paramset\n");
@@ -200,7 +200,7 @@ namespace Palete {
                                            
                        
                }
-
+                
                        
                /**
                 * guess the fqn of a type == eg. gboolean or Widget etc...
index a1a4ce7..b93610c 100644 (file)
@@ -28,11 +28,14 @@ namespace Palete {
                
                public GirObject paramset = null;
                public GirObject return_value = null;
-                   
+               public bool is_deprecated = false;                  
                public bool is_instance;
                public bool is_array;
                public bool  is_varargs;
                public bool  ctor_only; // specially added ctor properties..
+               public bool is_writable = true;
+               public bool is_readable = true;
+               public bool is_abstract = false;
                public  string parent;
                public  string value;
                // to be filled in...
@@ -111,6 +114,9 @@ namespace Palete {
                        for(var i =0;i< this.inherits.size; i++) {
                                ret += this.inherits.get(i);
                        }
+                       for(var i =0;i< this.implements.size; i++) {
+                               ret += this.implements.get(i);
+                       }
                        return ret;
 
                }
index 71796fd..8941154 100644 (file)
@@ -1,5 +1,34 @@
 using Gtk;
 
+
+/**
+Known issues with Palete
+
+
+Object Add:
+
+SourceView/TextView - can add widget (which doesnt really seem to work) - as it's subclassing a container
+Gtk.Table - adding children? (nothing is currently allowed.
+
+
+Properties list 
+- need to remove widgets from this..
+- help / show source interface etc..?
+- make wider?
+
+Events list
+- signature on insert
+- show source interface / help
+
+
+
+
+
+
+*/
+
+
+
 namespace Palete {
 
        
@@ -44,16 +73,169 @@ namespace Palete {
                    // no parent...
                }
              
-               public override void  load () {
+               public override void  load () 
+               {
+                       
+                       var gtk = Gir.factory(this.project, "Gtk"); // triggers a load...
+                       var pr = (Project.Gtk) this.project;
+                       
+                       
+                       this.map = new Gee.ArrayList<Usage>();
+                       foreach(var key in   pr.gir_cache.keys) {
+                               var gir = pr.gir_cache.get(key);
+                               
+                               this.add_map_from_classes(gir.classes);
+                       }
+               }
+               
+               public void add_map_from_classes(Gee.HashMap<string,GirObject> classes)
+               {
+                       
+                       var widgets = new Gee.ArrayList<string>();
+                       var top = new Gee.ArrayList<string>();
+                       var topleft = new Gee.ArrayList<string>();
+                       var containers = new Gee.ArrayList<string>();
 
-                       this.loadUsageFile(BuilderApplication.configDirectory() + "/resources/GtkUsage.txt");
+                       topleft.add("*top");
+                       
+                       
+                       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;
+                               }
+                                       
+                               if (!cls.inherits.contains("Gtk.Widget") && !cls.implements.contains("Gtk.Widget")) {
+                                       continue;
+                               }
+                               // we can still add properties of abstract classes...
+                               
+                               if (!cls.is_abstract) {
+                                       
+                                       if (
+                                                        
+                                                         // GTK4 !!
+                                                        cls.inherits.contains("Gtk.Root")
+                                                        || 
+                                                        cls.implements.contains("Gtk.Root")
+                                                        || 
+                                                        cls.inherits.contains("Gtk.Native")
+                                                        || 
+                                                        cls.implements.contains("Gtk.Native")
+                                                        || 
+                                                        // Gtk3
+                                                        // check for depricated?
+                                                        cls.inherits.contains("Gtk.Window")
+                                                        || 
+                                                        cls.fqn() == "Gtk.Window"
+                                                        || 
+                                                        cls.fqn() == "Gtk.Popover" // dont allow it as a child
+                                                        
+                                                        ) {
+                                               top.add(cls.fqn());
+                                               // skip - can't add these widgets to anything
+                                       } else { 
+                                               //GLib.debug("Add Widget %s", cls.fqn());
+                                               widgets.add(cls.fqn());
+                                               top.add(cls.fqn());
+                                               //GLib.debug("Got Class %s : %s Inherits %s", cls.ns , cls.name,
+                                               //      string.joinv( ",", cls.inheritsToStringArray())
+                                               //);
+                                               
+                                               
+                                       }
+                               }
+                               if (cls.inherits.contains("Gtk.Container") || cls.implements.contains("Gtk.Container")) {
+                                       containers.add(cls.fqn());
+                                       GLib.debug("Add Container %s", cls.fqn());
+                               }
+                               
+                               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" || 
+                                               prop.name == "attached_to" || 
+                                               prop.name == "mnemonic_widget" ||
+                                               prop.name == "application" ||
+                                               prop.name == "transient_for"
+                                               
+                                               ) {
+                                               continue;
+                                       }
+                                       var propcls = this.getClass(prop.type);
+                                       if (propcls == null) {
+                                               continue;
+                                       }
+                                       // check if propcls is abstract?
+                                       if (!propcls.is_abstract) { 
+                                               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);
+                                       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?
+                                               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));
+                               }
+                       }
+                                               
+                                               
+                                
+                         
+                         
+                       this.map.add(new Usage( topleft, top));
+                       this.map.add(new Usage( containers, widgets));
+               
+                       
+                       
+                       ///this.loadUsageFile(BuilderApplication.configDirectory() + "/resources/GtkUsage.txt");
         
                     
                }
                
-               public string doc(string what) {
-                       var ns = what.split(".")[0];
-                       var gir =  Gir.factory(this.project,ns);
+               public string doc(string what) 
+               {
+               var ns = what.split(".")[0];
+               var gir =  Gir.factory(this.project,ns);
                        return   gir.doc(what);
                        
                    //return typeof(this.comments[ns][what]) == 'undefined' ?  '' : this.comments[ns][what];
@@ -225,6 +407,7 @@ namespace Palete {
                        
                        return ret;
                }
+               // get a list of available vapi files...
                
                public  Gee.ArrayList<string>  loadPackages(string dirname)
                {
index 613cff4..4080b56 100644 (file)
@@ -153,7 +153,7 @@ namespace Palete {
                        c.ns = parent.name;
                        c.parent = cls.base_class == null ? "" : cls.base_class.get_full_name() ;  // extends...
                        c.gparent = parent;
-                       
+                       c.is_abstract = cls.is_abstract;
                        foreach(var p in cls.get_properties()) {
                                this.add_property(c, p);
                        }
@@ -189,11 +189,111 @@ namespace Palete {
 #endif                         
                                 
                        }
-                         
                        
+                       if (cls.version.deprecated) { 
+                               GLib.debug("class %s is deprecated", c.name);
+                               c.is_deprecated = true;
+                       }
                        
-                        
                }
+               
+               public GirObject? fqn_to_cls(string fqn)
+               {
+                       var ar = fqn.split(".");
+                       var pkg = this.project.gir_cache.get(ar[0]);
+                       var cls = pkg != null ? pkg.classes.get(ar[1]) : null;
+                       return cls;
+               }
+               
+               public void augment_inherits_for(GirObject cls, Gee.ArrayList<string> to_check, bool is_top)
+               {
+                       foreach (var chk_cls in to_check) {
+                               if (!cls.inherits.contains(chk_cls)) { 
+                                       cls.inherits.add(chk_cls);
+                                       
+                               } else {
+                                       if (!is_top) {
+                                               continue;
+                                       }
+                               }
+                               
+                               
+                               var subcls = this.fqn_to_cls(chk_cls);
+                               if (subcls == null) {
+                                       continue;
+                               }
+                               this.augment_inherits_for(cls, subcls.inherits, false);
+                               this.augment_implements_for(cls, subcls.implements);
+                       }
+               
+               }
+               public void augment_implements_for(GirObject cls, Gee.ArrayList<string> to_check)
+               {
+                       foreach (var chk_cls in to_check) {
+                               if (cls.implements.contains(chk_cls)) { 
+                                       continue;
+                               }
+                               cls.implements.add(chk_cls);
+                               
+                               var subcls = this.fqn_to_cls(chk_cls);
+                               if (subcls == null) {
+                                       continue;
+                               }
+                               this.augment_implements_for(cls, subcls.implements);
+
+                       }
+               
+               }
+               
+               // this might miss out interfaces of child classes?
+               public void augment_all_inheritence()
+               {
+                       // this works out all the children...
+                       foreach(var pkgname in this.project.gir_cache.keys) {
+                       
+                               var pkg = this.project.gir_cache.get(pkgname);
+                               foreach (var clsname in pkg.classes.keys) {
+                                       var cls = pkg.classes.get(clsname);
+                                       this.augment_inherits_for(cls, cls.inherits, true);
+                                       this.augment_implements_for(cls, cls.implements);
+                               }
+                       }
+                       // now do the implementations
+                       foreach(var pkgname in this.project.gir_cache.keys) {
+                       
+                               var pkg = this.project.gir_cache.get(pkgname);
+                               foreach (var clsname in pkg.classes.keys) {
+                                       var cls = pkg.classes.get(clsname);
+                                       foreach(var parentname in cls.inherits) {
+                                               var parent =  this.fqn_to_cls(parentname);
+                                               if (parent == null) { 
+                                                       continue;
+                                               }
+                                               if (parent.implementations.contains(cls.fqn())) {
+                                                       continue;
+                                               }
+                                               parent.implementations.add(cls.fqn());
+                                       
+                                       }
+                                       foreach(var parentname in cls.implements) {
+                                               var parent =  this.fqn_to_cls(parentname);
+                                               if (parent == null) { 
+                                                       continue;
+                                               }
+                                               if (parent.implementations.contains(cls.fqn())) {
+                                                       continue;
+                                               }
+                                               parent.implementations.add(cls.fqn());
+                                       
+                                       }
+                               }
+                       }
+                       
+                               
+               }
+               
+                
+               
                public void add_property(GirObject parent, Vala.Property prop)
                {
                        var c = new GirObject("Prop",prop.name);
@@ -205,6 +305,12 @@ namespace Palete {
 #elif VALA_0_36
                        c.type  = prop.property_type.data_type == null ? "" : prop.property_type.data_type.get_full_name();             
 #endif
+                       c.is_readable = prop.get_accessor != null ?  prop.get_accessor.readable : false;
+                       c.is_writable = prop.get_accessor != null ?  prop.get_accessor.writable : false;
+                       if (prop.version.deprecated) { 
+                               GLib.debug("class %s is deprecated", c.name);
+                               c.is_deprecated = true;
+                       }
                        parent.props.set(prop.name,c);
 
                        
@@ -493,6 +599,11 @@ namespace Palete {
                        
                        Vala.CodeContext.pop ();
                        
+                       
+                       this.augment_all_inheritence();
+                       
+                       
+                       
                        print("ALL OK?\n");
                 
                }
index 25ef0a0..42aff3a 100644 (file)
@@ -7,6 +7,21 @@
  * 
  * we need to sort out that - paths is currently a key/value array..
  * 
+ * currently we store projects in ~/.Builder/{md5}.json
+   - then for Gtk projects we have a file config1.builder - which contains dependancies, and a list of files for each target
+     (for builder it's ended up in src/Builder/config1.builder? by accident.
+   - should really support something like 
+       roobuilder --build {path_to_cfg} {target} - or local directory if not set..
+       roobuilder --build-errors {path_to_cfg} {target} - or local directory if not set..
+       
+       
+   
+   
+   should really store project data in the directory of the project?
+   
+   
+   
  * 
  * 
  */