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