src/Builder4/PopoverAddProp.bjs
[roobuilder] / src / Builder4 / PopoverAddProp.bjs
1 {
2  "build_module" : "",
3  "items" : [
4   {
5    "# JsRender.NodePropType ptype" : "",
6    "$ xns" : "Gtk",
7    "@ void select" : "(JsRender.NodeProp prop)",
8    "Gtk.PositionType position" : "Gtk.PositionType.RIGHT",
9    "Xcls_MainWindow mainwindow" : "",
10    "bool active" : false,
11    "bool hexpand" : false,
12    "bool modal" : true,
13    "id" : "PopoverAddProp",
14    "int height_request" : 800,
15    "int width_request" : 900,
16    "items" : [
17     {
18      "$ shadow_type" : "Gtk.ShadowType.IN",
19      "$ xns" : "Gtk",
20      "* init" : [
21       "    this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
22       " "
23      ],
24      "* pack" : "add",
25      "items" : [
26       {
27        "$ enable_tree_lines" : true,
28        "$ headers_visible" : true,
29        "$ xns" : "Gtk",
30        "* init" : [
31         "{  ",
32         "       var description = new Pango.FontDescription();",
33         "     description.set_size(10000);",
34         "    this.el.override_font(description);     ",
35         "                    ",
36         "    this.el.get_selection().set_mode( Gtk.SelectionMode.SINGLE);",
37         " ",
38         "",
39         "    ",
40         "  ",
41         "    ",
42         "}",
43         ""
44        ],
45        "* pack" : "add",
46        "items" : [
47         {
48          "$ columns" : [
49           "",
50           "typeof(JsRender.NodeProp),  // 0 real key",
51           "typeof(string),  // text display",
52           "typeof(string),  // tooltip",
53           "typeof(string),  // sortable string",
54           "typeof(string), // prop type",
55           "typeof(string) // from interface",
56           "",
57           "// add later? source?",
58           "/* was:",
59           "typeof(string),  // 0 real key",
60           "typeof(string), // 1 real type",
61           "typeof(string), // 2 docs ?",
62           "typeof(string), // 3 visable desc",
63           "typeof(string), // 4 function desc",
64           "typeof(string) // 5 element type (event|prop)",
65           "*/"
66          ],
67          "$ xns" : "Gtk",
68          "* pack" : "set_model",
69          "id" : "model",
70          "n_columns" : 6,
71          "xtype" : "ListStore",
72          "| JsRender.NodeProp getValue" : [
73           "(Gtk.TreeIter iter)",
74           "{",
75           "",
76           "    GLib.Value value;",
77           "    this.el.get_value(iter, 0, out value);",
78           " ",
79           "    return (JsRender.NodeProp)value;",
80           "    ",
81           "}"
82          ]
83         },
84         {
85          "$ xns" : "Gtk",
86          "* init" : [
87           "  this.el.add_attribute(_this.namerender.el , \"markup\", 1  );",
88           " ",
89           ""
90          ],
91          "* pack" : "append_column",
92          "id" : "namecol",
93          "items" : [
94           {
95            "$ xns" : "Gtk",
96            "* pack" : "pack_start,true",
97            "id" : "namerender",
98            "xtype" : "CellRendererText"
99           }
100          ],
101          "utf8 title" : "Double click to add",
102          "xtype" : "TreeViewColumn"
103         },
104         {
105          "$ xns" : "Gtk",
106          "* init" : [
107           "  this.el.add_attribute(_this.typerender.el , \"markup\", 1  );",
108           " ",
109           ""
110          ],
111          "* pack" : "append_column",
112          "id" : "type",
113          "items" : [
114           {
115            "$ xns" : "Gtk",
116            "* pack" : "composite_name",
117            "id" : "typerender",
118            "xtype" : "CellRendererText"
119           }
120          ],
121          "string title" : "Type",
122          "xtype" : "TreeViewColumn"
123         },
124         {
125          "$ xns" : "Gtk",
126          "* init" : [
127           "  this.el.add_attribute(_this.typerender.el , \"markup\", 1  );",
128           " ",
129           ""
130          ],
131          "* pack" : "append_column",
132          "id" : "from",
133          "int sort_column_id" : 4,
134          "items" : [
135           {
136            "$ xns" : "Gtk",
137            "* pack" : "composite_name",
138            "id" : "fromrender",
139            "xtype" : "CellRendererText"
140           }
141          ],
142          "string title" : "From",
143          "xtype" : "TreeViewColumn"
144         }
145        ],
146        "listeners" : {
147         "row_activated" : [
148          "(path, column)  => {",
149          "",
150          "\tGtk.TreeIter iter;",
151          "",
152          "",
153          "\tvar m = _this.model;",
154          "",
155          "\tm.el.get_iter(out iter,path);",
156          "",
157          " ",
158          "\tvar prop = m.getValue(iter);",
159          " ",
160          "",
161          "\t// hide the popover",
162          "\t_this.el.hide();",
163          "\t ",
164          "\t",
165          "\t_this.select(prop);",
166          " ",
167          "}",
168          " "
169         ]
170        },
171        "tooltip_column" : 2,
172        "xtype" : "TreeView"
173       }
174      ],
175      "xtype" : "ScrolledWindow"
176     }
177    ],
178    "xtype" : "Popover",
179    "| void clear" : [
180     "() {",
181     " this.model.el.clear();",
182     "}",
183     ""
184    ],
185    "| void hide" : [
186     "() {",
187     "\tthis.ptype = JsRender.NodePropType.NONE;",
188     "\tthis.el.hide();",
189     "}",
190     ""
191    ],
192    "| void show" : [
193     "(Palete.Palete pal, JsRender.NodePropType ptype, string xtype,  Gtk.Widget onbtn) {",
194     "",
195     "    /// what does this do?",
196     "    //if (this.prop_or_listener  != \"\" && this.prop_or_listener == prop_or_listener) {",
197     "    //\tthis.prop_or_listener = \"\";",
198     "    //\tthis.el.hide();",
199     "    //\treturn;",
200     "\t//}",
201     "\t",
202     "\t",
203     "\t",
204     "    this.ptype = ptype;",
205     "    ",
206     "    this.model.el.clear();",
207     "",
208     "    Gtk.TreeIter iter;",
209     "    var elementList = pal.getPropertiesFor( xtype, ptype);",
210     "     ",
211     "    //print (\"GOT \" + elementList.length + \" items for \" + fullpath + \"|\" + type);",
212     "           // console.dump(elementList);",
213     "           ",
214     "    var miter = elementList.map_iterator();",
215     "    while (miter.next()) {",
216     "       var p = miter.get_value();",
217     "        ",
218     "        this.model.el.append(out iter);",
219     "\t\t",
220     "\t\tvar prop = p.toNodeProp();",
221     "\t\t",
222     "\t \t ",
223     "",
224     "        this.model.el.set(iter,",
225     "                0,  prop, ",
226     "                1,  prop.to_property_option_markup(),",
227     "                2,  prop.to_property_option_tooltip(),                ",
228     "                3,  prop.name,",
229     "                4,  prop.type,",
230     "                5,  p.propertyof",
231     "                -1",
232     "        );",
233     "    }",
234     "    this.model.el.set_sort_column_id(3,Gtk.SortType.ASCENDING);    ",
235     "    ",
236     "    // set size up...",
237     "    ",
238     "",
239     "    int w,h;",
240     "    this.mainwindow.el.get_size(out w, out h);",
241     "    ",
242     "    // left tree = 250, editor area = 500?",
243     "    ",
244     "    // min 450?",
245     "\t// max hieght ...",
246     "    this.el.set_size_request( 450, h);",
247     "",
248     "    ",
249     "",
250     "    if (this.el.relative_to == null) {",
251     "        this.el.set_relative_to(onbtn);",
252     "    }",
253     "    this.el.show_all();",
254     "   ",
255     "    while(Gtk.events_pending()) { ",
256     "            Gtk.main_iteration();   // why?",
257     "    }       ",
258     " //   this.hpane.el.set_position( 0);",
259     "}",
260     ""
261    ]
262   }
263  ],
264  "modOrder" : "",
265  "name" : "PopoverAddProp",
266  "parent" : "",
267  "path" : "/home/alan/gitlive/roobuilder/src/Builder4/PopoverAddProp.bjs",
268  "permname" : "",
269  "title" : ""
270 }