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) {
78 this.get('/EditProject').show({
79 success : function(pr) {
80 _this.get('/LeftProjectTree').get('combo').setValue(pr.fn);
91 "activate":function (self) {
92 var fn = this.get('/LeftProjectTree.combo').getValue();
94 this.get('/LeftProjectTree').showNoProjectSelected();
97 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
98 this.get('/DialogNewComponent').show({
99 project : pm.getByFn(fn)
105 xtype: Gtk.SeparatorMenuItem,
112 use_underline : true,
114 "activate":function (self) {
148 label : "Select Project",
150 pack : "pack_start,false,true",
152 XObject.prototype.init.call(this);
153 this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
156 "activate":function (self) {
157 var nb = this.get('/LeftTopPanel.notebook');
158 if (this.el.expanded) {
161 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
164 var model = this.get('/LeftProjectTree.combomodel');
165 // print ("loading Projects?")
166 //console.dump(pm.projects);
167 model.loadData(pm.projects);
170 nb.el.set_current_page(1);
171 //pm.on('changed', function() {
172 //console.log("CAUGHT project manager change");
173 // _combo.model.loadData(pm.projects);
177 nb.el.set_current_page(0);
179 "enter_notify_event":function (self, event) {
180 this.el.expanded = !this.el.expanded;
181 //if (this.el.expanded ) {
182 this.listeners.activate.call(this);
194 pack : "pack_start,true,true",
196 XObject.prototype.init.call(this);
197 this.el.set_current_page(0);
202 xtype: Gtk.ScrolledWindow,
204 shadow_type : Gtk.ShadowType.IN,
206 XObject.prototype.init.call(this);
207 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
210 getPaleteProvider : function() {
211 var model = this.get('model');
212 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
213 return pm.getPalete(model.file.getType());
215 renderView : function() {
216 var model = this.get('model');
217 print("RENDER VIEW?" + model.file.getType());
218 switch( model.file.getType()) {
220 this.get('/RightBrowser.view').renderJS(model.toJS(false,true)[0]);
222 this.get('/RightGtkView').renderJS(model.toJS(false,true)[0]);
230 headers_visible : false,
231 enable_tree_lines : true,
234 XObject.prototype.init.call(this);
235 var description = new Pango.FontDescription.c_new();
236 description.set_size(8000);
237 this.el.modify_font(description);
239 this.selection = this.el.get_selection();
240 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
242 this.selection.signal['changed'].connect(function() {
243 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
244 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
248 Gtk.drag_source_set (
249 this.el, /* widget will be drag-able */
250 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
251 null, /* lists of target to support */
252 0, /* size of list */
253 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
256 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
258 Gtk.drag_source_add_text_targets(this.el);
261 this.el, /* widget that will accept a drop */
262 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
263 null, /* lists of target to support */
264 0, /* size of list */
265 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
268 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
269 Gtk.drag_dest_add_text_targets(this.el);
271 highlight : function(treepath_ar) {
272 if (treepath_ar.length && treepath_ar[0].length ) {
273 this.el.set_drag_dest_row(
274 new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);
276 this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
280 selectNode : function(treepath_str) {
281 //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
282 var tp = new Gtk.TreePath.from_string(treepath_str);
283 this.el.set_cursor(tp, null, false);
284 this.el.scroll_to_cell(tp, null, false, 0,0);
287 "button_press_event":function (self, ev) {
288 console.log("button press?");
289 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
290 print("click" + ev.type);
296 this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
298 if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();
300 this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
301 this.get('/LeftTreeMenu').el.show_all();
302 this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
303 print("click:" + res.path.to_string());
306 "drag_begin":function (self, drag_context) {
307 print('SOURCE: drag-begin');
308 this.targetData = false;
309 // find what is selected in our tree...
310 var iter = new Gtk.TreeIter();
311 var s = this.selection;
312 s.get_selected(this.get('/LeftTree.model').el, iter);
314 // set some properties of the tree for use by the dropped element.
315 var value = new GObject.Value('');
316 this.get('/LeftTree.model').el.get_value(iter, 2, value);
317 var data = JSON.parse(value.value);
318 var xname = this.get('/LeftTree.model').file.guessName(data);
320 this.el.dragData = xname;
321 this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);
324 // make the drag icon a picture of the node that was selected
325 var path = this.get('/LeftTree.model').el.get_path(iter);
326 this.el.treepath = path.to_string();
328 var pix = this.el.create_row_drag_icon ( path);
330 Gtk.drag_set_icon_pixmap (ctx,
339 "drag_end":function (self, drag_context) {
340 Seed.print('LEFT-TREE: drag-end');
341 this.el.dragData = false;
342 this.el.dropList = false;
343 this.targetData = false;
344 this.get('/LeftTree.view').highlight(false);
347 "drag_motion":function (self, ctx, x, y, time) {
348 console.log("LEFT-TREE: drag-motion");
349 var src = Gtk.drag_get_source_widget(ctx);
351 // a drag from elsewhere...- prevent drop..
353 print("no drag data!");
354 Gdk.drag_status(ctx, 0, time);
355 this.targetData = false;
358 var action = Gdk.DragAction.COPY;
359 if (src == this.el) {
360 // unless we are copying!!! ctl button..
361 action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
365 if (!this.get('/LeftTree.model').el.iter_n_children(null)) {
366 // no children.. -- asume it's ok..
367 this.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];
368 Gdk.drag_status(ctx, action ,time);
372 print("GETTING POS");
373 var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);
374 print("ISOVER? " + isOver);
376 Gdk.drag_status(ctx, 0 ,time);
377 return false; // not over apoint!?!
379 // drag node is parent of child..
380 console.log("SRC TREEPATH: " + src.treepath);
381 console.log("TARGET TREEPATH: " + data.path.to_string());
383 // nned to check a few here..
384 //Gtk.TreeViewDropPosition.INTO_OR_AFTER
385 //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
386 //Gtk.TreeViewDropPosition.AFTER
387 //Gtk.TreeViewDropPosition.BEFORE
389 if (typeof(src.treepath) != 'undefined' &&
390 src.treepath == data.path.to_string().substring(0,src.treepath.length)) {
391 print("subpath drag");
392 Gdk.drag_status(ctx, 0 ,time);
397 //print("DUMPING DATA");
398 //console.dump(data);
401 print(data.path.to_string() +' => '+ data.pos);
402 var tg = this.get('/LeftTree.model').findDropNodeByPath(
403 data.path.to_string(), src.dropList, data.pos);
405 this.get('/LeftTree.view').highlight(tg);
407 print("Can not find drop node path");
408 this.targetData = false;
409 Gdk.drag_status(ctx, 0, time);
413 this.targetData = tg;
416 Gdk.drag_status(ctx, action ,time);
420 "drag_drop":function (w, ctx, x, y, time) {
421 Seed.print("TARGET: drag-drop");
425 w, /* will receive 'drag-data-received' signal */
426 ctx, /* represents the current state of the DnD */
427 this.get('/Window').atoms["STRING"], /* the target type we want */
428 time /* time stamp */
432 /* No target offered by source => error */
437 "drag_data_received":function (self, ctx, x, y, sel_data, info, time) {
438 print("Tree: drag-data-received");
440 var delete_selection_data = false;
441 var dnd_success = false;
442 /* Deal with what we are given from source */
443 if( sel_data && sel_data.length ) {
445 if (ctx.action == Gdk.DragAction.ASK) {
446 /* Ask the user to move or copy, then set the ctx action. */
449 if (ctx.action == Gdk.DragAction.MOVE) {
450 //delete_selection_data = true;
453 var source = Gtk.drag_get_source_widget(ctx);
455 if (this.targetData) {
456 if (source != this.el) {
457 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
459 // drag around.. - reorder..
460 this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);
464 //Seed.print(this.targetData);
470 // we can send stuff to souce here...
476 if (dnd_success == false)
478 Seed.print ("DnD data transfer failed!\n");
481 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
484 "cursor_changed":function (self) {
485 if (this.blockChanges) {
488 var iter = new Gtk.TreeIter();
490 if (this.selection.count_selected_rows() < 1) {
491 this.get('/LeftPanel.model').load( false);
492 this.get('/MidPropTree').activeElement = false;
493 this.get('/MidPropTree').hideWin();
495 var pm = this.get('/RightPalete.model');
496 if (!this.get('/LeftTree').getPaleteProvider()) {
497 // it may not be loaded yet..
500 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
501 this.get('/LeftTree.model').listAllTypes()));
506 //console.log('changed');
507 var s = this.selection;
508 s.get_selected(this.get('/LeftTree.model').el, iter);
512 value = new GObject.Value('');
513 this.get('/LeftTree.model').el.get_value(iter, 2, value);
514 this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
516 var data = JSON.parse(value.value);
517 this.get('/MidPropTree').activeElement = data;
518 this.get('/MidPropTree').hideWin();
519 this.get('/LeftPanel.model').load( data);
521 console.log(value.value);
522 // _g.button.set_label(''+value.get_string());
524 var pm =this.get('/RightPalete.model');
525 pm.load( this.get('/RightPalete').provider.gatherList(
526 this.get('/LeftTree.model').listAllTypes()));
531 //Seed.print( value.get_string());
538 xtype: Gtk.TreeStore,
542 XObject.prototype.init.call(this);
543 this.el.set_column_types ( 3, [
544 GObject.TYPE_STRING, // title
545 GObject.TYPE_STRING, // tip
546 GObject.TYPE_STRING // source..
550 changed : function(n, refresh) {
551 print("MODEL CHANGED CALLED" + this.activePath);
552 if (this.activePath) {
553 var iter = new Gtk.TreeIter();
554 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
555 this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
556 this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
558 this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
560 //this.currentTree = this.toJS(false, true)[0];
561 this.file.items = this.toJS(false, false);
562 print("AFTER CHANGED");
563 //console.dump(this.file.items);
565 this.currentTree = this.file.items[0];
566 //console.log(this.file.toSource());
569 print("REDNER BROWSER?!");
570 this.get('/LeftTree').renderView();
572 var pm = this.get('/RightPalete.model');
573 if (!this.get('/RightPalete').provider) {
579 pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
580 //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
584 loadFile : function(f) {
590 console.log('missing file');
594 // load the file if not loaded..
595 if (f.items === false) {
597 f.loadItems(function() {
603 if (f.items.length && typeof(f.items[0]) == 'string') {
605 this.get('/RightEditor').el.show();
606 this.get('/RightEditor.view').load( f.items[0]);
610 //console.dump(f.items);
612 this.get('/LeftTree.view').el.expand_all();
614 if (!f.items.length) {
617 this.get('/Window.leftvpaned').el.set_position(80);
619 this.get('/LeftTree.view').el.set_cursor(
620 new Gtk.TreePath.from_string('0'), null, false);
624 this.get('/Window.leftvpaned').el.set_position(200);
628 //print("hide right editior");
629 this.get('/RightEditor').el.hide();
630 //print("set current tree");
631 this.currentTree = this.toJS(false, false)[0];
632 //console.dump(this.currentTree);
633 this.currentTree = this.currentTree || { items: [] };
634 this.get('/LeftTree').renderView();
635 //console.dump(this.map);
636 //var RightPalete = imports.Builder.RightPalete.RightPalete;
637 var pm = this.get('/RightPalete.model');
640 this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
642 if (!this.get('/RightPalete').provider) {
643 print ("********* PALETE PROVIDER MISSING?!!");
645 this.get('/LeftTree').renderView();
647 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
651 this.get('/Window.view-notebook').el.set_current_page(
652 this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
655 findDropNode : function(treepath_str, targets) {
657 // this is used by the dragdrop code in the roo version AFAIR..
659 var path = treepath_str.replace(/^builder-/, '');
660 // treemap is depreciated... - should really check if model has any entries..
662 if (!this.el.iter_n_children(null)) {
664 return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];
666 print("FIND treepath: " + path);
667 //console.dump(this.treemap);
669 if (!treepath_str.match(/^builder-/)) {
670 return []; // nothing!
672 if (targets === true) {
675 return this.findDropNodeByPath(path,targets)
677 findDropNodeByPath : function(treepath_str, targets, pref) {
678 var path = treepath_str + ''; // dupe it..
679 pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
681 //console.dump(this.treemap);
682 while (path.length) {
683 print("LOOKING FOR PATH: " + path);
684 var node_data = this.singleNodeToJS(path);
685 if (node_data === false) {
686 print("node not found");
690 var xname = this.get('/LeftTree.model').file.guessName(node_data);
693 targets.forEach(function(tg) {
697 if ((tg == xname) ) {
700 if (tg.indexOf(xname +':') === 0) {
702 prop = tg.split(':').pop();
707 if (last) { // pref is after/before..
708 // then it's after last
710 return []; // do not allow..
712 return [ last, pref , prop];
715 return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
717 var par = path.split(':');
720 path = par.join(':');
726 dropNode : function(target_data, node) {
729 console.dump(target_data);
730 var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
732 print("add " + tp + "@" + target_data[1] );
735 if (tp && target_data[1] < 2) { // before or after..
736 var ar = target_data[0].split(':');
738 parent = new Gtk.TreePath.from_string( ar.join(':') );
741 var n_iter = new Gtk.TreeIter();
742 var iter_par = new Gtk.TreeIter();
743 var iter_after = after ? new Gtk.TreeIter() : false;
747 if (parent !== false) {
748 this.el.get_iter(iter_par, parent);
755 print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
756 this.el.get_iter(iter_after, after);
757 this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
758 n_iter, iter_par, iter_after);
761 this.el.append(n_iter, iter_par);
765 if (typeof(node) == 'string') {
766 var ar = node.split('.');
767 var xtype = ar.pop();
770 '|xns' : ar.join('.'),
773 if (target_data.length == 3 && target_data[2].length) {
774 node['*prop'] = target_data[2];
778 // work out what kind of packing to use..
779 if (typeof(node.pack) == 'undefined' && parent !== false) {
780 var pal = this.get('/LeftTree').getPaleteProvider();
782 var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
783 print ("PNAME : " + pname);
784 var cname = pal.guessName(node);
785 print ("CNAME : " + cname);
786 node.pack = pal.getDefaultPack(pname, cname);
797 // load children - if it has any..
800 this.load(xitems, n_iter);
802 if (tp && (xitems || after)) {
803 this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
805 // wee need to get the empty proptypes from somewhere..
807 //var olditer = this.activeIter;
808 this.activePath = this.el.get_path(n_iter).to_string();
810 // changed actually set's the node data..
811 this.changed(node, true);
815 this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
817 //Builder.MidPropTree._model.load(node);
818 //Builder.MidPropTree._win.hideWin();
819 //Builder.LeftPanel._model.load( node);
823 moveNode : function(target_data, action) {
824 //print("MOVE NODE");
825 // console.dump(target_data);
826 var old_iter = new Gtk.TreeIter();
827 var s = this.get('/LeftTree.view').selection;
828 s.get_selected(this.el, old_iter);
829 var node = this.nodeToJS(old_iter,false);
830 //console.dump(node);
833 // needs to drop first, otherwise the target_data
834 // treepath will be invalid.
836 this.dropNode(target_data, node);
837 if (action & Gdk.DragAction.MOVE) {
838 // print("REMOVING OLD NODE");
839 this.el.remove(old_iter);
843 this.activePath= false;
844 this.changed(false,true);
846 deleteSelected : function() {
847 this.get('/LeftTree.view').blockChanges = true;
848 var old_iter = new Gtk.TreeIter();
849 var s = this.get('/LeftTree.view').selection;
850 s.get_selected(this.el, old_iter);
851 var path = this.el.get_path(old_iter).to_string();
853 this.activePath= false;
856 this.activePath= false;
857 var iter = new Gtk.TreeIter();
858 this.el.get_iter_from_string(iter, path);
859 this.el.remove(iter);
861 // rebuild treemap. -- depreciated.!!
864 //this.toJS(null, true) // does not do anything?
865 this.activePath= false;
866 this.changed(false,true);
867 this.get('/LeftTree.view').blockChanges = false;
870 listAllTypes : function() {
871 var s = this.get('/LeftTree.view').selection;
872 print ("LIST ALL TYPES: " + s.count_selected_rows() );
874 if (s.count_selected_rows() > 0) {
875 var iter = new Gtk.TreeIter();
876 s.get_selected(this.el, iter);
878 // set some properties of the tree for use by the dropped element.
879 var value = new GObject.Value('');
880 this.el.get_value(iter, 2, value);
881 var data = JSON.parse(value.value);
884 var xname = this.get('/LeftTree.model').file.guessName(data);
885 console.log('selected:' + xname);
889 return []; // could not find it..
897 li.forEach(function(el) {
898 // this is specific to roo!!!?
900 var fullpath = _this.file.guessName(el);
901 if (fullpath.length && ret.indexOf(fullpath) < 0) {
906 if (el.items && el.items.length) {
915 addall([this.currentTree]);
917 // only if we have nothing, should we add '*top'
921 //console.log('all types in tree');
927 singleNodeToJS : function (treepath)
929 var iter = new Gtk.TreeIter();
930 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
934 var iv = this.getIterValue(iter, 2);
936 return JSON.parse(iv);
939 nodeToJS : function (iter, with_id)
941 var par = new Gtk.TreeIter();
942 var iv = this.getIterValue(iter, 2);
944 var k = JSON.parse(iv);
945 if (k.json && !this.el.iter_parent( par, iter )) {
950 var treepath_str = this.el.get_path(iter).to_string();
951 // not sure how we can handle mixed id stuff..
952 if (typeof(k.id) == 'undefined') {
953 k.id = 'builder-'+ treepath_str ;
957 this.treemap[ treepath_str ] = k;
958 k.xtreepath = treepath_str ;
961 if (this.el.iter_has_child(iter)) {
962 citer = new Gtk.TreeIter();
963 this.el.iter_children(citer, iter);
964 k.items = this.toJS(citer,with_id);
968 toJS : function(iter, with_id)
970 //Seed.print("WITHID: "+ with_id);
977 iter = new Gtk.TreeIter();
978 if (!this.el.get_iter_first(iter)) {
988 var k = this.nodeToJS(iter, with_id);
992 if (!this.el.iter_next(iter)) {
998 // convert the list into a json string..
1002 getIterValue : function (iter, col) {
1003 var gval = new GObject.Value('');
1004 this.el.get_value(iter, col ,gval);
1009 nodeTitle : function(c) {
1012 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
1013 if (sr) txt.push('<s>');
1014 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
1015 if (c.xtype) { txt.push(c.xtype); }
1016 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1017 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1018 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1021 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1022 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1023 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1024 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1025 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1026 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1027 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1028 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1029 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1031 // for flat classes...
1032 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1033 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1036 if (sr) txt.push('</s>');
1037 return (txt.length == 0 ? "Element" : txt.join(" "));
1039 nodeToJSON : function(c) {
1047 return JSON.stringify(o);
1049 load : function(tr,iter)
1051 var citer = new Gtk.TreeIter();
1052 //this.insert(citer,iter,0);
1053 for(var i =0 ; i < tr.length; i++) {
1055 this.el.insert(citer,iter,-1);
1057 this.el.append(citer);
1060 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1061 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1062 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1063 if (tr[i].items && tr[i].items.length) {
1064 this.load(tr[i].items, citer);
1070 xtype: Gtk.TreeViewColumn,
1071 pack : "append_column",
1073 XObject.prototype.init.call(this);
1074 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1078 xtype: Gtk.CellRendererText,
1088 id : "LeftTreeMenu",
1091 xtype: Gtk.MenuItem,
1093 label : "Delete Element",
1095 "activate":function (self) {
1097 this.get('/LeftTree.model').deleteSelected();
1108 id : "LeftProjectTree",
1109 showNoProjectSelected : function() {
1110 this.get('/StandardErrorDialog').show("Select a Project first.");
1112 getActiveProject : function() {
1113 return this.project;
1116 "leave_notify_event":function (self, event) {
1123 pack : "pack_start,false,false",
1126 xtype: Gtk.ComboBox,
1129 XObject.prototype.init.call(this);
1130 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1132 getValue : function() {
1133 var ix = this.el.get_active();
1137 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1140 setValue : function(fn)
1144 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1145 data.forEach(function(n, ix) {
1153 "changed":function (self) {
1154 var fn = this.getValue();
1155 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1156 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1161 xtype: Gtk.CellRendererText,
1162 pack : "pack_start,true",
1166 xtype: Gtk.ListStore,
1169 XObject.prototype.init.call(this);
1170 this.el.set_column_types ( 2, [
1171 GObject.TYPE_STRING, // real key
1172 GObject.TYPE_STRING // real type
1178 loadData : function(data) {
1179 var ov = this.get('/LeftProjectTree.combo').getValue();
1181 var iter = new Gtk.TreeIter();
1183 data.forEach(function(p) {
1188 el.set_value(iter, 0, p.fn);
1189 el.set_value(iter, 1, p.name);
1193 this.get('/LeftProjectTree.combo').setValue(ov);
1202 xtype: Gtk.ScrolledWindow,
1204 shadow_type : Gtk.ShadowType.IN,
1206 XObject.prototype.init.call(this);
1207 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1211 xtype: Gtk.TreeView,
1212 headers_visible : false,
1213 enable_tree_lines : true,
1216 XObject.prototype.init.call(this);
1217 var description = new Pango.FontDescription.c_new();
1218 description.set_size(8000);
1219 this.el.modify_font(description);
1221 this.selection = this.el.get_selection();
1222 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1226 "cursor_changed":function (self) {
1227 var iter = new Gtk.TreeIter();
1229 if (this.selection.count_selected_rows() < 1) {
1230 //XN.get('Builder.LeftTree.model').
1231 this.get('/LeftTree.model').load( false);
1235 var model = this.get('/LeftProjectTree.model');
1236 //console.log('changed');
1237 var s = this.selection;
1238 s.get_selected(model, iter);
1239 value = new GObject.Value('');
1240 model.el.get_value(iter, 2, value);
1242 console.log(value.value);// id..
1244 var file = this.get('/LeftProjectTree').project.getById(value.value);
1251 var nb = this.get('/LeftTopPanel.expander');
1252 nb.el.expanded = false;
1253 nb.listeners.activate.call(nb);
1254 //_expander.el.set_expanded(false);
1256 var ltm = this.get('/LeftTree.model');
1264 xtype: Gtk.TreeStore,
1268 XObject.prototype.init.call(this);
1269 this.el.set_column_types ( 3, [
1270 GObject.TYPE_STRING, // title
1271 GObject.TYPE_STRING, // tip
1272 GObject.TYPE_STRING // id..
1276 loadProject : function(pr) {
1281 this.get('/LeftProjectTree').project = pr;
1282 this.load(pr.toTree());
1283 this.get('/LeftProjectTree.view').el.expand_all();
1285 load : function(tr,iter) {
1287 console.log('Project tree load: ' + tr.length);
1288 var citer = new Gtk.TreeIter();
1289 //this.insert(citer,iter,0);
1292 tr.forEach(function (r) {
1294 _this.el.append(citer);
1296 _this.el.insert(citer,iter,-1);
1298 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1299 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1300 _this.el.set_value(citer, 2, '' + r.id ); //id
1301 if (r.cn && r.cn.length) {
1302 _this.load(r.cn, citer);
1307 getValue : function(iter, col) {
1308 var gval = new GObject.Value('');
1309 this.el.get_value(iter, col ,gval);
1310 return '' + gval.value;
1314 xtype: Gtk.TreeViewColumn,
1315 pack : "append_column",
1317 XObject.prototype.init.call(this);
1318 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1322 xtype: Gtk.CellRendererText,
1345 pack : "pack_start,false,true,0",
1352 "button_press_event":function (self, event) {
1353 this.get('/MidPropTree.model').showData('props');
1365 stock : Gtk.STOCK_ADD,
1366 icon_size : Gtk.IconSize.MENU
1381 "button_press_event":function (self, event) {
1382 this.get('/MidPropTree.model').showData('events');
1394 stock : Gtk.STOCK_ADD,
1395 icon_size : Gtk.IconSize.MENU
1410 "button_press_event":function (self, ev) {
1411 var p = this.get('/AddPropertyPopup');
1415 p.el.set_screen(Gdk.Screen.get_default());
1417 p.el.popup(null, null, null, null, 3, ev.button.time);
1429 stock : Gtk.STOCK_ADD,
1430 icon_size : Gtk.IconSize.MENU
1442 id : "AddPropertyPopup",
1445 xtype: Gtk.MenuItem,
1447 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1450 "activate":function (self) {
1452 this.get('/LeftPanel.model').add( {
1463 xtype: Gtk.MenuItem,
1465 tooltip_markup : "Add what type of packing is to be used",
1468 "activate":function (self) {
1470 this.get('/LeftPanel.model').add( {
1480 xtype: Gtk.MenuItem,
1482 tooltip_markup : "Override the init method",
1485 "activate":function (self) {
1487 this.get('/LeftPanel.model').add( {
1490 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1497 xtype: Gtk.SeparatorMenuItem,
1501 xtype: Gtk.MenuItem,
1503 tooltip_markup : "Add a user defined string property",
1506 "activate":function (self) {
1508 this.get('/LeftPanel.model').add( {
1518 xtype: Gtk.MenuItem,
1520 tooltip_markup : "Add a user defined number property",
1523 "activate":function (self) {
1525 this.get('/LeftPanel.model').add( {
1535 xtype: Gtk.MenuItem,
1537 tooltip_markup : "Add a user defined boolean property",
1540 "activate":function (self) {
1542 this.get('/LeftPanel.model').add( {
1552 xtype: Gtk.SeparatorMenuItem,
1556 xtype: Gtk.MenuItem,
1558 tooltip_markup : "Add a user function boolean property",
1561 "activate":function (self) {
1563 this.get('/LeftPanel.model').add( {
1566 val : "function() {\n \n}\n",
1579 xtype: Gtk.ScrolledWindow,
1582 shadow_type : Gtk.ShadowType.IN,
1585 XObject.prototype.init.call(this);
1586 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1590 xtype: Gtk.TreeView,
1593 headers_visible : false,
1594 enable_tree_lines : true,
1596 XObject.prototype.init.call(this);
1598 this.selection = this.el.get_selection();
1599 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1602 var description = new Pango.FontDescription.c_new();
1603 description.set_size(8000);
1604 this.el.modify_font(description);
1607 "button_press_event":function (self, ev) {
1611 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1612 return false; //not on a element.
1616 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1618 if (res.column.title != 'value') {
1619 return false; // ignore..
1621 if ( this.get('/LeftPanel').editing) {
1624 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1625 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1626 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1630 var provider = this.get('/LeftTree').getPaleteProvider();
1632 var opts = provider.findOptions(type);
1634 if (opts === false) {
1635 this.get('/LeftPanel').editableColumn.setOptions([]);
1636 renderer.has_entry = true;
1638 LeftPanel.editableColumn.setOptions(opts);
1639 renderer.has_entry = false;
1643 //Seed.print("click" + ev.type);
1644 //console.dump(res);
1650 if (res.column.title == 'value') {
1653 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1654 var p = this.get('/LeftPanelPopup');
1659 p.el.set_screen(Gdk.Screen.get_default());
1661 p.el.popup(null, null, null, null, 3, ev.button.time);
1662 //Seed.print("click:" + res.column.title);
1670 xtype: Gtk.TreeStore,
1674 XObject.prototype.init.call(this);
1675 this.el.set_column_types ( 5, [
1676 GObject.TYPE_STRING, // 0 real key
1677 GObject.TYPE_STRING, // 1 real value
1678 GObject.TYPE_STRING, // 2 visable key
1679 GObject.TYPE_STRING, // 3 visable value
1680 GObject.TYPE_STRING, // 4 need to store type of!!!
1684 toShort : function(str) {
1685 var a = typeof(str) == 'string' ? str.split("\n") : [];
1686 return a.length > 1 ? a[0] + '....' : '' + str;
1688 load : function(ar) {
1691 this.get('/RightEditor').el.hide();
1698 var provider = this.get('/LeftTree').getPaleteProvider();
1701 var iter = new Gtk.TreeIter();
1703 if (typeof(ar[i]) == 'object') {
1707 var type = provider.findType(ar, i, ar[i]);
1709 this.el.append(iter);
1710 var p = this.el.get_path(iter).to_string();
1712 this.el.set_value(iter, 0, i);
1713 this.el.set_value(iter, 1, '' + ar[i]);
1714 this.el.set_value(iter, 2, i);
1715 this.el.set_value(iter, 3, this.toShort(ar[i]));
1716 this.el.set_value(iter, 4, type);
1718 ar.listeners = ar.listeners || {};
1719 for (var i in ar.listeners ) {
1720 this.el.append(iter);
1721 var p = this.el.get_path(iter).to_string();
1724 this.el.set_value(iter, 0, '!'+ i );
1725 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1726 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1728 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1729 this.el.set_value(iter, 4, 'function');
1733 add : function(info) {
1734 // info includes key, val, skel, etype..
1736 type = info.type.toLowerCase();
1737 var data = this.toJS();
1739 if (info.etype == 'events') {
1740 data.listeners = data.listeners || { };
1741 if (typeof(data.listeners[info.key]) != 'undefined') {
1742 return; //already set!
1745 if (typeof(data[info.key]) != 'undefined') {
1750 if (typeof(info.val) == 'undefined') {
1753 if (info.type == 'boolean') {
1756 if (type == 'number') {
1764 if (info.etype == 'events') {
1766 data.listeners[info.key] = info.val;
1769 data[info.key] = info.val;
1773 var map = this.load(data);
1775 // flag it as changed to the interface..
1777 this.get('/LeftTree.model').changed(data, true);
1780 this.startEditing(map[k]);
1783 LeftPanel.get('view').el.row_activated(
1784 new Gtk.TreePath.from_string(map[k]),
1785 LeftPanel.editableColumn.el
1789 startEditing : function(path,col) {
1791 * start editing path (or selected if not set..)
1792 * @param {String|false} path (optional) treepath to edit - selected tree gets
1793 * edited by default.
1794 * @param {Number} 0 or 1 (optional)- column to edit.
1797 if (typeof(path) == 'string') {
1798 tp = new Gtk.TreePath.from_string(path);
1800 var iter = new Gtk.TreeIter();
1801 var s = this.get('/LeftPanel.view').selection;
1802 s.get_selected(this.el, iter);
1803 tp = this.el.get_path(iter);
1804 path = tp.to_string();
1808 // which colum is to be edited..
1810 if (typeof(col) == 'undefined') {
1811 var k = this.getValue(path, 0);
1812 colObj = (!k.length || k == '|') ?
1813 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1815 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1818 // make sure the pulldown is set correctly..
1819 // not really needed for second col...
1821 var provider = this.get('/LeftTree').getPaleteProvider();
1823 var type = this.get('/LeftPanel.model').getType(path);
1824 var opts = provider.findOptions(type);
1825 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1827 if (opts === false) {
1828 this.get('/LeftPanel').editableColumn.setOptions([]);
1829 renderer.has_entry = true; /// probably does not have any effect.
1831 this.get('/LeftPanel').editableColumn.setOptions(opts);
1832 renderer.has_entry = false;
1836 // iter now has row...
1837 GLib.timeout_add(0, 100, function() {
1839 colObj.items[0].el.editable = true; // esp. need for col 0..
1840 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1849 deleteSelected : function() {
1850 var data = this.toJS();
1851 var iter = new Gtk.TreeIter();
1852 var s = this.get('/LeftPanel.view').selection;
1853 s.get_selected(this.el, iter);
1856 var gval = new GObject.Value('');
1857 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1859 var val = gval.value;
1860 if (val[0] == '!') {
1862 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1865 delete data.listeners[ val.substring(1)];
1866 if (!XObject.keys(data.listeners).length) {
1867 delete data.listeners;
1871 if (typeof(data[val]) == 'undefined') {
1879 this.get('/LeftTree.model').changed(data, true);
1883 changed : function(str, doRefresh) {
1884 if (!this.activePath) {
1887 var iter = new Gtk.TreeIter();
1888 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1890 this.el.set_value(iter, 1, '' +str);
1891 this.el.set_value(iter, 3, '' + this.toShort(str));
1892 // update the tree...
1894 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
1897 var iter = new Gtk.TreeIter();
1898 this.get('/LeftPanel.model').el.get_iter_first(iter);
1903 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
1906 ar.listeners = ar.listeners || {};
1907 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
1910 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
1913 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
1919 //print(JSON.stringify(ar));
1923 getType : function(treepath) {
1924 return this.getValue(treepath, 4);
1926 getValue : function(treepath_str, col) {
1927 var iter = new Gtk.TreeIter();
1928 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
1930 var gval = new GObject.Value('');
1931 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
1932 var val = '' + gval.value;
1936 var type = this.getType(this.el.get_path(iter).to_string());
1937 //print("TYPE: " +type + " - val:" + val);
1938 switch(type.toLowerCase()) {
1942 return parseFloat(val); // Nan ?? invalid!!?
1944 return val == 'true' ? true : false;
1950 editSelected : function(e) {
1951 print("EDIT SELECTED?");
1952 var iter = new Gtk.TreeIter();
1953 var s = this.get('/LeftPanel.view').selection;
1954 s.get_selected(this.get('/LeftPanel.model').el, iter);
1955 var m = this.get('/LeftPanel.model')
1957 var gval = new GObject.Value('');
1958 this.el.get_value(iter, 0 ,gval);
1959 var val = '' + gval.value;
1961 gval = new GObject.Value('');
1962 this.el.get_value(iter, 1 ,gval);
1963 var rval = gval.value;
1964 var activePath = this.el.get_path(iter).to_string();
1965 this.activePath = activePath ;
1966 // was activeIter...
1969 var showEditor = false;
1971 if (val[0] == '!') {
1974 if (val[0] == '|') {
1975 if (rval.match(/function/g) || rval.match(/\n/g)) {
1982 this.activePath = false;
1983 GLib.timeout_add(0, 1, function() {
1984 // Gdk.threads_enter();
1985 _this.get('/RightEditor').el.show();
1986 _this.get('/RightEditor.view').load( rval );
1990 _this.activePath = activePath ;
1992 // Gdk.threads_leave();
1998 this.get('/RightEditor').el.hide();
2000 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2006 xtype: Gtk.TreeViewColumn,
2007 pack : "append_column",
2009 XObject.prototype.init.call(this);
2011 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2012 this.get('/LeftPanel').propertyColumn = this;
2017 xtype: Gtk.CellRendererText,
2018 pack : "pack_start",
2020 "editing_started":function (self, editable, path) {
2022 this.get('/LeftPanel.model').activePath = path;
2025 "edited":function (self, object, p0) {
2026 var model = this.get('/LeftPanel.model');
2027 var path = model.activePath;
2028 var iter = new Gtk.TreeIter();
2029 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2030 model.el.set_value(iter, 0, p0);
2031 model.el.set_value(iter, 2, p0);
2033 model.activePath = false;
2035 this.get('/LeftTree.model').changed(model.toJS(), true);
2036 this.el.editable = false;
2043 xtype: Gtk.TreeViewColumn,
2044 pack : "append_column",
2046 XObject.prototype.init.call(this);
2047 this.el.add_attribute(this.items[0].el , 'text', 3 );
2048 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2049 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2050 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2052 this.get('/LeftPanel').editableColumn= this;
2054 setOptions : function(ar) {
2055 var m = this.items[0].el.model;
2057 var iter = new Gtk.TreeIter();
2058 ar.forEach(function(i) {
2061 m.set_value(iter, 0, i);
2067 xtype: Gtk.CellRendererCombo,
2068 pack : "pack_start",
2073 XObject.prototype.init.call(this);
2074 this.el.model = new Gtk.ListStore();
2075 this.el.model.set_column_types ( 1, [
2076 GObject.TYPE_STRING // 0 real key
2080 "edited":function (self, object, p0) {
2081 this.get('/LeftPanel').editing = false;
2082 print("EDITED? p:" + p0 + " t:" + p0);
2083 this.get('/LeftPanel.model').changed(p0, true);
2084 this.get('/LeftPanel.model').activePath = false;
2086 "editing_started":function (self, editable, path) {
2087 this.get('/LeftPanel').editing = true;
2088 // console.log('editing started');
2089 // r.has_entry = false;
2090 this.get('/LeftPanel.model').editSelected(editable);
2101 id : "LeftPanelPopup",
2104 xtype: Gtk.MenuItem,
2108 "activate":function (self) {
2109 this.get('/LeftPanel.model').deleteSelected();
2114 xtype: Gtk.MenuItem,
2118 "activate":function (self) {
2119 this.get('/LeftPanel.model').startEditing(false, 0);
2132 xtype: Gtk.ScrolledWindow,
2133 pack : "pack_end,false,true,0",
2135 shadow_type : Gtk.ShadowType.IN,
2137 XObject.prototype.init.call(this);
2138 XObject.prototype.init.call(this);
2139 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2140 this.el.set_size_request ( 150, -1 );
2143 activeElement : false,
2144 hideWin : function() {
2151 if (this.get('/Window.left').el.position < 160) {
2154 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2161 xtype: Gtk.TreeView,
2162 enable_tree_lines : true,
2163 headers_visible : false,
2166 XObject.prototype.init.call(this);
2168 var description = new Pango.FontDescription.c_new();
2169 description.set_size(8000);
2170 this.el.modify_font(description);
2172 //this.selection = this.el.get_selection();
2173 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2182 "cursor_changed":function (self) {
2183 var iter = new Gtk.TreeIter();
2185 //console.log('changed');
2186 var m = this.get('model');
2187 if (!this.selection){
2188 this.selection = this.el.get_selection();
2191 var s = this.selection;
2192 if (!s.get_selected(m.el, iter)) {
2195 var tp = m.el.get_path(iter).to_string();
2200 var key = m.getValue(tp, 0);
2202 var type = m.getValue(tp, 1);
2203 var skel = m.getValue(tp, 3);
2204 var etype = m.getValue(tp, 5);
2207 this.get('/MidPropTree').hideWin();
2209 if (type == 'function') {
2211 if (etype != 'events') {
2215 this.get('/LeftPanel.model').add({
2224 if (type.indexOf('.') > -1 ||
2225 type == 'boolean') {
2229 this.get('/LeftPanel.model').add( {
2239 xtype: Gtk.ListStore,
2242 XObject.prototype.init.call(this);
2243 this.el.set_column_types ( 6, [
2244 GObject.TYPE_STRING, // real key
2245 GObject.TYPE_STRING, // real type
2246 GObject.TYPE_STRING, // docs ?
2247 GObject.TYPE_STRING, // visable desc
2248 GObject.TYPE_STRING, // function desc
2249 GObject.TYPE_STRING // element type (event|prop)
2253 getValue : function(treepath, col)
2255 var tp = new Gtk.TreePath.from_string (treepath);
2256 var iter = new Gtk.TreeIter();
2257 this.el.get_iter (iter, tp);
2258 var value = new GObject.Value('');
2259 this.el.get_value(iter, col, value);
2263 showData : function(type) {
2265 if (!this.get('/MidPropTree').activeElement || !type) {
2266 return; // no active element
2269 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2270 var palete = this.get('/LeftTree').getPaleteProvider();
2274 Seed.print('Showing right?');
2275 if (!this.get('/MidPropTree').shown) {
2277 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2278 this.get('/MidPropTree').el.show();
2279 this.get('/MidPropTree').shown = true;
2282 var elementList = palete.getPropertiesFor(fullpath, type);
2283 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2284 // console.dump(elementList);
2287 var iter = new Gtk.TreeIter();
2288 for(var i =0 ; i < elementList.length; i++) {
2289 var p=elementList[i];
2290 this.el.append(iter);
2291 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2292 //GObject.TYPE_STRING, // real key
2293 // GObject.TYPE_STRING, // real type
2294 // GObject.TYPE_STRING, // docs ?
2295 // GObject.TYPE_STRING // func def?
2298 this.el.set_value(iter, 0, p.name);
2299 this.el.set_value(iter, 1, p.type);
2300 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2301 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2302 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2303 this.el.set_value(iter, 5, type);
2311 xtype: Gtk.TreeViewColumn,
2313 this.el = new Gtk.TreeViewColumn();
2314 this.parent.el.append_column(this.el);
2316 XObject.prototype.init.call(this);
2317 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2322 xtype: Gtk.CellRendererText,
2323 pack : "pack_start,true"
2347 xtype: Gtk.Notebook,
2348 pack : "pack_start,true,true",
2349 id : "view-help-nb",
2351 XObject.prototype.init.call(this);
2352 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" }));
2353 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" }));
2357 xtype: Gtk.Notebook,
2359 id : "view-notebook",
2362 XObject.prototype.init.call(this);
2363 this.el.set_current_page(0);
2365 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2366 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2373 id : "RightBrowser",
2377 pack : "pack_start,false,true,0",
2381 pack : "pack_start,false,false,0",
2382 label : "Dump HTML to console",
2384 "activate":function (self) {
2385 this.get('/RightBrowser.view').el.execute_script(
2386 "console.log(document.body.innerHTML);");
2387 this.get('/RightBrowser.view').el.execute_script(
2388 "console.log(Builder.dump(Builder));");
2395 xtype: Gtk.ScrolledWindow,
2397 shadow_type : Gtk.ShadowType.IN,
2399 XObject.prototype.init.call(this);
2400 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2404 xtype: WebKit.WebView,
2408 XObject.prototype.init.call(this);
2409 // this may not work!?
2410 this.el.open('file:///' + __script_path__ + '/../builder.html');
2414 this.el, /* widget that will accept a drop */
2415 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2416 null, /* lists of target to support */
2417 0, /* size of list */
2418 Gdk.DragAction.COPY /* what to do with data after dropped */
2421 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2422 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2424 renderJS : function(data) {
2425 this.renderedData = data;
2426 var str = JSON.stringify(data) ;
2429 console.log('not loaded yet');
2431 Seed.print("RENDER:" + str);
2432 imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2433 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2436 "load_finished":function (self, object) {
2437 if (this.ready) { // dont do it twice!
2442 this.renderJS(this.get('/LeftTree.model').toJS()[0]);
2444 "script_alert":function (self, object, p0) {
2447 return true; // do not display anything...
2449 "console_message":function (self, object, p0, p1) {
2450 console.log(object);
2451 if (!object.match(/^\{/)) {
2452 return false; // do not handle!!! -> later maybe in console..
2454 console.log(object);
2455 var val = JSON.parse(object);
2457 if (typeof(val['hover-node']) != 'undefined') {
2458 this.activeNode = val['hover-node'];
2459 console.log('active node: ' + this.activeNode);
2464 if (typeof(val['id']) != 'undefined') {
2465 // this.activeNode = val['id'];
2466 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2470 this.get('/LeftTree.view').selectNode(tg[0]);
2474 if (ret && typeof(val['set']) != 'undefined') {
2475 this.get('/LeftPanel.model').add({
2479 //console.log('active node: ' + this.activeNode);
2482 //Seed.print('a:'+a);
2483 //Seed.print('b:'+b);
2484 //Seed.print('c:'+c);
2487 "drag_motion":function (w, ctx, x, y, time, ud) {
2488 // console.log('DRAG MOTION');
2490 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2491 this.targetData = [];
2492 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2494 // A) find out from drag all the places that node could be dropped.
2495 var src = Gtk.drag_get_source_widget(ctx);
2496 if (!src.dropList) {
2497 Gdk.drag_status(ctx, 0, time);
2500 // b) get what we are over.. (from activeNode)
2501 // tree is empty.. - list should be correct..
2502 if (!this.get('/LeftTree.model').currentTree) {
2503 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2507 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2509 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2512 Gdk.drag_status(ctx, 0,time);
2513 this.get('/LeftTree.view').highlight(false);
2517 // if we have a target..
2518 // -> highlight it! (in browser)
2519 // -> highlight it! (in tree)
2521 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2522 this.get('/LeftTree.view').highlight(tg);
2523 this.targetData = tg;
2524 // for tree we should handle this...
2527 "drag_drop":function (w, ctx, x, y,time, ud) {
2528 print("TARGET: drag-drop");
2529 var is_valid_drop_site = true;
2534 w, /* will receive 'drag-data-received' signal */
2535 ctx, /* represents the current state of the DnD */
2536 this.get('/Window').atoms["STRING"], /* the target type we want */
2537 time /* time stamp */
2541 /* No target offered by source => error */
2544 return is_valid_drop_site;
2546 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2548 print("Browser: drag-data-received");
2549 var delete_selection_data = false;
2550 vardnd_success = false;
2551 /* Deal with what we are given from source */
2552 if( sel_data && sel_data.length ) {
2554 if (ctx.action == Gdk.DragAction.ASK) {
2555 /* Ask the user to move or copy, then set the ctx action. */
2558 if (ctx.action == Gdk.DragAction.MOVE) {
2559 delete_selection_data = true;
2561 var source = Gtk.drag_get_source_widget(ctx);
2563 print("Browser: source.DRAGDATA? " + source.dragData);
2564 if (this.targetData) {
2565 print(this.targetData);
2566 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2575 if (dnd_success == false)
2577 Seed.print ("DnD data transfer failed!\n");
2580 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2592 id : "RightGtkView",
2593 renderJS : function(data, withDebug)
2598 this.withDebug = false;
2600 if (this.renderedEl) {
2601 this.get('view').el.remove(this.renderedEl);
2602 this.renderedEl.destroy();
2603 this.renderedEl = false;
2606 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2607 // in theory tree is actually window..
2609 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2614 this.get('view').el.set_size_request(
2615 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2618 this.renderedEl.set_size_request(
2619 tree.default_width || 600,
2620 tree.default_height || 400
2622 this.get('view').el.show_all();
2627 showInWindow : function() {
2628 print("GET PROEJCT");
2629 var pr = this.get('/LeftProjectTree').getActiveProject();
2631 console.log(pr.paths);
2634 var src= this.buildJS(
2635 this.get('/LeftTree.model').toJS()[0],
2640 //var x = new imports.sandbox.Context();
2644 Seed.check_syntax('var e = ' + src);
2647 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2648 this.get('/Terminal').feed(console._dump(e)+"\n");
2650 var lines = src.split("\n");
2651 var start = Math.max(0, e.line - 10);
2652 var end = Math.min(lines.length, e.line + 10);
2653 for (var i =start ; i < end; i++) {
2655 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2658 this.get('/Terminal').feed(lines[i] + "\n");
2665 this.get('/BottomPane').el.set_current_page(1);
2666 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2667 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2668 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2670 var _top = x.get_global_object()._top;
2672 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2674 if (_top.el.popup) {
2675 _top.el.popup(null, null, null, null, 3, null);
2679 viewAdd : function(item, par)
2681 // does something similar to xobject..
2682 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2684 if (item.pack===false || item.pack === 'false') { // no ;
2687 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2688 var ns = imports.gi[item['|xns']];
2689 var ctr = ns[item['xtype']];
2691 for(var k in item) {
2693 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2708 if (k[0] == '|' && typeof(kv) == 'string') {
2710 if (kv.match(new RegExp('function'))) {
2713 print("WASL " + k + '=' + kv);
2715 eval( 'kv = ' + kv);
2716 } catch(e) { continue; }
2719 print(k + '=' + kv);
2721 if (k[0] == '|') { // should be boolean or number..
2724 if (k == 'show_tabs') { // force tab showing for notebooks.
2732 var el = new ctr(ctr_args);
2735 //console.dump(item.pack);
2742 if (typeof(item.pack) == 'string') {
2744 item.pack.split(',').forEach(function(e, i) {
2746 if (e == 'false') { args.push( false); return; }
2747 if (e == 'true') { args.push( true); return; }
2748 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2751 //print(args.join(","));
2753 pack_m = args.shift();
2755 pack_m = item.pack.shift();
2760 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2762 name: "ArgumentError",
2763 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2764 "ADDING : " + item.id + " " + el
2773 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2774 //Seed.print('args: ' + args.length);
2776 par[pack_m].apply(par, args);
2780 item.items = item.items || [];
2781 item.items.forEach(function(ch) {
2782 _this.viewAdd(ch, el);
2787 // add the signal handlers.
2788 // is it a widget!?!!?
2794 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2795 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2796 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2797 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2798 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2808 widgetExposeEvent : function() {
2809 /// print("WIDGET EXPOSE"); // draw highlight??
2812 widgetDragMotionEvent : function() {
2813 print("WIDGET DRAGMOTION");
2816 widgetDragDropEvent : function() {
2817 print("WIDGET DRAGDROP");
2820 widgetPressEvent : function(w,e,u,d) {
2821 if (this.get('view').pressed) {
2824 this.get('view').pressed = true;
2825 print("WIDGET PRESS " + d.xtreepath );
2826 this.get('/LeftTree.view').selectNode( d.xtreepath );
2829 widgetReleaseEvent : function() {
2830 this.get('view').pressed = false;
2836 pack : "pack_start,false,true,0",
2840 pack : "pack_start,false,false,0",
2841 label : "Run The Application",
2843 "button_press_event":function (self, event) {
2844 // call render on left tree - with special option!?!
2848 print("GET PROEJCT");
2849 var pr = this.get('/LeftProjectTree').getActiveProject();
2852 for (var i in pr.paths) {
2856 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
2857 print ("RUN DIR:" + dir);
2859 this.get('/BottomPane').el.set_current_page(1);
2860 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
2861 , false,false,false);
2862 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
2863 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2873 xtype: Gtk.ScrolledWindow,
2876 shadow_type : Gtk.ShadowType.IN,
2878 XObject.prototype.init.call(this);
2879 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2883 xtype: Gtk.EventBox,
2884 pack : "add_with_viewport",
2886 XObject.prototype.init.call(this);
2887 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
2888 red: 0x9F00, green: 0xB800 , blue : 0xA800
2896 XObject.prototype.init.call(this);
2897 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
2898 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
2903 xtype: Gtk.EventBox,
2906 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
2907 XObject.prototype.init.call(this);
2911 this.el, /* widget that will accept a drop */
2912 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2913 null, /* lists of target to support */
2914 0, /* size of list */
2915 Gdk.DragAction.COPY /* what to do with data after dropped */
2918 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2919 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2922 getActiveNode : function(x,y)
2924 // workout what node is here..
2925 return '0'; // top..
2929 "drag_motion":function (self, ctx, x, y, time) {
2931 // A) find out from drag all the places that node could be dropped.
2932 var src = Gtk.drag_get_source_widget(ctx);
2933 if (!src.dropList) {
2934 Gdk.drag_status(ctx, 0, time);
2937 // b) get what we are over.. (from activeNode)
2938 // tree is empty.. - list should be correct..
2939 if (!this.get('/LeftTree.model').currentTree) {
2940 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2944 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2945 var activeNode = this.getActiveNode(x, y);
2948 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
2951 Gdk.drag_status(ctx, 0,time);
2952 this.get('/LeftTree.view').highlight(false);
2956 // if we have a target..
2957 // -> highlight it! (in browser)
2958 // -> highlight it! (in tree)
2960 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2961 this.get('/LeftTree.view').highlight(tg);
2962 this.targetData = tg;
2963 // for tree we should handle this...
2966 "drag_drop":function (self,ctx, x, y, time) {
2967 Seed.print("TARGET: drag-drop");
2968 var is_valid_drop_site = true;
2973 self, /* will receive 'drag-data-received' signal */
2974 ctx, /* represents the current state of the this.gDnD */
2975 this.get('/Window').atoms["STRING"], /* the target type we want */
2976 time /* time stamp */
2980 /* No target offered by source => error */
2983 return is_valid_drop_site;
2986 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2988 Seed.print("GtkView: drag-data-received");
2989 var delete_selection_data = false;
2990 var dnd_success = false;
2991 /* Deal with what we are given from source */
2992 if( sel_data && sel_data.length ) {
2994 if (ctx.action == Gdk.DragAction.ASK) {
2995 /* Ask the user to move or copy, then set the ctx action. */
2998 if (ctx.action == Gdk.DragAction.MOVE) {
2999 delete_selection_data = true;
3001 var source = Gtk.drag_get_source_widget(ctx);
3003 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3004 if (this.targetData) {
3005 Seed.print(this.targetData);
3006 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3015 if (dnd_success == false)
3017 Seed.print ("DnD data transfer failed!\n");
3020 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3023 "button_press_event":function (self, event) {
3024 this.pressed = false;
3040 xtype: Gtk.ScrolledWindow,
3045 xtype: WebKit.WebView,
3049 XObject.prototype.init.call(this);
3050 this.get('/Window.help-view').el.open(
3051 "http://devel.akbkhome.com/seed/");
3062 xtype: Gtk.Notebook,
3065 XObject.prototype.init.call(this);
3066 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3067 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3072 xtype: Gtk.ScrolledWindow,
3077 xtype: GtkSource.View,
3081 XObject.prototype.init.call(this);
3082 var description = Pango.Font.description_from_string("monospace")
3083 description.set_size(8000);
3084 this.el.modify_font(description);
3087 load : function(str) {
3089 // show the help page for the active node..
3090 this.get('/Window.view-help-nb').el.set_current_page(1);
3092 // get the active element being edited.
3093 var xtype = this.get('/LeftTree.model').file.guessName(
3094 this.get('/MidPropTree').activeElement);
3095 // now load the help info in the page..
3096 this.get('/Window.help-view').el.open(
3097 "http://devel.akbkhome.com/seed/" + xtype + ".html");
3100 this.get('/BottomPane').el.set_current_page(0);
3101 this.el.get_buffer().set_text(str, str.length);
3102 var lm = GtkSource.LanguageManager.get_default();
3104 this.el.get_buffer().set_language(lm.get_language('js'));
3105 var buf = this.el.get_buffer();
3106 var cursor = buf.get_mark("insert");
3107 var iter= new Gtk.TextIter;
3108 buf.get_iter_at_mark(iter, cursor);
3110 iter.set_line_offset(4);
3111 buf.move_mark(cursor, iter);
3114 cursor = buf.get_mark("selection_bound");
3115 iter= new Gtk.TextIter;
3116 buf.get_iter_at_mark(iter, cursor);
3118 iter.set_line_offset(4);
3119 buf.move_mark(cursor, iter);
3121 this.el.grab_focus();
3125 xtype: GtkSource.Buffer,
3126 pack : "set_buffer",
3128 "changed":function (self) {
3129 var s = new Gtk.TextIter();
3130 var e = new Gtk.TextIter();
3131 this.el.get_start_iter(s);
3132 this.el.get_end_iter(e);
3133 var str = this.el.get_text(s,e,true);
3135 Seed.check_syntax('var e = ' + str);
3137 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3138 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3140 print("SYNTAX ERROR IN EDITOR");
3145 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3146 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3149 this.get('/LeftPanel.model').changed( str , false);
3158 xtype: Gtk.ScrolledWindow,
3162 xtype: Vte.Terminal,
3165 feed : function(str) {
3166 this.el.feed(str,str.length);
3177 pack : "pack_start,false,false",
3181 this.get('buttonbar').el.show();
3182 this.get('viewbox').el.hide();
3183 print("TRIED TO HIDE");
3186 this.get('buttonbar').el.hide();
3187 this.get('viewbox').el.show();
3188 // this.get('model').expanded();
3200 pack : "pack_start,false,true",
3202 "clicked":function (self) {
3203 this.get('/RightPalete').show();
3210 stock : Gtk.STOCK_GOTO_FIRST,
3211 icon_size : Gtk.IconSize.MENU
3221 XObject.prototype.init.call(this);
3222 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3225 "enter_notify_event":function (self, event) {
3226 this.get('/RightPalete').show();
3240 pack : "pack_start,false,true",
3249 pack : "pack_start,false,true",
3251 "clicked":function (self) {
3252 this.get('/RightPalete').hide();
3259 stock : Gtk.STOCK_GOTO_LAST,
3260 icon_size : Gtk.IconSize.MENU
3267 xtype: Gtk.ScrolledWindow,
3270 XObject.prototype.init.call(this);
3271 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3272 this.el.set_size_request(-1,200);
3274 shadow_type : Gtk.ShadowType.IN,
3277 xtype: Gtk.TreeView,
3280 XObject.prototype.init.call(this);
3281 this.el.set_size_request(150,-1);
3282 // set_reorderable: [1]
3284 var description = new Pango.FontDescription.c_new();
3285 description.set_size(8000);
3286 this.el.modify_font(description);
3288 this.selection = this.el.get_selection();
3289 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3290 // this.selection.signal['changed'].connect(function() {
3291 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3293 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3295 Gtk.drag_source_set (
3296 this.el, /* widget will be drag-able */
3297 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3298 null, /* lists of target to support */
3299 0, /* size of list */
3300 Gdk.DragAction.COPY /* what to do with data after dropped */
3302 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3304 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3305 Gtk.drag_source_add_text_targets(this.el);
3307 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3308 targets = new Gtk.TargetList();
3309 targets.add( LeftTree.atoms["STRING"], 0, 0);
3310 targets.add_text_targets( 1 );
3311 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3313 //if you want to allow text to be output elsewhere..
3314 //Gtk.drag_source_add_text_targets(this.el);
3318 headers_visible : false,
3319 enable_tree_lines : true,
3321 "drag_begin":function (self, ctx) {
3322 // we could fill this in now...
3323 Seed.print('SOURCE: drag-begin');
3327 var iter = new Gtk.TreeIter();
3328 var s = this.selection;
3329 s.get_selected(this.get('/RightPalete.model').el, iter);
3330 var path = this.get('/RightPalete.model').el.get_path(iter);
3332 var pix = this.el.create_row_drag_icon ( path);
3335 Gtk.drag_set_icon_pixmap (ctx,
3342 var value = new GObject.Value('');
3343 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3344 if (!this.get('/RightPalete').provider) {
3347 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3348 this.el.dragData = value.value;
3355 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3356 //Seed.print('Palete: drag-data-get: ' + target_type);
3357 if (this.el.dragData && this.el.dragData.length ) {
3358 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3362 //this.el.dragData = "TEST from source widget";
3366 "drag_end":function (self, drag_context) {
3367 Seed.print('SOURCE: drag-end');
3368 this.el.dragData = false;
3369 this.el.dropList = false;
3370 this.get('/LeftTree.view').highlight(false);
3376 xtype: Gtk.ListStore,
3379 XObject.prototype.init.call(this);
3380 this.el.set_column_types ( 2, [
3381 GObject.TYPE_STRING, // title
3382 GObject.TYPE_STRING // tip
3387 load : function(tr,iter)
3392 //console.log('Project tree load: ' + tr.length);
3393 var citer = new Gtk.TreeIter();
3394 //this.insert(citer,iter,0);
3395 for(var i =0 ; i < tr.length; i++) {
3398 this.el.append(citer);
3400 this.el.insert(citer,iter,-1);
3405 this.el.set_value(citer, 0, '' + r ); // title
3407 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3408 //if (r.cn && r.cn.length) {
3409 // this.load(r.cn, citer);
3415 getValue : function (iter, col) {
3416 var gval = new GObject.Value('');
3417 this.el.get_value(iter, col ,gval);
3424 xtype: Gtk.TreeViewColumn,
3425 pack : "append_column",
3427 XObject.prototype.init.call(this);
3428 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3432 xtype: Gtk.CellRendererText,
3454 XObject.cache['/Window'] = Window;