3 Pango = imports.gi.Pango;
4 GLib = imports.gi.GLib;
6 GObject = imports.gi.GObject;
7 GtkSource = imports.gi.GtkSource;
8 WebKit = imports.gi.WebKit;
10 console = imports.console;
11 XObject = imports.XObject.XObject;
12 builder.bjs=new XObject({
14 type : Gtk.WindowType.TOPLEVEL,
15 title : "Application Builder",
19 "STRING" : Gdk.atom_intern("STRING")
21 this.targetList = new Gtk.TargetList();
22 this.targetList.add( this.atoms["STRING"], 0, 0);
23 //imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();
25 "style \"gtkcombobox-style\" {\n" +
26 " GtkComboBox::appears-as-list = 1\n" +
28 "class \"GtkComboBox\" style \"gtkcombobox-style\"\n");
29 XObject.prototype.init.call(this);
30 // this.el.show_all();
48 pack : "pack_start,false,false",
60 label : "New Project",
73 xtype: Gtk.SeparatorMenuItem,
78 label : "Add Directory to Project",
85 xtype: Gtk.SeparatorMenuItem,
122 label : "Select Project",
124 pack : "pack_start,false,true",
126 XObject.prototype.init.call(this);
127 this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
138 pack : "pack_start,true,true",
140 XObject.prototype.init.call(this);
141 this.el.set_current_page(0);
146 xtype: Gtk.ScrolledWindow,
148 shadow_type : Gtk.ShadowType.IN,
150 XObject.prototype.init.call(this);
151 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
154 getPaleteProvider : function() {
155 var model = this.get('model');
156 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
157 return pm.getPalete(model.file.getType());
159 renderView : function() {
160 var model = this.get('model');
161 print("RENDER VIEW?" + model.file.getType());
162 switch( model.file.getType()) {
164 this.get('/RightBrowser.view').renderJS(model.toJS(false,true)[0]);
166 this.get('/RightGtkView').renderJS(model.toJS(false,true)[0]);
174 headers_visible : false,
175 enable_tree_lines : true,
178 XObject.prototype.init.call(this);
179 var description = new Pango.FontDescription.c_new();
180 description.set_size(8000);
181 this.el.modify_font(description);
183 this.selection = this.el.get_selection();
184 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
186 this.selection.signal['changed'].connect(function() {
187 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
188 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
192 Gtk.drag_source_set (
193 this.el, /* widget will be drag-able */
194 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
195 null, /* lists of target to support */
196 0, /* size of list */
197 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
200 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
202 Gtk.drag_source_add_text_targets(this.el);
205 this.el, /* widget that will accept a drop */
206 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
207 null, /* lists of target to support */
208 0, /* size of list */
209 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
212 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
213 Gtk.drag_dest_add_text_targets(this.el);
215 highlight : function(treepath_ar) {
216 if (treepath_ar.length && treepath_ar[0].length ) {
217 this.el.set_drag_dest_row(
218 new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);
220 this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
224 selectNode : function(treepath_str) {
225 this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
232 xtype: Gtk.TreeStore,
236 XObject.prototype.init.call(this);
237 this.el.set_column_types ( 3, [
238 GObject.TYPE_STRING, // title
239 GObject.TYPE_STRING, // tip
240 GObject.TYPE_STRING // source..
244 changed : function(n, refresh) {
245 print("MODEL CHANGED CALLED" + this.activePath);
246 if (this.activePath) {
247 var iter = new Gtk.TreeIter();
248 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
249 this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
250 this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
252 this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
254 //this.currentTree = this.toJS(false, true)[0];
255 this.file.items = this.toJS(false, false);
256 print("AFTER CHANGED");
257 //console.dump(this.file.items);
259 this.currentTree = this.file.items[0];
260 //console.log(this.file.toSource());
263 print("REDNER BROWSER?!");
264 this.get('/LeftTree').renderView();
266 var pm = this.get('/RightPalete.model');
267 if (!this.get('/RightPalete').provider) {
273 pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
274 //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
278 loadFile : function(f) {
284 console.log('missing file');
288 // load the file if not loaded..
289 if (f.items === false) {
291 f.loadItems(function() {
297 if (f.items.length && typeof(f.items[0]) == 'string') {
299 this.get('/RightEditor').el.show();
300 this.get('/RightEditor.view').load( f.items[0]);
304 //console.dump(f.items);
306 this.get('/LeftTree.view').el.expand_all();
308 if (!f.items.length) {
311 this.get('/Window.leftvpaned').el.set_position(80);
313 this.get('/LeftTree.view').el.set_cursor(
314 new Gtk.TreePath.from_string('0'), null, false);
318 this.get('/Window.leftvpaned').el.set_position(200);
322 //print("hide right editior");
323 this.get('/RightEditor').el.hide();
324 //print("set current tree");
325 this.currentTree = this.toJS(false, false)[0];
326 //console.dump(this.currentTree);
327 this.currentTree = this.currentTree || { items: [] };
328 this.get('/LeftTree').renderView();
329 //console.dump(this.map);
330 //var RightPalete = imports.Builder.RightPalete.RightPalete;
331 var pm = this.get('/RightPalete.model');
334 this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
336 if (!this.get('/RightPalete').provider) {
337 print ("********* PALETE PROVIDER MISSING?!!");
339 this.get('/LeftTree').renderView();
341 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
345 this.get('/Window.view-notebook').el.set_current_page(
346 this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
349 findDropNode : function(treepath_str, targets) {
351 // this is used by the dragdrop code in the roo version AFAIR..
353 var path = treepath_str.replace(/^builder-/, '');
354 // treemap is depreciated... - should really check if model has any entries..
356 if (!this.el.iter_n_children(null)) {
358 return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];
360 print("FIND treepath: " + path);
361 //console.dump(this.treemap);
363 if (!treepath_str.match(/^builder-/)) {
364 return []; // nothing!
366 if (targets === true) {
369 return this.findDropNodeByPath(path,targets)
371 findDropNodeByPath : function(treepath_str, targets, pref) {
372 var path = treepath_str + ''; // dupe it..
373 pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
375 //console.dump(this.treemap);
376 while (path.length) {
377 print("LOOKING FOR PATH: " + path);
378 var node_data = this.singleNodeToJS(path);
379 if (node_data === false) {
380 print("node not found");
384 var xname = this.get('/LeftTree.model').file.guessName(node_data);
387 targets.forEach(function(tg) {
391 if ((tg == xname) ) {
394 if (tg.indexOf(xname +':') === 0) {
396 prop = tg.split(':').pop();
401 if (last) { // pref is after/before..
402 // then it's after last
404 return []; // do not allow..
406 return [ last, pref , prop];
409 return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
411 var par = path.split(':');
414 path = par.join(':');
420 dropNode : function(target_data, node) {
421 console.dump(target_data);
422 var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
424 print("add where: " + target_data[1] );
427 if (target_data[1] < 2) { // before or after..
428 var ar = target_data[0].split(':');
430 parent = new Gtk.TreePath.from_string( ar.join(':') );
433 var n_iter = new Gtk.TreeIter();
434 var iter_par = new Gtk.TreeIter();
435 var iter_after = after ? new Gtk.TreeIter() : false;
439 if (parent !== false) {
440 this.el.get_iter(iter_par, parent);
447 print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
448 this.el.get_iter(iter_after, after);
449 this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
450 n_iter, iter_par, iter_after);
453 this.el.append(n_iter, iter_par);
457 if (typeof(node) == 'string') {
458 var ar = node.split('.');
459 var xtype = ar.pop();
462 '|xns' : ar.join('.'),
465 if (target_data.length == 3 && target_data[2].length) {
466 node['*prop'] = target_data[2];
470 // work out what kind of packing to use..
471 if (typeof(node.pack) == 'undefined' && parent !== false) {
472 var pal = this.get('/LeftTree').getPaleteProvider();
474 var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
475 print ("PNAME : " + pname);
476 var cname = pal.guessName(node);
477 print ("CNAME : " + cname);
478 node.pack = pal.getDefaultPack(pname, cname);
490 this.load(xitems, n_iter);
492 if (xitems || after) {
493 this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
495 // wee need to get the empty proptypes from somewhere..
497 //var olditer = this.activeIter;
498 this.activeIter = n_iter;
499 this.changed(node, true);
503 this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
505 //Builder.MidPropTree._model.load(node);
506 //Builder.MidPropTree._win.hideWin();
507 //Builder.LeftPanel._model.load( node);
511 moveNode : function(target_data, action) {
512 //print("MOVE NODE");
513 // console.dump(target_data);
514 var old_iter = new Gtk.TreeIter();
515 var s = this.get('/LeftTree.view').selection;
516 s.get_selected(this.el, old_iter);
517 var node = this.nodeToJS(old_iter,false);
518 //console.dump(node);
521 // needs to drop first, otherwise the target_data
522 // treepath will be invalid.
524 this.dropNode(target_data, node);
525 if (action & Gdk.DragAction.MOVE) {
526 // print("REMOVING OLD NODE");
527 this.el.remove(old_iter);
531 this.activeIter = false;
532 this.changed(false,true);
534 deleteSelected : function() {
536 var old_iter = new Gtk.TreeIter();
537 var s = this.get('/LeftTree.view').selection;
538 s.get_selected(this.el, old_iter);
541 this.el.remove(old_iter);
543 // rebuild treemap. -- depreciated.!!
546 //this.toJS(null, true) // does not do anything?
547 this.activeIter = false;
548 this.changed(false,true);
551 listAllTypes : function() {
552 var s = this.get('/LeftTree.view').selection;
553 print ("LIST ALL TYPES: " + s.count_selected_rows() );
555 if (s.count_selected_rows() > 0) {
556 var iter = new Gtk.TreeIter();
557 s.get_selected(this.el, iter);
559 // set some properties of the tree for use by the dropped element.
560 var value = new GObject.Value('');
561 this.el.get_value(iter, 2, value);
562 var data = JSON.parse(value.value);
565 var xname = this.get('/LeftTree.model').file.guessName(data);
566 console.log('selected:' + xname);
570 return []; // could not find it..
578 li.forEach(function(el) {
579 // this is specific to roo!!!?
581 var fullpath = _this.file.guessName(el);
582 if (fullpath.length && ret.indexOf(fullpath) < 0) {
587 if (el.items && el.items.length) {
596 addall([this.currentTree]);
598 // only if we have nothing, should we add '*top'
602 //console.log('all types in tree');
608 singleNodeToJS : function (treepath)
610 var iter = new Gtk.TreeIter();
611 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
615 var iv = this.getIterValue(iter, 2);
617 return JSON.parse(iv);
620 nodeToJS : function (iter, with_id)
622 var par = new Gtk.TreeIter();
623 var iv = this.getIterValue(iter, 2);
625 var k = JSON.parse(iv);
626 if (k.json && !this.el.iter_parent( par, iter )) {
631 var treepath_str = this.el.get_path(iter).to_string();
632 // not sure how we can handle mixed id stuff..
633 if (typeof(k.id) == 'undefined') {
634 k.id = 'builder-'+ treepath_str ;
638 this.treemap[ treepath_str ] = k;
639 k.xtreepath = treepath_str ;
642 if (this.el.iter_has_child(iter)) {
643 citer = new Gtk.TreeIter();
644 this.el.iter_children(citer, iter);
645 k.items = this.toJS(citer,with_id);
649 toJS : function(iter, with_id)
651 //Seed.print("WITHID: "+ with_id);
658 iter = new Gtk.TreeIter();
659 if (!this.el.get_iter_first(iter)) {
669 var k = this.nodeToJS(iter, with_id);
673 if (!this.el.iter_next(iter)) {
679 // convert the list into a json string..
683 getIterValue : function (iter, col) {
684 var gval = new GObject.Value('');
685 this.el.get_value(iter, col ,gval);
690 nodeTitle : function(c) {
693 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
694 if (sr) txt.push('<s>');
695 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
696 if (c.xtype) { txt.push(c.xtype); }
697 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
698 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
699 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
702 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
703 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
704 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
705 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
706 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
707 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
708 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
709 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
710 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
712 // for flat classes...
713 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
714 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
717 if (sr) txt.push('</s>');
718 return (txt.length == 0 ? "Element" : txt.join(" "));
720 nodeToJSON : function(c) {
728 return JSON.stringify(o);
730 load : function(tr,iter)
732 var citer = new Gtk.TreeIter();
733 //this.insert(citer,iter,0);
734 for(var i =0 ; i < tr.length; i++) {
736 this.el.insert(citer,iter,-1);
738 this.el.append(citer);
741 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
742 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
743 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
744 if (tr[i].items && tr[i].items.length) {
745 this.load(tr[i].items, citer);
751 xtype: Gtk.TreeViewColumn,
752 pack : "append_column",
754 XObject.prototype.init.call(this);
755 this.el.add_attribute(this.items[0].el , 'markup', 0 );
759 xtype: Gtk.CellRendererText,
771 id : "LeftProjectTree",
772 showNoProjectSelected : function() {
773 this.get('/StandardErrorDialog').show("Select a Project first.");
781 pack : "pack_start,false,false",
787 XObject.prototype.init.call(this);
788 this.el.add_attribute(this.get('render').el , 'markup', 1 );
790 getValue : function() {
791 var ix = this.el.get_active();
795 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
798 setValue : function(fn)
802 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
803 data.forEach(function(n, ix) {
815 xtype: Gtk.CellRendererText,
816 pack : "pack_start,true",
820 xtype: Gtk.ListStore,
823 XObject.prototype.init.call(this);
824 this.el.set_column_types ( 2, [
825 GObject.TYPE_STRING, // real key
826 GObject.TYPE_STRING // real type
832 loadData : function(data) {
833 var ov = this.get('/LeftProjectTree.combo').getValue();
835 var iter = new Gtk.TreeIter();
837 data.forEach(function(p) {
842 el.set_value(iter, 0, p.fn);
843 el.set_value(iter, 1, p.name);
847 this.get('/LeftProjectTree.combo').setValue(ov);
856 xtype: Gtk.ScrolledWindow,
858 shadow_type : Gtk.ShadowType.IN,
860 XObject.prototype.init.call(this);
861 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
866 headers_visible : false,
867 enable_tree_lines : true,
870 XObject.prototype.init.call(this);
871 var description = new Pango.FontDescription.c_new();
872 description.set_size(8000);
873 this.el.modify_font(description);
875 this.selection = this.el.get_selection();
876 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
884 xtype: Gtk.TreeStore,
888 XObject.prototype.init.call(this);
889 this.el.set_column_types ( 3, [
890 GObject.TYPE_STRING, // title
891 GObject.TYPE_STRING, // tip
892 GObject.TYPE_STRING // id..
896 loadProject : function(pr) {
901 this.get('/LeftProjectTree').project = pr;
902 this.load(pr.toTree());
903 this.get('/LeftProjectTree.view').el.expand_all();
905 load : function(tr,iter) {
907 console.log('Project tree load: ' + tr.length);
908 var citer = new Gtk.TreeIter();
909 //this.insert(citer,iter,0);
912 tr.forEach(function (r) {
914 _this.el.append(citer);
916 _this.el.insert(citer,iter,-1);
918 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
919 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
920 _this.el.set_value(citer, 2, '' + r.id ); //id
921 if (r.cn && r.cn.length) {
922 _this.load(r.cn, citer);
927 getValue : function(iter, col) {
928 var gval = new GObject.Value('');
929 this.el.get_value(iter, col ,gval);
930 return '' + gval.value;
934 xtype: Gtk.TreeViewColumn,
935 pack : "append_column",
937 XObject.prototype.init.call(this);
938 this.el.add_attribute(this.items[0].el , 'markup', 0 );
942 xtype: Gtk.CellRendererText,
965 pack : "pack_start,false,true,0",
982 stock : Gtk.STOCK_ADD,
983 icon_size : Gtk.IconSize.MENU
1008 stock : Gtk.STOCK_ADD,
1009 icon_size : Gtk.IconSize.MENU
1034 stock : Gtk.STOCK_ADD,
1035 icon_size : Gtk.IconSize.MENU
1047 id : "AddPropertyPopup",
1050 xtype: Gtk.MenuItem,
1052 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1059 xtype: Gtk.MenuItem,
1061 tooltip_markup : "Add what type of packing is to be used",
1068 xtype: Gtk.MenuItem,
1070 tooltip_markup : "Override the init method",
1077 xtype: Gtk.SeparatorMenuItem,
1081 xtype: Gtk.MenuItem,
1083 tooltip_markup : "Add a user defined string property",
1090 xtype: Gtk.MenuItem,
1092 tooltip_markup : "Add a user defined number property",
1099 xtype: Gtk.MenuItem,
1101 tooltip_markup : "Add a user defined boolean property",
1108 xtype: Gtk.SeparatorMenuItem,
1112 xtype: Gtk.MenuItem,
1114 tooltip_markup : "Add a user function boolean property",
1127 xtype: Gtk.ScrolledWindow,
1130 shadow_type : Gtk.ShadowType.IN,
1133 XObject.prototype.init.call(this);
1134 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1138 xtype: Gtk.TreeView,
1141 headers_visible : false,
1142 enable_tree_lines : true,
1144 XObject.prototype.init.call(this);
1146 this.selection = this.el.get_selection();
1147 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1150 var description = new Pango.FontDescription.c_new();
1151 description.set_size(8000);
1152 this.el.modify_font(description);
1159 xtype: Gtk.TreeStore,
1163 XObject.prototype.init.call(this);
1164 this.el.set_column_types ( 5, [
1165 GObject.TYPE_STRING, // 0 real key
1166 GObject.TYPE_STRING, // 1 real value
1167 GObject.TYPE_STRING, // 2 visable key
1168 GObject.TYPE_STRING, // 3 visable value
1169 GObject.TYPE_STRING, // 4 need to store type of!!!
1173 toShort : function(str) {
1174 var a = typeof(str) == 'string' ? str.split("\n") : [];
1175 return a.length > 1 ? a[0] + '....' : '' + str;
1177 load : function(ar) {
1180 this.get('/RightEditor').el.hide();
1187 var provider = this.get('/LeftTree').getPaleteProvider();
1190 var iter = new Gtk.TreeIter();
1192 if (typeof(ar[i]) == 'object') {
1196 var type = provider.findType(ar, i, ar[i]);
1198 this.el.append(iter);
1199 var p = this.el.get_path(iter).to_string();
1201 this.el.set_value(iter, 0, i);
1202 this.el.set_value(iter, 1, '' + ar[i]);
1203 this.el.set_value(iter, 2, i);
1204 this.el.set_value(iter, 3, this.toShort(ar[i]));
1205 this.el.set_value(iter, 4, type);
1207 ar.listeners = ar.listeners || {};
1208 for (var i in ar.listeners ) {
1209 this.el.append(iter);
1210 var p = this.el.get_path(iter).to_string();
1213 this.el.set_value(iter, 0, '!'+ i );
1214 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1215 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1217 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1218 this.el.set_value(iter, 4, 'function');
1222 add : function(info) {
1223 // info includes key, val, skel, etype..
1225 type = info.type.toLowerCase();
1226 var data = this.toJS();
1228 if (info.etype == 'events') {
1229 data.listeners = data.listeners || { };
1230 if (typeof(data.listeners[info.key]) != 'undefined') {
1231 return; //already set!
1234 if (typeof(data[info.key]) != 'undefined') {
1239 if (typeof(info.val) == 'undefined') {
1242 if (info.type == 'boolean') {
1245 if (type == 'number') {
1253 if (info.etype == 'events') {
1255 data.listeners[info.key] = info.val;
1258 data[info.key] = info.val;
1262 var map = this.load(data);
1264 // flag it as changed to the interface..
1266 this.get('/LeftTree.model').changed(data, true);
1269 this.startEditing(map[k]);
1272 LeftPanel.get('view').el.row_activated(
1273 new Gtk.TreePath.from_string(map[k]),
1274 LeftPanel.editableColumn.el
1278 startEditing : function(path,col) {
1280 * start editing path (or selected if not set..)
1281 * @param {String|false} path (optional) treepath to edit - selected tree gets
1282 * edited by default.
1283 * @param {Number} 0 or 1 (optional)- column to edit.
1286 if (typeof(path) == 'string') {
1287 tp = new Gtk.TreePath.from_string(path);
1289 var iter = new Gtk.TreeIter();
1290 var s = this.get('/LeftPanel.view').selection;
1291 s.get_selected(this.el, iter);
1292 tp = this.el.get_path(iter);
1293 path = tp.to_string();
1297 // which colum is to be edited..
1299 if (typeof(col) == 'undefined') {
1300 var k = this.getValue(path, 0);
1301 colObj = (!k.length || k == '|') ?
1302 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1304 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1307 // make sure the pulldown is set correctly..
1308 // not really needed for second col...
1310 var provider = this.get('/LeftTree').getPaleteProvider();
1312 var type = this.get('/LeftPanel.model').getType(path);
1313 var opts = provider.findOptions(type);
1314 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1316 if (opts === false) {
1317 this.get('/LeftPanel').editableColumn.setOptions([]);
1318 renderer.has_entry = true; /// probably does not have any effect.
1320 this.get('/LeftPanel').editableColumn.setOptions(opts);
1321 renderer.has_entry = false;
1325 // iter now has row...
1326 GLib.timeout_add(0, 100, function() {
1328 colObj.items[0].el.editable = true; // esp. need for col 0..
1329 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1338 deleteSelected : function() {
1339 var data = this.toJS();
1340 var iter = new Gtk.TreeIter();
1341 var s = this.get('/LeftPanel.view').selection;
1342 s.get_selected(this.el, iter);
1345 var gval = new GObject.Value('');
1346 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1348 var val = gval.value;
1349 if (val[0] == '!') {
1351 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1354 delete data.listeners[ val.substring(1)];
1355 if (!XObject.keys(data.listeners).length) {
1356 delete data.listeners;
1360 if (typeof(data[val]) == 'undefined') {
1368 this.get('/LeftTree.model').changed(data, true);
1372 changed : function(str, doRefresh) {
1373 if (!this.activePath) {
1376 var iter = new Gtk.TreeIter();
1377 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1379 this.el.set_value(iter, 1, '' +str);
1380 this.el.set_value(iter, 3, '' + this.toShort(str));
1381 // update the tree...
1382 var LeftTree = imports.Builder.LeftTree.LeftTree;
1383 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
1386 var iter = new Gtk.TreeIter();
1387 this.get('/LeftPanel.model').el.get_iter_first(iter);
1392 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
1395 ar.listeners = ar.listeners || {};
1396 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
1399 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
1402 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
1408 //print(JSON.stringify(ar));
1412 getType : function(treepath) {
1413 return this.getValue(treepath, 4);
1415 getValue : function(treepath_str, col) {
1416 var iter = new Gtk.TreeIter();
1417 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
1419 var gval = new GObject.Value('');
1420 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
1421 var val = '' + gval.value;
1425 var type = this.getType(this.el.get_path(iter).to_string());
1426 //print("TYPE: " +type + " - val:" + val);
1427 switch(type.toLowerCase()) {
1431 return parseFloat(val); // Nan ?? invalid!!?
1433 return val == 'true' ? true : false;
1439 editSelected : function(e) {
1440 print("EDIT SELECTED?");
1441 var iter = new Gtk.TreeIter();
1442 var s = this.get('/LeftPanel.view').selection;
1443 s.get_selected(this.get('/LeftPanel.model').el, iter);
1444 var m = this.get('/LeftPanel.model')
1446 var gval = new GObject.Value('');
1447 this.el.get_value(iter, 0 ,gval);
1448 var val = '' + gval.value;
1450 gval = new GObject.Value('');
1451 this.el.get_value(iter, 1 ,gval);
1452 var rval = gval.value;
1453 var activePath = this.el.get_path(iter).to_string();
1454 this.activePath = activePath ;
1455 // was activeIter...
1458 var showEditor = false;
1460 if (val[0] == '!') {
1463 if (val[0] == '|') {
1464 if (rval.match(/function/g) || rval.match(/\n/g)) {
1471 this.activePath = false;
1472 GLib.timeout_add(0, 1, function() {
1473 // Gdk.threads_enter();
1474 _this.get('/RightEditor').el.show();
1475 _this.get('/RightEditor.view').load( rval );
1479 _this.activePath = activePath ;
1481 // Gdk.threads_leave();
1487 this.get('/RightEditor').el.hide();
1489 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
1495 xtype: Gtk.TreeViewColumn,
1496 pack : "append_column",
1498 XObject.prototype.init.call(this);
1500 this.el.add_attribute(this.items[0].el , 'markup', 2 );
1501 this.get('/LeftPanel').propertyColumn = this;
1506 xtype: Gtk.CellRendererText,
1507 pack : "pack_start",
1515 xtype: Gtk.TreeViewColumn,
1516 pack : "append_column",
1518 XObject.prototype.init.call(this);
1519 this.el.add_attribute(this.items[0].el , 'text', 3 );
1520 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
1521 this.el.add_attribute(this.items[0].el , 'editable', 3 );
1522 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
1524 this.get('/LeftPanel').editableColumn= this;
1526 setOptions : function(ar) {
1527 var m = this.items[0].el.model;
1529 var iter = new Gtk.TreeIter();
1530 ar.forEach(function(i) {
1533 m.set_value(iter, 0, i);
1539 xtype: Gtk.CellRendererCombo,
1540 pack : "pack_start",
1545 XObject.prototype.init.call(this);
1546 this.el.model = new Gtk.ListStore();
1547 this.el.model.set_column_types ( 1, [
1548 GObject.TYPE_STRING // 0 real key
1562 id : "LeftPanelPopup",
1565 xtype: Gtk.MenuItem,
1573 xtype: Gtk.MenuItem,
1589 xtype: Gtk.ScrolledWindow,
1590 pack : "pack_end,false,true,0",
1592 shadow_type : Gtk.ShadowType.IN,
1594 XObject.prototype.init.call(this);
1595 XObject.prototype.init.call(this);
1596 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
1597 this.el.set_size_request ( 150, -1 );
1600 activeElement : false,
1601 hideWin : function() {
1608 if (this.get('/Window.left').el.position < 160) {
1611 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
1618 xtype: Gtk.TreeView,
1619 enable_tree_lines : true,
1620 headers_visible : false,
1623 XObject.prototype.init.call(this);
1625 var description = new Pango.FontDescription.c_new();
1626 description.set_size(8000);
1627 this.el.modify_font(description);
1629 //this.selection = this.el.get_selection();
1630 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1642 xtype: Gtk.ListStore,
1645 XObject.prototype.init.call(this);
1646 this.el.set_column_types ( 6, [
1647 GObject.TYPE_STRING, // real key
1648 GObject.TYPE_STRING, // real type
1649 GObject.TYPE_STRING, // docs ?
1650 GObject.TYPE_STRING, // visable desc
1651 GObject.TYPE_STRING, // function desc
1652 GObject.TYPE_STRING // element type (event|prop)
1656 getValue : function(treepath, col)
1658 var tp = new Gtk.TreePath.from_string (treepath);
1659 var iter = new Gtk.TreeIter();
1660 this.el.get_iter (iter, tp);
1661 var value = new GObject.Value('');
1662 this.el.get_value(iter, col, value);
1666 showData : function(type) {
1668 if (!this.get('/MidPropTree').activeElement || !type) {
1669 return; // no active element
1672 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
1673 var palete = this.get('/LeftTree').getPaleteProvider();
1677 Seed.print('Showing right?');
1678 if (!this.get('/MidPropTree').shown) {
1680 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
1681 this.get('/MidPropTree').el.show();
1682 this.get('/MidPropTree').shown = true;
1685 var elementList = palete.getPropertiesFor(fullpath, type);
1686 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
1687 // console.dump(elementList);
1690 var iter = new Gtk.TreeIter();
1691 for(var i =0 ; i < elementList.length; i++) {
1692 var p=elementList[i];
1693 this.el.append(iter);
1694 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
1695 //GObject.TYPE_STRING, // real key
1696 // GObject.TYPE_STRING, // real type
1697 // GObject.TYPE_STRING, // docs ?
1698 // GObject.TYPE_STRING // func def?
1701 this.el.set_value(iter, 0, p.name);
1702 this.el.set_value(iter, 1, p.type);
1703 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
1704 this.el.set_value(iter, 3, p.sig ? p.sig : '');
1705 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
1706 this.el.set_value(iter, 5, type);
1714 xtype: Gtk.TreeViewColumn,
1716 this.el = new Gtk.TreeViewColumn();
1717 this.parent.el.append_column(this.el);
1719 XObject.prototype.init.call(this);
1720 this.el.add_attribute(this.items[0].el , 'markup', 4 );
1725 xtype: Gtk.CellRendererText,
1726 pack : "pack_start,true"
1750 xtype: Gtk.Notebook,
1751 pack : "pack_start,true,true",
1752 id : "view-notebook",
1755 XObject.prototype.init.call(this);
1756 this.el.set_current_page(0);
1758 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
1759 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
1766 id : "RightBrowser",
1773 pack : "pack_start,false,true,0",
1777 pack : "pack_start,false,false,0",
1778 label : "Dump HTML to console",
1786 xtype: Gtk.ScrolledWindow,
1788 shadow_type : Gtk.ShadowType.IN,
1790 XObject.prototype.init.call(this);
1791 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1795 xtype: WebKit.WebView,
1799 XObject.prototype.init.call(this);
1800 // this may not work!?
1801 //this.el.open('file:///' + __script_path__ + '/../builder.html');
1805 this.el, /* widget that will accept a drop */
1806 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
1807 null, /* lists of target to support */
1808 0, /* size of list */
1809 Gdk.DragAction.COPY /* what to do with data after dropped */
1812 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
1813 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
1815 renderJS : function() {
1816 this.renderedData = data;
1817 var str = JSON.stringify(data) ;
1820 console.log('not loaded yet');
1822 Seed.print("RENDER:" + str);
1823 imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
1824 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
1837 id : "RightGtkView",
1838 buildJS : function(data,withDebug) {
1839 var i = [ 'Gtk', 'Gdk', 'Pango', 'GLib', 'Gio', 'GObject',
1840 'GtkSource', 'WebKit', 'Vte' ];
1842 i.forEach(function(e) {
1843 src += e+" = imports.gi." + e +";\n";
1845 src += "console = imports.console;\n"; // path?!!?
1846 src += "XObject = imports.XObject.XObject;\n"; // path?!!?
1848 src += "XObject.debug=true;\n";
1850 this.withDebug = withDebug;
1852 src += '_top=new XObject('+ this.mungeToString(data) + ')\n;';
1853 src += '_top.init();\n';
1855 imports.File.File.write('/tmp/BuilderGtkView.js', src);
1856 print("Test code in /tmp/BuilderGtkView.js");
1860 renderJS : function(data, withDebug)
1862 // can we mess with data?!?!?
1866 * sandbox it? - nope then will have dificulting passing. stuff aruond..
1872 this.withDebug = false;
1873 var src = this.buildJS(data,withDebug);
1874 var x = new imports.sandbox.Context();
1876 //x.get_global_object().a = "hello world";
1879 Seed.check_syntax('var e = ' + src);
1882 // if (!withDebug) {
1883 // return this.renderJS(data,true);
1885 print(e.message || e.toString());
1890 var r = new Gdk.Rectangle();
1891 var _top = x.get_global_object()._top;
1893 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
1895 if (_top.el.popup) {
1896 _top.el.popup(null, null, null, null, 3, null);
1901 var pb = _top.el.get_snapshot(r);
1909 var gc = new Gdk.GC.c_new(this.get('/Window').el.window);
1911 // 10 points all round..
1912 var full = new Gdk.Pixmap.c_new (this.get('/Window').el.window, r.width+20, r.height+20, pb.get_depth());
1913 // draw a white background..
1914 // gc.set_rgb_fg_color({ red: 0, white: 0, black : 0 });
1915 Gdk.draw_rectangle(full, gc, true, 0, 0, r.width+20, r.height+20);
1917 Gdk.draw_drawable (full, gc, pb, 0, 0, 10, 10, r.width, r.height);
1919 //gc.set_rgb_fg_color({ red: 255, white: 255, black : 255 });
1920 Gdk.draw_rectangle(full, gc, true, 0, 0, 10, 10);
1921 this.get('view').el.set_from_pixmap(full, null);
1922 //this.get('view-vbox').el.set_size_request( r.width+20, r.height+20);
1923 //var img = new Gtk.Image.from_file("/home/alan/solarpanels.jpeg");
1928 showInWindow : function() {
1929 var src= this.buildJS(
1930 this.get('/LeftTree.model').toJS()[0],
1935 //var x = new imports.sandbox.Context();
1939 Seed.check_syntax('var e = ' + src);
1942 this.get('/Terminal').feed(e.message || e.toString() + "\n");
1943 this.get('/Terminal').feed(console._dump(e)+"\n");
1945 var lines = src.split("\n");
1946 var start = Math.max(0, e.line - 10);
1947 var end = Math.min(lines.length, e.line + 10);
1948 for (var i =start ; i < end; i++) {
1950 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
1953 this.get('/Terminal').feed(lines[i] + "\n");
1960 this.get('/BottomPane').el.set_current_page(1);
1961 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
1962 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
1963 this.get('/Terminal').el.feed_child(cmd, cmd.length);
1965 var _top = x.get_global_object()._top;
1967 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
1969 if (_top.el.popup) {
1970 _top.el.popup(null, null, null, null, 3, null);
1974 mungeToString : function(obj, isListener, pad)
1978 var isArray = false;
1979 isListener = isListener || false;
1981 // am I munging a object or array...
1982 if (obj.constructor.toString() === Array.toString()) {
1983 for (var i= 0; i < obj.length; i++) {
1988 for (var i in obj) {
1997 typeof(obj['|xns']) != 'undefined' &&
1998 typeof(obj['xtype']) != 'undefined'
2000 els.push('xtype: '+ obj['|xns'] + '.' + obj['xtype']);
2001 skip.push('|xns','xtype');
2008 keys.forEach(function(i) {
2010 if (!isArray && skip.indexOf(i) > -1) {
2014 if (!_this.withDebug) {
2015 // do not write listeners unless we are debug mode.
2018 //if (obj[i].match(new RegExp("Gtk.main" + "_quit"))) { // we can not handle this very well..
2021 var str= ('' + obj[i]).replace(/^\s+|\s+$/g,"");
2022 var lines = str.split("\n");
2023 if (lines.length > 1) {
2024 str = lines.join("\n" + pad);
2026 els.push(JSON.stringify(i) + ":" + str);
2030 // does not hapepnd with arrays..
2031 if (typeof(el) == 'string' && !obj[i].length) { //skip empty.
2034 // this needs to go...
2035 // if (typeof(el) == 'string' && obj[i].match(new RegExp("Gtk.main" + "_quit"))) { // we can not handle this very well..
2039 var str= ('' + obj[i]).replace(/^\s+|\s+$/g,"");;
2040 var lines = str.split("\n");
2041 if (lines.length > 1) {
2042 str = lines.join("\n" + pad);
2045 els.push(JSON.stringify(i.substring(1)) + ":" + str);
2048 var left = isArray ? '' : (JSON.stringify(i) + " : " )
2049 if (typeof(el) == 'object') {
2050 els.push(left + _this.mungeToString(el, i == 'listeners', pad + ' '));
2053 els.push(JSON.stringify(i) + ":" + JSON.stringify(obj[i]));
2055 var spad = pad.substring(0, pad.length-4);
2056 return (isArray ? '[' : '{') + "\n" +
2057 pad + els.join(",\n" + pad ) +
2058 "\n" + spad + (isArray ? ']' : '}');
2066 pack : "pack_start,false,true,0",
2070 pack : "pack_start,false,false,0",
2071 label : "Run The Application",
2079 xtype: Gtk.ScrolledWindow,
2082 shadow_type : Gtk.ShadowType.IN,
2084 XObject.prototype.init.call(this);
2085 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2089 xtype: Gtk.Viewport,
2092 XObject.prototype.init.call(this);
2093 this.el.set_hadjustment(this.parent.el.get_hadjustment());
2094 this.el.set_vadjustment(this.parent.el.get_vadjustment());
2101 this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
2102 XObject.prototype.init.call(this);
2106 this.el, /* widget that will accept a drop */
2107 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2108 null, /* lists of target to support */
2109 0, /* size of list */
2110 Gdk.DragAction.COPY /* what to do with data after dropped */
2113 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2114 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2117 getActiveNode : function(x,y)
2119 // workout what node is here..
2120 return '0'; // top..
2138 xtype: Gtk.Notebook,
2141 XObject.prototype.init.call(this);
2142 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
2143 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
2148 xtype: Gtk.ScrolledWindow,
2153 xtype: GtkSource.View,
2157 XObject.prototype.init.call(this);
2158 var description = Pango.Font.description_from_string("monospace")
2159 description.set_size(8000);
2160 this.el.modify_font(description);
2163 load : function(str) {
2164 this.get('/BottomPane').el.set_current_page(0);
2165 this.el.get_buffer().set_text(str, str.length);
2166 var lm = GtkSource.LanguageManager.get_default();
2168 this.el.get_buffer().set_language(lm.get_language('js'));
2169 var buf = this.el.get_buffer();
2170 var cursor = buf.get_mark("insert");
2171 var iter= new Gtk.TextIter;
2172 buf.get_iter_at_mark(iter, cursor);
2174 iter.set_line_offset(4);
2175 buf.move_mark(cursor, iter);
2178 cursor = buf.get_mark("selection_bound");
2179 iter= new Gtk.TextIter;
2180 buf.get_iter_at_mark(iter, cursor);
2182 iter.set_line_offset(4);
2183 buf.move_mark(cursor, iter);
2185 this.el.grab_focus();
2189 xtype: GtkSource.Buffer,
2190 pack : "set_buffer",
2200 xtype: Gtk.ScrolledWindow,
2204 xtype: Vte.Terminal,
2207 feed : function(str) {
2208 this.el.feed(str,str.length);
2219 pack : "pack_start,false,false",
2223 this.get('buttonbar').el.show();
2224 this.get('viewbox').el.hide();
2225 print("TRIED TO HIDE");
2228 this.get('buttonbar').el.hide();
2229 this.get('viewbox').el.show();
2230 // this.get('model').expanded();
2242 pack : "pack_start,false,true",
2250 stock : Gtk.STOCK_GOTO_FIRST,
2251 icon_size : Gtk.IconSize.MENU
2261 XObject.prototype.init.call(this);
2262 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
2277 pack : "pack_start,false,true",
2286 pack : "pack_start,false,true",
2294 stock : Gtk.STOCK_GOTO_LAST,
2295 icon_size : Gtk.IconSize.MENU
2302 xtype: Gtk.ScrolledWindow,
2305 XObject.prototype.init.call(this);
2306 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2307 this.el.set_size_request(-1,200);
2309 shadow_type : Gtk.ShadowType.IN,
2312 xtype: Gtk.TreeView,
2315 XObject.prototype.init.call(this);
2316 this.el.set_size_request(150,-1);
2317 // set_reorderable: [1]
2319 var description = new Pango.FontDescription.c_new();
2320 description.set_size(8000);
2321 this.el.modify_font(description);
2323 this.selection = this.el.get_selection();
2324 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2325 // this.selection.signal['changed'].connect(function() {
2326 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
2328 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
2330 Gtk.drag_source_set (
2331 this.el, /* widget will be drag-able */
2332 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
2333 null, /* lists of target to support */
2334 0, /* size of list */
2335 Gdk.DragAction.COPY /* what to do with data after dropped */
2337 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
2339 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
2340 Gtk.drag_source_add_text_targets(this.el);
2342 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
2343 targets = new Gtk.TargetList();
2344 targets.add( LeftTree.atoms["STRING"], 0, 0);
2345 targets.add_text_targets( 1 );
2346 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
2348 //if you want to allow text to be output elsewhere..
2349 //Gtk.drag_source_add_text_targets(this.el);
2358 xtype: Gtk.ListStore,
2361 XObject.prototype.init.call(this);
2362 this.el.set_column_types ( 2, [
2363 GObject.TYPE_STRING, // title
2364 GObject.TYPE_STRING // tip
2369 load : function(tr,iter)
2374 //console.log('Project tree load: ' + tr.length);
2375 var citer = new Gtk.TreeIter();
2376 //this.insert(citer,iter,0);
2377 for(var i =0 ; i < tr.length; i++) {
2380 this.el.append(citer);
2382 this.el.insert(citer,iter,-1);
2387 this.el.set_value(citer, 0, '' + r ); // title
2389 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
2390 //if (r.cn && r.cn.length) {
2391 // this.load(r.cn, citer);
2397 getValue : function (iter, col) {
2398 var gval = new GObject.Value('');
2399 this.el.get_value(iter, col ,gval);
2406 xtype: Gtk.TreeViewColumn,
2407 pack : "append_column",
2409 XObject.prototype.init.call(this);
2410 this.el.add_attribute(this.items[0].el , 'markup', 0 );
2414 xtype: Gtk.CellRendererText,
2435 ;builder.bjs.init();