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;
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);
39 "delete_event":function (self, event) {
42 "destroy":function (self) {
45 "show":function (self) {
46 print("WINDOW SHOWING - trying to hide");
47 imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();
48 this.get('/MidPropTree').hideWin();
49 this.get('/RightPalete').hide();
60 pack : "pack_start,false,false",
72 label : "New Project",
74 "activate":function (self) {
75 this.get('/EditProject').show({
76 success : function(pr) {
77 this.get('/LeftProjectTree').get('combo').setValue(pr.fn);
87 "activate":function (self) {
88 var fn = this.get('/LeftProjectTree.combo').getValue();
90 this.get('/LeftProjectTree').showNoProjectSelected();
93 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
94 this.get('/DialogNewComponent').show({
95 project : pm.getByFn(fn)
101 xtype: Gtk.SeparatorMenuItem,
139 label : "Select Project",
141 pack : "pack_start,false,true",
143 XObject.prototype.init.call(this);
144 this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
147 "activate":function (self) {
148 var nb = this.get('/LeftTopPanel.notebook');
149 if (this.el.expanded) {
152 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
155 var model = this.get('/LeftProjectTree.combomodel');
156 // print ("loading Projects?")
157 //console.dump(pm.projects);
158 model.loadData(pm.projects);
161 nb.el.set_current_page(1);
162 //pm.on('changed', function() {
163 //console.log("CAUGHT project manager change");
164 // _combo.model.loadData(pm.projects);
168 nb.el.set_current_page(0);
170 "enter_notify_event":function (self, event) {
171 this.el.expanded = !this.el.expanded;
172 //if (this.el.expanded ) {
173 this.listeners.activate.call(this);
185 pack : "pack_start,true,true",
187 XObject.prototype.init.call(this);
188 this.el.set_current_page(0);
193 xtype: Gtk.ScrolledWindow,
195 shadow_type : Gtk.ShadowType.IN,
197 XObject.prototype.init.call(this);
198 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
201 getPaleteProvider : function() {
202 var model = this.get('model');
203 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
204 return pm.getPalete(model.file.getType());
206 renderView : function() {
207 var model = this.get('model');
208 print("RENDER VIEW?" + model.file.getType());
209 switch( model.file.getType()) {
211 this.get('/RightBrowser.view').renderJS(model.toJS(false,true)[0]);
213 this.get('/RightGtkView').renderJS(model.toJS(false,true)[0]);
221 headers_visible : false,
222 enable_tree_lines : true,
225 XObject.prototype.init.call(this);
226 var description = new Pango.FontDescription.c_new();
227 description.set_size(8000);
228 this.el.modify_font(description);
230 this.selection = this.el.get_selection();
231 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
233 this.selection.signal['changed'].connect(function() {
234 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
235 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
239 Gtk.drag_source_set (
240 this.el, /* widget will be drag-able */
241 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
242 null, /* lists of target to support */
243 0, /* size of list */
244 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
247 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
249 Gtk.drag_source_add_text_targets(this.el);
252 this.el, /* widget that will accept a drop */
253 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
254 null, /* lists of target to support */
255 0, /* size of list */
256 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
259 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
260 Gtk.drag_dest_add_text_targets(this.el);
262 highlight : function(treepath_ar) {
263 if (treepath_ar.length && treepath_ar[0].length ) {
264 this.el.set_drag_dest_row(
265 new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);
267 this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
271 selectNode : function(treepath_str) {
272 //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
273 var tp = new Gtk.TreePath.from_string(treepath_str);
274 this.el.set_cursor(tp, null, false);
275 this.el.scroll_to_cell(tp, null, false, 0,0);
278 "button_press_event":function (self, ev) {
279 console.log("button press?");
280 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
281 print("click" + ev.type);
287 this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
289 if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();
291 this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
292 this.get('/LeftTreeMenu').el.show_all();
293 this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
294 print("click:" + res.path.to_string());
297 "drag_begin":function (self, drag_context) {
298 print('SOURCE: drag-begin');
299 this.targetData = false;
300 // find what is selected in our tree...
301 var iter = new Gtk.TreeIter();
302 var s = this.selection;
303 s.get_selected(this.get('/LeftTree.model').el, iter);
305 // set some properties of the tree for use by the dropped element.
306 var value = new GObject.Value('');
307 this.get('/LeftTree.model').el.get_value(iter, 2, value);
308 var data = JSON.parse(value.value);
309 var xname = this.get('/LeftTree.model').file.guessName(data);
311 this.el.dragData = xname;
312 this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);
315 // make the drag icon a picture of the node that was selected
316 var path = this.get('/LeftTree.model').el.get_path(iter);
317 this.el.treepath = path.to_string();
319 var pix = this.el.create_row_drag_icon ( path);
321 Gtk.drag_set_icon_pixmap (ctx,
330 "drag_end":function (self, drag_context) {
331 Seed.print('LEFT-TREE: drag-end');
332 this.el.dragData = false;
333 this.el.dropList = false;
334 this.targetData = false;
335 this.get('/LeftTree.view').highlight(false);
338 "drag_motion":function (self, ctx, x, y, time) {
339 console.log("LEFT-TREE: drag-motion");
340 var src = Gtk.drag_get_source_widget(ctx);
342 // a drag from elsewhere...- prevent drop..
344 print("no drag data!");
345 Gdk.drag_status(ctx, 0, time);
346 this.targetData = false;
349 var action = Gdk.DragAction.COPY;
350 if (src == this.el) {
351 // unless we are copying!!! ctl button..
352 action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
356 if (!this.get('/LeftTree.model').el.iter_n_children(null)) {
357 // no children.. -- asume it's ok..
358 this.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];
359 Gdk.drag_status(ctx, action ,time);
363 print("GETTING POS");
364 var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);
365 print("ISOVER? " + isOver);
367 Gdk.drag_status(ctx, 0 ,time);
368 return false; // not over apoint!?!
370 // drag node is parent of child..
371 console.log("SRC TREEPATH: " + src.treepath);
372 console.log("TARGET TREEPATH: " + data.path.to_string());
374 // nned to check a few here..
375 //Gtk.TreeViewDropPosition.INTO_OR_AFTER
376 //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
377 //Gtk.TreeViewDropPosition.AFTER
378 //Gtk.TreeViewDropPosition.BEFORE
380 if (typeof(src.treepath) != 'undefined' &&
381 src.treepath == data.path.to_string().substring(0,src.treepath.length)) {
382 print("subpath drag");
383 Gdk.drag_status(ctx, 0 ,time);
388 //print("DUMPING DATA");
389 //console.dump(data);
392 print(data.path.to_string() +' => '+ data.pos);
393 var tg = this.get('/LeftTree.model').findDropNodeByPath(
394 data.path.to_string(), src.dropList, data.pos);
396 this.get('/LeftTree.view').highlight(tg);
398 print("Can not find drop node path");
399 this.targetData = false;
400 Gdk.drag_status(ctx, 0, time);
404 this.targetData = tg;
407 Gdk.drag_status(ctx, action ,time);
411 "drag_drop":function (w, ctx, x, y, time) {
412 Seed.print("TARGET: drag-drop");
416 w, /* will receive 'drag-data-received' signal */
417 ctx, /* represents the current state of the DnD */
418 this.get('/Window').atoms["STRING"], /* the target type we want */
419 time /* time stamp */
423 /* No target offered by source => error */
428 "drag_data_received":function (self, ctx, x, y, sel_data, info, time) {
429 print("Tree: drag-data-received");
431 var delete_selection_data = false;
432 var dnd_success = false;
433 /* Deal with what we are given from source */
434 if( sel_data && sel_data.length ) {
436 if (ctx.action == Gdk.DragAction.ASK) {
437 /* Ask the user to move or copy, then set the ctx action. */
440 if (ctx.action == Gdk.DragAction.MOVE) {
441 //delete_selection_data = true;
444 var source = Gtk.drag_get_source_widget(ctx);
446 if (this.targetData) {
447 if (source != this.el) {
448 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
450 // drag around.. - reorder..
451 this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);
455 //Seed.print(this.targetData);
461 // we can send stuff to souce here...
467 if (dnd_success == false)
469 Seed.print ("DnD data transfer failed!\n");
472 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
475 "cursor_changed":function (self) {
476 if (this.blockChanges) {
479 var iter = new Gtk.TreeIter();
481 if (this.selection.count_selected_rows() < 1) {
482 this.get('/LeftPanel.model').load( false);
483 this.get('/MidPropTree').activeElement = false;
484 this.get('/MidPropTree').hideWin();
486 var pm = this.get('/RightPalete.model');
487 if (!this.get('/LeftTree').getPaleteProvider()) {
488 // it may not be loaded yet..
491 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
492 this.get('/LeftTree.model').listAllTypes()));
497 //console.log('changed');
498 var s = this.selection;
499 s.get_selected(this.get('/LeftTree.model').el, iter);
503 value = new GObject.Value('');
504 this.get('/LeftTree.model').el.get_value(iter, 2, value);
505 this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
507 var data = JSON.parse(value.value);
508 this.get('/MidPropTree').activeElement = data;
509 this.get('/MidPropTree').hideWin();
510 this.get('/LeftPanel.model').load( data);
512 console.log(value.value);
513 // _g.button.set_label(''+value.get_string());
515 var pm =this.get('/RightPalete.model');
516 pm.load( this.get('/RightPalete').provider.gatherList(
517 this.get('/LeftTree.model').listAllTypes()));
522 //Seed.print( value.get_string());
529 xtype: Gtk.TreeStore,
533 XObject.prototype.init.call(this);
534 this.el.set_column_types ( 3, [
535 GObject.TYPE_STRING, // title
536 GObject.TYPE_STRING, // tip
537 GObject.TYPE_STRING // source..
541 changed : function(n, refresh) {
542 print("MODEL CHANGED CALLED" + this.activePath);
543 if (this.activePath) {
544 var iter = new Gtk.TreeIter();
545 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
546 this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
547 this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
549 this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
551 //this.currentTree = this.toJS(false, true)[0];
552 this.file.items = this.toJS(false, false);
553 print("AFTER CHANGED");
554 //console.dump(this.file.items);
556 this.currentTree = this.file.items[0];
557 //console.log(this.file.toSource());
560 print("REDNER BROWSER?!");
561 this.get('/LeftTree').renderView();
563 var pm = this.get('/RightPalete.model');
564 if (!this.get('/RightPalete').provider) {
570 pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
571 //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
575 loadFile : function(f) {
581 console.log('missing file');
585 // load the file if not loaded..
586 if (f.items === false) {
588 f.loadItems(function() {
594 if (f.items.length && typeof(f.items[0]) == 'string') {
596 this.get('/RightEditor').el.show();
597 this.get('/RightEditor.view').load( f.items[0]);
601 //console.dump(f.items);
603 this.get('/LeftTree.view').el.expand_all();
605 if (!f.items.length) {
608 this.get('/Window.leftvpaned').el.set_position(80);
610 this.get('/LeftTree.view').el.set_cursor(
611 new Gtk.TreePath.from_string('0'), null, false);
615 this.get('/Window.leftvpaned').el.set_position(200);
619 //print("hide right editior");
620 this.get('/RightEditor').el.hide();
621 //print("set current tree");
622 this.currentTree = this.toJS(false, false)[0];
623 //console.dump(this.currentTree);
624 this.currentTree = this.currentTree || { items: [] };
625 this.get('/LeftTree').renderView();
626 //console.dump(this.map);
627 //var RightPalete = imports.Builder.RightPalete.RightPalete;
628 var pm = this.get('/RightPalete.model');
631 this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
633 if (!this.get('/RightPalete').provider) {
634 print ("********* PALETE PROVIDER MISSING?!!");
636 this.get('/LeftTree').renderView();
638 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
642 this.get('/Window.view-notebook').el.set_current_page(
643 this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
646 findDropNode : function(treepath_str, targets) {
648 // this is used by the dragdrop code in the roo version AFAIR..
650 var path = treepath_str.replace(/^builder-/, '');
651 // treemap is depreciated... - should really check if model has any entries..
653 if (!this.el.iter_n_children(null)) {
655 return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];
657 print("FIND treepath: " + path);
658 //console.dump(this.treemap);
660 if (!treepath_str.match(/^builder-/)) {
661 return []; // nothing!
663 if (targets === true) {
666 return this.findDropNodeByPath(path,targets)
668 findDropNodeByPath : function(treepath_str, targets, pref) {
669 var path = treepath_str + ''; // dupe it..
670 pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
672 //console.dump(this.treemap);
673 while (path.length) {
674 print("LOOKING FOR PATH: " + path);
675 var node_data = this.singleNodeToJS(path);
676 if (node_data === false) {
677 print("node not found");
681 var xname = this.get('/LeftTree.model').file.guessName(node_data);
684 targets.forEach(function(tg) {
688 if ((tg == xname) ) {
691 if (tg.indexOf(xname +':') === 0) {
693 prop = tg.split(':').pop();
698 if (last) { // pref is after/before..
699 // then it's after last
701 return []; // do not allow..
703 return [ last, pref , prop];
706 return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
708 var par = path.split(':');
711 path = par.join(':');
717 dropNode : function(target_data, node) {
720 console.dump(target_data);
721 var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
723 print("add " + tp + "@" + target_data[1] );
726 if (tp && target_data[1] < 2) { // before or after..
727 var ar = target_data[0].split(':');
729 parent = new Gtk.TreePath.from_string( ar.join(':') );
732 var n_iter = new Gtk.TreeIter();
733 var iter_par = new Gtk.TreeIter();
734 var iter_after = after ? new Gtk.TreeIter() : false;
738 if (parent !== false) {
739 this.el.get_iter(iter_par, parent);
746 print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
747 this.el.get_iter(iter_after, after);
748 this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
749 n_iter, iter_par, iter_after);
752 this.el.append(n_iter, iter_par);
756 if (typeof(node) == 'string') {
757 var ar = node.split('.');
758 var xtype = ar.pop();
761 '|xns' : ar.join('.'),
764 if (target_data.length == 3 && target_data[2].length) {
765 node['*prop'] = target_data[2];
769 // work out what kind of packing to use..
770 if (typeof(node.pack) == 'undefined' && parent !== false) {
771 var pal = this.get('/LeftTree').getPaleteProvider();
773 var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
774 print ("PNAME : " + pname);
775 var cname = pal.guessName(node);
776 print ("CNAME : " + cname);
777 node.pack = pal.getDefaultPack(pname, cname);
788 // load children - if it has any..
791 this.load(xitems, n_iter);
793 if (tp && (xitems || after)) {
794 this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
796 // wee need to get the empty proptypes from somewhere..
798 //var olditer = this.activeIter;
799 this.activePath = this.el.get_path(n_iter).to_string();
801 // changed actually set's the node data..
802 this.changed(node, true);
806 this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
808 //Builder.MidPropTree._model.load(node);
809 //Builder.MidPropTree._win.hideWin();
810 //Builder.LeftPanel._model.load( node);
814 moveNode : function(target_data, action) {
815 //print("MOVE NODE");
816 // console.dump(target_data);
817 var old_iter = new Gtk.TreeIter();
818 var s = this.get('/LeftTree.view').selection;
819 s.get_selected(this.el, old_iter);
820 var node = this.nodeToJS(old_iter,false);
821 //console.dump(node);
824 // needs to drop first, otherwise the target_data
825 // treepath will be invalid.
827 this.dropNode(target_data, node);
828 if (action & Gdk.DragAction.MOVE) {
829 // print("REMOVING OLD NODE");
830 this.el.remove(old_iter);
834 this.activePath= false;
835 this.changed(false,true);
837 deleteSelected : function() {
838 this.get('/LeftTree.view').blockChanges = true;
839 var old_iter = new Gtk.TreeIter();
840 var s = this.get('/LeftTree.view').selection;
841 s.get_selected(this.el, old_iter);
842 var path = this.el.get_path(old_iter).to_string();
844 this.activePath= false;
847 this.activePath= false;
848 var iter = new Gtk.TreeIter();
849 this.el.get_iter_from_string(iter, path);
850 this.el.remove(iter);
852 // rebuild treemap. -- depreciated.!!
855 //this.toJS(null, true) // does not do anything?
856 this.activePath= false;
857 this.changed(false,true);
858 this.get('/LeftTree.view').blockChanges = false;
861 listAllTypes : function() {
862 var s = this.get('/LeftTree.view').selection;
863 print ("LIST ALL TYPES: " + s.count_selected_rows() );
865 if (s.count_selected_rows() > 0) {
866 var iter = new Gtk.TreeIter();
867 s.get_selected(this.el, iter);
869 // set some properties of the tree for use by the dropped element.
870 var value = new GObject.Value('');
871 this.el.get_value(iter, 2, value);
872 var data = JSON.parse(value.value);
875 var xname = this.get('/LeftTree.model').file.guessName(data);
876 console.log('selected:' + xname);
880 return []; // could not find it..
888 li.forEach(function(el) {
889 // this is specific to roo!!!?
891 var fullpath = _this.file.guessName(el);
892 if (fullpath.length && ret.indexOf(fullpath) < 0) {
897 if (el.items && el.items.length) {
906 addall([this.currentTree]);
908 // only if we have nothing, should we add '*top'
912 //console.log('all types in tree');
918 singleNodeToJS : function (treepath)
920 var iter = new Gtk.TreeIter();
921 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
925 var iv = this.getIterValue(iter, 2);
927 return JSON.parse(iv);
930 nodeToJS : function (iter, with_id)
932 var par = new Gtk.TreeIter();
933 var iv = this.getIterValue(iter, 2);
935 var k = JSON.parse(iv);
936 if (k.json && !this.el.iter_parent( par, iter )) {
941 var treepath_str = this.el.get_path(iter).to_string();
942 // not sure how we can handle mixed id stuff..
943 if (typeof(k.id) == 'undefined') {
944 k.id = 'builder-'+ treepath_str ;
948 this.treemap[ treepath_str ] = k;
949 k.xtreepath = treepath_str ;
952 if (this.el.iter_has_child(iter)) {
953 citer = new Gtk.TreeIter();
954 this.el.iter_children(citer, iter);
955 k.items = this.toJS(citer,with_id);
959 toJS : function(iter, with_id)
961 //Seed.print("WITHID: "+ with_id);
968 iter = new Gtk.TreeIter();
969 if (!this.el.get_iter_first(iter)) {
979 var k = this.nodeToJS(iter, with_id);
983 if (!this.el.iter_next(iter)) {
989 // convert the list into a json string..
993 getIterValue : function (iter, col) {
994 var gval = new GObject.Value('');
995 this.el.get_value(iter, col ,gval);
1000 nodeTitle : function(c) {
1003 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
1004 if (sr) txt.push('<s>');
1005 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
1006 if (c.xtype) { txt.push(c.xtype); }
1007 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1008 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1009 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1012 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1013 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1014 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1015 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1016 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1017 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1018 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1019 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1020 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1022 // for flat classes...
1023 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1024 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1027 if (sr) txt.push('</s>');
1028 return (txt.length == 0 ? "Element" : txt.join(" "));
1030 nodeToJSON : function(c) {
1038 return JSON.stringify(o);
1040 load : function(tr,iter)
1042 var citer = new Gtk.TreeIter();
1043 //this.insert(citer,iter,0);
1044 for(var i =0 ; i < tr.length; i++) {
1046 this.el.insert(citer,iter,-1);
1048 this.el.append(citer);
1051 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1052 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1053 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1054 if (tr[i].items && tr[i].items.length) {
1055 this.load(tr[i].items, citer);
1061 xtype: Gtk.TreeViewColumn,
1062 pack : "append_column",
1064 XObject.prototype.init.call(this);
1065 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1069 xtype: Gtk.CellRendererText,
1079 id : "LeftTreeMenu",
1082 xtype: Gtk.MenuItem,
1084 label : "Delete Element",
1086 "activate":function (self) {
1088 this.get('/LeftTree.model').deleteSelected();
1099 id : "LeftProjectTree",
1100 showNoProjectSelected : function() {
1101 this.get('/StandardErrorDialog').show("Select a Project first.");
1103 getActiveProject : function() {
1104 return this.project;
1107 "leave_notify_event":function (self, event) {
1114 pack : "pack_start,false,false",
1117 xtype: Gtk.ComboBox,
1120 XObject.prototype.init.call(this);
1121 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1123 getValue : function() {
1124 var ix = this.el.get_active();
1128 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1131 setValue : function(fn)
1135 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1136 data.forEach(function(n, ix) {
1144 "changed":function (self) {
1145 var fn = this.getValue();
1146 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1147 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1152 xtype: Gtk.CellRendererText,
1153 pack : "pack_start,true",
1157 xtype: Gtk.ListStore,
1160 XObject.prototype.init.call(this);
1161 this.el.set_column_types ( 2, [
1162 GObject.TYPE_STRING, // real key
1163 GObject.TYPE_STRING // real type
1169 loadData : function(data) {
1170 var ov = this.get('/LeftProjectTree.combo').getValue();
1172 var iter = new Gtk.TreeIter();
1174 data.forEach(function(p) {
1179 el.set_value(iter, 0, p.fn);
1180 el.set_value(iter, 1, p.name);
1184 this.get('/LeftProjectTree.combo').setValue(ov);
1193 xtype: Gtk.ScrolledWindow,
1195 shadow_type : Gtk.ShadowType.IN,
1197 XObject.prototype.init.call(this);
1198 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1202 xtype: Gtk.TreeView,
1203 headers_visible : false,
1204 enable_tree_lines : true,
1207 XObject.prototype.init.call(this);
1208 var description = new Pango.FontDescription.c_new();
1209 description.set_size(8000);
1210 this.el.modify_font(description);
1212 this.selection = this.el.get_selection();
1213 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1217 "cursor_changed":function (self) {
1218 var iter = new Gtk.TreeIter();
1220 if (this.selection.count_selected_rows() < 1) {
1221 //XN.get('Builder.LeftTree.model').
1222 this.get('/LeftTree.model').load( false);
1226 var model = this.get('/LeftProjectTree.model');
1227 //console.log('changed');
1228 var s = this.selection;
1229 s.get_selected(model, iter);
1230 value = new GObject.Value('');
1231 model.el.get_value(iter, 2, value);
1233 console.log(value.value);// id..
1235 var file = this.get('/LeftProjectTree').project.getById(value.value);
1242 var nb = this.get('/LeftTopPanel.expander');
1243 nb.el.expanded = false;
1244 nb.listeners.activate.call(nb);
1245 //_expander.el.set_expanded(false);
1247 var ltm = this.get('/LeftTree.model');
1255 xtype: Gtk.TreeStore,
1259 XObject.prototype.init.call(this);
1260 this.el.set_column_types ( 3, [
1261 GObject.TYPE_STRING, // title
1262 GObject.TYPE_STRING, // tip
1263 GObject.TYPE_STRING // id..
1267 loadProject : function(pr) {
1272 this.get('/LeftProjectTree').project = pr;
1273 this.load(pr.toTree());
1274 this.get('/LeftProjectTree.view').el.expand_all();
1276 load : function(tr,iter) {
1278 console.log('Project tree load: ' + tr.length);
1279 var citer = new Gtk.TreeIter();
1280 //this.insert(citer,iter,0);
1283 tr.forEach(function (r) {
1285 _this.el.append(citer);
1287 _this.el.insert(citer,iter,-1);
1289 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1290 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1291 _this.el.set_value(citer, 2, '' + r.id ); //id
1292 if (r.cn && r.cn.length) {
1293 _this.load(r.cn, citer);
1298 getValue : function(iter, col) {
1299 var gval = new GObject.Value('');
1300 this.el.get_value(iter, col ,gval);
1301 return '' + gval.value;
1305 xtype: Gtk.TreeViewColumn,
1306 pack : "append_column",
1308 XObject.prototype.init.call(this);
1309 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1313 xtype: Gtk.CellRendererText,
1336 pack : "pack_start,false,true,0",
1343 "button_press_event":function (self, event) {
1344 this.get('/MidPropTree.model').showData('props');
1356 stock : Gtk.STOCK_ADD,
1357 icon_size : Gtk.IconSize.MENU
1372 "button_press_event":function (self, event) {
1373 this.get('/MidPropTree.model').showData('events');
1385 stock : Gtk.STOCK_ADD,
1386 icon_size : Gtk.IconSize.MENU
1401 "button_press_event":function (self, ev) {
1402 var p = this.get('/AddPropertyPopup');
1406 p.el.set_screen(Gdk.Screen.get_default());
1408 p.el.popup(null, null, null, null, 3, ev.button.time);
1420 stock : Gtk.STOCK_ADD,
1421 icon_size : Gtk.IconSize.MENU
1433 id : "AddPropertyPopup",
1436 xtype: Gtk.MenuItem,
1438 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1441 "activate":function (self) {
1443 this.get('/LeftPanel.model').add( {
1454 xtype: Gtk.MenuItem,
1456 tooltip_markup : "Add what type of packing is to be used",
1459 "activate":function (self) {
1461 this.get('/LeftPanel.model').add( {
1471 xtype: Gtk.MenuItem,
1473 tooltip_markup : "Override the init method",
1476 "activate":function (self) {
1478 this.get('/LeftPanel.model').add( {
1481 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1488 xtype: Gtk.SeparatorMenuItem,
1492 xtype: Gtk.MenuItem,
1494 tooltip_markup : "Add a user defined string property",
1497 "activate":function (self) {
1499 this.get('/LeftPanel.model').add( {
1509 xtype: Gtk.MenuItem,
1511 tooltip_markup : "Add a user defined number property",
1514 "activate":function (self) {
1516 this.get('/LeftPanel.model').add( {
1526 xtype: Gtk.MenuItem,
1528 tooltip_markup : "Add a user defined boolean property",
1531 "activate":function (self) {
1533 this.get('/LeftPanel.model').add( {
1543 xtype: Gtk.SeparatorMenuItem,
1547 xtype: Gtk.MenuItem,
1549 tooltip_markup : "Add a user function boolean property",
1552 "activate":function (self) {
1554 this.get('/LeftPanel.model').add( {
1557 val : "function() {\n \n}\n",
1570 xtype: Gtk.ScrolledWindow,
1573 shadow_type : Gtk.ShadowType.IN,
1576 XObject.prototype.init.call(this);
1577 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1581 xtype: Gtk.TreeView,
1584 headers_visible : false,
1585 enable_tree_lines : true,
1587 XObject.prototype.init.call(this);
1589 this.selection = this.el.get_selection();
1590 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1593 var description = new Pango.FontDescription.c_new();
1594 description.set_size(8000);
1595 this.el.modify_font(description);
1598 "button_press_event":function (self, ev) {
1602 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1603 return false; //not on a element.
1607 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1609 if (res.column.title != 'value') {
1610 return false; // ignore..
1612 if ( this.get('/LeftPanel').editing) {
1615 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1616 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1617 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1621 var provider = this.get('/LeftTree').getPaleteProvider();
1623 var opts = provider.findOptions(type);
1625 if (opts === false) {
1626 this.get('/LeftPanel').editableColumn.setOptions([]);
1627 renderer.has_entry = true;
1629 LeftPanel.editableColumn.setOptions(opts);
1630 renderer.has_entry = false;
1634 //Seed.print("click" + ev.type);
1635 //console.dump(res);
1641 if (res.column.title == 'value') {
1644 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1645 var p = this.get('/LeftPanelPopup');
1650 p.el.set_screen(Gdk.Screen.get_default());
1652 p.el.popup(null, null, null, null, 3, ev.button.time);
1653 //Seed.print("click:" + res.column.title);
1661 xtype: Gtk.TreeStore,
1665 XObject.prototype.init.call(this);
1666 this.el.set_column_types ( 5, [
1667 GObject.TYPE_STRING, // 0 real key
1668 GObject.TYPE_STRING, // 1 real value
1669 GObject.TYPE_STRING, // 2 visable key
1670 GObject.TYPE_STRING, // 3 visable value
1671 GObject.TYPE_STRING, // 4 need to store type of!!!
1675 toShort : function(str) {
1676 var a = typeof(str) == 'string' ? str.split("\n") : [];
1677 return a.length > 1 ? a[0] + '....' : '' + str;
1679 load : function(ar) {
1682 this.get('/RightEditor').el.hide();
1689 var provider = this.get('/LeftTree').getPaleteProvider();
1692 var iter = new Gtk.TreeIter();
1694 if (typeof(ar[i]) == 'object') {
1698 var type = provider.findType(ar, i, ar[i]);
1700 this.el.append(iter);
1701 var p = this.el.get_path(iter).to_string();
1703 this.el.set_value(iter, 0, i);
1704 this.el.set_value(iter, 1, '' + ar[i]);
1705 this.el.set_value(iter, 2, i);
1706 this.el.set_value(iter, 3, this.toShort(ar[i]));
1707 this.el.set_value(iter, 4, type);
1709 ar.listeners = ar.listeners || {};
1710 for (var i in ar.listeners ) {
1711 this.el.append(iter);
1712 var p = this.el.get_path(iter).to_string();
1715 this.el.set_value(iter, 0, '!'+ i );
1716 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1717 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1719 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1720 this.el.set_value(iter, 4, 'function');
1724 add : function(info) {
1725 // info includes key, val, skel, etype..
1727 type = info.type.toLowerCase();
1728 var data = this.toJS();
1730 if (info.etype == 'events') {
1731 data.listeners = data.listeners || { };
1732 if (typeof(data.listeners[info.key]) != 'undefined') {
1733 return; //already set!
1736 if (typeof(data[info.key]) != 'undefined') {
1741 if (typeof(info.val) == 'undefined') {
1744 if (info.type == 'boolean') {
1747 if (type == 'number') {
1755 if (info.etype == 'events') {
1757 data.listeners[info.key] = info.val;
1760 data[info.key] = info.val;
1764 var map = this.load(data);
1766 // flag it as changed to the interface..
1768 this.get('/LeftTree.model').changed(data, true);
1771 this.startEditing(map[k]);
1774 LeftPanel.get('view').el.row_activated(
1775 new Gtk.TreePath.from_string(map[k]),
1776 LeftPanel.editableColumn.el
1780 startEditing : function(path,col) {
1782 * start editing path (or selected if not set..)
1783 * @param {String|false} path (optional) treepath to edit - selected tree gets
1784 * edited by default.
1785 * @param {Number} 0 or 1 (optional)- column to edit.
1788 if (typeof(path) == 'string') {
1789 tp = new Gtk.TreePath.from_string(path);
1791 var iter = new Gtk.TreeIter();
1792 var s = this.get('/LeftPanel.view').selection;
1793 s.get_selected(this.el, iter);
1794 tp = this.el.get_path(iter);
1795 path = tp.to_string();
1799 // which colum is to be edited..
1801 if (typeof(col) == 'undefined') {
1802 var k = this.getValue(path, 0);
1803 colObj = (!k.length || k == '|') ?
1804 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1806 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1809 // make sure the pulldown is set correctly..
1810 // not really needed for second col...
1812 var provider = this.get('/LeftTree').getPaleteProvider();
1814 var type = this.get('/LeftPanel.model').getType(path);
1815 var opts = provider.findOptions(type);
1816 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1818 if (opts === false) {
1819 this.get('/LeftPanel').editableColumn.setOptions([]);
1820 renderer.has_entry = true; /// probably does not have any effect.
1822 this.get('/LeftPanel').editableColumn.setOptions(opts);
1823 renderer.has_entry = false;
1827 // iter now has row...
1828 GLib.timeout_add(0, 100, function() {
1830 colObj.items[0].el.editable = true; // esp. need for col 0..
1831 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1840 deleteSelected : function() {
1841 var data = this.toJS();
1842 var iter = new Gtk.TreeIter();
1843 var s = this.get('/LeftPanel.view').selection;
1844 s.get_selected(this.el, iter);
1847 var gval = new GObject.Value('');
1848 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1850 var val = gval.value;
1851 if (val[0] == '!') {
1853 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1856 delete data.listeners[ val.substring(1)];
1857 if (!XObject.keys(data.listeners).length) {
1858 delete data.listeners;
1862 if (typeof(data[val]) == 'undefined') {
1870 this.get('/LeftTree.model').changed(data, true);
1874 changed : function(str, doRefresh) {
1875 if (!this.activePath) {
1878 var iter = new Gtk.TreeIter();
1879 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1881 this.el.set_value(iter, 1, '' +str);
1882 this.el.set_value(iter, 3, '' + this.toShort(str));
1883 // update the tree...
1885 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
1888 var iter = new Gtk.TreeIter();
1889 this.get('/LeftPanel.model').el.get_iter_first(iter);
1894 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
1897 ar.listeners = ar.listeners || {};
1898 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
1901 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
1904 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
1910 //print(JSON.stringify(ar));
1914 getType : function(treepath) {
1915 return this.getValue(treepath, 4);
1917 getValue : function(treepath_str, col) {
1918 var iter = new Gtk.TreeIter();
1919 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
1921 var gval = new GObject.Value('');
1922 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
1923 var val = '' + gval.value;
1927 var type = this.getType(this.el.get_path(iter).to_string());
1928 //print("TYPE: " +type + " - val:" + val);
1929 switch(type.toLowerCase()) {
1933 return parseFloat(val); // Nan ?? invalid!!?
1935 return val == 'true' ? true : false;
1941 editSelected : function(e) {
1942 print("EDIT SELECTED?");
1943 var iter = new Gtk.TreeIter();
1944 var s = this.get('/LeftPanel.view').selection;
1945 s.get_selected(this.get('/LeftPanel.model').el, iter);
1946 var m = this.get('/LeftPanel.model')
1948 var gval = new GObject.Value('');
1949 this.el.get_value(iter, 0 ,gval);
1950 var val = '' + gval.value;
1952 gval = new GObject.Value('');
1953 this.el.get_value(iter, 1 ,gval);
1954 var rval = gval.value;
1955 var activePath = this.el.get_path(iter).to_string();
1956 this.activePath = activePath ;
1957 // was activeIter...
1960 var showEditor = false;
1962 if (val[0] == '!') {
1965 if (val[0] == '|') {
1966 if (rval.match(/function/g) || rval.match(/\n/g)) {
1973 this.activePath = false;
1974 GLib.timeout_add(0, 1, function() {
1975 // Gdk.threads_enter();
1976 _this.get('/RightEditor').el.show();
1977 _this.get('/RightEditor.view').load( rval );
1981 _this.activePath = activePath ;
1983 // Gdk.threads_leave();
1989 this.get('/RightEditor').el.hide();
1991 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
1997 xtype: Gtk.TreeViewColumn,
1998 pack : "append_column",
2000 XObject.prototype.init.call(this);
2002 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2003 this.get('/LeftPanel').propertyColumn = this;
2008 xtype: Gtk.CellRendererText,
2009 pack : "pack_start",
2011 "editing_started":function (self, editable, path) {
2013 this.get('/LeftPanel.model').activePath = path;
2016 "edited":function (self, object, p0) {
2017 var model = this.get('/LeftPanel.model');
2018 var path = model.activePath;
2019 var iter = new Gtk.TreeIter();
2020 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2021 model.el.set_value(iter, 0, p0);
2022 model.el.set_value(iter, 2, p0);
2024 model.activePath = false;
2026 this.get('/LeftTree.model').changed(model.toJS(), true);
2027 this.el.editable = false;
2034 xtype: Gtk.TreeViewColumn,
2035 pack : "append_column",
2037 XObject.prototype.init.call(this);
2038 this.el.add_attribute(this.items[0].el , 'text', 3 );
2039 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2040 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2041 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2043 this.get('/LeftPanel').editableColumn= this;
2045 setOptions : function(ar) {
2046 var m = this.items[0].el.model;
2048 var iter = new Gtk.TreeIter();
2049 ar.forEach(function(i) {
2052 m.set_value(iter, 0, i);
2058 xtype: Gtk.CellRendererCombo,
2059 pack : "pack_start",
2064 XObject.prototype.init.call(this);
2065 this.el.model = new Gtk.ListStore();
2066 this.el.model.set_column_types ( 1, [
2067 GObject.TYPE_STRING // 0 real key
2071 "edited":function (self, object, p0) {
2072 this.get('/LeftPanel').editing = false;
2073 print("EDITED? p:" + p0 + " t:" + p0);
2074 this.get('/LeftPanel.model').changed(p0, true);
2075 this.get('/LeftPanel.model').activePath = false;
2077 "editing_started":function (self, editable, path) {
2078 this.get('/LeftPanel').editing = true;
2079 // console.log('editing started');
2080 // r.has_entry = false;
2081 this.get('/LeftPanel.model').editSelected(editable);
2092 id : "LeftPanelPopup",
2095 xtype: Gtk.MenuItem,
2099 "activate":function (self) {
2100 this.get('/LeftPanel.model').deleteSelected();
2105 xtype: Gtk.MenuItem,
2109 "activate":function (self) {
2110 this.get('/LeftPanel.model').startEditing(false, 0);
2123 xtype: Gtk.ScrolledWindow,
2124 pack : "pack_end,false,true,0",
2126 shadow_type : Gtk.ShadowType.IN,
2128 XObject.prototype.init.call(this);
2129 XObject.prototype.init.call(this);
2130 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2131 this.el.set_size_request ( 150, -1 );
2134 activeElement : false,
2135 hideWin : function() {
2142 if (this.get('/Window.left').el.position < 160) {
2145 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2152 xtype: Gtk.TreeView,
2153 enable_tree_lines : true,
2154 headers_visible : false,
2157 XObject.prototype.init.call(this);
2159 var description = new Pango.FontDescription.c_new();
2160 description.set_size(8000);
2161 this.el.modify_font(description);
2163 //this.selection = this.el.get_selection();
2164 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2173 "cursor_changed":function (self) {
2174 var iter = new Gtk.TreeIter();
2176 //console.log('changed');
2177 var m = this.get('model');
2178 if (!this.selection){
2179 this.selection = this.el.get_selection();
2182 var s = this.selection;
2183 if (!s.get_selected(m.el, iter)) {
2186 var tp = m.el.get_path(iter).to_string();
2191 var key = m.getValue(tp, 0);
2193 var type = m.getValue(tp, 1);
2194 var skel = m.getValue(tp, 3);
2195 var etype = m.getValue(tp, 5);
2198 this.get('/MidPropTree').hideWin();
2200 if (type == 'function') {
2202 if (etype != 'events') {
2206 this.get('/LeftPanel.model').add({
2215 if (type.indexOf('.') > -1 ||
2216 type == 'boolean') {
2220 this.get('/LeftPanel.model').add( {
2230 xtype: Gtk.ListStore,
2233 XObject.prototype.init.call(this);
2234 this.el.set_column_types ( 6, [
2235 GObject.TYPE_STRING, // real key
2236 GObject.TYPE_STRING, // real type
2237 GObject.TYPE_STRING, // docs ?
2238 GObject.TYPE_STRING, // visable desc
2239 GObject.TYPE_STRING, // function desc
2240 GObject.TYPE_STRING // element type (event|prop)
2244 getValue : function(treepath, col)
2246 var tp = new Gtk.TreePath.from_string (treepath);
2247 var iter = new Gtk.TreeIter();
2248 this.el.get_iter (iter, tp);
2249 var value = new GObject.Value('');
2250 this.el.get_value(iter, col, value);
2254 showData : function(type) {
2256 if (!this.get('/MidPropTree').activeElement || !type) {
2257 return; // no active element
2260 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2261 var palete = this.get('/LeftTree').getPaleteProvider();
2265 Seed.print('Showing right?');
2266 if (!this.get('/MidPropTree').shown) {
2268 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2269 this.get('/MidPropTree').el.show();
2270 this.get('/MidPropTree').shown = true;
2273 var elementList = palete.getPropertiesFor(fullpath, type);
2274 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2275 // console.dump(elementList);
2278 var iter = new Gtk.TreeIter();
2279 for(var i =0 ; i < elementList.length; i++) {
2280 var p=elementList[i];
2281 this.el.append(iter);
2282 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2283 //GObject.TYPE_STRING, // real key
2284 // GObject.TYPE_STRING, // real type
2285 // GObject.TYPE_STRING, // docs ?
2286 // GObject.TYPE_STRING // func def?
2289 this.el.set_value(iter, 0, p.name);
2290 this.el.set_value(iter, 1, p.type);
2291 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2292 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2293 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2294 this.el.set_value(iter, 5, type);
2302 xtype: Gtk.TreeViewColumn,
2304 this.el = new Gtk.TreeViewColumn();
2305 this.parent.el.append_column(this.el);
2307 XObject.prototype.init.call(this);
2308 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2313 xtype: Gtk.CellRendererText,
2314 pack : "pack_start,true"
2338 xtype: Gtk.Notebook,
2339 pack : "pack_start,true,true",
2340 id : "view-notebook",
2343 XObject.prototype.init.call(this);
2344 this.el.set_current_page(0);
2346 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2347 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2354 id : "RightBrowser",
2358 pack : "pack_start,false,true,0",
2362 pack : "pack_start,false,false,0",
2363 label : "Dump HTML to console",
2365 "activate":function (self) {
2366 this.get('/RightBrowser.view').el.execute_script(
2367 "console.log(document.body.innerHTML);");
2368 this.get('/RightBrowser.view').el.execute_script(
2369 "console.log(Builder.dump(Builder));");
2376 xtype: Gtk.ScrolledWindow,
2378 shadow_type : Gtk.ShadowType.IN,
2380 XObject.prototype.init.call(this);
2381 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2385 xtype: WebKit.WebView,
2389 XObject.prototype.init.call(this);
2390 // this may not work!?
2391 this.el.open('file:///' + __script_path__ + '/../builder.html');
2395 this.el, /* widget that will accept a drop */
2396 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2397 null, /* lists of target to support */
2398 0, /* size of list */
2399 Gdk.DragAction.COPY /* what to do with data after dropped */
2402 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2403 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2405 renderJS : function(data) {
2406 this.renderedData = data;
2407 var str = JSON.stringify(data) ;
2410 console.log('not loaded yet');
2412 Seed.print("RENDER:" + str);
2413 imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2414 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2417 "load_finished":function (self, object) {
2418 if (this.ready) { // dont do it twice!
2423 this.renderJS(this.get('/LeftTree.model').toJS()[0]);
2425 "script_alert":function (self, object, p0) {
2428 return true; // do not display anything...
2430 "console_message":function (self, object, p0, p1) {
2431 console.log(object);
2432 if (!object.match(/^\{/)) {
2433 return false; // do not handle!!! -> later maybe in console..
2435 console.log(object);
2436 var val = JSON.parse(object);
2438 if (typeof(val['hover-node']) != 'undefined') {
2439 this.activeNode = val['hover-node'];
2440 console.log('active node: ' + this.activeNode);
2445 if (typeof(val['id']) != 'undefined') {
2446 // this.activeNode = val['id'];
2447 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2451 this.get('/LeftTree.view').selectNode(tg[0]);
2455 if (ret && typeof(val['set']) != 'undefined') {
2456 this.get('/LeftPanel.model').add({
2460 //console.log('active node: ' + this.activeNode);
2463 //Seed.print('a:'+a);
2464 //Seed.print('b:'+b);
2465 //Seed.print('c:'+c);
2468 "drag_motion":function (w, ctx, x, y, time, ud) {
2469 // console.log('DRAG MOTION');
2471 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2472 this.targetData = [];
2473 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2475 // A) find out from drag all the places that node could be dropped.
2476 var src = Gtk.drag_get_source_widget(ctx);
2477 if (!src.dropList) {
2478 Gdk.drag_status(ctx, 0, time);
2481 // b) get what we are over.. (from activeNode)
2482 // tree is empty.. - list should be correct..
2483 if (!this.get('/LeftTree.model').currentTree) {
2484 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2488 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2490 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2493 Gdk.drag_status(ctx, 0,time);
2494 this.get('/LeftTree.view').highlight(false);
2498 // if we have a target..
2499 // -> highlight it! (in browser)
2500 // -> highlight it! (in tree)
2502 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2503 this.get('/LeftTree.view').highlight(tg);
2504 this.targetData = tg;
2505 // for tree we should handle this...
2508 "drag_drop":function (w, ctx, x, y,time, ud) {
2509 print("TARGET: drag-drop");
2510 var is_valid_drop_site = true;
2515 w, /* will receive 'drag-data-received' signal */
2516 ctx, /* represents the current state of the DnD */
2517 this.get('/Window').atoms["STRING"], /* the target type we want */
2518 time /* time stamp */
2522 /* No target offered by source => error */
2525 return is_valid_drop_site;
2527 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2529 print("Browser: drag-data-received");
2530 var delete_selection_data = false;
2531 vardnd_success = false;
2532 /* Deal with what we are given from source */
2533 if( sel_data && sel_data.length ) {
2535 if (ctx.action == Gdk.DragAction.ASK) {
2536 /* Ask the user to move or copy, then set the ctx action. */
2539 if (ctx.action == Gdk.DragAction.MOVE) {
2540 delete_selection_data = true;
2542 var source = Gtk.drag_get_source_widget(ctx);
2544 print("Browser: source.DRAGDATA? " + source.dragData);
2545 if (this.targetData) {
2546 print(this.targetData);
2547 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2556 if (dnd_success == false)
2558 Seed.print ("DnD data transfer failed!\n");
2561 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2573 id : "RightGtkView",
2574 renderJS : function(data, withDebug)
2579 this.withDebug = false;
2581 if (this.renderedEl) {
2582 this.get('view').el.remove(this.renderedEl);
2583 this.renderedEl.destroy();
2584 this.renderedEl = false;
2587 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2588 // in theory tree is actually window..
2590 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2595 this.get('view').el.set_size_request(
2596 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2599 this.renderedEl.set_size_request(
2600 tree.default_width || 600,
2601 tree.default_height || 400
2603 this.get('view').el.show_all();
2608 showInWindow : function() {
2609 print("GET PROEJCT");
2610 var pr = this.get('/LeftProjectTree').getActiveProject();
2612 console.log(pr.paths);
2615 var src= this.buildJS(
2616 this.get('/LeftTree.model').toJS()[0],
2621 //var x = new imports.sandbox.Context();
2625 Seed.check_syntax('var e = ' + src);
2628 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2629 this.get('/Terminal').feed(console._dump(e)+"\n");
2631 var lines = src.split("\n");
2632 var start = Math.max(0, e.line - 10);
2633 var end = Math.min(lines.length, e.line + 10);
2634 for (var i =start ; i < end; i++) {
2636 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2639 this.get('/Terminal').feed(lines[i] + "\n");
2646 this.get('/BottomPane').el.set_current_page(1);
2647 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2648 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2649 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2651 var _top = x.get_global_object()._top;
2653 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2655 if (_top.el.popup) {
2656 _top.el.popup(null, null, null, null, 3, null);
2660 viewAdd : function(item, par)
2662 // does something similar to xobject..
2663 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2665 if (item.pack===false || item.pack === 'false') { // no ;
2668 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2669 var ns = imports.gi[item['|xns']];
2670 var ctr = ns[item['xtype']];
2672 for(var k in item) {
2674 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2689 if (k[0] == '|' && typeof(kv) == 'string') {
2691 if (kv.match(new RegExp('function'))) {
2694 print("WASL " + k + '=' + kv);
2696 eval( 'kv = ' + kv);
2697 } catch(e) { continue; }
2700 print(k + '=' + kv);
2702 if (k[0] == '|') { // should be boolean or number..
2705 if (k == 'show_tabs') { // force tab showing for notebooks.
2713 var el = new ctr(ctr_args);
2716 //console.dump(item.pack);
2723 if (typeof(item.pack) == 'string') {
2725 item.pack.split(',').forEach(function(e, i) {
2727 if (e == 'false') { args.push( false); return; }
2728 if (e == 'true') { args.push( true); return; }
2729 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2732 //print(args.join(","));
2734 pack_m = args.shift();
2736 pack_m = item.pack.shift();
2741 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2743 name: "ArgumentError",
2744 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2745 "ADDING : " + item.id + " " + el
2754 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2755 //Seed.print('args: ' + args.length);
2757 par[pack_m].apply(par, args);
2761 item.items = item.items || [];
2762 item.items.forEach(function(ch) {
2763 _this.viewAdd(ch, el);
2768 // add the signal handlers.
2769 // is it a widget!?!!?
2775 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2776 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2777 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2778 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2779 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2789 widgetExposeEvent : function() {
2790 /// print("WIDGET EXPOSE"); // draw highlight??
2793 widgetDragMotionEvent : function() {
2794 print("WIDGET DRAGMOTION");
2797 widgetDragDropEvent : function() {
2798 print("WIDGET DRAGDROP");
2801 widgetPressEvent : function(w,e,u,d) {
2802 if (this.get('view').pressed) {
2805 this.get('view').pressed = true;
2806 print("WIDGET PRESS " + d.xtreepath );
2807 this.get('/LeftTree.view').selectNode( d.xtreepath );
2810 widgetReleaseEvent : function() {
2811 this.get('view').pressed = false;
2817 pack : "pack_start,false,true,0",
2821 pack : "pack_start,false,false,0",
2822 label : "Run The Application",
2824 "button_press_event":function (self, event) {
2825 // call render on left tree - with special option!?!
2829 print("GET PROEJCT");
2830 var pr = this.get('/LeftProjectTree').getActiveProject();
2833 for (var i in pr.paths) {
2837 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
2838 print ("RUN DIR:" + dir);
2840 this.get('/BottomPane').el.set_current_page(1);
2841 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
2842 , false,false,false);
2843 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
2844 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2854 xtype: Gtk.ScrolledWindow,
2857 shadow_type : Gtk.ShadowType.IN,
2859 XObject.prototype.init.call(this);
2860 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2864 xtype: Gtk.EventBox,
2867 XObject.prototype.init.call(this);
2868 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
2869 red: 0x9F00, green: 0xB800 , blue : 0xA800
2877 XObject.prototype.init.call(this);
2878 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
2879 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
2884 xtype: Gtk.EventBox,
2887 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
2888 XObject.prototype.init.call(this);
2892 this.el, /* widget that will accept a drop */
2893 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2894 null, /* lists of target to support */
2895 0, /* size of list */
2896 Gdk.DragAction.COPY /* what to do with data after dropped */
2899 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2900 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2903 getActiveNode : function(x,y)
2905 // workout what node is here..
2906 return '0'; // top..
2910 "drag_motion":function (self, ctx, x, y, time) {
2912 // A) find out from drag all the places that node could be dropped.
2913 var src = Gtk.drag_get_source_widget(ctx);
2914 if (!src.dropList) {
2915 Gdk.drag_status(ctx, 0, time);
2918 // b) get what we are over.. (from activeNode)
2919 // tree is empty.. - list should be correct..
2920 if (!this.get('/LeftTree.model').currentTree) {
2921 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2925 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2926 var activeNode = this.getActiveNode(x, y);
2929 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
2932 Gdk.drag_status(ctx, 0,time);
2933 this.get('/LeftTree.view').highlight(false);
2937 // if we have a target..
2938 // -> highlight it! (in browser)
2939 // -> highlight it! (in tree)
2941 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2942 this.get('/LeftTree.view').highlight(tg);
2943 this.targetData = tg;
2944 // for tree we should handle this...
2947 "drag_drop":function (self,ctx, x, y, time) {
2948 Seed.print("TARGET: drag-drop");
2949 var is_valid_drop_site = true;
2954 self, /* will receive 'drag-data-received' signal */
2955 ctx, /* represents the current state of the this.gDnD */
2956 this.get('/Window').atoms["STRING"], /* the target type we want */
2957 time /* time stamp */
2961 /* No target offered by source => error */
2964 return is_valid_drop_site;
2967 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2969 Seed.print("GtkView: drag-data-received");
2970 var delete_selection_data = false;
2971 var dnd_success = false;
2972 /* Deal with what we are given from source */
2973 if( sel_data && sel_data.length ) {
2975 if (ctx.action == Gdk.DragAction.ASK) {
2976 /* Ask the user to move or copy, then set the ctx action. */
2979 if (ctx.action == Gdk.DragAction.MOVE) {
2980 delete_selection_data = true;
2982 var source = Gtk.drag_get_source_widget(ctx);
2984 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
2985 if (this.targetData) {
2986 Seed.print(this.targetData);
2987 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2996 if (dnd_success == false)
2998 Seed.print ("DnD data transfer failed!\n");
3001 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3004 "button_press_event":function (self, event) {
3005 this.pressed = false;
3023 xtype: Gtk.Notebook,
3026 XObject.prototype.init.call(this);
3027 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3028 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3033 xtype: Gtk.ScrolledWindow,
3038 xtype: GtkSource.View,
3042 XObject.prototype.init.call(this);
3043 var description = Pango.Font.description_from_string("monospace")
3044 description.set_size(8000);
3045 this.el.modify_font(description);
3048 load : function(str) {
3049 this.get('/BottomPane').el.set_current_page(0);
3050 this.el.get_buffer().set_text(str, str.length);
3051 var lm = GtkSource.LanguageManager.get_default();
3053 this.el.get_buffer().set_language(lm.get_language('js'));
3054 var buf = this.el.get_buffer();
3055 var cursor = buf.get_mark("insert");
3056 var iter= new Gtk.TextIter;
3057 buf.get_iter_at_mark(iter, cursor);
3059 iter.set_line_offset(4);
3060 buf.move_mark(cursor, iter);
3063 cursor = buf.get_mark("selection_bound");
3064 iter= new Gtk.TextIter;
3065 buf.get_iter_at_mark(iter, cursor);
3067 iter.set_line_offset(4);
3068 buf.move_mark(cursor, iter);
3070 this.el.grab_focus();
3074 xtype: GtkSource.Buffer,
3075 pack : "set_buffer",
3077 "changed":function (self) {
3078 var s = new Gtk.TextIter();
3079 var e = new Gtk.TextIter();
3080 this.el.get_start_iter(s);
3081 this.el.get_end_iter(e);
3082 var str = this.el.get_text(s,e,true);
3084 Seed.check_syntax('var e = ' + str);
3086 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3087 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3089 print("SYNTAX ERROR IN EDITOR");
3094 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3095 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3098 this.get('/LeftPanel.model').changed( str , false);
3107 xtype: Gtk.ScrolledWindow,
3111 xtype: Vte.Terminal,
3114 feed : function(str) {
3115 this.el.feed(str,str.length);
3126 pack : "pack_start,false,false",
3130 this.get('buttonbar').el.show();
3131 this.get('viewbox').el.hide();
3132 print("TRIED TO HIDE");
3135 this.get('buttonbar').el.hide();
3136 this.get('viewbox').el.show();
3137 // this.get('model').expanded();
3149 pack : "pack_start,false,true",
3151 "clicked":function (self) {
3152 this.get('/RightPalete').show();
3159 stock : Gtk.STOCK_GOTO_FIRST,
3160 icon_size : Gtk.IconSize.MENU
3170 XObject.prototype.init.call(this);
3171 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3174 "enter_notify_event":function (self, event) {
3175 this.get('/RightPalete').show();
3189 pack : "pack_start,false,true",
3198 pack : "pack_start,false,true",
3200 "clicked":function (self) {
3201 this.get('/RightPalete').hide();
3208 stock : Gtk.STOCK_GOTO_LAST,
3209 icon_size : Gtk.IconSize.MENU
3216 xtype: Gtk.ScrolledWindow,
3219 XObject.prototype.init.call(this);
3220 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3221 this.el.set_size_request(-1,200);
3223 shadow_type : Gtk.ShadowType.IN,
3226 xtype: Gtk.TreeView,
3229 XObject.prototype.init.call(this);
3230 this.el.set_size_request(150,-1);
3231 // set_reorderable: [1]
3233 var description = new Pango.FontDescription.c_new();
3234 description.set_size(8000);
3235 this.el.modify_font(description);
3237 this.selection = this.el.get_selection();
3238 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3239 // this.selection.signal['changed'].connect(function() {
3240 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3242 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3244 Gtk.drag_source_set (
3245 this.el, /* widget will be drag-able */
3246 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3247 null, /* lists of target to support */
3248 0, /* size of list */
3249 Gdk.DragAction.COPY /* what to do with data after dropped */
3251 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3253 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3254 Gtk.drag_source_add_text_targets(this.el);
3256 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3257 targets = new Gtk.TargetList();
3258 targets.add( LeftTree.atoms["STRING"], 0, 0);
3259 targets.add_text_targets( 1 );
3260 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3262 //if you want to allow text to be output elsewhere..
3263 //Gtk.drag_source_add_text_targets(this.el);
3267 headers_visible : false,
3268 enable_tree_lines : true,
3270 "drag_begin":function (self, ctx) {
3271 // we could fill this in now...
3272 Seed.print('SOURCE: drag-begin');
3276 var iter = new Gtk.TreeIter();
3277 var s = this.selection;
3278 s.get_selected(this.get('/RightPalete.model').el, iter);
3279 var path = this.get('/RightPalete.model').el.get_path(iter);
3281 var pix = this.el.create_row_drag_icon ( path);
3284 Gtk.drag_set_icon_pixmap (ctx,
3291 var value = new GObject.Value('');
3292 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3293 if (!this.get('/RightPalete').provider) {
3296 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3297 this.el.dragData = value.value;
3304 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3305 //Seed.print('Palete: drag-data-get: ' + target_type);
3306 if (this.el.dragData && this.el.dragData.length ) {
3307 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3311 //this.el.dragData = "TEST from source widget";
3315 "drag_end":function (self, drag_context) {
3316 Seed.print('SOURCE: drag-end');
3317 this.el.dragData = false;
3318 this.el.dropList = false;
3319 this.get('/LeftTree.view').highlight(false);
3325 xtype: Gtk.ListStore,
3328 XObject.prototype.init.call(this);
3329 this.el.set_column_types ( 2, [
3330 GObject.TYPE_STRING, // title
3331 GObject.TYPE_STRING // tip
3336 load : function(tr,iter)
3341 //console.log('Project tree load: ' + tr.length);
3342 var citer = new Gtk.TreeIter();
3343 //this.insert(citer,iter,0);
3344 for(var i =0 ; i < tr.length; i++) {
3347 this.el.append(citer);
3349 this.el.insert(citer,iter,-1);
3354 this.el.set_value(citer, 0, '' + r ); // title
3356 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3357 //if (r.cn && r.cn.length) {
3358 // this.load(r.cn, citer);
3364 getValue : function (iter, col) {
3365 var gval = new GObject.Value('');
3366 this.el.get_value(iter, col ,gval);
3373 xtype: Gtk.TreeViewColumn,
3374 pack : "append_column",
3376 XObject.prototype.init.call(this);
3377 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3381 xtype: Gtk.CellRendererText,
3403 XObject.cache['/Window'] = Window;