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 print("caught changed hook on project manager - reloading data");
1209 _this.loadData(pm.projects);
1213 loadData : function(data) {
1214 var ov = this.get('/LeftProjectTree.combo').getValue();
1216 var iter = new Gtk.TreeIter();
1218 data.forEach(function(p) {
1223 el.set_value(iter, 0, p.fn);
1224 el.set_value(iter, 1, p.name);
1228 this.get('/LeftProjectTree.combo').setValue(ov);
1237 xtype: Gtk.ScrolledWindow,
1239 shadow_type : Gtk.ShadowType.IN,
1241 XObject.prototype.init.call(this);
1242 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1246 xtype: Gtk.TreeView,
1247 headers_visible : false,
1248 enable_tree_lines : true,
1251 XObject.prototype.init.call(this);
1252 var description = new Pango.FontDescription.c_new();
1253 description.set_size(8000);
1254 this.el.modify_font(description);
1256 this.selection = this.el.get_selection();
1257 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1261 "cursor_changed":function (self) {
1262 var iter = new Gtk.TreeIter();
1264 if (this.selection.count_selected_rows() < 1) {
1265 //XN.get('Builder.LeftTree.model').
1266 this.get('/LeftTree.model').load( false);
1270 var model = this.get('/LeftProjectTree.model');
1271 //console.log('changed');
1272 var s = this.selection;
1273 s.get_selected(model, iter);
1274 value = new GObject.Value('');
1275 model.el.get_value(iter, 2, value);
1277 console.log(value.value);// id..
1279 var file = this.get('/LeftProjectTree').project.getById(value.value);
1286 var nb = this.get('/LeftTopPanel.expander');
1287 nb.el.expanded = false;
1288 nb.listeners.activate.call(nb);
1289 //_expander.el.set_expanded(false);
1291 var ltm = this.get('/LeftTree.model');
1299 xtype: Gtk.TreeStore,
1303 XObject.prototype.init.call(this);
1304 this.el.set_column_types ( 3, [
1305 GObject.TYPE_STRING, // title
1306 GObject.TYPE_STRING, // tip
1307 GObject.TYPE_STRING // id..
1311 loadProject : function(pr) {
1316 this.get('/LeftProjectTree').project = pr;
1317 this.load(pr.toTree());
1318 this.get('/LeftProjectTree.view').el.expand_all();
1320 load : function(tr,iter) {
1322 console.log('Project tree load: ' + tr.length);
1323 var citer = new Gtk.TreeIter();
1324 //this.insert(citer,iter,0);
1327 tr.forEach(function (r) {
1329 _this.el.append(citer);
1331 _this.el.insert(citer,iter,-1);
1333 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1334 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1335 _this.el.set_value(citer, 2, '' + r.id ); //id
1336 if (r.cn && r.cn.length) {
1337 _this.load(r.cn, citer);
1342 getValue : function(iter, col) {
1343 var gval = new GObject.Value('');
1344 this.el.get_value(iter, col ,gval);
1345 return '' + gval.value;
1349 xtype: Gtk.TreeViewColumn,
1350 pack : "append_column",
1352 XObject.prototype.init.call(this);
1353 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1357 xtype: Gtk.CellRendererText,
1380 pack : "pack_start,false,true,0",
1387 "button_press_event":function (self, event) {
1388 this.get('/MidPropTree.model').showData('props');
1400 stock : Gtk.STOCK_ADD,
1401 icon_size : Gtk.IconSize.MENU
1416 "button_press_event":function (self, event) {
1417 this.get('/MidPropTree.model').showData('events');
1429 stock : Gtk.STOCK_ADD,
1430 icon_size : Gtk.IconSize.MENU
1445 "button_press_event":function (self, ev) {
1446 var p = this.get('/AddPropertyPopup');
1450 p.el.set_screen(Gdk.Screen.get_default());
1452 p.el.popup(null, null, null, null, 3, ev.button.time);
1464 stock : Gtk.STOCK_ADD,
1465 icon_size : Gtk.IconSize.MENU
1477 id : "AddPropertyPopup",
1480 xtype: Gtk.MenuItem,
1482 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1485 "activate":function (self) {
1487 this.get('/LeftPanel.model').add( {
1498 xtype: Gtk.MenuItem,
1500 tooltip_markup : "Add what type of packing is to be used",
1503 "activate":function (self) {
1505 this.get('/LeftPanel.model').add( {
1515 xtype: Gtk.MenuItem,
1517 tooltip_markup : "Override the init method",
1520 "activate":function (self) {
1522 this.get('/LeftPanel.model').add( {
1525 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1532 xtype: Gtk.SeparatorMenuItem,
1536 xtype: Gtk.MenuItem,
1538 tooltip_markup : "Add a user defined string property",
1541 "activate":function (self) {
1543 this.get('/LeftPanel.model').add( {
1553 xtype: Gtk.MenuItem,
1555 tooltip_markup : "Add a user defined number property",
1558 "activate":function (self) {
1560 this.get('/LeftPanel.model').add( {
1570 xtype: Gtk.MenuItem,
1572 tooltip_markup : "Add a user defined boolean property",
1575 "activate":function (self) {
1577 this.get('/LeftPanel.model').add( {
1587 xtype: Gtk.SeparatorMenuItem,
1591 xtype: Gtk.MenuItem,
1593 tooltip_markup : "Add a user function boolean property",
1596 "activate":function (self) {
1598 this.get('/LeftPanel.model').add( {
1601 val : "function() {\n \n}\n",
1614 xtype: Gtk.ScrolledWindow,
1617 shadow_type : Gtk.ShadowType.IN,
1620 XObject.prototype.init.call(this);
1621 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1625 xtype: Gtk.TreeView,
1628 headers_visible : false,
1629 enable_tree_lines : true,
1631 XObject.prototype.init.call(this);
1633 this.selection = this.el.get_selection();
1634 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1637 var description = new Pango.FontDescription.c_new();
1638 description.set_size(8000);
1639 this.el.modify_font(description);
1642 "button_press_event":function (self, ev) {
1646 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1647 return false; //not on a element.
1651 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1653 if (res.column.title != 'value') {
1654 return false; // ignore..
1656 if ( this.get('/LeftPanel').editing) {
1659 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1660 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1661 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1665 var provider = this.get('/LeftTree').getPaleteProvider();
1667 var opts = provider.findOptions(type);
1669 if (opts === false) {
1670 this.get('/LeftPanel').editableColumn.setOptions([]);
1671 renderer.has_entry = true;
1673 LeftPanel.editableColumn.setOptions(opts);
1674 renderer.has_entry = false;
1678 //Seed.print("click" + ev.type);
1679 //console.dump(res);
1685 if (res.column.title == 'value') {
1688 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1689 var p = this.get('/LeftPanelPopup');
1694 p.el.set_screen(Gdk.Screen.get_default());
1696 p.el.popup(null, null, null, null, 3, ev.button.time);
1697 //Seed.print("click:" + res.column.title);
1705 xtype: Gtk.TreeStore,
1709 XObject.prototype.init.call(this);
1710 this.el.set_column_types ( 5, [
1711 GObject.TYPE_STRING, // 0 real key
1712 GObject.TYPE_STRING, // 1 real value
1713 GObject.TYPE_STRING, // 2 visable key
1714 GObject.TYPE_STRING, // 3 visable value
1715 GObject.TYPE_STRING, // 4 need to store type of!!!
1719 toShort : function(str) {
1720 var a = typeof(str) == 'string' ? str.split("\n") : [];
1721 return a.length > 1 ? a[0] + '....' : '' + str;
1723 load : function(ar) {
1726 this.get('/RightEditor').el.hide();
1733 var provider = this.get('/LeftTree').getPaleteProvider();
1736 var iter = new Gtk.TreeIter();
1738 if (typeof(ar[i]) == 'object') {
1742 var type = provider.findType(ar, i, ar[i]);
1744 this.el.append(iter);
1745 var p = this.el.get_path(iter).to_string();
1747 this.el.set_value(iter, 0, i);
1748 this.el.set_value(iter, 1, '' + ar[i]);
1749 this.el.set_value(iter, 2, i);
1750 this.el.set_value(iter, 3, this.toShort(ar[i]));
1751 this.el.set_value(iter, 4, type);
1753 ar.listeners = ar.listeners || {};
1754 for (var i in ar.listeners ) {
1755 this.el.append(iter);
1756 var p = this.el.get_path(iter).to_string();
1759 this.el.set_value(iter, 0, '!'+ i );
1760 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1761 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1763 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1764 this.el.set_value(iter, 4, 'function');
1768 add : function(info) {
1769 // info includes key, val, skel, etype..
1771 type = info.type.toLowerCase();
1772 var data = this.toJS();
1774 if (info.etype == 'events') {
1775 data.listeners = data.listeners || { };
1776 if (typeof(data.listeners[info.key]) != 'undefined') {
1777 return; //already set!
1780 if (typeof(data[info.key]) != 'undefined') {
1785 if (typeof(info.val) == 'undefined') {
1788 if (info.type == 'boolean') {
1791 if (type == 'number') {
1799 if (info.etype == 'events') {
1801 data.listeners[info.key] = info.val;
1804 data[info.key] = info.val;
1808 var map = this.load(data);
1810 // flag it as changed to the interface..
1812 this.get('/LeftTree.model').changed(data, true);
1815 this.startEditing(map[k]);
1818 LeftPanel.get('view').el.row_activated(
1819 new Gtk.TreePath.from_string(map[k]),
1820 LeftPanel.editableColumn.el
1824 startEditing : function(path,col) {
1826 * start editing path (or selected if not set..)
1827 * @param {String|false} path (optional) treepath to edit - selected tree gets
1828 * edited by default.
1829 * @param {Number} 0 or 1 (optional)- column to edit.
1832 if (typeof(path) == 'string') {
1833 tp = new Gtk.TreePath.from_string(path);
1835 var iter = new Gtk.TreeIter();
1836 var s = this.get('/LeftPanel.view').selection;
1837 s.get_selected(this.el, iter);
1838 tp = this.el.get_path(iter);
1839 path = tp.to_string();
1843 // which colum is to be edited..
1845 if (typeof(col) == 'undefined') {
1846 var k = this.getValue(path, 0);
1847 colObj = (!k.length || k == '|') ?
1848 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1850 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1853 // make sure the pulldown is set correctly..
1854 // not really needed for second col...
1856 var provider = this.get('/LeftTree').getPaleteProvider();
1858 var type = this.get('/LeftPanel.model').getType(path);
1859 var opts = provider.findOptions(type);
1860 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1862 if (opts === false) {
1863 this.get('/LeftPanel').editableColumn.setOptions([]);
1864 renderer.has_entry = true; /// probably does not have any effect.
1866 this.get('/LeftPanel').editableColumn.setOptions(opts);
1867 renderer.has_entry = false;
1871 // iter now has row...
1872 GLib.timeout_add(0, 100, function() {
1874 colObj.items[0].el.editable = true; // esp. need for col 0..
1875 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1884 deleteSelected : function() {
1885 var data = this.toJS();
1886 var iter = new Gtk.TreeIter();
1887 var s = this.get('/LeftPanel.view').selection;
1888 s.get_selected(this.el, iter);
1891 var gval = new GObject.Value('');
1892 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1894 var val = gval.value;
1895 if (val[0] == '!') {
1897 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1900 delete data.listeners[ val.substring(1)];
1901 if (!XObject.keys(data.listeners).length) {
1902 delete data.listeners;
1906 if (typeof(data[val]) == 'undefined') {
1914 this.get('/LeftTree.model').changed(data, true);
1918 changed : function(str, doRefresh) {
1919 if (!this.activePath) {
1922 var iter = new Gtk.TreeIter();
1923 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1925 this.el.set_value(iter, 1, '' +str);
1926 this.el.set_value(iter, 3, '' + this.toShort(str));
1927 // update the tree...
1929 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
1932 var iter = new Gtk.TreeIter();
1933 this.get('/LeftPanel.model').el.get_iter_first(iter);
1938 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
1941 ar.listeners = ar.listeners || {};
1942 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
1945 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
1948 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
1954 //print(JSON.stringify(ar));
1958 getType : function(treepath) {
1959 return this.getValue(treepath, 4);
1961 getValue : function(treepath_str, col) {
1962 var iter = new Gtk.TreeIter();
1963 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
1965 var gval = new GObject.Value('');
1966 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
1967 var val = '' + gval.value;
1971 var type = this.getType(this.el.get_path(iter).to_string());
1972 //print("TYPE: " +type + " - val:" + val);
1973 switch(type.toLowerCase()) {
1977 return parseFloat(val); // Nan ?? invalid!!?
1979 return val == 'true' ? true : false;
1985 editSelected : function(e) {
1986 print("EDIT SELECTED?");
1987 var iter = new Gtk.TreeIter();
1988 var s = this.get('/LeftPanel.view').selection;
1989 s.get_selected(this.get('/LeftPanel.model').el, iter);
1990 var m = this.get('/LeftPanel.model')
1992 var gval = new GObject.Value('');
1993 this.el.get_value(iter, 0 ,gval);
1994 var val = '' + gval.value;
1996 gval = new GObject.Value('');
1997 this.el.get_value(iter, 1 ,gval);
1998 var rval = gval.value;
1999 var activePath = this.el.get_path(iter).to_string();
2000 this.activePath = activePath ;
2001 // was activeIter...
2004 var showEditor = false;
2006 if (val[0] == '!') {
2009 if (val[0] == '|') {
2010 if (rval.match(/function/g) || rval.match(/\n/g)) {
2017 this.activePath = false;
2018 GLib.timeout_add(0, 1, function() {
2019 // Gdk.threads_enter();
2020 _this.get('/RightEditor').el.show();
2021 _this.get('/RightEditor.view').load( rval );
2025 _this.activePath = activePath ;
2027 // Gdk.threads_leave();
2033 this.get('/RightEditor').el.hide();
2035 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2041 xtype: Gtk.TreeViewColumn,
2042 pack : "append_column",
2044 XObject.prototype.init.call(this);
2046 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2047 this.get('/LeftPanel').propertyColumn = this;
2052 xtype: Gtk.CellRendererText,
2053 pack : "pack_start",
2055 "editing_started":function (self, editable, path) {
2057 this.get('/LeftPanel.model').activePath = path;
2060 "edited":function (self, object, p0) {
2061 var model = this.get('/LeftPanel.model');
2062 var path = model.activePath;
2063 var iter = new Gtk.TreeIter();
2064 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2065 model.el.set_value(iter, 0, p0);
2066 model.el.set_value(iter, 2, p0);
2068 model.activePath = false;
2070 this.get('/LeftTree.model').changed(model.toJS(), true);
2071 this.el.editable = false;
2078 xtype: Gtk.TreeViewColumn,
2079 pack : "append_column",
2081 XObject.prototype.init.call(this);
2082 this.el.add_attribute(this.items[0].el , 'text', 3 );
2083 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2084 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2085 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2087 this.get('/LeftPanel').editableColumn= this;
2089 setOptions : function(ar) {
2090 var m = this.items[0].el.model;
2092 var iter = new Gtk.TreeIter();
2093 ar.forEach(function(i) {
2096 m.set_value(iter, 0, i);
2102 xtype: Gtk.CellRendererCombo,
2103 pack : "pack_start",
2108 XObject.prototype.init.call(this);
2109 this.el.model = new Gtk.ListStore();
2110 this.el.model.set_column_types ( 1, [
2111 GObject.TYPE_STRING // 0 real key
2115 "edited":function (self, object, p0) {
2116 this.get('/LeftPanel').editing = false;
2117 print("EDITED? p:" + p0 + " t:" + p0);
2118 this.get('/LeftPanel.model').changed(p0, true);
2119 this.get('/LeftPanel.model').activePath = false;
2121 "editing_started":function (self, editable, path) {
2122 this.get('/LeftPanel').editing = true;
2123 // console.log('editing started');
2124 // r.has_entry = false;
2125 this.get('/LeftPanel.model').editSelected(editable);
2136 id : "LeftPanelPopup",
2139 xtype: Gtk.MenuItem,
2143 "activate":function (self) {
2144 this.get('/LeftPanel.model').deleteSelected();
2149 xtype: Gtk.MenuItem,
2153 "activate":function (self) {
2154 this.get('/LeftPanel.model').startEditing(false, 0);
2167 xtype: Gtk.ScrolledWindow,
2168 pack : "pack_end,false,true,0",
2170 shadow_type : Gtk.ShadowType.IN,
2172 XObject.prototype.init.call(this);
2173 XObject.prototype.init.call(this);
2174 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2175 this.el.set_size_request ( 150, -1 );
2178 activeElement : false,
2179 hideWin : function() {
2186 if (this.get('/Window.left').el.position < 160) {
2189 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2196 xtype: Gtk.TreeView,
2197 enable_tree_lines : true,
2198 headers_visible : false,
2201 XObject.prototype.init.call(this);
2203 var description = new Pango.FontDescription.c_new();
2204 description.set_size(8000);
2205 this.el.modify_font(description);
2207 //this.selection = this.el.get_selection();
2208 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2217 "cursor_changed":function (self) {
2218 var iter = new Gtk.TreeIter();
2220 //console.log('changed');
2221 var m = this.get('model');
2222 if (!this.selection){
2223 this.selection = this.el.get_selection();
2226 var s = this.selection;
2227 if (!s.get_selected(m.el, iter)) {
2230 var tp = m.el.get_path(iter).to_string();
2235 var key = m.getValue(tp, 0);
2237 var type = m.getValue(tp, 1);
2238 var skel = m.getValue(tp, 3);
2239 var etype = m.getValue(tp, 5);
2242 this.get('/MidPropTree').hideWin();
2244 if (type == 'function') {
2246 if (etype != 'events') {
2250 this.get('/LeftPanel.model').add({
2259 if (type.indexOf('.') > -1 ||
2260 type == 'boolean') {
2264 this.get('/LeftPanel.model').add( {
2274 xtype: Gtk.ListStore,
2277 XObject.prototype.init.call(this);
2278 this.el.set_column_types ( 6, [
2279 GObject.TYPE_STRING, // real key
2280 GObject.TYPE_STRING, // real type
2281 GObject.TYPE_STRING, // docs ?
2282 GObject.TYPE_STRING, // visable desc
2283 GObject.TYPE_STRING, // function desc
2284 GObject.TYPE_STRING // element type (event|prop)
2288 getValue : function(treepath, col)
2290 var tp = new Gtk.TreePath.from_string (treepath);
2291 var iter = new Gtk.TreeIter();
2292 this.el.get_iter (iter, tp);
2293 var value = new GObject.Value('');
2294 this.el.get_value(iter, col, value);
2298 showData : function(type) {
2300 if (!this.get('/MidPropTree').activeElement || !type) {
2301 return; // no active element
2304 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2305 var palete = this.get('/LeftTree').getPaleteProvider();
2309 Seed.print('Showing right?');
2310 if (!this.get('/MidPropTree').shown) {
2312 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2313 this.get('/MidPropTree').el.show();
2314 this.get('/MidPropTree').shown = true;
2317 var elementList = palete.getPropertiesFor(fullpath, type);
2318 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2319 // console.dump(elementList);
2322 var iter = new Gtk.TreeIter();
2323 for(var i =0 ; i < elementList.length; i++) {
2324 var p=elementList[i];
2325 this.el.append(iter);
2326 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2327 //GObject.TYPE_STRING, // real key
2328 // GObject.TYPE_STRING, // real type
2329 // GObject.TYPE_STRING, // docs ?
2330 // GObject.TYPE_STRING // func def?
2333 this.el.set_value(iter, 0, p.name);
2334 this.el.set_value(iter, 1, p.type);
2335 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2336 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2337 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2338 this.el.set_value(iter, 5, type);
2346 xtype: Gtk.TreeViewColumn,
2348 this.el = new Gtk.TreeViewColumn();
2349 this.parent.el.append_column(this.el);
2351 XObject.prototype.init.call(this);
2352 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2357 xtype: Gtk.CellRendererText,
2358 pack : "pack_start,true"
2382 xtype: Gtk.Notebook,
2383 pack : "pack_start,true,true",
2384 id : "view-help-nb",
2386 XObject.prototype.init.call(this);
2387 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" }));
2388 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" }));
2392 xtype: Gtk.Notebook,
2394 id : "view-notebook",
2397 XObject.prototype.init.call(this);
2398 this.el.set_current_page(0);
2400 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2401 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2408 id : "RightBrowser",
2412 pack : "pack_start,false,true,0",
2416 pack : "pack_start,false,false,0",
2417 label : "Dump HTML to console",
2419 "activate":function (self) {
2420 this.get('/RightBrowser.view').el.execute_script(
2421 "console.log(document.body.innerHTML);");
2422 this.get('/RightBrowser.view').el.execute_script(
2423 "console.log(Builder.dump(Builder));");
2430 xtype: Gtk.ScrolledWindow,
2432 shadow_type : Gtk.ShadowType.IN,
2434 XObject.prototype.init.call(this);
2435 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2439 xtype: WebKit.WebView,
2443 XObject.prototype.init.call(this);
2444 // this may not work!?
2445 this.el.open('file:///' + __script_path__ + '/../builder.html');
2449 this.el, /* widget that will accept a drop */
2450 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2451 null, /* lists of target to support */
2452 0, /* size of list */
2453 Gdk.DragAction.COPY /* what to do with data after dropped */
2456 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2457 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2459 renderJS : function(data) {
2460 this.renderedData = data;
2461 var str = JSON.stringify(data) ;
2464 console.log('not loaded yet');
2466 Seed.print("RENDER:" + str);
2467 imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2468 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2471 "load_finished":function (self, object) {
2472 if (this.ready) { // dont do it twice!
2477 this.renderJS(this.get('/LeftTree.model').toJS()[0]);
2479 "script_alert":function (self, object, p0) {
2482 return true; // do not display anything...
2484 "console_message":function (self, object, p0, p1) {
2485 console.log(object);
2486 if (!object.match(/^\{/)) {
2487 return false; // do not handle!!! -> later maybe in console..
2489 console.log(object);
2490 var val = JSON.parse(object);
2492 if (typeof(val['hover-node']) != 'undefined') {
2493 this.activeNode = val['hover-node'];
2494 console.log('active node: ' + this.activeNode);
2499 if (typeof(val['id']) != 'undefined') {
2500 // this.activeNode = val['id'];
2501 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2505 this.get('/LeftTree.view').selectNode(tg[0]);
2509 if (ret && typeof(val['set']) != 'undefined') {
2510 this.get('/LeftPanel.model').add({
2514 //console.log('active node: ' + this.activeNode);
2517 //Seed.print('a:'+a);
2518 //Seed.print('b:'+b);
2519 //Seed.print('c:'+c);
2522 "drag_motion":function (w, ctx, x, y, time, ud) {
2523 // console.log('DRAG MOTION');
2525 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2526 this.targetData = [];
2527 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2529 // A) find out from drag all the places that node could be dropped.
2530 var src = Gtk.drag_get_source_widget(ctx);
2531 if (!src.dropList) {
2532 Gdk.drag_status(ctx, 0, time);
2535 // b) get what we are over.. (from activeNode)
2536 // tree is empty.. - list should be correct..
2537 if (!this.get('/LeftTree.model').currentTree) {
2538 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2542 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2544 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2547 Gdk.drag_status(ctx, 0,time);
2548 this.get('/LeftTree.view').highlight(false);
2552 // if we have a target..
2553 // -> highlight it! (in browser)
2554 // -> highlight it! (in tree)
2556 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2557 this.get('/LeftTree.view').highlight(tg);
2558 this.targetData = tg;
2559 // for tree we should handle this...
2562 "drag_drop":function (w, ctx, x, y,time, ud) {
2563 print("TARGET: drag-drop");
2564 var is_valid_drop_site = true;
2569 w, /* will receive 'drag-data-received' signal */
2570 ctx, /* represents the current state of the DnD */
2571 this.get('/Window').atoms["STRING"], /* the target type we want */
2572 time /* time stamp */
2576 /* No target offered by source => error */
2579 return is_valid_drop_site;
2581 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2583 print("Browser: drag-data-received");
2584 var delete_selection_data = false;
2585 vardnd_success = false;
2586 /* Deal with what we are given from source */
2587 if( sel_data && sel_data.length ) {
2589 if (ctx.action == Gdk.DragAction.ASK) {
2590 /* Ask the user to move or copy, then set the ctx action. */
2593 if (ctx.action == Gdk.DragAction.MOVE) {
2594 delete_selection_data = true;
2596 var source = Gtk.drag_get_source_widget(ctx);
2598 print("Browser: source.DRAGDATA? " + source.dragData);
2599 if (this.targetData) {
2600 print(this.targetData);
2601 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2610 if (dnd_success == false)
2612 Seed.print ("DnD data transfer failed!\n");
2615 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2627 id : "RightGtkView",
2628 renderJS : function(data, withDebug)
2633 this.withDebug = false;
2635 if (this.renderedEl) {
2636 this.get('view').el.remove(this.renderedEl);
2637 this.renderedEl.destroy();
2638 this.renderedEl = false;
2641 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2642 // in theory tree is actually window..
2644 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2649 this.get('view').el.set_size_request(
2650 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2653 this.renderedEl.set_size_request(
2654 tree.default_width || 600,
2655 tree.default_height || 400
2657 this.get('view').el.show_all();
2662 showInWindow : function() {
2663 print("GET PROEJCT");
2664 var pr = this.get('/LeftProjectTree').getActiveProject();
2666 console.log(pr.paths);
2669 var src= this.buildJS(
2670 this.get('/LeftTree.model').toJS()[0],
2675 //var x = new imports.sandbox.Context();
2679 Seed.check_syntax('var e = ' + src);
2682 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2683 this.get('/Terminal').feed(console._dump(e)+"\n");
2685 var lines = src.split("\n");
2686 var start = Math.max(0, e.line - 10);
2687 var end = Math.min(lines.length, e.line + 10);
2688 for (var i =start ; i < end; i++) {
2690 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2693 this.get('/Terminal').feed(lines[i] + "\n");
2700 this.get('/BottomPane').el.set_current_page(1);
2701 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2702 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2703 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2705 var _top = x.get_global_object()._top;
2707 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2709 if (_top.el.popup) {
2710 _top.el.popup(null, null, null, null, 3, null);
2714 viewAdd : function(item, par)
2716 // does something similar to xobject..
2717 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2719 if (item.pack===false || item.pack === 'false') { // no ;
2722 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2723 var ns = imports.gi[item['|xns']];
2724 var ctr = ns[item['xtype']];
2726 for(var k in item) {
2728 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2743 if (k[0] == '|' && typeof(kv) == 'string') {
2745 if (kv.match(new RegExp('function'))) {
2748 print("WASL " + k + '=' + kv);
2750 eval( 'kv = ' + kv);
2751 } catch(e) { continue; }
2754 print(k + '=' + kv);
2756 if (k[0] == '|') { // should be boolean or number..
2759 if (k == 'show_tabs') { // force tab showing for notebooks.
2767 var el = new ctr(ctr_args);
2770 //console.dump(item.pack);
2777 if (typeof(item.pack) == 'string') {
2779 item.pack.split(',').forEach(function(e, i) {
2781 if (e == 'false') { args.push( false); return; }
2782 if (e == 'true') { args.push( true); return; }
2783 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2786 //print(args.join(","));
2788 pack_m = args.shift();
2790 pack_m = item.pack.shift();
2795 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2797 name: "ArgumentError",
2798 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2799 "ADDING : " + item.id + " " + el
2808 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2809 //Seed.print('args: ' + args.length);
2811 par[pack_m].apply(par, args);
2815 item.items = item.items || [];
2816 item.items.forEach(function(ch) {
2817 _this.viewAdd(ch, el);
2822 // add the signal handlers.
2823 // is it a widget!?!!?
2829 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2830 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2831 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2832 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2833 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2843 widgetExposeEvent : function() {
2844 /// print("WIDGET EXPOSE"); // draw highlight??
2847 widgetDragMotionEvent : function() {
2848 print("WIDGET DRAGMOTION");
2851 widgetDragDropEvent : function() {
2852 print("WIDGET DRAGDROP");
2855 widgetPressEvent : function(w,e,u,d) {
2856 if (this.get('view').pressed) {
2859 this.get('view').pressed = true;
2860 print("WIDGET PRESS " + d.xtreepath );
2861 this.get('/LeftTree.view').selectNode( d.xtreepath );
2864 widgetReleaseEvent : function() {
2865 this.get('view').pressed = false;
2871 pack : "pack_start,false,true,0",
2875 pack : "pack_start,false,false,0",
2876 label : "Run The Application",
2878 "button_press_event":function (self, event) {
2879 // call render on left tree - with special option!?!
2883 print("GET PROEJCT");
2884 var pr = this.get('/LeftProjectTree').getActiveProject();
2887 for (var i in pr.paths) {
2891 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
2892 print ("RUN DIR:" + dir);
2894 this.get('/BottomPane').el.set_current_page(1);
2895 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
2896 , false,false,false);
2897 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
2898 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2908 xtype: Gtk.ScrolledWindow,
2911 shadow_type : Gtk.ShadowType.IN,
2913 XObject.prototype.init.call(this);
2914 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2918 xtype: Gtk.EventBox,
2919 pack : "add_with_viewport",
2921 XObject.prototype.init.call(this);
2922 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
2923 red: 0x9F00, green: 0xB800 , blue : 0xA800
2931 XObject.prototype.init.call(this);
2932 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
2933 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
2938 xtype: Gtk.EventBox,
2941 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
2942 XObject.prototype.init.call(this);
2946 this.el, /* widget that will accept a drop */
2947 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2948 null, /* lists of target to support */
2949 0, /* size of list */
2950 Gdk.DragAction.COPY /* what to do with data after dropped */
2953 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2954 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2957 getActiveNode : function(x,y)
2959 // workout what node is here..
2960 return '0'; // top..
2964 "drag_motion":function (self, ctx, x, y, time) {
2966 // A) find out from drag all the places that node could be dropped.
2967 var src = Gtk.drag_get_source_widget(ctx);
2968 if (!src.dropList) {
2969 Gdk.drag_status(ctx, 0, time);
2972 // b) get what we are over.. (from activeNode)
2973 // tree is empty.. - list should be correct..
2974 if (!this.get('/LeftTree.model').currentTree) {
2975 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2979 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2980 var activeNode = this.getActiveNode(x, y);
2983 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
2986 Gdk.drag_status(ctx, 0,time);
2987 this.get('/LeftTree.view').highlight(false);
2991 // if we have a target..
2992 // -> highlight it! (in browser)
2993 // -> highlight it! (in tree)
2995 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2996 this.get('/LeftTree.view').highlight(tg);
2997 this.targetData = tg;
2998 // for tree we should handle this...
3001 "drag_drop":function (self,ctx, x, y, time) {
3002 Seed.print("TARGET: drag-drop");
3003 var is_valid_drop_site = true;
3008 self, /* will receive 'drag-data-received' signal */
3009 ctx, /* represents the current state of the this.gDnD */
3010 this.get('/Window').atoms["STRING"], /* the target type we want */
3011 time /* time stamp */
3015 /* No target offered by source => error */
3018 return is_valid_drop_site;
3021 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3023 Seed.print("GtkView: drag-data-received");
3024 var delete_selection_data = false;
3025 var dnd_success = false;
3026 /* Deal with what we are given from source */
3027 if( sel_data && sel_data.length ) {
3029 if (ctx.action == Gdk.DragAction.ASK) {
3030 /* Ask the user to move or copy, then set the ctx action. */
3033 if (ctx.action == Gdk.DragAction.MOVE) {
3034 delete_selection_data = true;
3036 var source = Gtk.drag_get_source_widget(ctx);
3038 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3039 if (this.targetData) {
3040 Seed.print(this.targetData);
3041 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3050 if (dnd_success == false)
3052 Seed.print ("DnD data transfer failed!\n");
3055 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3058 "button_press_event":function (self, event) {
3059 this.pressed = false;
3075 xtype: Gtk.ScrolledWindow,
3080 xtype: WebKit.WebView,
3084 XObject.prototype.init.call(this);
3085 this.get('/Window.help-view').el.open(
3086 "http://devel.akbkhome.com/seed/");
3097 xtype: Gtk.Notebook,
3100 XObject.prototype.init.call(this);
3101 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3102 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3107 xtype: Gtk.ScrolledWindow,
3112 xtype: GtkSource.View,
3116 XObject.prototype.init.call(this);
3117 var description = Pango.Font.description_from_string("monospace")
3118 description.set_size(8000);
3119 this.el.modify_font(description);
3122 load : function(str) {
3124 // show the help page for the active node..
3125 this.get('/Window.view-help-nb').el.set_current_page(1);
3127 // get the active element being edited.
3128 var xtype = this.get('/LeftTree.model').file.guessName(
3129 this.get('/MidPropTree').activeElement);
3130 // now load the help info in the page..
3131 this.get('/Window.help-view').el.open(
3132 "http://devel.akbkhome.com/seed/" + xtype + ".html");
3135 this.get('/BottomPane').el.set_current_page(0);
3136 this.el.get_buffer().set_text(str, str.length);
3137 var lm = GtkSource.LanguageManager.get_default();
3139 this.el.get_buffer().set_language(lm.get_language('js'));
3140 var buf = this.el.get_buffer();
3141 var cursor = buf.get_mark("insert");
3142 var iter= new Gtk.TextIter;
3143 buf.get_iter_at_mark(iter, cursor);
3145 iter.set_line_offset(4);
3146 buf.move_mark(cursor, iter);
3149 cursor = buf.get_mark("selection_bound");
3150 iter= new Gtk.TextIter;
3151 buf.get_iter_at_mark(iter, cursor);
3153 iter.set_line_offset(4);
3154 buf.move_mark(cursor, iter);
3156 this.el.grab_focus();
3160 xtype: GtkSource.Buffer,
3161 pack : "set_buffer",
3163 "changed":function (self) {
3164 var s = new Gtk.TextIter();
3165 var e = new Gtk.TextIter();
3166 this.el.get_start_iter(s);
3167 this.el.get_end_iter(e);
3168 var str = this.el.get_text(s,e,true);
3170 Seed.check_syntax('var e = ' + str);
3172 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3173 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3175 print("SYNTAX ERROR IN EDITOR");
3180 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3181 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3184 this.get('/LeftPanel.model').changed( str , false);
3193 xtype: Gtk.ScrolledWindow,
3197 xtype: Vte.Terminal,
3200 feed : function(str) {
3201 this.el.feed(str,str.length);
3212 pack : "pack_start,false,false",
3216 this.get('buttonbar').el.show();
3217 this.get('viewbox').el.hide();
3218 print("TRIED TO HIDE");
3221 this.get('buttonbar').el.hide();
3222 this.get('viewbox').el.show();
3223 // this.get('model').expanded();
3235 pack : "pack_start,false,true",
3237 "clicked":function (self) {
3238 this.get('/RightPalete').show();
3245 stock : Gtk.STOCK_GOTO_FIRST,
3246 icon_size : Gtk.IconSize.MENU
3256 XObject.prototype.init.call(this);
3257 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3260 "enter_notify_event":function (self, event) {
3261 this.get('/RightPalete').show();
3275 pack : "pack_start,false,true",
3284 pack : "pack_start,false,true",
3286 "clicked":function (self) {
3287 this.get('/RightPalete').hide();
3294 stock : Gtk.STOCK_GOTO_LAST,
3295 icon_size : Gtk.IconSize.MENU
3302 xtype: Gtk.ScrolledWindow,
3305 XObject.prototype.init.call(this);
3306 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3307 this.el.set_size_request(-1,200);
3309 shadow_type : Gtk.ShadowType.IN,
3312 xtype: Gtk.TreeView,
3315 XObject.prototype.init.call(this);
3316 this.el.set_size_request(150,-1);
3317 // set_reorderable: [1]
3319 var description = new Pango.FontDescription.c_new();
3320 description.set_size(8000);
3321 this.el.modify_font(description);
3323 this.selection = this.el.get_selection();
3324 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3325 // this.selection.signal['changed'].connect(function() {
3326 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3328 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3330 Gtk.drag_source_set (
3331 this.el, /* widget will be drag-able */
3332 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3333 null, /* lists of target to support */
3334 0, /* size of list */
3335 Gdk.DragAction.COPY /* what to do with data after dropped */
3337 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3339 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3340 Gtk.drag_source_add_text_targets(this.el);
3342 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3343 targets = new Gtk.TargetList();
3344 targets.add( LeftTree.atoms["STRING"], 0, 0);
3345 targets.add_text_targets( 1 );
3346 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3348 //if you want to allow text to be output elsewhere..
3349 //Gtk.drag_source_add_text_targets(this.el);
3353 headers_visible : false,
3354 enable_tree_lines : true,
3356 "drag_begin":function (self, ctx) {
3357 // we could fill this in now...
3358 Seed.print('SOURCE: drag-begin');
3362 var iter = new Gtk.TreeIter();
3363 var s = this.selection;
3364 s.get_selected(this.get('/RightPalete.model').el, iter);
3365 var path = this.get('/RightPalete.model').el.get_path(iter);
3367 var pix = this.el.create_row_drag_icon ( path);
3370 Gtk.drag_set_icon_pixmap (ctx,
3377 var value = new GObject.Value('');
3378 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3379 if (!this.get('/RightPalete').provider) {
3382 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3383 this.el.dragData = value.value;
3390 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3391 //Seed.print('Palete: drag-data-get: ' + target_type);
3392 if (this.el.dragData && this.el.dragData.length ) {
3393 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3397 //this.el.dragData = "TEST from source widget";
3401 "drag_end":function (self, drag_context) {
3402 Seed.print('SOURCE: drag-end');
3403 this.el.dragData = false;
3404 this.el.dropList = false;
3405 this.get('/LeftTree.view').highlight(false);
3411 xtype: Gtk.ListStore,
3414 XObject.prototype.init.call(this);
3415 this.el.set_column_types ( 2, [
3416 GObject.TYPE_STRING, // title
3417 GObject.TYPE_STRING // tip
3422 load : function(tr,iter)
3427 //console.log('Project tree load: ' + tr.length);
3428 var citer = new Gtk.TreeIter();
3429 //this.insert(citer,iter,0);
3430 for(var i =0 ; i < tr.length; i++) {
3433 this.el.append(citer);
3435 this.el.insert(citer,iter,-1);
3440 this.el.set_value(citer, 0, '' + r ); // title
3442 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3443 //if (r.cn && r.cn.length) {
3444 // this.load(r.cn, citer);
3450 getValue : function (iter, col) {
3451 var gval = new GObject.Value('');
3452 this.el.get_value(iter, col ,gval);
3459 xtype: Gtk.TreeViewColumn,
3460 pack : "append_column",
3462 XObject.prototype.init.call(this);
3463 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3467 xtype: Gtk.CellRendererText,
3489 XObject.cache['/Window'] = Window;