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,
106 label : "Add Directory to Project",
109 "activate":function (self) {
110 var fn = this.get('/LeftProjectTree').get('combo').getValue();
112 this.get('/LeftProjectTree').showNoProjectSelected();
117 var dc = new Gtk.FileChooserDialog({
118 action : Gtk.FileChooserAction.SELECT_FOLDER,
120 'select-multiple' : false,
121 "show-hidden" : true,
123 dc.add_button("Add To Project", Gtk.ResponseType.ACCEPT );
124 dc.add_button("Cancel",Gtk.ResponseType.CANCEL);
126 if (dc.run() != Gtk.ResponseType.ACCEPT) {
132 //Seed.print(dc.get_filename());
133 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
134 pm.getByFn(fn).add(dc.get_filename(), 'dir');
140 xtype: Gtk.SeparatorMenuItem,
148 "activate":function (self) {
182 label : "Select Project",
184 pack : "pack_start,false,true",
186 XObject.prototype.init.call(this);
187 this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
190 "activate":function (self) {
191 var nb = this.get('/LeftTopPanel.notebook');
192 if (this.el.expanded) {
195 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
198 var model = this.get('/LeftProjectTree.combomodel');
199 // print ("loading Projects?")
200 //console.dump(pm.projects);
201 model.loadData(pm.projects);
204 nb.el.set_current_page(1);
205 //pm.on('changed', function() {
206 //console.log("CAUGHT project manager change");
207 // _combo.model.loadData(pm.projects);
211 nb.el.set_current_page(0);
213 "enter_notify_event":function (self, event) {
214 this.el.expanded = !this.el.expanded;
215 //if (this.el.expanded ) {
216 this.listeners.activate.call(this);
228 pack : "pack_start,true,true",
230 XObject.prototype.init.call(this);
231 this.el.set_current_page(0);
236 xtype: Gtk.ScrolledWindow,
238 shadow_type : Gtk.ShadowType.IN,
240 XObject.prototype.init.call(this);
241 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
244 getPaleteProvider : function() {
245 var model = this.get('model');
246 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
247 return pm.getPalete(model.file.getType());
249 renderView : function() {
250 var model = this.get('model');
251 print("RENDER VIEW?" + model.file.getType());
252 switch( model.file.getType()) {
254 this.get('/RightBrowser.view').renderJS(model.toJS(false,true)[0]);
256 this.get('/RightGtkView').renderJS(model.toJS(false,true)[0]);
264 headers_visible : false,
265 enable_tree_lines : true,
268 XObject.prototype.init.call(this);
269 var description = new Pango.FontDescription.c_new();
270 description.set_size(8000);
271 this.el.modify_font(description);
273 this.selection = this.el.get_selection();
274 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
276 this.selection.signal['changed'].connect(function() {
277 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
278 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
282 Gtk.drag_source_set (
283 this.el, /* widget will be drag-able */
284 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
285 null, /* lists of target to support */
286 0, /* size of list */
287 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
290 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
292 Gtk.drag_source_add_text_targets(this.el);
295 this.el, /* widget that will accept a drop */
296 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
297 null, /* lists of target to support */
298 0, /* size of list */
299 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
302 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
303 Gtk.drag_dest_add_text_targets(this.el);
305 highlight : function(treepath_ar) {
306 if (treepath_ar.length && treepath_ar[0].length ) {
307 this.el.set_drag_dest_row(
308 new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);
310 this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
314 selectNode : function(treepath_str) {
315 //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
316 var tp = new Gtk.TreePath.from_string(treepath_str);
317 this.el.set_cursor(tp, null, false);
318 this.el.scroll_to_cell(tp, null, false, 0,0);
321 "button_press_event":function (self, ev) {
322 console.log("button press?");
323 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
324 print("click" + ev.type);
330 this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
332 if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();
334 this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
335 this.get('/LeftTreeMenu').el.show_all();
336 this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
337 print("click:" + res.path.to_string());
340 "drag_begin":function (self, drag_context) {
341 print('SOURCE: drag-begin');
342 this.targetData = false;
343 // find what is selected in our tree...
344 var iter = new Gtk.TreeIter();
345 var s = this.selection;
346 s.get_selected(this.get('/LeftTree.model').el, iter);
348 // set some properties of the tree for use by the dropped element.
349 var value = new GObject.Value('');
350 this.get('/LeftTree.model').el.get_value(iter, 2, value);
351 var data = JSON.parse(value.value);
352 var xname = this.get('/LeftTree.model').file.guessName(data);
354 this.el.dragData = xname;
355 this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);
358 // make the drag icon a picture of the node that was selected
359 var path = this.get('/LeftTree.model').el.get_path(iter);
360 this.el.treepath = path.to_string();
362 var pix = this.el.create_row_drag_icon ( path);
364 Gtk.drag_set_icon_pixmap (ctx,
373 "drag_end":function (self, drag_context) {
374 Seed.print('LEFT-TREE: drag-end');
375 this.el.dragData = false;
376 this.el.dropList = false;
377 this.targetData = false;
378 this.get('/LeftTree.view').highlight(false);
381 "drag_motion":function (self, ctx, x, y, time) {
382 console.log("LEFT-TREE: drag-motion");
383 var src = Gtk.drag_get_source_widget(ctx);
385 // a drag from elsewhere...- prevent drop..
387 print("no drag data!");
388 Gdk.drag_status(ctx, 0, time);
389 this.targetData = false;
392 var action = Gdk.DragAction.COPY;
393 if (src == this.el) {
394 // unless we are copying!!! ctl button..
395 action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
399 if (!this.get('/LeftTree.model').el.iter_n_children(null)) {
400 // no children.. -- asume it's ok..
401 this.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];
402 Gdk.drag_status(ctx, action ,time);
406 print("GETTING POS");
407 var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);
408 print("ISOVER? " + isOver);
410 Gdk.drag_status(ctx, 0 ,time);
411 return false; // not over apoint!?!
413 // drag node is parent of child..
414 console.log("SRC TREEPATH: " + src.treepath);
415 console.log("TARGET TREEPATH: " + data.path.to_string());
417 // nned to check a few here..
418 //Gtk.TreeViewDropPosition.INTO_OR_AFTER
419 //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
420 //Gtk.TreeViewDropPosition.AFTER
421 //Gtk.TreeViewDropPosition.BEFORE
423 if (typeof(src.treepath) != 'undefined' &&
424 src.treepath == data.path.to_string().substring(0,src.treepath.length)) {
425 print("subpath drag");
426 Gdk.drag_status(ctx, 0 ,time);
431 //print("DUMPING DATA");
432 //console.dump(data);
435 print(data.path.to_string() +' => '+ data.pos);
436 var tg = this.get('/LeftTree.model').findDropNodeByPath(
437 data.path.to_string(), src.dropList, data.pos);
439 this.get('/LeftTree.view').highlight(tg);
441 print("Can not find drop node path");
442 this.targetData = false;
443 Gdk.drag_status(ctx, 0, time);
447 this.targetData = tg;
450 Gdk.drag_status(ctx, action ,time);
454 "drag_drop":function (w, ctx, x, y, time) {
455 Seed.print("TARGET: drag-drop");
459 w, /* will receive 'drag-data-received' signal */
460 ctx, /* represents the current state of the DnD */
461 this.get('/Window').atoms["STRING"], /* the target type we want */
462 time /* time stamp */
466 /* No target offered by source => error */
471 "drag_data_received":function (self, ctx, x, y, sel_data, info, time) {
472 print("Tree: drag-data-received");
474 var delete_selection_data = false;
475 var dnd_success = false;
476 /* Deal with what we are given from source */
477 if( sel_data && sel_data.length ) {
479 if (ctx.action == Gdk.DragAction.ASK) {
480 /* Ask the user to move or copy, then set the ctx action. */
483 if (ctx.action == Gdk.DragAction.MOVE) {
484 //delete_selection_data = true;
487 var source = Gtk.drag_get_source_widget(ctx);
489 if (this.targetData) {
490 if (source != this.el) {
491 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
493 // drag around.. - reorder..
494 this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);
498 //Seed.print(this.targetData);
504 // we can send stuff to souce here...
510 if (dnd_success == false)
512 Seed.print ("DnD data transfer failed!\n");
515 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
518 "cursor_changed":function (self) {
519 var iter = new Gtk.TreeIter();
521 if (this.selection.count_selected_rows() < 1) {
522 this.get('/LeftPanel.model').load( false);
523 this.get('/MidPropTree').activeElement = false;
524 this.get('/MidPropTree').hideWin();
526 var pm = this.get('/RightPalete.model');
527 if (!this.get('/LeftTree').getPaleteProvider()) {
528 // it may not be loaded yet..
531 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
532 this.get('/LeftTree.model').listAllTypes()));
537 //console.log('changed');
538 var s = this.selection;
539 s.get_selected(this.get('/LeftTree.model').el, iter);
543 value = new GObject.Value('');
544 this.get('/LeftTree.model').el.get_value(iter, 2, value);
545 this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
547 var data = JSON.parse(value.value);
548 this.get('/MidPropTree').activeElement = data;
549 this.get('/MidPropTree').hideWin();
550 this.get('/LeftPanel.model').load( data);
552 console.log(value.value);
553 // _g.button.set_label(''+value.get_string());
555 var pm =this.get('/RightPalete.model');
556 pm.load( this.get('/RightPalete').provider.gatherList(
557 this.get('/LeftTree.model').listAllTypes()));
562 //Seed.print( value.get_string());
569 xtype: Gtk.TreeStore,
573 XObject.prototype.init.call(this);
574 this.el.set_column_types ( 3, [
575 GObject.TYPE_STRING, // title
576 GObject.TYPE_STRING, // tip
577 GObject.TYPE_STRING // source..
581 changed : function(n, refresh) {
582 print("MODEL CHANGED CALLED" + this.activePath);
583 if (this.activePath) {
584 var iter = new Gtk.TreeIter();
585 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
586 this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
587 this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
589 this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
591 //this.currentTree = this.toJS(false, true)[0];
592 this.file.items = this.toJS(false, false);
593 print("AFTER CHANGED");
594 //console.dump(this.file.items);
596 this.currentTree = this.file.items[0];
597 //console.log(this.file.toSource());
600 print("REDNER BROWSER?!");
601 this.get('/LeftTree').renderView();
603 var pm = this.get('/RightPalete.model');
604 if (!this.get('/RightPalete').provider) {
610 pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
611 //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
615 loadFile : function(f) {
621 console.log('missing file');
625 // load the file if not loaded..
626 if (f.items === false) {
628 f.loadItems(function() {
634 if (f.items.length && typeof(f.items[0]) == 'string') {
636 this.get('/RightEditor').el.show();
637 this.get('/RightEditor.view').load( f.items[0]);
641 //console.dump(f.items);
643 this.get('/LeftTree.view').el.expand_all();
645 if (!f.items.length) {
648 this.get('/Window.leftvpaned').el.set_position(80);
650 this.get('/LeftTree.view').el.set_cursor(
651 new Gtk.TreePath.from_string('0'), null, false);
655 this.get('/Window.leftvpaned').el.set_position(200);
659 //print("hide right editior");
660 this.get('/RightEditor').el.hide();
661 //print("set current tree");
662 this.currentTree = this.toJS(false, false)[0];
663 //console.dump(this.currentTree);
664 this.currentTree = this.currentTree || { items: [] };
665 this.get('/LeftTree').renderView();
666 //console.dump(this.map);
667 //var RightPalete = imports.Builder.RightPalete.RightPalete;
668 var pm = this.get('/RightPalete.model');
671 this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
673 if (!this.get('/RightPalete').provider) {
674 print ("********* PALETE PROVIDER MISSING?!!");
676 this.get('/LeftTree').renderView();
678 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
682 this.get('/Window.view-notebook').el.set_current_page(
683 this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
686 findDropNode : function(treepath_str, targets) {
688 // this is used by the dragdrop code in the roo version AFAIR..
690 var path = treepath_str.replace(/^builder-/, '');
691 // treemap is depreciated... - should really check if model has any entries..
693 if (!this.el.iter_n_children(null)) {
695 return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];
697 print("FIND treepath: " + path);
698 //console.dump(this.treemap);
700 if (!treepath_str.match(/^builder-/)) {
701 return []; // nothing!
703 if (targets === true) {
706 return this.findDropNodeByPath(path,targets)
708 findDropNodeByPath : function(treepath_str, targets, pref) {
709 var path = treepath_str + ''; // dupe it..
710 pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
712 //console.dump(this.treemap);
713 while (path.length) {
714 print("LOOKING FOR PATH: " + path);
715 var node_data = this.singleNodeToJS(path);
716 if (node_data === false) {
717 print("node not found");
721 var xname = this.get('/LeftTree.model').file.guessName(node_data);
724 targets.forEach(function(tg) {
728 if ((tg == xname) ) {
731 if (tg.indexOf(xname +':') === 0) {
733 prop = tg.split(':').pop();
738 if (last) { // pref is after/before..
739 // then it's after last
741 return []; // do not allow..
743 return [ last, pref , prop];
746 return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
748 var par = path.split(':');
751 path = par.join(':');
757 dropNode : function(target_data, node) {
760 console.dump(target_data);
761 var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
763 print("add " + tp + "@" + target_data[1] );
766 if (tp && target_data[1] < 2) { // before or after..
767 var ar = target_data[0].split(':');
769 parent = new Gtk.TreePath.from_string( ar.join(':') );
772 var n_iter = new Gtk.TreeIter();
773 var iter_par = new Gtk.TreeIter();
774 var iter_after = after ? new Gtk.TreeIter() : false;
778 if (parent !== false) {
779 this.el.get_iter(iter_par, parent);
786 print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
787 this.el.get_iter(iter_after, after);
788 this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
789 n_iter, iter_par, iter_after);
792 this.el.append(n_iter, iter_par);
796 if (typeof(node) == 'string') {
797 var ar = node.split('.');
798 var xtype = ar.pop();
801 '|xns' : ar.join('.'),
804 if (target_data.length == 3 && target_data[2].length) {
805 node['*prop'] = target_data[2];
809 // work out what kind of packing to use..
810 if (typeof(node.pack) == 'undefined' && parent !== false) {
811 var pal = this.get('/LeftTree').getPaleteProvider();
813 var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
814 print ("PNAME : " + pname);
815 var cname = pal.guessName(node);
816 print ("CNAME : " + cname);
817 node.pack = pal.getDefaultPack(pname, cname);
828 // load children - if it has any..
831 this.load(xitems, n_iter);
833 if (tp && (xitems || after)) {
834 this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
836 // wee need to get the empty proptypes from somewhere..
838 //var olditer = this.activeIter;
839 this.activePath = this.el.get_path(n_iter).to_string();
841 // changed actually set's the node data..
842 this.changed(node, true);
846 this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
848 //Builder.MidPropTree._model.load(node);
849 //Builder.MidPropTree._win.hideWin();
850 //Builder.LeftPanel._model.load( node);
854 moveNode : function(target_data, action) {
855 //print("MOVE NODE");
856 // console.dump(target_data);
857 var old_iter = new Gtk.TreeIter();
858 var s = this.get('/LeftTree.view').selection;
859 s.get_selected(this.el, old_iter);
860 var node = this.nodeToJS(old_iter,false);
861 //console.dump(node);
864 // needs to drop first, otherwise the target_data
865 // treepath will be invalid.
867 this.dropNode(target_data, node);
868 if (action & Gdk.DragAction.MOVE) {
869 // print("REMOVING OLD NODE");
870 this.el.remove(old_iter);
874 this.activeIter = false;
875 this.changed(false,true);
877 deleteSelected : function() {
879 var old_iter = new Gtk.TreeIter();
880 var s = this.get('/LeftTree.view').selection;
881 s.get_selected(this.el, old_iter);
884 this.el.remove(old_iter);
886 // rebuild treemap. -- depreciated.!!
889 //this.toJS(null, true) // does not do anything?
890 this.activeIter = false;
891 this.changed(false,true);
894 listAllTypes : function() {
895 var s = this.get('/LeftTree.view').selection;
896 print ("LIST ALL TYPES: " + s.count_selected_rows() );
898 if (s.count_selected_rows() > 0) {
899 var iter = new Gtk.TreeIter();
900 s.get_selected(this.el, iter);
902 // set some properties of the tree for use by the dropped element.
903 var value = new GObject.Value('');
904 this.el.get_value(iter, 2, value);
905 var data = JSON.parse(value.value);
908 var xname = this.get('/LeftTree.model').file.guessName(data);
909 console.log('selected:' + xname);
913 return []; // could not find it..
921 li.forEach(function(el) {
922 // this is specific to roo!!!?
924 var fullpath = _this.file.guessName(el);
925 if (fullpath.length && ret.indexOf(fullpath) < 0) {
930 if (el.items && el.items.length) {
939 addall([this.currentTree]);
941 // only if we have nothing, should we add '*top'
945 //console.log('all types in tree');
951 singleNodeToJS : function (treepath)
953 var iter = new Gtk.TreeIter();
954 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
958 var iv = this.getIterValue(iter, 2);
960 return JSON.parse(iv);
963 nodeToJS : function (iter, with_id)
965 var par = new Gtk.TreeIter();
966 var iv = this.getIterValue(iter, 2);
968 var k = JSON.parse(iv);
969 if (k.json && !this.el.iter_parent( par, iter )) {
974 var treepath_str = this.el.get_path(iter).to_string();
975 // not sure how we can handle mixed id stuff..
976 if (typeof(k.id) == 'undefined') {
977 k.id = 'builder-'+ treepath_str ;
981 this.treemap[ treepath_str ] = k;
982 k.xtreepath = treepath_str ;
985 if (this.el.iter_has_child(iter)) {
986 citer = new Gtk.TreeIter();
987 this.el.iter_children(citer, iter);
988 k.items = this.toJS(citer,with_id);
992 toJS : function(iter, with_id)
994 //Seed.print("WITHID: "+ with_id);
1001 iter = new Gtk.TreeIter();
1002 if (!this.el.get_iter_first(iter)) {
1012 var k = this.nodeToJS(iter, with_id);
1016 if (!this.el.iter_next(iter)) {
1022 // convert the list into a json string..
1026 getIterValue : function (iter, col) {
1027 var gval = new GObject.Value('');
1028 this.el.get_value(iter, col ,gval);
1033 nodeTitle : function(c) {
1036 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
1037 if (sr) txt.push('<s>');
1038 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
1039 if (c.xtype) { txt.push(c.xtype); }
1040 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1041 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1042 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1045 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1046 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1047 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1048 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1049 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1050 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1051 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1052 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1053 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1055 // for flat classes...
1056 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1057 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1060 if (sr) txt.push('</s>');
1061 return (txt.length == 0 ? "Element" : txt.join(" "));
1063 nodeToJSON : function(c) {
1071 return JSON.stringify(o);
1073 load : function(tr,iter)
1075 var citer = new Gtk.TreeIter();
1076 //this.insert(citer,iter,0);
1077 for(var i =0 ; i < tr.length; i++) {
1079 this.el.insert(citer,iter,-1);
1081 this.el.append(citer);
1084 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1085 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1086 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1087 if (tr[i].items && tr[i].items.length) {
1088 this.load(tr[i].items, citer);
1094 xtype: Gtk.TreeViewColumn,
1095 pack : "append_column",
1097 XObject.prototype.init.call(this);
1098 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1102 xtype: Gtk.CellRendererText,
1112 id : "LeftTreeMenu",
1115 xtype: Gtk.MenuItem,
1117 label : "Delete Element",
1119 "activate":function (self) {
1121 this.get('/LeftTree.model').deleteSelected();
1132 id : "LeftProjectTree",
1133 showNoProjectSelected : function() {
1134 this.get('/StandardErrorDialog').show("Select a Project first.");
1136 getActiveProject : function() {
1137 return this.project;
1140 "leave_notify_event":function (self, event) {
1147 pack : "pack_start,false,false",
1150 xtype: Gtk.ComboBox,
1153 XObject.prototype.init.call(this);
1154 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1156 getValue : function() {
1157 var ix = this.el.get_active();
1161 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1164 setValue : function(fn)
1168 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1169 data.forEach(function(n, ix) {
1177 "changed":function (self) {
1178 var fn = this.getValue();
1179 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1180 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1185 xtype: Gtk.CellRendererText,
1186 pack : "pack_start,true",
1190 xtype: Gtk.ListStore,
1193 XObject.prototype.init.call(this);
1194 this.el.set_column_types ( 2, [
1195 GObject.TYPE_STRING, // real key
1196 GObject.TYPE_STRING // real type
1202 loadData : function(data) {
1203 var ov = this.get('/LeftProjectTree.combo').getValue();
1205 var iter = new Gtk.TreeIter();
1207 data.forEach(function(p) {
1212 el.set_value(iter, 0, p.fn);
1213 el.set_value(iter, 1, p.name);
1217 this.get('/LeftProjectTree.combo').setValue(ov);
1226 xtype: Gtk.ScrolledWindow,
1228 shadow_type : Gtk.ShadowType.IN,
1230 XObject.prototype.init.call(this);
1231 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1235 xtype: Gtk.TreeView,
1236 headers_visible : false,
1237 enable_tree_lines : true,
1240 XObject.prototype.init.call(this);
1241 var description = new Pango.FontDescription.c_new();
1242 description.set_size(8000);
1243 this.el.modify_font(description);
1245 this.selection = this.el.get_selection();
1246 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1250 "cursor_changed":function (self) {
1251 var iter = new Gtk.TreeIter();
1253 if (this.selection.count_selected_rows() < 1) {
1254 //XN.get('Builder.LeftTree.model').
1255 this.get('/LeftTree.model').load( false);
1259 var model = this.get('/LeftProjectTree.model');
1260 //console.log('changed');
1261 var s = this.selection;
1262 s.get_selected(model, iter);
1263 value = new GObject.Value('');
1264 model.el.get_value(iter, 2, value);
1266 console.log(value.value);// id..
1268 var file = this.get('/LeftProjectTree').project.getById(value.value);
1275 var nb = this.get('/LeftTopPanel.expander');
1276 nb.el.expanded = false;
1277 nb.listeners.activate.call(nb);
1278 //_expander.el.set_expanded(false);
1280 var ltm = this.get('/LeftTree.model');
1288 xtype: Gtk.TreeStore,
1292 XObject.prototype.init.call(this);
1293 this.el.set_column_types ( 3, [
1294 GObject.TYPE_STRING, // title
1295 GObject.TYPE_STRING, // tip
1296 GObject.TYPE_STRING // id..
1300 loadProject : function(pr) {
1305 this.get('/LeftProjectTree').project = pr;
1306 this.load(pr.toTree());
1307 this.get('/LeftProjectTree.view').el.expand_all();
1309 load : function(tr,iter) {
1311 console.log('Project tree load: ' + tr.length);
1312 var citer = new Gtk.TreeIter();
1313 //this.insert(citer,iter,0);
1316 tr.forEach(function (r) {
1318 _this.el.append(citer);
1320 _this.el.insert(citer,iter,-1);
1322 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1323 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1324 _this.el.set_value(citer, 2, '' + r.id ); //id
1325 if (r.cn && r.cn.length) {
1326 _this.load(r.cn, citer);
1331 getValue : function(iter, col) {
1332 var gval = new GObject.Value('');
1333 this.el.get_value(iter, col ,gval);
1334 return '' + gval.value;
1338 xtype: Gtk.TreeViewColumn,
1339 pack : "append_column",
1341 XObject.prototype.init.call(this);
1342 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1346 xtype: Gtk.CellRendererText,
1369 pack : "pack_start,false,true,0",
1376 "button_press_event":function (self, event) {
1377 this.get('/MidPropTree.model').showData('props');
1389 stock : Gtk.STOCK_ADD,
1390 icon_size : Gtk.IconSize.MENU
1405 "button_press_event":function (self, event) {
1406 this.get('/MidPropTree.model').showData('events');
1418 stock : Gtk.STOCK_ADD,
1419 icon_size : Gtk.IconSize.MENU
1434 "button_press_event":function (self, ev) {
1435 var p = this.get('/AddPropertyPopup');
1439 p.el.set_screen(Gdk.Screen.get_default());
1441 p.el.popup(null, null, null, null, 3, ev.button.time);
1453 stock : Gtk.STOCK_ADD,
1454 icon_size : Gtk.IconSize.MENU
1466 id : "AddPropertyPopup",
1469 xtype: Gtk.MenuItem,
1471 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1474 "activate":function (self) {
1476 this.get('/LeftPanel.model').add( {
1487 xtype: Gtk.MenuItem,
1489 tooltip_markup : "Add what type of packing is to be used",
1492 "activate":function (self) {
1494 this.get('/LeftPanel.model').add( {
1504 xtype: Gtk.MenuItem,
1506 tooltip_markup : "Override the init method",
1509 "activate":function (self) {
1511 this.get('/LeftPanel.model').add( {
1514 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1521 xtype: Gtk.SeparatorMenuItem,
1525 xtype: Gtk.MenuItem,
1527 tooltip_markup : "Add a user defined string property",
1530 "activate":function (self) {
1532 this.get('/LeftPanel.model').add( {
1542 xtype: Gtk.MenuItem,
1544 tooltip_markup : "Add a user defined number property",
1547 "activate":function (self) {
1549 this.get('/LeftPanel.model').add( {
1559 xtype: Gtk.MenuItem,
1561 tooltip_markup : "Add a user defined boolean property",
1564 "activate":function (self) {
1566 this.get('/LeftPanel.model').add( {
1576 xtype: Gtk.SeparatorMenuItem,
1580 xtype: Gtk.MenuItem,
1582 tooltip_markup : "Add a user function boolean property",
1585 "activate":function (self) {
1587 this.get('/LeftPanel.model').add( {
1590 val : "function() {\n \n}\n",
1603 xtype: Gtk.ScrolledWindow,
1606 shadow_type : Gtk.ShadowType.IN,
1609 XObject.prototype.init.call(this);
1610 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1614 xtype: Gtk.TreeView,
1617 headers_visible : false,
1618 enable_tree_lines : true,
1620 XObject.prototype.init.call(this);
1622 this.selection = this.el.get_selection();
1623 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1626 var description = new Pango.FontDescription.c_new();
1627 description.set_size(8000);
1628 this.el.modify_font(description);
1631 "button_press_event":function (self, ev) {
1635 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1636 return false; //not on a element.
1640 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1642 if (res.column.title != 'value') {
1643 return false; // ignore..
1645 if ( this.get('/LeftPanel').editing) {
1648 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1649 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1650 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1654 var provider = this.get('/LeftTree').getPaleteProvider();
1656 var opts = provider.findOptions(type);
1658 if (opts === false) {
1659 this.get('/LeftPanel').editableColumn.setOptions([]);
1660 renderer.has_entry = true;
1662 LeftPanel.editableColumn.setOptions(opts);
1663 renderer.has_entry = false;
1667 //Seed.print("click" + ev.type);
1668 //console.dump(res);
1674 if (res.column.title == 'value') {
1677 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1678 var p = this.get('/LeftPanelPopup');
1683 p.el.set_screen(Gdk.Screen.get_default());
1685 p.el.popup(null, null, null, null, 3, ev.button.time);
1686 //Seed.print("click:" + res.column.title);
1694 xtype: Gtk.TreeStore,
1698 XObject.prototype.init.call(this);
1699 this.el.set_column_types ( 5, [
1700 GObject.TYPE_STRING, // 0 real key
1701 GObject.TYPE_STRING, // 1 real value
1702 GObject.TYPE_STRING, // 2 visable key
1703 GObject.TYPE_STRING, // 3 visable value
1704 GObject.TYPE_STRING, // 4 need to store type of!!!
1708 toShort : function(str) {
1709 var a = typeof(str) == 'string' ? str.split("\n") : [];
1710 return a.length > 1 ? a[0] + '....' : '' + str;
1712 load : function(ar) {
1715 this.get('/RightEditor').el.hide();
1722 var provider = this.get('/LeftTree').getPaleteProvider();
1725 var iter = new Gtk.TreeIter();
1727 if (typeof(ar[i]) == 'object') {
1731 var type = provider.findType(ar, i, ar[i]);
1733 this.el.append(iter);
1734 var p = this.el.get_path(iter).to_string();
1736 this.el.set_value(iter, 0, i);
1737 this.el.set_value(iter, 1, '' + ar[i]);
1738 this.el.set_value(iter, 2, i);
1739 this.el.set_value(iter, 3, this.toShort(ar[i]));
1740 this.el.set_value(iter, 4, type);
1742 ar.listeners = ar.listeners || {};
1743 for (var i in ar.listeners ) {
1744 this.el.append(iter);
1745 var p = this.el.get_path(iter).to_string();
1748 this.el.set_value(iter, 0, '!'+ i );
1749 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1750 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1752 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1753 this.el.set_value(iter, 4, 'function');
1757 add : function(info) {
1758 // info includes key, val, skel, etype..
1760 type = info.type.toLowerCase();
1761 var data = this.toJS();
1763 if (info.etype == 'events') {
1764 data.listeners = data.listeners || { };
1765 if (typeof(data.listeners[info.key]) != 'undefined') {
1766 return; //already set!
1769 if (typeof(data[info.key]) != 'undefined') {
1774 if (typeof(info.val) == 'undefined') {
1777 if (info.type == 'boolean') {
1780 if (type == 'number') {
1788 if (info.etype == 'events') {
1790 data.listeners[info.key] = info.val;
1793 data[info.key] = info.val;
1797 var map = this.load(data);
1799 // flag it as changed to the interface..
1801 this.get('/LeftTree.model').changed(data, true);
1804 this.startEditing(map[k]);
1807 LeftPanel.get('view').el.row_activated(
1808 new Gtk.TreePath.from_string(map[k]),
1809 LeftPanel.editableColumn.el
1813 startEditing : function(path,col) {
1815 * start editing path (or selected if not set..)
1816 * @param {String|false} path (optional) treepath to edit - selected tree gets
1817 * edited by default.
1818 * @param {Number} 0 or 1 (optional)- column to edit.
1821 if (typeof(path) == 'string') {
1822 tp = new Gtk.TreePath.from_string(path);
1824 var iter = new Gtk.TreeIter();
1825 var s = this.get('/LeftPanel.view').selection;
1826 s.get_selected(this.el, iter);
1827 tp = this.el.get_path(iter);
1828 path = tp.to_string();
1832 // which colum is to be edited..
1834 if (typeof(col) == 'undefined') {
1835 var k = this.getValue(path, 0);
1836 colObj = (!k.length || k == '|') ?
1837 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1839 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1842 // make sure the pulldown is set correctly..
1843 // not really needed for second col...
1845 var provider = this.get('/LeftTree').getPaleteProvider();
1847 var type = this.get('/LeftPanel.model').getType(path);
1848 var opts = provider.findOptions(type);
1849 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1851 if (opts === false) {
1852 this.get('/LeftPanel').editableColumn.setOptions([]);
1853 renderer.has_entry = true; /// probably does not have any effect.
1855 this.get('/LeftPanel').editableColumn.setOptions(opts);
1856 renderer.has_entry = false;
1860 // iter now has row...
1861 GLib.timeout_add(0, 100, function() {
1863 colObj.items[0].el.editable = true; // esp. need for col 0..
1864 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1873 deleteSelected : function() {
1874 var data = this.toJS();
1875 var iter = new Gtk.TreeIter();
1876 var s = this.get('/LeftPanel.view').selection;
1877 s.get_selected(this.el, iter);
1880 var gval = new GObject.Value('');
1881 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1883 var val = gval.value;
1884 if (val[0] == '!') {
1886 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1889 delete data.listeners[ val.substring(1)];
1890 if (!XObject.keys(data.listeners).length) {
1891 delete data.listeners;
1895 if (typeof(data[val]) == 'undefined') {
1903 this.get('/LeftTree.model').changed(data, true);
1907 changed : function(str, doRefresh) {
1908 if (!this.activePath) {
1911 var iter = new Gtk.TreeIter();
1912 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1914 this.el.set_value(iter, 1, '' +str);
1915 this.el.set_value(iter, 3, '' + this.toShort(str));
1916 // update the tree...
1918 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
1921 var iter = new Gtk.TreeIter();
1922 this.get('/LeftPanel.model').el.get_iter_first(iter);
1927 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
1930 ar.listeners = ar.listeners || {};
1931 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
1934 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
1937 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
1943 //print(JSON.stringify(ar));
1947 getType : function(treepath) {
1948 return this.getValue(treepath, 4);
1950 getValue : function(treepath_str, col) {
1951 var iter = new Gtk.TreeIter();
1952 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
1954 var gval = new GObject.Value('');
1955 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
1956 var val = '' + gval.value;
1960 var type = this.getType(this.el.get_path(iter).to_string());
1961 //print("TYPE: " +type + " - val:" + val);
1962 switch(type.toLowerCase()) {
1966 return parseFloat(val); // Nan ?? invalid!!?
1968 return val == 'true' ? true : false;
1974 editSelected : function(e) {
1975 print("EDIT SELECTED?");
1976 var iter = new Gtk.TreeIter();
1977 var s = this.get('/LeftPanel.view').selection;
1978 s.get_selected(this.get('/LeftPanel.model').el, iter);
1979 var m = this.get('/LeftPanel.model')
1981 var gval = new GObject.Value('');
1982 this.el.get_value(iter, 0 ,gval);
1983 var val = '' + gval.value;
1985 gval = new GObject.Value('');
1986 this.el.get_value(iter, 1 ,gval);
1987 var rval = gval.value;
1988 var activePath = this.el.get_path(iter).to_string();
1989 this.activePath = activePath ;
1990 // was activeIter...
1993 var showEditor = false;
1995 if (val[0] == '!') {
1998 if (val[0] == '|') {
1999 if (rval.match(/function/g) || rval.match(/\n/g)) {
2006 this.activePath = false;
2007 GLib.timeout_add(0, 1, function() {
2008 // Gdk.threads_enter();
2009 _this.get('/RightEditor').el.show();
2010 _this.get('/RightEditor.view').load( rval );
2014 _this.activePath = activePath ;
2016 // Gdk.threads_leave();
2022 this.get('/RightEditor').el.hide();
2024 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2030 xtype: Gtk.TreeViewColumn,
2031 pack : "append_column",
2033 XObject.prototype.init.call(this);
2035 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2036 this.get('/LeftPanel').propertyColumn = this;
2041 xtype: Gtk.CellRendererText,
2042 pack : "pack_start",
2044 "editing_started":function (self, editable, path) {
2046 this.get('/LeftPanel.model').activePath = path;
2049 "edited":function (self, object, p0) {
2050 var model = this.get('/LeftPanel.model');
2051 var path = model.activePath;
2052 var iter = new Gtk.TreeIter();
2053 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2054 model.el.set_value(iter, 0, p0);
2055 model.el.set_value(iter, 2, p0);
2057 model.activePath = false;
2059 this.get('/LeftTree.model').changed(model.toJS(), true);
2060 this.el.editable = false;
2067 xtype: Gtk.TreeViewColumn,
2068 pack : "append_column",
2070 XObject.prototype.init.call(this);
2071 this.el.add_attribute(this.items[0].el , 'text', 3 );
2072 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2073 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2074 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2076 this.get('/LeftPanel').editableColumn= this;
2078 setOptions : function(ar) {
2079 var m = this.items[0].el.model;
2081 var iter = new Gtk.TreeIter();
2082 ar.forEach(function(i) {
2085 m.set_value(iter, 0, i);
2091 xtype: Gtk.CellRendererCombo,
2092 pack : "pack_start",
2097 XObject.prototype.init.call(this);
2098 this.el.model = new Gtk.ListStore();
2099 this.el.model.set_column_types ( 1, [
2100 GObject.TYPE_STRING // 0 real key
2104 "edited":function (self, object, p0) {
2105 this.get('/LeftPanel').editing = false;
2106 print("EDITED? p:" + p0 + " t:" + p0);
2107 this.get('/LeftPanel.model').changed(p0, true);
2108 this.get('/LeftPanel.model').activePath = false;
2110 "editing_started":function (self, editable, path) {
2111 this.get('/LeftPanel').editing = true;
2112 // console.log('editing started');
2113 // r.has_entry = false;
2114 this.get('/LeftPanel.model').editSelected(editable);
2125 id : "LeftPanelPopup",
2128 xtype: Gtk.MenuItem,
2132 "activate":function (self) {
2133 this.get('/LeftPanel.model').deleteSelected();
2138 xtype: Gtk.MenuItem,
2142 "activate":function (self) {
2143 this.get('/LeftPanel.model').startEditing(false, 0);
2156 xtype: Gtk.ScrolledWindow,
2157 pack : "pack_end,false,true,0",
2159 shadow_type : Gtk.ShadowType.IN,
2161 XObject.prototype.init.call(this);
2162 XObject.prototype.init.call(this);
2163 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2164 this.el.set_size_request ( 150, -1 );
2167 activeElement : false,
2168 hideWin : function() {
2175 if (this.get('/Window.left').el.position < 160) {
2178 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2185 xtype: Gtk.TreeView,
2186 enable_tree_lines : true,
2187 headers_visible : false,
2190 XObject.prototype.init.call(this);
2192 var description = new Pango.FontDescription.c_new();
2193 description.set_size(8000);
2194 this.el.modify_font(description);
2196 //this.selection = this.el.get_selection();
2197 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2206 "cursor_changed":function (self) {
2207 var iter = new Gtk.TreeIter();
2209 //console.log('changed');
2210 var m = this.get('model');
2211 if (!this.selection){
2212 this.selection = this.el.get_selection();
2215 var s = this.selection;
2216 if (!s.get_selected(m.el, iter)) {
2219 var tp = m.el.get_path(iter).to_string();
2224 var key = m.getValue(tp, 0);
2226 var type = m.getValue(tp, 1);
2227 var skel = m.getValue(tp, 3);
2228 var etype = m.getValue(tp, 5);
2231 this.get('/MidPropTree').hideWin();
2233 if (type == 'function') {
2235 if (etype != 'events') {
2239 this.get('/LeftPanel.model').add({
2248 if (type.indexOf('.') > -1 ||
2249 type == 'boolean') {
2253 this.get('/LeftPanel.model').add( {
2263 xtype: Gtk.ListStore,
2266 XObject.prototype.init.call(this);
2267 this.el.set_column_types ( 6, [
2268 GObject.TYPE_STRING, // real key
2269 GObject.TYPE_STRING, // real type
2270 GObject.TYPE_STRING, // docs ?
2271 GObject.TYPE_STRING, // visable desc
2272 GObject.TYPE_STRING, // function desc
2273 GObject.TYPE_STRING // element type (event|prop)
2277 getValue : function(treepath, col)
2279 var tp = new Gtk.TreePath.from_string (treepath);
2280 var iter = new Gtk.TreeIter();
2281 this.el.get_iter (iter, tp);
2282 var value = new GObject.Value('');
2283 this.el.get_value(iter, col, value);
2287 showData : function(type) {
2289 if (!this.get('/MidPropTree').activeElement || !type) {
2290 return; // no active element
2293 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2294 var palete = this.get('/LeftTree').getPaleteProvider();
2298 Seed.print('Showing right?');
2299 if (!this.get('/MidPropTree').shown) {
2301 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2302 this.get('/MidPropTree').el.show();
2303 this.get('/MidPropTree').shown = true;
2306 var elementList = palete.getPropertiesFor(fullpath, type);
2307 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2308 // console.dump(elementList);
2311 var iter = new Gtk.TreeIter();
2312 for(var i =0 ; i < elementList.length; i++) {
2313 var p=elementList[i];
2314 this.el.append(iter);
2315 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2316 //GObject.TYPE_STRING, // real key
2317 // GObject.TYPE_STRING, // real type
2318 // GObject.TYPE_STRING, // docs ?
2319 // GObject.TYPE_STRING // func def?
2322 this.el.set_value(iter, 0, p.name);
2323 this.el.set_value(iter, 1, p.type);
2324 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2325 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2326 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2327 this.el.set_value(iter, 5, type);
2335 xtype: Gtk.TreeViewColumn,
2337 this.el = new Gtk.TreeViewColumn();
2338 this.parent.el.append_column(this.el);
2340 XObject.prototype.init.call(this);
2341 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2346 xtype: Gtk.CellRendererText,
2347 pack : "pack_start,true"
2371 xtype: Gtk.Notebook,
2372 pack : "pack_start,true,true",
2373 id : "view-notebook",
2376 XObject.prototype.init.call(this);
2377 this.el.set_current_page(0);
2379 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2380 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2387 id : "RightBrowser",
2391 pack : "pack_start,false,true,0",
2395 pack : "pack_start,false,false,0",
2396 label : "Dump HTML to console",
2398 "activate":function (self) {
2399 this.get('/RightBrowser.view').el.execute_script(
2400 "console.log(document.body.innerHTML);");
2401 this.get('/RightBrowser.view').el.execute_script(
2402 "console.log(Builder.dump(Builder));");
2409 xtype: Gtk.ScrolledWindow,
2411 shadow_type : Gtk.ShadowType.IN,
2413 XObject.prototype.init.call(this);
2414 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2418 xtype: WebKit.WebView,
2422 XObject.prototype.init.call(this);
2423 // this may not work!?
2424 this.el.open('file:///' + __script_path__ + '/../builder.html');
2428 this.el, /* widget that will accept a drop */
2429 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2430 null, /* lists of target to support */
2431 0, /* size of list */
2432 Gdk.DragAction.COPY /* what to do with data after dropped */
2435 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2436 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2438 renderJS : function(data) {
2439 this.renderedData = data;
2440 var str = JSON.stringify(data) ;
2443 console.log('not loaded yet');
2445 Seed.print("RENDER:" + str);
2446 imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2447 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2450 "load_finished":function (self, object) {
2451 if (this.ready) { // dont do it twice!
2456 this.renderJS(this.get('/LeftTree.model').toJS()[0]);
2458 "script_alert":function (self, object, p0) {
2461 return true; // do not display anything...
2463 "console_message":function (self, object, p0, p1) {
2464 console.log(object);
2465 if (!object.match(/^\{/)) {
2466 return false; // do not handle!!! -> later maybe in console..
2468 console.log(object);
2469 var val = JSON.parse(object);
2471 if (typeof(val['hover-node']) != 'undefined') {
2472 this.activeNode = val['hover-node'];
2473 console.log('active node: ' + this.activeNode);
2478 if (typeof(val['id']) != 'undefined') {
2479 // this.activeNode = val['id'];
2480 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2484 this.get('/LeftTree.view').selectNode(tg[0]);
2488 if (ret && typeof(val['set']) != 'undefined') {
2489 this.get('/LeftPanel.model').add({
2493 //console.log('active node: ' + this.activeNode);
2496 //Seed.print('a:'+a);
2497 //Seed.print('b:'+b);
2498 //Seed.print('c:'+c);
2501 "drag_motion":function (w, ctx, x, y, time, ud) {
2502 // console.log('DRAG MOTION');
2504 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2505 this.targetData = [];
2506 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2508 // A) find out from drag all the places that node could be dropped.
2509 var src = Gtk.drag_get_source_widget(ctx);
2510 if (!src.dropList) {
2511 Gdk.drag_status(ctx, 0, time);
2514 // b) get what we are over.. (from activeNode)
2515 // tree is empty.. - list should be correct..
2516 if (!this.get('/LeftTree.model').currentTree) {
2517 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2521 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2523 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2526 Gdk.drag_status(ctx, 0,time);
2527 this.get('/LeftTree.view').highlight(false);
2531 // if we have a target..
2532 // -> highlight it! (in browser)
2533 // -> highlight it! (in tree)
2535 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2536 this.get('/LeftTree.view').highlight(tg);
2537 this.targetData = tg;
2538 // for tree we should handle this...
2541 "drag_drop":function (w, ctx, x, y,time, ud) {
2542 print("TARGET: drag-drop");
2543 var is_valid_drop_site = true;
2548 w, /* will receive 'drag-data-received' signal */
2549 ctx, /* represents the current state of the DnD */
2550 this.get('/Window').atoms["STRING"], /* the target type we want */
2551 time /* time stamp */
2555 /* No target offered by source => error */
2558 return is_valid_drop_site;
2560 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2562 print("Browser: drag-data-received");
2563 var delete_selection_data = false;
2564 vardnd_success = false;
2565 /* Deal with what we are given from source */
2566 if( sel_data && sel_data.length ) {
2568 if (ctx.action == Gdk.DragAction.ASK) {
2569 /* Ask the user to move or copy, then set the ctx action. */
2572 if (ctx.action == Gdk.DragAction.MOVE) {
2573 delete_selection_data = true;
2575 var source = Gtk.drag_get_source_widget(ctx);
2577 print("Browser: source.DRAGDATA? " + source.dragData);
2578 if (this.targetData) {
2579 print(this.targetData);
2580 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2589 if (dnd_success == false)
2591 Seed.print ("DnD data transfer failed!\n");
2594 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2606 id : "RightGtkView",
2607 renderJS : function(data, withDebug)
2612 this.withDebug = false;
2614 if (this.renderedEl) {
2615 this.get('view').el.remove(this.renderedEl);
2616 this.renderedEl.destroy();
2617 this.renderedEl = false;
2620 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2621 // in theory tree is actually window..
2623 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2628 this.get('view').el.set_size_request(
2629 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2632 this.renderedEl.set_size_request(
2633 tree.default_width || 600,
2634 tree.default_height || 400
2636 this.get('view').el.show_all();
2641 showInWindow : function() {
2642 print("GET PROEJCT");
2643 var pr = this.get('/LeftProjectTree').getActiveProject();
2645 console.log(pr.paths);
2648 var src= this.buildJS(
2649 this.get('/LeftTree.model').toJS()[0],
2654 //var x = new imports.sandbox.Context();
2658 Seed.check_syntax('var e = ' + src);
2661 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2662 this.get('/Terminal').feed(console._dump(e)+"\n");
2664 var lines = src.split("\n");
2665 var start = Math.max(0, e.line - 10);
2666 var end = Math.min(lines.length, e.line + 10);
2667 for (var i =start ; i < end; i++) {
2669 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2672 this.get('/Terminal').feed(lines[i] + "\n");
2679 this.get('/BottomPane').el.set_current_page(1);
2680 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2681 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2682 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2684 var _top = x.get_global_object()._top;
2686 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2688 if (_top.el.popup) {
2689 _top.el.popup(null, null, null, null, 3, null);
2693 viewAdd : function(item, par)
2695 // does something similar to xobject..
2696 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2698 if (item.pack===false || item.pack === 'false') { // no ;
2701 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2702 var ns = imports.gi[item['|xns']];
2703 var ctr = ns[item['xtype']];
2705 for(var k in item) {
2707 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2722 if (k[0] == '|' && typeof(kv) == 'string') {
2724 if (kv.match(new RegExp('function'))) {
2727 print("WASL " + k + '=' + kv);
2729 eval( 'kv = ' + kv);
2730 } catch(e) { continue; }
2733 print(k + '=' + kv);
2735 if (k[0] == '|') { // should be boolean or number..
2738 if (k == 'show_tabs') { // force tab showing for notebooks.
2746 var el = new ctr(ctr_args);
2749 //console.dump(item.pack);
2756 if (typeof(item.pack) == 'string') {
2758 item.pack.split(',').forEach(function(e, i) {
2760 if (e == 'false') { args.push( false); return; }
2761 if (e == 'true') { args.push( true); return; }
2762 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2765 //print(args.join(","));
2767 pack_m = args.shift();
2769 pack_m = item.pack.shift();
2774 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2776 name: "ArgumentError",
2777 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2778 "ADDING : " + item.id + " " + el
2787 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2788 //Seed.print('args: ' + args.length);
2790 par[pack_m].apply(par, args);
2794 item.items = item.items || [];
2795 item.items.forEach(function(ch) {
2796 _this.viewAdd(ch, el);
2801 // add the signal handlers.
2802 // is it a widget!?!!?
2808 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2809 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2810 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2811 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2812 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2822 widgetExposeEvent : function() {
2823 /// print("WIDGET EXPOSE"); // draw highlight??
2826 widgetDragMotionEvent : function() {
2827 print("WIDGET DRAGMOTION");
2830 widgetDragDropEvent : function() {
2831 print("WIDGET DRAGDROP");
2834 widgetPressEvent : function(w,e,u,d) {
2835 if (this.get('view').pressed) {
2838 this.get('view').pressed = true;
2839 print("WIDGET PRESS " + d.xtreepath );
2840 this.get('/LeftTree.view').selectNode( d.xtreepath );
2843 widgetReleaseEvent : function() {
2844 this.get('view').pressed = false;
2850 pack : "pack_start,false,true,0",
2854 pack : "pack_start,false,false,0",
2855 label : "Run The Application",
2857 "button_press_event":function (self, event) {
2858 // call render on left tree - with special option!?!
2862 print("GET PROEJCT");
2863 var pr = this.get('/LeftProjectTree').getActiveProject();
2866 for (var i in pr.paths) {
2870 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
2871 print ("RUN DIR:" + dir);
2873 this.get('/BottomPane').el.set_current_page(1);
2874 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
2875 , false,false,false);
2876 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
2877 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2887 xtype: Gtk.ScrolledWindow,
2890 shadow_type : Gtk.ShadowType.IN,
2892 XObject.prototype.init.call(this);
2893 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2897 xtype: Gtk.EventBox,
2900 XObject.prototype.init.call(this);
2901 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
2902 red: 0x9F00, green: 0xB800 , blue : 0xA800
2910 XObject.prototype.init.call(this);
2911 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
2912 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
2917 xtype: Gtk.EventBox,
2920 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
2921 XObject.prototype.init.call(this);
2925 this.el, /* widget that will accept a drop */
2926 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2927 null, /* lists of target to support */
2928 0, /* size of list */
2929 Gdk.DragAction.COPY /* what to do with data after dropped */
2932 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2933 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2936 getActiveNode : function(x,y)
2938 // workout what node is here..
2939 return '0'; // top..
2943 "drag_motion":function (self, ctx, x, y, time) {
2945 // A) find out from drag all the places that node could be dropped.
2946 var src = Gtk.drag_get_source_widget(ctx);
2947 if (!src.dropList) {
2948 Gdk.drag_status(ctx, 0, time);
2951 // b) get what we are over.. (from activeNode)
2952 // tree is empty.. - list should be correct..
2953 if (!this.get('/LeftTree.model').currentTree) {
2954 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2958 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2959 var activeNode = this.getActiveNode(x, y);
2962 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
2965 Gdk.drag_status(ctx, 0,time);
2966 this.get('/LeftTree.view').highlight(false);
2970 // if we have a target..
2971 // -> highlight it! (in browser)
2972 // -> highlight it! (in tree)
2974 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2975 this.get('/LeftTree.view').highlight(tg);
2976 this.targetData = tg;
2977 // for tree we should handle this...
2980 "drag_drop":function (self,ctx, x, y, time) {
2981 Seed.print("TARGET: drag-drop");
2982 var is_valid_drop_site = true;
2987 self, /* will receive 'drag-data-received' signal */
2988 ctx, /* represents the current state of the this.gDnD */
2989 this.get('/Window').atoms["STRING"], /* the target type we want */
2990 time /* time stamp */
2994 /* No target offered by source => error */
2997 return is_valid_drop_site;
3000 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3002 Seed.print("GtkView: drag-data-received");
3003 var delete_selection_data = false;
3004 var dnd_success = false;
3005 /* Deal with what we are given from source */
3006 if( sel_data && sel_data.length ) {
3008 if (ctx.action == Gdk.DragAction.ASK) {
3009 /* Ask the user to move or copy, then set the ctx action. */
3012 if (ctx.action == Gdk.DragAction.MOVE) {
3013 delete_selection_data = true;
3015 var source = Gtk.drag_get_source_widget(ctx);
3017 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3018 if (this.targetData) {
3019 Seed.print(this.targetData);
3020 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3029 if (dnd_success == false)
3031 Seed.print ("DnD data transfer failed!\n");
3034 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3037 "button_press_event":function (self, event) {
3038 this.pressed = false;
3056 xtype: Gtk.Notebook,
3059 XObject.prototype.init.call(this);
3060 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3061 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3066 xtype: Gtk.ScrolledWindow,
3071 xtype: GtkSource.View,
3075 XObject.prototype.init.call(this);
3076 var description = Pango.Font.description_from_string("monospace")
3077 description.set_size(8000);
3078 this.el.modify_font(description);
3081 load : function(str) {
3082 this.get('/BottomPane').el.set_current_page(0);
3083 this.el.get_buffer().set_text(str, str.length);
3084 var lm = GtkSource.LanguageManager.get_default();
3086 this.el.get_buffer().set_language(lm.get_language('js'));
3087 var buf = this.el.get_buffer();
3088 var cursor = buf.get_mark("insert");
3089 var iter= new Gtk.TextIter;
3090 buf.get_iter_at_mark(iter, cursor);
3092 iter.set_line_offset(4);
3093 buf.move_mark(cursor, iter);
3096 cursor = buf.get_mark("selection_bound");
3097 iter= new Gtk.TextIter;
3098 buf.get_iter_at_mark(iter, cursor);
3100 iter.set_line_offset(4);
3101 buf.move_mark(cursor, iter);
3103 this.el.grab_focus();
3107 xtype: GtkSource.Buffer,
3108 pack : "set_buffer",
3110 "changed":function (self) {
3111 var s = new Gtk.TextIter();
3112 var e = new Gtk.TextIter();
3113 this.el.get_start_iter(s);
3114 this.el.get_end_iter(e);
3115 var str = this.el.get_text(s,e,true);
3117 Seed.check_syntax('var e = ' + str);
3119 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3120 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3122 print("SYNTAX ERROR IN EDITOR");
3127 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3128 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3131 this.get('/LeftPanel.model').changed( str , false);
3140 xtype: Gtk.ScrolledWindow,
3144 xtype: Vte.Terminal,
3147 feed : function(str) {
3148 this.el.feed(str,str.length);
3159 pack : "pack_start,false,false",
3163 this.get('buttonbar').el.show();
3164 this.get('viewbox').el.hide();
3165 print("TRIED TO HIDE");
3168 this.get('buttonbar').el.hide();
3169 this.get('viewbox').el.show();
3170 // this.get('model').expanded();
3182 pack : "pack_start,false,true",
3184 "clicked":function (self) {
3185 this.get('/RightPalete').show();
3192 stock : Gtk.STOCK_GOTO_FIRST,
3193 icon_size : Gtk.IconSize.MENU
3203 XObject.prototype.init.call(this);
3204 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3207 "enter_notify_event":function (self, event) {
3208 this.get('/RightPalete').show();
3222 pack : "pack_start,false,true",
3231 pack : "pack_start,false,true",
3233 "clicked":function (self) {
3234 this.get('/RightPalete').hide();
3241 stock : Gtk.STOCK_GOTO_LAST,
3242 icon_size : Gtk.IconSize.MENU
3249 xtype: Gtk.ScrolledWindow,
3252 XObject.prototype.init.call(this);
3253 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3254 this.el.set_size_request(-1,200);
3256 shadow_type : Gtk.ShadowType.IN,
3259 xtype: Gtk.TreeView,
3262 XObject.prototype.init.call(this);
3263 this.el.set_size_request(150,-1);
3264 // set_reorderable: [1]
3266 var description = new Pango.FontDescription.c_new();
3267 description.set_size(8000);
3268 this.el.modify_font(description);
3270 this.selection = this.el.get_selection();
3271 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3272 // this.selection.signal['changed'].connect(function() {
3273 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3275 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3277 Gtk.drag_source_set (
3278 this.el, /* widget will be drag-able */
3279 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3280 null, /* lists of target to support */
3281 0, /* size of list */
3282 Gdk.DragAction.COPY /* what to do with data after dropped */
3284 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3286 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3287 Gtk.drag_source_add_text_targets(this.el);
3289 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3290 targets = new Gtk.TargetList();
3291 targets.add( LeftTree.atoms["STRING"], 0, 0);
3292 targets.add_text_targets( 1 );
3293 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3295 //if you want to allow text to be output elsewhere..
3296 //Gtk.drag_source_add_text_targets(this.el);
3300 headers_visible : false,
3301 enable_tree_lines : true,
3303 "drag_begin":function (self, ctx) {
3304 // we could fill this in now...
3305 Seed.print('SOURCE: drag-begin');
3309 var iter = new Gtk.TreeIter();
3310 var s = this.selection;
3311 s.get_selected(this.get('/RightPalete.model').el, iter);
3312 var path = this.get('/RightPalete.model').el.get_path(iter);
3314 var pix = this.el.create_row_drag_icon ( path);
3317 Gtk.drag_set_icon_pixmap (ctx,
3324 var value = new GObject.Value('');
3325 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3326 if (!this.get('/RightPalete').provider) {
3329 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3330 this.el.dragData = value.value;
3337 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3338 //Seed.print('Palete: drag-data-get: ' + target_type);
3339 if (this.el.dragData && this.el.dragData.length ) {
3340 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3344 //this.el.dragData = "TEST from source widget";
3348 "drag_end":function (self, drag_context) {
3349 Seed.print('SOURCE: drag-end');
3350 this.el.dragData = false;
3351 this.el.dropList = false;
3352 this.get('/LeftTree.view').highlight(false);
3358 xtype: Gtk.ListStore,
3361 XObject.prototype.init.call(this);
3362 this.el.set_column_types ( 2, [
3363 GObject.TYPE_STRING, // title
3364 GObject.TYPE_STRING // tip
3369 load : function(tr,iter)
3374 //console.log('Project tree load: ' + tr.length);
3375 var citer = new Gtk.TreeIter();
3376 //this.insert(citer,iter,0);
3377 for(var i =0 ; i < tr.length; i++) {
3380 this.el.append(citer);
3382 this.el.insert(citer,iter,-1);
3387 this.el.set_value(citer, 0, '' + r ); // title
3389 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3390 //if (r.cn && r.cn.length) {
3391 // this.load(r.cn, citer);
3397 getValue : function (iter, col) {
3398 var gval = new GObject.Value('');
3399 this.el.get_value(iter, col ,gval);
3406 xtype: Gtk.TreeViewColumn,
3407 pack : "append_column",
3409 XObject.prototype.init.call(this);
3410 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3414 xtype: Gtk.CellRendererText,
3436 XObject.cache['/Window'] = Window;