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",
74 label : "New _Project",
76 "activate":function (self) {
77 this.get('/EditProject').show({
78 success : function(pr) {
79 this.get('/LeftProjectTree').get('combo').setValue(pr.fn);
90 "activate":function (self) {
91 var fn = this.get('/LeftProjectTree.combo').getValue();
93 this.get('/LeftProjectTree').showNoProjectSelected();
96 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
97 this.get('/DialogNewComponent').show({
98 project : pm.getByFn(fn)
104 xtype: Gtk.SeparatorMenuItem,
111 use_underline : true,
113 "activate":function (self) {
147 label : "Select Project",
149 pack : "pack_start,false,true",
151 XObject.prototype.init.call(this);
152 this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
155 "activate":function (self) {
156 var nb = this.get('/LeftTopPanel.notebook');
157 if (this.el.expanded) {
160 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
163 var model = this.get('/LeftProjectTree.combomodel');
164 // print ("loading Projects?")
165 //console.dump(pm.projects);
166 model.loadData(pm.projects);
169 nb.el.set_current_page(1);
170 //pm.on('changed', function() {
171 //console.log("CAUGHT project manager change");
172 // _combo.model.loadData(pm.projects);
176 nb.el.set_current_page(0);
178 "enter_notify_event":function (self, event) {
179 this.el.expanded = !this.el.expanded;
180 //if (this.el.expanded ) {
181 this.listeners.activate.call(this);
193 pack : "pack_start,true,true",
195 XObject.prototype.init.call(this);
196 this.el.set_current_page(0);
201 xtype: Gtk.ScrolledWindow,
203 shadow_type : Gtk.ShadowType.IN,
205 XObject.prototype.init.call(this);
206 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
209 getPaleteProvider : function() {
210 var model = this.get('model');
211 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
212 return pm.getPalete(model.file.getType());
214 renderView : function() {
215 var model = this.get('model');
216 print("RENDER VIEW?" + model.file.getType());
217 switch( model.file.getType()) {
219 this.get('/RightBrowser.view').renderJS(model.toJS(false,true)[0]);
221 this.get('/RightGtkView').renderJS(model.toJS(false,true)[0]);
229 headers_visible : false,
230 enable_tree_lines : true,
233 XObject.prototype.init.call(this);
234 var description = new Pango.FontDescription.c_new();
235 description.set_size(8000);
236 this.el.modify_font(description);
238 this.selection = this.el.get_selection();
239 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
241 this.selection.signal['changed'].connect(function() {
242 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
243 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
247 Gtk.drag_source_set (
248 this.el, /* widget will be drag-able */
249 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
250 null, /* lists of target to support */
251 0, /* size of list */
252 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
255 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
257 Gtk.drag_source_add_text_targets(this.el);
260 this.el, /* widget that will accept a drop */
261 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
262 null, /* lists of target to support */
263 0, /* size of list */
264 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
267 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
268 Gtk.drag_dest_add_text_targets(this.el);
270 highlight : function(treepath_ar) {
271 if (treepath_ar.length && treepath_ar[0].length ) {
272 this.el.set_drag_dest_row(
273 new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);
275 this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
279 selectNode : function(treepath_str) {
280 //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
281 var tp = new Gtk.TreePath.from_string(treepath_str);
282 this.el.set_cursor(tp, null, false);
283 this.el.scroll_to_cell(tp, null, false, 0,0);
286 "button_press_event":function (self, ev) {
287 console.log("button press?");
288 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
289 print("click" + ev.type);
295 this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
297 if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();
299 this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
300 this.get('/LeftTreeMenu').el.show_all();
301 this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
302 print("click:" + res.path.to_string());
305 "drag_begin":function (self, drag_context) {
306 print('SOURCE: drag-begin');
307 this.targetData = false;
308 // find what is selected in our tree...
309 var iter = new Gtk.TreeIter();
310 var s = this.selection;
311 s.get_selected(this.get('/LeftTree.model').el, iter);
313 // set some properties of the tree for use by the dropped element.
314 var value = new GObject.Value('');
315 this.get('/LeftTree.model').el.get_value(iter, 2, value);
316 var data = JSON.parse(value.value);
317 var xname = this.get('/LeftTree.model').file.guessName(data);
319 this.el.dragData = xname;
320 this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);
323 // make the drag icon a picture of the node that was selected
324 var path = this.get('/LeftTree.model').el.get_path(iter);
325 this.el.treepath = path.to_string();
327 var pix = this.el.create_row_drag_icon ( path);
329 Gtk.drag_set_icon_pixmap (ctx,
338 "drag_end":function (self, drag_context) {
339 Seed.print('LEFT-TREE: drag-end');
340 this.el.dragData = false;
341 this.el.dropList = false;
342 this.targetData = false;
343 this.get('/LeftTree.view').highlight(false);
346 "drag_motion":function (self, ctx, x, y, time) {
347 console.log("LEFT-TREE: drag-motion");
348 var src = Gtk.drag_get_source_widget(ctx);
350 // a drag from elsewhere...- prevent drop..
352 print("no drag data!");
353 Gdk.drag_status(ctx, 0, time);
354 this.targetData = false;
357 var action = Gdk.DragAction.COPY;
358 if (src == this.el) {
359 // unless we are copying!!! ctl button..
360 action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
364 if (!this.get('/LeftTree.model').el.iter_n_children(null)) {
365 // no children.. -- asume it's ok..
366 this.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];
367 Gdk.drag_status(ctx, action ,time);
371 print("GETTING POS");
372 var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);
373 print("ISOVER? " + isOver);
375 Gdk.drag_status(ctx, 0 ,time);
376 return false; // not over apoint!?!
378 // drag node is parent of child..
379 console.log("SRC TREEPATH: " + src.treepath);
380 console.log("TARGET TREEPATH: " + data.path.to_string());
382 // nned to check a few here..
383 //Gtk.TreeViewDropPosition.INTO_OR_AFTER
384 //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
385 //Gtk.TreeViewDropPosition.AFTER
386 //Gtk.TreeViewDropPosition.BEFORE
388 if (typeof(src.treepath) != 'undefined' &&
389 src.treepath == data.path.to_string().substring(0,src.treepath.length)) {
390 print("subpath drag");
391 Gdk.drag_status(ctx, 0 ,time);
396 //print("DUMPING DATA");
397 //console.dump(data);
400 print(data.path.to_string() +' => '+ data.pos);
401 var tg = this.get('/LeftTree.model').findDropNodeByPath(
402 data.path.to_string(), src.dropList, data.pos);
404 this.get('/LeftTree.view').highlight(tg);
406 print("Can not find drop node path");
407 this.targetData = false;
408 Gdk.drag_status(ctx, 0, time);
412 this.targetData = tg;
415 Gdk.drag_status(ctx, action ,time);
419 "drag_drop":function (w, ctx, x, y, time) {
420 Seed.print("TARGET: drag-drop");
424 w, /* will receive 'drag-data-received' signal */
425 ctx, /* represents the current state of the DnD */
426 this.get('/Window').atoms["STRING"], /* the target type we want */
427 time /* time stamp */
431 /* No target offered by source => error */
436 "drag_data_received":function (self, ctx, x, y, sel_data, info, time) {
437 print("Tree: drag-data-received");
439 var delete_selection_data = false;
440 var dnd_success = false;
441 /* Deal with what we are given from source */
442 if( sel_data && sel_data.length ) {
444 if (ctx.action == Gdk.DragAction.ASK) {
445 /* Ask the user to move or copy, then set the ctx action. */
448 if (ctx.action == Gdk.DragAction.MOVE) {
449 //delete_selection_data = true;
452 var source = Gtk.drag_get_source_widget(ctx);
454 if (this.targetData) {
455 if (source != this.el) {
456 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
458 // drag around.. - reorder..
459 this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);
463 //Seed.print(this.targetData);
469 // we can send stuff to souce here...
475 if (dnd_success == false)
477 Seed.print ("DnD data transfer failed!\n");
480 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
483 "cursor_changed":function (self) {
484 if (this.blockChanges) {
487 var iter = new Gtk.TreeIter();
489 if (this.selection.count_selected_rows() < 1) {
490 this.get('/LeftPanel.model').load( false);
491 this.get('/MidPropTree').activeElement = false;
492 this.get('/MidPropTree').hideWin();
494 var pm = this.get('/RightPalete.model');
495 if (!this.get('/LeftTree').getPaleteProvider()) {
496 // it may not be loaded yet..
499 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
500 this.get('/LeftTree.model').listAllTypes()));
505 //console.log('changed');
506 var s = this.selection;
507 s.get_selected(this.get('/LeftTree.model').el, iter);
511 value = new GObject.Value('');
512 this.get('/LeftTree.model').el.get_value(iter, 2, value);
513 this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
515 var data = JSON.parse(value.value);
516 this.get('/MidPropTree').activeElement = data;
517 this.get('/MidPropTree').hideWin();
518 this.get('/LeftPanel.model').load( data);
520 console.log(value.value);
521 // _g.button.set_label(''+value.get_string());
523 var pm =this.get('/RightPalete.model');
524 pm.load( this.get('/RightPalete').provider.gatherList(
525 this.get('/LeftTree.model').listAllTypes()));
530 //Seed.print( value.get_string());
537 xtype: Gtk.TreeStore,
541 XObject.prototype.init.call(this);
542 this.el.set_column_types ( 3, [
543 GObject.TYPE_STRING, // title
544 GObject.TYPE_STRING, // tip
545 GObject.TYPE_STRING // source..
549 changed : function(n, refresh) {
550 print("MODEL CHANGED CALLED" + this.activePath);
551 if (this.activePath) {
552 var iter = new Gtk.TreeIter();
553 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
554 this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
555 this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
557 this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
559 //this.currentTree = this.toJS(false, true)[0];
560 this.file.items = this.toJS(false, false);
561 print("AFTER CHANGED");
562 //console.dump(this.file.items);
564 this.currentTree = this.file.items[0];
565 //console.log(this.file.toSource());
568 print("REDNER BROWSER?!");
569 this.get('/LeftTree').renderView();
571 var pm = this.get('/RightPalete.model');
572 if (!this.get('/RightPalete').provider) {
578 pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
579 //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
583 loadFile : function(f) {
589 console.log('missing file');
593 // load the file if not loaded..
594 if (f.items === false) {
596 f.loadItems(function() {
602 if (f.items.length && typeof(f.items[0]) == 'string') {
604 this.get('/RightEditor').el.show();
605 this.get('/RightEditor.view').load( f.items[0]);
609 //console.dump(f.items);
611 this.get('/LeftTree.view').el.expand_all();
613 if (!f.items.length) {
616 this.get('/Window.leftvpaned').el.set_position(80);
618 this.get('/LeftTree.view').el.set_cursor(
619 new Gtk.TreePath.from_string('0'), null, false);
623 this.get('/Window.leftvpaned').el.set_position(200);
627 //print("hide right editior");
628 this.get('/RightEditor').el.hide();
629 //print("set current tree");
630 this.currentTree = this.toJS(false, false)[0];
631 //console.dump(this.currentTree);
632 this.currentTree = this.currentTree || { items: [] };
633 this.get('/LeftTree').renderView();
634 //console.dump(this.map);
635 //var RightPalete = imports.Builder.RightPalete.RightPalete;
636 var pm = this.get('/RightPalete.model');
639 this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
641 if (!this.get('/RightPalete').provider) {
642 print ("********* PALETE PROVIDER MISSING?!!");
644 this.get('/LeftTree').renderView();
646 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
650 this.get('/Window.view-notebook').el.set_current_page(
651 this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
654 findDropNode : function(treepath_str, targets) {
656 // this is used by the dragdrop code in the roo version AFAIR..
658 var path = treepath_str.replace(/^builder-/, '');
659 // treemap is depreciated... - should really check if model has any entries..
661 if (!this.el.iter_n_children(null)) {
663 return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];
665 print("FIND treepath: " + path);
666 //console.dump(this.treemap);
668 if (!treepath_str.match(/^builder-/)) {
669 return []; // nothing!
671 if (targets === true) {
674 return this.findDropNodeByPath(path,targets)
676 findDropNodeByPath : function(treepath_str, targets, pref) {
677 var path = treepath_str + ''; // dupe it..
678 pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
680 //console.dump(this.treemap);
681 while (path.length) {
682 print("LOOKING FOR PATH: " + path);
683 var node_data = this.singleNodeToJS(path);
684 if (node_data === false) {
685 print("node not found");
689 var xname = this.get('/LeftTree.model').file.guessName(node_data);
692 targets.forEach(function(tg) {
696 if ((tg == xname) ) {
699 if (tg.indexOf(xname +':') === 0) {
701 prop = tg.split(':').pop();
706 if (last) { // pref is after/before..
707 // then it's after last
709 return []; // do not allow..
711 return [ last, pref , prop];
714 return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
716 var par = path.split(':');
719 path = par.join(':');
725 dropNode : function(target_data, node) {
728 console.dump(target_data);
729 var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
731 print("add " + tp + "@" + target_data[1] );
734 if (tp && target_data[1] < 2) { // before or after..
735 var ar = target_data[0].split(':');
737 parent = new Gtk.TreePath.from_string( ar.join(':') );
740 var n_iter = new Gtk.TreeIter();
741 var iter_par = new Gtk.TreeIter();
742 var iter_after = after ? new Gtk.TreeIter() : false;
746 if (parent !== false) {
747 this.el.get_iter(iter_par, parent);
754 print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
755 this.el.get_iter(iter_after, after);
756 this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
757 n_iter, iter_par, iter_after);
760 this.el.append(n_iter, iter_par);
764 if (typeof(node) == 'string') {
765 var ar = node.split('.');
766 var xtype = ar.pop();
769 '|xns' : ar.join('.'),
772 if (target_data.length == 3 && target_data[2].length) {
773 node['*prop'] = target_data[2];
777 // work out what kind of packing to use..
778 if (typeof(node.pack) == 'undefined' && parent !== false) {
779 var pal = this.get('/LeftTree').getPaleteProvider();
781 var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
782 print ("PNAME : " + pname);
783 var cname = pal.guessName(node);
784 print ("CNAME : " + cname);
785 node.pack = pal.getDefaultPack(pname, cname);
796 // load children - if it has any..
799 this.load(xitems, n_iter);
801 if (tp && (xitems || after)) {
802 this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
804 // wee need to get the empty proptypes from somewhere..
806 //var olditer = this.activeIter;
807 this.activePath = this.el.get_path(n_iter).to_string();
809 // changed actually set's the node data..
810 this.changed(node, true);
814 this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
816 //Builder.MidPropTree._model.load(node);
817 //Builder.MidPropTree._win.hideWin();
818 //Builder.LeftPanel._model.load( node);
822 moveNode : function(target_data, action) {
823 //print("MOVE NODE");
824 // console.dump(target_data);
825 var old_iter = new Gtk.TreeIter();
826 var s = this.get('/LeftTree.view').selection;
827 s.get_selected(this.el, old_iter);
828 var node = this.nodeToJS(old_iter,false);
829 //console.dump(node);
832 // needs to drop first, otherwise the target_data
833 // treepath will be invalid.
835 this.dropNode(target_data, node);
836 if (action & Gdk.DragAction.MOVE) {
837 // print("REMOVING OLD NODE");
838 this.el.remove(old_iter);
842 this.activePath= false;
843 this.changed(false,true);
845 deleteSelected : function() {
846 this.get('/LeftTree.view').blockChanges = true;
847 var old_iter = new Gtk.TreeIter();
848 var s = this.get('/LeftTree.view').selection;
849 s.get_selected(this.el, old_iter);
850 var path = this.el.get_path(old_iter).to_string();
852 this.activePath= false;
855 this.activePath= false;
856 var iter = new Gtk.TreeIter();
857 this.el.get_iter_from_string(iter, path);
858 this.el.remove(iter);
860 // rebuild treemap. -- depreciated.!!
863 //this.toJS(null, true) // does not do anything?
864 this.activePath= false;
865 this.changed(false,true);
866 this.get('/LeftTree.view').blockChanges = false;
869 listAllTypes : function() {
870 var s = this.get('/LeftTree.view').selection;
871 print ("LIST ALL TYPES: " + s.count_selected_rows() );
873 if (s.count_selected_rows() > 0) {
874 var iter = new Gtk.TreeIter();
875 s.get_selected(this.el, iter);
877 // set some properties of the tree for use by the dropped element.
878 var value = new GObject.Value('');
879 this.el.get_value(iter, 2, value);
880 var data = JSON.parse(value.value);
883 var xname = this.get('/LeftTree.model').file.guessName(data);
884 console.log('selected:' + xname);
888 return []; // could not find it..
896 li.forEach(function(el) {
897 // this is specific to roo!!!?
899 var fullpath = _this.file.guessName(el);
900 if (fullpath.length && ret.indexOf(fullpath) < 0) {
905 if (el.items && el.items.length) {
914 addall([this.currentTree]);
916 // only if we have nothing, should we add '*top'
920 //console.log('all types in tree');
926 singleNodeToJS : function (treepath)
928 var iter = new Gtk.TreeIter();
929 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
933 var iv = this.getIterValue(iter, 2);
935 return JSON.parse(iv);
938 nodeToJS : function (iter, with_id)
940 var par = new Gtk.TreeIter();
941 var iv = this.getIterValue(iter, 2);
943 var k = JSON.parse(iv);
944 if (k.json && !this.el.iter_parent( par, iter )) {
949 var treepath_str = this.el.get_path(iter).to_string();
950 // not sure how we can handle mixed id stuff..
951 if (typeof(k.id) == 'undefined') {
952 k.id = 'builder-'+ treepath_str ;
956 this.treemap[ treepath_str ] = k;
957 k.xtreepath = treepath_str ;
960 if (this.el.iter_has_child(iter)) {
961 citer = new Gtk.TreeIter();
962 this.el.iter_children(citer, iter);
963 k.items = this.toJS(citer,with_id);
967 toJS : function(iter, with_id)
969 //Seed.print("WITHID: "+ with_id);
976 iter = new Gtk.TreeIter();
977 if (!this.el.get_iter_first(iter)) {
987 var k = this.nodeToJS(iter, with_id);
991 if (!this.el.iter_next(iter)) {
997 // convert the list into a json string..
1001 getIterValue : function (iter, col) {
1002 var gval = new GObject.Value('');
1003 this.el.get_value(iter, col ,gval);
1008 nodeTitle : function(c) {
1011 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
1012 if (sr) txt.push('<s>');
1013 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
1014 if (c.xtype) { txt.push(c.xtype); }
1015 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1016 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1017 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1020 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1021 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1022 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1023 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1024 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1025 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1026 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1027 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1028 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1030 // for flat classes...
1031 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1032 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1035 if (sr) txt.push('</s>');
1036 return (txt.length == 0 ? "Element" : txt.join(" "));
1038 nodeToJSON : function(c) {
1046 return JSON.stringify(o);
1048 load : function(tr,iter)
1050 var citer = new Gtk.TreeIter();
1051 //this.insert(citer,iter,0);
1052 for(var i =0 ; i < tr.length; i++) {
1054 this.el.insert(citer,iter,-1);
1056 this.el.append(citer);
1059 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1060 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1061 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1062 if (tr[i].items && tr[i].items.length) {
1063 this.load(tr[i].items, citer);
1069 xtype: Gtk.TreeViewColumn,
1070 pack : "append_column",
1072 XObject.prototype.init.call(this);
1073 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1077 xtype: Gtk.CellRendererText,
1087 id : "LeftTreeMenu",
1090 xtype: Gtk.MenuItem,
1092 label : "Delete Element",
1094 "activate":function (self) {
1096 this.get('/LeftTree.model').deleteSelected();
1107 id : "LeftProjectTree",
1108 showNoProjectSelected : function() {
1109 this.get('/StandardErrorDialog').show("Select a Project first.");
1111 getActiveProject : function() {
1112 return this.project;
1115 "leave_notify_event":function (self, event) {
1122 pack : "pack_start,false,false",
1125 xtype: Gtk.ComboBox,
1128 XObject.prototype.init.call(this);
1129 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1131 getValue : function() {
1132 var ix = this.el.get_active();
1136 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1139 setValue : function(fn)
1143 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1144 data.forEach(function(n, ix) {
1152 "changed":function (self) {
1153 var fn = this.getValue();
1154 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1155 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1160 xtype: Gtk.CellRendererText,
1161 pack : "pack_start,true",
1165 xtype: Gtk.ListStore,
1168 XObject.prototype.init.call(this);
1169 this.el.set_column_types ( 2, [
1170 GObject.TYPE_STRING, // real key
1171 GObject.TYPE_STRING // real type
1177 loadData : function(data) {
1178 var ov = this.get('/LeftProjectTree.combo').getValue();
1180 var iter = new Gtk.TreeIter();
1182 data.forEach(function(p) {
1187 el.set_value(iter, 0, p.fn);
1188 el.set_value(iter, 1, p.name);
1192 this.get('/LeftProjectTree.combo').setValue(ov);
1201 xtype: Gtk.ScrolledWindow,
1203 shadow_type : Gtk.ShadowType.IN,
1205 XObject.prototype.init.call(this);
1206 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1210 xtype: Gtk.TreeView,
1211 headers_visible : false,
1212 enable_tree_lines : true,
1215 XObject.prototype.init.call(this);
1216 var description = new Pango.FontDescription.c_new();
1217 description.set_size(8000);
1218 this.el.modify_font(description);
1220 this.selection = this.el.get_selection();
1221 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1225 "cursor_changed":function (self) {
1226 var iter = new Gtk.TreeIter();
1228 if (this.selection.count_selected_rows() < 1) {
1229 //XN.get('Builder.LeftTree.model').
1230 this.get('/LeftTree.model').load( false);
1234 var model = this.get('/LeftProjectTree.model');
1235 //console.log('changed');
1236 var s = this.selection;
1237 s.get_selected(model, iter);
1238 value = new GObject.Value('');
1239 model.el.get_value(iter, 2, value);
1241 console.log(value.value);// id..
1243 var file = this.get('/LeftProjectTree').project.getById(value.value);
1250 var nb = this.get('/LeftTopPanel.expander');
1251 nb.el.expanded = false;
1252 nb.listeners.activate.call(nb);
1253 //_expander.el.set_expanded(false);
1255 var ltm = this.get('/LeftTree.model');
1263 xtype: Gtk.TreeStore,
1267 XObject.prototype.init.call(this);
1268 this.el.set_column_types ( 3, [
1269 GObject.TYPE_STRING, // title
1270 GObject.TYPE_STRING, // tip
1271 GObject.TYPE_STRING // id..
1275 loadProject : function(pr) {
1280 this.get('/LeftProjectTree').project = pr;
1281 this.load(pr.toTree());
1282 this.get('/LeftProjectTree.view').el.expand_all();
1284 load : function(tr,iter) {
1286 console.log('Project tree load: ' + tr.length);
1287 var citer = new Gtk.TreeIter();
1288 //this.insert(citer,iter,0);
1291 tr.forEach(function (r) {
1293 _this.el.append(citer);
1295 _this.el.insert(citer,iter,-1);
1297 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1298 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1299 _this.el.set_value(citer, 2, '' + r.id ); //id
1300 if (r.cn && r.cn.length) {
1301 _this.load(r.cn, citer);
1306 getValue : function(iter, col) {
1307 var gval = new GObject.Value('');
1308 this.el.get_value(iter, col ,gval);
1309 return '' + gval.value;
1313 xtype: Gtk.TreeViewColumn,
1314 pack : "append_column",
1316 XObject.prototype.init.call(this);
1317 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1321 xtype: Gtk.CellRendererText,
1344 pack : "pack_start,false,true,0",
1351 "button_press_event":function (self, event) {
1352 this.get('/MidPropTree.model').showData('props');
1364 stock : Gtk.STOCK_ADD,
1365 icon_size : Gtk.IconSize.MENU
1380 "button_press_event":function (self, event) {
1381 this.get('/MidPropTree.model').showData('events');
1393 stock : Gtk.STOCK_ADD,
1394 icon_size : Gtk.IconSize.MENU
1409 "button_press_event":function (self, ev) {
1410 var p = this.get('/AddPropertyPopup');
1414 p.el.set_screen(Gdk.Screen.get_default());
1416 p.el.popup(null, null, null, null, 3, ev.button.time);
1428 stock : Gtk.STOCK_ADD,
1429 icon_size : Gtk.IconSize.MENU
1441 id : "AddPropertyPopup",
1444 xtype: Gtk.MenuItem,
1446 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1449 "activate":function (self) {
1451 this.get('/LeftPanel.model').add( {
1462 xtype: Gtk.MenuItem,
1464 tooltip_markup : "Add what type of packing is to be used",
1467 "activate":function (self) {
1469 this.get('/LeftPanel.model').add( {
1479 xtype: Gtk.MenuItem,
1481 tooltip_markup : "Override the init method",
1484 "activate":function (self) {
1486 this.get('/LeftPanel.model').add( {
1489 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1496 xtype: Gtk.SeparatorMenuItem,
1500 xtype: Gtk.MenuItem,
1502 tooltip_markup : "Add a user defined string property",
1505 "activate":function (self) {
1507 this.get('/LeftPanel.model').add( {
1517 xtype: Gtk.MenuItem,
1519 tooltip_markup : "Add a user defined number property",
1522 "activate":function (self) {
1524 this.get('/LeftPanel.model').add( {
1534 xtype: Gtk.MenuItem,
1536 tooltip_markup : "Add a user defined boolean property",
1539 "activate":function (self) {
1541 this.get('/LeftPanel.model').add( {
1551 xtype: Gtk.SeparatorMenuItem,
1555 xtype: Gtk.MenuItem,
1557 tooltip_markup : "Add a user function boolean property",
1560 "activate":function (self) {
1562 this.get('/LeftPanel.model').add( {
1565 val : "function() {\n \n}\n",
1578 xtype: Gtk.ScrolledWindow,
1581 shadow_type : Gtk.ShadowType.IN,
1584 XObject.prototype.init.call(this);
1585 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1589 xtype: Gtk.TreeView,
1592 headers_visible : false,
1593 enable_tree_lines : true,
1595 XObject.prototype.init.call(this);
1597 this.selection = this.el.get_selection();
1598 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1601 var description = new Pango.FontDescription.c_new();
1602 description.set_size(8000);
1603 this.el.modify_font(description);
1606 "button_press_event":function (self, ev) {
1610 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1611 return false; //not on a element.
1615 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1617 if (res.column.title != 'value') {
1618 return false; // ignore..
1620 if ( this.get('/LeftPanel').editing) {
1623 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1624 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1625 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1629 var provider = this.get('/LeftTree').getPaleteProvider();
1631 var opts = provider.findOptions(type);
1633 if (opts === false) {
1634 this.get('/LeftPanel').editableColumn.setOptions([]);
1635 renderer.has_entry = true;
1637 LeftPanel.editableColumn.setOptions(opts);
1638 renderer.has_entry = false;
1642 //Seed.print("click" + ev.type);
1643 //console.dump(res);
1649 if (res.column.title == 'value') {
1652 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1653 var p = this.get('/LeftPanelPopup');
1658 p.el.set_screen(Gdk.Screen.get_default());
1660 p.el.popup(null, null, null, null, 3, ev.button.time);
1661 //Seed.print("click:" + res.column.title);
1669 xtype: Gtk.TreeStore,
1673 XObject.prototype.init.call(this);
1674 this.el.set_column_types ( 5, [
1675 GObject.TYPE_STRING, // 0 real key
1676 GObject.TYPE_STRING, // 1 real value
1677 GObject.TYPE_STRING, // 2 visable key
1678 GObject.TYPE_STRING, // 3 visable value
1679 GObject.TYPE_STRING, // 4 need to store type of!!!
1683 toShort : function(str) {
1684 var a = typeof(str) == 'string' ? str.split("\n") : [];
1685 return a.length > 1 ? a[0] + '....' : '' + str;
1687 load : function(ar) {
1690 this.get('/RightEditor').el.hide();
1697 var provider = this.get('/LeftTree').getPaleteProvider();
1700 var iter = new Gtk.TreeIter();
1702 if (typeof(ar[i]) == 'object') {
1706 var type = provider.findType(ar, i, ar[i]);
1708 this.el.append(iter);
1709 var p = this.el.get_path(iter).to_string();
1711 this.el.set_value(iter, 0, i);
1712 this.el.set_value(iter, 1, '' + ar[i]);
1713 this.el.set_value(iter, 2, i);
1714 this.el.set_value(iter, 3, this.toShort(ar[i]));
1715 this.el.set_value(iter, 4, type);
1717 ar.listeners = ar.listeners || {};
1718 for (var i in ar.listeners ) {
1719 this.el.append(iter);
1720 var p = this.el.get_path(iter).to_string();
1723 this.el.set_value(iter, 0, '!'+ i );
1724 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1725 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1727 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1728 this.el.set_value(iter, 4, 'function');
1732 add : function(info) {
1733 // info includes key, val, skel, etype..
1735 type = info.type.toLowerCase();
1736 var data = this.toJS();
1738 if (info.etype == 'events') {
1739 data.listeners = data.listeners || { };
1740 if (typeof(data.listeners[info.key]) != 'undefined') {
1741 return; //already set!
1744 if (typeof(data[info.key]) != 'undefined') {
1749 if (typeof(info.val) == 'undefined') {
1752 if (info.type == 'boolean') {
1755 if (type == 'number') {
1763 if (info.etype == 'events') {
1765 data.listeners[info.key] = info.val;
1768 data[info.key] = info.val;
1772 var map = this.load(data);
1774 // flag it as changed to the interface..
1776 this.get('/LeftTree.model').changed(data, true);
1779 this.startEditing(map[k]);
1782 LeftPanel.get('view').el.row_activated(
1783 new Gtk.TreePath.from_string(map[k]),
1784 LeftPanel.editableColumn.el
1788 startEditing : function(path,col) {
1790 * start editing path (or selected if not set..)
1791 * @param {String|false} path (optional) treepath to edit - selected tree gets
1792 * edited by default.
1793 * @param {Number} 0 or 1 (optional)- column to edit.
1796 if (typeof(path) == 'string') {
1797 tp = new Gtk.TreePath.from_string(path);
1799 var iter = new Gtk.TreeIter();
1800 var s = this.get('/LeftPanel.view').selection;
1801 s.get_selected(this.el, iter);
1802 tp = this.el.get_path(iter);
1803 path = tp.to_string();
1807 // which colum is to be edited..
1809 if (typeof(col) == 'undefined') {
1810 var k = this.getValue(path, 0);
1811 colObj = (!k.length || k == '|') ?
1812 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1814 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1817 // make sure the pulldown is set correctly..
1818 // not really needed for second col...
1820 var provider = this.get('/LeftTree').getPaleteProvider();
1822 var type = this.get('/LeftPanel.model').getType(path);
1823 var opts = provider.findOptions(type);
1824 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1826 if (opts === false) {
1827 this.get('/LeftPanel').editableColumn.setOptions([]);
1828 renderer.has_entry = true; /// probably does not have any effect.
1830 this.get('/LeftPanel').editableColumn.setOptions(opts);
1831 renderer.has_entry = false;
1835 // iter now has row...
1836 GLib.timeout_add(0, 100, function() {
1838 colObj.items[0].el.editable = true; // esp. need for col 0..
1839 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1848 deleteSelected : function() {
1849 var data = this.toJS();
1850 var iter = new Gtk.TreeIter();
1851 var s = this.get('/LeftPanel.view').selection;
1852 s.get_selected(this.el, iter);
1855 var gval = new GObject.Value('');
1856 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1858 var val = gval.value;
1859 if (val[0] == '!') {
1861 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1864 delete data.listeners[ val.substring(1)];
1865 if (!XObject.keys(data.listeners).length) {
1866 delete data.listeners;
1870 if (typeof(data[val]) == 'undefined') {
1878 this.get('/LeftTree.model').changed(data, true);
1882 changed : function(str, doRefresh) {
1883 if (!this.activePath) {
1886 var iter = new Gtk.TreeIter();
1887 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1889 this.el.set_value(iter, 1, '' +str);
1890 this.el.set_value(iter, 3, '' + this.toShort(str));
1891 // update the tree...
1893 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
1896 var iter = new Gtk.TreeIter();
1897 this.get('/LeftPanel.model').el.get_iter_first(iter);
1902 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
1905 ar.listeners = ar.listeners || {};
1906 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
1909 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
1912 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
1918 //print(JSON.stringify(ar));
1922 getType : function(treepath) {
1923 return this.getValue(treepath, 4);
1925 getValue : function(treepath_str, col) {
1926 var iter = new Gtk.TreeIter();
1927 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
1929 var gval = new GObject.Value('');
1930 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
1931 var val = '' + gval.value;
1935 var type = this.getType(this.el.get_path(iter).to_string());
1936 //print("TYPE: " +type + " - val:" + val);
1937 switch(type.toLowerCase()) {
1941 return parseFloat(val); // Nan ?? invalid!!?
1943 return val == 'true' ? true : false;
1949 editSelected : function(e) {
1950 print("EDIT SELECTED?");
1951 var iter = new Gtk.TreeIter();
1952 var s = this.get('/LeftPanel.view').selection;
1953 s.get_selected(this.get('/LeftPanel.model').el, iter);
1954 var m = this.get('/LeftPanel.model')
1956 var gval = new GObject.Value('');
1957 this.el.get_value(iter, 0 ,gval);
1958 var val = '' + gval.value;
1960 gval = new GObject.Value('');
1961 this.el.get_value(iter, 1 ,gval);
1962 var rval = gval.value;
1963 var activePath = this.el.get_path(iter).to_string();
1964 this.activePath = activePath ;
1965 // was activeIter...
1968 var showEditor = false;
1970 if (val[0] == '!') {
1973 if (val[0] == '|') {
1974 if (rval.match(/function/g) || rval.match(/\n/g)) {
1981 this.activePath = false;
1982 GLib.timeout_add(0, 1, function() {
1983 // Gdk.threads_enter();
1984 _this.get('/RightEditor').el.show();
1985 _this.get('/RightEditor.view').load( rval );
1989 _this.activePath = activePath ;
1991 // Gdk.threads_leave();
1997 this.get('/RightEditor').el.hide();
1999 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2005 xtype: Gtk.TreeViewColumn,
2006 pack : "append_column",
2008 XObject.prototype.init.call(this);
2010 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2011 this.get('/LeftPanel').propertyColumn = this;
2016 xtype: Gtk.CellRendererText,
2017 pack : "pack_start",
2019 "editing_started":function (self, editable, path) {
2021 this.get('/LeftPanel.model').activePath = path;
2024 "edited":function (self, object, p0) {
2025 var model = this.get('/LeftPanel.model');
2026 var path = model.activePath;
2027 var iter = new Gtk.TreeIter();
2028 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2029 model.el.set_value(iter, 0, p0);
2030 model.el.set_value(iter, 2, p0);
2032 model.activePath = false;
2034 this.get('/LeftTree.model').changed(model.toJS(), true);
2035 this.el.editable = false;
2042 xtype: Gtk.TreeViewColumn,
2043 pack : "append_column",
2045 XObject.prototype.init.call(this);
2046 this.el.add_attribute(this.items[0].el , 'text', 3 );
2047 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2048 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2049 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2051 this.get('/LeftPanel').editableColumn= this;
2053 setOptions : function(ar) {
2054 var m = this.items[0].el.model;
2056 var iter = new Gtk.TreeIter();
2057 ar.forEach(function(i) {
2060 m.set_value(iter, 0, i);
2066 xtype: Gtk.CellRendererCombo,
2067 pack : "pack_start",
2072 XObject.prototype.init.call(this);
2073 this.el.model = new Gtk.ListStore();
2074 this.el.model.set_column_types ( 1, [
2075 GObject.TYPE_STRING // 0 real key
2079 "edited":function (self, object, p0) {
2080 this.get('/LeftPanel').editing = false;
2081 print("EDITED? p:" + p0 + " t:" + p0);
2082 this.get('/LeftPanel.model').changed(p0, true);
2083 this.get('/LeftPanel.model').activePath = false;
2085 "editing_started":function (self, editable, path) {
2086 this.get('/LeftPanel').editing = true;
2087 // console.log('editing started');
2088 // r.has_entry = false;
2089 this.get('/LeftPanel.model').editSelected(editable);
2100 id : "LeftPanelPopup",
2103 xtype: Gtk.MenuItem,
2107 "activate":function (self) {
2108 this.get('/LeftPanel.model').deleteSelected();
2113 xtype: Gtk.MenuItem,
2117 "activate":function (self) {
2118 this.get('/LeftPanel.model').startEditing(false, 0);
2131 xtype: Gtk.ScrolledWindow,
2132 pack : "pack_end,false,true,0",
2134 shadow_type : Gtk.ShadowType.IN,
2136 XObject.prototype.init.call(this);
2137 XObject.prototype.init.call(this);
2138 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2139 this.el.set_size_request ( 150, -1 );
2142 activeElement : false,
2143 hideWin : function() {
2150 if (this.get('/Window.left').el.position < 160) {
2153 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2160 xtype: Gtk.TreeView,
2161 enable_tree_lines : true,
2162 headers_visible : false,
2165 XObject.prototype.init.call(this);
2167 var description = new Pango.FontDescription.c_new();
2168 description.set_size(8000);
2169 this.el.modify_font(description);
2171 //this.selection = this.el.get_selection();
2172 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2181 "cursor_changed":function (self) {
2182 var iter = new Gtk.TreeIter();
2184 //console.log('changed');
2185 var m = this.get('model');
2186 if (!this.selection){
2187 this.selection = this.el.get_selection();
2190 var s = this.selection;
2191 if (!s.get_selected(m.el, iter)) {
2194 var tp = m.el.get_path(iter).to_string();
2199 var key = m.getValue(tp, 0);
2201 var type = m.getValue(tp, 1);
2202 var skel = m.getValue(tp, 3);
2203 var etype = m.getValue(tp, 5);
2206 this.get('/MidPropTree').hideWin();
2208 if (type == 'function') {
2210 if (etype != 'events') {
2214 this.get('/LeftPanel.model').add({
2223 if (type.indexOf('.') > -1 ||
2224 type == 'boolean') {
2228 this.get('/LeftPanel.model').add( {
2238 xtype: Gtk.ListStore,
2241 XObject.prototype.init.call(this);
2242 this.el.set_column_types ( 6, [
2243 GObject.TYPE_STRING, // real key
2244 GObject.TYPE_STRING, // real type
2245 GObject.TYPE_STRING, // docs ?
2246 GObject.TYPE_STRING, // visable desc
2247 GObject.TYPE_STRING, // function desc
2248 GObject.TYPE_STRING // element type (event|prop)
2252 getValue : function(treepath, col)
2254 var tp = new Gtk.TreePath.from_string (treepath);
2255 var iter = new Gtk.TreeIter();
2256 this.el.get_iter (iter, tp);
2257 var value = new GObject.Value('');
2258 this.el.get_value(iter, col, value);
2262 showData : function(type) {
2264 if (!this.get('/MidPropTree').activeElement || !type) {
2265 return; // no active element
2268 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2269 var palete = this.get('/LeftTree').getPaleteProvider();
2273 Seed.print('Showing right?');
2274 if (!this.get('/MidPropTree').shown) {
2276 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2277 this.get('/MidPropTree').el.show();
2278 this.get('/MidPropTree').shown = true;
2281 var elementList = palete.getPropertiesFor(fullpath, type);
2282 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2283 // console.dump(elementList);
2286 var iter = new Gtk.TreeIter();
2287 for(var i =0 ; i < elementList.length; i++) {
2288 var p=elementList[i];
2289 this.el.append(iter);
2290 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2291 //GObject.TYPE_STRING, // real key
2292 // GObject.TYPE_STRING, // real type
2293 // GObject.TYPE_STRING, // docs ?
2294 // GObject.TYPE_STRING // func def?
2297 this.el.set_value(iter, 0, p.name);
2298 this.el.set_value(iter, 1, p.type);
2299 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2300 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2301 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2302 this.el.set_value(iter, 5, type);
2310 xtype: Gtk.TreeViewColumn,
2312 this.el = new Gtk.TreeViewColumn();
2313 this.parent.el.append_column(this.el);
2315 XObject.prototype.init.call(this);
2316 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2321 xtype: Gtk.CellRendererText,
2322 pack : "pack_start,true"
2346 xtype: Gtk.Notebook,
2347 pack : "pack_start,true,true",
2348 id : "view-notebook",
2351 XObject.prototype.init.call(this);
2352 this.el.set_current_page(0);
2354 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2355 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2362 id : "RightBrowser",
2366 pack : "pack_start,false,true,0",
2370 pack : "pack_start,false,false,0",
2371 label : "Dump HTML to console",
2373 "activate":function (self) {
2374 this.get('/RightBrowser.view').el.execute_script(
2375 "console.log(document.body.innerHTML);");
2376 this.get('/RightBrowser.view').el.execute_script(
2377 "console.log(Builder.dump(Builder));");
2384 xtype: Gtk.ScrolledWindow,
2386 shadow_type : Gtk.ShadowType.IN,
2388 XObject.prototype.init.call(this);
2389 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2393 xtype: WebKit.WebView,
2397 XObject.prototype.init.call(this);
2398 // this may not work!?
2399 this.el.open('file:///' + __script_path__ + '/../builder.html');
2403 this.el, /* widget that will accept a drop */
2404 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2405 null, /* lists of target to support */
2406 0, /* size of list */
2407 Gdk.DragAction.COPY /* what to do with data after dropped */
2410 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2411 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2413 renderJS : function(data) {
2414 this.renderedData = data;
2415 var str = JSON.stringify(data) ;
2418 console.log('not loaded yet');
2420 Seed.print("RENDER:" + str);
2421 imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2422 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2425 "load_finished":function (self, object) {
2426 if (this.ready) { // dont do it twice!
2431 this.renderJS(this.get('/LeftTree.model').toJS()[0]);
2433 "script_alert":function (self, object, p0) {
2436 return true; // do not display anything...
2438 "console_message":function (self, object, p0, p1) {
2439 console.log(object);
2440 if (!object.match(/^\{/)) {
2441 return false; // do not handle!!! -> later maybe in console..
2443 console.log(object);
2444 var val = JSON.parse(object);
2446 if (typeof(val['hover-node']) != 'undefined') {
2447 this.activeNode = val['hover-node'];
2448 console.log('active node: ' + this.activeNode);
2453 if (typeof(val['id']) != 'undefined') {
2454 // this.activeNode = val['id'];
2455 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2459 this.get('/LeftTree.view').selectNode(tg[0]);
2463 if (ret && typeof(val['set']) != 'undefined') {
2464 this.get('/LeftPanel.model').add({
2468 //console.log('active node: ' + this.activeNode);
2471 //Seed.print('a:'+a);
2472 //Seed.print('b:'+b);
2473 //Seed.print('c:'+c);
2476 "drag_motion":function (w, ctx, x, y, time, ud) {
2477 // console.log('DRAG MOTION');
2479 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2480 this.targetData = [];
2481 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2483 // A) find out from drag all the places that node could be dropped.
2484 var src = Gtk.drag_get_source_widget(ctx);
2485 if (!src.dropList) {
2486 Gdk.drag_status(ctx, 0, time);
2489 // b) get what we are over.. (from activeNode)
2490 // tree is empty.. - list should be correct..
2491 if (!this.get('/LeftTree.model').currentTree) {
2492 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2496 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2498 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2501 Gdk.drag_status(ctx, 0,time);
2502 this.get('/LeftTree.view').highlight(false);
2506 // if we have a target..
2507 // -> highlight it! (in browser)
2508 // -> highlight it! (in tree)
2510 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2511 this.get('/LeftTree.view').highlight(tg);
2512 this.targetData = tg;
2513 // for tree we should handle this...
2516 "drag_drop":function (w, ctx, x, y,time, ud) {
2517 print("TARGET: drag-drop");
2518 var is_valid_drop_site = true;
2523 w, /* will receive 'drag-data-received' signal */
2524 ctx, /* represents the current state of the DnD */
2525 this.get('/Window').atoms["STRING"], /* the target type we want */
2526 time /* time stamp */
2530 /* No target offered by source => error */
2533 return is_valid_drop_site;
2535 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2537 print("Browser: drag-data-received");
2538 var delete_selection_data = false;
2539 vardnd_success = false;
2540 /* Deal with what we are given from source */
2541 if( sel_data && sel_data.length ) {
2543 if (ctx.action == Gdk.DragAction.ASK) {
2544 /* Ask the user to move or copy, then set the ctx action. */
2547 if (ctx.action == Gdk.DragAction.MOVE) {
2548 delete_selection_data = true;
2550 var source = Gtk.drag_get_source_widget(ctx);
2552 print("Browser: source.DRAGDATA? " + source.dragData);
2553 if (this.targetData) {
2554 print(this.targetData);
2555 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2564 if (dnd_success == false)
2566 Seed.print ("DnD data transfer failed!\n");
2569 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2581 id : "RightGtkView",
2582 renderJS : function(data, withDebug)
2587 this.withDebug = false;
2589 if (this.renderedEl) {
2590 this.get('view').el.remove(this.renderedEl);
2591 this.renderedEl.destroy();
2592 this.renderedEl = false;
2595 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2596 // in theory tree is actually window..
2598 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2603 this.get('view').el.set_size_request(
2604 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2607 this.renderedEl.set_size_request(
2608 tree.default_width || 600,
2609 tree.default_height || 400
2611 this.get('view').el.show_all();
2616 showInWindow : function() {
2617 print("GET PROEJCT");
2618 var pr = this.get('/LeftProjectTree').getActiveProject();
2620 console.log(pr.paths);
2623 var src= this.buildJS(
2624 this.get('/LeftTree.model').toJS()[0],
2629 //var x = new imports.sandbox.Context();
2633 Seed.check_syntax('var e = ' + src);
2636 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2637 this.get('/Terminal').feed(console._dump(e)+"\n");
2639 var lines = src.split("\n");
2640 var start = Math.max(0, e.line - 10);
2641 var end = Math.min(lines.length, e.line + 10);
2642 for (var i =start ; i < end; i++) {
2644 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2647 this.get('/Terminal').feed(lines[i] + "\n");
2654 this.get('/BottomPane').el.set_current_page(1);
2655 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2656 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2657 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2659 var _top = x.get_global_object()._top;
2661 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2663 if (_top.el.popup) {
2664 _top.el.popup(null, null, null, null, 3, null);
2668 viewAdd : function(item, par)
2670 // does something similar to xobject..
2671 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2673 if (item.pack===false || item.pack === 'false') { // no ;
2676 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2677 var ns = imports.gi[item['|xns']];
2678 var ctr = ns[item['xtype']];
2680 for(var k in item) {
2682 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2697 if (k[0] == '|' && typeof(kv) == 'string') {
2699 if (kv.match(new RegExp('function'))) {
2702 print("WASL " + k + '=' + kv);
2704 eval( 'kv = ' + kv);
2705 } catch(e) { continue; }
2708 print(k + '=' + kv);
2710 if (k[0] == '|') { // should be boolean or number..
2713 if (k == 'show_tabs') { // force tab showing for notebooks.
2721 var el = new ctr(ctr_args);
2724 //console.dump(item.pack);
2731 if (typeof(item.pack) == 'string') {
2733 item.pack.split(',').forEach(function(e, i) {
2735 if (e == 'false') { args.push( false); return; }
2736 if (e == 'true') { args.push( true); return; }
2737 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2740 //print(args.join(","));
2742 pack_m = args.shift();
2744 pack_m = item.pack.shift();
2749 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2751 name: "ArgumentError",
2752 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2753 "ADDING : " + item.id + " " + el
2762 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2763 //Seed.print('args: ' + args.length);
2765 par[pack_m].apply(par, args);
2769 item.items = item.items || [];
2770 item.items.forEach(function(ch) {
2771 _this.viewAdd(ch, el);
2776 // add the signal handlers.
2777 // is it a widget!?!!?
2783 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2784 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2785 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2786 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2787 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2797 widgetExposeEvent : function() {
2798 /// print("WIDGET EXPOSE"); // draw highlight??
2801 widgetDragMotionEvent : function() {
2802 print("WIDGET DRAGMOTION");
2805 widgetDragDropEvent : function() {
2806 print("WIDGET DRAGDROP");
2809 widgetPressEvent : function(w,e,u,d) {
2810 if (this.get('view').pressed) {
2813 this.get('view').pressed = true;
2814 print("WIDGET PRESS " + d.xtreepath );
2815 this.get('/LeftTree.view').selectNode( d.xtreepath );
2818 widgetReleaseEvent : function() {
2819 this.get('view').pressed = false;
2825 pack : "pack_start,false,true,0",
2829 pack : "pack_start,false,false,0",
2830 label : "Run The Application",
2832 "button_press_event":function (self, event) {
2833 // call render on left tree - with special option!?!
2837 print("GET PROEJCT");
2838 var pr = this.get('/LeftProjectTree').getActiveProject();
2841 for (var i in pr.paths) {
2845 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
2846 print ("RUN DIR:" + dir);
2848 this.get('/BottomPane').el.set_current_page(1);
2849 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
2850 , false,false,false);
2851 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
2852 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2862 xtype: Gtk.ScrolledWindow,
2865 shadow_type : Gtk.ShadowType.IN,
2867 XObject.prototype.init.call(this);
2868 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2872 xtype: Gtk.EventBox,
2875 XObject.prototype.init.call(this);
2876 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
2877 red: 0x9F00, green: 0xB800 , blue : 0xA800
2885 XObject.prototype.init.call(this);
2886 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
2887 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
2892 xtype: Gtk.EventBox,
2895 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
2896 XObject.prototype.init.call(this);
2900 this.el, /* widget that will accept a drop */
2901 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2902 null, /* lists of target to support */
2903 0, /* size of list */
2904 Gdk.DragAction.COPY /* what to do with data after dropped */
2907 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2908 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2911 getActiveNode : function(x,y)
2913 // workout what node is here..
2914 return '0'; // top..
2918 "drag_motion":function (self, ctx, x, y, time) {
2920 // A) find out from drag all the places that node could be dropped.
2921 var src = Gtk.drag_get_source_widget(ctx);
2922 if (!src.dropList) {
2923 Gdk.drag_status(ctx, 0, time);
2926 // b) get what we are over.. (from activeNode)
2927 // tree is empty.. - list should be correct..
2928 if (!this.get('/LeftTree.model').currentTree) {
2929 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2933 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2934 var activeNode = this.getActiveNode(x, y);
2937 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
2940 Gdk.drag_status(ctx, 0,time);
2941 this.get('/LeftTree.view').highlight(false);
2945 // if we have a target..
2946 // -> highlight it! (in browser)
2947 // -> highlight it! (in tree)
2949 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2950 this.get('/LeftTree.view').highlight(tg);
2951 this.targetData = tg;
2952 // for tree we should handle this...
2955 "drag_drop":function (self,ctx, x, y, time) {
2956 Seed.print("TARGET: drag-drop");
2957 var is_valid_drop_site = true;
2962 self, /* will receive 'drag-data-received' signal */
2963 ctx, /* represents the current state of the this.gDnD */
2964 this.get('/Window').atoms["STRING"], /* the target type we want */
2965 time /* time stamp */
2969 /* No target offered by source => error */
2972 return is_valid_drop_site;
2975 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2977 Seed.print("GtkView: drag-data-received");
2978 var delete_selection_data = false;
2979 var dnd_success = false;
2980 /* Deal with what we are given from source */
2981 if( sel_data && sel_data.length ) {
2983 if (ctx.action == Gdk.DragAction.ASK) {
2984 /* Ask the user to move or copy, then set the ctx action. */
2987 if (ctx.action == Gdk.DragAction.MOVE) {
2988 delete_selection_data = true;
2990 var source = Gtk.drag_get_source_widget(ctx);
2992 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
2993 if (this.targetData) {
2994 Seed.print(this.targetData);
2995 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3004 if (dnd_success == false)
3006 Seed.print ("DnD data transfer failed!\n");
3009 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3012 "button_press_event":function (self, event) {
3013 this.pressed = false;
3031 xtype: Gtk.Notebook,
3034 XObject.prototype.init.call(this);
3035 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3036 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3041 xtype: Gtk.ScrolledWindow,
3046 xtype: GtkSource.View,
3050 XObject.prototype.init.call(this);
3051 var description = Pango.Font.description_from_string("monospace")
3052 description.set_size(8000);
3053 this.el.modify_font(description);
3056 load : function(str) {
3057 this.get('/BottomPane').el.set_current_page(0);
3058 this.el.get_buffer().set_text(str, str.length);
3059 var lm = GtkSource.LanguageManager.get_default();
3061 this.el.get_buffer().set_language(lm.get_language('js'));
3062 var buf = this.el.get_buffer();
3063 var cursor = buf.get_mark("insert");
3064 var iter= new Gtk.TextIter;
3065 buf.get_iter_at_mark(iter, cursor);
3067 iter.set_line_offset(4);
3068 buf.move_mark(cursor, iter);
3071 cursor = buf.get_mark("selection_bound");
3072 iter= new Gtk.TextIter;
3073 buf.get_iter_at_mark(iter, cursor);
3075 iter.set_line_offset(4);
3076 buf.move_mark(cursor, iter);
3078 this.el.grab_focus();
3082 xtype: GtkSource.Buffer,
3083 pack : "set_buffer",
3085 "changed":function (self) {
3086 var s = new Gtk.TextIter();
3087 var e = new Gtk.TextIter();
3088 this.el.get_start_iter(s);
3089 this.el.get_end_iter(e);
3090 var str = this.el.get_text(s,e,true);
3092 Seed.check_syntax('var e = ' + str);
3094 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3095 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3097 print("SYNTAX ERROR IN EDITOR");
3102 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3103 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3106 this.get('/LeftPanel.model').changed( str , false);
3115 xtype: Gtk.ScrolledWindow,
3119 xtype: Vte.Terminal,
3122 feed : function(str) {
3123 this.el.feed(str,str.length);
3134 pack : "pack_start,false,false",
3138 this.get('buttonbar').el.show();
3139 this.get('viewbox').el.hide();
3140 print("TRIED TO HIDE");
3143 this.get('buttonbar').el.hide();
3144 this.get('viewbox').el.show();
3145 // this.get('model').expanded();
3157 pack : "pack_start,false,true",
3159 "clicked":function (self) {
3160 this.get('/RightPalete').show();
3167 stock : Gtk.STOCK_GOTO_FIRST,
3168 icon_size : Gtk.IconSize.MENU
3178 XObject.prototype.init.call(this);
3179 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3182 "enter_notify_event":function (self, event) {
3183 this.get('/RightPalete').show();
3197 pack : "pack_start,false,true",
3206 pack : "pack_start,false,true",
3208 "clicked":function (self) {
3209 this.get('/RightPalete').hide();
3216 stock : Gtk.STOCK_GOTO_LAST,
3217 icon_size : Gtk.IconSize.MENU
3224 xtype: Gtk.ScrolledWindow,
3227 XObject.prototype.init.call(this);
3228 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3229 this.el.set_size_request(-1,200);
3231 shadow_type : Gtk.ShadowType.IN,
3234 xtype: Gtk.TreeView,
3237 XObject.prototype.init.call(this);
3238 this.el.set_size_request(150,-1);
3239 // set_reorderable: [1]
3241 var description = new Pango.FontDescription.c_new();
3242 description.set_size(8000);
3243 this.el.modify_font(description);
3245 this.selection = this.el.get_selection();
3246 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3247 // this.selection.signal['changed'].connect(function() {
3248 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3250 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3252 Gtk.drag_source_set (
3253 this.el, /* widget will be drag-able */
3254 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3255 null, /* lists of target to support */
3256 0, /* size of list */
3257 Gdk.DragAction.COPY /* what to do with data after dropped */
3259 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3261 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3262 Gtk.drag_source_add_text_targets(this.el);
3264 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3265 targets = new Gtk.TargetList();
3266 targets.add( LeftTree.atoms["STRING"], 0, 0);
3267 targets.add_text_targets( 1 );
3268 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3270 //if you want to allow text to be output elsewhere..
3271 //Gtk.drag_source_add_text_targets(this.el);
3275 headers_visible : false,
3276 enable_tree_lines : true,
3278 "drag_begin":function (self, ctx) {
3279 // we could fill this in now...
3280 Seed.print('SOURCE: drag-begin');
3284 var iter = new Gtk.TreeIter();
3285 var s = this.selection;
3286 s.get_selected(this.get('/RightPalete.model').el, iter);
3287 var path = this.get('/RightPalete.model').el.get_path(iter);
3289 var pix = this.el.create_row_drag_icon ( path);
3292 Gtk.drag_set_icon_pixmap (ctx,
3299 var value = new GObject.Value('');
3300 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3301 if (!this.get('/RightPalete').provider) {
3304 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3305 this.el.dragData = value.value;
3312 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3313 //Seed.print('Palete: drag-data-get: ' + target_type);
3314 if (this.el.dragData && this.el.dragData.length ) {
3315 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3319 //this.el.dragData = "TEST from source widget";
3323 "drag_end":function (self, drag_context) {
3324 Seed.print('SOURCE: drag-end');
3325 this.el.dragData = false;
3326 this.el.dropList = false;
3327 this.get('/LeftTree.view').highlight(false);
3333 xtype: Gtk.ListStore,
3336 XObject.prototype.init.call(this);
3337 this.el.set_column_types ( 2, [
3338 GObject.TYPE_STRING, // title
3339 GObject.TYPE_STRING // tip
3344 load : function(tr,iter)
3349 //console.log('Project tree load: ' + tr.length);
3350 var citer = new Gtk.TreeIter();
3351 //this.insert(citer,iter,0);
3352 for(var i =0 ; i < tr.length; i++) {
3355 this.el.append(citer);
3357 this.el.insert(citer,iter,-1);
3362 this.el.set_value(citer, 0, '' + r ); // title
3364 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3365 //if (r.cn && r.cn.length) {
3366 // this.load(r.cn, citer);
3372 getValue : function (iter, col) {
3373 var gval = new GObject.Value('');
3374 this.el.get_value(iter, col ,gval);
3381 xtype: Gtk.TreeViewColumn,
3382 pack : "append_column",
3384 XObject.prototype.init.call(this);
3385 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3389 xtype: Gtk.CellRendererText,
3411 XObject.cache['/Window'] = Window;