263602fe6e1e4a0762a5022ec943af27eac9b2d7
[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" : "typerenderer",
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            "xtype" : "TreeView"
139           }
140          ],
141          "string title" : "From",
142          "xtype" : "TreeView"
143         }
144        ],
145        "listeners" : {
146         "row_activated" : [
147          "(path, column)  => {",
148          "",
149          "\tGtk.TreeIter iter;",
150          "",
151          "",
152          "\tvar m = _this.model;",
153          "",
154          "\tm.el.get_iter(out iter,path);",
155          "",
156          " ",
157          "\tvar prop = m.getValue(iter);",
158          " ",
159          "",
160          "\t// hide the popover",
161          "\t_this.el.hide();",
162          "\t ",
163          "\t",
164          "\t_this.select(prop);",
165          " ",
166          "}",
167          " "
168         ]
169        },
170        "tooltip_column" : 2,
171        "xtype" : "TreeView"
172       }
173      ],
174      "xtype" : "ScrolledWindow"
175     }
176    ],
177    "xtype" : "Popover",
178    "| void clear" : [
179     "() {",
180     " this.model.el.clear();",
181     "}",
182     ""
183    ],
184    "| void hide" : [
185     "() {",
186     "\tthis.ptype = JsRender.NodePropType.NONE;",
187     "\tthis.el.hide();",
188     "}",
189     ""
190    ],
191    "| void show" : [
192     "(Palete.Palete pal, JsRender.NodePropType ptype, string xtype,  Gtk.Widget onbtn) {",
193     "",
194     "    /// what does this do?",
195     "    //if (this.prop_or_listener  != \"\" && this.prop_or_listener == prop_or_listener) {",
196     "    //\tthis.prop_or_listener = \"\";",
197     "    //\tthis.el.hide();",
198     "    //\treturn;",
199     "\t//}",
200     "\t",
201     "\t",
202     "\t",
203     "    this.ptype = ptype;",
204     "    ",
205     "    this.model.el.clear();",
206     "",
207     "    Gtk.TreeIter iter;",
208     "    var elementList = pal.getPropertiesFor( xtype, ptype);",
209     "     ",
210     "    //print (\"GOT \" + elementList.length + \" items for \" + fullpath + \"|\" + type);",
211     "           // console.dump(elementList);",
212     "           ",
213     "    var miter = elementList.map_iterator();",
214     "    while (miter.next()) {",
215     "       var p = miter.get_value();",
216     "        ",
217     "        this.model.el.append(out iter);",
218     "\t\t",
219     "\t\tvar prop = p.toNodeProp();",
220     "\t\t",
221     "\t \t ",
222     "",
223     "        this.model.el.set(iter,",
224     "                0,  prop, ",
225     "                1,  prop.to_property_option_markup(),",
226     "                2,  prop.to_property_option_tooltip(),                ",
227     "                3,  prop.name,",
228     "                4,  prop.type,",
229     "                5,  p.propertyof",
230     "                -1",
231     "        );",
232     "    }",
233     "    this.model.el.set_sort_column_id(3,Gtk.SortType.ASCENDING);    ",
234     "    ",
235     "    // set size up...",
236     "    ",
237     "",
238     "    int w,h;",
239     "    this.mainwindow.el.get_size(out w, out h);",
240     "    ",
241     "    // left tree = 250, editor area = 500?",
242     "    ",
243     "    // min 450?",
244     "\t// max hieght ...",
245     "    this.el.set_size_request( 450, h);",
246     "",
247     "    ",
248     "",
249     "    if (this.el.relative_to == null) {",
250     "        this.el.set_relative_to(onbtn);",
251     "    }",
252     "    this.el.show_all();",
253     "   ",
254     "    while(Gtk.events_pending()) { ",
255     "            Gtk.main_iteration();   // why?",
256     "    }       ",
257     " //   this.hpane.el.set_position( 0);",
258     "}",
259     ""
260    ]
261   }
262  ],
263  "modOrder" : "",
264  "name" : "PopoverAddProp",
265  "parent" : "",
266  "path" : "/home/alan/gitlive/roobuilder/src/Builder4/PopoverAddProp.bjs",
267  "permname" : "",
268  "title" : ""
269 }