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 pm = imports.Builder.Provider.ProjectManager.ProjectManager;
122 var pr = pm.getByFn(fn);
125 this.get('/DialogConfirm').show("Are you sure you want to delete project '" + pr.name + "'", function() {
126 pm.deleteProject(fn);
134 xtype: Gtk.SeparatorMenuItem,
141 use_underline : true,
143 "activate":function (self) {
177 label : "Select Project",
179 pack : "pack_start,false,true",
181 XObject.prototype.init.call(this);
182 this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
185 "activate":function (self) {
186 var nb = this.get('/LeftTopPanel.notebook');
187 if (this.el.expanded) {
190 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
193 var model = this.get('/LeftProjectTree.combomodel');
194 // print ("loading Projects?")
195 //console.dump(pm.projects);
196 model.loadData(pm.projects);
199 nb.el.set_current_page(1);
200 //pm.on('changed', function() {
201 //console.log("CAUGHT project manager change");
202 // _combo.model.loadData(pm.projects);
206 nb.el.set_current_page(0);
208 "enter_notify_event":function (self, event) {
209 this.el.expanded = !this.el.expanded;
210 //if (this.el.expanded ) {
211 this.listeners.activate.call(this);
223 pack : "pack_start,true,true",
225 XObject.prototype.init.call(this);
226 this.el.set_current_page(0);
231 xtype: Gtk.ScrolledWindow,
233 shadow_type : Gtk.ShadowType.IN,
235 XObject.prototype.init.call(this);
236 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
239 getPaleteProvider : function() {
240 var model = this.get('model');
241 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
242 return pm.getPalete(model.file.getType());
244 renderView : function() {
245 var model = this.get('model');
246 print("RENDER VIEW?" + model.file.getType());
247 switch( model.file.getType()) {
249 this.get('/RightBrowser.view').renderJS(model.toJS(false,true)[0]);
251 this.get('/RightGtkView').renderJS(model.toJS(false,true)[0]);
259 headers_visible : false,
260 enable_tree_lines : true,
263 XObject.prototype.init.call(this);
264 var description = new Pango.FontDescription.c_new();
265 description.set_size(8000);
266 this.el.modify_font(description);
268 this.selection = this.el.get_selection();
269 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
271 this.selection.signal['changed'].connect(function() {
272 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
273 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
277 Gtk.drag_source_set (
278 this.el, /* widget will be drag-able */
279 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
280 null, /* lists of target to support */
281 0, /* size of list */
282 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
285 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
287 Gtk.drag_source_add_text_targets(this.el);
290 this.el, /* widget that will accept a drop */
291 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
292 null, /* lists of target to support */
293 0, /* size of list */
294 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
297 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
298 Gtk.drag_dest_add_text_targets(this.el);
300 highlight : function(treepath_ar) {
301 if (treepath_ar.length && treepath_ar[0].length ) {
302 this.el.set_drag_dest_row(
303 new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);
305 this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
309 selectNode : function(treepath_str) {
310 //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
311 var tp = new Gtk.TreePath.from_string(treepath_str);
312 this.el.set_cursor(tp, null, false);
313 this.el.scroll_to_cell(tp, null, false, 0,0);
316 "button_press_event":function (self, ev) {
317 console.log("button press?");
318 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
319 print("click" + ev.type);
325 this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
327 if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();
329 this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
330 this.get('/LeftTreeMenu').el.show_all();
331 this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
332 print("click:" + res.path.to_string());
335 "drag_begin":function (self, drag_context) {
336 print('SOURCE: drag-begin');
337 this.targetData = false;
338 // find what is selected in our tree...
339 var iter = new Gtk.TreeIter();
340 var s = this.selection;
341 s.get_selected(this.get('/LeftTree.model').el, iter);
343 // set some properties of the tree for use by the dropped element.
344 var value = new GObject.Value('');
345 this.get('/LeftTree.model').el.get_value(iter, 2, value);
346 var data = JSON.parse(value.value);
347 var xname = this.get('/LeftTree.model').file.guessName(data);
349 this.el.dragData = xname;
350 this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);
353 // make the drag icon a picture of the node that was selected
354 var path = this.get('/LeftTree.model').el.get_path(iter);
355 this.el.treepath = path.to_string();
357 var pix = this.el.create_row_drag_icon ( path);
359 Gtk.drag_set_icon_pixmap (ctx,
368 "drag_end":function (self, drag_context) {
369 Seed.print('LEFT-TREE: drag-end');
370 this.el.dragData = false;
371 this.el.dropList = false;
372 this.targetData = false;
373 this.get('/LeftTree.view').highlight(false);
376 "drag_motion":function (self, ctx, x, y, time) {
377 console.log("LEFT-TREE: drag-motion");
378 var src = Gtk.drag_get_source_widget(ctx);
380 // a drag from elsewhere...- prevent drop..
382 print("no drag data!");
383 Gdk.drag_status(ctx, 0, time);
384 this.targetData = false;
387 var action = Gdk.DragAction.COPY;
388 if (src == this.el) {
389 // unless we are copying!!! ctl button..
390 action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
394 if (!this.get('/LeftTree.model').el.iter_n_children(null)) {
395 // no children.. -- asume it's ok..
396 this.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];
397 Gdk.drag_status(ctx, action ,time);
401 print("GETTING POS");
402 var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);
403 print("ISOVER? " + isOver);
405 Gdk.drag_status(ctx, 0 ,time);
406 return false; // not over apoint!?!
408 // drag node is parent of child..
409 console.log("SRC TREEPATH: " + src.treepath);
410 console.log("TARGET TREEPATH: " + data.path.to_string());
412 // nned to check a few here..
413 //Gtk.TreeViewDropPosition.INTO_OR_AFTER
414 //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
415 //Gtk.TreeViewDropPosition.AFTER
416 //Gtk.TreeViewDropPosition.BEFORE
418 if (typeof(src.treepath) != 'undefined' &&
419 src.treepath == data.path.to_string().substring(0,src.treepath.length)) {
420 print("subpath drag");
421 Gdk.drag_status(ctx, 0 ,time);
426 //print("DUMPING DATA");
427 //console.dump(data);
430 print(data.path.to_string() +' => '+ data.pos);
431 var tg = this.get('/LeftTree.model').findDropNodeByPath(
432 data.path.to_string(), src.dropList, data.pos);
434 this.get('/LeftTree.view').highlight(tg);
436 print("Can not find drop node path");
437 this.targetData = false;
438 Gdk.drag_status(ctx, 0, time);
442 this.targetData = tg;
445 Gdk.drag_status(ctx, action ,time);
449 "drag_drop":function (w, ctx, x, y, time) {
450 Seed.print("TARGET: drag-drop");
454 w, /* will receive 'drag-data-received' signal */
455 ctx, /* represents the current state of the DnD */
456 this.get('/Window').atoms["STRING"], /* the target type we want */
457 time /* time stamp */
461 /* No target offered by source => error */
466 "drag_data_received":function (self, ctx, x, y, sel_data, info, time) {
467 print("Tree: drag-data-received");
469 var delete_selection_data = false;
470 var dnd_success = false;
471 /* Deal with what we are given from source */
472 if( sel_data && sel_data.length ) {
474 if (ctx.action == Gdk.DragAction.ASK) {
475 /* Ask the user to move or copy, then set the ctx action. */
478 if (ctx.action == Gdk.DragAction.MOVE) {
479 //delete_selection_data = true;
482 var source = Gtk.drag_get_source_widget(ctx);
484 if (this.targetData) {
485 if (source != this.el) {
486 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
488 // drag around.. - reorder..
489 this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);
493 //Seed.print(this.targetData);
499 // we can send stuff to souce here...
505 if (dnd_success == false)
507 Seed.print ("DnD data transfer failed!\n");
510 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
513 "cursor_changed":function (self) {
514 if (this.blockChanges) {
517 var iter = new Gtk.TreeIter();
519 if (this.selection.count_selected_rows() < 1) {
520 this.get('/LeftPanel.model').load( false);
521 this.get('/MidPropTree').activeElement = false;
522 this.get('/MidPropTree').hideWin();
524 var pm = this.get('/RightPalete.model');
525 if (!this.get('/LeftTree').getPaleteProvider()) {
526 // it may not be loaded yet..
529 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
530 this.get('/LeftTree.model').listAllTypes()));
535 //console.log('changed');
536 var s = this.selection;
537 s.get_selected(this.get('/LeftTree.model').el, iter);
541 value = new GObject.Value('');
542 this.get('/LeftTree.model').el.get_value(iter, 2, value);
543 this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
545 var data = JSON.parse(value.value);
546 this.get('/MidPropTree').activeElement = data;
547 this.get('/MidPropTree').hideWin();
548 this.get('/LeftPanel.model').load( data);
550 console.log(value.value);
551 // _g.button.set_label(''+value.get_string());
553 var pm =this.get('/RightPalete.model');
554 pm.load( this.get('/RightPalete').provider.gatherList(
555 this.get('/LeftTree.model').listAllTypes()));
560 //Seed.print( value.get_string());
567 xtype: Gtk.TreeStore,
571 XObject.prototype.init.call(this);
572 this.el.set_column_types ( 3, [
573 GObject.TYPE_STRING, // title
574 GObject.TYPE_STRING, // tip
575 GObject.TYPE_STRING // source..
579 changed : function(n, refresh) {
580 print("MODEL CHANGED CALLED" + this.activePath);
581 if (this.activePath) {
582 var iter = new Gtk.TreeIter();
583 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
584 this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
585 this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
587 this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
589 //this.currentTree = this.toJS(false, true)[0];
590 this.file.items = this.toJS(false, false);
591 print("AFTER CHANGED");
592 //console.dump(this.file.items);
594 this.currentTree = this.file.items[0];
595 //console.log(this.file.toSource());
598 print("REDNER BROWSER?!");
599 this.get('/LeftTree').renderView();
601 var pm = this.get('/RightPalete.model');
602 if (!this.get('/RightPalete').provider) {
608 pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
609 //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
613 loadFile : function(f) {
619 console.log('missing file');
623 // load the file if not loaded..
624 if (f.items === false) {
626 f.loadItems(function() {
632 if (f.items.length && typeof(f.items[0]) == 'string') {
634 this.get('/RightEditor').el.show();
635 this.get('/RightEditor.view').load( f.items[0]);
639 //console.dump(f.items);
641 this.get('/LeftTree.view').el.expand_all();
643 if (!f.items.length) {
646 this.get('/Window.leftvpaned').el.set_position(80);
648 this.get('/LeftTree.view').el.set_cursor(
649 new Gtk.TreePath.from_string('0'), null, false);
653 this.get('/Window.leftvpaned').el.set_position(200);
657 //print("hide right editior");
658 this.get('/RightEditor').el.hide();
659 //print("set current tree");
660 this.currentTree = this.toJS(false, false)[0];
661 //console.dump(this.currentTree);
662 this.currentTree = this.currentTree || { items: [] };
663 this.get('/LeftTree').renderView();
664 //console.dump(this.map);
665 //var RightPalete = imports.Builder.RightPalete.RightPalete;
666 var pm = this.get('/RightPalete.model');
669 this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
671 if (!this.get('/RightPalete').provider) {
672 print ("********* PALETE PROVIDER MISSING?!!");
674 this.get('/LeftTree').renderView();
676 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
680 this.get('/Window.view-notebook').el.set_current_page(
681 this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
684 findDropNode : function(treepath_str, targets) {
686 // this is used by the dragdrop code in the roo version AFAIR..
688 var path = treepath_str.replace(/^builder-/, '');
689 // treemap is depreciated... - should really check if model has any entries..
691 if (!this.el.iter_n_children(null)) {
693 return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];
695 print("FIND treepath: " + path);
696 //console.dump(this.treemap);
698 if (!treepath_str.match(/^builder-/)) {
699 return []; // nothing!
701 if (targets === true) {
704 return this.findDropNodeByPath(path,targets)
706 findDropNodeByPath : function(treepath_str, targets, pref) {
707 var path = treepath_str + ''; // dupe it..
708 pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
710 //console.dump(this.treemap);
711 while (path.length) {
712 print("LOOKING FOR PATH: " + path);
713 var node_data = this.singleNodeToJS(path);
714 if (node_data === false) {
715 print("node not found");
719 var xname = this.get('/LeftTree.model').file.guessName(node_data);
722 targets.forEach(function(tg) {
726 if ((tg == xname) ) {
729 if (tg.indexOf(xname +':') === 0) {
731 prop = tg.split(':').pop();
736 if (last) { // pref is after/before..
737 // then it's after last
739 return []; // do not allow..
741 return [ last, pref , prop];
744 return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
746 var par = path.split(':');
749 path = par.join(':');
755 dropNode : function(target_data, node) {
758 console.dump(target_data);
759 var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
761 print("add " + tp + "@" + target_data[1] );
764 if (tp && target_data[1] < 2) { // before or after..
765 var ar = target_data[0].split(':');
767 parent = new Gtk.TreePath.from_string( ar.join(':') );
770 var n_iter = new Gtk.TreeIter();
771 var iter_par = new Gtk.TreeIter();
772 var iter_after = after ? new Gtk.TreeIter() : false;
776 if (parent !== false) {
777 this.el.get_iter(iter_par, parent);
784 print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
785 this.el.get_iter(iter_after, after);
786 this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
787 n_iter, iter_par, iter_after);
790 this.el.append(n_iter, iter_par);
794 if (typeof(node) == 'string') {
795 var ar = node.split('.');
796 var xtype = ar.pop();
799 '|xns' : ar.join('.'),
802 if (target_data.length == 3 && target_data[2].length) {
803 node['*prop'] = target_data[2];
807 // work out what kind of packing to use..
808 if (typeof(node.pack) == 'undefined' && parent !== false) {
809 var pal = this.get('/LeftTree').getPaleteProvider();
811 var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
812 print ("PNAME : " + pname);
813 var cname = pal.guessName(node);
814 print ("CNAME : " + cname);
815 node.pack = pal.getDefaultPack(pname, cname);
826 // load children - if it has any..
829 this.load(xitems, n_iter);
831 if (tp && (xitems || after)) {
832 this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
834 // wee need to get the empty proptypes from somewhere..
836 //var olditer = this.activeIter;
837 this.activePath = this.el.get_path(n_iter).to_string();
839 // changed actually set's the node data..
840 this.changed(node, true);
844 this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
846 //Builder.MidPropTree._model.load(node);
847 //Builder.MidPropTree._win.hideWin();
848 //Builder.LeftPanel._model.load( node);
852 moveNode : function(target_data, action) {
853 //print("MOVE NODE");
854 // console.dump(target_data);
855 var old_iter = new Gtk.TreeIter();
856 var s = this.get('/LeftTree.view').selection;
857 s.get_selected(this.el, old_iter);
858 var node = this.nodeToJS(old_iter,false);
859 //console.dump(node);
862 // needs to drop first, otherwise the target_data
863 // treepath will be invalid.
865 this.dropNode(target_data, node);
866 if (action & Gdk.DragAction.MOVE) {
867 // print("REMOVING OLD NODE");
868 this.el.remove(old_iter);
872 this.activePath= false;
873 this.changed(false,true);
875 deleteSelected : function() {
876 this.get('/LeftTree.view').blockChanges = true;
877 var old_iter = new Gtk.TreeIter();
878 var s = this.get('/LeftTree.view').selection;
879 s.get_selected(this.el, old_iter);
880 var path = this.el.get_path(old_iter).to_string();
882 this.activePath= false;
885 this.activePath= false;
886 var iter = new Gtk.TreeIter();
887 this.el.get_iter_from_string(iter, path);
888 this.el.remove(iter);
890 // rebuild treemap. -- depreciated.!!
893 //this.toJS(null, true) // does not do anything?
894 this.activePath= false;
895 this.changed(false,true);
896 this.get('/LeftTree.view').blockChanges = false;
899 listAllTypes : function() {
900 var s = this.get('/LeftTree.view').selection;
901 print ("LIST ALL TYPES: " + s.count_selected_rows() );
903 if (s.count_selected_rows() > 0) {
904 var iter = new Gtk.TreeIter();
905 s.get_selected(this.el, iter);
907 // set some properties of the tree for use by the dropped element.
908 var value = new GObject.Value('');
909 this.el.get_value(iter, 2, value);
910 var data = JSON.parse(value.value);
913 var xname = this.get('/LeftTree.model').file.guessName(data);
914 console.log('selected:' + xname);
918 return []; // could not find it..
926 li.forEach(function(el) {
927 // this is specific to roo!!!?
929 var fullpath = _this.file.guessName(el);
930 if (fullpath.length && ret.indexOf(fullpath) < 0) {
935 if (el.items && el.items.length) {
944 addall([this.currentTree]);
946 // only if we have nothing, should we add '*top'
950 //console.log('all types in tree');
956 singleNodeToJS : function (treepath)
958 var iter = new Gtk.TreeIter();
959 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
963 var iv = this.getIterValue(iter, 2);
965 return JSON.parse(iv);
968 nodeToJS : function (iter, with_id)
970 var par = new Gtk.TreeIter();
971 var iv = this.getIterValue(iter, 2);
973 var k = JSON.parse(iv);
974 if (k.json && !this.el.iter_parent( par, iter )) {
979 var treepath_str = this.el.get_path(iter).to_string();
980 // not sure how we can handle mixed id stuff..
981 if (typeof(k.id) == 'undefined') {
982 k.id = 'builder-'+ treepath_str ;
986 this.treemap[ treepath_str ] = k;
987 k.xtreepath = treepath_str ;
990 if (this.el.iter_has_child(iter)) {
991 citer = new Gtk.TreeIter();
992 this.el.iter_children(citer, iter);
993 k.items = this.toJS(citer,with_id);
997 toJS : function(iter, with_id)
999 //Seed.print("WITHID: "+ with_id);
1006 iter = new Gtk.TreeIter();
1007 if (!this.el.get_iter_first(iter)) {
1017 var k = this.nodeToJS(iter, with_id);
1021 if (!this.el.iter_next(iter)) {
1027 // convert the list into a json string..
1031 getIterValue : function (iter, col) {
1032 var gval = new GObject.Value('');
1033 this.el.get_value(iter, col ,gval);
1038 nodeTitle : function(c) {
1041 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
1042 if (sr) txt.push('<s>');
1043 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
1044 if (c.xtype) { txt.push(c.xtype); }
1045 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1046 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1047 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1050 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1051 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1052 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1053 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1054 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1055 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1056 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1057 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1058 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1060 // for flat classes...
1061 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1062 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1065 if (sr) txt.push('</s>');
1066 return (txt.length == 0 ? "Element" : txt.join(" "));
1068 nodeToJSON : function(c) {
1076 return JSON.stringify(o);
1078 load : function(tr,iter)
1080 var citer = new Gtk.TreeIter();
1081 //this.insert(citer,iter,0);
1082 for(var i =0 ; i < tr.length; i++) {
1084 this.el.insert(citer,iter,-1);
1086 this.el.append(citer);
1089 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1090 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1091 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1092 if (tr[i].items && tr[i].items.length) {
1093 this.load(tr[i].items, citer);
1099 xtype: Gtk.TreeViewColumn,
1100 pack : "append_column",
1102 XObject.prototype.init.call(this);
1103 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1107 xtype: Gtk.CellRendererText,
1117 id : "LeftTreeMenu",
1120 xtype: Gtk.MenuItem,
1122 label : "Delete Element",
1124 "activate":function (self) {
1126 this.get('/LeftTree.model').deleteSelected();
1137 id : "LeftProjectTree",
1138 showNoProjectSelected : function() {
1139 this.get('/StandardErrorDialog').show("Select a Project first.");
1141 getActiveProject : function() {
1142 return this.project;
1145 "leave_notify_event":function (self, event) {
1152 pack : "pack_start,false,false",
1155 xtype: Gtk.ComboBox,
1158 XObject.prototype.init.call(this);
1159 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1161 getValue : function() {
1162 var ix = this.el.get_active();
1166 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1169 setValue : function(fn)
1173 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1174 data.forEach(function(n, ix) {
1182 "changed":function (self) {
1183 var fn = this.getValue();
1184 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1185 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1190 xtype: Gtk.CellRendererText,
1191 pack : "pack_start,true",
1195 xtype: Gtk.ListStore,
1198 XObject.prototype.init.call(this);
1199 this.el.set_column_types ( 2, [
1200 GObject.TYPE_STRING, // real key
1201 GObject.TYPE_STRING // real type
1205 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1207 pm.on('changed', function() {
1208 _this.loadData(pm.projects);
1212 loadData : function(data) {
1213 var ov = this.get('/LeftProjectTree.combo').getValue();
1215 var iter = new Gtk.TreeIter();
1217 data.forEach(function(p) {
1222 el.set_value(iter, 0, p.fn);
1223 el.set_value(iter, 1, p.name);
1227 this.get('/LeftProjectTree.combo').setValue(ov);
1236 xtype: Gtk.ScrolledWindow,
1238 shadow_type : Gtk.ShadowType.IN,
1240 XObject.prototype.init.call(this);
1241 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1245 xtype: Gtk.TreeView,
1246 headers_visible : false,
1247 enable_tree_lines : true,
1250 XObject.prototype.init.call(this);
1251 var description = new Pango.FontDescription.c_new();
1252 description.set_size(8000);
1253 this.el.modify_font(description);
1255 this.selection = this.el.get_selection();
1256 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1260 "cursor_changed":function (self) {
1261 var iter = new Gtk.TreeIter();
1263 if (this.selection.count_selected_rows() < 1) {
1264 //XN.get('Builder.LeftTree.model').
1265 this.get('/LeftTree.model').load( false);
1269 var model = this.get('/LeftProjectTree.model');
1270 //console.log('changed');
1271 var s = this.selection;
1272 s.get_selected(model, iter);
1273 value = new GObject.Value('');
1274 model.el.get_value(iter, 2, value);
1276 console.log(value.value);// id..
1278 var file = this.get('/LeftProjectTree').project.getById(value.value);
1285 var nb = this.get('/LeftTopPanel.expander');
1286 nb.el.expanded = false;
1287 nb.listeners.activate.call(nb);
1288 //_expander.el.set_expanded(false);
1290 var ltm = this.get('/LeftTree.model');
1298 xtype: Gtk.TreeStore,
1302 XObject.prototype.init.call(this);
1303 this.el.set_column_types ( 3, [
1304 GObject.TYPE_STRING, // title
1305 GObject.TYPE_STRING, // tip
1306 GObject.TYPE_STRING // id..
1310 loadProject : function(pr) {
1315 this.get('/LeftProjectTree').project = pr;
1316 this.load(pr.toTree());
1317 this.get('/LeftProjectTree.view').el.expand_all();
1319 load : function(tr,iter) {
1321 console.log('Project tree load: ' + tr.length);
1322 var citer = new Gtk.TreeIter();
1323 //this.insert(citer,iter,0);
1326 tr.forEach(function (r) {
1328 _this.el.append(citer);
1330 _this.el.insert(citer,iter,-1);
1332 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1333 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1334 _this.el.set_value(citer, 2, '' + r.id ); //id
1335 if (r.cn && r.cn.length) {
1336 _this.load(r.cn, citer);
1341 getValue : function(iter, col) {
1342 var gval = new GObject.Value('');
1343 this.el.get_value(iter, col ,gval);
1344 return '' + gval.value;
1348 xtype: Gtk.TreeViewColumn,
1349 pack : "append_column",
1351 XObject.prototype.init.call(this);
1352 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1356 xtype: Gtk.CellRendererText,
1379 pack : "pack_start,false,true,0",
1386 "button_press_event":function (self, event) {
1387 this.get('/MidPropTree.model').showData('props');
1399 stock : Gtk.STOCK_ADD,
1400 icon_size : Gtk.IconSize.MENU
1415 "button_press_event":function (self, event) {
1416 this.get('/MidPropTree.model').showData('events');
1428 stock : Gtk.STOCK_ADD,
1429 icon_size : Gtk.IconSize.MENU
1444 "button_press_event":function (self, ev) {
1445 var p = this.get('/AddPropertyPopup');
1449 p.el.set_screen(Gdk.Screen.get_default());
1451 p.el.popup(null, null, null, null, 3, ev.button.time);
1463 stock : Gtk.STOCK_ADD,
1464 icon_size : Gtk.IconSize.MENU
1476 id : "AddPropertyPopup",
1479 xtype: Gtk.MenuItem,
1481 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1484 "activate":function (self) {
1486 this.get('/LeftPanel.model').add( {
1497 xtype: Gtk.MenuItem,
1499 tooltip_markup : "Add what type of packing is to be used",
1502 "activate":function (self) {
1504 this.get('/LeftPanel.model').add( {
1514 xtype: Gtk.MenuItem,
1516 tooltip_markup : "Override the init method",
1519 "activate":function (self) {
1521 this.get('/LeftPanel.model').add( {
1524 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1531 xtype: Gtk.SeparatorMenuItem,
1535 xtype: Gtk.MenuItem,
1537 tooltip_markup : "Add a user defined string property",
1540 "activate":function (self) {
1542 this.get('/LeftPanel.model').add( {
1552 xtype: Gtk.MenuItem,
1554 tooltip_markup : "Add a user defined number property",
1557 "activate":function (self) {
1559 this.get('/LeftPanel.model').add( {
1569 xtype: Gtk.MenuItem,
1571 tooltip_markup : "Add a user defined boolean property",
1574 "activate":function (self) {
1576 this.get('/LeftPanel.model').add( {
1586 xtype: Gtk.SeparatorMenuItem,
1590 xtype: Gtk.MenuItem,
1592 tooltip_markup : "Add a user function boolean property",
1595 "activate":function (self) {
1597 this.get('/LeftPanel.model').add( {
1600 val : "function() {\n \n}\n",
1613 xtype: Gtk.ScrolledWindow,
1616 shadow_type : Gtk.ShadowType.IN,
1619 XObject.prototype.init.call(this);
1620 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1624 xtype: Gtk.TreeView,
1627 headers_visible : false,
1628 enable_tree_lines : true,
1630 XObject.prototype.init.call(this);
1632 this.selection = this.el.get_selection();
1633 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1636 var description = new Pango.FontDescription.c_new();
1637 description.set_size(8000);
1638 this.el.modify_font(description);
1641 "button_press_event":function (self, ev) {
1645 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1646 return false; //not on a element.
1650 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1652 if (res.column.title != 'value') {
1653 return false; // ignore..
1655 if ( this.get('/LeftPanel').editing) {
1658 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1659 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1660 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1664 var provider = this.get('/LeftTree').getPaleteProvider();
1666 var opts = provider.findOptions(type);
1668 if (opts === false) {
1669 this.get('/LeftPanel').editableColumn.setOptions([]);
1670 renderer.has_entry = true;
1672 LeftPanel.editableColumn.setOptions(opts);
1673 renderer.has_entry = false;
1677 //Seed.print("click" + ev.type);
1678 //console.dump(res);
1684 if (res.column.title == 'value') {
1687 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1688 var p = this.get('/LeftPanelPopup');
1693 p.el.set_screen(Gdk.Screen.get_default());
1695 p.el.popup(null, null, null, null, 3, ev.button.time);
1696 //Seed.print("click:" + res.column.title);
1704 xtype: Gtk.TreeStore,
1708 XObject.prototype.init.call(this);
1709 this.el.set_column_types ( 5, [
1710 GObject.TYPE_STRING, // 0 real key
1711 GObject.TYPE_STRING, // 1 real value
1712 GObject.TYPE_STRING, // 2 visable key
1713 GObject.TYPE_STRING, // 3 visable value
1714 GObject.TYPE_STRING, // 4 need to store type of!!!
1718 toShort : function(str) {
1719 var a = typeof(str) == 'string' ? str.split("\n") : [];
1720 return a.length > 1 ? a[0] + '....' : '' + str;
1722 load : function(ar) {
1725 this.get('/RightEditor').el.hide();
1732 var provider = this.get('/LeftTree').getPaleteProvider();
1735 var iter = new Gtk.TreeIter();
1737 if (typeof(ar[i]) == 'object') {
1741 var type = provider.findType(ar, i, ar[i]);
1743 this.el.append(iter);
1744 var p = this.el.get_path(iter).to_string();
1746 this.el.set_value(iter, 0, i);
1747 this.el.set_value(iter, 1, '' + ar[i]);
1748 this.el.set_value(iter, 2, i);
1749 this.el.set_value(iter, 3, this.toShort(ar[i]));
1750 this.el.set_value(iter, 4, type);
1752 ar.listeners = ar.listeners || {};
1753 for (var i in ar.listeners ) {
1754 this.el.append(iter);
1755 var p = this.el.get_path(iter).to_string();
1758 this.el.set_value(iter, 0, '!'+ i );
1759 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1760 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1762 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1763 this.el.set_value(iter, 4, 'function');
1767 add : function(info) {
1768 // info includes key, val, skel, etype..
1770 type = info.type.toLowerCase();
1771 var data = this.toJS();
1773 if (info.etype == 'events') {
1774 data.listeners = data.listeners || { };
1775 if (typeof(data.listeners[info.key]) != 'undefined') {
1776 return; //already set!
1779 if (typeof(data[info.key]) != 'undefined') {
1784 if (typeof(info.val) == 'undefined') {
1787 if (info.type == 'boolean') {
1790 if (type == 'number') {
1798 if (info.etype == 'events') {
1800 data.listeners[info.key] = info.val;
1803 data[info.key] = info.val;
1807 var map = this.load(data);
1809 // flag it as changed to the interface..
1811 this.get('/LeftTree.model').changed(data, true);
1814 this.startEditing(map[k]);
1817 LeftPanel.get('view').el.row_activated(
1818 new Gtk.TreePath.from_string(map[k]),
1819 LeftPanel.editableColumn.el
1823 startEditing : function(path,col) {
1825 * start editing path (or selected if not set..)
1826 * @param {String|false} path (optional) treepath to edit - selected tree gets
1827 * edited by default.
1828 * @param {Number} 0 or 1 (optional)- column to edit.
1831 if (typeof(path) == 'string') {
1832 tp = new Gtk.TreePath.from_string(path);
1834 var iter = new Gtk.TreeIter();
1835 var s = this.get('/LeftPanel.view').selection;
1836 s.get_selected(this.el, iter);
1837 tp = this.el.get_path(iter);
1838 path = tp.to_string();
1842 // which colum is to be edited..
1844 if (typeof(col) == 'undefined') {
1845 var k = this.getValue(path, 0);
1846 colObj = (!k.length || k == '|') ?
1847 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1849 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1852 // make sure the pulldown is set correctly..
1853 // not really needed for second col...
1855 var provider = this.get('/LeftTree').getPaleteProvider();
1857 var type = this.get('/LeftPanel.model').getType(path);
1858 var opts = provider.findOptions(type);
1859 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1861 if (opts === false) {
1862 this.get('/LeftPanel').editableColumn.setOptions([]);
1863 renderer.has_entry = true; /// probably does not have any effect.
1865 this.get('/LeftPanel').editableColumn.setOptions(opts);
1866 renderer.has_entry = false;
1870 // iter now has row...
1871 GLib.timeout_add(0, 100, function() {
1873 colObj.items[0].el.editable = true; // esp. need for col 0..
1874 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1883 deleteSelected : function() {
1884 var data = this.toJS();
1885 var iter = new Gtk.TreeIter();
1886 var s = this.get('/LeftPanel.view').selection;
1887 s.get_selected(this.el, iter);
1890 var gval = new GObject.Value('');
1891 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1893 var val = gval.value;
1894 if (val[0] == '!') {
1896 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1899 delete data.listeners[ val.substring(1)];
1900 if (!XObject.keys(data.listeners).length) {
1901 delete data.listeners;
1905 if (typeof(data[val]) == 'undefined') {
1913 this.get('/LeftTree.model').changed(data, true);
1917 changed : function(str, doRefresh) {
1918 if (!this.activePath) {
1921 var iter = new Gtk.TreeIter();
1922 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1924 this.el.set_value(iter, 1, '' +str);
1925 this.el.set_value(iter, 3, '' + this.toShort(str));
1926 // update the tree...
1928 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
1931 var iter = new Gtk.TreeIter();
1932 this.get('/LeftPanel.model').el.get_iter_first(iter);
1937 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
1940 ar.listeners = ar.listeners || {};
1941 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
1944 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
1947 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
1953 //print(JSON.stringify(ar));
1957 getType : function(treepath) {
1958 return this.getValue(treepath, 4);
1960 getValue : function(treepath_str, col) {
1961 var iter = new Gtk.TreeIter();
1962 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
1964 var gval = new GObject.Value('');
1965 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
1966 var val = '' + gval.value;
1970 var type = this.getType(this.el.get_path(iter).to_string());
1971 //print("TYPE: " +type + " - val:" + val);
1972 switch(type.toLowerCase()) {
1976 return parseFloat(val); // Nan ?? invalid!!?
1978 return val == 'true' ? true : false;
1984 editSelected : function(e) {
1985 print("EDIT SELECTED?");
1986 var iter = new Gtk.TreeIter();
1987 var s = this.get('/LeftPanel.view').selection;
1988 s.get_selected(this.get('/LeftPanel.model').el, iter);
1989 var m = this.get('/LeftPanel.model')
1991 var gval = new GObject.Value('');
1992 this.el.get_value(iter, 0 ,gval);
1993 var val = '' + gval.value;
1995 gval = new GObject.Value('');
1996 this.el.get_value(iter, 1 ,gval);
1997 var rval = gval.value;
1998 var activePath = this.el.get_path(iter).to_string();
1999 this.activePath = activePath ;
2000 // was activeIter...
2003 var showEditor = false;
2005 if (val[0] == '!') {
2008 if (val[0] == '|') {
2009 if (rval.match(/function/g) || rval.match(/\n/g)) {
2016 this.activePath = false;
2017 GLib.timeout_add(0, 1, function() {
2018 // Gdk.threads_enter();
2019 _this.get('/RightEditor').el.show();
2020 _this.get('/RightEditor.view').load( rval );
2024 _this.activePath = activePath ;
2026 // Gdk.threads_leave();
2032 this.get('/RightEditor').el.hide();
2034 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2040 xtype: Gtk.TreeViewColumn,
2041 pack : "append_column",
2043 XObject.prototype.init.call(this);
2045 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2046 this.get('/LeftPanel').propertyColumn = this;
2051 xtype: Gtk.CellRendererText,
2052 pack : "pack_start",
2054 "editing_started":function (self, editable, path) {
2056 this.get('/LeftPanel.model').activePath = path;
2059 "edited":function (self, object, p0) {
2060 var model = this.get('/LeftPanel.model');
2061 var path = model.activePath;
2062 var iter = new Gtk.TreeIter();
2063 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2064 model.el.set_value(iter, 0, p0);
2065 model.el.set_value(iter, 2, p0);
2067 model.activePath = false;
2069 this.get('/LeftTree.model').changed(model.toJS(), true);
2070 this.el.editable = false;
2077 xtype: Gtk.TreeViewColumn,
2078 pack : "append_column",
2080 XObject.prototype.init.call(this);
2081 this.el.add_attribute(this.items[0].el , 'text', 3 );
2082 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2083 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2084 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2086 this.get('/LeftPanel').editableColumn= this;
2088 setOptions : function(ar) {
2089 var m = this.items[0].el.model;
2091 var iter = new Gtk.TreeIter();
2092 ar.forEach(function(i) {
2095 m.set_value(iter, 0, i);
2101 xtype: Gtk.CellRendererCombo,
2102 pack : "pack_start",
2107 XObject.prototype.init.call(this);
2108 this.el.model = new Gtk.ListStore();
2109 this.el.model.set_column_types ( 1, [
2110 GObject.TYPE_STRING // 0 real key
2114 "edited":function (self, object, p0) {
2115 this.get('/LeftPanel').editing = false;
2116 print("EDITED? p:" + p0 + " t:" + p0);
2117 this.get('/LeftPanel.model').changed(p0, true);
2118 this.get('/LeftPanel.model').activePath = false;
2120 "editing_started":function (self, editable, path) {
2121 this.get('/LeftPanel').editing = true;
2122 // console.log('editing started');
2123 // r.has_entry = false;
2124 this.get('/LeftPanel.model').editSelected(editable);
2135 id : "LeftPanelPopup",
2138 xtype: Gtk.MenuItem,
2142 "activate":function (self) {
2143 this.get('/LeftPanel.model').deleteSelected();
2148 xtype: Gtk.MenuItem,
2152 "activate":function (self) {
2153 this.get('/LeftPanel.model').startEditing(false, 0);
2166 xtype: Gtk.ScrolledWindow,
2167 pack : "pack_end,false,true,0",
2169 shadow_type : Gtk.ShadowType.IN,
2171 XObject.prototype.init.call(this);
2172 XObject.prototype.init.call(this);
2173 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2174 this.el.set_size_request ( 150, -1 );
2177 activeElement : false,
2178 hideWin : function() {
2185 if (this.get('/Window.left').el.position < 160) {
2188 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2195 xtype: Gtk.TreeView,
2196 enable_tree_lines : true,
2197 headers_visible : false,
2200 XObject.prototype.init.call(this);
2202 var description = new Pango.FontDescription.c_new();
2203 description.set_size(8000);
2204 this.el.modify_font(description);
2206 //this.selection = this.el.get_selection();
2207 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2216 "cursor_changed":function (self) {
2217 var iter = new Gtk.TreeIter();
2219 //console.log('changed');
2220 var m = this.get('model');
2221 if (!this.selection){
2222 this.selection = this.el.get_selection();
2225 var s = this.selection;
2226 if (!s.get_selected(m.el, iter)) {
2229 var tp = m.el.get_path(iter).to_string();
2234 var key = m.getValue(tp, 0);
2236 var type = m.getValue(tp, 1);
2237 var skel = m.getValue(tp, 3);
2238 var etype = m.getValue(tp, 5);
2241 this.get('/MidPropTree').hideWin();
2243 if (type == 'function') {
2245 if (etype != 'events') {
2249 this.get('/LeftPanel.model').add({
2258 if (type.indexOf('.') > -1 ||
2259 type == 'boolean') {
2263 this.get('/LeftPanel.model').add( {
2273 xtype: Gtk.ListStore,
2276 XObject.prototype.init.call(this);
2277 this.el.set_column_types ( 6, [
2278 GObject.TYPE_STRING, // real key
2279 GObject.TYPE_STRING, // real type
2280 GObject.TYPE_STRING, // docs ?
2281 GObject.TYPE_STRING, // visable desc
2282 GObject.TYPE_STRING, // function desc
2283 GObject.TYPE_STRING // element type (event|prop)
2287 getValue : function(treepath, col)
2289 var tp = new Gtk.TreePath.from_string (treepath);
2290 var iter = new Gtk.TreeIter();
2291 this.el.get_iter (iter, tp);
2292 var value = new GObject.Value('');
2293 this.el.get_value(iter, col, value);
2297 showData : function(type) {
2299 if (!this.get('/MidPropTree').activeElement || !type) {
2300 return; // no active element
2303 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2304 var palete = this.get('/LeftTree').getPaleteProvider();
2308 Seed.print('Showing right?');
2309 if (!this.get('/MidPropTree').shown) {
2311 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2312 this.get('/MidPropTree').el.show();
2313 this.get('/MidPropTree').shown = true;
2316 var elementList = palete.getPropertiesFor(fullpath, type);
2317 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2318 // console.dump(elementList);
2321 var iter = new Gtk.TreeIter();
2322 for(var i =0 ; i < elementList.length; i++) {
2323 var p=elementList[i];
2324 this.el.append(iter);
2325 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2326 //GObject.TYPE_STRING, // real key
2327 // GObject.TYPE_STRING, // real type
2328 // GObject.TYPE_STRING, // docs ?
2329 // GObject.TYPE_STRING // func def?
2332 this.el.set_value(iter, 0, p.name);
2333 this.el.set_value(iter, 1, p.type);
2334 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2335 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2336 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2337 this.el.set_value(iter, 5, type);
2345 xtype: Gtk.TreeViewColumn,
2347 this.el = new Gtk.TreeViewColumn();
2348 this.parent.el.append_column(this.el);
2350 XObject.prototype.init.call(this);
2351 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2356 xtype: Gtk.CellRendererText,
2357 pack : "pack_start,true"
2381 xtype: Gtk.Notebook,
2382 pack : "pack_start,true,true",
2383 id : "view-help-nb",
2385 XObject.prototype.init.call(this);
2386 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" }));
2387 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" }));
2391 xtype: Gtk.Notebook,
2393 id : "view-notebook",
2396 XObject.prototype.init.call(this);
2397 this.el.set_current_page(0);
2399 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2400 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2407 id : "RightBrowser",
2411 pack : "pack_start,false,true,0",
2415 pack : "pack_start,false,false,0",
2416 label : "Dump HTML to console",
2418 "activate":function (self) {
2419 this.get('/RightBrowser.view').el.execute_script(
2420 "console.log(document.body.innerHTML);");
2421 this.get('/RightBrowser.view').el.execute_script(
2422 "console.log(Builder.dump(Builder));");
2429 xtype: Gtk.ScrolledWindow,
2431 shadow_type : Gtk.ShadowType.IN,
2433 XObject.prototype.init.call(this);
2434 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2438 xtype: WebKit.WebView,
2442 XObject.prototype.init.call(this);
2443 // this may not work!?
2444 this.el.open('file:///' + __script_path__ + '/../builder.html');
2448 this.el, /* widget that will accept a drop */
2449 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2450 null, /* lists of target to support */
2451 0, /* size of list */
2452 Gdk.DragAction.COPY /* what to do with data after dropped */
2455 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2456 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2458 renderJS : function(data) {
2459 this.renderedData = data;
2460 var str = JSON.stringify(data) ;
2463 console.log('not loaded yet');
2465 Seed.print("RENDER:" + str);
2466 imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2467 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2470 "load_finished":function (self, object) {
2471 if (this.ready) { // dont do it twice!
2476 this.renderJS(this.get('/LeftTree.model').toJS()[0]);
2478 "script_alert":function (self, object, p0) {
2481 return true; // do not display anything...
2483 "console_message":function (self, object, p0, p1) {
2484 console.log(object);
2485 if (!object.match(/^\{/)) {
2486 return false; // do not handle!!! -> later maybe in console..
2488 console.log(object);
2489 var val = JSON.parse(object);
2491 if (typeof(val['hover-node']) != 'undefined') {
2492 this.activeNode = val['hover-node'];
2493 console.log('active node: ' + this.activeNode);
2498 if (typeof(val['id']) != 'undefined') {
2499 // this.activeNode = val['id'];
2500 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2504 this.get('/LeftTree.view').selectNode(tg[0]);
2508 if (ret && typeof(val['set']) != 'undefined') {
2509 this.get('/LeftPanel.model').add({
2513 //console.log('active node: ' + this.activeNode);
2516 //Seed.print('a:'+a);
2517 //Seed.print('b:'+b);
2518 //Seed.print('c:'+c);
2521 "drag_motion":function (w, ctx, x, y, time, ud) {
2522 // console.log('DRAG MOTION');
2524 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2525 this.targetData = [];
2526 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2528 // A) find out from drag all the places that node could be dropped.
2529 var src = Gtk.drag_get_source_widget(ctx);
2530 if (!src.dropList) {
2531 Gdk.drag_status(ctx, 0, time);
2534 // b) get what we are over.. (from activeNode)
2535 // tree is empty.. - list should be correct..
2536 if (!this.get('/LeftTree.model').currentTree) {
2537 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2541 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2543 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2546 Gdk.drag_status(ctx, 0,time);
2547 this.get('/LeftTree.view').highlight(false);
2551 // if we have a target..
2552 // -> highlight it! (in browser)
2553 // -> highlight it! (in tree)
2555 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2556 this.get('/LeftTree.view').highlight(tg);
2557 this.targetData = tg;
2558 // for tree we should handle this...
2561 "drag_drop":function (w, ctx, x, y,time, ud) {
2562 print("TARGET: drag-drop");
2563 var is_valid_drop_site = true;
2568 w, /* will receive 'drag-data-received' signal */
2569 ctx, /* represents the current state of the DnD */
2570 this.get('/Window').atoms["STRING"], /* the target type we want */
2571 time /* time stamp */
2575 /* No target offered by source => error */
2578 return is_valid_drop_site;
2580 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2582 print("Browser: drag-data-received");
2583 var delete_selection_data = false;
2584 vardnd_success = false;
2585 /* Deal with what we are given from source */
2586 if( sel_data && sel_data.length ) {
2588 if (ctx.action == Gdk.DragAction.ASK) {
2589 /* Ask the user to move or copy, then set the ctx action. */
2592 if (ctx.action == Gdk.DragAction.MOVE) {
2593 delete_selection_data = true;
2595 var source = Gtk.drag_get_source_widget(ctx);
2597 print("Browser: source.DRAGDATA? " + source.dragData);
2598 if (this.targetData) {
2599 print(this.targetData);
2600 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2609 if (dnd_success == false)
2611 Seed.print ("DnD data transfer failed!\n");
2614 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2626 id : "RightGtkView",
2627 renderJS : function(data, withDebug)
2632 this.withDebug = false;
2634 if (this.renderedEl) {
2635 this.get('view').el.remove(this.renderedEl);
2636 this.renderedEl.destroy();
2637 this.renderedEl = false;
2640 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2641 // in theory tree is actually window..
2643 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2648 this.get('view').el.set_size_request(
2649 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2652 this.renderedEl.set_size_request(
2653 tree.default_width || 600,
2654 tree.default_height || 400
2656 this.get('view').el.show_all();
2661 showInWindow : function() {
2662 print("GET PROEJCT");
2663 var pr = this.get('/LeftProjectTree').getActiveProject();
2665 console.log(pr.paths);
2668 var src= this.buildJS(
2669 this.get('/LeftTree.model').toJS()[0],
2674 //var x = new imports.sandbox.Context();
2678 Seed.check_syntax('var e = ' + src);
2681 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2682 this.get('/Terminal').feed(console._dump(e)+"\n");
2684 var lines = src.split("\n");
2685 var start = Math.max(0, e.line - 10);
2686 var end = Math.min(lines.length, e.line + 10);
2687 for (var i =start ; i < end; i++) {
2689 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2692 this.get('/Terminal').feed(lines[i] + "\n");
2699 this.get('/BottomPane').el.set_current_page(1);
2700 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2701 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2702 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2704 var _top = x.get_global_object()._top;
2706 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2708 if (_top.el.popup) {
2709 _top.el.popup(null, null, null, null, 3, null);
2713 viewAdd : function(item, par)
2715 // does something similar to xobject..
2716 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2718 if (item.pack===false || item.pack === 'false') { // no ;
2721 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2722 var ns = imports.gi[item['|xns']];
2723 var ctr = ns[item['xtype']];
2725 for(var k in item) {
2727 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2742 if (k[0] == '|' && typeof(kv) == 'string') {
2744 if (kv.match(new RegExp('function'))) {
2747 print("WASL " + k + '=' + kv);
2749 eval( 'kv = ' + kv);
2750 } catch(e) { continue; }
2753 print(k + '=' + kv);
2755 if (k[0] == '|') { // should be boolean or number..
2758 if (k == 'show_tabs') { // force tab showing for notebooks.
2766 var el = new ctr(ctr_args);
2769 //console.dump(item.pack);
2776 if (typeof(item.pack) == 'string') {
2778 item.pack.split(',').forEach(function(e, i) {
2780 if (e == 'false') { args.push( false); return; }
2781 if (e == 'true') { args.push( true); return; }
2782 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2785 //print(args.join(","));
2787 pack_m = args.shift();
2789 pack_m = item.pack.shift();
2794 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2796 name: "ArgumentError",
2797 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2798 "ADDING : " + item.id + " " + el
2807 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2808 //Seed.print('args: ' + args.length);
2810 par[pack_m].apply(par, args);
2814 item.items = item.items || [];
2815 item.items.forEach(function(ch) {
2816 _this.viewAdd(ch, el);
2821 // add the signal handlers.
2822 // is it a widget!?!!?
2828 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2829 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2830 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2831 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2832 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2842 widgetExposeEvent : function() {
2843 /// print("WIDGET EXPOSE"); // draw highlight??
2846 widgetDragMotionEvent : function() {
2847 print("WIDGET DRAGMOTION");
2850 widgetDragDropEvent : function() {
2851 print("WIDGET DRAGDROP");
2854 widgetPressEvent : function(w,e,u,d) {
2855 if (this.get('view').pressed) {
2858 this.get('view').pressed = true;
2859 print("WIDGET PRESS " + d.xtreepath );
2860 this.get('/LeftTree.view').selectNode( d.xtreepath );
2863 widgetReleaseEvent : function() {
2864 this.get('view').pressed = false;
2870 pack : "pack_start,false,true,0",
2874 pack : "pack_start,false,false,0",
2875 label : "Run The Application",
2877 "button_press_event":function (self, event) {
2878 // call render on left tree - with special option!?!
2882 print("GET PROEJCT");
2883 var pr = this.get('/LeftProjectTree').getActiveProject();
2886 for (var i in pr.paths) {
2890 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
2891 print ("RUN DIR:" + dir);
2893 this.get('/BottomPane').el.set_current_page(1);
2894 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
2895 , false,false,false);
2896 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
2897 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2907 xtype: Gtk.ScrolledWindow,
2910 shadow_type : Gtk.ShadowType.IN,
2912 XObject.prototype.init.call(this);
2913 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2917 xtype: Gtk.EventBox,
2918 pack : "add_with_viewport",
2920 XObject.prototype.init.call(this);
2921 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
2922 red: 0x9F00, green: 0xB800 , blue : 0xA800
2930 XObject.prototype.init.call(this);
2931 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
2932 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
2937 xtype: Gtk.EventBox,
2940 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
2941 XObject.prototype.init.call(this);
2945 this.el, /* widget that will accept a drop */
2946 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2947 null, /* lists of target to support */
2948 0, /* size of list */
2949 Gdk.DragAction.COPY /* what to do with data after dropped */
2952 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2953 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2956 getActiveNode : function(x,y)
2958 // workout what node is here..
2959 return '0'; // top..
2963 "drag_motion":function (self, ctx, x, y, time) {
2965 // A) find out from drag all the places that node could be dropped.
2966 var src = Gtk.drag_get_source_widget(ctx);
2967 if (!src.dropList) {
2968 Gdk.drag_status(ctx, 0, time);
2971 // b) get what we are over.. (from activeNode)
2972 // tree is empty.. - list should be correct..
2973 if (!this.get('/LeftTree.model').currentTree) {
2974 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2978 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2979 var activeNode = this.getActiveNode(x, y);
2982 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
2985 Gdk.drag_status(ctx, 0,time);
2986 this.get('/LeftTree.view').highlight(false);
2990 // if we have a target..
2991 // -> highlight it! (in browser)
2992 // -> highlight it! (in tree)
2994 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2995 this.get('/LeftTree.view').highlight(tg);
2996 this.targetData = tg;
2997 // for tree we should handle this...
3000 "drag_drop":function (self,ctx, x, y, time) {
3001 Seed.print("TARGET: drag-drop");
3002 var is_valid_drop_site = true;
3007 self, /* will receive 'drag-data-received' signal */
3008 ctx, /* represents the current state of the this.gDnD */
3009 this.get('/Window').atoms["STRING"], /* the target type we want */
3010 time /* time stamp */
3014 /* No target offered by source => error */
3017 return is_valid_drop_site;
3020 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3022 Seed.print("GtkView: drag-data-received");
3023 var delete_selection_data = false;
3024 var dnd_success = false;
3025 /* Deal with what we are given from source */
3026 if( sel_data && sel_data.length ) {
3028 if (ctx.action == Gdk.DragAction.ASK) {
3029 /* Ask the user to move or copy, then set the ctx action. */
3032 if (ctx.action == Gdk.DragAction.MOVE) {
3033 delete_selection_data = true;
3035 var source = Gtk.drag_get_source_widget(ctx);
3037 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3038 if (this.targetData) {
3039 Seed.print(this.targetData);
3040 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3049 if (dnd_success == false)
3051 Seed.print ("DnD data transfer failed!\n");
3054 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3057 "button_press_event":function (self, event) {
3058 this.pressed = false;
3074 xtype: Gtk.ScrolledWindow,
3079 xtype: WebKit.WebView,
3083 XObject.prototype.init.call(this);
3084 this.get('/Window.help-view').el.open(
3085 "http://devel.akbkhome.com/seed/");
3096 xtype: Gtk.Notebook,
3099 XObject.prototype.init.call(this);
3100 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3101 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3106 xtype: Gtk.ScrolledWindow,
3111 xtype: GtkSource.View,
3115 XObject.prototype.init.call(this);
3116 var description = Pango.Font.description_from_string("monospace")
3117 description.set_size(8000);
3118 this.el.modify_font(description);
3121 load : function(str) {
3123 // show the help page for the active node..
3124 this.get('/Window.view-help-nb').el.set_current_page(1);
3126 // get the active element being edited.
3127 var xtype = this.get('/LeftTree.model').file.guessName(
3128 this.get('/MidPropTree').activeElement);
3129 // now load the help info in the page..
3130 this.get('/Window.help-view').el.open(
3131 "http://devel.akbkhome.com/seed/" + xtype + ".html");
3134 this.get('/BottomPane').el.set_current_page(0);
3135 this.el.get_buffer().set_text(str, str.length);
3136 var lm = GtkSource.LanguageManager.get_default();
3138 this.el.get_buffer().set_language(lm.get_language('js'));
3139 var buf = this.el.get_buffer();
3140 var cursor = buf.get_mark("insert");
3141 var iter= new Gtk.TextIter;
3142 buf.get_iter_at_mark(iter, cursor);
3144 iter.set_line_offset(4);
3145 buf.move_mark(cursor, iter);
3148 cursor = buf.get_mark("selection_bound");
3149 iter= new Gtk.TextIter;
3150 buf.get_iter_at_mark(iter, cursor);
3152 iter.set_line_offset(4);
3153 buf.move_mark(cursor, iter);
3155 this.el.grab_focus();
3159 xtype: GtkSource.Buffer,
3160 pack : "set_buffer",
3162 "changed":function (self) {
3163 var s = new Gtk.TextIter();
3164 var e = new Gtk.TextIter();
3165 this.el.get_start_iter(s);
3166 this.el.get_end_iter(e);
3167 var str = this.el.get_text(s,e,true);
3169 Seed.check_syntax('var e = ' + str);
3171 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3172 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3174 print("SYNTAX ERROR IN EDITOR");
3179 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3180 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3183 this.get('/LeftPanel.model').changed( str , false);
3192 xtype: Gtk.ScrolledWindow,
3196 xtype: Vte.Terminal,
3199 feed : function(str) {
3200 this.el.feed(str,str.length);
3211 pack : "pack_start,false,false",
3215 this.get('buttonbar').el.show();
3216 this.get('viewbox').el.hide();
3217 print("TRIED TO HIDE");
3220 this.get('buttonbar').el.hide();
3221 this.get('viewbox').el.show();
3222 // this.get('model').expanded();
3234 pack : "pack_start,false,true",
3236 "clicked":function (self) {
3237 this.get('/RightPalete').show();
3244 stock : Gtk.STOCK_GOTO_FIRST,
3245 icon_size : Gtk.IconSize.MENU
3255 XObject.prototype.init.call(this);
3256 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3259 "enter_notify_event":function (self, event) {
3260 this.get('/RightPalete').show();
3274 pack : "pack_start,false,true",
3283 pack : "pack_start,false,true",
3285 "clicked":function (self) {
3286 this.get('/RightPalete').hide();
3293 stock : Gtk.STOCK_GOTO_LAST,
3294 icon_size : Gtk.IconSize.MENU
3301 xtype: Gtk.ScrolledWindow,
3304 XObject.prototype.init.call(this);
3305 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3306 this.el.set_size_request(-1,200);
3308 shadow_type : Gtk.ShadowType.IN,
3311 xtype: Gtk.TreeView,
3314 XObject.prototype.init.call(this);
3315 this.el.set_size_request(150,-1);
3316 // set_reorderable: [1]
3318 var description = new Pango.FontDescription.c_new();
3319 description.set_size(8000);
3320 this.el.modify_font(description);
3322 this.selection = this.el.get_selection();
3323 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3324 // this.selection.signal['changed'].connect(function() {
3325 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3327 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3329 Gtk.drag_source_set (
3330 this.el, /* widget will be drag-able */
3331 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3332 null, /* lists of target to support */
3333 0, /* size of list */
3334 Gdk.DragAction.COPY /* what to do with data after dropped */
3336 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3338 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3339 Gtk.drag_source_add_text_targets(this.el);
3341 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3342 targets = new Gtk.TargetList();
3343 targets.add( LeftTree.atoms["STRING"], 0, 0);
3344 targets.add_text_targets( 1 );
3345 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3347 //if you want to allow text to be output elsewhere..
3348 //Gtk.drag_source_add_text_targets(this.el);
3352 headers_visible : false,
3353 enable_tree_lines : true,
3355 "drag_begin":function (self, ctx) {
3356 // we could fill this in now...
3357 Seed.print('SOURCE: drag-begin');
3361 var iter = new Gtk.TreeIter();
3362 var s = this.selection;
3363 s.get_selected(this.get('/RightPalete.model').el, iter);
3364 var path = this.get('/RightPalete.model').el.get_path(iter);
3366 var pix = this.el.create_row_drag_icon ( path);
3369 Gtk.drag_set_icon_pixmap (ctx,
3376 var value = new GObject.Value('');
3377 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3378 if (!this.get('/RightPalete').provider) {
3381 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3382 this.el.dragData = value.value;
3389 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3390 //Seed.print('Palete: drag-data-get: ' + target_type);
3391 if (this.el.dragData && this.el.dragData.length ) {
3392 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3396 //this.el.dragData = "TEST from source widget";
3400 "drag_end":function (self, drag_context) {
3401 Seed.print('SOURCE: drag-end');
3402 this.el.dragData = false;
3403 this.el.dropList = false;
3404 this.get('/LeftTree.view').highlight(false);
3410 xtype: Gtk.ListStore,
3413 XObject.prototype.init.call(this);
3414 this.el.set_column_types ( 2, [
3415 GObject.TYPE_STRING, // title
3416 GObject.TYPE_STRING // tip
3421 load : function(tr,iter)
3426 //console.log('Project tree load: ' + tr.length);
3427 var citer = new Gtk.TreeIter();
3428 //this.insert(citer,iter,0);
3429 for(var i =0 ; i < tr.length; i++) {
3432 this.el.append(citer);
3434 this.el.insert(citer,iter,-1);
3439 this.el.set_value(citer, 0, '' + r ); // title
3441 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3442 //if (r.cn && r.cn.length) {
3443 // this.load(r.cn, citer);
3449 getValue : function (iter, col) {
3450 var gval = new GObject.Value('');
3451 this.el.get_value(iter, col ,gval);
3458 xtype: Gtk.TreeViewColumn,
3459 pack : "append_column",
3461 XObject.prototype.init.call(this);
3462 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3466 xtype: Gtk.CellRendererText,
3488 XObject.cache['/Window'] = Window;