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