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,
110 use_underline : true,
112 label : "D_elete Project",
114 "activate":function (self) {
116 var fn = this.get('/LeftProjectTree').get('combo').getValue();
118 this.get('/StandardErrorDialog').show("Select a project")
121 this.get('/DialogConfirm').show("Do you want to delete ????", function() {
129 xtype: Gtk.SeparatorMenuItem,
136 use_underline : true,
138 "activate":function (self) {
172 label : "Select Project",
174 pack : "pack_start,false,true",
176 XObject.prototype.init.call(this);
177 this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
180 "activate":function (self) {
181 var nb = this.get('/LeftTopPanel.notebook');
182 if (this.el.expanded) {
185 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
188 var model = this.get('/LeftProjectTree.combomodel');
189 // print ("loading Projects?")
190 //console.dump(pm.projects);
191 model.loadData(pm.projects);
194 nb.el.set_current_page(1);
195 //pm.on('changed', function() {
196 //console.log("CAUGHT project manager change");
197 // _combo.model.loadData(pm.projects);
201 nb.el.set_current_page(0);
203 "enter_notify_event":function (self, event) {
204 this.el.expanded = !this.el.expanded;
205 //if (this.el.expanded ) {
206 this.listeners.activate.call(this);
218 pack : "pack_start,true,true",
220 XObject.prototype.init.call(this);
221 this.el.set_current_page(0);
226 xtype: Gtk.ScrolledWindow,
228 shadow_type : Gtk.ShadowType.IN,
230 XObject.prototype.init.call(this);
231 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
234 getPaleteProvider : function() {
235 var model = this.get('model');
236 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
237 return pm.getPalete(model.file.getType());
239 renderView : function() {
240 var model = this.get('model');
241 print("RENDER VIEW?" + model.file.getType());
242 switch( model.file.getType()) {
244 this.get('/RightBrowser.view').renderJS(model.toJS(false,true)[0]);
246 this.get('/RightGtkView').renderJS(model.toJS(false,true)[0]);
254 headers_visible : false,
255 enable_tree_lines : true,
258 XObject.prototype.init.call(this);
259 var description = new Pango.FontDescription.c_new();
260 description.set_size(8000);
261 this.el.modify_font(description);
263 this.selection = this.el.get_selection();
264 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
266 this.selection.signal['changed'].connect(function() {
267 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
268 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
272 Gtk.drag_source_set (
273 this.el, /* widget will be drag-able */
274 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
275 null, /* lists of target to support */
276 0, /* size of list */
277 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
280 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
282 Gtk.drag_source_add_text_targets(this.el);
285 this.el, /* widget that will accept a drop */
286 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
287 null, /* lists of target to support */
288 0, /* size of list */
289 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
292 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
293 Gtk.drag_dest_add_text_targets(this.el);
295 highlight : function(treepath_ar) {
296 if (treepath_ar.length && treepath_ar[0].length ) {
297 this.el.set_drag_dest_row(
298 new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);
300 this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
304 selectNode : function(treepath_str) {
305 //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
306 var tp = new Gtk.TreePath.from_string(treepath_str);
307 this.el.set_cursor(tp, null, false);
308 this.el.scroll_to_cell(tp, null, false, 0,0);
311 "button_press_event":function (self, ev) {
312 console.log("button press?");
313 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
314 print("click" + ev.type);
320 this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
322 if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();
324 this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
325 this.get('/LeftTreeMenu').el.show_all();
326 this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
327 print("click:" + res.path.to_string());
330 "drag_begin":function (self, drag_context) {
331 print('SOURCE: drag-begin');
332 this.targetData = false;
333 // find what is selected in our tree...
334 var iter = new Gtk.TreeIter();
335 var s = this.selection;
336 s.get_selected(this.get('/LeftTree.model').el, iter);
338 // set some properties of the tree for use by the dropped element.
339 var value = new GObject.Value('');
340 this.get('/LeftTree.model').el.get_value(iter, 2, value);
341 var data = JSON.parse(value.value);
342 var xname = this.get('/LeftTree.model').file.guessName(data);
344 this.el.dragData = xname;
345 this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);
348 // make the drag icon a picture of the node that was selected
349 var path = this.get('/LeftTree.model').el.get_path(iter);
350 this.el.treepath = path.to_string();
352 var pix = this.el.create_row_drag_icon ( path);
354 Gtk.drag_set_icon_pixmap (ctx,
363 "drag_end":function (self, drag_context) {
364 Seed.print('LEFT-TREE: drag-end');
365 this.el.dragData = false;
366 this.el.dropList = false;
367 this.targetData = false;
368 this.get('/LeftTree.view').highlight(false);
371 "drag_motion":function (self, ctx, x, y, time) {
372 console.log("LEFT-TREE: drag-motion");
373 var src = Gtk.drag_get_source_widget(ctx);
375 // a drag from elsewhere...- prevent drop..
377 print("no drag data!");
378 Gdk.drag_status(ctx, 0, time);
379 this.targetData = false;
382 var action = Gdk.DragAction.COPY;
383 if (src == this.el) {
384 // unless we are copying!!! ctl button..
385 action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
389 if (!this.get('/LeftTree.model').el.iter_n_children(null)) {
390 // no children.. -- asume it's ok..
391 this.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];
392 Gdk.drag_status(ctx, action ,time);
396 print("GETTING POS");
397 var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);
398 print("ISOVER? " + isOver);
400 Gdk.drag_status(ctx, 0 ,time);
401 return false; // not over apoint!?!
403 // drag node is parent of child..
404 console.log("SRC TREEPATH: " + src.treepath);
405 console.log("TARGET TREEPATH: " + data.path.to_string());
407 // nned to check a few here..
408 //Gtk.TreeViewDropPosition.INTO_OR_AFTER
409 //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
410 //Gtk.TreeViewDropPosition.AFTER
411 //Gtk.TreeViewDropPosition.BEFORE
413 if (typeof(src.treepath) != 'undefined' &&
414 src.treepath == data.path.to_string().substring(0,src.treepath.length)) {
415 print("subpath drag");
416 Gdk.drag_status(ctx, 0 ,time);
421 //print("DUMPING DATA");
422 //console.dump(data);
425 print(data.path.to_string() +' => '+ data.pos);
426 var tg = this.get('/LeftTree.model').findDropNodeByPath(
427 data.path.to_string(), src.dropList, data.pos);
429 this.get('/LeftTree.view').highlight(tg);
431 print("Can not find drop node path");
432 this.targetData = false;
433 Gdk.drag_status(ctx, 0, time);
437 this.targetData = tg;
440 Gdk.drag_status(ctx, action ,time);
444 "drag_drop":function (w, ctx, x, y, time) {
445 Seed.print("TARGET: drag-drop");
449 w, /* will receive 'drag-data-received' signal */
450 ctx, /* represents the current state of the DnD */
451 this.get('/Window').atoms["STRING"], /* the target type we want */
452 time /* time stamp */
456 /* No target offered by source => error */
461 "drag_data_received":function (self, ctx, x, y, sel_data, info, time) {
462 print("Tree: drag-data-received");
464 var delete_selection_data = false;
465 var dnd_success = false;
466 /* Deal with what we are given from source */
467 if( sel_data && sel_data.length ) {
469 if (ctx.action == Gdk.DragAction.ASK) {
470 /* Ask the user to move or copy, then set the ctx action. */
473 if (ctx.action == Gdk.DragAction.MOVE) {
474 //delete_selection_data = true;
477 var source = Gtk.drag_get_source_widget(ctx);
479 if (this.targetData) {
480 if (source != this.el) {
481 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
483 // drag around.. - reorder..
484 this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);
488 //Seed.print(this.targetData);
494 // we can send stuff to souce here...
500 if (dnd_success == false)
502 Seed.print ("DnD data transfer failed!\n");
505 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
508 "cursor_changed":function (self) {
509 if (this.blockChanges) {
512 var iter = new Gtk.TreeIter();
514 if (this.selection.count_selected_rows() < 1) {
515 this.get('/LeftPanel.model').load( false);
516 this.get('/MidPropTree').activeElement = false;
517 this.get('/MidPropTree').hideWin();
519 var pm = this.get('/RightPalete.model');
520 if (!this.get('/LeftTree').getPaleteProvider()) {
521 // it may not be loaded yet..
524 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
525 this.get('/LeftTree.model').listAllTypes()));
530 //console.log('changed');
531 var s = this.selection;
532 s.get_selected(this.get('/LeftTree.model').el, iter);
536 value = new GObject.Value('');
537 this.get('/LeftTree.model').el.get_value(iter, 2, value);
538 this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
540 var data = JSON.parse(value.value);
541 this.get('/MidPropTree').activeElement = data;
542 this.get('/MidPropTree').hideWin();
543 this.get('/LeftPanel.model').load( data);
545 console.log(value.value);
546 // _g.button.set_label(''+value.get_string());
548 var pm =this.get('/RightPalete.model');
549 pm.load( this.get('/RightPalete').provider.gatherList(
550 this.get('/LeftTree.model').listAllTypes()));
555 //Seed.print( value.get_string());
562 xtype: Gtk.TreeStore,
566 XObject.prototype.init.call(this);
567 this.el.set_column_types ( 3, [
568 GObject.TYPE_STRING, // title
569 GObject.TYPE_STRING, // tip
570 GObject.TYPE_STRING // source..
574 changed : function(n, refresh) {
575 print("MODEL CHANGED CALLED" + this.activePath);
576 if (this.activePath) {
577 var iter = new Gtk.TreeIter();
578 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
579 this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
580 this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
582 this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
584 //this.currentTree = this.toJS(false, true)[0];
585 this.file.items = this.toJS(false, false);
586 print("AFTER CHANGED");
587 //console.dump(this.file.items);
589 this.currentTree = this.file.items[0];
590 //console.log(this.file.toSource());
593 print("REDNER BROWSER?!");
594 this.get('/LeftTree').renderView();
596 var pm = this.get('/RightPalete.model');
597 if (!this.get('/RightPalete').provider) {
603 pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
604 //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
608 loadFile : function(f) {
614 console.log('missing file');
618 // load the file if not loaded..
619 if (f.items === false) {
621 f.loadItems(function() {
627 if (f.items.length && typeof(f.items[0]) == 'string') {
629 this.get('/RightEditor').el.show();
630 this.get('/RightEditor.view').load( f.items[0]);
634 //console.dump(f.items);
636 this.get('/LeftTree.view').el.expand_all();
638 if (!f.items.length) {
641 this.get('/Window.leftvpaned').el.set_position(80);
643 this.get('/LeftTree.view').el.set_cursor(
644 new Gtk.TreePath.from_string('0'), null, false);
648 this.get('/Window.leftvpaned').el.set_position(200);
652 //print("hide right editior");
653 this.get('/RightEditor').el.hide();
654 //print("set current tree");
655 this.currentTree = this.toJS(false, false)[0];
656 //console.dump(this.currentTree);
657 this.currentTree = this.currentTree || { items: [] };
658 this.get('/LeftTree').renderView();
659 //console.dump(this.map);
660 //var RightPalete = imports.Builder.RightPalete.RightPalete;
661 var pm = this.get('/RightPalete.model');
664 this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
666 if (!this.get('/RightPalete').provider) {
667 print ("********* PALETE PROVIDER MISSING?!!");
669 this.get('/LeftTree').renderView();
671 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
675 this.get('/Window.view-notebook').el.set_current_page(
676 this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
679 findDropNode : function(treepath_str, targets) {
681 // this is used by the dragdrop code in the roo version AFAIR..
683 var path = treepath_str.replace(/^builder-/, '');
684 // treemap is depreciated... - should really check if model has any entries..
686 if (!this.el.iter_n_children(null)) {
688 return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];
690 print("FIND treepath: " + path);
691 //console.dump(this.treemap);
693 if (!treepath_str.match(/^builder-/)) {
694 return []; // nothing!
696 if (targets === true) {
699 return this.findDropNodeByPath(path,targets)
701 findDropNodeByPath : function(treepath_str, targets, pref) {
702 var path = treepath_str + ''; // dupe it..
703 pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
705 //console.dump(this.treemap);
706 while (path.length) {
707 print("LOOKING FOR PATH: " + path);
708 var node_data = this.singleNodeToJS(path);
709 if (node_data === false) {
710 print("node not found");
714 var xname = this.get('/LeftTree.model').file.guessName(node_data);
717 targets.forEach(function(tg) {
721 if ((tg == xname) ) {
724 if (tg.indexOf(xname +':') === 0) {
726 prop = tg.split(':').pop();
731 if (last) { // pref is after/before..
732 // then it's after last
734 return []; // do not allow..
736 return [ last, pref , prop];
739 return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
741 var par = path.split(':');
744 path = par.join(':');
750 dropNode : function(target_data, node) {
753 console.dump(target_data);
754 var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
756 print("add " + tp + "@" + target_data[1] );
759 if (tp && target_data[1] < 2) { // before or after..
760 var ar = target_data[0].split(':');
762 parent = new Gtk.TreePath.from_string( ar.join(':') );
765 var n_iter = new Gtk.TreeIter();
766 var iter_par = new Gtk.TreeIter();
767 var iter_after = after ? new Gtk.TreeIter() : false;
771 if (parent !== false) {
772 this.el.get_iter(iter_par, parent);
779 print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
780 this.el.get_iter(iter_after, after);
781 this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
782 n_iter, iter_par, iter_after);
785 this.el.append(n_iter, iter_par);
789 if (typeof(node) == 'string') {
790 var ar = node.split('.');
791 var xtype = ar.pop();
794 '|xns' : ar.join('.'),
797 if (target_data.length == 3 && target_data[2].length) {
798 node['*prop'] = target_data[2];
802 // work out what kind of packing to use..
803 if (typeof(node.pack) == 'undefined' && parent !== false) {
804 var pal = this.get('/LeftTree').getPaleteProvider();
806 var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
807 print ("PNAME : " + pname);
808 var cname = pal.guessName(node);
809 print ("CNAME : " + cname);
810 node.pack = pal.getDefaultPack(pname, cname);
821 // load children - if it has any..
824 this.load(xitems, n_iter);
826 if (tp && (xitems || after)) {
827 this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
829 // wee need to get the empty proptypes from somewhere..
831 //var olditer = this.activeIter;
832 this.activePath = this.el.get_path(n_iter).to_string();
834 // changed actually set's the node data..
835 this.changed(node, true);
839 this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
841 //Builder.MidPropTree._model.load(node);
842 //Builder.MidPropTree._win.hideWin();
843 //Builder.LeftPanel._model.load( node);
847 moveNode : function(target_data, action) {
848 //print("MOVE NODE");
849 // console.dump(target_data);
850 var old_iter = new Gtk.TreeIter();
851 var s = this.get('/LeftTree.view').selection;
852 s.get_selected(this.el, old_iter);
853 var node = this.nodeToJS(old_iter,false);
854 //console.dump(node);
857 // needs to drop first, otherwise the target_data
858 // treepath will be invalid.
860 this.dropNode(target_data, node);
861 if (action & Gdk.DragAction.MOVE) {
862 // print("REMOVING OLD NODE");
863 this.el.remove(old_iter);
867 this.activePath= false;
868 this.changed(false,true);
870 deleteSelected : function() {
871 this.get('/LeftTree.view').blockChanges = true;
872 var old_iter = new Gtk.TreeIter();
873 var s = this.get('/LeftTree.view').selection;
874 s.get_selected(this.el, old_iter);
875 var path = this.el.get_path(old_iter).to_string();
877 this.activePath= false;
880 this.activePath= false;
881 var iter = new Gtk.TreeIter();
882 this.el.get_iter_from_string(iter, path);
883 this.el.remove(iter);
885 // rebuild treemap. -- depreciated.!!
888 //this.toJS(null, true) // does not do anything?
889 this.activePath= false;
890 this.changed(false,true);
891 this.get('/LeftTree.view').blockChanges = false;
894 listAllTypes : function() {
895 var s = this.get('/LeftTree.view').selection;
896 print ("LIST ALL TYPES: " + s.count_selected_rows() );
898 if (s.count_selected_rows() > 0) {
899 var iter = new Gtk.TreeIter();
900 s.get_selected(this.el, iter);
902 // set some properties of the tree for use by the dropped element.
903 var value = new GObject.Value('');
904 this.el.get_value(iter, 2, value);
905 var data = JSON.parse(value.value);
908 var xname = this.get('/LeftTree.model').file.guessName(data);
909 console.log('selected:' + xname);
913 return []; // could not find it..
921 li.forEach(function(el) {
922 // this is specific to roo!!!?
924 var fullpath = _this.file.guessName(el);
925 if (fullpath.length && ret.indexOf(fullpath) < 0) {
930 if (el.items && el.items.length) {
939 addall([this.currentTree]);
941 // only if we have nothing, should we add '*top'
945 //console.log('all types in tree');
951 singleNodeToJS : function (treepath)
953 var iter = new Gtk.TreeIter();
954 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
958 var iv = this.getIterValue(iter, 2);
960 return JSON.parse(iv);
963 nodeToJS : function (iter, with_id)
965 var par = new Gtk.TreeIter();
966 var iv = this.getIterValue(iter, 2);
968 var k = JSON.parse(iv);
969 if (k.json && !this.el.iter_parent( par, iter )) {
974 var treepath_str = this.el.get_path(iter).to_string();
975 // not sure how we can handle mixed id stuff..
976 if (typeof(k.id) == 'undefined') {
977 k.id = 'builder-'+ treepath_str ;
981 this.treemap[ treepath_str ] = k;
982 k.xtreepath = treepath_str ;
985 if (this.el.iter_has_child(iter)) {
986 citer = new Gtk.TreeIter();
987 this.el.iter_children(citer, iter);
988 k.items = this.toJS(citer,with_id);
992 toJS : function(iter, with_id)
994 //Seed.print("WITHID: "+ with_id);
1001 iter = new Gtk.TreeIter();
1002 if (!this.el.get_iter_first(iter)) {
1012 var k = this.nodeToJS(iter, with_id);
1016 if (!this.el.iter_next(iter)) {
1022 // convert the list into a json string..
1026 getIterValue : function (iter, col) {
1027 var gval = new GObject.Value('');
1028 this.el.get_value(iter, col ,gval);
1033 nodeTitle : function(c) {
1036 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
1037 if (sr) txt.push('<s>');
1038 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
1039 if (c.xtype) { txt.push(c.xtype); }
1040 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1041 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1042 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1045 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1046 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1047 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1048 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1049 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1050 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1051 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1052 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1053 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1055 // for flat classes...
1056 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1057 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1060 if (sr) txt.push('</s>');
1061 return (txt.length == 0 ? "Element" : txt.join(" "));
1063 nodeToJSON : function(c) {
1071 return JSON.stringify(o);
1073 load : function(tr,iter)
1075 var citer = new Gtk.TreeIter();
1076 //this.insert(citer,iter,0);
1077 for(var i =0 ; i < tr.length; i++) {
1079 this.el.insert(citer,iter,-1);
1081 this.el.append(citer);
1084 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1085 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1086 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1087 if (tr[i].items && tr[i].items.length) {
1088 this.load(tr[i].items, citer);
1094 xtype: Gtk.TreeViewColumn,
1095 pack : "append_column",
1097 XObject.prototype.init.call(this);
1098 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1102 xtype: Gtk.CellRendererText,
1112 id : "LeftTreeMenu",
1115 xtype: Gtk.MenuItem,
1117 label : "Delete Element",
1119 "activate":function (self) {
1121 this.get('/LeftTree.model').deleteSelected();
1132 id : "LeftProjectTree",
1133 showNoProjectSelected : function() {
1134 this.get('/StandardErrorDialog').show("Select a Project first.");
1136 getActiveProject : function() {
1137 return this.project;
1140 "leave_notify_event":function (self, event) {
1147 pack : "pack_start,false,false",
1150 xtype: Gtk.ComboBox,
1153 XObject.prototype.init.call(this);
1154 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1156 getValue : function() {
1157 var ix = this.el.get_active();
1161 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1164 setValue : function(fn)
1168 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1169 data.forEach(function(n, ix) {
1177 "changed":function (self) {
1178 var fn = this.getValue();
1179 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1180 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1185 xtype: Gtk.CellRendererText,
1186 pack : "pack_start,true",
1190 xtype: Gtk.ListStore,
1193 XObject.prototype.init.call(this);
1194 this.el.set_column_types ( 2, [
1195 GObject.TYPE_STRING, // real key
1196 GObject.TYPE_STRING // real type
1202 loadData : function(data) {
1203 var ov = this.get('/LeftProjectTree.combo').getValue();
1205 var iter = new Gtk.TreeIter();
1207 data.forEach(function(p) {
1212 el.set_value(iter, 0, p.fn);
1213 el.set_value(iter, 1, p.name);
1217 this.get('/LeftProjectTree.combo').setValue(ov);
1226 xtype: Gtk.ScrolledWindow,
1228 shadow_type : Gtk.ShadowType.IN,
1230 XObject.prototype.init.call(this);
1231 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1235 xtype: Gtk.TreeView,
1236 headers_visible : false,
1237 enable_tree_lines : true,
1240 XObject.prototype.init.call(this);
1241 var description = new Pango.FontDescription.c_new();
1242 description.set_size(8000);
1243 this.el.modify_font(description);
1245 this.selection = this.el.get_selection();
1246 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1250 "cursor_changed":function (self) {
1251 var iter = new Gtk.TreeIter();
1253 if (this.selection.count_selected_rows() < 1) {
1254 //XN.get('Builder.LeftTree.model').
1255 this.get('/LeftTree.model').load( false);
1259 var model = this.get('/LeftProjectTree.model');
1260 //console.log('changed');
1261 var s = this.selection;
1262 s.get_selected(model, iter);
1263 value = new GObject.Value('');
1264 model.el.get_value(iter, 2, value);
1266 console.log(value.value);// id..
1268 var file = this.get('/LeftProjectTree').project.getById(value.value);
1275 var nb = this.get('/LeftTopPanel.expander');
1276 nb.el.expanded = false;
1277 nb.listeners.activate.call(nb);
1278 //_expander.el.set_expanded(false);
1280 var ltm = this.get('/LeftTree.model');
1288 xtype: Gtk.TreeStore,
1292 XObject.prototype.init.call(this);
1293 this.el.set_column_types ( 3, [
1294 GObject.TYPE_STRING, // title
1295 GObject.TYPE_STRING, // tip
1296 GObject.TYPE_STRING // id..
1300 loadProject : function(pr) {
1305 this.get('/LeftProjectTree').project = pr;
1306 this.load(pr.toTree());
1307 this.get('/LeftProjectTree.view').el.expand_all();
1309 load : function(tr,iter) {
1311 console.log('Project tree load: ' + tr.length);
1312 var citer = new Gtk.TreeIter();
1313 //this.insert(citer,iter,0);
1316 tr.forEach(function (r) {
1318 _this.el.append(citer);
1320 _this.el.insert(citer,iter,-1);
1322 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1323 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1324 _this.el.set_value(citer, 2, '' + r.id ); //id
1325 if (r.cn && r.cn.length) {
1326 _this.load(r.cn, citer);
1331 getValue : function(iter, col) {
1332 var gval = new GObject.Value('');
1333 this.el.get_value(iter, col ,gval);
1334 return '' + gval.value;
1338 xtype: Gtk.TreeViewColumn,
1339 pack : "append_column",
1341 XObject.prototype.init.call(this);
1342 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1346 xtype: Gtk.CellRendererText,
1369 pack : "pack_start,false,true,0",
1376 "button_press_event":function (self, event) {
1377 this.get('/MidPropTree.model').showData('props');
1389 stock : Gtk.STOCK_ADD,
1390 icon_size : Gtk.IconSize.MENU
1405 "button_press_event":function (self, event) {
1406 this.get('/MidPropTree.model').showData('events');
1418 stock : Gtk.STOCK_ADD,
1419 icon_size : Gtk.IconSize.MENU
1434 "button_press_event":function (self, ev) {
1435 var p = this.get('/AddPropertyPopup');
1439 p.el.set_screen(Gdk.Screen.get_default());
1441 p.el.popup(null, null, null, null, 3, ev.button.time);
1453 stock : Gtk.STOCK_ADD,
1454 icon_size : Gtk.IconSize.MENU
1466 id : "AddPropertyPopup",
1469 xtype: Gtk.MenuItem,
1471 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1474 "activate":function (self) {
1476 this.get('/LeftPanel.model').add( {
1487 xtype: Gtk.MenuItem,
1489 tooltip_markup : "Add what type of packing is to be used",
1492 "activate":function (self) {
1494 this.get('/LeftPanel.model').add( {
1504 xtype: Gtk.MenuItem,
1506 tooltip_markup : "Override the init method",
1509 "activate":function (self) {
1511 this.get('/LeftPanel.model').add( {
1514 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1521 xtype: Gtk.SeparatorMenuItem,
1525 xtype: Gtk.MenuItem,
1527 tooltip_markup : "Add a user defined string property",
1530 "activate":function (self) {
1532 this.get('/LeftPanel.model').add( {
1542 xtype: Gtk.MenuItem,
1544 tooltip_markup : "Add a user defined number property",
1547 "activate":function (self) {
1549 this.get('/LeftPanel.model').add( {
1559 xtype: Gtk.MenuItem,
1561 tooltip_markup : "Add a user defined boolean property",
1564 "activate":function (self) {
1566 this.get('/LeftPanel.model').add( {
1576 xtype: Gtk.SeparatorMenuItem,
1580 xtype: Gtk.MenuItem,
1582 tooltip_markup : "Add a user function boolean property",
1585 "activate":function (self) {
1587 this.get('/LeftPanel.model').add( {
1590 val : "function() {\n \n}\n",
1603 xtype: Gtk.ScrolledWindow,
1606 shadow_type : Gtk.ShadowType.IN,
1609 XObject.prototype.init.call(this);
1610 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1614 xtype: Gtk.TreeView,
1617 headers_visible : false,
1618 enable_tree_lines : true,
1620 XObject.prototype.init.call(this);
1622 this.selection = this.el.get_selection();
1623 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1626 var description = new Pango.FontDescription.c_new();
1627 description.set_size(8000);
1628 this.el.modify_font(description);
1631 "button_press_event":function (self, ev) {
1635 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1636 return false; //not on a element.
1640 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1642 if (res.column.title != 'value') {
1643 return false; // ignore..
1645 if ( this.get('/LeftPanel').editing) {
1648 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1649 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1650 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1654 var provider = this.get('/LeftTree').getPaleteProvider();
1656 var opts = provider.findOptions(type);
1658 if (opts === false) {
1659 this.get('/LeftPanel').editableColumn.setOptions([]);
1660 renderer.has_entry = true;
1662 LeftPanel.editableColumn.setOptions(opts);
1663 renderer.has_entry = false;
1667 //Seed.print("click" + ev.type);
1668 //console.dump(res);
1674 if (res.column.title == 'value') {
1677 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1678 var p = this.get('/LeftPanelPopup');
1683 p.el.set_screen(Gdk.Screen.get_default());
1685 p.el.popup(null, null, null, null, 3, ev.button.time);
1686 //Seed.print("click:" + res.column.title);
1694 xtype: Gtk.TreeStore,
1698 XObject.prototype.init.call(this);
1699 this.el.set_column_types ( 5, [
1700 GObject.TYPE_STRING, // 0 real key
1701 GObject.TYPE_STRING, // 1 real value
1702 GObject.TYPE_STRING, // 2 visable key
1703 GObject.TYPE_STRING, // 3 visable value
1704 GObject.TYPE_STRING, // 4 need to store type of!!!
1708 toShort : function(str) {
1709 var a = typeof(str) == 'string' ? str.split("\n") : [];
1710 return a.length > 1 ? a[0] + '....' : '' + str;
1712 load : function(ar) {
1715 this.get('/RightEditor').el.hide();
1722 var provider = this.get('/LeftTree').getPaleteProvider();
1725 var iter = new Gtk.TreeIter();
1727 if (typeof(ar[i]) == 'object') {
1731 var type = provider.findType(ar, i, ar[i]);
1733 this.el.append(iter);
1734 var p = this.el.get_path(iter).to_string();
1736 this.el.set_value(iter, 0, i);
1737 this.el.set_value(iter, 1, '' + ar[i]);
1738 this.el.set_value(iter, 2, i);
1739 this.el.set_value(iter, 3, this.toShort(ar[i]));
1740 this.el.set_value(iter, 4, type);
1742 ar.listeners = ar.listeners || {};
1743 for (var i in ar.listeners ) {
1744 this.el.append(iter);
1745 var p = this.el.get_path(iter).to_string();
1748 this.el.set_value(iter, 0, '!'+ i );
1749 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1750 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1752 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1753 this.el.set_value(iter, 4, 'function');
1757 add : function(info) {
1758 // info includes key, val, skel, etype..
1760 type = info.type.toLowerCase();
1761 var data = this.toJS();
1763 if (info.etype == 'events') {
1764 data.listeners = data.listeners || { };
1765 if (typeof(data.listeners[info.key]) != 'undefined') {
1766 return; //already set!
1769 if (typeof(data[info.key]) != 'undefined') {
1774 if (typeof(info.val) == 'undefined') {
1777 if (info.type == 'boolean') {
1780 if (type == 'number') {
1788 if (info.etype == 'events') {
1790 data.listeners[info.key] = info.val;
1793 data[info.key] = info.val;
1797 var map = this.load(data);
1799 // flag it as changed to the interface..
1801 this.get('/LeftTree.model').changed(data, true);
1804 this.startEditing(map[k]);
1807 LeftPanel.get('view').el.row_activated(
1808 new Gtk.TreePath.from_string(map[k]),
1809 LeftPanel.editableColumn.el
1813 startEditing : function(path,col) {
1815 * start editing path (or selected if not set..)
1816 * @param {String|false} path (optional) treepath to edit - selected tree gets
1817 * edited by default.
1818 * @param {Number} 0 or 1 (optional)- column to edit.
1821 if (typeof(path) == 'string') {
1822 tp = new Gtk.TreePath.from_string(path);
1824 var iter = new Gtk.TreeIter();
1825 var s = this.get('/LeftPanel.view').selection;
1826 s.get_selected(this.el, iter);
1827 tp = this.el.get_path(iter);
1828 path = tp.to_string();
1832 // which colum is to be edited..
1834 if (typeof(col) == 'undefined') {
1835 var k = this.getValue(path, 0);
1836 colObj = (!k.length || k == '|') ?
1837 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1839 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1842 // make sure the pulldown is set correctly..
1843 // not really needed for second col...
1845 var provider = this.get('/LeftTree').getPaleteProvider();
1847 var type = this.get('/LeftPanel.model').getType(path);
1848 var opts = provider.findOptions(type);
1849 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1851 if (opts === false) {
1852 this.get('/LeftPanel').editableColumn.setOptions([]);
1853 renderer.has_entry = true; /// probably does not have any effect.
1855 this.get('/LeftPanel').editableColumn.setOptions(opts);
1856 renderer.has_entry = false;
1860 // iter now has row...
1861 GLib.timeout_add(0, 100, function() {
1863 colObj.items[0].el.editable = true; // esp. need for col 0..
1864 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1873 deleteSelected : function() {
1874 var data = this.toJS();
1875 var iter = new Gtk.TreeIter();
1876 var s = this.get('/LeftPanel.view').selection;
1877 s.get_selected(this.el, iter);
1880 var gval = new GObject.Value('');
1881 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1883 var val = gval.value;
1884 if (val[0] == '!') {
1886 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1889 delete data.listeners[ val.substring(1)];
1890 if (!XObject.keys(data.listeners).length) {
1891 delete data.listeners;
1895 if (typeof(data[val]) == 'undefined') {
1903 this.get('/LeftTree.model').changed(data, true);
1907 changed : function(str, doRefresh) {
1908 if (!this.activePath) {
1911 var iter = new Gtk.TreeIter();
1912 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1914 this.el.set_value(iter, 1, '' +str);
1915 this.el.set_value(iter, 3, '' + this.toShort(str));
1916 // update the tree...
1918 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
1921 var iter = new Gtk.TreeIter();
1922 this.get('/LeftPanel.model').el.get_iter_first(iter);
1927 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
1930 ar.listeners = ar.listeners || {};
1931 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
1934 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
1937 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
1943 //print(JSON.stringify(ar));
1947 getType : function(treepath) {
1948 return this.getValue(treepath, 4);
1950 getValue : function(treepath_str, col) {
1951 var iter = new Gtk.TreeIter();
1952 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
1954 var gval = new GObject.Value('');
1955 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
1956 var val = '' + gval.value;
1960 var type = this.getType(this.el.get_path(iter).to_string());
1961 //print("TYPE: " +type + " - val:" + val);
1962 switch(type.toLowerCase()) {
1966 return parseFloat(val); // Nan ?? invalid!!?
1968 return val == 'true' ? true : false;
1974 editSelected : function(e) {
1975 print("EDIT SELECTED?");
1976 var iter = new Gtk.TreeIter();
1977 var s = this.get('/LeftPanel.view').selection;
1978 s.get_selected(this.get('/LeftPanel.model').el, iter);
1979 var m = this.get('/LeftPanel.model')
1981 var gval = new GObject.Value('');
1982 this.el.get_value(iter, 0 ,gval);
1983 var val = '' + gval.value;
1985 gval = new GObject.Value('');
1986 this.el.get_value(iter, 1 ,gval);
1987 var rval = gval.value;
1988 var activePath = this.el.get_path(iter).to_string();
1989 this.activePath = activePath ;
1990 // was activeIter...
1993 var showEditor = false;
1995 if (val[0] == '!') {
1998 if (val[0] == '|') {
1999 if (rval.match(/function/g) || rval.match(/\n/g)) {
2006 this.activePath = false;
2007 GLib.timeout_add(0, 1, function() {
2008 // Gdk.threads_enter();
2009 _this.get('/RightEditor').el.show();
2010 _this.get('/RightEditor.view').load( rval );
2014 _this.activePath = activePath ;
2016 // Gdk.threads_leave();
2022 this.get('/RightEditor').el.hide();
2024 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2030 xtype: Gtk.TreeViewColumn,
2031 pack : "append_column",
2033 XObject.prototype.init.call(this);
2035 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2036 this.get('/LeftPanel').propertyColumn = this;
2041 xtype: Gtk.CellRendererText,
2042 pack : "pack_start",
2044 "editing_started":function (self, editable, path) {
2046 this.get('/LeftPanel.model').activePath = path;
2049 "edited":function (self, object, p0) {
2050 var model = this.get('/LeftPanel.model');
2051 var path = model.activePath;
2052 var iter = new Gtk.TreeIter();
2053 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2054 model.el.set_value(iter, 0, p0);
2055 model.el.set_value(iter, 2, p0);
2057 model.activePath = false;
2059 this.get('/LeftTree.model').changed(model.toJS(), true);
2060 this.el.editable = false;
2067 xtype: Gtk.TreeViewColumn,
2068 pack : "append_column",
2070 XObject.prototype.init.call(this);
2071 this.el.add_attribute(this.items[0].el , 'text', 3 );
2072 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2073 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2074 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2076 this.get('/LeftPanel').editableColumn= this;
2078 setOptions : function(ar) {
2079 var m = this.items[0].el.model;
2081 var iter = new Gtk.TreeIter();
2082 ar.forEach(function(i) {
2085 m.set_value(iter, 0, i);
2091 xtype: Gtk.CellRendererCombo,
2092 pack : "pack_start",
2097 XObject.prototype.init.call(this);
2098 this.el.model = new Gtk.ListStore();
2099 this.el.model.set_column_types ( 1, [
2100 GObject.TYPE_STRING // 0 real key
2104 "edited":function (self, object, p0) {
2105 this.get('/LeftPanel').editing = false;
2106 print("EDITED? p:" + p0 + " t:" + p0);
2107 this.get('/LeftPanel.model').changed(p0, true);
2108 this.get('/LeftPanel.model').activePath = false;
2110 "editing_started":function (self, editable, path) {
2111 this.get('/LeftPanel').editing = true;
2112 // console.log('editing started');
2113 // r.has_entry = false;
2114 this.get('/LeftPanel.model').editSelected(editable);
2125 id : "LeftPanelPopup",
2128 xtype: Gtk.MenuItem,
2132 "activate":function (self) {
2133 this.get('/LeftPanel.model').deleteSelected();
2138 xtype: Gtk.MenuItem,
2142 "activate":function (self) {
2143 this.get('/LeftPanel.model').startEditing(false, 0);
2156 xtype: Gtk.ScrolledWindow,
2157 pack : "pack_end,false,true,0",
2159 shadow_type : Gtk.ShadowType.IN,
2161 XObject.prototype.init.call(this);
2162 XObject.prototype.init.call(this);
2163 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2164 this.el.set_size_request ( 150, -1 );
2167 activeElement : false,
2168 hideWin : function() {
2175 if (this.get('/Window.left').el.position < 160) {
2178 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2185 xtype: Gtk.TreeView,
2186 enable_tree_lines : true,
2187 headers_visible : false,
2190 XObject.prototype.init.call(this);
2192 var description = new Pango.FontDescription.c_new();
2193 description.set_size(8000);
2194 this.el.modify_font(description);
2196 //this.selection = this.el.get_selection();
2197 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2206 "cursor_changed":function (self) {
2207 var iter = new Gtk.TreeIter();
2209 //console.log('changed');
2210 var m = this.get('model');
2211 if (!this.selection){
2212 this.selection = this.el.get_selection();
2215 var s = this.selection;
2216 if (!s.get_selected(m.el, iter)) {
2219 var tp = m.el.get_path(iter).to_string();
2224 var key = m.getValue(tp, 0);
2226 var type = m.getValue(tp, 1);
2227 var skel = m.getValue(tp, 3);
2228 var etype = m.getValue(tp, 5);
2231 this.get('/MidPropTree').hideWin();
2233 if (type == 'function') {
2235 if (etype != 'events') {
2239 this.get('/LeftPanel.model').add({
2248 if (type.indexOf('.') > -1 ||
2249 type == 'boolean') {
2253 this.get('/LeftPanel.model').add( {
2263 xtype: Gtk.ListStore,
2266 XObject.prototype.init.call(this);
2267 this.el.set_column_types ( 6, [
2268 GObject.TYPE_STRING, // real key
2269 GObject.TYPE_STRING, // real type
2270 GObject.TYPE_STRING, // docs ?
2271 GObject.TYPE_STRING, // visable desc
2272 GObject.TYPE_STRING, // function desc
2273 GObject.TYPE_STRING // element type (event|prop)
2277 getValue : function(treepath, col)
2279 var tp = new Gtk.TreePath.from_string (treepath);
2280 var iter = new Gtk.TreeIter();
2281 this.el.get_iter (iter, tp);
2282 var value = new GObject.Value('');
2283 this.el.get_value(iter, col, value);
2287 showData : function(type) {
2289 if (!this.get('/MidPropTree').activeElement || !type) {
2290 return; // no active element
2293 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2294 var palete = this.get('/LeftTree').getPaleteProvider();
2298 Seed.print('Showing right?');
2299 if (!this.get('/MidPropTree').shown) {
2301 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2302 this.get('/MidPropTree').el.show();
2303 this.get('/MidPropTree').shown = true;
2306 var elementList = palete.getPropertiesFor(fullpath, type);
2307 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2308 // console.dump(elementList);
2311 var iter = new Gtk.TreeIter();
2312 for(var i =0 ; i < elementList.length; i++) {
2313 var p=elementList[i];
2314 this.el.append(iter);
2315 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2316 //GObject.TYPE_STRING, // real key
2317 // GObject.TYPE_STRING, // real type
2318 // GObject.TYPE_STRING, // docs ?
2319 // GObject.TYPE_STRING // func def?
2322 this.el.set_value(iter, 0, p.name);
2323 this.el.set_value(iter, 1, p.type);
2324 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2325 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2326 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2327 this.el.set_value(iter, 5, type);
2335 xtype: Gtk.TreeViewColumn,
2337 this.el = new Gtk.TreeViewColumn();
2338 this.parent.el.append_column(this.el);
2340 XObject.prototype.init.call(this);
2341 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2346 xtype: Gtk.CellRendererText,
2347 pack : "pack_start,true"
2371 xtype: Gtk.Notebook,
2372 pack : "pack_start,true,true",
2373 id : "view-help-nb",
2375 XObject.prototype.init.call(this);
2376 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" }));
2377 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" }));
2381 xtype: Gtk.Notebook,
2383 id : "view-notebook",
2386 XObject.prototype.init.call(this);
2387 this.el.set_current_page(0);
2389 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2390 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2397 id : "RightBrowser",
2401 pack : "pack_start,false,true,0",
2405 pack : "pack_start,false,false,0",
2406 label : "Dump HTML to console",
2408 "activate":function (self) {
2409 this.get('/RightBrowser.view').el.execute_script(
2410 "console.log(document.body.innerHTML);");
2411 this.get('/RightBrowser.view').el.execute_script(
2412 "console.log(Builder.dump(Builder));");
2419 xtype: Gtk.ScrolledWindow,
2421 shadow_type : Gtk.ShadowType.IN,
2423 XObject.prototype.init.call(this);
2424 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2428 xtype: WebKit.WebView,
2432 XObject.prototype.init.call(this);
2433 // this may not work!?
2434 this.el.open('file:///' + __script_path__ + '/../builder.html');
2438 this.el, /* widget that will accept a drop */
2439 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2440 null, /* lists of target to support */
2441 0, /* size of list */
2442 Gdk.DragAction.COPY /* what to do with data after dropped */
2445 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2446 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2448 renderJS : function(data) {
2449 this.renderedData = data;
2450 var str = JSON.stringify(data) ;
2453 console.log('not loaded yet');
2455 Seed.print("RENDER:" + str);
2456 imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2457 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2460 "load_finished":function (self, object) {
2461 if (this.ready) { // dont do it twice!
2466 this.renderJS(this.get('/LeftTree.model').toJS()[0]);
2468 "script_alert":function (self, object, p0) {
2471 return true; // do not display anything...
2473 "console_message":function (self, object, p0, p1) {
2474 console.log(object);
2475 if (!object.match(/^\{/)) {
2476 return false; // do not handle!!! -> later maybe in console..
2478 console.log(object);
2479 var val = JSON.parse(object);
2481 if (typeof(val['hover-node']) != 'undefined') {
2482 this.activeNode = val['hover-node'];
2483 console.log('active node: ' + this.activeNode);
2488 if (typeof(val['id']) != 'undefined') {
2489 // this.activeNode = val['id'];
2490 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2494 this.get('/LeftTree.view').selectNode(tg[0]);
2498 if (ret && typeof(val['set']) != 'undefined') {
2499 this.get('/LeftPanel.model').add({
2503 //console.log('active node: ' + this.activeNode);
2506 //Seed.print('a:'+a);
2507 //Seed.print('b:'+b);
2508 //Seed.print('c:'+c);
2511 "drag_motion":function (w, ctx, x, y, time, ud) {
2512 // console.log('DRAG MOTION');
2514 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2515 this.targetData = [];
2516 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2518 // A) find out from drag all the places that node could be dropped.
2519 var src = Gtk.drag_get_source_widget(ctx);
2520 if (!src.dropList) {
2521 Gdk.drag_status(ctx, 0, time);
2524 // b) get what we are over.. (from activeNode)
2525 // tree is empty.. - list should be correct..
2526 if (!this.get('/LeftTree.model').currentTree) {
2527 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2531 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2533 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2536 Gdk.drag_status(ctx, 0,time);
2537 this.get('/LeftTree.view').highlight(false);
2541 // if we have a target..
2542 // -> highlight it! (in browser)
2543 // -> highlight it! (in tree)
2545 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2546 this.get('/LeftTree.view').highlight(tg);
2547 this.targetData = tg;
2548 // for tree we should handle this...
2551 "drag_drop":function (w, ctx, x, y,time, ud) {
2552 print("TARGET: drag-drop");
2553 var is_valid_drop_site = true;
2558 w, /* will receive 'drag-data-received' signal */
2559 ctx, /* represents the current state of the DnD */
2560 this.get('/Window').atoms["STRING"], /* the target type we want */
2561 time /* time stamp */
2565 /* No target offered by source => error */
2568 return is_valid_drop_site;
2570 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2572 print("Browser: drag-data-received");
2573 var delete_selection_data = false;
2574 vardnd_success = false;
2575 /* Deal with what we are given from source */
2576 if( sel_data && sel_data.length ) {
2578 if (ctx.action == Gdk.DragAction.ASK) {
2579 /* Ask the user to move or copy, then set the ctx action. */
2582 if (ctx.action == Gdk.DragAction.MOVE) {
2583 delete_selection_data = true;
2585 var source = Gtk.drag_get_source_widget(ctx);
2587 print("Browser: source.DRAGDATA? " + source.dragData);
2588 if (this.targetData) {
2589 print(this.targetData);
2590 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2599 if (dnd_success == false)
2601 Seed.print ("DnD data transfer failed!\n");
2604 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2616 id : "RightGtkView",
2617 renderJS : function(data, withDebug)
2622 this.withDebug = false;
2624 if (this.renderedEl) {
2625 this.get('view').el.remove(this.renderedEl);
2626 this.renderedEl.destroy();
2627 this.renderedEl = false;
2630 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2631 // in theory tree is actually window..
2633 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2638 this.get('view').el.set_size_request(
2639 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2642 this.renderedEl.set_size_request(
2643 tree.default_width || 600,
2644 tree.default_height || 400
2646 this.get('view').el.show_all();
2651 showInWindow : function() {
2652 print("GET PROEJCT");
2653 var pr = this.get('/LeftProjectTree').getActiveProject();
2655 console.log(pr.paths);
2658 var src= this.buildJS(
2659 this.get('/LeftTree.model').toJS()[0],
2664 //var x = new imports.sandbox.Context();
2668 Seed.check_syntax('var e = ' + src);
2671 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2672 this.get('/Terminal').feed(console._dump(e)+"\n");
2674 var lines = src.split("\n");
2675 var start = Math.max(0, e.line - 10);
2676 var end = Math.min(lines.length, e.line + 10);
2677 for (var i =start ; i < end; i++) {
2679 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2682 this.get('/Terminal').feed(lines[i] + "\n");
2689 this.get('/BottomPane').el.set_current_page(1);
2690 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2691 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2692 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2694 var _top = x.get_global_object()._top;
2696 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2698 if (_top.el.popup) {
2699 _top.el.popup(null, null, null, null, 3, null);
2703 viewAdd : function(item, par)
2705 // does something similar to xobject..
2706 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2708 if (item.pack===false || item.pack === 'false') { // no ;
2711 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2712 var ns = imports.gi[item['|xns']];
2713 var ctr = ns[item['xtype']];
2715 for(var k in item) {
2717 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2732 if (k[0] == '|' && typeof(kv) == 'string') {
2734 if (kv.match(new RegExp('function'))) {
2737 print("WASL " + k + '=' + kv);
2739 eval( 'kv = ' + kv);
2740 } catch(e) { continue; }
2743 print(k + '=' + kv);
2745 if (k[0] == '|') { // should be boolean or number..
2748 if (k == 'show_tabs') { // force tab showing for notebooks.
2756 var el = new ctr(ctr_args);
2759 //console.dump(item.pack);
2766 if (typeof(item.pack) == 'string') {
2768 item.pack.split(',').forEach(function(e, i) {
2770 if (e == 'false') { args.push( false); return; }
2771 if (e == 'true') { args.push( true); return; }
2772 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2775 //print(args.join(","));
2777 pack_m = args.shift();
2779 pack_m = item.pack.shift();
2784 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2786 name: "ArgumentError",
2787 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2788 "ADDING : " + item.id + " " + el
2797 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2798 //Seed.print('args: ' + args.length);
2800 par[pack_m].apply(par, args);
2804 item.items = item.items || [];
2805 item.items.forEach(function(ch) {
2806 _this.viewAdd(ch, el);
2811 // add the signal handlers.
2812 // is it a widget!?!!?
2818 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2819 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2820 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2821 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2822 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2832 widgetExposeEvent : function() {
2833 /// print("WIDGET EXPOSE"); // draw highlight??
2836 widgetDragMotionEvent : function() {
2837 print("WIDGET DRAGMOTION");
2840 widgetDragDropEvent : function() {
2841 print("WIDGET DRAGDROP");
2844 widgetPressEvent : function(w,e,u,d) {
2845 if (this.get('view').pressed) {
2848 this.get('view').pressed = true;
2849 print("WIDGET PRESS " + d.xtreepath );
2850 this.get('/LeftTree.view').selectNode( d.xtreepath );
2853 widgetReleaseEvent : function() {
2854 this.get('view').pressed = false;
2860 pack : "pack_start,false,true,0",
2864 pack : "pack_start,false,false,0",
2865 label : "Run The Application",
2867 "button_press_event":function (self, event) {
2868 // call render on left tree - with special option!?!
2872 print("GET PROEJCT");
2873 var pr = this.get('/LeftProjectTree').getActiveProject();
2876 for (var i in pr.paths) {
2880 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
2881 print ("RUN DIR:" + dir);
2883 this.get('/BottomPane').el.set_current_page(1);
2884 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
2885 , false,false,false);
2886 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
2887 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2897 xtype: Gtk.ScrolledWindow,
2900 shadow_type : Gtk.ShadowType.IN,
2902 XObject.prototype.init.call(this);
2903 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2907 xtype: Gtk.EventBox,
2908 pack : "add_with_viewport",
2910 XObject.prototype.init.call(this);
2911 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
2912 red: 0x9F00, green: 0xB800 , blue : 0xA800
2920 XObject.prototype.init.call(this);
2921 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
2922 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
2927 xtype: Gtk.EventBox,
2930 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
2931 XObject.prototype.init.call(this);
2935 this.el, /* widget that will accept a drop */
2936 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2937 null, /* lists of target to support */
2938 0, /* size of list */
2939 Gdk.DragAction.COPY /* what to do with data after dropped */
2942 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2943 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2946 getActiveNode : function(x,y)
2948 // workout what node is here..
2949 return '0'; // top..
2953 "drag_motion":function (self, ctx, x, y, time) {
2955 // A) find out from drag all the places that node could be dropped.
2956 var src = Gtk.drag_get_source_widget(ctx);
2957 if (!src.dropList) {
2958 Gdk.drag_status(ctx, 0, time);
2961 // b) get what we are over.. (from activeNode)
2962 // tree is empty.. - list should be correct..
2963 if (!this.get('/LeftTree.model').currentTree) {
2964 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2968 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2969 var activeNode = this.getActiveNode(x, y);
2972 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
2975 Gdk.drag_status(ctx, 0,time);
2976 this.get('/LeftTree.view').highlight(false);
2980 // if we have a target..
2981 // -> highlight it! (in browser)
2982 // -> highlight it! (in tree)
2984 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2985 this.get('/LeftTree.view').highlight(tg);
2986 this.targetData = tg;
2987 // for tree we should handle this...
2990 "drag_drop":function (self,ctx, x, y, time) {
2991 Seed.print("TARGET: drag-drop");
2992 var is_valid_drop_site = true;
2997 self, /* will receive 'drag-data-received' signal */
2998 ctx, /* represents the current state of the this.gDnD */
2999 this.get('/Window').atoms["STRING"], /* the target type we want */
3000 time /* time stamp */
3004 /* No target offered by source => error */
3007 return is_valid_drop_site;
3010 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3012 Seed.print("GtkView: drag-data-received");
3013 var delete_selection_data = false;
3014 var dnd_success = false;
3015 /* Deal with what we are given from source */
3016 if( sel_data && sel_data.length ) {
3018 if (ctx.action == Gdk.DragAction.ASK) {
3019 /* Ask the user to move or copy, then set the ctx action. */
3022 if (ctx.action == Gdk.DragAction.MOVE) {
3023 delete_selection_data = true;
3025 var source = Gtk.drag_get_source_widget(ctx);
3027 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3028 if (this.targetData) {
3029 Seed.print(this.targetData);
3030 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3039 if (dnd_success == false)
3041 Seed.print ("DnD data transfer failed!\n");
3044 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3047 "button_press_event":function (self, event) {
3048 this.pressed = false;
3064 xtype: Gtk.ScrolledWindow,
3069 xtype: WebKit.WebView,
3073 XObject.prototype.init.call(this);
3074 this.get('/Window.help-view').el.open(
3075 "http://devel.akbkhome.com/seed/");
3086 xtype: Gtk.Notebook,
3089 XObject.prototype.init.call(this);
3090 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3091 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3096 xtype: Gtk.ScrolledWindow,
3101 xtype: GtkSource.View,
3105 XObject.prototype.init.call(this);
3106 var description = Pango.Font.description_from_string("monospace")
3107 description.set_size(8000);
3108 this.el.modify_font(description);
3111 load : function(str) {
3113 // show the help page for the active node..
3114 this.get('/Window.view-help-nb').el.set_current_page(1);
3116 // get the active element being edited.
3117 var xtype = this.get('/LeftTree.model').file.guessName(
3118 this.get('/MidPropTree').activeElement);
3119 // now load the help info in the page..
3120 this.get('/Window.help-view').el.open(
3121 "http://devel.akbkhome.com/seed/" + xtype + ".html");
3124 this.get('/BottomPane').el.set_current_page(0);
3125 this.el.get_buffer().set_text(str, str.length);
3126 var lm = GtkSource.LanguageManager.get_default();
3128 this.el.get_buffer().set_language(lm.get_language('js'));
3129 var buf = this.el.get_buffer();
3130 var cursor = buf.get_mark("insert");
3131 var iter= new Gtk.TextIter;
3132 buf.get_iter_at_mark(iter, cursor);
3134 iter.set_line_offset(4);
3135 buf.move_mark(cursor, iter);
3138 cursor = buf.get_mark("selection_bound");
3139 iter= new Gtk.TextIter;
3140 buf.get_iter_at_mark(iter, cursor);
3142 iter.set_line_offset(4);
3143 buf.move_mark(cursor, iter);
3145 this.el.grab_focus();
3149 xtype: GtkSource.Buffer,
3150 pack : "set_buffer",
3152 "changed":function (self) {
3153 var s = new Gtk.TextIter();
3154 var e = new Gtk.TextIter();
3155 this.el.get_start_iter(s);
3156 this.el.get_end_iter(e);
3157 var str = this.el.get_text(s,e,true);
3159 Seed.check_syntax('var e = ' + str);
3161 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3162 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3164 print("SYNTAX ERROR IN EDITOR");
3169 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3170 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3173 this.get('/LeftPanel.model').changed( str , false);
3182 xtype: Gtk.ScrolledWindow,
3186 xtype: Vte.Terminal,
3189 feed : function(str) {
3190 this.el.feed(str,str.length);
3201 pack : "pack_start,false,false",
3205 this.get('buttonbar').el.show();
3206 this.get('viewbox').el.hide();
3207 print("TRIED TO HIDE");
3210 this.get('buttonbar').el.hide();
3211 this.get('viewbox').el.show();
3212 // this.get('model').expanded();
3224 pack : "pack_start,false,true",
3226 "clicked":function (self) {
3227 this.get('/RightPalete').show();
3234 stock : Gtk.STOCK_GOTO_FIRST,
3235 icon_size : Gtk.IconSize.MENU
3245 XObject.prototype.init.call(this);
3246 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3249 "enter_notify_event":function (self, event) {
3250 this.get('/RightPalete').show();
3264 pack : "pack_start,false,true",
3273 pack : "pack_start,false,true",
3275 "clicked":function (self) {
3276 this.get('/RightPalete').hide();
3283 stock : Gtk.STOCK_GOTO_LAST,
3284 icon_size : Gtk.IconSize.MENU
3291 xtype: Gtk.ScrolledWindow,
3294 XObject.prototype.init.call(this);
3295 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3296 this.el.set_size_request(-1,200);
3298 shadow_type : Gtk.ShadowType.IN,
3301 xtype: Gtk.TreeView,
3304 XObject.prototype.init.call(this);
3305 this.el.set_size_request(150,-1);
3306 // set_reorderable: [1]
3308 var description = new Pango.FontDescription.c_new();
3309 description.set_size(8000);
3310 this.el.modify_font(description);
3312 this.selection = this.el.get_selection();
3313 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3314 // this.selection.signal['changed'].connect(function() {
3315 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3317 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3319 Gtk.drag_source_set (
3320 this.el, /* widget will be drag-able */
3321 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3322 null, /* lists of target to support */
3323 0, /* size of list */
3324 Gdk.DragAction.COPY /* what to do with data after dropped */
3326 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3328 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3329 Gtk.drag_source_add_text_targets(this.el);
3331 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3332 targets = new Gtk.TargetList();
3333 targets.add( LeftTree.atoms["STRING"], 0, 0);
3334 targets.add_text_targets( 1 );
3335 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3337 //if you want to allow text to be output elsewhere..
3338 //Gtk.drag_source_add_text_targets(this.el);
3342 headers_visible : false,
3343 enable_tree_lines : true,
3345 "drag_begin":function (self, ctx) {
3346 // we could fill this in now...
3347 Seed.print('SOURCE: drag-begin');
3351 var iter = new Gtk.TreeIter();
3352 var s = this.selection;
3353 s.get_selected(this.get('/RightPalete.model').el, iter);
3354 var path = this.get('/RightPalete.model').el.get_path(iter);
3356 var pix = this.el.create_row_drag_icon ( path);
3359 Gtk.drag_set_icon_pixmap (ctx,
3366 var value = new GObject.Value('');
3367 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3368 if (!this.get('/RightPalete').provider) {
3371 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3372 this.el.dragData = value.value;
3379 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3380 //Seed.print('Palete: drag-data-get: ' + target_type);
3381 if (this.el.dragData && this.el.dragData.length ) {
3382 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3386 //this.el.dragData = "TEST from source widget";
3390 "drag_end":function (self, drag_context) {
3391 Seed.print('SOURCE: drag-end');
3392 this.el.dragData = false;
3393 this.el.dropList = false;
3394 this.get('/LeftTree.view').highlight(false);
3400 xtype: Gtk.ListStore,
3403 XObject.prototype.init.call(this);
3404 this.el.set_column_types ( 2, [
3405 GObject.TYPE_STRING, // title
3406 GObject.TYPE_STRING // tip
3411 load : function(tr,iter)
3416 //console.log('Project tree load: ' + tr.length);
3417 var citer = new Gtk.TreeIter();
3418 //this.insert(citer,iter,0);
3419 for(var i =0 ; i < tr.length; i++) {
3422 this.el.append(citer);
3424 this.el.insert(citer,iter,-1);
3429 this.el.set_value(citer, 0, '' + r ); // title
3431 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3432 //if (r.cn && r.cn.length) {
3433 // this.load(r.cn, citer);
3439 getValue : function (iter, col) {
3440 var gval = new GObject.Value('');
3441 this.el.get_value(iter, col ,gval);
3448 xtype: Gtk.TreeViewColumn,
3449 pack : "append_column",
3451 XObject.prototype.init.call(this);
3452 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3456 xtype: Gtk.CellRendererText,
3478 XObject.cache['/Window'] = Window;