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