03a4eb89a19fa932a6f1ae5dfd99b75bb0d6eaf8
[app.Builder.js] / src / Builder4 / GtkView.bjs
1 {
2  "name" : "GtkView",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/GtkView.bjs",
6  "permname" : "",
7  "modOrder" : "",
8  "build_module" : "builder",
9  "items" : [
10   {
11    "listeners" : {
12     "size_allocate" : "(aloc) => {\n\n    this.width = aloc.width;\n    this.height =aloc.height;\n    }\n"
13    },
14    "id" : "GtkView",
15    "| 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",
16    "# Gtk.Widget lastObj" : "null",
17    "| void loadFile" : "(JsRender.JsRender file) \n{\n        file.compile_notice.connect(this.compileNotice);\n       // this.el.set_position((int)(this.el.max_position * 0.7));\n        this.el.set_position(this.el.max_position );\n        this.file = null;\n        \n        if (file.tree == null) {\n            return;\n        }\n        this.file = file;\n        if (this.lastObj != null) {\n            this.container.el.remove(this.lastObj);\n        }\n        \n        // hide the compile view at present..\n          \n        \n        var w = this.width;\n        var h = this.height;\n        \n        print(\"ALLOC SET SIZES %d, %d\\n\", w,h); \n        \n        // set the container size min to 500/500 or 20 px less than max..\n        w = int.max (w-20, 500);\n        h = int.max (h-20, 500); \n        \n        print(\"SET SIZES %d, %d\\n\", w,h);       \n        _this.container.el.set_size_request(w,h);\n        \n        _this.view_layout.el.set_size(w,h); // should be baded on calc.. -- see update_scrolled.\n        var rgba = Gdk.RGBA ();\n        rgba.parse (\"#ccc\");\n        _this.view_layout.el.override_background_color(Gtk.StateFlags.NORMAL, rgba);\n        \n        \n\tvar x = new JsRender.NodeToGtk(file.tree);\n        var obj = x.munge() as Gtk.Widget;\n        this.lastObj = null;\n\tif (obj == null) {\n        \treturn;\n\t}\n\tthis.lastObj = obj;\n        \n        this.container.el.add(obj);\n        obj.show_all();\n        \n         \n        \n}\n ",
18    "int width" : 0,
19    "Xcls_MainWindow main_window" : "",
20    "xtype" : "VPaned",
21    "# JsRender.JsRender file" : "null",
22    "int height" : 0,
23    "| void compileNotice" : "( string  type,   string file,   int line,   string  message) {\n    // if type = \"START\"... then we reset the tree?\n    // the issue is that the compiler is continually going..\n    // so editing a file etc.. may change things.?\n    // probably not an issue.\n    print(\"err %s / %s:%d / %s\\n\", type,file,line,message);\n    \n    if (type ==\"START\") {\n        // reset the tree;\n        return;\n    }\n    var cs = _this.compile_result_store;\n    \n    var top = 0;\n    var title = \"\";\n    switch(type) {\n        case \"ERR\":\n            title = \"Errors\";\n            top =0;\n            break;\n        \n        case \"WARN\":\n            title = \"Warnings\";\n            top =1;\n            break;\n            \n        case \"DEPR\":\n            title = \"Depricated\";\n            top=2;\n            break;\n        \n        default:\n            title = type;\n            top =3;\n            break;\n    }\n            \n    \n     var tv = cs.nodeFindOrCreate(null, top.to_string(), title);\n     tv = cs.nodeFindOrCreate(tv, \"%d:%s\".printf(top, file), file);\n      cs.nodeAppendOrCreate(tv, \"%d:%s:%d\".printf(top, file,line), file,line, message);\n    \n}\n ",
24    "$ xns" : "Gtk",
25    "items" : [
26     {
27      "* pack" : "pack1,true,true",
28      "xtype" : "ScrolledWindow",
29      "$ xns" : "Gtk",
30      "items" : [
31       {
32        "id" : "view_layout",
33        "xtype" : "Layout",
34        "* pack" : "add",
35        "$ xns" : "Gtk",
36        "items" : [
37         {
38          "id" : "container",
39          "* pack" : "put,10,10",
40          "xtype" : "HBox",
41          "$ xns" : "Gtk"
42         }
43        ]
44       }
45      ]
46     },
47     {
48      "id" : "compile_view",
49      "xtype" : "VBox",
50      "* pack" : "pack2,true,true",
51      "gboolean homogeneous" : false,
52      "$ xns" : "Gtk",
53      "items" : [
54       {
55        "xtype" : "HBox",
56        "* pack" : "pack_start,false,false,0",
57        "$ xns" : "Gtk",
58        "items" : [
59         {
60          "* pack" : "pack_start,true,true,0",
61          "xtype" : "Button",
62          "$ xns" : "Gtk",
63          "utf8 label" : "Full Compile"
64         }
65        ]
66       },
67       {
68        "xtype" : "HPaned",
69        "* pack" : "pack_start,true,true,0",
70        "$ xns" : "Gtk",
71        "items" : [
72         {
73          "* init" : "{\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n\n}\n",
74          "* pack" : "add",
75          "xtype" : "ScrolledWindow",
76          "$ xns" : "Gtk",
77          "items" : [
78           {
79            "* pack" : "add",
80            "xtype" : "TreeView",
81            "$ xns" : "Gtk",
82            "items" : [
83             {
84              "gint n_columns" : 4,
85              "id" : "compile_result_store",
86              "columns" : "  typeof(string), typeof(int), typeof(string), typeof(string) ",
87              "* pack" : "set_model",
88              "xtype" : "TreeStore",
89              "| void nodeAppendOrCreate" : "(Gtk.TreePath  par, string id, string file, int line, string message) {\n\n    Gtk.TreeIter piter;\n     \n    this.el.get_iter(out piter, par);\n     \n    // loop through parent childnre\n    Gtk.TreeIter iter; \n    var loop =  par == null ? \n        this.el.iter_children(out iter, null) :\n         this.el.iter_children(out iter,  piter);\n    \n    while (loop) {\n        GLib.Value val;\n        this.el.get_value(iter, 0, out val);\n        var sval = (string)val;\n        if (sval == id) {\n            GLib.Value mval;\n            this.el.get_value(iter, 2, out mval);\n            var smval = (string)mval;\n            mval.set_string(smval + \"\\n\" + GLib.Markup.escape_text(message)); //markup?\n        \n            return;\n        }\n        loop = this.el.iter_next(ref iter);    \n    }\n    \n    // create the node...\n    if (par == null) {\n        this.el.append(out iter, null);\n    } else {\n        this.el.append(out iter, piter);\n    }\n    this.el.set(iter, 0, id, 1, line,2, GLib.Markup.escape_text(\"%d: %s\".printf(line,message)), 3, file,-1);\n        \n    return ;\n\n}   ",
90              "$ xns" : "Gtk",
91              "| Gtk.TreePath nodeFindOrCreate" : "(Gtk.TreePath? par, string id, string title) {\n\n\n    //print(\"looking for %s\\n\", id);\n    // loop through parent childnre\n    Gtk.TreeIter piter   ;\n    Gtk.TreeIter iter;\n    var loop = true;\n    if (par != null) {\n        this.el.get_iter(out piter, par);\n        loop = this.el.iter_children(out iter,  piter);\n    } else {\n        loop = this.el.iter_children(out iter, null) ;\n    }\n         \n         \n    while (loop) {\n        GLib.Value val;\n        this.el.get_value(iter, 0, out val);\n        var sval = (string)val;\n        //print(\"got node %s\", sval);\n        if (sval == id) {\n            return this.el.get_path(iter);\n        }\n        loop = this.el.iter_next(ref iter);    \n    }\n    // create the node...\n     if (par == null) {\n        this.el.append(out iter, null);\n    } else {\n      this.el.get_iter(out piter, par);\n        this.el.append(out iter, piter);\n    }\n    //print(\"add iter %s / %s\", id, title);\n    this.el.set(iter, 0, id, 1, 0, 2, title, 3, \"\",-1);\n       \n    return   this.el.get_path(iter);\n\n}\n "
92             },
93             {
94              "utf8 title" : "Compile output",
95              "* init" : "{\n  this.el.add_attribute(_this.renderer.el , \"markup\", 2 );\n \n}\n",
96              "xtype" : "TreeViewColumn",
97              "* pack" : "append_column",
98              "string id" : "column",
99              "$ xns" : "Gtk",
100              "items" : [
101               {
102                "id" : "renderer",
103                "xtype" : "CellRendererText",
104                "* pack" : "pack_start,true",
105                "$ xns" : "Gtk"
106               }
107              ]
108             }
109            ]
110           }
111          ]
112         },
113         {
114          "* pack" : "add",
115          "xtype" : "ScrolledWindow",
116          "$ xns" : "Gtk",
117          "items" : [
118           {
119            "gboolean show_line_marks" : true,
120            "xtype" : "View",
121            "* pack" : "add",
122            "$ xns" : "GtkSource",
123            "gboolean show_line_numbers" : true,
124            "gboolean editable" : false
125           }
126          ]
127         }
128        ]
129       }
130      ]
131     }
132    ]
133   }
134  ]
135 }