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();
885 this.activeIter = false;
886 var iter = new Gtk.TreeIter();
887 this.el.get_iter_from_string(iter, path);
888 this.el.remove(old_iter);
890 // rebuild treemap. -- depreciated.!!
893 //this.toJS(null, true) // does not do anything?
895 this.changed(false,true);
898 listAllTypes : function() {
899 var s = this.get('/LeftTree.view').selection;
900 print ("LIST ALL TYPES: " + s.count_selected_rows() );
902 if (s.count_selected_rows() > 0) {
903 var iter = new Gtk.TreeIter();
904 s.get_selected(this.el, iter);
906 // set some properties of the tree for use by the dropped element.
907 var value = new GObject.Value('');
908 this.el.get_value(iter, 2, value);
909 var data = JSON.parse(value.value);
912 var xname = this.get('/LeftTree.model').file.guessName(data);
913 console.log('selected:' + xname);
917 return []; // could not find it..
925 li.forEach(function(el) {
926 // this is specific to roo!!!?
928 var fullpath = _this.file.guessName(el);
929 if (fullpath.length && ret.indexOf(fullpath) < 0) {
934 if (el.items && el.items.length) {
943 addall([this.currentTree]);
945 // only if we have nothing, should we add '*top'
949 //console.log('all types in tree');
955 singleNodeToJS : function (treepath)
957 var iter = new Gtk.TreeIter();
958 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
962 var iv = this.getIterValue(iter, 2);
964 return JSON.parse(iv);
967 nodeToJS : function (iter, with_id)
969 var par = new Gtk.TreeIter();
970 var iv = this.getIterValue(iter, 2);
972 var k = JSON.parse(iv);
973 if (k.json && !this.el.iter_parent( par, iter )) {
978 var treepath_str = this.el.get_path(iter).to_string();
979 // not sure how we can handle mixed id stuff..
980 if (typeof(k.id) == 'undefined') {
981 k.id = 'builder-'+ treepath_str ;
985 this.treemap[ treepath_str ] = k;
986 k.xtreepath = treepath_str ;
989 if (this.el.iter_has_child(iter)) {
990 citer = new Gtk.TreeIter();
991 this.el.iter_children(citer, iter);
992 k.items = this.toJS(citer,with_id);
996 toJS : function(iter, with_id)
998 //Seed.print("WITHID: "+ with_id);
1005 iter = new Gtk.TreeIter();
1006 if (!this.el.get_iter_first(iter)) {
1016 var k = this.nodeToJS(iter, with_id);
1020 if (!this.el.iter_next(iter)) {
1026 // convert the list into a json string..
1030 getIterValue : function (iter, col) {
1031 var gval = new GObject.Value('');
1032 this.el.get_value(iter, col ,gval);
1037 nodeTitle : function(c) {
1040 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
1041 if (sr) txt.push('<s>');
1042 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
1043 if (c.xtype) { txt.push(c.xtype); }
1044 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1045 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1046 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1049 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1050 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1051 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1052 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1053 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1054 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1055 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1056 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1057 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1059 // for flat classes...
1060 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1061 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1064 if (sr) txt.push('</s>');
1065 return (txt.length == 0 ? "Element" : txt.join(" "));
1067 nodeToJSON : function(c) {
1075 return JSON.stringify(o);
1077 load : function(tr,iter)
1079 var citer = new Gtk.TreeIter();
1080 //this.insert(citer,iter,0);
1081 for(var i =0 ; i < tr.length; i++) {
1083 this.el.insert(citer,iter,-1);
1085 this.el.append(citer);
1088 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1089 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1090 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1091 if (tr[i].items && tr[i].items.length) {
1092 this.load(tr[i].items, citer);
1098 xtype: Gtk.TreeViewColumn,
1099 pack : "append_column",
1101 XObject.prototype.init.call(this);
1102 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1106 xtype: Gtk.CellRendererText,
1116 id : "LeftTreeMenu",
1119 xtype: Gtk.MenuItem,
1121 label : "Delete Element",
1123 "activate":function (self) {
1125 this.get('/LeftTree.model').deleteSelected();
1136 id : "LeftProjectTree",
1137 showNoProjectSelected : function() {
1138 this.get('/StandardErrorDialog').show("Select a Project first.");
1140 getActiveProject : function() {
1141 return this.project;
1144 "leave_notify_event":function (self, event) {
1151 pack : "pack_start,false,false",
1154 xtype: Gtk.ComboBox,
1157 XObject.prototype.init.call(this);
1158 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1160 getValue : function() {
1161 var ix = this.el.get_active();
1165 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1168 setValue : function(fn)
1172 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1173 data.forEach(function(n, ix) {
1181 "changed":function (self) {
1182 var fn = this.getValue();
1183 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1184 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1189 xtype: Gtk.CellRendererText,
1190 pack : "pack_start,true",
1194 xtype: Gtk.ListStore,
1197 XObject.prototype.init.call(this);
1198 this.el.set_column_types ( 2, [
1199 GObject.TYPE_STRING, // real key
1200 GObject.TYPE_STRING // real type
1206 loadData : function(data) {
1207 var ov = this.get('/LeftProjectTree.combo').getValue();
1209 var iter = new Gtk.TreeIter();
1211 data.forEach(function(p) {
1216 el.set_value(iter, 0, p.fn);
1217 el.set_value(iter, 1, p.name);
1221 this.get('/LeftProjectTree.combo').setValue(ov);
1230 xtype: Gtk.ScrolledWindow,
1232 shadow_type : Gtk.ShadowType.IN,
1234 XObject.prototype.init.call(this);
1235 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1239 xtype: Gtk.TreeView,
1240 headers_visible : false,
1241 enable_tree_lines : true,
1244 XObject.prototype.init.call(this);
1245 var description = new Pango.FontDescription.c_new();
1246 description.set_size(8000);
1247 this.el.modify_font(description);
1249 this.selection = this.el.get_selection();
1250 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1254 "cursor_changed":function (self) {
1255 var iter = new Gtk.TreeIter();
1257 if (this.selection.count_selected_rows() < 1) {
1258 //XN.get('Builder.LeftTree.model').
1259 this.get('/LeftTree.model').load( false);
1263 var model = this.get('/LeftProjectTree.model');
1264 //console.log('changed');
1265 var s = this.selection;
1266 s.get_selected(model, iter);
1267 value = new GObject.Value('');
1268 model.el.get_value(iter, 2, value);
1270 console.log(value.value);// id..
1272 var file = this.get('/LeftProjectTree').project.getById(value.value);
1279 var nb = this.get('/LeftTopPanel.expander');
1280 nb.el.expanded = false;
1281 nb.listeners.activate.call(nb);
1282 //_expander.el.set_expanded(false);
1284 var ltm = this.get('/LeftTree.model');
1292 xtype: Gtk.TreeStore,
1296 XObject.prototype.init.call(this);
1297 this.el.set_column_types ( 3, [
1298 GObject.TYPE_STRING, // title
1299 GObject.TYPE_STRING, // tip
1300 GObject.TYPE_STRING // id..
1304 loadProject : function(pr) {
1309 this.get('/LeftProjectTree').project = pr;
1310 this.load(pr.toTree());
1311 this.get('/LeftProjectTree.view').el.expand_all();
1313 load : function(tr,iter) {
1315 console.log('Project tree load: ' + tr.length);
1316 var citer = new Gtk.TreeIter();
1317 //this.insert(citer,iter,0);
1320 tr.forEach(function (r) {
1322 _this.el.append(citer);
1324 _this.el.insert(citer,iter,-1);
1326 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1327 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1328 _this.el.set_value(citer, 2, '' + r.id ); //id
1329 if (r.cn && r.cn.length) {
1330 _this.load(r.cn, citer);
1335 getValue : function(iter, col) {
1336 var gval = new GObject.Value('');
1337 this.el.get_value(iter, col ,gval);
1338 return '' + gval.value;
1342 xtype: Gtk.TreeViewColumn,
1343 pack : "append_column",
1345 XObject.prototype.init.call(this);
1346 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1350 xtype: Gtk.CellRendererText,
1373 pack : "pack_start,false,true,0",
1380 "button_press_event":function (self, event) {
1381 this.get('/MidPropTree.model').showData('props');
1393 stock : Gtk.STOCK_ADD,
1394 icon_size : Gtk.IconSize.MENU
1409 "button_press_event":function (self, event) {
1410 this.get('/MidPropTree.model').showData('events');
1422 stock : Gtk.STOCK_ADD,
1423 icon_size : Gtk.IconSize.MENU
1438 "button_press_event":function (self, ev) {
1439 var p = this.get('/AddPropertyPopup');
1443 p.el.set_screen(Gdk.Screen.get_default());
1445 p.el.popup(null, null, null, null, 3, ev.button.time);
1457 stock : Gtk.STOCK_ADD,
1458 icon_size : Gtk.IconSize.MENU
1470 id : "AddPropertyPopup",
1473 xtype: Gtk.MenuItem,
1475 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1478 "activate":function (self) {
1480 this.get('/LeftPanel.model').add( {
1491 xtype: Gtk.MenuItem,
1493 tooltip_markup : "Add what type of packing is to be used",
1496 "activate":function (self) {
1498 this.get('/LeftPanel.model').add( {
1508 xtype: Gtk.MenuItem,
1510 tooltip_markup : "Override the init method",
1513 "activate":function (self) {
1515 this.get('/LeftPanel.model').add( {
1518 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1525 xtype: Gtk.SeparatorMenuItem,
1529 xtype: Gtk.MenuItem,
1531 tooltip_markup : "Add a user defined string property",
1534 "activate":function (self) {
1536 this.get('/LeftPanel.model').add( {
1546 xtype: Gtk.MenuItem,
1548 tooltip_markup : "Add a user defined number property",
1551 "activate":function (self) {
1553 this.get('/LeftPanel.model').add( {
1563 xtype: Gtk.MenuItem,
1565 tooltip_markup : "Add a user defined boolean property",
1568 "activate":function (self) {
1570 this.get('/LeftPanel.model').add( {
1580 xtype: Gtk.SeparatorMenuItem,
1584 xtype: Gtk.MenuItem,
1586 tooltip_markup : "Add a user function boolean property",
1589 "activate":function (self) {
1591 this.get('/LeftPanel.model').add( {
1594 val : "function() {\n \n}\n",
1607 xtype: Gtk.ScrolledWindow,
1610 shadow_type : Gtk.ShadowType.IN,
1613 XObject.prototype.init.call(this);
1614 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1618 xtype: Gtk.TreeView,
1621 headers_visible : false,
1622 enable_tree_lines : true,
1624 XObject.prototype.init.call(this);
1626 this.selection = this.el.get_selection();
1627 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1630 var description = new Pango.FontDescription.c_new();
1631 description.set_size(8000);
1632 this.el.modify_font(description);
1635 "button_press_event":function (self, ev) {
1639 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1640 return false; //not on a element.
1644 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1646 if (res.column.title != 'value') {
1647 return false; // ignore..
1649 if ( this.get('/LeftPanel').editing) {
1652 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1653 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1654 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1658 var provider = this.get('/LeftTree').getPaleteProvider();
1660 var opts = provider.findOptions(type);
1662 if (opts === false) {
1663 this.get('/LeftPanel').editableColumn.setOptions([]);
1664 renderer.has_entry = true;
1666 LeftPanel.editableColumn.setOptions(opts);
1667 renderer.has_entry = false;
1671 //Seed.print("click" + ev.type);
1672 //console.dump(res);
1678 if (res.column.title == 'value') {
1681 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1682 var p = this.get('/LeftPanelPopup');
1687 p.el.set_screen(Gdk.Screen.get_default());
1689 p.el.popup(null, null, null, null, 3, ev.button.time);
1690 //Seed.print("click:" + res.column.title);
1698 xtype: Gtk.TreeStore,
1702 XObject.prototype.init.call(this);
1703 this.el.set_column_types ( 5, [
1704 GObject.TYPE_STRING, // 0 real key
1705 GObject.TYPE_STRING, // 1 real value
1706 GObject.TYPE_STRING, // 2 visable key
1707 GObject.TYPE_STRING, // 3 visable value
1708 GObject.TYPE_STRING, // 4 need to store type of!!!
1712 toShort : function(str) {
1713 var a = typeof(str) == 'string' ? str.split("\n") : [];
1714 return a.length > 1 ? a[0] + '....' : '' + str;
1716 load : function(ar) {
1719 this.get('/RightEditor').el.hide();
1726 var provider = this.get('/LeftTree').getPaleteProvider();
1729 var iter = new Gtk.TreeIter();
1731 if (typeof(ar[i]) == 'object') {
1735 var type = provider.findType(ar, i, ar[i]);
1737 this.el.append(iter);
1738 var p = this.el.get_path(iter).to_string();
1740 this.el.set_value(iter, 0, i);
1741 this.el.set_value(iter, 1, '' + ar[i]);
1742 this.el.set_value(iter, 2, i);
1743 this.el.set_value(iter, 3, this.toShort(ar[i]));
1744 this.el.set_value(iter, 4, type);
1746 ar.listeners = ar.listeners || {};
1747 for (var i in ar.listeners ) {
1748 this.el.append(iter);
1749 var p = this.el.get_path(iter).to_string();
1752 this.el.set_value(iter, 0, '!'+ i );
1753 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1754 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1756 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1757 this.el.set_value(iter, 4, 'function');
1761 add : function(info) {
1762 // info includes key, val, skel, etype..
1764 type = info.type.toLowerCase();
1765 var data = this.toJS();
1767 if (info.etype == 'events') {
1768 data.listeners = data.listeners || { };
1769 if (typeof(data.listeners[info.key]) != 'undefined') {
1770 return; //already set!
1773 if (typeof(data[info.key]) != 'undefined') {
1778 if (typeof(info.val) == 'undefined') {
1781 if (info.type == 'boolean') {
1784 if (type == 'number') {
1792 if (info.etype == 'events') {
1794 data.listeners[info.key] = info.val;
1797 data[info.key] = info.val;
1801 var map = this.load(data);
1803 // flag it as changed to the interface..
1805 this.get('/LeftTree.model').changed(data, true);
1808 this.startEditing(map[k]);
1811 LeftPanel.get('view').el.row_activated(
1812 new Gtk.TreePath.from_string(map[k]),
1813 LeftPanel.editableColumn.el
1817 startEditing : function(path,col) {
1819 * start editing path (or selected if not set..)
1820 * @param {String|false} path (optional) treepath to edit - selected tree gets
1821 * edited by default.
1822 * @param {Number} 0 or 1 (optional)- column to edit.
1825 if (typeof(path) == 'string') {
1826 tp = new Gtk.TreePath.from_string(path);
1828 var iter = new Gtk.TreeIter();
1829 var s = this.get('/LeftPanel.view').selection;
1830 s.get_selected(this.el, iter);
1831 tp = this.el.get_path(iter);
1832 path = tp.to_string();
1836 // which colum is to be edited..
1838 if (typeof(col) == 'undefined') {
1839 var k = this.getValue(path, 0);
1840 colObj = (!k.length || k == '|') ?
1841 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1843 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1846 // make sure the pulldown is set correctly..
1847 // not really needed for second col...
1849 var provider = this.get('/LeftTree').getPaleteProvider();
1851 var type = this.get('/LeftPanel.model').getType(path);
1852 var opts = provider.findOptions(type);
1853 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1855 if (opts === false) {
1856 this.get('/LeftPanel').editableColumn.setOptions([]);
1857 renderer.has_entry = true; /// probably does not have any effect.
1859 this.get('/LeftPanel').editableColumn.setOptions(opts);
1860 renderer.has_entry = false;
1864 // iter now has row...
1865 GLib.timeout_add(0, 100, function() {
1867 colObj.items[0].el.editable = true; // esp. need for col 0..
1868 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1877 deleteSelected : function() {
1878 var data = this.toJS();
1879 var iter = new Gtk.TreeIter();
1880 var s = this.get('/LeftPanel.view').selection;
1881 s.get_selected(this.el, iter);
1884 var gval = new GObject.Value('');
1885 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1887 var val = gval.value;
1888 if (val[0] == '!') {
1890 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1893 delete data.listeners[ val.substring(1)];
1894 if (!XObject.keys(data.listeners).length) {
1895 delete data.listeners;
1899 if (typeof(data[val]) == 'undefined') {
1907 this.get('/LeftTree.model').changed(data, true);
1911 changed : function(str, doRefresh) {
1912 if (!this.activePath) {
1915 var iter = new Gtk.TreeIter();
1916 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1918 this.el.set_value(iter, 1, '' +str);
1919 this.el.set_value(iter, 3, '' + this.toShort(str));
1920 // update the tree...
1922 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
1925 var iter = new Gtk.TreeIter();
1926 this.get('/LeftPanel.model').el.get_iter_first(iter);
1931 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
1934 ar.listeners = ar.listeners || {};
1935 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
1938 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
1941 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
1947 //print(JSON.stringify(ar));
1951 getType : function(treepath) {
1952 return this.getValue(treepath, 4);
1954 getValue : function(treepath_str, col) {
1955 var iter = new Gtk.TreeIter();
1956 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
1958 var gval = new GObject.Value('');
1959 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
1960 var val = '' + gval.value;
1964 var type = this.getType(this.el.get_path(iter).to_string());
1965 //print("TYPE: " +type + " - val:" + val);
1966 switch(type.toLowerCase()) {
1970 return parseFloat(val); // Nan ?? invalid!!?
1972 return val == 'true' ? true : false;
1978 editSelected : function(e) {
1979 print("EDIT SELECTED?");
1980 var iter = new Gtk.TreeIter();
1981 var s = this.get('/LeftPanel.view').selection;
1982 s.get_selected(this.get('/LeftPanel.model').el, iter);
1983 var m = this.get('/LeftPanel.model')
1985 var gval = new GObject.Value('');
1986 this.el.get_value(iter, 0 ,gval);
1987 var val = '' + gval.value;
1989 gval = new GObject.Value('');
1990 this.el.get_value(iter, 1 ,gval);
1991 var rval = gval.value;
1992 var activePath = this.el.get_path(iter).to_string();
1993 this.activePath = activePath ;
1994 // was activeIter...
1997 var showEditor = false;
1999 if (val[0] == '!') {
2002 if (val[0] == '|') {
2003 if (rval.match(/function/g) || rval.match(/\n/g)) {
2010 this.activePath = false;
2011 GLib.timeout_add(0, 1, function() {
2012 // Gdk.threads_enter();
2013 _this.get('/RightEditor').el.show();
2014 _this.get('/RightEditor.view').load( rval );
2018 _this.activePath = activePath ;
2020 // Gdk.threads_leave();
2026 this.get('/RightEditor').el.hide();
2028 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2034 xtype: Gtk.TreeViewColumn,
2035 pack : "append_column",
2037 XObject.prototype.init.call(this);
2039 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2040 this.get('/LeftPanel').propertyColumn = this;
2045 xtype: Gtk.CellRendererText,
2046 pack : "pack_start",
2048 "editing_started":function (self, editable, path) {
2050 this.get('/LeftPanel.model').activePath = path;
2053 "edited":function (self, object, p0) {
2054 var model = this.get('/LeftPanel.model');
2055 var path = model.activePath;
2056 var iter = new Gtk.TreeIter();
2057 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2058 model.el.set_value(iter, 0, p0);
2059 model.el.set_value(iter, 2, p0);
2061 model.activePath = false;
2063 this.get('/LeftTree.model').changed(model.toJS(), true);
2064 this.el.editable = false;
2071 xtype: Gtk.TreeViewColumn,
2072 pack : "append_column",
2074 XObject.prototype.init.call(this);
2075 this.el.add_attribute(this.items[0].el , 'text', 3 );
2076 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2077 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2078 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2080 this.get('/LeftPanel').editableColumn= this;
2082 setOptions : function(ar) {
2083 var m = this.items[0].el.model;
2085 var iter = new Gtk.TreeIter();
2086 ar.forEach(function(i) {
2089 m.set_value(iter, 0, i);
2095 xtype: Gtk.CellRendererCombo,
2096 pack : "pack_start",
2101 XObject.prototype.init.call(this);
2102 this.el.model = new Gtk.ListStore();
2103 this.el.model.set_column_types ( 1, [
2104 GObject.TYPE_STRING // 0 real key
2108 "edited":function (self, object, p0) {
2109 this.get('/LeftPanel').editing = false;
2110 print("EDITED? p:" + p0 + " t:" + p0);
2111 this.get('/LeftPanel.model').changed(p0, true);
2112 this.get('/LeftPanel.model').activePath = false;
2114 "editing_started":function (self, editable, path) {
2115 this.get('/LeftPanel').editing = true;
2116 // console.log('editing started');
2117 // r.has_entry = false;
2118 this.get('/LeftPanel.model').editSelected(editable);
2129 id : "LeftPanelPopup",
2132 xtype: Gtk.MenuItem,
2136 "activate":function (self) {
2137 this.get('/LeftPanel.model').deleteSelected();
2142 xtype: Gtk.MenuItem,
2146 "activate":function (self) {
2147 this.get('/LeftPanel.model').startEditing(false, 0);
2160 xtype: Gtk.ScrolledWindow,
2161 pack : "pack_end,false,true,0",
2163 shadow_type : Gtk.ShadowType.IN,
2165 XObject.prototype.init.call(this);
2166 XObject.prototype.init.call(this);
2167 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2168 this.el.set_size_request ( 150, -1 );
2171 activeElement : false,
2172 hideWin : function() {
2179 if (this.get('/Window.left').el.position < 160) {
2182 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2189 xtype: Gtk.TreeView,
2190 enable_tree_lines : true,
2191 headers_visible : false,
2194 XObject.prototype.init.call(this);
2196 var description = new Pango.FontDescription.c_new();
2197 description.set_size(8000);
2198 this.el.modify_font(description);
2200 //this.selection = this.el.get_selection();
2201 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2210 "cursor_changed":function (self) {
2211 var iter = new Gtk.TreeIter();
2213 //console.log('changed');
2214 var m = this.get('model');
2215 if (!this.selection){
2216 this.selection = this.el.get_selection();
2219 var s = this.selection;
2220 if (!s.get_selected(m.el, iter)) {
2223 var tp = m.el.get_path(iter).to_string();
2228 var key = m.getValue(tp, 0);
2230 var type = m.getValue(tp, 1);
2231 var skel = m.getValue(tp, 3);
2232 var etype = m.getValue(tp, 5);
2235 this.get('/MidPropTree').hideWin();
2237 if (type == 'function') {
2239 if (etype != 'events') {
2243 this.get('/LeftPanel.model').add({
2252 if (type.indexOf('.') > -1 ||
2253 type == 'boolean') {
2257 this.get('/LeftPanel.model').add( {
2267 xtype: Gtk.ListStore,
2270 XObject.prototype.init.call(this);
2271 this.el.set_column_types ( 6, [
2272 GObject.TYPE_STRING, // real key
2273 GObject.TYPE_STRING, // real type
2274 GObject.TYPE_STRING, // docs ?
2275 GObject.TYPE_STRING, // visable desc
2276 GObject.TYPE_STRING, // function desc
2277 GObject.TYPE_STRING // element type (event|prop)
2281 getValue : function(treepath, col)
2283 var tp = new Gtk.TreePath.from_string (treepath);
2284 var iter = new Gtk.TreeIter();
2285 this.el.get_iter (iter, tp);
2286 var value = new GObject.Value('');
2287 this.el.get_value(iter, col, value);
2291 showData : function(type) {
2293 if (!this.get('/MidPropTree').activeElement || !type) {
2294 return; // no active element
2297 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2298 var palete = this.get('/LeftTree').getPaleteProvider();
2302 Seed.print('Showing right?');
2303 if (!this.get('/MidPropTree').shown) {
2305 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2306 this.get('/MidPropTree').el.show();
2307 this.get('/MidPropTree').shown = true;
2310 var elementList = palete.getPropertiesFor(fullpath, type);
2311 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2312 // console.dump(elementList);
2315 var iter = new Gtk.TreeIter();
2316 for(var i =0 ; i < elementList.length; i++) {
2317 var p=elementList[i];
2318 this.el.append(iter);
2319 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2320 //GObject.TYPE_STRING, // real key
2321 // GObject.TYPE_STRING, // real type
2322 // GObject.TYPE_STRING, // docs ?
2323 // GObject.TYPE_STRING // func def?
2326 this.el.set_value(iter, 0, p.name);
2327 this.el.set_value(iter, 1, p.type);
2328 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2329 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2330 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2331 this.el.set_value(iter, 5, type);
2339 xtype: Gtk.TreeViewColumn,
2341 this.el = new Gtk.TreeViewColumn();
2342 this.parent.el.append_column(this.el);
2344 XObject.prototype.init.call(this);
2345 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2350 xtype: Gtk.CellRendererText,
2351 pack : "pack_start,true"
2375 xtype: Gtk.Notebook,
2376 pack : "pack_start,true,true",
2377 id : "view-notebook",
2380 XObject.prototype.init.call(this);
2381 this.el.set_current_page(0);
2383 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2384 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2391 id : "RightBrowser",
2395 pack : "pack_start,false,true,0",
2399 pack : "pack_start,false,false,0",
2400 label : "Dump HTML to console",
2402 "activate":function (self) {
2403 this.get('/RightBrowser.view').el.execute_script(
2404 "console.log(document.body.innerHTML);");
2405 this.get('/RightBrowser.view').el.execute_script(
2406 "console.log(Builder.dump(Builder));");
2413 xtype: Gtk.ScrolledWindow,
2415 shadow_type : Gtk.ShadowType.IN,
2417 XObject.prototype.init.call(this);
2418 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2422 xtype: WebKit.WebView,
2426 XObject.prototype.init.call(this);
2427 // this may not work!?
2428 this.el.open('file:///' + __script_path__ + '/../builder.html');
2432 this.el, /* widget that will accept a drop */
2433 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2434 null, /* lists of target to support */
2435 0, /* size of list */
2436 Gdk.DragAction.COPY /* what to do with data after dropped */
2439 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2440 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2442 renderJS : function(data) {
2443 this.renderedData = data;
2444 var str = JSON.stringify(data) ;
2447 console.log('not loaded yet');
2449 Seed.print("RENDER:" + str);
2450 imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2451 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2454 "load_finished":function (self, object) {
2455 if (this.ready) { // dont do it twice!
2460 this.renderJS(this.get('/LeftTree.model').toJS()[0]);
2462 "script_alert":function (self, object, p0) {
2465 return true; // do not display anything...
2467 "console_message":function (self, object, p0, p1) {
2468 console.log(object);
2469 if (!object.match(/^\{/)) {
2470 return false; // do not handle!!! -> later maybe in console..
2472 console.log(object);
2473 var val = JSON.parse(object);
2475 if (typeof(val['hover-node']) != 'undefined') {
2476 this.activeNode = val['hover-node'];
2477 console.log('active node: ' + this.activeNode);
2482 if (typeof(val['id']) != 'undefined') {
2483 // this.activeNode = val['id'];
2484 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2488 this.get('/LeftTree.view').selectNode(tg[0]);
2492 if (ret && typeof(val['set']) != 'undefined') {
2493 this.get('/LeftPanel.model').add({
2497 //console.log('active node: ' + this.activeNode);
2500 //Seed.print('a:'+a);
2501 //Seed.print('b:'+b);
2502 //Seed.print('c:'+c);
2505 "drag_motion":function (w, ctx, x, y, time, ud) {
2506 // console.log('DRAG MOTION');
2508 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2509 this.targetData = [];
2510 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2512 // A) find out from drag all the places that node could be dropped.
2513 var src = Gtk.drag_get_source_widget(ctx);
2514 if (!src.dropList) {
2515 Gdk.drag_status(ctx, 0, time);
2518 // b) get what we are over.. (from activeNode)
2519 // tree is empty.. - list should be correct..
2520 if (!this.get('/LeftTree.model').currentTree) {
2521 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2525 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2527 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2530 Gdk.drag_status(ctx, 0,time);
2531 this.get('/LeftTree.view').highlight(false);
2535 // if we have a target..
2536 // -> highlight it! (in browser)
2537 // -> highlight it! (in tree)
2539 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2540 this.get('/LeftTree.view').highlight(tg);
2541 this.targetData = tg;
2542 // for tree we should handle this...
2545 "drag_drop":function (w, ctx, x, y,time, ud) {
2546 print("TARGET: drag-drop");
2547 var is_valid_drop_site = true;
2552 w, /* will receive 'drag-data-received' signal */
2553 ctx, /* represents the current state of the DnD */
2554 this.get('/Window').atoms["STRING"], /* the target type we want */
2555 time /* time stamp */
2559 /* No target offered by source => error */
2562 return is_valid_drop_site;
2564 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2566 print("Browser: drag-data-received");
2567 var delete_selection_data = false;
2568 vardnd_success = false;
2569 /* Deal with what we are given from source */
2570 if( sel_data && sel_data.length ) {
2572 if (ctx.action == Gdk.DragAction.ASK) {
2573 /* Ask the user to move or copy, then set the ctx action. */
2576 if (ctx.action == Gdk.DragAction.MOVE) {
2577 delete_selection_data = true;
2579 var source = Gtk.drag_get_source_widget(ctx);
2581 print("Browser: source.DRAGDATA? " + source.dragData);
2582 if (this.targetData) {
2583 print(this.targetData);
2584 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2593 if (dnd_success == false)
2595 Seed.print ("DnD data transfer failed!\n");
2598 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2610 id : "RightGtkView",
2611 renderJS : function(data, withDebug)
2616 this.withDebug = false;
2618 if (this.renderedEl) {
2619 this.get('view').el.remove(this.renderedEl);
2620 this.renderedEl.destroy();
2621 this.renderedEl = false;
2624 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2625 // in theory tree is actually window..
2627 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2632 this.get('view').el.set_size_request(
2633 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2636 this.renderedEl.set_size_request(
2637 tree.default_width || 600,
2638 tree.default_height || 400
2640 this.get('view').el.show_all();
2645 showInWindow : function() {
2646 print("GET PROEJCT");
2647 var pr = this.get('/LeftProjectTree').getActiveProject();
2649 console.log(pr.paths);
2652 var src= this.buildJS(
2653 this.get('/LeftTree.model').toJS()[0],
2658 //var x = new imports.sandbox.Context();
2662 Seed.check_syntax('var e = ' + src);
2665 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2666 this.get('/Terminal').feed(console._dump(e)+"\n");
2668 var lines = src.split("\n");
2669 var start = Math.max(0, e.line - 10);
2670 var end = Math.min(lines.length, e.line + 10);
2671 for (var i =start ; i < end; i++) {
2673 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2676 this.get('/Terminal').feed(lines[i] + "\n");
2683 this.get('/BottomPane').el.set_current_page(1);
2684 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2685 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2686 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2688 var _top = x.get_global_object()._top;
2690 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2692 if (_top.el.popup) {
2693 _top.el.popup(null, null, null, null, 3, null);
2697 viewAdd : function(item, par)
2699 // does something similar to xobject..
2700 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2702 if (item.pack===false || item.pack === 'false') { // no ;
2705 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2706 var ns = imports.gi[item['|xns']];
2707 var ctr = ns[item['xtype']];
2709 for(var k in item) {
2711 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2726 if (k[0] == '|' && typeof(kv) == 'string') {
2728 if (kv.match(new RegExp('function'))) {
2731 print("WASL " + k + '=' + kv);
2733 eval( 'kv = ' + kv);
2734 } catch(e) { continue; }
2737 print(k + '=' + kv);
2739 if (k[0] == '|') { // should be boolean or number..
2742 if (k == 'show_tabs') { // force tab showing for notebooks.
2750 var el = new ctr(ctr_args);
2753 //console.dump(item.pack);
2760 if (typeof(item.pack) == 'string') {
2762 item.pack.split(',').forEach(function(e, i) {
2764 if (e == 'false') { args.push( false); return; }
2765 if (e == 'true') { args.push( true); return; }
2766 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2769 //print(args.join(","));
2771 pack_m = args.shift();
2773 pack_m = item.pack.shift();
2778 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2780 name: "ArgumentError",
2781 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2782 "ADDING : " + item.id + " " + el
2791 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2792 //Seed.print('args: ' + args.length);
2794 par[pack_m].apply(par, args);
2798 item.items = item.items || [];
2799 item.items.forEach(function(ch) {
2800 _this.viewAdd(ch, el);
2805 // add the signal handlers.
2806 // is it a widget!?!!?
2812 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2813 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2814 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2815 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2816 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2826 widgetExposeEvent : function() {
2827 /// print("WIDGET EXPOSE"); // draw highlight??
2830 widgetDragMotionEvent : function() {
2831 print("WIDGET DRAGMOTION");
2834 widgetDragDropEvent : function() {
2835 print("WIDGET DRAGDROP");
2838 widgetPressEvent : function(w,e,u,d) {
2839 if (this.get('view').pressed) {
2842 this.get('view').pressed = true;
2843 print("WIDGET PRESS " + d.xtreepath );
2844 this.get('/LeftTree.view').selectNode( d.xtreepath );
2847 widgetReleaseEvent : function() {
2848 this.get('view').pressed = false;
2854 pack : "pack_start,false,true,0",
2858 pack : "pack_start,false,false,0",
2859 label : "Run The Application",
2861 "button_press_event":function (self, event) {
2862 // call render on left tree - with special option!?!
2866 print("GET PROEJCT");
2867 var pr = this.get('/LeftProjectTree').getActiveProject();
2870 for (var i in pr.paths) {
2874 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
2875 print ("RUN DIR:" + dir);
2877 this.get('/BottomPane').el.set_current_page(1);
2878 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
2879 , false,false,false);
2880 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
2881 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2891 xtype: Gtk.ScrolledWindow,
2894 shadow_type : Gtk.ShadowType.IN,
2896 XObject.prototype.init.call(this);
2897 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2901 xtype: Gtk.EventBox,
2904 XObject.prototype.init.call(this);
2905 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
2906 red: 0x9F00, green: 0xB800 , blue : 0xA800
2914 XObject.prototype.init.call(this);
2915 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
2916 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
2921 xtype: Gtk.EventBox,
2924 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
2925 XObject.prototype.init.call(this);
2929 this.el, /* widget that will accept a drop */
2930 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2931 null, /* lists of target to support */
2932 0, /* size of list */
2933 Gdk.DragAction.COPY /* what to do with data after dropped */
2936 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2937 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2940 getActiveNode : function(x,y)
2942 // workout what node is here..
2943 return '0'; // top..
2947 "drag_motion":function (self, ctx, x, y, time) {
2949 // A) find out from drag all the places that node could be dropped.
2950 var src = Gtk.drag_get_source_widget(ctx);
2951 if (!src.dropList) {
2952 Gdk.drag_status(ctx, 0, time);
2955 // b) get what we are over.. (from activeNode)
2956 // tree is empty.. - list should be correct..
2957 if (!this.get('/LeftTree.model').currentTree) {
2958 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2962 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2963 var activeNode = this.getActiveNode(x, y);
2966 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
2969 Gdk.drag_status(ctx, 0,time);
2970 this.get('/LeftTree.view').highlight(false);
2974 // if we have a target..
2975 // -> highlight it! (in browser)
2976 // -> highlight it! (in tree)
2978 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2979 this.get('/LeftTree.view').highlight(tg);
2980 this.targetData = tg;
2981 // for tree we should handle this...
2984 "drag_drop":function (self,ctx, x, y, time) {
2985 Seed.print("TARGET: drag-drop");
2986 var is_valid_drop_site = true;
2991 self, /* will receive 'drag-data-received' signal */
2992 ctx, /* represents the current state of the this.gDnD */
2993 this.get('/Window').atoms["STRING"], /* the target type we want */
2994 time /* time stamp */
2998 /* No target offered by source => error */
3001 return is_valid_drop_site;
3004 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3006 Seed.print("GtkView: drag-data-received");
3007 var delete_selection_data = false;
3008 var dnd_success = false;
3009 /* Deal with what we are given from source */
3010 if( sel_data && sel_data.length ) {
3012 if (ctx.action == Gdk.DragAction.ASK) {
3013 /* Ask the user to move or copy, then set the ctx action. */
3016 if (ctx.action == Gdk.DragAction.MOVE) {
3017 delete_selection_data = true;
3019 var source = Gtk.drag_get_source_widget(ctx);
3021 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3022 if (this.targetData) {
3023 Seed.print(this.targetData);
3024 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3033 if (dnd_success == false)
3035 Seed.print ("DnD data transfer failed!\n");
3038 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3041 "button_press_event":function (self, event) {
3042 this.pressed = false;
3060 xtype: Gtk.Notebook,
3063 XObject.prototype.init.call(this);
3064 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3065 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3070 xtype: Gtk.ScrolledWindow,
3075 xtype: GtkSource.View,
3079 XObject.prototype.init.call(this);
3080 var description = Pango.Font.description_from_string("monospace")
3081 description.set_size(8000);
3082 this.el.modify_font(description);
3085 load : function(str) {
3086 this.get('/BottomPane').el.set_current_page(0);
3087 this.el.get_buffer().set_text(str, str.length);
3088 var lm = GtkSource.LanguageManager.get_default();
3090 this.el.get_buffer().set_language(lm.get_language('js'));
3091 var buf = this.el.get_buffer();
3092 var cursor = buf.get_mark("insert");
3093 var iter= new Gtk.TextIter;
3094 buf.get_iter_at_mark(iter, cursor);
3096 iter.set_line_offset(4);
3097 buf.move_mark(cursor, iter);
3100 cursor = buf.get_mark("selection_bound");
3101 iter= new Gtk.TextIter;
3102 buf.get_iter_at_mark(iter, cursor);
3104 iter.set_line_offset(4);
3105 buf.move_mark(cursor, iter);
3107 this.el.grab_focus();
3111 xtype: GtkSource.Buffer,
3112 pack : "set_buffer",
3114 "changed":function (self) {
3115 var s = new Gtk.TextIter();
3116 var e = new Gtk.TextIter();
3117 this.el.get_start_iter(s);
3118 this.el.get_end_iter(e);
3119 var str = this.el.get_text(s,e,true);
3121 Seed.check_syntax('var e = ' + str);
3123 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3124 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3126 print("SYNTAX ERROR IN EDITOR");
3131 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3132 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3135 this.get('/LeftPanel.model').changed( str , false);
3144 xtype: Gtk.ScrolledWindow,
3148 xtype: Vte.Terminal,
3151 feed : function(str) {
3152 this.el.feed(str,str.length);
3163 pack : "pack_start,false,false",
3167 this.get('buttonbar').el.show();
3168 this.get('viewbox').el.hide();
3169 print("TRIED TO HIDE");
3172 this.get('buttonbar').el.hide();
3173 this.get('viewbox').el.show();
3174 // this.get('model').expanded();
3186 pack : "pack_start,false,true",
3188 "clicked":function (self) {
3189 this.get('/RightPalete').show();
3196 stock : Gtk.STOCK_GOTO_FIRST,
3197 icon_size : Gtk.IconSize.MENU
3207 XObject.prototype.init.call(this);
3208 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3211 "enter_notify_event":function (self, event) {
3212 this.get('/RightPalete').show();
3226 pack : "pack_start,false,true",
3235 pack : "pack_start,false,true",
3237 "clicked":function (self) {
3238 this.get('/RightPalete').hide();
3245 stock : Gtk.STOCK_GOTO_LAST,
3246 icon_size : Gtk.IconSize.MENU
3253 xtype: Gtk.ScrolledWindow,
3256 XObject.prototype.init.call(this);
3257 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3258 this.el.set_size_request(-1,200);
3260 shadow_type : Gtk.ShadowType.IN,
3263 xtype: Gtk.TreeView,
3266 XObject.prototype.init.call(this);
3267 this.el.set_size_request(150,-1);
3268 // set_reorderable: [1]
3270 var description = new Pango.FontDescription.c_new();
3271 description.set_size(8000);
3272 this.el.modify_font(description);
3274 this.selection = this.el.get_selection();
3275 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3276 // this.selection.signal['changed'].connect(function() {
3277 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3279 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3281 Gtk.drag_source_set (
3282 this.el, /* widget will be drag-able */
3283 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3284 null, /* lists of target to support */
3285 0, /* size of list */
3286 Gdk.DragAction.COPY /* what to do with data after dropped */
3288 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3290 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3291 Gtk.drag_source_add_text_targets(this.el);
3293 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3294 targets = new Gtk.TargetList();
3295 targets.add( LeftTree.atoms["STRING"], 0, 0);
3296 targets.add_text_targets( 1 );
3297 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3299 //if you want to allow text to be output elsewhere..
3300 //Gtk.drag_source_add_text_targets(this.el);
3304 headers_visible : false,
3305 enable_tree_lines : true,
3307 "drag_begin":function (self, ctx) {
3308 // we could fill this in now...
3309 Seed.print('SOURCE: drag-begin');
3313 var iter = new Gtk.TreeIter();
3314 var s = this.selection;
3315 s.get_selected(this.get('/RightPalete.model').el, iter);
3316 var path = this.get('/RightPalete.model').el.get_path(iter);
3318 var pix = this.el.create_row_drag_icon ( path);
3321 Gtk.drag_set_icon_pixmap (ctx,
3328 var value = new GObject.Value('');
3329 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3330 if (!this.get('/RightPalete').provider) {
3333 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3334 this.el.dragData = value.value;
3341 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3342 //Seed.print('Palete: drag-data-get: ' + target_type);
3343 if (this.el.dragData && this.el.dragData.length ) {
3344 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3348 //this.el.dragData = "TEST from source widget";
3352 "drag_end":function (self, drag_context) {
3353 Seed.print('SOURCE: drag-end');
3354 this.el.dragData = false;
3355 this.el.dropList = false;
3356 this.get('/LeftTree.view').highlight(false);
3362 xtype: Gtk.ListStore,
3365 XObject.prototype.init.call(this);
3366 this.el.set_column_types ( 2, [
3367 GObject.TYPE_STRING, // title
3368 GObject.TYPE_STRING // tip
3373 load : function(tr,iter)
3378 //console.log('Project tree load: ' + tr.length);
3379 var citer = new Gtk.TreeIter();
3380 //this.insert(citer,iter,0);
3381 for(var i =0 ; i < tr.length; i++) {
3384 this.el.append(citer);
3386 this.el.insert(citer,iter,-1);
3391 this.el.set_value(citer, 0, '' + r ); // title
3393 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3394 //if (r.cn && r.cn.length) {
3395 // this.load(r.cn, citer);
3401 getValue : function (iter, col) {
3402 var gval = new GObject.Value('');
3403 this.el.get_value(iter, col ,gval);
3410 xtype: Gtk.TreeViewColumn,
3411 pack : "append_column",
3413 XObject.prototype.init.call(this);
3414 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3418 xtype: Gtk.CellRendererText,
3440 XObject.cache['/Window'] = Window;