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 var pr = imports.Builder.Provider.ProjectManager.ProjectManager.getByFn(fn);
124 this.get('/DialogConfirm').show("Are you sure you want to delete project '" + pr.name + "'", function() {
132 xtype: Gtk.SeparatorMenuItem,
139 use_underline : true,
141 "activate":function (self) {
175 label : "Select Project",
177 pack : "pack_start,false,true",
179 XObject.prototype.init.call(this);
180 this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
183 "activate":function (self) {
184 var nb = this.get('/LeftTopPanel.notebook');
185 if (this.el.expanded) {
188 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
191 var model = this.get('/LeftProjectTree.combomodel');
192 // print ("loading Projects?")
193 //console.dump(pm.projects);
194 model.loadData(pm.projects);
197 nb.el.set_current_page(1);
198 //pm.on('changed', function() {
199 //console.log("CAUGHT project manager change");
200 // _combo.model.loadData(pm.projects);
204 nb.el.set_current_page(0);
206 "enter_notify_event":function (self, event) {
207 this.el.expanded = !this.el.expanded;
208 //if (this.el.expanded ) {
209 this.listeners.activate.call(this);
221 pack : "pack_start,true,true",
223 XObject.prototype.init.call(this);
224 this.el.set_current_page(0);
229 xtype: Gtk.ScrolledWindow,
231 shadow_type : Gtk.ShadowType.IN,
233 XObject.prototype.init.call(this);
234 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
237 getPaleteProvider : function() {
238 var model = this.get('model');
239 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
240 return pm.getPalete(model.file.getType());
242 renderView : function() {
243 var model = this.get('model');
244 print("RENDER VIEW?" + model.file.getType());
245 switch( model.file.getType()) {
247 this.get('/RightBrowser.view').renderJS(model.toJS(false,true)[0]);
249 this.get('/RightGtkView').renderJS(model.toJS(false,true)[0]);
257 headers_visible : false,
258 enable_tree_lines : true,
261 XObject.prototype.init.call(this);
262 var description = new Pango.FontDescription.c_new();
263 description.set_size(8000);
264 this.el.modify_font(description);
266 this.selection = this.el.get_selection();
267 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
269 this.selection.signal['changed'].connect(function() {
270 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
271 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
275 Gtk.drag_source_set (
276 this.el, /* widget will be drag-able */
277 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
278 null, /* lists of target to support */
279 0, /* size of list */
280 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
283 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
285 Gtk.drag_source_add_text_targets(this.el);
288 this.el, /* widget that will accept a drop */
289 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
290 null, /* lists of target to support */
291 0, /* size of list */
292 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
295 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
296 Gtk.drag_dest_add_text_targets(this.el);
298 highlight : function(treepath_ar) {
299 if (treepath_ar.length && treepath_ar[0].length ) {
300 this.el.set_drag_dest_row(
301 new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);
303 this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
307 selectNode : function(treepath_str) {
308 //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
309 var tp = new Gtk.TreePath.from_string(treepath_str);
310 this.el.set_cursor(tp, null, false);
311 this.el.scroll_to_cell(tp, null, false, 0,0);
314 "button_press_event":function (self, ev) {
315 console.log("button press?");
316 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
317 print("click" + ev.type);
323 this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
325 if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();
327 this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
328 this.get('/LeftTreeMenu').el.show_all();
329 this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
330 print("click:" + res.path.to_string());
333 "drag_begin":function (self, drag_context) {
334 print('SOURCE: drag-begin');
335 this.targetData = false;
336 // find what is selected in our tree...
337 var iter = new Gtk.TreeIter();
338 var s = this.selection;
339 s.get_selected(this.get('/LeftTree.model').el, iter);
341 // set some properties of the tree for use by the dropped element.
342 var value = new GObject.Value('');
343 this.get('/LeftTree.model').el.get_value(iter, 2, value);
344 var data = JSON.parse(value.value);
345 var xname = this.get('/LeftTree.model').file.guessName(data);
347 this.el.dragData = xname;
348 this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);
351 // make the drag icon a picture of the node that was selected
352 var path = this.get('/LeftTree.model').el.get_path(iter);
353 this.el.treepath = path.to_string();
355 var pix = this.el.create_row_drag_icon ( path);
357 Gtk.drag_set_icon_pixmap (ctx,
366 "drag_end":function (self, drag_context) {
367 Seed.print('LEFT-TREE: drag-end');
368 this.el.dragData = false;
369 this.el.dropList = false;
370 this.targetData = false;
371 this.get('/LeftTree.view').highlight(false);
374 "drag_motion":function (self, ctx, x, y, time) {
375 console.log("LEFT-TREE: drag-motion");
376 var src = Gtk.drag_get_source_widget(ctx);
378 // a drag from elsewhere...- prevent drop..
380 print("no drag data!");
381 Gdk.drag_status(ctx, 0, time);
382 this.targetData = false;
385 var action = Gdk.DragAction.COPY;
386 if (src == this.el) {
387 // unless we are copying!!! ctl button..
388 action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
392 if (!this.get('/LeftTree.model').el.iter_n_children(null)) {
393 // no children.. -- asume it's ok..
394 this.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];
395 Gdk.drag_status(ctx, action ,time);
399 print("GETTING POS");
400 var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);
401 print("ISOVER? " + isOver);
403 Gdk.drag_status(ctx, 0 ,time);
404 return false; // not over apoint!?!
406 // drag node is parent of child..
407 console.log("SRC TREEPATH: " + src.treepath);
408 console.log("TARGET TREEPATH: " + data.path.to_string());
410 // nned to check a few here..
411 //Gtk.TreeViewDropPosition.INTO_OR_AFTER
412 //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
413 //Gtk.TreeViewDropPosition.AFTER
414 //Gtk.TreeViewDropPosition.BEFORE
416 if (typeof(src.treepath) != 'undefined' &&
417 src.treepath == data.path.to_string().substring(0,src.treepath.length)) {
418 print("subpath drag");
419 Gdk.drag_status(ctx, 0 ,time);
424 //print("DUMPING DATA");
425 //console.dump(data);
428 print(data.path.to_string() +' => '+ data.pos);
429 var tg = this.get('/LeftTree.model').findDropNodeByPath(
430 data.path.to_string(), src.dropList, data.pos);
432 this.get('/LeftTree.view').highlight(tg);
434 print("Can not find drop node path");
435 this.targetData = false;
436 Gdk.drag_status(ctx, 0, time);
440 this.targetData = tg;
443 Gdk.drag_status(ctx, action ,time);
447 "drag_drop":function (w, ctx, x, y, time) {
448 Seed.print("TARGET: drag-drop");
452 w, /* will receive 'drag-data-received' signal */
453 ctx, /* represents the current state of the DnD */
454 this.get('/Window').atoms["STRING"], /* the target type we want */
455 time /* time stamp */
459 /* No target offered by source => error */
464 "drag_data_received":function (self, ctx, x, y, sel_data, info, time) {
465 print("Tree: drag-data-received");
467 var delete_selection_data = false;
468 var dnd_success = false;
469 /* Deal with what we are given from source */
470 if( sel_data && sel_data.length ) {
472 if (ctx.action == Gdk.DragAction.ASK) {
473 /* Ask the user to move or copy, then set the ctx action. */
476 if (ctx.action == Gdk.DragAction.MOVE) {
477 //delete_selection_data = true;
480 var source = Gtk.drag_get_source_widget(ctx);
482 if (this.targetData) {
483 if (source != this.el) {
484 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
486 // drag around.. - reorder..
487 this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);
491 //Seed.print(this.targetData);
497 // we can send stuff to souce here...
503 if (dnd_success == false)
505 Seed.print ("DnD data transfer failed!\n");
508 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
511 "cursor_changed":function (self) {
512 if (this.blockChanges) {
515 var iter = new Gtk.TreeIter();
517 if (this.selection.count_selected_rows() < 1) {
518 this.get('/LeftPanel.model').load( false);
519 this.get('/MidPropTree').activeElement = false;
520 this.get('/MidPropTree').hideWin();
522 var pm = this.get('/RightPalete.model');
523 if (!this.get('/LeftTree').getPaleteProvider()) {
524 // it may not be loaded yet..
527 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
528 this.get('/LeftTree.model').listAllTypes()));
533 //console.log('changed');
534 var s = this.selection;
535 s.get_selected(this.get('/LeftTree.model').el, iter);
539 value = new GObject.Value('');
540 this.get('/LeftTree.model').el.get_value(iter, 2, value);
541 this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
543 var data = JSON.parse(value.value);
544 this.get('/MidPropTree').activeElement = data;
545 this.get('/MidPropTree').hideWin();
546 this.get('/LeftPanel.model').load( data);
548 console.log(value.value);
549 // _g.button.set_label(''+value.get_string());
551 var pm =this.get('/RightPalete.model');
552 pm.load( this.get('/RightPalete').provider.gatherList(
553 this.get('/LeftTree.model').listAllTypes()));
558 //Seed.print( value.get_string());
565 xtype: Gtk.TreeStore,
569 XObject.prototype.init.call(this);
570 this.el.set_column_types ( 3, [
571 GObject.TYPE_STRING, // title
572 GObject.TYPE_STRING, // tip
573 GObject.TYPE_STRING // source..
577 changed : function(n, refresh) {
578 print("MODEL CHANGED CALLED" + this.activePath);
579 if (this.activePath) {
580 var iter = new Gtk.TreeIter();
581 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
582 this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
583 this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
585 this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
587 //this.currentTree = this.toJS(false, true)[0];
588 this.file.items = this.toJS(false, false);
589 print("AFTER CHANGED");
590 //console.dump(this.file.items);
592 this.currentTree = this.file.items[0];
593 //console.log(this.file.toSource());
596 print("REDNER BROWSER?!");
597 this.get('/LeftTree').renderView();
599 var pm = this.get('/RightPalete.model');
600 if (!this.get('/RightPalete').provider) {
606 pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
607 //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
611 loadFile : function(f) {
617 console.log('missing file');
621 // load the file if not loaded..
622 if (f.items === false) {
624 f.loadItems(function() {
630 if (f.items.length && typeof(f.items[0]) == 'string') {
632 this.get('/RightEditor').el.show();
633 this.get('/RightEditor.view').load( f.items[0]);
637 //console.dump(f.items);
639 this.get('/LeftTree.view').el.expand_all();
641 if (!f.items.length) {
644 this.get('/Window.leftvpaned').el.set_position(80);
646 this.get('/LeftTree.view').el.set_cursor(
647 new Gtk.TreePath.from_string('0'), null, false);
651 this.get('/Window.leftvpaned').el.set_position(200);
655 //print("hide right editior");
656 this.get('/RightEditor').el.hide();
657 //print("set current tree");
658 this.currentTree = this.toJS(false, false)[0];
659 //console.dump(this.currentTree);
660 this.currentTree = this.currentTree || { items: [] };
661 this.get('/LeftTree').renderView();
662 //console.dump(this.map);
663 //var RightPalete = imports.Builder.RightPalete.RightPalete;
664 var pm = this.get('/RightPalete.model');
667 this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
669 if (!this.get('/RightPalete').provider) {
670 print ("********* PALETE PROVIDER MISSING?!!");
672 this.get('/LeftTree').renderView();
674 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
678 this.get('/Window.view-notebook').el.set_current_page(
679 this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
682 findDropNode : function(treepath_str, targets) {
684 // this is used by the dragdrop code in the roo version AFAIR..
686 var path = treepath_str.replace(/^builder-/, '');
687 // treemap is depreciated... - should really check if model has any entries..
689 if (!this.el.iter_n_children(null)) {
691 return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];
693 print("FIND treepath: " + path);
694 //console.dump(this.treemap);
696 if (!treepath_str.match(/^builder-/)) {
697 return []; // nothing!
699 if (targets === true) {
702 return this.findDropNodeByPath(path,targets)
704 findDropNodeByPath : function(treepath_str, targets, pref) {
705 var path = treepath_str + ''; // dupe it..
706 pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
708 //console.dump(this.treemap);
709 while (path.length) {
710 print("LOOKING FOR PATH: " + path);
711 var node_data = this.singleNodeToJS(path);
712 if (node_data === false) {
713 print("node not found");
717 var xname = this.get('/LeftTree.model').file.guessName(node_data);
720 targets.forEach(function(tg) {
724 if ((tg == xname) ) {
727 if (tg.indexOf(xname +':') === 0) {
729 prop = tg.split(':').pop();
734 if (last) { // pref is after/before..
735 // then it's after last
737 return []; // do not allow..
739 return [ last, pref , prop];
742 return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
744 var par = path.split(':');
747 path = par.join(':');
753 dropNode : function(target_data, node) {
756 console.dump(target_data);
757 var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
759 print("add " + tp + "@" + target_data[1] );
762 if (tp && target_data[1] < 2) { // before or after..
763 var ar = target_data[0].split(':');
765 parent = new Gtk.TreePath.from_string( ar.join(':') );
768 var n_iter = new Gtk.TreeIter();
769 var iter_par = new Gtk.TreeIter();
770 var iter_after = after ? new Gtk.TreeIter() : false;
774 if (parent !== false) {
775 this.el.get_iter(iter_par, parent);
782 print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
783 this.el.get_iter(iter_after, after);
784 this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
785 n_iter, iter_par, iter_after);
788 this.el.append(n_iter, iter_par);
792 if (typeof(node) == 'string') {
793 var ar = node.split('.');
794 var xtype = ar.pop();
797 '|xns' : ar.join('.'),
800 if (target_data.length == 3 && target_data[2].length) {
801 node['*prop'] = target_data[2];
805 // work out what kind of packing to use..
806 if (typeof(node.pack) == 'undefined' && parent !== false) {
807 var pal = this.get('/LeftTree').getPaleteProvider();
809 var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
810 print ("PNAME : " + pname);
811 var cname = pal.guessName(node);
812 print ("CNAME : " + cname);
813 node.pack = pal.getDefaultPack(pname, cname);
824 // load children - if it has any..
827 this.load(xitems, n_iter);
829 if (tp && (xitems || after)) {
830 this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
832 // wee need to get the empty proptypes from somewhere..
834 //var olditer = this.activeIter;
835 this.activePath = this.el.get_path(n_iter).to_string();
837 // changed actually set's the node data..
838 this.changed(node, true);
842 this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
844 //Builder.MidPropTree._model.load(node);
845 //Builder.MidPropTree._win.hideWin();
846 //Builder.LeftPanel._model.load( node);
850 moveNode : function(target_data, action) {
851 //print("MOVE NODE");
852 // console.dump(target_data);
853 var old_iter = new Gtk.TreeIter();
854 var s = this.get('/LeftTree.view').selection;
855 s.get_selected(this.el, old_iter);
856 var node = this.nodeToJS(old_iter,false);
857 //console.dump(node);
860 // needs to drop first, otherwise the target_data
861 // treepath will be invalid.
863 this.dropNode(target_data, node);
864 if (action & Gdk.DragAction.MOVE) {
865 // print("REMOVING OLD NODE");
866 this.el.remove(old_iter);
870 this.activePath= false;
871 this.changed(false,true);
873 deleteSelected : function() {
874 this.get('/LeftTree.view').blockChanges = true;
875 var old_iter = new Gtk.TreeIter();
876 var s = this.get('/LeftTree.view').selection;
877 s.get_selected(this.el, old_iter);
878 var path = this.el.get_path(old_iter).to_string();
880 this.activePath= false;
883 this.activePath= false;
884 var iter = new Gtk.TreeIter();
885 this.el.get_iter_from_string(iter, path);
886 this.el.remove(iter);
888 // rebuild treemap. -- depreciated.!!
891 //this.toJS(null, true) // does not do anything?
892 this.activePath= false;
893 this.changed(false,true);
894 this.get('/LeftTree.view').blockChanges = false;
897 listAllTypes : function() {
898 var s = this.get('/LeftTree.view').selection;
899 print ("LIST ALL TYPES: " + s.count_selected_rows() );
901 if (s.count_selected_rows() > 0) {
902 var iter = new Gtk.TreeIter();
903 s.get_selected(this.el, iter);
905 // set some properties of the tree for use by the dropped element.
906 var value = new GObject.Value('');
907 this.el.get_value(iter, 2, value);
908 var data = JSON.parse(value.value);
911 var xname = this.get('/LeftTree.model').file.guessName(data);
912 console.log('selected:' + xname);
916 return []; // could not find it..
924 li.forEach(function(el) {
925 // this is specific to roo!!!?
927 var fullpath = _this.file.guessName(el);
928 if (fullpath.length && ret.indexOf(fullpath) < 0) {
933 if (el.items && el.items.length) {
942 addall([this.currentTree]);
944 // only if we have nothing, should we add '*top'
948 //console.log('all types in tree');
954 singleNodeToJS : function (treepath)
956 var iter = new Gtk.TreeIter();
957 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
961 var iv = this.getIterValue(iter, 2);
963 return JSON.parse(iv);
966 nodeToJS : function (iter, with_id)
968 var par = new Gtk.TreeIter();
969 var iv = this.getIterValue(iter, 2);
971 var k = JSON.parse(iv);
972 if (k.json && !this.el.iter_parent( par, iter )) {
977 var treepath_str = this.el.get_path(iter).to_string();
978 // not sure how we can handle mixed id stuff..
979 if (typeof(k.id) == 'undefined') {
980 k.id = 'builder-'+ treepath_str ;
984 this.treemap[ treepath_str ] = k;
985 k.xtreepath = treepath_str ;
988 if (this.el.iter_has_child(iter)) {
989 citer = new Gtk.TreeIter();
990 this.el.iter_children(citer, iter);
991 k.items = this.toJS(citer,with_id);
995 toJS : function(iter, with_id)
997 //Seed.print("WITHID: "+ with_id);
1004 iter = new Gtk.TreeIter();
1005 if (!this.el.get_iter_first(iter)) {
1015 var k = this.nodeToJS(iter, with_id);
1019 if (!this.el.iter_next(iter)) {
1025 // convert the list into a json string..
1029 getIterValue : function (iter, col) {
1030 var gval = new GObject.Value('');
1031 this.el.get_value(iter, col ,gval);
1036 nodeTitle : function(c) {
1039 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
1040 if (sr) txt.push('<s>');
1041 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
1042 if (c.xtype) { txt.push(c.xtype); }
1043 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1044 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1045 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1048 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1049 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1050 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1051 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1052 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1053 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1054 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1055 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1056 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1058 // for flat classes...
1059 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1060 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1063 if (sr) txt.push('</s>');
1064 return (txt.length == 0 ? "Element" : txt.join(" "));
1066 nodeToJSON : function(c) {
1074 return JSON.stringify(o);
1076 load : function(tr,iter)
1078 var citer = new Gtk.TreeIter();
1079 //this.insert(citer,iter,0);
1080 for(var i =0 ; i < tr.length; i++) {
1082 this.el.insert(citer,iter,-1);
1084 this.el.append(citer);
1087 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1088 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1089 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1090 if (tr[i].items && tr[i].items.length) {
1091 this.load(tr[i].items, citer);
1097 xtype: Gtk.TreeViewColumn,
1098 pack : "append_column",
1100 XObject.prototype.init.call(this);
1101 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1105 xtype: Gtk.CellRendererText,
1115 id : "LeftTreeMenu",
1118 xtype: Gtk.MenuItem,
1120 label : "Delete Element",
1122 "activate":function (self) {
1124 this.get('/LeftTree.model').deleteSelected();
1135 id : "LeftProjectTree",
1136 showNoProjectSelected : function() {
1137 this.get('/StandardErrorDialog').show("Select a Project first.");
1139 getActiveProject : function() {
1140 return this.project;
1143 "leave_notify_event":function (self, event) {
1150 pack : "pack_start,false,false",
1153 xtype: Gtk.ComboBox,
1156 XObject.prototype.init.call(this);
1157 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1159 getValue : function() {
1160 var ix = this.el.get_active();
1164 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1167 setValue : function(fn)
1171 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1172 data.forEach(function(n, ix) {
1180 "changed":function (self) {
1181 var fn = this.getValue();
1182 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1183 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1188 xtype: Gtk.CellRendererText,
1189 pack : "pack_start,true",
1193 xtype: Gtk.ListStore,
1196 XObject.prototype.init.call(this);
1197 this.el.set_column_types ( 2, [
1198 GObject.TYPE_STRING, // real key
1199 GObject.TYPE_STRING // real type
1205 loadData : function(data) {
1206 var ov = this.get('/LeftProjectTree.combo').getValue();
1208 var iter = new Gtk.TreeIter();
1210 data.forEach(function(p) {
1215 el.set_value(iter, 0, p.fn);
1216 el.set_value(iter, 1, p.name);
1220 this.get('/LeftProjectTree.combo').setValue(ov);
1229 xtype: Gtk.ScrolledWindow,
1231 shadow_type : Gtk.ShadowType.IN,
1233 XObject.prototype.init.call(this);
1234 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1238 xtype: Gtk.TreeView,
1239 headers_visible : false,
1240 enable_tree_lines : true,
1243 XObject.prototype.init.call(this);
1244 var description = new Pango.FontDescription.c_new();
1245 description.set_size(8000);
1246 this.el.modify_font(description);
1248 this.selection = this.el.get_selection();
1249 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1253 "cursor_changed":function (self) {
1254 var iter = new Gtk.TreeIter();
1256 if (this.selection.count_selected_rows() < 1) {
1257 //XN.get('Builder.LeftTree.model').
1258 this.get('/LeftTree.model').load( false);
1262 var model = this.get('/LeftProjectTree.model');
1263 //console.log('changed');
1264 var s = this.selection;
1265 s.get_selected(model, iter);
1266 value = new GObject.Value('');
1267 model.el.get_value(iter, 2, value);
1269 console.log(value.value);// id..
1271 var file = this.get('/LeftProjectTree').project.getById(value.value);
1278 var nb = this.get('/LeftTopPanel.expander');
1279 nb.el.expanded = false;
1280 nb.listeners.activate.call(nb);
1281 //_expander.el.set_expanded(false);
1283 var ltm = this.get('/LeftTree.model');
1291 xtype: Gtk.TreeStore,
1295 XObject.prototype.init.call(this);
1296 this.el.set_column_types ( 3, [
1297 GObject.TYPE_STRING, // title
1298 GObject.TYPE_STRING, // tip
1299 GObject.TYPE_STRING // id..
1303 loadProject : function(pr) {
1308 this.get('/LeftProjectTree').project = pr;
1309 this.load(pr.toTree());
1310 this.get('/LeftProjectTree.view').el.expand_all();
1312 load : function(tr,iter) {
1314 console.log('Project tree load: ' + tr.length);
1315 var citer = new Gtk.TreeIter();
1316 //this.insert(citer,iter,0);
1319 tr.forEach(function (r) {
1321 _this.el.append(citer);
1323 _this.el.insert(citer,iter,-1);
1325 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1326 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1327 _this.el.set_value(citer, 2, '' + r.id ); //id
1328 if (r.cn && r.cn.length) {
1329 _this.load(r.cn, citer);
1334 getValue : function(iter, col) {
1335 var gval = new GObject.Value('');
1336 this.el.get_value(iter, col ,gval);
1337 return '' + gval.value;
1341 xtype: Gtk.TreeViewColumn,
1342 pack : "append_column",
1344 XObject.prototype.init.call(this);
1345 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1349 xtype: Gtk.CellRendererText,
1372 pack : "pack_start,false,true,0",
1379 "button_press_event":function (self, event) {
1380 this.get('/MidPropTree.model').showData('props');
1392 stock : Gtk.STOCK_ADD,
1393 icon_size : Gtk.IconSize.MENU
1408 "button_press_event":function (self, event) {
1409 this.get('/MidPropTree.model').showData('events');
1421 stock : Gtk.STOCK_ADD,
1422 icon_size : Gtk.IconSize.MENU
1437 "button_press_event":function (self, ev) {
1438 var p = this.get('/AddPropertyPopup');
1442 p.el.set_screen(Gdk.Screen.get_default());
1444 p.el.popup(null, null, null, null, 3, ev.button.time);
1456 stock : Gtk.STOCK_ADD,
1457 icon_size : Gtk.IconSize.MENU
1469 id : "AddPropertyPopup",
1472 xtype: Gtk.MenuItem,
1474 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1477 "activate":function (self) {
1479 this.get('/LeftPanel.model').add( {
1490 xtype: Gtk.MenuItem,
1492 tooltip_markup : "Add what type of packing is to be used",
1495 "activate":function (self) {
1497 this.get('/LeftPanel.model').add( {
1507 xtype: Gtk.MenuItem,
1509 tooltip_markup : "Override the init method",
1512 "activate":function (self) {
1514 this.get('/LeftPanel.model').add( {
1517 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1524 xtype: Gtk.SeparatorMenuItem,
1528 xtype: Gtk.MenuItem,
1530 tooltip_markup : "Add a user defined string property",
1533 "activate":function (self) {
1535 this.get('/LeftPanel.model').add( {
1545 xtype: Gtk.MenuItem,
1547 tooltip_markup : "Add a user defined number property",
1550 "activate":function (self) {
1552 this.get('/LeftPanel.model').add( {
1562 xtype: Gtk.MenuItem,
1564 tooltip_markup : "Add a user defined boolean property",
1567 "activate":function (self) {
1569 this.get('/LeftPanel.model').add( {
1579 xtype: Gtk.SeparatorMenuItem,
1583 xtype: Gtk.MenuItem,
1585 tooltip_markup : "Add a user function boolean property",
1588 "activate":function (self) {
1590 this.get('/LeftPanel.model').add( {
1593 val : "function() {\n \n}\n",
1606 xtype: Gtk.ScrolledWindow,
1609 shadow_type : Gtk.ShadowType.IN,
1612 XObject.prototype.init.call(this);
1613 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1617 xtype: Gtk.TreeView,
1620 headers_visible : false,
1621 enable_tree_lines : true,
1623 XObject.prototype.init.call(this);
1625 this.selection = this.el.get_selection();
1626 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1629 var description = new Pango.FontDescription.c_new();
1630 description.set_size(8000);
1631 this.el.modify_font(description);
1634 "button_press_event":function (self, ev) {
1638 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1639 return false; //not on a element.
1643 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1645 if (res.column.title != 'value') {
1646 return false; // ignore..
1648 if ( this.get('/LeftPanel').editing) {
1651 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1652 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1653 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1657 var provider = this.get('/LeftTree').getPaleteProvider();
1659 var opts = provider.findOptions(type);
1661 if (opts === false) {
1662 this.get('/LeftPanel').editableColumn.setOptions([]);
1663 renderer.has_entry = true;
1665 LeftPanel.editableColumn.setOptions(opts);
1666 renderer.has_entry = false;
1670 //Seed.print("click" + ev.type);
1671 //console.dump(res);
1677 if (res.column.title == 'value') {
1680 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1681 var p = this.get('/LeftPanelPopup');
1686 p.el.set_screen(Gdk.Screen.get_default());
1688 p.el.popup(null, null, null, null, 3, ev.button.time);
1689 //Seed.print("click:" + res.column.title);
1697 xtype: Gtk.TreeStore,
1701 XObject.prototype.init.call(this);
1702 this.el.set_column_types ( 5, [
1703 GObject.TYPE_STRING, // 0 real key
1704 GObject.TYPE_STRING, // 1 real value
1705 GObject.TYPE_STRING, // 2 visable key
1706 GObject.TYPE_STRING, // 3 visable value
1707 GObject.TYPE_STRING, // 4 need to store type of!!!
1711 toShort : function(str) {
1712 var a = typeof(str) == 'string' ? str.split("\n") : [];
1713 return a.length > 1 ? a[0] + '....' : '' + str;
1715 load : function(ar) {
1718 this.get('/RightEditor').el.hide();
1725 var provider = this.get('/LeftTree').getPaleteProvider();
1728 var iter = new Gtk.TreeIter();
1730 if (typeof(ar[i]) == 'object') {
1734 var type = provider.findType(ar, i, ar[i]);
1736 this.el.append(iter);
1737 var p = this.el.get_path(iter).to_string();
1739 this.el.set_value(iter, 0, i);
1740 this.el.set_value(iter, 1, '' + ar[i]);
1741 this.el.set_value(iter, 2, i);
1742 this.el.set_value(iter, 3, this.toShort(ar[i]));
1743 this.el.set_value(iter, 4, type);
1745 ar.listeners = ar.listeners || {};
1746 for (var i in ar.listeners ) {
1747 this.el.append(iter);
1748 var p = this.el.get_path(iter).to_string();
1751 this.el.set_value(iter, 0, '!'+ i );
1752 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1753 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1755 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1756 this.el.set_value(iter, 4, 'function');
1760 add : function(info) {
1761 // info includes key, val, skel, etype..
1763 type = info.type.toLowerCase();
1764 var data = this.toJS();
1766 if (info.etype == 'events') {
1767 data.listeners = data.listeners || { };
1768 if (typeof(data.listeners[info.key]) != 'undefined') {
1769 return; //already set!
1772 if (typeof(data[info.key]) != 'undefined') {
1777 if (typeof(info.val) == 'undefined') {
1780 if (info.type == 'boolean') {
1783 if (type == 'number') {
1791 if (info.etype == 'events') {
1793 data.listeners[info.key] = info.val;
1796 data[info.key] = info.val;
1800 var map = this.load(data);
1802 // flag it as changed to the interface..
1804 this.get('/LeftTree.model').changed(data, true);
1807 this.startEditing(map[k]);
1810 LeftPanel.get('view').el.row_activated(
1811 new Gtk.TreePath.from_string(map[k]),
1812 LeftPanel.editableColumn.el
1816 startEditing : function(path,col) {
1818 * start editing path (or selected if not set..)
1819 * @param {String|false} path (optional) treepath to edit - selected tree gets
1820 * edited by default.
1821 * @param {Number} 0 or 1 (optional)- column to edit.
1824 if (typeof(path) == 'string') {
1825 tp = new Gtk.TreePath.from_string(path);
1827 var iter = new Gtk.TreeIter();
1828 var s = this.get('/LeftPanel.view').selection;
1829 s.get_selected(this.el, iter);
1830 tp = this.el.get_path(iter);
1831 path = tp.to_string();
1835 // which colum is to be edited..
1837 if (typeof(col) == 'undefined') {
1838 var k = this.getValue(path, 0);
1839 colObj = (!k.length || k == '|') ?
1840 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1842 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1845 // make sure the pulldown is set correctly..
1846 // not really needed for second col...
1848 var provider = this.get('/LeftTree').getPaleteProvider();
1850 var type = this.get('/LeftPanel.model').getType(path);
1851 var opts = provider.findOptions(type);
1852 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1854 if (opts === false) {
1855 this.get('/LeftPanel').editableColumn.setOptions([]);
1856 renderer.has_entry = true; /// probably does not have any effect.
1858 this.get('/LeftPanel').editableColumn.setOptions(opts);
1859 renderer.has_entry = false;
1863 // iter now has row...
1864 GLib.timeout_add(0, 100, function() {
1866 colObj.items[0].el.editable = true; // esp. need for col 0..
1867 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1876 deleteSelected : function() {
1877 var data = this.toJS();
1878 var iter = new Gtk.TreeIter();
1879 var s = this.get('/LeftPanel.view').selection;
1880 s.get_selected(this.el, iter);
1883 var gval = new GObject.Value('');
1884 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1886 var val = gval.value;
1887 if (val[0] == '!') {
1889 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1892 delete data.listeners[ val.substring(1)];
1893 if (!XObject.keys(data.listeners).length) {
1894 delete data.listeners;
1898 if (typeof(data[val]) == 'undefined') {
1906 this.get('/LeftTree.model').changed(data, true);
1910 changed : function(str, doRefresh) {
1911 if (!this.activePath) {
1914 var iter = new Gtk.TreeIter();
1915 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1917 this.el.set_value(iter, 1, '' +str);
1918 this.el.set_value(iter, 3, '' + this.toShort(str));
1919 // update the tree...
1921 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
1924 var iter = new Gtk.TreeIter();
1925 this.get('/LeftPanel.model').el.get_iter_first(iter);
1930 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
1933 ar.listeners = ar.listeners || {};
1934 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
1937 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
1940 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
1946 //print(JSON.stringify(ar));
1950 getType : function(treepath) {
1951 return this.getValue(treepath, 4);
1953 getValue : function(treepath_str, col) {
1954 var iter = new Gtk.TreeIter();
1955 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
1957 var gval = new GObject.Value('');
1958 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
1959 var val = '' + gval.value;
1963 var type = this.getType(this.el.get_path(iter).to_string());
1964 //print("TYPE: " +type + " - val:" + val);
1965 switch(type.toLowerCase()) {
1969 return parseFloat(val); // Nan ?? invalid!!?
1971 return val == 'true' ? true : false;
1977 editSelected : function(e) {
1978 print("EDIT SELECTED?");
1979 var iter = new Gtk.TreeIter();
1980 var s = this.get('/LeftPanel.view').selection;
1981 s.get_selected(this.get('/LeftPanel.model').el, iter);
1982 var m = this.get('/LeftPanel.model')
1984 var gval = new GObject.Value('');
1985 this.el.get_value(iter, 0 ,gval);
1986 var val = '' + gval.value;
1988 gval = new GObject.Value('');
1989 this.el.get_value(iter, 1 ,gval);
1990 var rval = gval.value;
1991 var activePath = this.el.get_path(iter).to_string();
1992 this.activePath = activePath ;
1993 // was activeIter...
1996 var showEditor = false;
1998 if (val[0] == '!') {
2001 if (val[0] == '|') {
2002 if (rval.match(/function/g) || rval.match(/\n/g)) {
2009 this.activePath = false;
2010 GLib.timeout_add(0, 1, function() {
2011 // Gdk.threads_enter();
2012 _this.get('/RightEditor').el.show();
2013 _this.get('/RightEditor.view').load( rval );
2017 _this.activePath = activePath ;
2019 // Gdk.threads_leave();
2025 this.get('/RightEditor').el.hide();
2027 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2033 xtype: Gtk.TreeViewColumn,
2034 pack : "append_column",
2036 XObject.prototype.init.call(this);
2038 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2039 this.get('/LeftPanel').propertyColumn = this;
2044 xtype: Gtk.CellRendererText,
2045 pack : "pack_start",
2047 "editing_started":function (self, editable, path) {
2049 this.get('/LeftPanel.model').activePath = path;
2052 "edited":function (self, object, p0) {
2053 var model = this.get('/LeftPanel.model');
2054 var path = model.activePath;
2055 var iter = new Gtk.TreeIter();
2056 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2057 model.el.set_value(iter, 0, p0);
2058 model.el.set_value(iter, 2, p0);
2060 model.activePath = false;
2062 this.get('/LeftTree.model').changed(model.toJS(), true);
2063 this.el.editable = false;
2070 xtype: Gtk.TreeViewColumn,
2071 pack : "append_column",
2073 XObject.prototype.init.call(this);
2074 this.el.add_attribute(this.items[0].el , 'text', 3 );
2075 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2076 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2077 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2079 this.get('/LeftPanel').editableColumn= this;
2081 setOptions : function(ar) {
2082 var m = this.items[0].el.model;
2084 var iter = new Gtk.TreeIter();
2085 ar.forEach(function(i) {
2088 m.set_value(iter, 0, i);
2094 xtype: Gtk.CellRendererCombo,
2095 pack : "pack_start",
2100 XObject.prototype.init.call(this);
2101 this.el.model = new Gtk.ListStore();
2102 this.el.model.set_column_types ( 1, [
2103 GObject.TYPE_STRING // 0 real key
2107 "edited":function (self, object, p0) {
2108 this.get('/LeftPanel').editing = false;
2109 print("EDITED? p:" + p0 + " t:" + p0);
2110 this.get('/LeftPanel.model').changed(p0, true);
2111 this.get('/LeftPanel.model').activePath = false;
2113 "editing_started":function (self, editable, path) {
2114 this.get('/LeftPanel').editing = true;
2115 // console.log('editing started');
2116 // r.has_entry = false;
2117 this.get('/LeftPanel.model').editSelected(editable);
2128 id : "LeftPanelPopup",
2131 xtype: Gtk.MenuItem,
2135 "activate":function (self) {
2136 this.get('/LeftPanel.model').deleteSelected();
2141 xtype: Gtk.MenuItem,
2145 "activate":function (self) {
2146 this.get('/LeftPanel.model').startEditing(false, 0);
2159 xtype: Gtk.ScrolledWindow,
2160 pack : "pack_end,false,true,0",
2162 shadow_type : Gtk.ShadowType.IN,
2164 XObject.prototype.init.call(this);
2165 XObject.prototype.init.call(this);
2166 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2167 this.el.set_size_request ( 150, -1 );
2170 activeElement : false,
2171 hideWin : function() {
2178 if (this.get('/Window.left').el.position < 160) {
2181 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2188 xtype: Gtk.TreeView,
2189 enable_tree_lines : true,
2190 headers_visible : false,
2193 XObject.prototype.init.call(this);
2195 var description = new Pango.FontDescription.c_new();
2196 description.set_size(8000);
2197 this.el.modify_font(description);
2199 //this.selection = this.el.get_selection();
2200 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2209 "cursor_changed":function (self) {
2210 var iter = new Gtk.TreeIter();
2212 //console.log('changed');
2213 var m = this.get('model');
2214 if (!this.selection){
2215 this.selection = this.el.get_selection();
2218 var s = this.selection;
2219 if (!s.get_selected(m.el, iter)) {
2222 var tp = m.el.get_path(iter).to_string();
2227 var key = m.getValue(tp, 0);
2229 var type = m.getValue(tp, 1);
2230 var skel = m.getValue(tp, 3);
2231 var etype = m.getValue(tp, 5);
2234 this.get('/MidPropTree').hideWin();
2236 if (type == 'function') {
2238 if (etype != 'events') {
2242 this.get('/LeftPanel.model').add({
2251 if (type.indexOf('.') > -1 ||
2252 type == 'boolean') {
2256 this.get('/LeftPanel.model').add( {
2266 xtype: Gtk.ListStore,
2269 XObject.prototype.init.call(this);
2270 this.el.set_column_types ( 6, [
2271 GObject.TYPE_STRING, // real key
2272 GObject.TYPE_STRING, // real type
2273 GObject.TYPE_STRING, // docs ?
2274 GObject.TYPE_STRING, // visable desc
2275 GObject.TYPE_STRING, // function desc
2276 GObject.TYPE_STRING // element type (event|prop)
2280 getValue : function(treepath, col)
2282 var tp = new Gtk.TreePath.from_string (treepath);
2283 var iter = new Gtk.TreeIter();
2284 this.el.get_iter (iter, tp);
2285 var value = new GObject.Value('');
2286 this.el.get_value(iter, col, value);
2290 showData : function(type) {
2292 if (!this.get('/MidPropTree').activeElement || !type) {
2293 return; // no active element
2296 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2297 var palete = this.get('/LeftTree').getPaleteProvider();
2301 Seed.print('Showing right?');
2302 if (!this.get('/MidPropTree').shown) {
2304 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2305 this.get('/MidPropTree').el.show();
2306 this.get('/MidPropTree').shown = true;
2309 var elementList = palete.getPropertiesFor(fullpath, type);
2310 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2311 // console.dump(elementList);
2314 var iter = new Gtk.TreeIter();
2315 for(var i =0 ; i < elementList.length; i++) {
2316 var p=elementList[i];
2317 this.el.append(iter);
2318 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2319 //GObject.TYPE_STRING, // real key
2320 // GObject.TYPE_STRING, // real type
2321 // GObject.TYPE_STRING, // docs ?
2322 // GObject.TYPE_STRING // func def?
2325 this.el.set_value(iter, 0, p.name);
2326 this.el.set_value(iter, 1, p.type);
2327 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2328 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2329 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2330 this.el.set_value(iter, 5, type);
2338 xtype: Gtk.TreeViewColumn,
2340 this.el = new Gtk.TreeViewColumn();
2341 this.parent.el.append_column(this.el);
2343 XObject.prototype.init.call(this);
2344 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2349 xtype: Gtk.CellRendererText,
2350 pack : "pack_start,true"
2374 xtype: Gtk.Notebook,
2375 pack : "pack_start,true,true",
2376 id : "view-help-nb",
2378 XObject.prototype.init.call(this);
2379 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" }));
2380 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" }));
2384 xtype: Gtk.Notebook,
2386 id : "view-notebook",
2389 XObject.prototype.init.call(this);
2390 this.el.set_current_page(0);
2392 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2393 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2400 id : "RightBrowser",
2404 pack : "pack_start,false,true,0",
2408 pack : "pack_start,false,false,0",
2409 label : "Dump HTML to console",
2411 "activate":function (self) {
2412 this.get('/RightBrowser.view').el.execute_script(
2413 "console.log(document.body.innerHTML);");
2414 this.get('/RightBrowser.view').el.execute_script(
2415 "console.log(Builder.dump(Builder));");
2422 xtype: Gtk.ScrolledWindow,
2424 shadow_type : Gtk.ShadowType.IN,
2426 XObject.prototype.init.call(this);
2427 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2431 xtype: WebKit.WebView,
2435 XObject.prototype.init.call(this);
2436 // this may not work!?
2437 this.el.open('file:///' + __script_path__ + '/../builder.html');
2441 this.el, /* widget that will accept a drop */
2442 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2443 null, /* lists of target to support */
2444 0, /* size of list */
2445 Gdk.DragAction.COPY /* what to do with data after dropped */
2448 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2449 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2451 renderJS : function(data) {
2452 this.renderedData = data;
2453 var str = JSON.stringify(data) ;
2456 console.log('not loaded yet');
2458 Seed.print("RENDER:" + str);
2459 imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2460 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2463 "load_finished":function (self, object) {
2464 if (this.ready) { // dont do it twice!
2469 this.renderJS(this.get('/LeftTree.model').toJS()[0]);
2471 "script_alert":function (self, object, p0) {
2474 return true; // do not display anything...
2476 "console_message":function (self, object, p0, p1) {
2477 console.log(object);
2478 if (!object.match(/^\{/)) {
2479 return false; // do not handle!!! -> later maybe in console..
2481 console.log(object);
2482 var val = JSON.parse(object);
2484 if (typeof(val['hover-node']) != 'undefined') {
2485 this.activeNode = val['hover-node'];
2486 console.log('active node: ' + this.activeNode);
2491 if (typeof(val['id']) != 'undefined') {
2492 // this.activeNode = val['id'];
2493 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2497 this.get('/LeftTree.view').selectNode(tg[0]);
2501 if (ret && typeof(val['set']) != 'undefined') {
2502 this.get('/LeftPanel.model').add({
2506 //console.log('active node: ' + this.activeNode);
2509 //Seed.print('a:'+a);
2510 //Seed.print('b:'+b);
2511 //Seed.print('c:'+c);
2514 "drag_motion":function (w, ctx, x, y, time, ud) {
2515 // console.log('DRAG MOTION');
2517 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2518 this.targetData = [];
2519 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2521 // A) find out from drag all the places that node could be dropped.
2522 var src = Gtk.drag_get_source_widget(ctx);
2523 if (!src.dropList) {
2524 Gdk.drag_status(ctx, 0, time);
2527 // b) get what we are over.. (from activeNode)
2528 // tree is empty.. - list should be correct..
2529 if (!this.get('/LeftTree.model').currentTree) {
2530 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2534 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2536 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2539 Gdk.drag_status(ctx, 0,time);
2540 this.get('/LeftTree.view').highlight(false);
2544 // if we have a target..
2545 // -> highlight it! (in browser)
2546 // -> highlight it! (in tree)
2548 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2549 this.get('/LeftTree.view').highlight(tg);
2550 this.targetData = tg;
2551 // for tree we should handle this...
2554 "drag_drop":function (w, ctx, x, y,time, ud) {
2555 print("TARGET: drag-drop");
2556 var is_valid_drop_site = true;
2561 w, /* will receive 'drag-data-received' signal */
2562 ctx, /* represents the current state of the DnD */
2563 this.get('/Window').atoms["STRING"], /* the target type we want */
2564 time /* time stamp */
2568 /* No target offered by source => error */
2571 return is_valid_drop_site;
2573 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2575 print("Browser: drag-data-received");
2576 var delete_selection_data = false;
2577 vardnd_success = false;
2578 /* Deal with what we are given from source */
2579 if( sel_data && sel_data.length ) {
2581 if (ctx.action == Gdk.DragAction.ASK) {
2582 /* Ask the user to move or copy, then set the ctx action. */
2585 if (ctx.action == Gdk.DragAction.MOVE) {
2586 delete_selection_data = true;
2588 var source = Gtk.drag_get_source_widget(ctx);
2590 print("Browser: source.DRAGDATA? " + source.dragData);
2591 if (this.targetData) {
2592 print(this.targetData);
2593 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2602 if (dnd_success == false)
2604 Seed.print ("DnD data transfer failed!\n");
2607 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2619 id : "RightGtkView",
2620 renderJS : function(data, withDebug)
2625 this.withDebug = false;
2627 if (this.renderedEl) {
2628 this.get('view').el.remove(this.renderedEl);
2629 this.renderedEl.destroy();
2630 this.renderedEl = false;
2633 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2634 // in theory tree is actually window..
2636 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2641 this.get('view').el.set_size_request(
2642 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2645 this.renderedEl.set_size_request(
2646 tree.default_width || 600,
2647 tree.default_height || 400
2649 this.get('view').el.show_all();
2654 showInWindow : function() {
2655 print("GET PROEJCT");
2656 var pr = this.get('/LeftProjectTree').getActiveProject();
2658 console.log(pr.paths);
2661 var src= this.buildJS(
2662 this.get('/LeftTree.model').toJS()[0],
2667 //var x = new imports.sandbox.Context();
2671 Seed.check_syntax('var e = ' + src);
2674 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2675 this.get('/Terminal').feed(console._dump(e)+"\n");
2677 var lines = src.split("\n");
2678 var start = Math.max(0, e.line - 10);
2679 var end = Math.min(lines.length, e.line + 10);
2680 for (var i =start ; i < end; i++) {
2682 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2685 this.get('/Terminal').feed(lines[i] + "\n");
2692 this.get('/BottomPane').el.set_current_page(1);
2693 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2694 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2695 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2697 var _top = x.get_global_object()._top;
2699 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2701 if (_top.el.popup) {
2702 _top.el.popup(null, null, null, null, 3, null);
2706 viewAdd : function(item, par)
2708 // does something similar to xobject..
2709 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2711 if (item.pack===false || item.pack === 'false') { // no ;
2714 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2715 var ns = imports.gi[item['|xns']];
2716 var ctr = ns[item['xtype']];
2718 for(var k in item) {
2720 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2735 if (k[0] == '|' && typeof(kv) == 'string') {
2737 if (kv.match(new RegExp('function'))) {
2740 print("WASL " + k + '=' + kv);
2742 eval( 'kv = ' + kv);
2743 } catch(e) { continue; }
2746 print(k + '=' + kv);
2748 if (k[0] == '|') { // should be boolean or number..
2751 if (k == 'show_tabs') { // force tab showing for notebooks.
2759 var el = new ctr(ctr_args);
2762 //console.dump(item.pack);
2769 if (typeof(item.pack) == 'string') {
2771 item.pack.split(',').forEach(function(e, i) {
2773 if (e == 'false') { args.push( false); return; }
2774 if (e == 'true') { args.push( true); return; }
2775 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2778 //print(args.join(","));
2780 pack_m = args.shift();
2782 pack_m = item.pack.shift();
2787 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2789 name: "ArgumentError",
2790 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2791 "ADDING : " + item.id + " " + el
2800 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2801 //Seed.print('args: ' + args.length);
2803 par[pack_m].apply(par, args);
2807 item.items = item.items || [];
2808 item.items.forEach(function(ch) {
2809 _this.viewAdd(ch, el);
2814 // add the signal handlers.
2815 // is it a widget!?!!?
2821 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2822 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2823 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2824 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2825 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2835 widgetExposeEvent : function() {
2836 /// print("WIDGET EXPOSE"); // draw highlight??
2839 widgetDragMotionEvent : function() {
2840 print("WIDGET DRAGMOTION");
2843 widgetDragDropEvent : function() {
2844 print("WIDGET DRAGDROP");
2847 widgetPressEvent : function(w,e,u,d) {
2848 if (this.get('view').pressed) {
2851 this.get('view').pressed = true;
2852 print("WIDGET PRESS " + d.xtreepath );
2853 this.get('/LeftTree.view').selectNode( d.xtreepath );
2856 widgetReleaseEvent : function() {
2857 this.get('view').pressed = false;
2863 pack : "pack_start,false,true,0",
2867 pack : "pack_start,false,false,0",
2868 label : "Run The Application",
2870 "button_press_event":function (self, event) {
2871 // call render on left tree - with special option!?!
2875 print("GET PROEJCT");
2876 var pr = this.get('/LeftProjectTree').getActiveProject();
2879 for (var i in pr.paths) {
2883 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
2884 print ("RUN DIR:" + dir);
2886 this.get('/BottomPane').el.set_current_page(1);
2887 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
2888 , false,false,false);
2889 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
2890 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2900 xtype: Gtk.ScrolledWindow,
2903 shadow_type : Gtk.ShadowType.IN,
2905 XObject.prototype.init.call(this);
2906 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2910 xtype: Gtk.EventBox,
2911 pack : "add_with_viewport",
2913 XObject.prototype.init.call(this);
2914 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
2915 red: 0x9F00, green: 0xB800 , blue : 0xA800
2923 XObject.prototype.init.call(this);
2924 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
2925 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
2930 xtype: Gtk.EventBox,
2933 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
2934 XObject.prototype.init.call(this);
2938 this.el, /* widget that will accept a drop */
2939 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2940 null, /* lists of target to support */
2941 0, /* size of list */
2942 Gdk.DragAction.COPY /* what to do with data after dropped */
2945 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2946 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2949 getActiveNode : function(x,y)
2951 // workout what node is here..
2952 return '0'; // top..
2956 "drag_motion":function (self, ctx, x, y, time) {
2958 // A) find out from drag all the places that node could be dropped.
2959 var src = Gtk.drag_get_source_widget(ctx);
2960 if (!src.dropList) {
2961 Gdk.drag_status(ctx, 0, time);
2964 // b) get what we are over.. (from activeNode)
2965 // tree is empty.. - list should be correct..
2966 if (!this.get('/LeftTree.model').currentTree) {
2967 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2971 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2972 var activeNode = this.getActiveNode(x, y);
2975 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
2978 Gdk.drag_status(ctx, 0,time);
2979 this.get('/LeftTree.view').highlight(false);
2983 // if we have a target..
2984 // -> highlight it! (in browser)
2985 // -> highlight it! (in tree)
2987 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2988 this.get('/LeftTree.view').highlight(tg);
2989 this.targetData = tg;
2990 // for tree we should handle this...
2993 "drag_drop":function (self,ctx, x, y, time) {
2994 Seed.print("TARGET: drag-drop");
2995 var is_valid_drop_site = true;
3000 self, /* will receive 'drag-data-received' signal */
3001 ctx, /* represents the current state of the this.gDnD */
3002 this.get('/Window').atoms["STRING"], /* the target type we want */
3003 time /* time stamp */
3007 /* No target offered by source => error */
3010 return is_valid_drop_site;
3013 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3015 Seed.print("GtkView: drag-data-received");
3016 var delete_selection_data = false;
3017 var dnd_success = false;
3018 /* Deal with what we are given from source */
3019 if( sel_data && sel_data.length ) {
3021 if (ctx.action == Gdk.DragAction.ASK) {
3022 /* Ask the user to move or copy, then set the ctx action. */
3025 if (ctx.action == Gdk.DragAction.MOVE) {
3026 delete_selection_data = true;
3028 var source = Gtk.drag_get_source_widget(ctx);
3030 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3031 if (this.targetData) {
3032 Seed.print(this.targetData);
3033 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3042 if (dnd_success == false)
3044 Seed.print ("DnD data transfer failed!\n");
3047 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3050 "button_press_event":function (self, event) {
3051 this.pressed = false;
3067 xtype: Gtk.ScrolledWindow,
3072 xtype: WebKit.WebView,
3076 XObject.prototype.init.call(this);
3077 this.get('/Window.help-view').el.open(
3078 "http://devel.akbkhome.com/seed/");
3089 xtype: Gtk.Notebook,
3092 XObject.prototype.init.call(this);
3093 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3094 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3099 xtype: Gtk.ScrolledWindow,
3104 xtype: GtkSource.View,
3108 XObject.prototype.init.call(this);
3109 var description = Pango.Font.description_from_string("monospace")
3110 description.set_size(8000);
3111 this.el.modify_font(description);
3114 load : function(str) {
3116 // show the help page for the active node..
3117 this.get('/Window.view-help-nb').el.set_current_page(1);
3119 // get the active element being edited.
3120 var xtype = this.get('/LeftTree.model').file.guessName(
3121 this.get('/MidPropTree').activeElement);
3122 // now load the help info in the page..
3123 this.get('/Window.help-view').el.open(
3124 "http://devel.akbkhome.com/seed/" + xtype + ".html");
3127 this.get('/BottomPane').el.set_current_page(0);
3128 this.el.get_buffer().set_text(str, str.length);
3129 var lm = GtkSource.LanguageManager.get_default();
3131 this.el.get_buffer().set_language(lm.get_language('js'));
3132 var buf = this.el.get_buffer();
3133 var cursor = buf.get_mark("insert");
3134 var iter= new Gtk.TextIter;
3135 buf.get_iter_at_mark(iter, cursor);
3137 iter.set_line_offset(4);
3138 buf.move_mark(cursor, iter);
3141 cursor = buf.get_mark("selection_bound");
3142 iter= new Gtk.TextIter;
3143 buf.get_iter_at_mark(iter, cursor);
3145 iter.set_line_offset(4);
3146 buf.move_mark(cursor, iter);
3148 this.el.grab_focus();
3152 xtype: GtkSource.Buffer,
3153 pack : "set_buffer",
3155 "changed":function (self) {
3156 var s = new Gtk.TextIter();
3157 var e = new Gtk.TextIter();
3158 this.el.get_start_iter(s);
3159 this.el.get_end_iter(e);
3160 var str = this.el.get_text(s,e,true);
3162 Seed.check_syntax('var e = ' + str);
3164 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3165 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3167 print("SYNTAX ERROR IN EDITOR");
3172 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3173 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3176 this.get('/LeftPanel.model').changed( str , false);
3185 xtype: Gtk.ScrolledWindow,
3189 xtype: Vte.Terminal,
3192 feed : function(str) {
3193 this.el.feed(str,str.length);
3204 pack : "pack_start,false,false",
3208 this.get('buttonbar').el.show();
3209 this.get('viewbox').el.hide();
3210 print("TRIED TO HIDE");
3213 this.get('buttonbar').el.hide();
3214 this.get('viewbox').el.show();
3215 // this.get('model').expanded();
3227 pack : "pack_start,false,true",
3229 "clicked":function (self) {
3230 this.get('/RightPalete').show();
3237 stock : Gtk.STOCK_GOTO_FIRST,
3238 icon_size : Gtk.IconSize.MENU
3248 XObject.prototype.init.call(this);
3249 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3252 "enter_notify_event":function (self, event) {
3253 this.get('/RightPalete').show();
3267 pack : "pack_start,false,true",
3276 pack : "pack_start,false,true",
3278 "clicked":function (self) {
3279 this.get('/RightPalete').hide();
3286 stock : Gtk.STOCK_GOTO_LAST,
3287 icon_size : Gtk.IconSize.MENU
3294 xtype: Gtk.ScrolledWindow,
3297 XObject.prototype.init.call(this);
3298 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3299 this.el.set_size_request(-1,200);
3301 shadow_type : Gtk.ShadowType.IN,
3304 xtype: Gtk.TreeView,
3307 XObject.prototype.init.call(this);
3308 this.el.set_size_request(150,-1);
3309 // set_reorderable: [1]
3311 var description = new Pango.FontDescription.c_new();
3312 description.set_size(8000);
3313 this.el.modify_font(description);
3315 this.selection = this.el.get_selection();
3316 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3317 // this.selection.signal['changed'].connect(function() {
3318 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3320 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3322 Gtk.drag_source_set (
3323 this.el, /* widget will be drag-able */
3324 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3325 null, /* lists of target to support */
3326 0, /* size of list */
3327 Gdk.DragAction.COPY /* what to do with data after dropped */
3329 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3331 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3332 Gtk.drag_source_add_text_targets(this.el);
3334 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3335 targets = new Gtk.TargetList();
3336 targets.add( LeftTree.atoms["STRING"], 0, 0);
3337 targets.add_text_targets( 1 );
3338 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3340 //if you want to allow text to be output elsewhere..
3341 //Gtk.drag_source_add_text_targets(this.el);
3345 headers_visible : false,
3346 enable_tree_lines : true,
3348 "drag_begin":function (self, ctx) {
3349 // we could fill this in now...
3350 Seed.print('SOURCE: drag-begin');
3354 var iter = new Gtk.TreeIter();
3355 var s = this.selection;
3356 s.get_selected(this.get('/RightPalete.model').el, iter);
3357 var path = this.get('/RightPalete.model').el.get_path(iter);
3359 var pix = this.el.create_row_drag_icon ( path);
3362 Gtk.drag_set_icon_pixmap (ctx,
3369 var value = new GObject.Value('');
3370 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3371 if (!this.get('/RightPalete').provider) {
3374 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3375 this.el.dragData = value.value;
3382 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3383 //Seed.print('Palete: drag-data-get: ' + target_type);
3384 if (this.el.dragData && this.el.dragData.length ) {
3385 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3389 //this.el.dragData = "TEST from source widget";
3393 "drag_end":function (self, drag_context) {
3394 Seed.print('SOURCE: drag-end');
3395 this.el.dragData = false;
3396 this.el.dropList = false;
3397 this.get('/LeftTree.view').highlight(false);
3403 xtype: Gtk.ListStore,
3406 XObject.prototype.init.call(this);
3407 this.el.set_column_types ( 2, [
3408 GObject.TYPE_STRING, // title
3409 GObject.TYPE_STRING // tip
3414 load : function(tr,iter)
3419 //console.log('Project tree load: ' + tr.length);
3420 var citer = new Gtk.TreeIter();
3421 //this.insert(citer,iter,0);
3422 for(var i =0 ; i < tr.length; i++) {
3425 this.el.append(citer);
3427 this.el.insert(citer,iter,-1);
3432 this.el.set_value(citer, 0, '' + r ); // title
3434 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3435 //if (r.cn && r.cn.length) {
3436 // this.load(r.cn, citer);
3442 getValue : function (iter, col) {
3443 var gval = new GObject.Value('');
3444 this.el.get_value(iter, col ,gval);
3451 xtype: Gtk.TreeViewColumn,
3452 pack : "append_column",
3454 XObject.prototype.init.call(this);
3455 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3459 xtype: Gtk.CellRendererText,
3481 XObject.cache['/Window'] = Window;