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);
882 var path = this.el.get_path(old_iter).to_string();
883 this.activeIter = false;
886 this.activeIter = false;
887 var iter = new Gtk.TreeIter();
888 this.el.get_iter_from_string(iter, path);
889 this.el.remove(iter);
891 // rebuild treemap. -- depreciated.!!
894 //this.toJS(null, true) // does not do anything?
896 this.changed(false,true);
899 listAllTypes : function() {
900 var s = this.get('/LeftTree.view').selection;
901 print ("LIST ALL TYPES: " + s.count_selected_rows() );
903 if (s.count_selected_rows() > 0) {
904 var iter = new Gtk.TreeIter();
905 s.get_selected(this.el, iter);
907 // set some properties of the tree for use by the dropped element.
908 var value = new GObject.Value('');
909 this.el.get_value(iter, 2, value);
910 var data = JSON.parse(value.value);
913 var xname = this.get('/LeftTree.model').file.guessName(data);
914 console.log('selected:' + xname);
918 return []; // could not find it..
926 li.forEach(function(el) {
927 // this is specific to roo!!!?
929 var fullpath = _this.file.guessName(el);
930 if (fullpath.length && ret.indexOf(fullpath) < 0) {
935 if (el.items && el.items.length) {
944 addall([this.currentTree]);
946 // only if we have nothing, should we add '*top'
950 //console.log('all types in tree');
956 singleNodeToJS : function (treepath)
958 var iter = new Gtk.TreeIter();
959 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
963 var iv = this.getIterValue(iter, 2);
965 return JSON.parse(iv);
968 nodeToJS : function (iter, with_id)
970 var par = new Gtk.TreeIter();
971 var iv = this.getIterValue(iter, 2);
973 var k = JSON.parse(iv);
974 if (k.json && !this.el.iter_parent( par, iter )) {
979 var treepath_str = this.el.get_path(iter).to_string();
980 // not sure how we can handle mixed id stuff..
981 if (typeof(k.id) == 'undefined') {
982 k.id = 'builder-'+ treepath_str ;
986 this.treemap[ treepath_str ] = k;
987 k.xtreepath = treepath_str ;
990 if (this.el.iter_has_child(iter)) {
991 citer = new Gtk.TreeIter();
992 this.el.iter_children(citer, iter);
993 k.items = this.toJS(citer,with_id);
997 toJS : function(iter, with_id)
999 //Seed.print("WITHID: "+ with_id);
1006 iter = new Gtk.TreeIter();
1007 if (!this.el.get_iter_first(iter)) {
1017 var k = this.nodeToJS(iter, with_id);
1021 if (!this.el.iter_next(iter)) {
1027 // convert the list into a json string..
1031 getIterValue : function (iter, col) {
1032 var gval = new GObject.Value('');
1033 this.el.get_value(iter, col ,gval);
1038 nodeTitle : function(c) {
1041 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
1042 if (sr) txt.push('<s>');
1043 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
1044 if (c.xtype) { txt.push(c.xtype); }
1045 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1046 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1047 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1050 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1051 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1052 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1053 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1054 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1055 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1056 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1057 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1058 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1060 // for flat classes...
1061 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1062 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1065 if (sr) txt.push('</s>');
1066 return (txt.length == 0 ? "Element" : txt.join(" "));
1068 nodeToJSON : function(c) {
1076 return JSON.stringify(o);
1078 load : function(tr,iter)
1080 var citer = new Gtk.TreeIter();
1081 //this.insert(citer,iter,0);
1082 for(var i =0 ; i < tr.length; i++) {
1084 this.el.insert(citer,iter,-1);
1086 this.el.append(citer);
1089 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1090 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1091 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1092 if (tr[i].items && tr[i].items.length) {
1093 this.load(tr[i].items, citer);
1099 xtype: Gtk.TreeViewColumn,
1100 pack : "append_column",
1102 XObject.prototype.init.call(this);
1103 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1107 xtype: Gtk.CellRendererText,
1117 id : "LeftTreeMenu",
1120 xtype: Gtk.MenuItem,
1122 label : "Delete Element",
1124 "activate":function (self) {
1126 this.get('/LeftTree.model').deleteSelected();
1137 id : "LeftProjectTree",
1138 showNoProjectSelected : function() {
1139 this.get('/StandardErrorDialog').show("Select a Project first.");
1141 getActiveProject : function() {
1142 return this.project;
1145 "leave_notify_event":function (self, event) {
1152 pack : "pack_start,false,false",
1155 xtype: Gtk.ComboBox,
1158 XObject.prototype.init.call(this);
1159 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1161 getValue : function() {
1162 var ix = this.el.get_active();
1166 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1169 setValue : function(fn)
1173 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1174 data.forEach(function(n, ix) {
1182 "changed":function (self) {
1183 var fn = this.getValue();
1184 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1185 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1190 xtype: Gtk.CellRendererText,
1191 pack : "pack_start,true",
1195 xtype: Gtk.ListStore,
1198 XObject.prototype.init.call(this);
1199 this.el.set_column_types ( 2, [
1200 GObject.TYPE_STRING, // real key
1201 GObject.TYPE_STRING // real type
1207 loadData : function(data) {
1208 var ov = this.get('/LeftProjectTree.combo').getValue();
1210 var iter = new Gtk.TreeIter();
1212 data.forEach(function(p) {
1217 el.set_value(iter, 0, p.fn);
1218 el.set_value(iter, 1, p.name);
1222 this.get('/LeftProjectTree.combo').setValue(ov);
1231 xtype: Gtk.ScrolledWindow,
1233 shadow_type : Gtk.ShadowType.IN,
1235 XObject.prototype.init.call(this);
1236 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1240 xtype: Gtk.TreeView,
1241 headers_visible : false,
1242 enable_tree_lines : true,
1245 XObject.prototype.init.call(this);
1246 var description = new Pango.FontDescription.c_new();
1247 description.set_size(8000);
1248 this.el.modify_font(description);
1250 this.selection = this.el.get_selection();
1251 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1255 "cursor_changed":function (self) {
1256 var iter = new Gtk.TreeIter();
1258 if (this.selection.count_selected_rows() < 1) {
1259 //XN.get('Builder.LeftTree.model').
1260 this.get('/LeftTree.model').load( false);
1264 var model = this.get('/LeftProjectTree.model');
1265 //console.log('changed');
1266 var s = this.selection;
1267 s.get_selected(model, iter);
1268 value = new GObject.Value('');
1269 model.el.get_value(iter, 2, value);
1271 console.log(value.value);// id..
1273 var file = this.get('/LeftProjectTree').project.getById(value.value);
1280 var nb = this.get('/LeftTopPanel.expander');
1281 nb.el.expanded = false;
1282 nb.listeners.activate.call(nb);
1283 //_expander.el.set_expanded(false);
1285 var ltm = this.get('/LeftTree.model');
1293 xtype: Gtk.TreeStore,
1297 XObject.prototype.init.call(this);
1298 this.el.set_column_types ( 3, [
1299 GObject.TYPE_STRING, // title
1300 GObject.TYPE_STRING, // tip
1301 GObject.TYPE_STRING // id..
1305 loadProject : function(pr) {
1310 this.get('/LeftProjectTree').project = pr;
1311 this.load(pr.toTree());
1312 this.get('/LeftProjectTree.view').el.expand_all();
1314 load : function(tr,iter) {
1316 console.log('Project tree load: ' + tr.length);
1317 var citer = new Gtk.TreeIter();
1318 //this.insert(citer,iter,0);
1321 tr.forEach(function (r) {
1323 _this.el.append(citer);
1325 _this.el.insert(citer,iter,-1);
1327 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1328 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1329 _this.el.set_value(citer, 2, '' + r.id ); //id
1330 if (r.cn && r.cn.length) {
1331 _this.load(r.cn, citer);
1336 getValue : function(iter, col) {
1337 var gval = new GObject.Value('');
1338 this.el.get_value(iter, col ,gval);
1339 return '' + gval.value;
1343 xtype: Gtk.TreeViewColumn,
1344 pack : "append_column",
1346 XObject.prototype.init.call(this);
1347 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1351 xtype: Gtk.CellRendererText,
1374 pack : "pack_start,false,true,0",
1381 "button_press_event":function (self, event) {
1382 this.get('/MidPropTree.model').showData('props');
1394 stock : Gtk.STOCK_ADD,
1395 icon_size : Gtk.IconSize.MENU
1410 "button_press_event":function (self, event) {
1411 this.get('/MidPropTree.model').showData('events');
1423 stock : Gtk.STOCK_ADD,
1424 icon_size : Gtk.IconSize.MENU
1439 "button_press_event":function (self, ev) {
1440 var p = this.get('/AddPropertyPopup');
1444 p.el.set_screen(Gdk.Screen.get_default());
1446 p.el.popup(null, null, null, null, 3, ev.button.time);
1458 stock : Gtk.STOCK_ADD,
1459 icon_size : Gtk.IconSize.MENU
1471 id : "AddPropertyPopup",
1474 xtype: Gtk.MenuItem,
1476 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1479 "activate":function (self) {
1481 this.get('/LeftPanel.model').add( {
1492 xtype: Gtk.MenuItem,
1494 tooltip_markup : "Add what type of packing is to be used",
1497 "activate":function (self) {
1499 this.get('/LeftPanel.model').add( {
1509 xtype: Gtk.MenuItem,
1511 tooltip_markup : "Override the init method",
1514 "activate":function (self) {
1516 this.get('/LeftPanel.model').add( {
1519 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1526 xtype: Gtk.SeparatorMenuItem,
1530 xtype: Gtk.MenuItem,
1532 tooltip_markup : "Add a user defined string property",
1535 "activate":function (self) {
1537 this.get('/LeftPanel.model').add( {
1547 xtype: Gtk.MenuItem,
1549 tooltip_markup : "Add a user defined number property",
1552 "activate":function (self) {
1554 this.get('/LeftPanel.model').add( {
1564 xtype: Gtk.MenuItem,
1566 tooltip_markup : "Add a user defined boolean property",
1569 "activate":function (self) {
1571 this.get('/LeftPanel.model').add( {
1581 xtype: Gtk.SeparatorMenuItem,
1585 xtype: Gtk.MenuItem,
1587 tooltip_markup : "Add a user function boolean property",
1590 "activate":function (self) {
1592 this.get('/LeftPanel.model').add( {
1595 val : "function() {\n \n}\n",
1608 xtype: Gtk.ScrolledWindow,
1611 shadow_type : Gtk.ShadowType.IN,
1614 XObject.prototype.init.call(this);
1615 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1619 xtype: Gtk.TreeView,
1622 headers_visible : false,
1623 enable_tree_lines : true,
1625 XObject.prototype.init.call(this);
1627 this.selection = this.el.get_selection();
1628 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1631 var description = new Pango.FontDescription.c_new();
1632 description.set_size(8000);
1633 this.el.modify_font(description);
1636 "button_press_event":function (self, ev) {
1640 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1641 return false; //not on a element.
1645 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1647 if (res.column.title != 'value') {
1648 return false; // ignore..
1650 if ( this.get('/LeftPanel').editing) {
1653 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1654 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1655 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1659 var provider = this.get('/LeftTree').getPaleteProvider();
1661 var opts = provider.findOptions(type);
1663 if (opts === false) {
1664 this.get('/LeftPanel').editableColumn.setOptions([]);
1665 renderer.has_entry = true;
1667 LeftPanel.editableColumn.setOptions(opts);
1668 renderer.has_entry = false;
1672 //Seed.print("click" + ev.type);
1673 //console.dump(res);
1679 if (res.column.title == 'value') {
1682 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1683 var p = this.get('/LeftPanelPopup');
1688 p.el.set_screen(Gdk.Screen.get_default());
1690 p.el.popup(null, null, null, null, 3, ev.button.time);
1691 //Seed.print("click:" + res.column.title);
1699 xtype: Gtk.TreeStore,
1703 XObject.prototype.init.call(this);
1704 this.el.set_column_types ( 5, [
1705 GObject.TYPE_STRING, // 0 real key
1706 GObject.TYPE_STRING, // 1 real value
1707 GObject.TYPE_STRING, // 2 visable key
1708 GObject.TYPE_STRING, // 3 visable value
1709 GObject.TYPE_STRING, // 4 need to store type of!!!
1713 toShort : function(str) {
1714 var a = typeof(str) == 'string' ? str.split("\n") : [];
1715 return a.length > 1 ? a[0] + '....' : '' + str;
1717 load : function(ar) {
1720 this.get('/RightEditor').el.hide();
1727 var provider = this.get('/LeftTree').getPaleteProvider();
1730 var iter = new Gtk.TreeIter();
1732 if (typeof(ar[i]) == 'object') {
1736 var type = provider.findType(ar, i, ar[i]);
1738 this.el.append(iter);
1739 var p = this.el.get_path(iter).to_string();
1741 this.el.set_value(iter, 0, i);
1742 this.el.set_value(iter, 1, '' + ar[i]);
1743 this.el.set_value(iter, 2, i);
1744 this.el.set_value(iter, 3, this.toShort(ar[i]));
1745 this.el.set_value(iter, 4, type);
1747 ar.listeners = ar.listeners || {};
1748 for (var i in ar.listeners ) {
1749 this.el.append(iter);
1750 var p = this.el.get_path(iter).to_string();
1753 this.el.set_value(iter, 0, '!'+ i );
1754 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1755 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1757 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1758 this.el.set_value(iter, 4, 'function');
1762 add : function(info) {
1763 // info includes key, val, skel, etype..
1765 type = info.type.toLowerCase();
1766 var data = this.toJS();
1768 if (info.etype == 'events') {
1769 data.listeners = data.listeners || { };
1770 if (typeof(data.listeners[info.key]) != 'undefined') {
1771 return; //already set!
1774 if (typeof(data[info.key]) != 'undefined') {
1779 if (typeof(info.val) == 'undefined') {
1782 if (info.type == 'boolean') {
1785 if (type == 'number') {
1793 if (info.etype == 'events') {
1795 data.listeners[info.key] = info.val;
1798 data[info.key] = info.val;
1802 var map = this.load(data);
1804 // flag it as changed to the interface..
1806 this.get('/LeftTree.model').changed(data, true);
1809 this.startEditing(map[k]);
1812 LeftPanel.get('view').el.row_activated(
1813 new Gtk.TreePath.from_string(map[k]),
1814 LeftPanel.editableColumn.el
1818 startEditing : function(path,col) {
1820 * start editing path (or selected if not set..)
1821 * @param {String|false} path (optional) treepath to edit - selected tree gets
1822 * edited by default.
1823 * @param {Number} 0 or 1 (optional)- column to edit.
1826 if (typeof(path) == 'string') {
1827 tp = new Gtk.TreePath.from_string(path);
1829 var iter = new Gtk.TreeIter();
1830 var s = this.get('/LeftPanel.view').selection;
1831 s.get_selected(this.el, iter);
1832 tp = this.el.get_path(iter);
1833 path = tp.to_string();
1837 // which colum is to be edited..
1839 if (typeof(col) == 'undefined') {
1840 var k = this.getValue(path, 0);
1841 colObj = (!k.length || k == '|') ?
1842 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1844 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1847 // make sure the pulldown is set correctly..
1848 // not really needed for second col...
1850 var provider = this.get('/LeftTree').getPaleteProvider();
1852 var type = this.get('/LeftPanel.model').getType(path);
1853 var opts = provider.findOptions(type);
1854 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1856 if (opts === false) {
1857 this.get('/LeftPanel').editableColumn.setOptions([]);
1858 renderer.has_entry = true; /// probably does not have any effect.
1860 this.get('/LeftPanel').editableColumn.setOptions(opts);
1861 renderer.has_entry = false;
1865 // iter now has row...
1866 GLib.timeout_add(0, 100, function() {
1868 colObj.items[0].el.editable = true; // esp. need for col 0..
1869 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1878 deleteSelected : function() {
1879 var data = this.toJS();
1880 var iter = new Gtk.TreeIter();
1881 var s = this.get('/LeftPanel.view').selection;
1882 s.get_selected(this.el, iter);
1885 var gval = new GObject.Value('');
1886 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1888 var val = gval.value;
1889 if (val[0] == '!') {
1891 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1894 delete data.listeners[ val.substring(1)];
1895 if (!XObject.keys(data.listeners).length) {
1896 delete data.listeners;
1900 if (typeof(data[val]) == 'undefined') {
1908 this.get('/LeftTree.model').changed(data, true);
1912 changed : function(str, doRefresh) {
1913 if (!this.activePath) {
1916 var iter = new Gtk.TreeIter();
1917 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1919 this.el.set_value(iter, 1, '' +str);
1920 this.el.set_value(iter, 3, '' + this.toShort(str));
1921 // update the tree...
1923 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
1926 var iter = new Gtk.TreeIter();
1927 this.get('/LeftPanel.model').el.get_iter_first(iter);
1932 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
1935 ar.listeners = ar.listeners || {};
1936 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
1939 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
1942 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
1948 //print(JSON.stringify(ar));
1952 getType : function(treepath) {
1953 return this.getValue(treepath, 4);
1955 getValue : function(treepath_str, col) {
1956 var iter = new Gtk.TreeIter();
1957 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
1959 var gval = new GObject.Value('');
1960 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
1961 var val = '' + gval.value;
1965 var type = this.getType(this.el.get_path(iter).to_string());
1966 //print("TYPE: " +type + " - val:" + val);
1967 switch(type.toLowerCase()) {
1971 return parseFloat(val); // Nan ?? invalid!!?
1973 return val == 'true' ? true : false;
1979 editSelected : function(e) {
1980 print("EDIT SELECTED?");
1981 var iter = new Gtk.TreeIter();
1982 var s = this.get('/LeftPanel.view').selection;
1983 s.get_selected(this.get('/LeftPanel.model').el, iter);
1984 var m = this.get('/LeftPanel.model')
1986 var gval = new GObject.Value('');
1987 this.el.get_value(iter, 0 ,gval);
1988 var val = '' + gval.value;
1990 gval = new GObject.Value('');
1991 this.el.get_value(iter, 1 ,gval);
1992 var rval = gval.value;
1993 var activePath = this.el.get_path(iter).to_string();
1994 this.activePath = activePath ;
1995 // was activeIter...
1998 var showEditor = false;
2000 if (val[0] == '!') {
2003 if (val[0] == '|') {
2004 if (rval.match(/function/g) || rval.match(/\n/g)) {
2011 this.activePath = false;
2012 GLib.timeout_add(0, 1, function() {
2013 // Gdk.threads_enter();
2014 _this.get('/RightEditor').el.show();
2015 _this.get('/RightEditor.view').load( rval );
2019 _this.activePath = activePath ;
2021 // Gdk.threads_leave();
2027 this.get('/RightEditor').el.hide();
2029 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2035 xtype: Gtk.TreeViewColumn,
2036 pack : "append_column",
2038 XObject.prototype.init.call(this);
2040 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2041 this.get('/LeftPanel').propertyColumn = this;
2046 xtype: Gtk.CellRendererText,
2047 pack : "pack_start",
2049 "editing_started":function (self, editable, path) {
2051 this.get('/LeftPanel.model').activePath = path;
2054 "edited":function (self, object, p0) {
2055 var model = this.get('/LeftPanel.model');
2056 var path = model.activePath;
2057 var iter = new Gtk.TreeIter();
2058 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2059 model.el.set_value(iter, 0, p0);
2060 model.el.set_value(iter, 2, p0);
2062 model.activePath = false;
2064 this.get('/LeftTree.model').changed(model.toJS(), true);
2065 this.el.editable = false;
2072 xtype: Gtk.TreeViewColumn,
2073 pack : "append_column",
2075 XObject.prototype.init.call(this);
2076 this.el.add_attribute(this.items[0].el , 'text', 3 );
2077 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2078 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2079 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2081 this.get('/LeftPanel').editableColumn= this;
2083 setOptions : function(ar) {
2084 var m = this.items[0].el.model;
2086 var iter = new Gtk.TreeIter();
2087 ar.forEach(function(i) {
2090 m.set_value(iter, 0, i);
2096 xtype: Gtk.CellRendererCombo,
2097 pack : "pack_start",
2102 XObject.prototype.init.call(this);
2103 this.el.model = new Gtk.ListStore();
2104 this.el.model.set_column_types ( 1, [
2105 GObject.TYPE_STRING // 0 real key
2109 "edited":function (self, object, p0) {
2110 this.get('/LeftPanel').editing = false;
2111 print("EDITED? p:" + p0 + " t:" + p0);
2112 this.get('/LeftPanel.model').changed(p0, true);
2113 this.get('/LeftPanel.model').activePath = false;
2115 "editing_started":function (self, editable, path) {
2116 this.get('/LeftPanel').editing = true;
2117 // console.log('editing started');
2118 // r.has_entry = false;
2119 this.get('/LeftPanel.model').editSelected(editable);
2130 id : "LeftPanelPopup",
2133 xtype: Gtk.MenuItem,
2137 "activate":function (self) {
2138 this.get('/LeftPanel.model').deleteSelected();
2143 xtype: Gtk.MenuItem,
2147 "activate":function (self) {
2148 this.get('/LeftPanel.model').startEditing(false, 0);
2161 xtype: Gtk.ScrolledWindow,
2162 pack : "pack_end,false,true,0",
2164 shadow_type : Gtk.ShadowType.IN,
2166 XObject.prototype.init.call(this);
2167 XObject.prototype.init.call(this);
2168 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2169 this.el.set_size_request ( 150, -1 );
2172 activeElement : false,
2173 hideWin : function() {
2180 if (this.get('/Window.left').el.position < 160) {
2183 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2190 xtype: Gtk.TreeView,
2191 enable_tree_lines : true,
2192 headers_visible : false,
2195 XObject.prototype.init.call(this);
2197 var description = new Pango.FontDescription.c_new();
2198 description.set_size(8000);
2199 this.el.modify_font(description);
2201 //this.selection = this.el.get_selection();
2202 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2211 "cursor_changed":function (self) {
2212 var iter = new Gtk.TreeIter();
2214 //console.log('changed');
2215 var m = this.get('model');
2216 if (!this.selection){
2217 this.selection = this.el.get_selection();
2220 var s = this.selection;
2221 if (!s.get_selected(m.el, iter)) {
2224 var tp = m.el.get_path(iter).to_string();
2229 var key = m.getValue(tp, 0);
2231 var type = m.getValue(tp, 1);
2232 var skel = m.getValue(tp, 3);
2233 var etype = m.getValue(tp, 5);
2236 this.get('/MidPropTree').hideWin();
2238 if (type == 'function') {
2240 if (etype != 'events') {
2244 this.get('/LeftPanel.model').add({
2253 if (type.indexOf('.') > -1 ||
2254 type == 'boolean') {
2258 this.get('/LeftPanel.model').add( {
2268 xtype: Gtk.ListStore,
2271 XObject.prototype.init.call(this);
2272 this.el.set_column_types ( 6, [
2273 GObject.TYPE_STRING, // real key
2274 GObject.TYPE_STRING, // real type
2275 GObject.TYPE_STRING, // docs ?
2276 GObject.TYPE_STRING, // visable desc
2277 GObject.TYPE_STRING, // function desc
2278 GObject.TYPE_STRING // element type (event|prop)
2282 getValue : function(treepath, col)
2284 var tp = new Gtk.TreePath.from_string (treepath);
2285 var iter = new Gtk.TreeIter();
2286 this.el.get_iter (iter, tp);
2287 var value = new GObject.Value('');
2288 this.el.get_value(iter, col, value);
2292 showData : function(type) {
2294 if (!this.get('/MidPropTree').activeElement || !type) {
2295 return; // no active element
2298 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2299 var palete = this.get('/LeftTree').getPaleteProvider();
2303 Seed.print('Showing right?');
2304 if (!this.get('/MidPropTree').shown) {
2306 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2307 this.get('/MidPropTree').el.show();
2308 this.get('/MidPropTree').shown = true;
2311 var elementList = palete.getPropertiesFor(fullpath, type);
2312 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2313 // console.dump(elementList);
2316 var iter = new Gtk.TreeIter();
2317 for(var i =0 ; i < elementList.length; i++) {
2318 var p=elementList[i];
2319 this.el.append(iter);
2320 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2321 //GObject.TYPE_STRING, // real key
2322 // GObject.TYPE_STRING, // real type
2323 // GObject.TYPE_STRING, // docs ?
2324 // GObject.TYPE_STRING // func def?
2327 this.el.set_value(iter, 0, p.name);
2328 this.el.set_value(iter, 1, p.type);
2329 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2330 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2331 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2332 this.el.set_value(iter, 5, type);
2340 xtype: Gtk.TreeViewColumn,
2342 this.el = new Gtk.TreeViewColumn();
2343 this.parent.el.append_column(this.el);
2345 XObject.prototype.init.call(this);
2346 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2351 xtype: Gtk.CellRendererText,
2352 pack : "pack_start,true"
2376 xtype: Gtk.Notebook,
2377 pack : "pack_start,true,true",
2378 id : "view-notebook",
2381 XObject.prototype.init.call(this);
2382 this.el.set_current_page(0);
2384 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2385 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2392 id : "RightBrowser",
2396 pack : "pack_start,false,true,0",
2400 pack : "pack_start,false,false,0",
2401 label : "Dump HTML to console",
2403 "activate":function (self) {
2404 this.get('/RightBrowser.view').el.execute_script(
2405 "console.log(document.body.innerHTML);");
2406 this.get('/RightBrowser.view').el.execute_script(
2407 "console.log(Builder.dump(Builder));");
2414 xtype: Gtk.ScrolledWindow,
2416 shadow_type : Gtk.ShadowType.IN,
2418 XObject.prototype.init.call(this);
2419 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2423 xtype: WebKit.WebView,
2427 XObject.prototype.init.call(this);
2428 // this may not work!?
2429 this.el.open('file:///' + __script_path__ + '/../builder.html');
2433 this.el, /* widget that will accept a drop */
2434 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2435 null, /* lists of target to support */
2436 0, /* size of list */
2437 Gdk.DragAction.COPY /* what to do with data after dropped */
2440 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2441 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2443 renderJS : function(data) {
2444 this.renderedData = data;
2445 var str = JSON.stringify(data) ;
2448 console.log('not loaded yet');
2450 Seed.print("RENDER:" + str);
2451 imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2452 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2455 "load_finished":function (self, object) {
2456 if (this.ready) { // dont do it twice!
2461 this.renderJS(this.get('/LeftTree.model').toJS()[0]);
2463 "script_alert":function (self, object, p0) {
2466 return true; // do not display anything...
2468 "console_message":function (self, object, p0, p1) {
2469 console.log(object);
2470 if (!object.match(/^\{/)) {
2471 return false; // do not handle!!! -> later maybe in console..
2473 console.log(object);
2474 var val = JSON.parse(object);
2476 if (typeof(val['hover-node']) != 'undefined') {
2477 this.activeNode = val['hover-node'];
2478 console.log('active node: ' + this.activeNode);
2483 if (typeof(val['id']) != 'undefined') {
2484 // this.activeNode = val['id'];
2485 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2489 this.get('/LeftTree.view').selectNode(tg[0]);
2493 if (ret && typeof(val['set']) != 'undefined') {
2494 this.get('/LeftPanel.model').add({
2498 //console.log('active node: ' + this.activeNode);
2501 //Seed.print('a:'+a);
2502 //Seed.print('b:'+b);
2503 //Seed.print('c:'+c);
2506 "drag_motion":function (w, ctx, x, y, time, ud) {
2507 // console.log('DRAG MOTION');
2509 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2510 this.targetData = [];
2511 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2513 // A) find out from drag all the places that node could be dropped.
2514 var src = Gtk.drag_get_source_widget(ctx);
2515 if (!src.dropList) {
2516 Gdk.drag_status(ctx, 0, time);
2519 // b) get what we are over.. (from activeNode)
2520 // tree is empty.. - list should be correct..
2521 if (!this.get('/LeftTree.model').currentTree) {
2522 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2526 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2528 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2531 Gdk.drag_status(ctx, 0,time);
2532 this.get('/LeftTree.view').highlight(false);
2536 // if we have a target..
2537 // -> highlight it! (in browser)
2538 // -> highlight it! (in tree)
2540 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2541 this.get('/LeftTree.view').highlight(tg);
2542 this.targetData = tg;
2543 // for tree we should handle this...
2546 "drag_drop":function (w, ctx, x, y,time, ud) {
2547 print("TARGET: drag-drop");
2548 var is_valid_drop_site = true;
2553 w, /* will receive 'drag-data-received' signal */
2554 ctx, /* represents the current state of the DnD */
2555 this.get('/Window').atoms["STRING"], /* the target type we want */
2556 time /* time stamp */
2560 /* No target offered by source => error */
2563 return is_valid_drop_site;
2565 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2567 print("Browser: drag-data-received");
2568 var delete_selection_data = false;
2569 vardnd_success = false;
2570 /* Deal with what we are given from source */
2571 if( sel_data && sel_data.length ) {
2573 if (ctx.action == Gdk.DragAction.ASK) {
2574 /* Ask the user to move or copy, then set the ctx action. */
2577 if (ctx.action == Gdk.DragAction.MOVE) {
2578 delete_selection_data = true;
2580 var source = Gtk.drag_get_source_widget(ctx);
2582 print("Browser: source.DRAGDATA? " + source.dragData);
2583 if (this.targetData) {
2584 print(this.targetData);
2585 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2594 if (dnd_success == false)
2596 Seed.print ("DnD data transfer failed!\n");
2599 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2611 id : "RightGtkView",
2612 renderJS : function(data, withDebug)
2617 this.withDebug = false;
2619 if (this.renderedEl) {
2620 this.get('view').el.remove(this.renderedEl);
2621 this.renderedEl.destroy();
2622 this.renderedEl = false;
2625 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2626 // in theory tree is actually window..
2628 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2633 this.get('view').el.set_size_request(
2634 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2637 this.renderedEl.set_size_request(
2638 tree.default_width || 600,
2639 tree.default_height || 400
2641 this.get('view').el.show_all();
2646 showInWindow : function() {
2647 print("GET PROEJCT");
2648 var pr = this.get('/LeftProjectTree').getActiveProject();
2650 console.log(pr.paths);
2653 var src= this.buildJS(
2654 this.get('/LeftTree.model').toJS()[0],
2659 //var x = new imports.sandbox.Context();
2663 Seed.check_syntax('var e = ' + src);
2666 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2667 this.get('/Terminal').feed(console._dump(e)+"\n");
2669 var lines = src.split("\n");
2670 var start = Math.max(0, e.line - 10);
2671 var end = Math.min(lines.length, e.line + 10);
2672 for (var i =start ; i < end; i++) {
2674 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2677 this.get('/Terminal').feed(lines[i] + "\n");
2684 this.get('/BottomPane').el.set_current_page(1);
2685 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2686 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2687 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2689 var _top = x.get_global_object()._top;
2691 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2693 if (_top.el.popup) {
2694 _top.el.popup(null, null, null, null, 3, null);
2698 viewAdd : function(item, par)
2700 // does something similar to xobject..
2701 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2703 if (item.pack===false || item.pack === 'false') { // no ;
2706 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2707 var ns = imports.gi[item['|xns']];
2708 var ctr = ns[item['xtype']];
2710 for(var k in item) {
2712 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2727 if (k[0] == '|' && typeof(kv) == 'string') {
2729 if (kv.match(new RegExp('function'))) {
2732 print("WASL " + k + '=' + kv);
2734 eval( 'kv = ' + kv);
2735 } catch(e) { continue; }
2738 print(k + '=' + kv);
2740 if (k[0] == '|') { // should be boolean or number..
2743 if (k == 'show_tabs') { // force tab showing for notebooks.
2751 var el = new ctr(ctr_args);
2754 //console.dump(item.pack);
2761 if (typeof(item.pack) == 'string') {
2763 item.pack.split(',').forEach(function(e, i) {
2765 if (e == 'false') { args.push( false); return; }
2766 if (e == 'true') { args.push( true); return; }
2767 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2770 //print(args.join(","));
2772 pack_m = args.shift();
2774 pack_m = item.pack.shift();
2779 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2781 name: "ArgumentError",
2782 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2783 "ADDING : " + item.id + " " + el
2792 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2793 //Seed.print('args: ' + args.length);
2795 par[pack_m].apply(par, args);
2799 item.items = item.items || [];
2800 item.items.forEach(function(ch) {
2801 _this.viewAdd(ch, el);
2806 // add the signal handlers.
2807 // is it a widget!?!!?
2813 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2814 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2815 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2816 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2817 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2827 widgetExposeEvent : function() {
2828 /// print("WIDGET EXPOSE"); // draw highlight??
2831 widgetDragMotionEvent : function() {
2832 print("WIDGET DRAGMOTION");
2835 widgetDragDropEvent : function() {
2836 print("WIDGET DRAGDROP");
2839 widgetPressEvent : function(w,e,u,d) {
2840 if (this.get('view').pressed) {
2843 this.get('view').pressed = true;
2844 print("WIDGET PRESS " + d.xtreepath );
2845 this.get('/LeftTree.view').selectNode( d.xtreepath );
2848 widgetReleaseEvent : function() {
2849 this.get('view').pressed = false;
2855 pack : "pack_start,false,true,0",
2859 pack : "pack_start,false,false,0",
2860 label : "Run The Application",
2862 "button_press_event":function (self, event) {
2863 // call render on left tree - with special option!?!
2867 print("GET PROEJCT");
2868 var pr = this.get('/LeftProjectTree').getActiveProject();
2871 for (var i in pr.paths) {
2875 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
2876 print ("RUN DIR:" + dir);
2878 this.get('/BottomPane').el.set_current_page(1);
2879 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
2880 , false,false,false);
2881 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
2882 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2892 xtype: Gtk.ScrolledWindow,
2895 shadow_type : Gtk.ShadowType.IN,
2897 XObject.prototype.init.call(this);
2898 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2902 xtype: Gtk.EventBox,
2905 XObject.prototype.init.call(this);
2906 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
2907 red: 0x9F00, green: 0xB800 , blue : 0xA800
2915 XObject.prototype.init.call(this);
2916 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
2917 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
2922 xtype: Gtk.EventBox,
2925 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
2926 XObject.prototype.init.call(this);
2930 this.el, /* widget that will accept a drop */
2931 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2932 null, /* lists of target to support */
2933 0, /* size of list */
2934 Gdk.DragAction.COPY /* what to do with data after dropped */
2937 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2938 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2941 getActiveNode : function(x,y)
2943 // workout what node is here..
2944 return '0'; // top..
2948 "drag_motion":function (self, ctx, x, y, time) {
2950 // A) find out from drag all the places that node could be dropped.
2951 var src = Gtk.drag_get_source_widget(ctx);
2952 if (!src.dropList) {
2953 Gdk.drag_status(ctx, 0, time);
2956 // b) get what we are over.. (from activeNode)
2957 // tree is empty.. - list should be correct..
2958 if (!this.get('/LeftTree.model').currentTree) {
2959 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2963 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2964 var activeNode = this.getActiveNode(x, y);
2967 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
2970 Gdk.drag_status(ctx, 0,time);
2971 this.get('/LeftTree.view').highlight(false);
2975 // if we have a target..
2976 // -> highlight it! (in browser)
2977 // -> highlight it! (in tree)
2979 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2980 this.get('/LeftTree.view').highlight(tg);
2981 this.targetData = tg;
2982 // for tree we should handle this...
2985 "drag_drop":function (self,ctx, x, y, time) {
2986 Seed.print("TARGET: drag-drop");
2987 var is_valid_drop_site = true;
2992 self, /* will receive 'drag-data-received' signal */
2993 ctx, /* represents the current state of the this.gDnD */
2994 this.get('/Window').atoms["STRING"], /* the target type we want */
2995 time /* time stamp */
2999 /* No target offered by source => error */
3002 return is_valid_drop_site;
3005 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3007 Seed.print("GtkView: drag-data-received");
3008 var delete_selection_data = false;
3009 var dnd_success = false;
3010 /* Deal with what we are given from source */
3011 if( sel_data && sel_data.length ) {
3013 if (ctx.action == Gdk.DragAction.ASK) {
3014 /* Ask the user to move or copy, then set the ctx action. */
3017 if (ctx.action == Gdk.DragAction.MOVE) {
3018 delete_selection_data = true;
3020 var source = Gtk.drag_get_source_widget(ctx);
3022 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3023 if (this.targetData) {
3024 Seed.print(this.targetData);
3025 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3034 if (dnd_success == false)
3036 Seed.print ("DnD data transfer failed!\n");
3039 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3042 "button_press_event":function (self, event) {
3043 this.pressed = false;
3061 xtype: Gtk.Notebook,
3064 XObject.prototype.init.call(this);
3065 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3066 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3071 xtype: Gtk.ScrolledWindow,
3076 xtype: GtkSource.View,
3080 XObject.prototype.init.call(this);
3081 var description = Pango.Font.description_from_string("monospace")
3082 description.set_size(8000);
3083 this.el.modify_font(description);
3086 load : function(str) {
3087 this.get('/BottomPane').el.set_current_page(0);
3088 this.el.get_buffer().set_text(str, str.length);
3089 var lm = GtkSource.LanguageManager.get_default();
3091 this.el.get_buffer().set_language(lm.get_language('js'));
3092 var buf = this.el.get_buffer();
3093 var cursor = buf.get_mark("insert");
3094 var iter= new Gtk.TextIter;
3095 buf.get_iter_at_mark(iter, cursor);
3097 iter.set_line_offset(4);
3098 buf.move_mark(cursor, iter);
3101 cursor = buf.get_mark("selection_bound");
3102 iter= new Gtk.TextIter;
3103 buf.get_iter_at_mark(iter, cursor);
3105 iter.set_line_offset(4);
3106 buf.move_mark(cursor, iter);
3108 this.el.grab_focus();
3112 xtype: GtkSource.Buffer,
3113 pack : "set_buffer",
3115 "changed":function (self) {
3116 var s = new Gtk.TextIter();
3117 var e = new Gtk.TextIter();
3118 this.el.get_start_iter(s);
3119 this.el.get_end_iter(e);
3120 var str = this.el.get_text(s,e,true);
3122 Seed.check_syntax('var e = ' + str);
3124 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3125 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3127 print("SYNTAX ERROR IN EDITOR");
3132 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3133 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3136 this.get('/LeftPanel.model').changed( str , false);
3145 xtype: Gtk.ScrolledWindow,
3149 xtype: Vte.Terminal,
3152 feed : function(str) {
3153 this.el.feed(str,str.length);
3164 pack : "pack_start,false,false",
3168 this.get('buttonbar').el.show();
3169 this.get('viewbox').el.hide();
3170 print("TRIED TO HIDE");
3173 this.get('buttonbar').el.hide();
3174 this.get('viewbox').el.show();
3175 // this.get('model').expanded();
3187 pack : "pack_start,false,true",
3189 "clicked":function (self) {
3190 this.get('/RightPalete').show();
3197 stock : Gtk.STOCK_GOTO_FIRST,
3198 icon_size : Gtk.IconSize.MENU
3208 XObject.prototype.init.call(this);
3209 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3212 "enter_notify_event":function (self, event) {
3213 this.get('/RightPalete').show();
3227 pack : "pack_start,false,true",
3236 pack : "pack_start,false,true",
3238 "clicked":function (self) {
3239 this.get('/RightPalete').hide();
3246 stock : Gtk.STOCK_GOTO_LAST,
3247 icon_size : Gtk.IconSize.MENU
3254 xtype: Gtk.ScrolledWindow,
3257 XObject.prototype.init.call(this);
3258 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3259 this.el.set_size_request(-1,200);
3261 shadow_type : Gtk.ShadowType.IN,
3264 xtype: Gtk.TreeView,
3267 XObject.prototype.init.call(this);
3268 this.el.set_size_request(150,-1);
3269 // set_reorderable: [1]
3271 var description = new Pango.FontDescription.c_new();
3272 description.set_size(8000);
3273 this.el.modify_font(description);
3275 this.selection = this.el.get_selection();
3276 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3277 // this.selection.signal['changed'].connect(function() {
3278 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3280 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3282 Gtk.drag_source_set (
3283 this.el, /* widget will be drag-able */
3284 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3285 null, /* lists of target to support */
3286 0, /* size of list */
3287 Gdk.DragAction.COPY /* what to do with data after dropped */
3289 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3291 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3292 Gtk.drag_source_add_text_targets(this.el);
3294 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3295 targets = new Gtk.TargetList();
3296 targets.add( LeftTree.atoms["STRING"], 0, 0);
3297 targets.add_text_targets( 1 );
3298 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3300 //if you want to allow text to be output elsewhere..
3301 //Gtk.drag_source_add_text_targets(this.el);
3305 headers_visible : false,
3306 enable_tree_lines : true,
3308 "drag_begin":function (self, ctx) {
3309 // we could fill this in now...
3310 Seed.print('SOURCE: drag-begin');
3314 var iter = new Gtk.TreeIter();
3315 var s = this.selection;
3316 s.get_selected(this.get('/RightPalete.model').el, iter);
3317 var path = this.get('/RightPalete.model').el.get_path(iter);
3319 var pix = this.el.create_row_drag_icon ( path);
3322 Gtk.drag_set_icon_pixmap (ctx,
3329 var value = new GObject.Value('');
3330 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3331 if (!this.get('/RightPalete').provider) {
3334 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3335 this.el.dragData = value.value;
3342 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3343 //Seed.print('Palete: drag-data-get: ' + target_type);
3344 if (this.el.dragData && this.el.dragData.length ) {
3345 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3349 //this.el.dragData = "TEST from source widget";
3353 "drag_end":function (self, drag_context) {
3354 Seed.print('SOURCE: drag-end');
3355 this.el.dragData = false;
3356 this.el.dropList = false;
3357 this.get('/LeftTree.view').highlight(false);
3363 xtype: Gtk.ListStore,
3366 XObject.prototype.init.call(this);
3367 this.el.set_column_types ( 2, [
3368 GObject.TYPE_STRING, // title
3369 GObject.TYPE_STRING // tip
3374 load : function(tr,iter)
3379 //console.log('Project tree load: ' + tr.length);
3380 var citer = new Gtk.TreeIter();
3381 //this.insert(citer,iter,0);
3382 for(var i =0 ; i < tr.length; i++) {
3385 this.el.append(citer);
3387 this.el.insert(citer,iter,-1);
3392 this.el.set_value(citer, 0, '' + r ); // title
3394 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3395 //if (r.cn && r.cn.length) {
3396 // this.load(r.cn, citer);
3402 getValue : function (iter, col) {
3403 var gval = new GObject.Value('');
3404 this.el.get_value(iter, col ,gval);
3411 xtype: Gtk.TreeViewColumn,
3412 pack : "append_column",
3414 XObject.prototype.init.call(this);
3415 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3419 xtype: Gtk.CellRendererText,
3441 XObject.cache['/Window'] = Window;