Fix #7250 - better handling of adding properties
[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           "",
55           "// add later? source?",
56           "/* was:",
57           "typeof(string),  // 0 real key",
58           "typeof(string), // 1 real type",
59           "typeof(string), // 2 docs ?",
60           "typeof(string), // 3 visable desc",
61           "typeof(string), // 4 function desc",
62           "typeof(string) // 5 element type (event|prop)",
63           "*/"
64          ],
65          "$ xns" : "Gtk",
66          "* pack" : "set_model",
67          "id" : "model",
68          "n_columns" : 4,
69          "xtype" : "ListStore",
70          "| JsRender.NodeProp getValue" : [
71           "(Gtk.TreeIter iter, int col)",
72           "{",
73           "",
74           "    GLib.Value value;",
75           "    this.el.get_value(iter, col, out value);",
76           " ",
77           "    return (JsRender.NodeProp)value;",
78           "    ",
79           "}"
80          ]
81         },
82         {
83          "$ xns" : "Gtk",
84          "* init" : [
85           "  this.el.add_attribute(_this.namerender.el , \"markup\", 1  );",
86           " ",
87           ""
88          ],
89          "* pack" : "append_column",
90          "id" : "namecol",
91          "items" : [
92           {
93            "$ xns" : "Gtk",
94            "* pack" : "pack_start,true",
95            "id" : "namerender",
96            "xtype" : "CellRendererText"
97           }
98          ],
99          "utf8 title" : "Double click to add",
100          "xtype" : "TreeViewColumn"
101         }
102        ],
103        "listeners" : {
104         "row_activated" : [
105          "(path, column)  => {",
106          "",
107          "\tGtk.TreeIter iter;",
108          "",
109          "",
110          "\tvar m = _this.model;",
111          "",
112          "\tm.el.get_iter(out iter,path);",
113          "",
114          " ",
115          "\tvar prop = m.getValue(iter, 0);",
116          " ",
117          "",
118          "\t// hide the popover",
119          "\t_this.el.hide();",
120          "\t ",
121          "\t",
122          "\t_this.select(prop);",
123          " ",
124          "}",
125          " "
126         ]
127        },
128        "tooltip_column" : 2,
129        "xtype" : "TreeView"
130       }
131      ],
132      "xtype" : "ScrolledWindow"
133     }
134    ],
135    "xtype" : "Popover",
136    "| void clear" : [
137     "() {",
138     " this.model.el.clear();",
139     "}",
140     ""
141    ],
142    "| void hide" : [
143     "() {",
144     "\tthis.ptype = JsRender.NodePropType.NONE;",
145     "\tthis.el.hide();",
146     "}",
147     ""
148    ],
149    "| void show" : [
150     "(Palete.Palete pal, JsRender.NodePropType ptype, string xtype,  Gtk.Widget onbtn) {",
151     "",
152     "    /// what does this do?",
153     "    //if (this.prop_or_listener  != \"\" && this.prop_or_listener == prop_or_listener) {",
154     "    //\tthis.prop_or_listener = \"\";",
155     "    //\tthis.el.hide();",
156     "    //\treturn;",
157     "\t//}",
158     "\t",
159     "\t",
160     "\t",
161     "    this.ptype = ptype;",
162     "    ",
163     "    this.model.el.clear();",
164     "",
165     "    Gtk.TreeIter iter;",
166     "    var elementList = pal.getPropertiesFor( xtype, ptype);",
167     "     ",
168     "    //print (\"GOT \" + elementList.length + \" items for \" + fullpath + \"|\" + type);",
169     "           // console.dump(elementList);",
170     "           ",
171     "    var miter = elementList.map_iterator();",
172     "    while (miter.next()) {",
173     "       var p = miter.get_value();",
174     "        ",
175     "        this.model.el.append(out iter);",
176     "\t\t",
177     "\t\tvar prop = p.toNodeProp();",
178     "\t\t",
179     "\t \t ",
180     "",
181     "        this.model.el.set(iter,",
182     "                0,  prop, ",
183     "                1,  prop.to_property_option_markup(),",
184     "                2,  prop.to_property_option_tooltip(),                ",
185     "                3,  prop.name,                ",
186     "                -1",
187     "        );",
188     "    }",
189     "    this.model.el.set_sort_column_id(3,Gtk.SortType.ASCENDING);    ",
190     "    ",
191     "    // set size up...",
192     "    ",
193     "",
194     "    int w,h;",
195     "    this.mainwindow.el.get_size(out w, out h);",
196     "    ",
197     "    // left tree = 250, editor area = 500?",
198     "    ",
199     "    // min 450?",
200     "\t// max hieght ...",
201     "    this.el.set_size_request( 250, h);",
202     "",
203     "    ",
204     "",
205     "    if (this.el.relative_to == null) {",
206     "        this.el.set_relative_to(onbtn);",
207     "    }",
208     "    this.el.show_all();",
209     "   ",
210     "    while(Gtk.events_pending()) { ",
211     "            Gtk.main_iteration();   // why?",
212     "    }       ",
213     " //   this.hpane.el.set_position( 0);",
214     "}",
215     ""
216    ]
217   }
218  ],
219  "modOrder" : "",
220  "name" : "PopoverAddProp",
221  "parent" : "",
222  "path" : "/home/alan/gitlive/roobuilder/src/Builder4/PopoverAddProp.bjs",
223  "permname" : "",
224  "title" : ""
225 }