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,
138 label : "Select Project",
140 pack : "pack_start,false,true",
142 XObject.prototype.init.call(this);
143 this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
146 "activate":function (self) {
147 var nb = this.get('/LeftTopPanel.notebook');
148 if (this.el.expanded) {
151 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
154 var model = this.get('/LeftProjectTree.combomodel');
155 // print ("loading Projects?")
156 //console.dump(pm.projects);
157 model.loadData(pm.projects);
160 nb.el.set_current_page(1);
161 //pm.on('changed', function() {
162 //console.log("CAUGHT project manager change");
163 // _combo.model.loadData(pm.projects);
167 nb.el.set_current_page(0);
169 "enter_notify_event":function (self, event) {
170 this.el.expanded = !this.el.expanded;
171 //if (this.el.expanded ) {
172 this.listeners.activate.call(this);
184 pack : "pack_start,true,true",
186 XObject.prototype.init.call(this);
187 this.el.set_current_page(0);
192 xtype: Gtk.ScrolledWindow,
194 shadow_type : Gtk.ShadowType.IN,
196 XObject.prototype.init.call(this);
197 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
200 getPaleteProvider : function() {
201 var model = this.get('model');
202 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
203 return pm.getPalete(model.file.getType());
205 renderView : function() {
206 var model = this.get('model');
207 print("RENDER VIEW?" + model.file.getType());
208 switch( model.file.getType()) {
210 this.get('/RightBrowser.view').renderJS(model.toJS(false,true)[0]);
212 this.get('/RightGtkView').renderJS(model.toJS(false,true)[0]);
220 headers_visible : false,
221 enable_tree_lines : true,
224 XObject.prototype.init.call(this);
225 var description = new Pango.FontDescription.c_new();
226 description.set_size(8000);
227 this.el.modify_font(description);
229 this.selection = this.el.get_selection();
230 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
232 this.selection.signal['changed'].connect(function() {
233 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
234 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
238 Gtk.drag_source_set (
239 this.el, /* widget will be drag-able */
240 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
241 null, /* lists of target to support */
242 0, /* size of list */
243 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
246 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
248 Gtk.drag_source_add_text_targets(this.el);
251 this.el, /* widget that will accept a drop */
252 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
253 null, /* lists of target to support */
254 0, /* size of list */
255 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
258 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
259 Gtk.drag_dest_add_text_targets(this.el);
261 highlight : function(treepath_ar) {
262 if (treepath_ar.length && treepath_ar[0].length ) {
263 this.el.set_drag_dest_row(
264 new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);
266 this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
270 selectNode : function(treepath_str) {
271 //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
272 var tp = new Gtk.TreePath.from_string(treepath_str);
273 this.el.set_cursor(tp, null, false);
274 this.el.scroll_to_cell(tp, null, false, 0,0);
277 "button_press_event":function (self, ev) {
278 console.log("button press?");
279 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
280 print("click" + ev.type);
286 this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
288 if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();
290 this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
291 this.get('/LeftTreeMenu').el.show_all();
292 this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
293 print("click:" + res.path.to_string());
296 "drag_begin":function (self, drag_context) {
297 print('SOURCE: drag-begin');
298 this.targetData = false;
299 // find what is selected in our tree...
300 var iter = new Gtk.TreeIter();
301 var s = this.selection;
302 s.get_selected(this.get('/LeftTree.model').el, iter);
304 // set some properties of the tree for use by the dropped element.
305 var value = new GObject.Value('');
306 this.get('/LeftTree.model').el.get_value(iter, 2, value);
307 var data = JSON.parse(value.value);
308 var xname = this.get('/LeftTree.model').file.guessName(data);
310 this.el.dragData = xname;
311 this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);
314 // make the drag icon a picture of the node that was selected
315 var path = this.get('/LeftTree.model').el.get_path(iter);
316 this.el.treepath = path.to_string();
318 var pix = this.el.create_row_drag_icon ( path);
320 Gtk.drag_set_icon_pixmap (ctx,
329 "drag_end":function (self, drag_context) {
330 Seed.print('LEFT-TREE: drag-end');
331 this.el.dragData = false;
332 this.el.dropList = false;
333 this.targetData = false;
334 this.get('/LeftTree.view').highlight(false);
337 "drag_motion":function (self, ctx, x, y, time) {
338 console.log("LEFT-TREE: drag-motion");
339 var src = Gtk.drag_get_source_widget(ctx);
341 // a drag from elsewhere...- prevent drop..
343 print("no drag data!");
344 Gdk.drag_status(ctx, 0, time);
345 this.targetData = false;
348 var action = Gdk.DragAction.COPY;
349 if (src == this.el) {
350 // unless we are copying!!! ctl button..
351 action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
355 if (!this.get('/LeftTree.model').el.iter_n_children(null)) {
356 // no children.. -- asume it's ok..
357 this.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];
358 Gdk.drag_status(ctx, action ,time);
362 print("GETTING POS");
363 var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);
364 print("ISOVER? " + isOver);
366 Gdk.drag_status(ctx, 0 ,time);
367 return false; // not over apoint!?!
369 // drag node is parent of child..
370 console.log("SRC TREEPATH: " + src.treepath);
371 console.log("TARGET TREEPATH: " + data.path.to_string());
373 // nned to check a few here..
374 //Gtk.TreeViewDropPosition.INTO_OR_AFTER
375 //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
376 //Gtk.TreeViewDropPosition.AFTER
377 //Gtk.TreeViewDropPosition.BEFORE
379 if (typeof(src.treepath) != 'undefined' &&
380 src.treepath == data.path.to_string().substring(0,src.treepath.length)) {
381 print("subpath drag");
382 Gdk.drag_status(ctx, 0 ,time);
387 //print("DUMPING DATA");
388 //console.dump(data);
391 print(data.path.to_string() +' => '+ data.pos);
392 var tg = this.get('/LeftTree.model').findDropNodeByPath(
393 data.path.to_string(), src.dropList, data.pos);
395 this.get('/LeftTree.view').highlight(tg);
397 print("Can not find drop node path");
398 this.targetData = false;
399 Gdk.drag_status(ctx, 0, time);
403 this.targetData = tg;
406 Gdk.drag_status(ctx, action ,time);
410 "drag_drop":function (w, ctx, x, y, time) {
411 Seed.print("TARGET: drag-drop");
415 w, /* will receive 'drag-data-received' signal */
416 ctx, /* represents the current state of the DnD */
417 this.get('/Window').atoms["STRING"], /* the target type we want */
418 time /* time stamp */
422 /* No target offered by source => error */
427 "drag_data_received":function (self, ctx, x, y, sel_data, info, time) {
428 print("Tree: drag-data-received");
430 var delete_selection_data = false;
431 var dnd_success = false;
432 /* Deal with what we are given from source */
433 if( sel_data && sel_data.length ) {
435 if (ctx.action == Gdk.DragAction.ASK) {
436 /* Ask the user to move or copy, then set the ctx action. */
439 if (ctx.action == Gdk.DragAction.MOVE) {
440 //delete_selection_data = true;
443 var source = Gtk.drag_get_source_widget(ctx);
445 if (this.targetData) {
446 if (source != this.el) {
447 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
449 // drag around.. - reorder..
450 this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);
454 //Seed.print(this.targetData);
460 // we can send stuff to souce here...
466 if (dnd_success == false)
468 Seed.print ("DnD data transfer failed!\n");
471 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
474 "cursor_changed":function (self) {
475 if (this.blockChanges) {
478 var iter = new Gtk.TreeIter();
480 if (this.selection.count_selected_rows() < 1) {
481 this.get('/LeftPanel.model').load( false);
482 this.get('/MidPropTree').activeElement = false;
483 this.get('/MidPropTree').hideWin();
485 var pm = this.get('/RightPalete.model');
486 if (!this.get('/LeftTree').getPaleteProvider()) {
487 // it may not be loaded yet..
490 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
491 this.get('/LeftTree.model').listAllTypes()));
496 //console.log('changed');
497 var s = this.selection;
498 s.get_selected(this.get('/LeftTree.model').el, iter);
502 value = new GObject.Value('');
503 this.get('/LeftTree.model').el.get_value(iter, 2, value);
504 this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
506 var data = JSON.parse(value.value);
507 this.get('/MidPropTree').activeElement = data;
508 this.get('/MidPropTree').hideWin();
509 this.get('/LeftPanel.model').load( data);
511 console.log(value.value);
512 // _g.button.set_label(''+value.get_string());
514 var pm =this.get('/RightPalete.model');
515 pm.load( this.get('/RightPalete').provider.gatherList(
516 this.get('/LeftTree.model').listAllTypes()));
521 //Seed.print( value.get_string());
528 xtype: Gtk.TreeStore,
532 XObject.prototype.init.call(this);
533 this.el.set_column_types ( 3, [
534 GObject.TYPE_STRING, // title
535 GObject.TYPE_STRING, // tip
536 GObject.TYPE_STRING // source..
540 changed : function(n, refresh) {
541 print("MODEL CHANGED CALLED" + this.activePath);
542 if (this.activePath) {
543 var iter = new Gtk.TreeIter();
544 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
545 this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
546 this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
548 this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
550 //this.currentTree = this.toJS(false, true)[0];
551 this.file.items = this.toJS(false, false);
552 print("AFTER CHANGED");
553 //console.dump(this.file.items);
555 this.currentTree = this.file.items[0];
556 //console.log(this.file.toSource());
559 print("REDNER BROWSER?!");
560 this.get('/LeftTree').renderView();
562 var pm = this.get('/RightPalete.model');
563 if (!this.get('/RightPalete').provider) {
569 pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
570 //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
574 loadFile : function(f) {
580 console.log('missing file');
584 // load the file if not loaded..
585 if (f.items === false) {
587 f.loadItems(function() {
593 if (f.items.length && typeof(f.items[0]) == 'string') {
595 this.get('/RightEditor').el.show();
596 this.get('/RightEditor.view').load( f.items[0]);
600 //console.dump(f.items);
602 this.get('/LeftTree.view').el.expand_all();
604 if (!f.items.length) {
607 this.get('/Window.leftvpaned').el.set_position(80);
609 this.get('/LeftTree.view').el.set_cursor(
610 new Gtk.TreePath.from_string('0'), null, false);
614 this.get('/Window.leftvpaned').el.set_position(200);
618 //print("hide right editior");
619 this.get('/RightEditor').el.hide();
620 //print("set current tree");
621 this.currentTree = this.toJS(false, false)[0];
622 //console.dump(this.currentTree);
623 this.currentTree = this.currentTree || { items: [] };
624 this.get('/LeftTree').renderView();
625 //console.dump(this.map);
626 //var RightPalete = imports.Builder.RightPalete.RightPalete;
627 var pm = this.get('/RightPalete.model');
630 this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
632 if (!this.get('/RightPalete').provider) {
633 print ("********* PALETE PROVIDER MISSING?!!");
635 this.get('/LeftTree').renderView();
637 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
641 this.get('/Window.view-notebook').el.set_current_page(
642 this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
645 findDropNode : function(treepath_str, targets) {
647 // this is used by the dragdrop code in the roo version AFAIR..
649 var path = treepath_str.replace(/^builder-/, '');
650 // treemap is depreciated... - should really check if model has any entries..
652 if (!this.el.iter_n_children(null)) {
654 return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];
656 print("FIND treepath: " + path);
657 //console.dump(this.treemap);
659 if (!treepath_str.match(/^builder-/)) {
660 return []; // nothing!
662 if (targets === true) {
665 return this.findDropNodeByPath(path,targets)
667 findDropNodeByPath : function(treepath_str, targets, pref) {
668 var path = treepath_str + ''; // dupe it..
669 pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
671 //console.dump(this.treemap);
672 while (path.length) {
673 print("LOOKING FOR PATH: " + path);
674 var node_data = this.singleNodeToJS(path);
675 if (node_data === false) {
676 print("node not found");
680 var xname = this.get('/LeftTree.model').file.guessName(node_data);
683 targets.forEach(function(tg) {
687 if ((tg == xname) ) {
690 if (tg.indexOf(xname +':') === 0) {
692 prop = tg.split(':').pop();
697 if (last) { // pref is after/before..
698 // then it's after last
700 return []; // do not allow..
702 return [ last, pref , prop];
705 return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
707 var par = path.split(':');
710 path = par.join(':');
716 dropNode : function(target_data, node) {
719 console.dump(target_data);
720 var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
722 print("add " + tp + "@" + target_data[1] );
725 if (tp && target_data[1] < 2) { // before or after..
726 var ar = target_data[0].split(':');
728 parent = new Gtk.TreePath.from_string( ar.join(':') );
731 var n_iter = new Gtk.TreeIter();
732 var iter_par = new Gtk.TreeIter();
733 var iter_after = after ? new Gtk.TreeIter() : false;
737 if (parent !== false) {
738 this.el.get_iter(iter_par, parent);
745 print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
746 this.el.get_iter(iter_after, after);
747 this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
748 n_iter, iter_par, iter_after);
751 this.el.append(n_iter, iter_par);
755 if (typeof(node) == 'string') {
756 var ar = node.split('.');
757 var xtype = ar.pop();
760 '|xns' : ar.join('.'),
763 if (target_data.length == 3 && target_data[2].length) {
764 node['*prop'] = target_data[2];
768 // work out what kind of packing to use..
769 if (typeof(node.pack) == 'undefined' && parent !== false) {
770 var pal = this.get('/LeftTree').getPaleteProvider();
772 var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
773 print ("PNAME : " + pname);
774 var cname = pal.guessName(node);
775 print ("CNAME : " + cname);
776 node.pack = pal.getDefaultPack(pname, cname);
787 // load children - if it has any..
790 this.load(xitems, n_iter);
792 if (tp && (xitems || after)) {
793 this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
795 // wee need to get the empty proptypes from somewhere..
797 //var olditer = this.activeIter;
798 this.activePath = this.el.get_path(n_iter).to_string();
800 // changed actually set's the node data..
801 this.changed(node, true);
805 this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
807 //Builder.MidPropTree._model.load(node);
808 //Builder.MidPropTree._win.hideWin();
809 //Builder.LeftPanel._model.load( node);
813 moveNode : function(target_data, action) {
814 //print("MOVE NODE");
815 // console.dump(target_data);
816 var old_iter = new Gtk.TreeIter();
817 var s = this.get('/LeftTree.view').selection;
818 s.get_selected(this.el, old_iter);
819 var node = this.nodeToJS(old_iter,false);
820 //console.dump(node);
823 // needs to drop first, otherwise the target_data
824 // treepath will be invalid.
826 this.dropNode(target_data, node);
827 if (action & Gdk.DragAction.MOVE) {
828 // print("REMOVING OLD NODE");
829 this.el.remove(old_iter);
833 this.activePath= false;
834 this.changed(false,true);
836 deleteSelected : function() {
837 this.get('/LeftTree.view').blockChanges = true;
838 var old_iter = new Gtk.TreeIter();
839 var s = this.get('/LeftTree.view').selection;
840 s.get_selected(this.el, old_iter);
841 var path = this.el.get_path(old_iter).to_string();
843 this.activePath= false;
846 this.activePath= false;
847 var iter = new Gtk.TreeIter();
848 this.el.get_iter_from_string(iter, path);
849 this.el.remove(iter);
851 // rebuild treemap. -- depreciated.!!
854 //this.toJS(null, true) // does not do anything?
855 this.activePath= false;
856 this.changed(false,true);
857 this.get('/LeftTree.view').blockChanges = false;
860 listAllTypes : function() {
861 var s = this.get('/LeftTree.view').selection;
862 print ("LIST ALL TYPES: " + s.count_selected_rows() );
864 if (s.count_selected_rows() > 0) {
865 var iter = new Gtk.TreeIter();
866 s.get_selected(this.el, iter);
868 // set some properties of the tree for use by the dropped element.
869 var value = new GObject.Value('');
870 this.el.get_value(iter, 2, value);
871 var data = JSON.parse(value.value);
874 var xname = this.get('/LeftTree.model').file.guessName(data);
875 console.log('selected:' + xname);
879 return []; // could not find it..
887 li.forEach(function(el) {
888 // this is specific to roo!!!?
890 var fullpath = _this.file.guessName(el);
891 if (fullpath.length && ret.indexOf(fullpath) < 0) {
896 if (el.items && el.items.length) {
905 addall([this.currentTree]);
907 // only if we have nothing, should we add '*top'
911 //console.log('all types in tree');
917 singleNodeToJS : function (treepath)
919 var iter = new Gtk.TreeIter();
920 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
924 var iv = this.getIterValue(iter, 2);
926 return JSON.parse(iv);
929 nodeToJS : function (iter, with_id)
931 var par = new Gtk.TreeIter();
932 var iv = this.getIterValue(iter, 2);
934 var k = JSON.parse(iv);
935 if (k.json && !this.el.iter_parent( par, iter )) {
940 var treepath_str = this.el.get_path(iter).to_string();
941 // not sure how we can handle mixed id stuff..
942 if (typeof(k.id) == 'undefined') {
943 k.id = 'builder-'+ treepath_str ;
947 this.treemap[ treepath_str ] = k;
948 k.xtreepath = treepath_str ;
951 if (this.el.iter_has_child(iter)) {
952 citer = new Gtk.TreeIter();
953 this.el.iter_children(citer, iter);
954 k.items = this.toJS(citer,with_id);
958 toJS : function(iter, with_id)
960 //Seed.print("WITHID: "+ with_id);
967 iter = new Gtk.TreeIter();
968 if (!this.el.get_iter_first(iter)) {
978 var k = this.nodeToJS(iter, with_id);
982 if (!this.el.iter_next(iter)) {
988 // convert the list into a json string..
992 getIterValue : function (iter, col) {
993 var gval = new GObject.Value('');
994 this.el.get_value(iter, col ,gval);
999 nodeTitle : function(c) {
1002 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
1003 if (sr) txt.push('<s>');
1004 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
1005 if (c.xtype) { txt.push(c.xtype); }
1006 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1007 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1008 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1011 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1012 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1013 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1014 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1015 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1016 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1017 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1018 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1019 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1021 // for flat classes...
1022 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1023 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1026 if (sr) txt.push('</s>');
1027 return (txt.length == 0 ? "Element" : txt.join(" "));
1029 nodeToJSON : function(c) {
1037 return JSON.stringify(o);
1039 load : function(tr,iter)
1041 var citer = new Gtk.TreeIter();
1042 //this.insert(citer,iter,0);
1043 for(var i =0 ; i < tr.length; i++) {
1045 this.el.insert(citer,iter,-1);
1047 this.el.append(citer);
1050 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1051 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1052 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1053 if (tr[i].items && tr[i].items.length) {
1054 this.load(tr[i].items, citer);
1060 xtype: Gtk.TreeViewColumn,
1061 pack : "append_column",
1063 XObject.prototype.init.call(this);
1064 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1068 xtype: Gtk.CellRendererText,
1078 id : "LeftTreeMenu",
1081 xtype: Gtk.MenuItem,
1083 label : "Delete Element",
1085 "activate":function (self) {
1087 this.get('/LeftTree.model').deleteSelected();
1098 id : "LeftProjectTree",
1099 showNoProjectSelected : function() {
1100 this.get('/StandardErrorDialog').show("Select a Project first.");
1102 getActiveProject : function() {
1103 return this.project;
1106 "leave_notify_event":function (self, event) {
1113 pack : "pack_start,false,false",
1116 xtype: Gtk.ComboBox,
1119 XObject.prototype.init.call(this);
1120 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1122 getValue : function() {
1123 var ix = this.el.get_active();
1127 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1130 setValue : function(fn)
1134 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1135 data.forEach(function(n, ix) {
1143 "changed":function (self) {
1144 var fn = this.getValue();
1145 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1146 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1151 xtype: Gtk.CellRendererText,
1152 pack : "pack_start,true",
1156 xtype: Gtk.ListStore,
1159 XObject.prototype.init.call(this);
1160 this.el.set_column_types ( 2, [
1161 GObject.TYPE_STRING, // real key
1162 GObject.TYPE_STRING // real type
1168 loadData : function(data) {
1169 var ov = this.get('/LeftProjectTree.combo').getValue();
1171 var iter = new Gtk.TreeIter();
1173 data.forEach(function(p) {
1178 el.set_value(iter, 0, p.fn);
1179 el.set_value(iter, 1, p.name);
1183 this.get('/LeftProjectTree.combo').setValue(ov);
1192 xtype: Gtk.ScrolledWindow,
1194 shadow_type : Gtk.ShadowType.IN,
1196 XObject.prototype.init.call(this);
1197 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1201 xtype: Gtk.TreeView,
1202 headers_visible : false,
1203 enable_tree_lines : true,
1206 XObject.prototype.init.call(this);
1207 var description = new Pango.FontDescription.c_new();
1208 description.set_size(8000);
1209 this.el.modify_font(description);
1211 this.selection = this.el.get_selection();
1212 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1216 "cursor_changed":function (self) {
1217 var iter = new Gtk.TreeIter();
1219 if (this.selection.count_selected_rows() < 1) {
1220 //XN.get('Builder.LeftTree.model').
1221 this.get('/LeftTree.model').load( false);
1225 var model = this.get('/LeftProjectTree.model');
1226 //console.log('changed');
1227 var s = this.selection;
1228 s.get_selected(model, iter);
1229 value = new GObject.Value('');
1230 model.el.get_value(iter, 2, value);
1232 console.log(value.value);// id..
1234 var file = this.get('/LeftProjectTree').project.getById(value.value);
1241 var nb = this.get('/LeftTopPanel.expander');
1242 nb.el.expanded = false;
1243 nb.listeners.activate.call(nb);
1244 //_expander.el.set_expanded(false);
1246 var ltm = this.get('/LeftTree.model');
1254 xtype: Gtk.TreeStore,
1258 XObject.prototype.init.call(this);
1259 this.el.set_column_types ( 3, [
1260 GObject.TYPE_STRING, // title
1261 GObject.TYPE_STRING, // tip
1262 GObject.TYPE_STRING // id..
1266 loadProject : function(pr) {
1271 this.get('/LeftProjectTree').project = pr;
1272 this.load(pr.toTree());
1273 this.get('/LeftProjectTree.view').el.expand_all();
1275 load : function(tr,iter) {
1277 console.log('Project tree load: ' + tr.length);
1278 var citer = new Gtk.TreeIter();
1279 //this.insert(citer,iter,0);
1282 tr.forEach(function (r) {
1284 _this.el.append(citer);
1286 _this.el.insert(citer,iter,-1);
1288 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1289 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1290 _this.el.set_value(citer, 2, '' + r.id ); //id
1291 if (r.cn && r.cn.length) {
1292 _this.load(r.cn, citer);
1297 getValue : function(iter, col) {
1298 var gval = new GObject.Value('');
1299 this.el.get_value(iter, col ,gval);
1300 return '' + gval.value;
1304 xtype: Gtk.TreeViewColumn,
1305 pack : "append_column",
1307 XObject.prototype.init.call(this);
1308 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1312 xtype: Gtk.CellRendererText,
1335 pack : "pack_start,false,true,0",
1342 "button_press_event":function (self, event) {
1343 this.get('/MidPropTree.model').showData('props');
1355 stock : Gtk.STOCK_ADD,
1356 icon_size : Gtk.IconSize.MENU
1371 "button_press_event":function (self, event) {
1372 this.get('/MidPropTree.model').showData('events');
1384 stock : Gtk.STOCK_ADD,
1385 icon_size : Gtk.IconSize.MENU
1400 "button_press_event":function (self, ev) {
1401 var p = this.get('/AddPropertyPopup');
1405 p.el.set_screen(Gdk.Screen.get_default());
1407 p.el.popup(null, null, null, null, 3, ev.button.time);
1419 stock : Gtk.STOCK_ADD,
1420 icon_size : Gtk.IconSize.MENU
1432 id : "AddPropertyPopup",
1435 xtype: Gtk.MenuItem,
1437 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1440 "activate":function (self) {
1442 this.get('/LeftPanel.model').add( {
1453 xtype: Gtk.MenuItem,
1455 tooltip_markup : "Add what type of packing is to be used",
1458 "activate":function (self) {
1460 this.get('/LeftPanel.model').add( {
1470 xtype: Gtk.MenuItem,
1472 tooltip_markup : "Override the init method",
1475 "activate":function (self) {
1477 this.get('/LeftPanel.model').add( {
1480 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1487 xtype: Gtk.SeparatorMenuItem,
1491 xtype: Gtk.MenuItem,
1493 tooltip_markup : "Add a user defined string property",
1496 "activate":function (self) {
1498 this.get('/LeftPanel.model').add( {
1508 xtype: Gtk.MenuItem,
1510 tooltip_markup : "Add a user defined number property",
1513 "activate":function (self) {
1515 this.get('/LeftPanel.model').add( {
1525 xtype: Gtk.MenuItem,
1527 tooltip_markup : "Add a user defined boolean property",
1530 "activate":function (self) {
1532 this.get('/LeftPanel.model').add( {
1542 xtype: Gtk.SeparatorMenuItem,
1546 xtype: Gtk.MenuItem,
1548 tooltip_markup : "Add a user function boolean property",
1551 "activate":function (self) {
1553 this.get('/LeftPanel.model').add( {
1556 val : "function() {\n \n}\n",
1569 xtype: Gtk.ScrolledWindow,
1572 shadow_type : Gtk.ShadowType.IN,
1575 XObject.prototype.init.call(this);
1576 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1580 xtype: Gtk.TreeView,
1583 headers_visible : false,
1584 enable_tree_lines : true,
1586 XObject.prototype.init.call(this);
1588 this.selection = this.el.get_selection();
1589 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1592 var description = new Pango.FontDescription.c_new();
1593 description.set_size(8000);
1594 this.el.modify_font(description);
1597 "button_press_event":function (self, ev) {
1601 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1602 return false; //not on a element.
1606 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1608 if (res.column.title != 'value') {
1609 return false; // ignore..
1611 if ( this.get('/LeftPanel').editing) {
1614 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1615 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1616 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1620 var provider = this.get('/LeftTree').getPaleteProvider();
1622 var opts = provider.findOptions(type);
1624 if (opts === false) {
1625 this.get('/LeftPanel').editableColumn.setOptions([]);
1626 renderer.has_entry = true;
1628 LeftPanel.editableColumn.setOptions(opts);
1629 renderer.has_entry = false;
1633 //Seed.print("click" + ev.type);
1634 //console.dump(res);
1640 if (res.column.title == 'value') {
1643 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1644 var p = this.get('/LeftPanelPopup');
1649 p.el.set_screen(Gdk.Screen.get_default());
1651 p.el.popup(null, null, null, null, 3, ev.button.time);
1652 //Seed.print("click:" + res.column.title);
1660 xtype: Gtk.TreeStore,
1664 XObject.prototype.init.call(this);
1665 this.el.set_column_types ( 5, [
1666 GObject.TYPE_STRING, // 0 real key
1667 GObject.TYPE_STRING, // 1 real value
1668 GObject.TYPE_STRING, // 2 visable key
1669 GObject.TYPE_STRING, // 3 visable value
1670 GObject.TYPE_STRING, // 4 need to store type of!!!
1674 toShort : function(str) {
1675 var a = typeof(str) == 'string' ? str.split("\n") : [];
1676 return a.length > 1 ? a[0] + '....' : '' + str;
1678 load : function(ar) {
1681 this.get('/RightEditor').el.hide();
1688 var provider = this.get('/LeftTree').getPaleteProvider();
1691 var iter = new Gtk.TreeIter();
1693 if (typeof(ar[i]) == 'object') {
1697 var type = provider.findType(ar, i, ar[i]);
1699 this.el.append(iter);
1700 var p = this.el.get_path(iter).to_string();
1702 this.el.set_value(iter, 0, i);
1703 this.el.set_value(iter, 1, '' + ar[i]);
1704 this.el.set_value(iter, 2, i);
1705 this.el.set_value(iter, 3, this.toShort(ar[i]));
1706 this.el.set_value(iter, 4, type);
1708 ar.listeners = ar.listeners || {};
1709 for (var i in ar.listeners ) {
1710 this.el.append(iter);
1711 var p = this.el.get_path(iter).to_string();
1714 this.el.set_value(iter, 0, '!'+ i );
1715 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1716 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1718 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1719 this.el.set_value(iter, 4, 'function');
1723 add : function(info) {
1724 // info includes key, val, skel, etype..
1726 type = info.type.toLowerCase();
1727 var data = this.toJS();
1729 if (info.etype == 'events') {
1730 data.listeners = data.listeners || { };
1731 if (typeof(data.listeners[info.key]) != 'undefined') {
1732 return; //already set!
1735 if (typeof(data[info.key]) != 'undefined') {
1740 if (typeof(info.val) == 'undefined') {
1743 if (info.type == 'boolean') {
1746 if (type == 'number') {
1754 if (info.etype == 'events') {
1756 data.listeners[info.key] = info.val;
1759 data[info.key] = info.val;
1763 var map = this.load(data);
1765 // flag it as changed to the interface..
1767 this.get('/LeftTree.model').changed(data, true);
1770 this.startEditing(map[k]);
1773 LeftPanel.get('view').el.row_activated(
1774 new Gtk.TreePath.from_string(map[k]),
1775 LeftPanel.editableColumn.el
1779 startEditing : function(path,col) {
1781 * start editing path (or selected if not set..)
1782 * @param {String|false} path (optional) treepath to edit - selected tree gets
1783 * edited by default.
1784 * @param {Number} 0 or 1 (optional)- column to edit.
1787 if (typeof(path) == 'string') {
1788 tp = new Gtk.TreePath.from_string(path);
1790 var iter = new Gtk.TreeIter();
1791 var s = this.get('/LeftPanel.view').selection;
1792 s.get_selected(this.el, iter);
1793 tp = this.el.get_path(iter);
1794 path = tp.to_string();
1798 // which colum is to be edited..
1800 if (typeof(col) == 'undefined') {
1801 var k = this.getValue(path, 0);
1802 colObj = (!k.length || k == '|') ?
1803 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1805 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1808 // make sure the pulldown is set correctly..
1809 // not really needed for second col...
1811 var provider = this.get('/LeftTree').getPaleteProvider();
1813 var type = this.get('/LeftPanel.model').getType(path);
1814 var opts = provider.findOptions(type);
1815 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1817 if (opts === false) {
1818 this.get('/LeftPanel').editableColumn.setOptions([]);
1819 renderer.has_entry = true; /// probably does not have any effect.
1821 this.get('/LeftPanel').editableColumn.setOptions(opts);
1822 renderer.has_entry = false;
1826 // iter now has row...
1827 GLib.timeout_add(0, 100, function() {
1829 colObj.items[0].el.editable = true; // esp. need for col 0..
1830 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1839 deleteSelected : function() {
1840 var data = this.toJS();
1841 var iter = new Gtk.TreeIter();
1842 var s = this.get('/LeftPanel.view').selection;
1843 s.get_selected(this.el, iter);
1846 var gval = new GObject.Value('');
1847 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1849 var val = gval.value;
1850 if (val[0] == '!') {
1852 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1855 delete data.listeners[ val.substring(1)];
1856 if (!XObject.keys(data.listeners).length) {
1857 delete data.listeners;
1861 if (typeof(data[val]) == 'undefined') {
1869 this.get('/LeftTree.model').changed(data, true);
1873 changed : function(str, doRefresh) {
1874 if (!this.activePath) {
1877 var iter = new Gtk.TreeIter();
1878 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1880 this.el.set_value(iter, 1, '' +str);
1881 this.el.set_value(iter, 3, '' + this.toShort(str));
1882 // update the tree...
1884 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
1887 var iter = new Gtk.TreeIter();
1888 this.get('/LeftPanel.model').el.get_iter_first(iter);
1893 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
1896 ar.listeners = ar.listeners || {};
1897 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
1900 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
1903 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
1909 //print(JSON.stringify(ar));
1913 getType : function(treepath) {
1914 return this.getValue(treepath, 4);
1916 getValue : function(treepath_str, col) {
1917 var iter = new Gtk.TreeIter();
1918 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
1920 var gval = new GObject.Value('');
1921 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
1922 var val = '' + gval.value;
1926 var type = this.getType(this.el.get_path(iter).to_string());
1927 //print("TYPE: " +type + " - val:" + val);
1928 switch(type.toLowerCase()) {
1932 return parseFloat(val); // Nan ?? invalid!!?
1934 return val == 'true' ? true : false;
1940 editSelected : function(e) {
1941 print("EDIT SELECTED?");
1942 var iter = new Gtk.TreeIter();
1943 var s = this.get('/LeftPanel.view').selection;
1944 s.get_selected(this.get('/LeftPanel.model').el, iter);
1945 var m = this.get('/LeftPanel.model')
1947 var gval = new GObject.Value('');
1948 this.el.get_value(iter, 0 ,gval);
1949 var val = '' + gval.value;
1951 gval = new GObject.Value('');
1952 this.el.get_value(iter, 1 ,gval);
1953 var rval = gval.value;
1954 var activePath = this.el.get_path(iter).to_string();
1955 this.activePath = activePath ;
1956 // was activeIter...
1959 var showEditor = false;
1961 if (val[0] == '!') {
1964 if (val[0] == '|') {
1965 if (rval.match(/function/g) || rval.match(/\n/g)) {
1972 this.activePath = false;
1973 GLib.timeout_add(0, 1, function() {
1974 // Gdk.threads_enter();
1975 _this.get('/RightEditor').el.show();
1976 _this.get('/RightEditor.view').load( rval );
1980 _this.activePath = activePath ;
1982 // Gdk.threads_leave();
1988 this.get('/RightEditor').el.hide();
1990 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
1996 xtype: Gtk.TreeViewColumn,
1997 pack : "append_column",
1999 XObject.prototype.init.call(this);
2001 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2002 this.get('/LeftPanel').propertyColumn = this;
2007 xtype: Gtk.CellRendererText,
2008 pack : "pack_start",
2010 "editing_started":function (self, editable, path) {
2012 this.get('/LeftPanel.model').activePath = path;
2015 "edited":function (self, object, p0) {
2016 var model = this.get('/LeftPanel.model');
2017 var path = model.activePath;
2018 var iter = new Gtk.TreeIter();
2019 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2020 model.el.set_value(iter, 0, p0);
2021 model.el.set_value(iter, 2, p0);
2023 model.activePath = false;
2025 this.get('/LeftTree.model').changed(model.toJS(), true);
2026 this.el.editable = false;
2033 xtype: Gtk.TreeViewColumn,
2034 pack : "append_column",
2036 XObject.prototype.init.call(this);
2037 this.el.add_attribute(this.items[0].el , 'text', 3 );
2038 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2039 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2040 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2042 this.get('/LeftPanel').editableColumn= this;
2044 setOptions : function(ar) {
2045 var m = this.items[0].el.model;
2047 var iter = new Gtk.TreeIter();
2048 ar.forEach(function(i) {
2051 m.set_value(iter, 0, i);
2057 xtype: Gtk.CellRendererCombo,
2058 pack : "pack_start",
2063 XObject.prototype.init.call(this);
2064 this.el.model = new Gtk.ListStore();
2065 this.el.model.set_column_types ( 1, [
2066 GObject.TYPE_STRING // 0 real key
2070 "edited":function (self, object, p0) {
2071 this.get('/LeftPanel').editing = false;
2072 print("EDITED? p:" + p0 + " t:" + p0);
2073 this.get('/LeftPanel.model').changed(p0, true);
2074 this.get('/LeftPanel.model').activePath = false;
2076 "editing_started":function (self, editable, path) {
2077 this.get('/LeftPanel').editing = true;
2078 // console.log('editing started');
2079 // r.has_entry = false;
2080 this.get('/LeftPanel.model').editSelected(editable);
2091 id : "LeftPanelPopup",
2094 xtype: Gtk.MenuItem,
2098 "activate":function (self) {
2099 this.get('/LeftPanel.model').deleteSelected();
2104 xtype: Gtk.MenuItem,
2108 "activate":function (self) {
2109 this.get('/LeftPanel.model').startEditing(false, 0);
2122 xtype: Gtk.ScrolledWindow,
2123 pack : "pack_end,false,true,0",
2125 shadow_type : Gtk.ShadowType.IN,
2127 XObject.prototype.init.call(this);
2128 XObject.prototype.init.call(this);
2129 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2130 this.el.set_size_request ( 150, -1 );
2133 activeElement : false,
2134 hideWin : function() {
2141 if (this.get('/Window.left').el.position < 160) {
2144 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2151 xtype: Gtk.TreeView,
2152 enable_tree_lines : true,
2153 headers_visible : false,
2156 XObject.prototype.init.call(this);
2158 var description = new Pango.FontDescription.c_new();
2159 description.set_size(8000);
2160 this.el.modify_font(description);
2162 //this.selection = this.el.get_selection();
2163 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2172 "cursor_changed":function (self) {
2173 var iter = new Gtk.TreeIter();
2175 //console.log('changed');
2176 var m = this.get('model');
2177 if (!this.selection){
2178 this.selection = this.el.get_selection();
2181 var s = this.selection;
2182 if (!s.get_selected(m.el, iter)) {
2185 var tp = m.el.get_path(iter).to_string();
2190 var key = m.getValue(tp, 0);
2192 var type = m.getValue(tp, 1);
2193 var skel = m.getValue(tp, 3);
2194 var etype = m.getValue(tp, 5);
2197 this.get('/MidPropTree').hideWin();
2199 if (type == 'function') {
2201 if (etype != 'events') {
2205 this.get('/LeftPanel.model').add({
2214 if (type.indexOf('.') > -1 ||
2215 type == 'boolean') {
2219 this.get('/LeftPanel.model').add( {
2229 xtype: Gtk.ListStore,
2232 XObject.prototype.init.call(this);
2233 this.el.set_column_types ( 6, [
2234 GObject.TYPE_STRING, // real key
2235 GObject.TYPE_STRING, // real type
2236 GObject.TYPE_STRING, // docs ?
2237 GObject.TYPE_STRING, // visable desc
2238 GObject.TYPE_STRING, // function desc
2239 GObject.TYPE_STRING // element type (event|prop)
2243 getValue : function(treepath, col)
2245 var tp = new Gtk.TreePath.from_string (treepath);
2246 var iter = new Gtk.TreeIter();
2247 this.el.get_iter (iter, tp);
2248 var value = new GObject.Value('');
2249 this.el.get_value(iter, col, value);
2253 showData : function(type) {
2255 if (!this.get('/MidPropTree').activeElement || !type) {
2256 return; // no active element
2259 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2260 var palete = this.get('/LeftTree').getPaleteProvider();
2264 Seed.print('Showing right?');
2265 if (!this.get('/MidPropTree').shown) {
2267 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2268 this.get('/MidPropTree').el.show();
2269 this.get('/MidPropTree').shown = true;
2272 var elementList = palete.getPropertiesFor(fullpath, type);
2273 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2274 // console.dump(elementList);
2277 var iter = new Gtk.TreeIter();
2278 for(var i =0 ; i < elementList.length; i++) {
2279 var p=elementList[i];
2280 this.el.append(iter);
2281 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2282 //GObject.TYPE_STRING, // real key
2283 // GObject.TYPE_STRING, // real type
2284 // GObject.TYPE_STRING, // docs ?
2285 // GObject.TYPE_STRING // func def?
2288 this.el.set_value(iter, 0, p.name);
2289 this.el.set_value(iter, 1, p.type);
2290 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2291 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2292 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2293 this.el.set_value(iter, 5, type);
2301 xtype: Gtk.TreeViewColumn,
2303 this.el = new Gtk.TreeViewColumn();
2304 this.parent.el.append_column(this.el);
2306 XObject.prototype.init.call(this);
2307 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2312 xtype: Gtk.CellRendererText,
2313 pack : "pack_start,true"
2337 xtype: Gtk.Notebook,
2338 pack : "pack_start,true,true",
2339 id : "view-notebook",
2342 XObject.prototype.init.call(this);
2343 this.el.set_current_page(0);
2345 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2346 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2353 id : "RightBrowser",
2357 pack : "pack_start,false,true,0",
2361 pack : "pack_start,false,false,0",
2362 label : "Dump HTML to console",
2364 "activate":function (self) {
2365 this.get('/RightBrowser.view').el.execute_script(
2366 "console.log(document.body.innerHTML);");
2367 this.get('/RightBrowser.view').el.execute_script(
2368 "console.log(Builder.dump(Builder));");
2375 xtype: Gtk.ScrolledWindow,
2377 shadow_type : Gtk.ShadowType.IN,
2379 XObject.prototype.init.call(this);
2380 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2384 xtype: WebKit.WebView,
2388 XObject.prototype.init.call(this);
2389 // this may not work!?
2390 this.el.open('file:///' + __script_path__ + '/../builder.html');
2394 this.el, /* widget that will accept a drop */
2395 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2396 null, /* lists of target to support */
2397 0, /* size of list */
2398 Gdk.DragAction.COPY /* what to do with data after dropped */
2401 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2402 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2404 renderJS : function(data) {
2405 this.renderedData = data;
2406 var str = JSON.stringify(data) ;
2409 console.log('not loaded yet');
2411 Seed.print("RENDER:" + str);
2412 imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2413 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2416 "load_finished":function (self, object) {
2417 if (this.ready) { // dont do it twice!
2422 this.renderJS(this.get('/LeftTree.model').toJS()[0]);
2424 "script_alert":function (self, object, p0) {
2427 return true; // do not display anything...
2429 "console_message":function (self, object, p0, p1) {
2430 console.log(object);
2431 if (!object.match(/^\{/)) {
2432 return false; // do not handle!!! -> later maybe in console..
2434 console.log(object);
2435 var val = JSON.parse(object);
2437 if (typeof(val['hover-node']) != 'undefined') {
2438 this.activeNode = val['hover-node'];
2439 console.log('active node: ' + this.activeNode);
2444 if (typeof(val['id']) != 'undefined') {
2445 // this.activeNode = val['id'];
2446 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2450 this.get('/LeftTree.view').selectNode(tg[0]);
2454 if (ret && typeof(val['set']) != 'undefined') {
2455 this.get('/LeftPanel.model').add({
2459 //console.log('active node: ' + this.activeNode);
2462 //Seed.print('a:'+a);
2463 //Seed.print('b:'+b);
2464 //Seed.print('c:'+c);
2467 "drag_motion":function (w, ctx, x, y, time, ud) {
2468 // console.log('DRAG MOTION');
2470 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2471 this.targetData = [];
2472 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2474 // A) find out from drag all the places that node could be dropped.
2475 var src = Gtk.drag_get_source_widget(ctx);
2476 if (!src.dropList) {
2477 Gdk.drag_status(ctx, 0, time);
2480 // b) get what we are over.. (from activeNode)
2481 // tree is empty.. - list should be correct..
2482 if (!this.get('/LeftTree.model').currentTree) {
2483 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2487 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2489 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2492 Gdk.drag_status(ctx, 0,time);
2493 this.get('/LeftTree.view').highlight(false);
2497 // if we have a target..
2498 // -> highlight it! (in browser)
2499 // -> highlight it! (in tree)
2501 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2502 this.get('/LeftTree.view').highlight(tg);
2503 this.targetData = tg;
2504 // for tree we should handle this...
2507 "drag_drop":function (w, ctx, x, y,time, ud) {
2508 print("TARGET: drag-drop");
2509 var is_valid_drop_site = true;
2514 w, /* will receive 'drag-data-received' signal */
2515 ctx, /* represents the current state of the DnD */
2516 this.get('/Window').atoms["STRING"], /* the target type we want */
2517 time /* time stamp */
2521 /* No target offered by source => error */
2524 return is_valid_drop_site;
2526 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2528 print("Browser: drag-data-received");
2529 var delete_selection_data = false;
2530 vardnd_success = false;
2531 /* Deal with what we are given from source */
2532 if( sel_data && sel_data.length ) {
2534 if (ctx.action == Gdk.DragAction.ASK) {
2535 /* Ask the user to move or copy, then set the ctx action. */
2538 if (ctx.action == Gdk.DragAction.MOVE) {
2539 delete_selection_data = true;
2541 var source = Gtk.drag_get_source_widget(ctx);
2543 print("Browser: source.DRAGDATA? " + source.dragData);
2544 if (this.targetData) {
2545 print(this.targetData);
2546 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2555 if (dnd_success == false)
2557 Seed.print ("DnD data transfer failed!\n");
2560 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2572 id : "RightGtkView",
2573 renderJS : function(data, withDebug)
2578 this.withDebug = false;
2580 if (this.renderedEl) {
2581 this.get('view').el.remove(this.renderedEl);
2582 this.renderedEl.destroy();
2583 this.renderedEl = false;
2586 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2587 // in theory tree is actually window..
2589 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2594 this.get('view').el.set_size_request(
2595 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2598 this.renderedEl.set_size_request(
2599 tree.default_width || 600,
2600 tree.default_height || 400
2602 this.get('view').el.show_all();
2607 showInWindow : function() {
2608 print("GET PROEJCT");
2609 var pr = this.get('/LeftProjectTree').getActiveProject();
2611 console.log(pr.paths);
2614 var src= this.buildJS(
2615 this.get('/LeftTree.model').toJS()[0],
2620 //var x = new imports.sandbox.Context();
2624 Seed.check_syntax('var e = ' + src);
2627 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2628 this.get('/Terminal').feed(console._dump(e)+"\n");
2630 var lines = src.split("\n");
2631 var start = Math.max(0, e.line - 10);
2632 var end = Math.min(lines.length, e.line + 10);
2633 for (var i =start ; i < end; i++) {
2635 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2638 this.get('/Terminal').feed(lines[i] + "\n");
2645 this.get('/BottomPane').el.set_current_page(1);
2646 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2647 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2648 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2650 var _top = x.get_global_object()._top;
2652 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2654 if (_top.el.popup) {
2655 _top.el.popup(null, null, null, null, 3, null);
2659 viewAdd : function(item, par)
2661 // does something similar to xobject..
2662 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2664 if (item.pack===false || item.pack === 'false') { // no ;
2667 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2668 var ns = imports.gi[item['|xns']];
2669 var ctr = ns[item['xtype']];
2671 for(var k in item) {
2673 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2688 if (k[0] == '|' && typeof(kv) == 'string') {
2690 if (kv.match(new RegExp('function'))) {
2693 print("WASL " + k + '=' + kv);
2695 eval( 'kv = ' + kv);
2696 } catch(e) { continue; }
2699 print(k + '=' + kv);
2701 if (k[0] == '|') { // should be boolean or number..
2704 if (k == 'show_tabs') { // force tab showing for notebooks.
2712 var el = new ctr(ctr_args);
2715 //console.dump(item.pack);
2722 if (typeof(item.pack) == 'string') {
2724 item.pack.split(',').forEach(function(e, i) {
2726 if (e == 'false') { args.push( false); return; }
2727 if (e == 'true') { args.push( true); return; }
2728 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2731 //print(args.join(","));
2733 pack_m = args.shift();
2735 pack_m = item.pack.shift();
2740 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2742 name: "ArgumentError",
2743 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2744 "ADDING : " + item.id + " " + el
2753 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2754 //Seed.print('args: ' + args.length);
2756 par[pack_m].apply(par, args);
2760 item.items = item.items || [];
2761 item.items.forEach(function(ch) {
2762 _this.viewAdd(ch, el);
2767 // add the signal handlers.
2768 // is it a widget!?!!?
2774 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2775 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2776 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2777 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2778 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2788 widgetExposeEvent : function() {
2789 /// print("WIDGET EXPOSE"); // draw highlight??
2792 widgetDragMotionEvent : function() {
2793 print("WIDGET DRAGMOTION");
2796 widgetDragDropEvent : function() {
2797 print("WIDGET DRAGDROP");
2800 widgetPressEvent : function(w,e,u,d) {
2801 if (this.get('view').pressed) {
2804 this.get('view').pressed = true;
2805 print("WIDGET PRESS " + d.xtreepath );
2806 this.get('/LeftTree.view').selectNode( d.xtreepath );
2809 widgetReleaseEvent : function() {
2810 this.get('view').pressed = false;
2816 pack : "pack_start,false,true,0",
2820 pack : "pack_start,false,false,0",
2821 label : "Run The Application",
2823 "button_press_event":function (self, event) {
2824 // call render on left tree - with special option!?!
2828 print("GET PROEJCT");
2829 var pr = this.get('/LeftProjectTree').getActiveProject();
2832 for (var i in pr.paths) {
2836 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
2837 print ("RUN DIR:" + dir);
2839 this.get('/BottomPane').el.set_current_page(1);
2840 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
2841 , false,false,false);
2842 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
2843 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2853 xtype: Gtk.ScrolledWindow,
2856 shadow_type : Gtk.ShadowType.IN,
2858 XObject.prototype.init.call(this);
2859 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2863 xtype: Gtk.EventBox,
2866 XObject.prototype.init.call(this);
2867 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
2868 red: 0x9F00, green: 0xB800 , blue : 0xA800
2876 XObject.prototype.init.call(this);
2877 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
2878 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
2883 xtype: Gtk.EventBox,
2886 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
2887 XObject.prototype.init.call(this);
2891 this.el, /* widget that will accept a drop */
2892 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2893 null, /* lists of target to support */
2894 0, /* size of list */
2895 Gdk.DragAction.COPY /* what to do with data after dropped */
2898 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2899 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2902 getActiveNode : function(x,y)
2904 // workout what node is here..
2905 return '0'; // top..
2909 "drag_motion":function (self, ctx, x, y, time) {
2911 // A) find out from drag all the places that node could be dropped.
2912 var src = Gtk.drag_get_source_widget(ctx);
2913 if (!src.dropList) {
2914 Gdk.drag_status(ctx, 0, time);
2917 // b) get what we are over.. (from activeNode)
2918 // tree is empty.. - list should be correct..
2919 if (!this.get('/LeftTree.model').currentTree) {
2920 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2924 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2925 var activeNode = this.getActiveNode(x, y);
2928 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
2931 Gdk.drag_status(ctx, 0,time);
2932 this.get('/LeftTree.view').highlight(false);
2936 // if we have a target..
2937 // -> highlight it! (in browser)
2938 // -> highlight it! (in tree)
2940 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2941 this.get('/LeftTree.view').highlight(tg);
2942 this.targetData = tg;
2943 // for tree we should handle this...
2946 "drag_drop":function (self,ctx, x, y, time) {
2947 Seed.print("TARGET: drag-drop");
2948 var is_valid_drop_site = true;
2953 self, /* will receive 'drag-data-received' signal */
2954 ctx, /* represents the current state of the this.gDnD */
2955 this.get('/Window').atoms["STRING"], /* the target type we want */
2956 time /* time stamp */
2960 /* No target offered by source => error */
2963 return is_valid_drop_site;
2966 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2968 Seed.print("GtkView: drag-data-received");
2969 var delete_selection_data = false;
2970 var dnd_success = false;
2971 /* Deal with what we are given from source */
2972 if( sel_data && sel_data.length ) {
2974 if (ctx.action == Gdk.DragAction.ASK) {
2975 /* Ask the user to move or copy, then set the ctx action. */
2978 if (ctx.action == Gdk.DragAction.MOVE) {
2979 delete_selection_data = true;
2981 var source = Gtk.drag_get_source_widget(ctx);
2983 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
2984 if (this.targetData) {
2985 Seed.print(this.targetData);
2986 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2995 if (dnd_success == false)
2997 Seed.print ("DnD data transfer failed!\n");
3000 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3003 "button_press_event":function (self, event) {
3004 this.pressed = false;
3022 xtype: Gtk.Notebook,
3025 XObject.prototype.init.call(this);
3026 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3027 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3032 xtype: Gtk.ScrolledWindow,
3037 xtype: GtkSource.View,
3041 XObject.prototype.init.call(this);
3042 var description = Pango.Font.description_from_string("monospace")
3043 description.set_size(8000);
3044 this.el.modify_font(description);
3047 load : function(str) {
3048 this.get('/BottomPane').el.set_current_page(0);
3049 this.el.get_buffer().set_text(str, str.length);
3050 var lm = GtkSource.LanguageManager.get_default();
3052 this.el.get_buffer().set_language(lm.get_language('js'));
3053 var buf = this.el.get_buffer();
3054 var cursor = buf.get_mark("insert");
3055 var iter= new Gtk.TextIter;
3056 buf.get_iter_at_mark(iter, cursor);
3058 iter.set_line_offset(4);
3059 buf.move_mark(cursor, iter);
3062 cursor = buf.get_mark("selection_bound");
3063 iter= new Gtk.TextIter;
3064 buf.get_iter_at_mark(iter, cursor);
3066 iter.set_line_offset(4);
3067 buf.move_mark(cursor, iter);
3069 this.el.grab_focus();
3073 xtype: GtkSource.Buffer,
3074 pack : "set_buffer",
3076 "changed":function (self) {
3077 var s = new Gtk.TextIter();
3078 var e = new Gtk.TextIter();
3079 this.el.get_start_iter(s);
3080 this.el.get_end_iter(e);
3081 var str = this.el.get_text(s,e,true);
3083 Seed.check_syntax('var e = ' + str);
3085 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3086 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3088 print("SYNTAX ERROR IN EDITOR");
3093 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3094 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3097 this.get('/LeftPanel.model').changed( str , false);
3106 xtype: Gtk.ScrolledWindow,
3110 xtype: Vte.Terminal,
3113 feed : function(str) {
3114 this.el.feed(str,str.length);
3125 pack : "pack_start,false,false",
3129 this.get('buttonbar').el.show();
3130 this.get('viewbox').el.hide();
3131 print("TRIED TO HIDE");
3134 this.get('buttonbar').el.hide();
3135 this.get('viewbox').el.show();
3136 // this.get('model').expanded();
3148 pack : "pack_start,false,true",
3150 "clicked":function (self) {
3151 this.get('/RightPalete').show();
3158 stock : Gtk.STOCK_GOTO_FIRST,
3159 icon_size : Gtk.IconSize.MENU
3169 XObject.prototype.init.call(this);
3170 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3173 "enter_notify_event":function (self, event) {
3174 this.get('/RightPalete').show();
3188 pack : "pack_start,false,true",
3197 pack : "pack_start,false,true",
3199 "clicked":function (self) {
3200 this.get('/RightPalete').hide();
3207 stock : Gtk.STOCK_GOTO_LAST,
3208 icon_size : Gtk.IconSize.MENU
3215 xtype: Gtk.ScrolledWindow,
3218 XObject.prototype.init.call(this);
3219 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3220 this.el.set_size_request(-1,200);
3222 shadow_type : Gtk.ShadowType.IN,
3225 xtype: Gtk.TreeView,
3228 XObject.prototype.init.call(this);
3229 this.el.set_size_request(150,-1);
3230 // set_reorderable: [1]
3232 var description = new Pango.FontDescription.c_new();
3233 description.set_size(8000);
3234 this.el.modify_font(description);
3236 this.selection = this.el.get_selection();
3237 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3238 // this.selection.signal['changed'].connect(function() {
3239 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3241 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3243 Gtk.drag_source_set (
3244 this.el, /* widget will be drag-able */
3245 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3246 null, /* lists of target to support */
3247 0, /* size of list */
3248 Gdk.DragAction.COPY /* what to do with data after dropped */
3250 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3252 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3253 Gtk.drag_source_add_text_targets(this.el);
3255 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3256 targets = new Gtk.TargetList();
3257 targets.add( LeftTree.atoms["STRING"], 0, 0);
3258 targets.add_text_targets( 1 );
3259 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3261 //if you want to allow text to be output elsewhere..
3262 //Gtk.drag_source_add_text_targets(this.el);
3266 headers_visible : false,
3267 enable_tree_lines : true,
3269 "drag_begin":function (self, ctx) {
3270 // we could fill this in now...
3271 Seed.print('SOURCE: drag-begin');
3275 var iter = new Gtk.TreeIter();
3276 var s = this.selection;
3277 s.get_selected(this.get('/RightPalete.model').el, iter);
3278 var path = this.get('/RightPalete.model').el.get_path(iter);
3280 var pix = this.el.create_row_drag_icon ( path);
3283 Gtk.drag_set_icon_pixmap (ctx,
3290 var value = new GObject.Value('');
3291 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3292 if (!this.get('/RightPalete').provider) {
3295 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3296 this.el.dragData = value.value;
3303 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3304 //Seed.print('Palete: drag-data-get: ' + target_type);
3305 if (this.el.dragData && this.el.dragData.length ) {
3306 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3310 //this.el.dragData = "TEST from source widget";
3314 "drag_end":function (self, drag_context) {
3315 Seed.print('SOURCE: drag-end');
3316 this.el.dragData = false;
3317 this.el.dropList = false;
3318 this.get('/LeftTree.view').highlight(false);
3324 xtype: Gtk.ListStore,
3327 XObject.prototype.init.call(this);
3328 this.el.set_column_types ( 2, [
3329 GObject.TYPE_STRING, // title
3330 GObject.TYPE_STRING // tip
3335 load : function(tr,iter)
3340 //console.log('Project tree load: ' + tr.length);
3341 var citer = new Gtk.TreeIter();
3342 //this.insert(citer,iter,0);
3343 for(var i =0 ; i < tr.length; i++) {
3346 this.el.append(citer);
3348 this.el.insert(citer,iter,-1);
3353 this.el.set_value(citer, 0, '' + r ); // title
3355 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3356 //if (r.cn && r.cn.length) {
3357 // this.load(r.cn, citer);
3363 getValue : function (iter, col) {
3364 var gval = new GObject.Value('');
3365 this.el.get_value(iter, col ,gval);
3372 xtype: Gtk.TreeViewColumn,
3373 pack : "append_column",
3375 XObject.prototype.init.call(this);
3376 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3380 xtype: Gtk.CellRendererText,
3402 XObject.cache['/Window'] = Window;