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));
318 "button_press_event":function (self, ev) {
319 console.log("button press?");
320 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
321 print("click" + ev.type);
327 this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
329 if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();
331 this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
332 this.get('/LeftTreeMenu').el.show_all();
333 this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
334 print("click:" + res.path.to_string());
337 "drag_begin":function (self, drag_context) {
338 print('SOURCE: drag-begin');
339 this.targetData = false;
340 // find what is selected in our tree...
341 var iter = new Gtk.TreeIter();
342 var s = this.selection;
343 s.get_selected(this.get('/LeftTree.model').el, iter);
345 // set some properties of the tree for use by the dropped element.
346 var value = new GObject.Value('');
347 this.get('/LeftTree.model').el.get_value(iter, 2, value);
348 var data = JSON.parse(value.value);
349 var xname = this.get('/LeftTree.model').file.guessName(data);
351 this.el.dragData = xname;
352 this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);
355 // make the drag icon a picture of the node that was selected
356 var path = this.get('/LeftTree.model').el.get_path(iter);
357 this.el.treepath = path.to_string();
359 var pix = this.el.create_row_drag_icon ( path);
361 Gtk.drag_set_icon_pixmap (ctx,
370 "drag_end":function (self, drag_context) {
371 Seed.print('LEFT-TREE: drag-end');
372 this.el.dragData = false;
373 this.el.dropList = false;
374 this.targetData = false;
375 this.get('/LeftTree.view').highlight(false);
378 "drag_motion":function (self, ctx, x, y, time) {
379 console.log("LEFT-TREE: drag-motion");
380 var src = Gtk.drag_get_source_widget(ctx);
382 // a drag from elsewhere...- prevent drop..
384 print("no drag data!");
385 Gdk.drag_status(ctx, 0, time);
386 this.targetData = false;
389 var action = Gdk.DragAction.COPY;
390 if (src == this.el) {
391 // unless we are copying!!! ctl button..
392 action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
396 if (!this.get('/LeftTree.model').el.iter_n_children(null)) {
397 // no children.. -- asume it's ok..
398 this.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];
399 Gdk.drag_status(ctx, action ,time);
403 print("GETTING POS");
404 var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);
405 print("ISOVER? " + isOver);
407 Gdk.drag_status(ctx, 0 ,time);
408 return false; // not over apoint!?!
410 // drag node is parent of child..
411 console.log("SRC TREEPATH: " + src.treepath);
412 console.log("TARGET TREEPATH: " + data.path.to_string());
414 // nned to check a few here..
415 //Gtk.TreeViewDropPosition.INTO_OR_AFTER
416 //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
417 //Gtk.TreeViewDropPosition.AFTER
418 //Gtk.TreeViewDropPosition.BEFORE
420 if (typeof(src.treepath) != 'undefined' &&
421 src.treepath == data.path.to_string().substring(0,src.treepath.length)) {
422 print("subpath drag");
423 Gdk.drag_status(ctx, 0 ,time);
428 //print("DUMPING DATA");
429 //console.dump(data);
432 print(data.path.to_string() +' => '+ data.pos);
433 var tg = this.get('/LeftTree.model').findDropNodeByPath(
434 data.path.to_string(), src.dropList, data.pos);
436 this.get('/LeftTree.view').highlight(tg);
438 print("Can not find drop node path");
439 this.targetData = false;
440 Gdk.drag_status(ctx, 0, time);
444 this.targetData = tg;
447 Gdk.drag_status(ctx, action ,time);
451 "drag_drop":function (w, ctx, x, y, time) {
452 Seed.print("TARGET: drag-drop");
456 w, /* will receive 'drag-data-received' signal */
457 ctx, /* represents the current state of the DnD */
458 this.get('/Window').atoms["STRING"], /* the target type we want */
459 time /* time stamp */
463 /* No target offered by source => error */
468 "drag_data_received":function (self, ctx, x, y, sel_data, info, time) {
469 print("Tree: drag-data-received");
471 var delete_selection_data = false;
472 var dnd_success = false;
473 /* Deal with what we are given from source */
474 if( sel_data && sel_data.length ) {
476 if (ctx.action == Gdk.DragAction.ASK) {
477 /* Ask the user to move or copy, then set the ctx action. */
480 if (ctx.action == Gdk.DragAction.MOVE) {
481 //delete_selection_data = true;
484 var source = Gtk.drag_get_source_widget(ctx);
486 if (this.targetData) {
487 if (source != this.el) {
488 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
490 // drag around.. - reorder..
491 this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);
495 //Seed.print(this.targetData);
501 // we can send stuff to souce here...
507 if (dnd_success == false)
509 Seed.print ("DnD data transfer failed!\n");
512 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
515 "cursor_changed":function (self) {
516 var iter = new Gtk.TreeIter();
518 if (this.selection.count_selected_rows() < 1) {
519 this.get('/LeftPanel.model').load( false);
520 this.get('/MidPropTree').activeElement = false;
521 this.get('/MidPropTree').hideWin();
523 var pm = this.get('/RightPalete.model');
524 if (!this.get('/LeftTree').getPaleteProvider()) {
525 // it may not be loaded yet..
528 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
529 this.get('/LeftTree.model').listAllTypes()));
534 //console.log('changed');
535 var s = this.selection;
536 s.get_selected(this.get('/LeftTree.model').el, iter);
540 value = new GObject.Value('');
541 this.get('/LeftTree.model').el.get_value(iter, 2, value);
542 this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
544 var data = JSON.parse(value.value);
545 this.get('/MidPropTree').activeElement = data;
546 this.get('/MidPropTree').hideWin();
547 this.get('/LeftPanel.model').load( data);
549 console.log(value.value);
550 // _g.button.set_label(''+value.get_string());
552 var pm =this.get('/RightPalete.model');
553 pm.load( this.get('/RightPalete').provider.gatherList(
554 this.get('/LeftTree.model').listAllTypes()));
559 //Seed.print( value.get_string());
566 xtype: Gtk.TreeStore,
570 XObject.prototype.init.call(this);
571 this.el.set_column_types ( 3, [
572 GObject.TYPE_STRING, // title
573 GObject.TYPE_STRING, // tip
574 GObject.TYPE_STRING // source..
578 changed : function(n, refresh) {
579 print("MODEL CHANGED CALLED" + this.activePath);
580 if (this.activePath) {
581 var iter = new Gtk.TreeIter();
582 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
583 this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
584 this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
586 this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
588 //this.currentTree = this.toJS(false, true)[0];
589 this.file.items = this.toJS(false, false);
590 print("AFTER CHANGED");
591 //console.dump(this.file.items);
593 this.currentTree = this.file.items[0];
594 //console.log(this.file.toSource());
597 print("REDNER BROWSER?!");
598 this.get('/LeftTree').renderView();
600 var pm = this.get('/RightPalete.model');
601 if (!this.get('/RightPalete').provider) {
607 pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
608 //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
612 loadFile : function(f) {
618 console.log('missing file');
622 // load the file if not loaded..
623 if (f.items === false) {
625 f.loadItems(function() {
631 if (f.items.length && typeof(f.items[0]) == 'string') {
633 this.get('/RightEditor').el.show();
634 this.get('/RightEditor.view').load( f.items[0]);
638 //console.dump(f.items);
640 this.get('/LeftTree.view').el.expand_all();
642 if (!f.items.length) {
645 this.get('/Window.leftvpaned').el.set_position(80);
647 this.get('/LeftTree.view').el.set_cursor(
648 new Gtk.TreePath.from_string('0'), null, false);
652 this.get('/Window.leftvpaned').el.set_position(200);
656 //print("hide right editior");
657 this.get('/RightEditor').el.hide();
658 //print("set current tree");
659 this.currentTree = this.toJS(false, false)[0];
660 //console.dump(this.currentTree);
661 this.currentTree = this.currentTree || { items: [] };
662 this.get('/LeftTree').renderView();
663 //console.dump(this.map);
664 //var RightPalete = imports.Builder.RightPalete.RightPalete;
665 var pm = this.get('/RightPalete.model');
668 this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
670 if (!this.get('/RightPalete').provider) {
671 print ("********* PALETE PROVIDER MISSING?!!");
673 this.get('/LeftTree').renderView();
675 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
679 this.get('/Window.view-notebook').el.set_current_page(
680 this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
683 findDropNode : function(treepath_str, targets) {
685 // this is used by the dragdrop code in the roo version AFAIR..
687 var path = treepath_str.replace(/^builder-/, '');
688 // treemap is depreciated... - should really check if model has any entries..
690 if (!this.el.iter_n_children(null)) {
692 return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];
694 print("FIND treepath: " + path);
695 //console.dump(this.treemap);
697 if (!treepath_str.match(/^builder-/)) {
698 return []; // nothing!
700 if (targets === true) {
703 return this.findDropNodeByPath(path,targets)
705 findDropNodeByPath : function(treepath_str, targets, pref) {
706 var path = treepath_str + ''; // dupe it..
707 pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
709 //console.dump(this.treemap);
710 while (path.length) {
711 print("LOOKING FOR PATH: " + path);
712 var node_data = this.singleNodeToJS(path);
713 if (node_data === false) {
714 print("node not found");
718 var xname = this.get('/LeftTree.model').file.guessName(node_data);
721 targets.forEach(function(tg) {
725 if ((tg == xname) ) {
728 if (tg.indexOf(xname +':') === 0) {
730 prop = tg.split(':').pop();
735 if (last) { // pref is after/before..
736 // then it's after last
738 return []; // do not allow..
740 return [ last, pref , prop];
743 return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
745 var par = path.split(':');
748 path = par.join(':');
754 dropNode : function(target_data, node) {
757 console.dump(target_data);
758 var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
760 print("add " + tp + "@" + target_data[1] );
763 if (tp && target_data[1] < 2) { // before or after..
764 var ar = target_data[0].split(':');
766 parent = new Gtk.TreePath.from_string( ar.join(':') );
769 var n_iter = new Gtk.TreeIter();
770 var iter_par = new Gtk.TreeIter();
771 var iter_after = after ? new Gtk.TreeIter() : false;
775 if (parent !== false) {
776 this.el.get_iter(iter_par, parent);
783 print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
784 this.el.get_iter(iter_after, after);
785 this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
786 n_iter, iter_par, iter_after);
789 this.el.append(n_iter, iter_par);
793 if (typeof(node) == 'string') {
794 var ar = node.split('.');
795 var xtype = ar.pop();
798 '|xns' : ar.join('.'),
801 if (target_data.length == 3 && target_data[2].length) {
802 node['*prop'] = target_data[2];
806 // work out what kind of packing to use..
807 if (typeof(node.pack) == 'undefined' && parent !== false) {
808 var pal = this.get('/LeftTree').getPaleteProvider();
810 var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
811 print ("PNAME : " + pname);
812 var cname = pal.guessName(node);
813 print ("CNAME : " + cname);
814 node.pack = pal.getDefaultPack(pname, cname);
825 // load children - if it has any..
828 this.load(xitems, n_iter);
830 if (tp && (xitems || after)) {
831 this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
833 // wee need to get the empty proptypes from somewhere..
835 //var olditer = this.activeIter;
836 this.activePath = this.el.get_path(n_iter).to_string();
838 // changed actually set's the node data..
839 this.changed(node, true);
843 this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
845 //Builder.MidPropTree._model.load(node);
846 //Builder.MidPropTree._win.hideWin();
847 //Builder.LeftPanel._model.load( node);
851 moveNode : function(target_data, action) {
852 //print("MOVE NODE");
853 // console.dump(target_data);
854 var old_iter = new Gtk.TreeIter();
855 var s = this.get('/LeftTree.view').selection;
856 s.get_selected(this.el, old_iter);
857 var node = this.nodeToJS(old_iter,false);
858 //console.dump(node);
861 // needs to drop first, otherwise the target_data
862 // treepath will be invalid.
864 this.dropNode(target_data, node);
865 if (action & Gdk.DragAction.MOVE) {
866 // print("REMOVING OLD NODE");
867 this.el.remove(old_iter);
871 this.activeIter = false;
872 this.changed(false,true);
874 deleteSelected : function() {
876 var old_iter = new Gtk.TreeIter();
877 var s = this.get('/LeftTree.view').selection;
878 s.get_selected(this.el, old_iter);
881 this.el.remove(old_iter);
883 // rebuild treemap. -- depreciated.!!
886 //this.toJS(null, true) // does not do anything?
887 this.activeIter = false;
888 this.changed(false,true);
891 listAllTypes : function() {
892 var s = this.get('/LeftTree.view').selection;
893 print ("LIST ALL TYPES: " + s.count_selected_rows() );
895 if (s.count_selected_rows() > 0) {
896 var iter = new Gtk.TreeIter();
897 s.get_selected(this.el, iter);
899 // set some properties of the tree for use by the dropped element.
900 var value = new GObject.Value('');
901 this.el.get_value(iter, 2, value);
902 var data = JSON.parse(value.value);
905 var xname = this.get('/LeftTree.model').file.guessName(data);
906 console.log('selected:' + xname);
910 return []; // could not find it..
918 li.forEach(function(el) {
919 // this is specific to roo!!!?
921 var fullpath = _this.file.guessName(el);
922 if (fullpath.length && ret.indexOf(fullpath) < 0) {
927 if (el.items && el.items.length) {
936 addall([this.currentTree]);
938 // only if we have nothing, should we add '*top'
942 //console.log('all types in tree');
948 singleNodeToJS : function (treepath)
950 var iter = new Gtk.TreeIter();
951 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
955 var iv = this.getIterValue(iter, 2);
957 return JSON.parse(iv);
960 nodeToJS : function (iter, with_id)
962 var par = new Gtk.TreeIter();
963 var iv = this.getIterValue(iter, 2);
965 var k = JSON.parse(iv);
966 if (k.json && !this.el.iter_parent( par, iter )) {
971 var treepath_str = this.el.get_path(iter).to_string();
972 // not sure how we can handle mixed id stuff..
973 if (typeof(k.id) == 'undefined') {
974 k.id = 'builder-'+ treepath_str ;
978 this.treemap[ treepath_str ] = k;
979 k.xtreepath = treepath_str ;
982 if (this.el.iter_has_child(iter)) {
983 citer = new Gtk.TreeIter();
984 this.el.iter_children(citer, iter);
985 k.items = this.toJS(citer,with_id);
989 toJS : function(iter, with_id)
991 //Seed.print("WITHID: "+ with_id);
998 iter = new Gtk.TreeIter();
999 if (!this.el.get_iter_first(iter)) {
1009 var k = this.nodeToJS(iter, with_id);
1013 if (!this.el.iter_next(iter)) {
1019 // convert the list into a json string..
1023 getIterValue : function (iter, col) {
1024 var gval = new GObject.Value('');
1025 this.el.get_value(iter, col ,gval);
1030 nodeTitle : function(c) {
1033 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
1034 if (sr) txt.push('<s>');
1035 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
1036 if (c.xtype) { txt.push(c.xtype); }
1037 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1038 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1039 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1042 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1043 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1044 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1045 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1046 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1047 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1048 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1049 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1050 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1052 // for flat classes...
1053 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1054 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1057 if (sr) txt.push('</s>');
1058 return (txt.length == 0 ? "Element" : txt.join(" "));
1060 nodeToJSON : function(c) {
1068 return JSON.stringify(o);
1070 load : function(tr,iter)
1072 var citer = new Gtk.TreeIter();
1073 //this.insert(citer,iter,0);
1074 for(var i =0 ; i < tr.length; i++) {
1076 this.el.insert(citer,iter,-1);
1078 this.el.append(citer);
1081 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1082 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1083 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1084 if (tr[i].items && tr[i].items.length) {
1085 this.load(tr[i].items, citer);
1091 xtype: Gtk.TreeViewColumn,
1092 pack : "append_column",
1094 XObject.prototype.init.call(this);
1095 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1099 xtype: Gtk.CellRendererText,
1109 id : "LeftTreeMenu",
1112 xtype: Gtk.MenuItem,
1114 label : "Delete Element",
1116 "activate":function (self) {
1118 this.get('/LeftTree.model').deleteSelected();
1129 id : "LeftProjectTree",
1130 showNoProjectSelected : function() {
1131 this.get('/StandardErrorDialog').show("Select a Project first.");
1133 getActiveProject : function() {
1134 return this.project;
1137 "leave_notify_event":function (self, event) {
1144 pack : "pack_start,false,false",
1147 xtype: Gtk.ComboBox,
1150 XObject.prototype.init.call(this);
1151 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1153 getValue : function() {
1154 var ix = this.el.get_active();
1158 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1161 setValue : function(fn)
1165 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1166 data.forEach(function(n, ix) {
1174 "changed":function (self) {
1175 var fn = this.getValue();
1176 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1177 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1182 xtype: Gtk.CellRendererText,
1183 pack : "pack_start,true",
1187 xtype: Gtk.ListStore,
1190 XObject.prototype.init.call(this);
1191 this.el.set_column_types ( 2, [
1192 GObject.TYPE_STRING, // real key
1193 GObject.TYPE_STRING // real type
1199 loadData : function(data) {
1200 var ov = this.get('/LeftProjectTree.combo').getValue();
1202 var iter = new Gtk.TreeIter();
1204 data.forEach(function(p) {
1209 el.set_value(iter, 0, p.fn);
1210 el.set_value(iter, 1, p.name);
1214 this.get('/LeftProjectTree.combo').setValue(ov);
1223 xtype: Gtk.ScrolledWindow,
1225 shadow_type : Gtk.ShadowType.IN,
1227 XObject.prototype.init.call(this);
1228 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1232 xtype: Gtk.TreeView,
1233 headers_visible : false,
1234 enable_tree_lines : true,
1237 XObject.prototype.init.call(this);
1238 var description = new Pango.FontDescription.c_new();
1239 description.set_size(8000);
1240 this.el.modify_font(description);
1242 this.selection = this.el.get_selection();
1243 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1247 "cursor_changed":function (self) {
1248 var iter = new Gtk.TreeIter();
1250 if (this.selection.count_selected_rows() < 1) {
1251 //XN.get('Builder.LeftTree.model').
1252 this.get('/LeftTree.model').load( false);
1256 var model = this.get('/LeftProjectTree.model');
1257 //console.log('changed');
1258 var s = this.selection;
1259 s.get_selected(model, iter);
1260 value = new GObject.Value('');
1261 model.el.get_value(iter, 2, value);
1263 console.log(value.value);// id..
1265 var file = this.get('/LeftProjectTree').project.getById(value.value);
1272 var nb = this.get('/LeftTopPanel.expander');
1273 nb.el.expanded = false;
1274 nb.listeners.activate.call(nb);
1275 //_expander.el.set_expanded(false);
1277 var ltm = this.get('/LeftTree.model');
1285 xtype: Gtk.TreeStore,
1289 XObject.prototype.init.call(this);
1290 this.el.set_column_types ( 3, [
1291 GObject.TYPE_STRING, // title
1292 GObject.TYPE_STRING, // tip
1293 GObject.TYPE_STRING // id..
1297 loadProject : function(pr) {
1302 this.get('/LeftProjectTree').project = pr;
1303 this.load(pr.toTree());
1304 this.get('/LeftProjectTree.view').el.expand_all();
1306 load : function(tr,iter) {
1308 console.log('Project tree load: ' + tr.length);
1309 var citer = new Gtk.TreeIter();
1310 //this.insert(citer,iter,0);
1313 tr.forEach(function (r) {
1315 _this.el.append(citer);
1317 _this.el.insert(citer,iter,-1);
1319 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1320 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1321 _this.el.set_value(citer, 2, '' + r.id ); //id
1322 if (r.cn && r.cn.length) {
1323 _this.load(r.cn, citer);
1328 getValue : function(iter, col) {
1329 var gval = new GObject.Value('');
1330 this.el.get_value(iter, col ,gval);
1331 return '' + gval.value;
1335 xtype: Gtk.TreeViewColumn,
1336 pack : "append_column",
1338 XObject.prototype.init.call(this);
1339 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1343 xtype: Gtk.CellRendererText,
1366 pack : "pack_start,false,true,0",
1373 "button_press_event":function (self, event) {
1374 this.get('/MidPropTree.model').showData('props');
1386 stock : Gtk.STOCK_ADD,
1387 icon_size : Gtk.IconSize.MENU
1402 "button_press_event":function (self, event) {
1403 this.get('/MidPropTree.model').showData('events');
1415 stock : Gtk.STOCK_ADD,
1416 icon_size : Gtk.IconSize.MENU
1431 "button_press_event":function (self, ev) {
1432 var p = this.get('/AddPropertyPopup');
1436 p.el.set_screen(Gdk.Screen.get_default());
1438 p.el.popup(null, null, null, null, 3, ev.button.time);
1450 stock : Gtk.STOCK_ADD,
1451 icon_size : Gtk.IconSize.MENU
1463 id : "AddPropertyPopup",
1466 xtype: Gtk.MenuItem,
1468 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1471 "activate":function (self) {
1473 this.get('/LeftPanel.model').add( {
1484 xtype: Gtk.MenuItem,
1486 tooltip_markup : "Add what type of packing is to be used",
1489 "activate":function (self) {
1491 this.get('/LeftPanel.model').add( {
1501 xtype: Gtk.MenuItem,
1503 tooltip_markup : "Override the init method",
1506 "activate":function (self) {
1508 this.get('/LeftPanel.model').add( {
1511 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1518 xtype: Gtk.SeparatorMenuItem,
1522 xtype: Gtk.MenuItem,
1524 tooltip_markup : "Add a user defined string property",
1527 "activate":function (self) {
1529 this.get('/LeftPanel.model').add( {
1539 xtype: Gtk.MenuItem,
1541 tooltip_markup : "Add a user defined number property",
1544 "activate":function (self) {
1546 this.get('/LeftPanel.model').add( {
1556 xtype: Gtk.MenuItem,
1558 tooltip_markup : "Add a user defined boolean property",
1561 "activate":function (self) {
1563 this.get('/LeftPanel.model').add( {
1573 xtype: Gtk.SeparatorMenuItem,
1577 xtype: Gtk.MenuItem,
1579 tooltip_markup : "Add a user function boolean property",
1582 "activate":function (self) {
1584 this.get('/LeftPanel.model').add( {
1587 val : "function() {\n \n}\n",
1600 xtype: Gtk.ScrolledWindow,
1603 shadow_type : Gtk.ShadowType.IN,
1606 XObject.prototype.init.call(this);
1607 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1611 xtype: Gtk.TreeView,
1614 headers_visible : false,
1615 enable_tree_lines : true,
1617 XObject.prototype.init.call(this);
1619 this.selection = this.el.get_selection();
1620 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1623 var description = new Pango.FontDescription.c_new();
1624 description.set_size(8000);
1625 this.el.modify_font(description);
1628 "button_press_event":function (self, ev) {
1632 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1633 return false; //not on a element.
1637 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1639 if (res.column.title != 'value') {
1640 return false; // ignore..
1642 if ( this.get('/LeftPanel').editing) {
1645 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1646 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1647 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1651 var provider = this.get('/LeftTree').getPaleteProvider();
1653 var opts = provider.findOptions(type);
1655 if (opts === false) {
1656 this.get('/LeftPanel').editableColumn.setOptions([]);
1657 renderer.has_entry = true;
1659 LeftPanel.editableColumn.setOptions(opts);
1660 renderer.has_entry = false;
1664 //Seed.print("click" + ev.type);
1665 //console.dump(res);
1671 if (res.column.title == 'value') {
1674 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1675 var p = this.get('/LeftPanelPopup');
1680 p.el.set_screen(Gdk.Screen.get_default());
1682 p.el.popup(null, null, null, null, 3, ev.button.time);
1683 //Seed.print("click:" + res.column.title);
1691 xtype: Gtk.TreeStore,
1695 XObject.prototype.init.call(this);
1696 this.el.set_column_types ( 5, [
1697 GObject.TYPE_STRING, // 0 real key
1698 GObject.TYPE_STRING, // 1 real value
1699 GObject.TYPE_STRING, // 2 visable key
1700 GObject.TYPE_STRING, // 3 visable value
1701 GObject.TYPE_STRING, // 4 need to store type of!!!
1705 toShort : function(str) {
1706 var a = typeof(str) == 'string' ? str.split("\n") : [];
1707 return a.length > 1 ? a[0] + '....' : '' + str;
1709 load : function(ar) {
1712 this.get('/RightEditor').el.hide();
1719 var provider = this.get('/LeftTree').getPaleteProvider();
1722 var iter = new Gtk.TreeIter();
1724 if (typeof(ar[i]) == 'object') {
1728 var type = provider.findType(ar, i, ar[i]);
1730 this.el.append(iter);
1731 var p = this.el.get_path(iter).to_string();
1733 this.el.set_value(iter, 0, i);
1734 this.el.set_value(iter, 1, '' + ar[i]);
1735 this.el.set_value(iter, 2, i);
1736 this.el.set_value(iter, 3, this.toShort(ar[i]));
1737 this.el.set_value(iter, 4, type);
1739 ar.listeners = ar.listeners || {};
1740 for (var i in ar.listeners ) {
1741 this.el.append(iter);
1742 var p = this.el.get_path(iter).to_string();
1745 this.el.set_value(iter, 0, '!'+ i );
1746 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1747 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1749 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1750 this.el.set_value(iter, 4, 'function');
1754 add : function(info) {
1755 // info includes key, val, skel, etype..
1757 type = info.type.toLowerCase();
1758 var data = this.toJS();
1760 if (info.etype == 'events') {
1761 data.listeners = data.listeners || { };
1762 if (typeof(data.listeners[info.key]) != 'undefined') {
1763 return; //already set!
1766 if (typeof(data[info.key]) != 'undefined') {
1771 if (typeof(info.val) == 'undefined') {
1774 if (info.type == 'boolean') {
1777 if (type == 'number') {
1785 if (info.etype == 'events') {
1787 data.listeners[info.key] = info.val;
1790 data[info.key] = info.val;
1794 var map = this.load(data);
1796 // flag it as changed to the interface..
1798 this.get('/LeftTree.model').changed(data, true);
1801 this.startEditing(map[k]);
1804 LeftPanel.get('view').el.row_activated(
1805 new Gtk.TreePath.from_string(map[k]),
1806 LeftPanel.editableColumn.el
1810 startEditing : function(path,col) {
1812 * start editing path (or selected if not set..)
1813 * @param {String|false} path (optional) treepath to edit - selected tree gets
1814 * edited by default.
1815 * @param {Number} 0 or 1 (optional)- column to edit.
1818 if (typeof(path) == 'string') {
1819 tp = new Gtk.TreePath.from_string(path);
1821 var iter = new Gtk.TreeIter();
1822 var s = this.get('/LeftPanel.view').selection;
1823 s.get_selected(this.el, iter);
1824 tp = this.el.get_path(iter);
1825 path = tp.to_string();
1829 // which colum is to be edited..
1831 if (typeof(col) == 'undefined') {
1832 var k = this.getValue(path, 0);
1833 colObj = (!k.length || k == '|') ?
1834 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1836 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1839 // make sure the pulldown is set correctly..
1840 // not really needed for second col...
1842 var provider = this.get('/LeftTree').getPaleteProvider();
1844 var type = this.get('/LeftPanel.model').getType(path);
1845 var opts = provider.findOptions(type);
1846 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1848 if (opts === false) {
1849 this.get('/LeftPanel').editableColumn.setOptions([]);
1850 renderer.has_entry = true; /// probably does not have any effect.
1852 this.get('/LeftPanel').editableColumn.setOptions(opts);
1853 renderer.has_entry = false;
1857 // iter now has row...
1858 GLib.timeout_add(0, 100, function() {
1860 colObj.items[0].el.editable = true; // esp. need for col 0..
1861 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1870 deleteSelected : function() {
1871 var data = this.toJS();
1872 var iter = new Gtk.TreeIter();
1873 var s = this.get('/LeftPanel.view').selection;
1874 s.get_selected(this.el, iter);
1877 var gval = new GObject.Value('');
1878 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1880 var val = gval.value;
1881 if (val[0] == '!') {
1883 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1886 delete data.listeners[ val.substring(1)];
1887 if (!XObject.keys(data.listeners).length) {
1888 delete data.listeners;
1892 if (typeof(data[val]) == 'undefined') {
1900 this.get('/LeftTree.model').changed(data, true);
1904 changed : function(str, doRefresh) {
1905 if (!this.activePath) {
1908 var iter = new Gtk.TreeIter();
1909 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1911 this.el.set_value(iter, 1, '' +str);
1912 this.el.set_value(iter, 3, '' + this.toShort(str));
1913 // update the tree...
1915 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
1918 var iter = new Gtk.TreeIter();
1919 this.get('/LeftPanel.model').el.get_iter_first(iter);
1924 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
1927 ar.listeners = ar.listeners || {};
1928 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
1931 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
1934 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
1940 //print(JSON.stringify(ar));
1944 getType : function(treepath) {
1945 return this.getValue(treepath, 4);
1947 getValue : function(treepath_str, col) {
1948 var iter = new Gtk.TreeIter();
1949 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
1951 var gval = new GObject.Value('');
1952 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
1953 var val = '' + gval.value;
1957 var type = this.getType(this.el.get_path(iter).to_string());
1958 //print("TYPE: " +type + " - val:" + val);
1959 switch(type.toLowerCase()) {
1963 return parseFloat(val); // Nan ?? invalid!!?
1965 return val == 'true' ? true : false;
1971 editSelected : function(e) {
1972 print("EDIT SELECTED?");
1973 var iter = new Gtk.TreeIter();
1974 var s = this.get('/LeftPanel.view').selection;
1975 s.get_selected(this.get('/LeftPanel.model').el, iter);
1976 var m = this.get('/LeftPanel.model')
1978 var gval = new GObject.Value('');
1979 this.el.get_value(iter, 0 ,gval);
1980 var val = '' + gval.value;
1982 gval = new GObject.Value('');
1983 this.el.get_value(iter, 1 ,gval);
1984 var rval = gval.value;
1985 var activePath = this.el.get_path(iter).to_string();
1986 this.activePath = activePath ;
1987 // was activeIter...
1990 var showEditor = false;
1992 if (val[0] == '!') {
1995 if (val[0] == '|') {
1996 if (rval.match(/function/g) || rval.match(/\n/g)) {
2003 this.activePath = false;
2004 GLib.timeout_add(0, 1, function() {
2005 // Gdk.threads_enter();
2006 _this.get('/RightEditor').el.show();
2007 _this.get('/RightEditor.view').load( rval );
2011 _this.activePath = activePath ;
2013 // Gdk.threads_leave();
2019 this.get('/RightEditor').el.hide();
2021 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2027 xtype: Gtk.TreeViewColumn,
2028 pack : "append_column",
2030 XObject.prototype.init.call(this);
2032 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2033 this.get('/LeftPanel').propertyColumn = this;
2038 xtype: Gtk.CellRendererText,
2039 pack : "pack_start",
2041 "editing_started":function (self, editable, path) {
2043 this.get('/LeftPanel.model').activePath = path;
2046 "edited":function (self, object, p0) {
2047 var model = this.get('/LeftPanel.model');
2048 var path = model.activePath;
2049 var iter = new Gtk.TreeIter();
2050 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2051 model.el.set_value(iter, 0, p0);
2052 model.el.set_value(iter, 2, p0);
2054 model.activePath = false;
2056 this.get('/LeftTree.model').changed(model.toJS(), true);
2057 this.el.editable = false;
2064 xtype: Gtk.TreeViewColumn,
2065 pack : "append_column",
2067 XObject.prototype.init.call(this);
2068 this.el.add_attribute(this.items[0].el , 'text', 3 );
2069 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2070 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2071 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2073 this.get('/LeftPanel').editableColumn= this;
2075 setOptions : function(ar) {
2076 var m = this.items[0].el.model;
2078 var iter = new Gtk.TreeIter();
2079 ar.forEach(function(i) {
2082 m.set_value(iter, 0, i);
2088 xtype: Gtk.CellRendererCombo,
2089 pack : "pack_start",
2094 XObject.prototype.init.call(this);
2095 this.el.model = new Gtk.ListStore();
2096 this.el.model.set_column_types ( 1, [
2097 GObject.TYPE_STRING // 0 real key
2101 "edited":function (self, object, p0) {
2102 this.get('/LeftPanel').editing = false;
2103 print("EDITED? p:" + p0 + " t:" + p0);
2104 this.get('/LeftPanel.model').changed(p0, true);
2105 this.get('/LeftPanel.model').activePath = false;
2107 "editing_started":function (self, editable, path) {
2108 this.get('/LeftPanel').editing = true;
2109 // console.log('editing started');
2110 // r.has_entry = false;
2111 this.get('/LeftPanel.model').editSelected(editable);
2122 id : "LeftPanelPopup",
2125 xtype: Gtk.MenuItem,
2129 "activate":function (self) {
2130 this.get('/LeftPanel.model').deleteSelected();
2135 xtype: Gtk.MenuItem,
2139 "activate":function (self) {
2140 this.get('/LeftPanel.model').startEditing(false, 0);
2153 xtype: Gtk.ScrolledWindow,
2154 pack : "pack_end,false,true,0",
2156 shadow_type : Gtk.ShadowType.IN,
2158 XObject.prototype.init.call(this);
2159 XObject.prototype.init.call(this);
2160 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2161 this.el.set_size_request ( 150, -1 );
2164 activeElement : false,
2165 hideWin : function() {
2172 if (this.get('/Window.left').el.position < 160) {
2175 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2182 xtype: Gtk.TreeView,
2183 enable_tree_lines : true,
2184 headers_visible : false,
2187 XObject.prototype.init.call(this);
2189 var description = new Pango.FontDescription.c_new();
2190 description.set_size(8000);
2191 this.el.modify_font(description);
2193 //this.selection = this.el.get_selection();
2194 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2203 "cursor_changed":function (self) {
2204 var iter = new Gtk.TreeIter();
2206 //console.log('changed');
2207 var m = this.get('model');
2208 if (!this.selection){
2209 this.selection = this.el.get_selection();
2212 var s = this.selection;
2213 if (!s.get_selected(m.el, iter)) {
2216 var tp = m.el.get_path(iter).to_string();
2221 var key = m.getValue(tp, 0);
2223 var type = m.getValue(tp, 1);
2224 var skel = m.getValue(tp, 3);
2225 var etype = m.getValue(tp, 5);
2228 this.get('/MidPropTree').hideWin();
2230 if (type == 'function') {
2232 if (etype != 'events') {
2236 this.get('/LeftPanel.model').add({
2245 if (type.indexOf('.') > -1 ||
2246 type == 'boolean') {
2250 this.get('/LeftPanel.model').add( {
2260 xtype: Gtk.ListStore,
2263 XObject.prototype.init.call(this);
2264 this.el.set_column_types ( 6, [
2265 GObject.TYPE_STRING, // real key
2266 GObject.TYPE_STRING, // real type
2267 GObject.TYPE_STRING, // docs ?
2268 GObject.TYPE_STRING, // visable desc
2269 GObject.TYPE_STRING, // function desc
2270 GObject.TYPE_STRING // element type (event|prop)
2274 getValue : function(treepath, col)
2276 var tp = new Gtk.TreePath.from_string (treepath);
2277 var iter = new Gtk.TreeIter();
2278 this.el.get_iter (iter, tp);
2279 var value = new GObject.Value('');
2280 this.el.get_value(iter, col, value);
2284 showData : function(type) {
2286 if (!this.get('/MidPropTree').activeElement || !type) {
2287 return; // no active element
2290 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2291 var palete = this.get('/LeftTree').getPaleteProvider();
2295 Seed.print('Showing right?');
2296 if (!this.get('/MidPropTree').shown) {
2298 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2299 this.get('/MidPropTree').el.show();
2300 this.get('/MidPropTree').shown = true;
2303 var elementList = palete.getPropertiesFor(fullpath, type);
2304 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2305 // console.dump(elementList);
2308 var iter = new Gtk.TreeIter();
2309 for(var i =0 ; i < elementList.length; i++) {
2310 var p=elementList[i];
2311 this.el.append(iter);
2312 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2313 //GObject.TYPE_STRING, // real key
2314 // GObject.TYPE_STRING, // real type
2315 // GObject.TYPE_STRING, // docs ?
2316 // GObject.TYPE_STRING // func def?
2319 this.el.set_value(iter, 0, p.name);
2320 this.el.set_value(iter, 1, p.type);
2321 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2322 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2323 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2324 this.el.set_value(iter, 5, type);
2332 xtype: Gtk.TreeViewColumn,
2334 this.el = new Gtk.TreeViewColumn();
2335 this.parent.el.append_column(this.el);
2337 XObject.prototype.init.call(this);
2338 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2343 xtype: Gtk.CellRendererText,
2344 pack : "pack_start,true"
2368 xtype: Gtk.Notebook,
2369 pack : "pack_start,true,true",
2370 id : "view-notebook",
2373 XObject.prototype.init.call(this);
2374 this.el.set_current_page(0);
2376 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2377 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2384 id : "RightBrowser",
2388 pack : "pack_start,false,true,0",
2392 pack : "pack_start,false,false,0",
2393 label : "Dump HTML to console",
2395 "activate":function (self) {
2396 this.get('/RightBrowser.view').el.execute_script(
2397 "console.log(document.body.innerHTML);");
2398 this.get('/RightBrowser.view').el.execute_script(
2399 "console.log(Builder.dump(Builder));");
2406 xtype: Gtk.ScrolledWindow,
2408 shadow_type : Gtk.ShadowType.IN,
2410 XObject.prototype.init.call(this);
2411 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2415 xtype: WebKit.WebView,
2419 XObject.prototype.init.call(this);
2420 // this may not work!?
2421 //this.el.open('file:///' + __script_path__ + '/../builder.html');
2425 this.el, /* widget that will accept a drop */
2426 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2427 null, /* lists of target to support */
2428 0, /* size of list */
2429 Gdk.DragAction.COPY /* what to do with data after dropped */
2432 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2433 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2435 renderJS : function() {
2436 this.renderedData = data;
2437 var str = JSON.stringify(data) ;
2440 console.log('not loaded yet');
2442 Seed.print("RENDER:" + str);
2443 imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2444 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2447 "load_finished":function (self, object) {
2448 if (this.ready) { // dont do it twice!
2453 this.renderJS(this.get('/LeftTree.model').toJS()[0]);
2455 "script_alert":function (self, object, p0) {
2458 return true; // do not display anything...
2460 "console_message":function (self, object, p0, p1) {
2461 console.log(object);
2462 if (!object.match(/^\{/)) {
2463 return false; // do not handle!!! -> later maybe in console..
2465 console.log(object);
2466 var val = JSON.parse(object);
2468 if (typeof(val['hover-node']) != 'undefined') {
2469 this.activeNode = val['hover-node'];
2470 console.log('active node: ' + this.activeNode);
2475 if (typeof(val['id']) != 'undefined') {
2476 // this.activeNode = val['id'];
2477 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2481 this.get('/LeftTree.view').selectNode(tg[0]);
2485 if (ret && typeof(val['set']) != 'undefined') {
2486 this.get('/LeftPanel.model').add({
2490 //console.log('active node: ' + this.activeNode);
2493 //Seed.print('a:'+a);
2494 //Seed.print('b:'+b);
2495 //Seed.print('c:'+c);
2498 "drag_motion":function (w, ctx, x, y, time, ud) {
2499 // console.log('DRAG MOTION');
2501 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2502 this.targetData = [];
2503 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2505 // A) find out from drag all the places that node could be dropped.
2506 var src = Gtk.drag_get_source_widget(ctx);
2507 if (!src.dropList) {
2508 Gdk.drag_status(ctx, 0, time);
2511 // b) get what we are over.. (from activeNode)
2512 // tree is empty.. - list should be correct..
2513 if (!this.get('/LeftTree.model').currentTree) {
2514 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2518 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2520 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2523 Gdk.drag_status(ctx, 0,time);
2524 this.get('/LeftTree.view').highlight(false);
2528 // if we have a target..
2529 // -> highlight it! (in browser)
2530 // -> highlight it! (in tree)
2532 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2533 this.get('/LeftTree.view').highlight(tg);
2534 this.targetData = tg;
2535 // for tree we should handle this...
2538 "drag_drop":function (w, ctx, x, y,time, ud) {
2539 print("TARGET: drag-drop");
2540 var is_valid_drop_site = true;
2545 w, /* will receive 'drag-data-received' signal */
2546 ctx, /* represents the current state of the DnD */
2547 this.get('/Window').atoms["STRING"], /* the target type we want */
2548 time /* time stamp */
2552 /* No target offered by source => error */
2555 return is_valid_drop_site;
2557 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2559 print("Browser: drag-data-received");
2560 var delete_selection_data = false;
2561 vardnd_success = false;
2562 /* Deal with what we are given from source */
2563 if( sel_data && sel_data.length ) {
2565 if (ctx.action == Gdk.DragAction.ASK) {
2566 /* Ask the user to move or copy, then set the ctx action. */
2569 if (ctx.action == Gdk.DragAction.MOVE) {
2570 delete_selection_data = true;
2572 var source = Gtk.drag_get_source_widget(ctx);
2574 print("Browser: source.DRAGDATA? " + source.dragData);
2575 if (this.targetData) {
2576 print(this.targetData);
2577 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2586 if (dnd_success == false)
2588 Seed.print ("DnD data transfer failed!\n");
2591 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2603 id : "RightGtkView",
2604 renderJS : function(data, withDebug)
2609 this.withDebug = false;
2611 if (this.renderedEl) {
2612 this.get('view').el.remove(this.renderedEl);
2613 this.renderedEl.destroy();
2614 this.renderedEl = false;
2617 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2618 // in theory tree is actually window..
2620 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2625 this.get('view').el.set_size_request(
2626 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2629 this.renderedEl.set_size_request(
2630 tree.default_width || 600,
2631 tree.default_height || 400
2633 this.get('view').el.show_all();
2638 showInWindow : function() {
2639 print("GET PROEJCT");
2640 var pr = this.get('/LeftProjectTree').getActiveProject();
2642 console.log(pr.paths);
2645 var src= this.buildJS(
2646 this.get('/LeftTree.model').toJS()[0],
2651 //var x = new imports.sandbox.Context();
2655 Seed.check_syntax('var e = ' + src);
2658 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2659 this.get('/Terminal').feed(console._dump(e)+"\n");
2661 var lines = src.split("\n");
2662 var start = Math.max(0, e.line - 10);
2663 var end = Math.min(lines.length, e.line + 10);
2664 for (var i =start ; i < end; i++) {
2666 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2669 this.get('/Terminal').feed(lines[i] + "\n");
2676 this.get('/BottomPane').el.set_current_page(1);
2677 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2678 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2679 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2681 var _top = x.get_global_object()._top;
2683 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2685 if (_top.el.popup) {
2686 _top.el.popup(null, null, null, null, 3, null);
2690 viewAdd : function(item, par)
2692 // does something similar to xobject..
2693 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2695 if (item.pack===false || item.pack === 'false') { // no ;
2698 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2699 var ns = imports.gi[item['|xns']];
2700 var ctr = ns[item['xtype']];
2702 for(var k in item) {
2704 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2719 if (k[0] == '|' && typeof(kv) == 'string') {
2721 if (kv.match(new RegExp('function'))) {
2724 print("WASL " + k + '=' + kv);
2726 eval( 'kv = ' + kv);
2727 } catch(e) { continue; }
2730 print(k + '=' + kv);
2732 if (k[0] == '|') { // should be boolean or number..
2735 if (k == 'show_tabs') { // force tab showing for notebooks.
2743 var el = new ctr(ctr_args);
2746 //console.dump(item.pack);
2753 if (typeof(item.pack) == 'string') {
2755 item.pack.split(',').forEach(function(e, i) {
2757 if (e == 'false') { args.push( false); return; }
2758 if (e == 'true') { args.push( true); return; }
2759 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2762 //print(args.join(","));
2764 pack_m = args.shift();
2766 pack_m = item.pack.shift();
2771 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2773 name: "ArgumentError",
2774 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2775 "ADDING : " + item.id + " " + el
2784 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2785 //Seed.print('args: ' + args.length);
2787 par[pack_m].apply(par, args);
2791 item.items = item.items || [];
2792 item.items.forEach(function(ch) {
2793 _this.viewAdd(ch, el);
2798 // add the signal handlers.
2799 // is it a widget!?!!?
2805 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2806 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2807 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2808 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2809 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2819 widgetExposeEvent : function() {
2820 /// print("WIDGET EXPOSE"); // draw highlight??
2823 widgetDragMotionEvent : function() {
2824 print("WIDGET DRAGMOTION");
2827 widgetDragDropEvent : function() {
2828 print("WIDGET DRAGDROP");
2831 widgetPressEvent : function(w,e,u,d) {
2832 if (this.get('view').pressed) {
2835 this.get('view').pressed = true;
2836 print("WIDGET PRESS " + d.xtreepath );
2837 var tp = new Gtk.TreePath.from_string(d.xtreepath);
2838 this.get('/LeftTree.view').el.set_cursor(tp, null, false);
2839 this.get('/LeftTree.view').el.scroll_to_cell(tp, null, false, 0,0);
2842 widgetReleaseEvent : function() {
2843 this.get('view').pressed = false;
2849 pack : "pack_start,false,true,0",
2853 pack : "pack_start,false,false,0",
2854 label : "Run The Application",
2856 "button_press_event":function (self, event) {
2857 // call render on left tree - with special option!?!
2861 print("GET PROEJCT");
2862 var pr = this.get('/LeftProjectTree').getActiveProject();
2865 for (var i in pr.paths) {
2869 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
2870 print ("RUN DIR:" + dir);
2872 this.get('/BottomPane').el.set_current_page(1);
2873 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
2874 , false,false,false);
2875 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
2876 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2886 xtype: Gtk.ScrolledWindow,
2889 shadow_type : Gtk.ShadowType.IN,
2891 XObject.prototype.init.call(this);
2892 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2896 xtype: Gtk.EventBox,
2899 XObject.prototype.init.call(this);
2900 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
2901 red: 0x9F00, green: 0xB800 , blue : 0xA800
2909 XObject.prototype.init.call(this);
2910 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
2911 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
2916 xtype: Gtk.EventBox,
2919 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
2920 XObject.prototype.init.call(this);
2924 this.el, /* widget that will accept a drop */
2925 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2926 null, /* lists of target to support */
2927 0, /* size of list */
2928 Gdk.DragAction.COPY /* what to do with data after dropped */
2931 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2932 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2935 getActiveNode : function(x,y)
2937 // workout what node is here..
2938 return '0'; // top..
2942 "drag_motion":function (self, ctx, x, y, time) {
2944 // A) find out from drag all the places that node could be dropped.
2945 var src = Gtk.drag_get_source_widget(ctx);
2946 if (!src.dropList) {
2947 Gdk.drag_status(ctx, 0, time);
2950 // b) get what we are over.. (from activeNode)
2951 // tree is empty.. - list should be correct..
2952 if (!this.get('/LeftTree.model').currentTree) {
2953 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2957 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2958 var activeNode = this.getActiveNode(x, y);
2961 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
2964 Gdk.drag_status(ctx, 0,time);
2965 this.get('/LeftTree.view').highlight(false);
2969 // if we have a target..
2970 // -> highlight it! (in browser)
2971 // -> highlight it! (in tree)
2973 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2974 this.get('/LeftTree.view').highlight(tg);
2975 this.targetData = tg;
2976 // for tree we should handle this...
2979 "drag_drop":function (self,ctx, x, y, time) {
2980 Seed.print("TARGET: drag-drop");
2981 var is_valid_drop_site = true;
2986 self, /* will receive 'drag-data-received' signal */
2987 ctx, /* represents the current state of the this.gDnD */
2988 this.get('/Window').atoms["STRING"], /* the target type we want */
2989 time /* time stamp */
2993 /* No target offered by source => error */
2996 return is_valid_drop_site;
2999 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3001 Seed.print("GtkView: drag-data-received");
3002 var delete_selection_data = false;
3003 var dnd_success = false;
3004 /* Deal with what we are given from source */
3005 if( sel_data && sel_data.length ) {
3007 if (ctx.action == Gdk.DragAction.ASK) {
3008 /* Ask the user to move or copy, then set the ctx action. */
3011 if (ctx.action == Gdk.DragAction.MOVE) {
3012 delete_selection_data = true;
3014 var source = Gtk.drag_get_source_widget(ctx);
3016 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3017 if (this.targetData) {
3018 Seed.print(this.targetData);
3019 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3028 if (dnd_success == false)
3030 Seed.print ("DnD data transfer failed!\n");
3033 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3036 "button_press_event":function (self, event) {
3037 this.pressed = false;
3055 xtype: Gtk.Notebook,
3058 XObject.prototype.init.call(this);
3059 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3060 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3065 xtype: Gtk.ScrolledWindow,
3070 xtype: GtkSource.View,
3074 XObject.prototype.init.call(this);
3075 var description = Pango.Font.description_from_string("monospace")
3076 description.set_size(8000);
3077 this.el.modify_font(description);
3080 load : function(str) {
3081 this.get('/BottomPane').el.set_current_page(0);
3082 this.el.get_buffer().set_text(str, str.length);
3083 var lm = GtkSource.LanguageManager.get_default();
3085 this.el.get_buffer().set_language(lm.get_language('js'));
3086 var buf = this.el.get_buffer();
3087 var cursor = buf.get_mark("insert");
3088 var iter= new Gtk.TextIter;
3089 buf.get_iter_at_mark(iter, cursor);
3091 iter.set_line_offset(4);
3092 buf.move_mark(cursor, iter);
3095 cursor = buf.get_mark("selection_bound");
3096 iter= new Gtk.TextIter;
3097 buf.get_iter_at_mark(iter, cursor);
3099 iter.set_line_offset(4);
3100 buf.move_mark(cursor, iter);
3102 this.el.grab_focus();
3106 xtype: GtkSource.Buffer,
3107 pack : "set_buffer",
3109 "changed":function (self) {
3110 var s = new Gtk.TextIter();
3111 var e = new Gtk.TextIter();
3112 this.el.get_start_iter(s);
3113 this.el.get_end_iter(e);
3114 var str = this.el.get_text(s,e,true);
3116 Seed.check_syntax('var e = ' + str);
3118 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3119 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3121 print("SYNTAX ERROR IN EDITOR");
3126 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3127 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3130 this.get('/LeftPanel.model').changed( str , false);
3139 xtype: Gtk.ScrolledWindow,
3143 xtype: Vte.Terminal,
3146 feed : function(str) {
3147 this.el.feed(str,str.length);
3158 pack : "pack_start,false,false",
3162 this.get('buttonbar').el.show();
3163 this.get('viewbox').el.hide();
3164 print("TRIED TO HIDE");
3167 this.get('buttonbar').el.hide();
3168 this.get('viewbox').el.show();
3169 // this.get('model').expanded();
3181 pack : "pack_start,false,true",
3183 "clicked":function (self) {
3184 this.get('/RightPalete').show();
3191 stock : Gtk.STOCK_GOTO_FIRST,
3192 icon_size : Gtk.IconSize.MENU
3202 XObject.prototype.init.call(this);
3203 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3206 "enter_notify_event":function (self, event) {
3207 this.get('/RightPalete').show();
3221 pack : "pack_start,false,true",
3230 pack : "pack_start,false,true",
3232 "clicked":function (self) {
3233 this.get('/RightPalete').hide();
3240 stock : Gtk.STOCK_GOTO_LAST,
3241 icon_size : Gtk.IconSize.MENU
3248 xtype: Gtk.ScrolledWindow,
3251 XObject.prototype.init.call(this);
3252 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3253 this.el.set_size_request(-1,200);
3255 shadow_type : Gtk.ShadowType.IN,
3258 xtype: Gtk.TreeView,
3261 XObject.prototype.init.call(this);
3262 this.el.set_size_request(150,-1);
3263 // set_reorderable: [1]
3265 var description = new Pango.FontDescription.c_new();
3266 description.set_size(8000);
3267 this.el.modify_font(description);
3269 this.selection = this.el.get_selection();
3270 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3271 // this.selection.signal['changed'].connect(function() {
3272 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3274 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3276 Gtk.drag_source_set (
3277 this.el, /* widget will be drag-able */
3278 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3279 null, /* lists of target to support */
3280 0, /* size of list */
3281 Gdk.DragAction.COPY /* what to do with data after dropped */
3283 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3285 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3286 Gtk.drag_source_add_text_targets(this.el);
3288 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3289 targets = new Gtk.TargetList();
3290 targets.add( LeftTree.atoms["STRING"], 0, 0);
3291 targets.add_text_targets( 1 );
3292 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3294 //if you want to allow text to be output elsewhere..
3295 //Gtk.drag_source_add_text_targets(this.el);
3299 headers_visible : false,
3300 enable_tree_lines : true,
3302 "drag_begin":function (self, ctx) {
3303 // we could fill this in now...
3304 Seed.print('SOURCE: drag-begin');
3308 var iter = new Gtk.TreeIter();
3309 var s = this.selection;
3310 s.get_selected(this.get('/RightPalete.model').el, iter);
3311 var path = this.get('/RightPalete.model').el.get_path(iter);
3313 var pix = this.el.create_row_drag_icon ( path);
3316 Gtk.drag_set_icon_pixmap (ctx,
3323 var value = new GObject.Value('');
3324 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3325 if (!this.get('/RightPalete').provider) {
3328 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3329 this.el.dragData = value.value;
3336 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3337 //Seed.print('Palete: drag-data-get: ' + target_type);
3338 if (this.el.dragData && this.el.dragData.length ) {
3339 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3343 //this.el.dragData = "TEST from source widget";
3347 "drag_end":function (self, drag_context) {
3348 Seed.print('SOURCE: drag-end');
3349 this.el.dragData = false;
3350 this.el.dropList = false;
3351 this.get('/LeftTree.view').highlight(false);
3357 xtype: Gtk.ListStore,
3360 XObject.prototype.init.call(this);
3361 this.el.set_column_types ( 2, [
3362 GObject.TYPE_STRING, // title
3363 GObject.TYPE_STRING // tip
3368 load : function(tr,iter)
3373 //console.log('Project tree load: ' + tr.length);
3374 var citer = new Gtk.TreeIter();
3375 //this.insert(citer,iter,0);
3376 for(var i =0 ; i < tr.length; i++) {
3379 this.el.append(citer);
3381 this.el.insert(citer,iter,-1);
3386 this.el.set_value(citer, 0, '' + r ); // title
3388 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3389 //if (r.cn && r.cn.length) {
3390 // this.load(r.cn, citer);
3396 getValue : function (iter, col) {
3397 var gval = new GObject.Value('');
3398 this.el.get_value(iter, col ,gval);
3405 xtype: Gtk.TreeViewColumn,
3406 pack : "append_column",
3408 XObject.prototype.init.call(this);
3409 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3413 xtype: Gtk.CellRendererText,
3435 XObject.cache['/Window'] = Window;