35705a0aca043535e2ba799ab28f2303a42d19df
[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          "int sort_column_id" : 3,
94          "items" : [
95           {
96            "$ xns" : "Gtk",
97            "* pack" : "pack_start,true",
98            "id" : "namerender",
99            "xtype" : "CellRendererText"
100           }
101          ],
102          "utf8 title" : "Double click to add",
103          "xtype" : "TreeViewColumn"
104         },
105         {
106          "$ xns" : "Gtk",
107          "* init" : [
108           "  this.el.add_attribute(_this.typerender.el , \"text\", 3  );",
109           " ",
110           ""
111          ],
112          "* pack" : "append_column",
113          "id" : "type",
114          "int sort_column_id" : 4,
115          "items" : [
116           {
117            "$ xns" : "Gtk",
118            "* pack" : "pack_start,true",
119            "id" : "typerender",
120            "xtype" : "CellRendererText"
121           }
122          ],
123          "string title" : "Type",
124          "xtype" : "TreeViewColumn"
125         },
126         {
127          "$ xns" : "Gtk",
128          "* init" : [
129           "  this.el.add_attribute(_this.fromrender.el , \"text\", 5);",
130           " ",
131           ""
132          ],
133          "* pack" : "append_column",
134          "id" : "from",
135          "int sort_column_id" : 5,
136          "items" : [
137           {
138            "$ xns" : "Gtk",
139            "* pack" : "pack_start,true",
140            "id" : "fromrender",
141            "xtype" : "CellRendererText"
142           }
143          ],
144          "string title" : "From",
145          "xtype" : "TreeViewColumn"
146         }
147        ],
148        "listeners" : {
149         "row_activated" : [
150          "(path, column)  => {",
151          "",
152          "\tGtk.TreeIter iter;",
153          "",
154          "",
155          "\tvar m = _this.model;",
156          "",
157          "\tm.el.get_iter(out iter,path);",
158          "",
159          " ",
160          "\tvar prop = m.getValue(iter);",
161          " ",
162          "",
163          "\t// hide the popover",
164          "\t_this.el.hide();",
165          "\t ",
166          "\t",
167          "\t_this.select(prop);",
168          " ",
169          "}",
170          " "
171         ]
172        },
173        "tooltip_column" : 2,
174        "xtype" : "TreeView"
175       }
176      ],
177      "xtype" : "ScrolledWindow"
178     }
179    ],
180    "xtype" : "Popover",
181    "| void clear" : [
182     "() {",
183     " this.model.el.clear();",
184     "}",
185     ""
186    ],
187    "| void hide" : [
188     "() {",
189     "\tthis.ptype = JsRender.NodePropType.NONE;",
190     "\tthis.el.hide();",
191     "}",
192     ""
193    ],
194    "| void show" : [
195     "(Palete.Palete pal, JsRender.NodePropType ptype, string xtype,  Gtk.Widget onbtn) {",
196     "",
197     "    /// what does this do?",
198     "    //if (this.prop_or_listener  != \"\" && this.prop_or_listener == prop_or_listener) {",
199     "    //\tthis.prop_or_listener = \"\";",
200     "    //\tthis.el.hide();",
201     "    //\treturn;",
202     "\t//}",
203     "\t",
204     "\t",
205     "\t",
206     "    this.ptype = ptype;",
207     "    ",
208     "    this.model.el.clear();",
209     "",
210     "    Gtk.TreeIter iter;",
211     "    var elementList = pal.getPropertiesFor( xtype, ptype);",
212     "     ",
213     "    //print (\"GOT \" + elementList.length + \" items for \" + fullpath + \"|\" + type);",
214     "           // console.dump(elementList);",
215     "           ",
216     "    var miter = elementList.map_iterator();",
217     "    while (miter.next()) {",
218     "       var p = miter.get_value();",
219     "        ",
220     "        this.model.el.append(out iter);",
221     "\t\t",
222     "\t\tvar prop = p.toNodeProp();",
223     "\t\t",
224     "\t \t ",
225     "",
226     "        this.model.el.set(iter,",
227     "                0,  prop, ",
228     "                1,  prop.to_property_option_markup(),",
229     "                2,  prop.to_property_option_tooltip(),                ",
230     "                3,  prop.name,",
231     "                4,  prop.rtype,",
232     "                5,  p.propertyof,",
233     "                -1",
234     "        );",
235     "    }",
236     "    this.model.el.set_sort_column_id(3,Gtk.SortType.ASCENDING);    ",
237     "    ",
238     "    // set size up...",
239     "    ",
240     "",
241     "    int w,h;",
242     "    this.mainwindow.el.get_size(out w, out h);",
243     "    ",
244     "    // left tree = 250, editor area = 500?",
245     "    ",
246     "    // min 450?",
247     "\t// max hieght ...",
248     "    this.el.set_size_request( 550, h);",
249     "",
250     "    ",
251     "",
252     "    if (this.el.relative_to == null) {",
253     "        this.el.set_relative_to(onbtn);",
254     "    }",
255     "    this.el.show_all();",
256     "   ",
257     "    while(Gtk.events_pending()) { ",
258     "            Gtk.main_iteration();   // why?",
259     "    }       ",
260     " //   this.hpane.el.set_position( 0);",
261     "}",
262     ""
263    ]
264   }
265  ],
266  "modOrder" : "",
267  "name" : "PopoverAddProp",
268  "parent" : "",
269  "path" : "/home/alan/gitlive/roobuilder/src/Builder4/PopoverAddProp.bjs",
270  "permname" : "",
271  "title" : ""
272 }