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();
50 this.get('/BottomPane').el.hide();
61 pack : "pack_start,false,false",
75 label : "New _Project",
77 "activate":function (self) {
79 this.get('/EditProject').show({
80 success : function(pr) {
81 _this.get('/LeftProjectTree').get('combo').setValue(pr.fn);
92 "activate":function (self) {
93 var fn = this.get('/LeftProjectTree.combo').getValue();
95 this.get('/LeftProjectTree').showNoProjectSelected();
98 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
99 this.get('/DialogNewComponent').show({
100 project : pm.getByFn(fn)
106 xtype: Gtk.SeparatorMenuItem,
111 use_underline : true,
113 label : "D_elete Project",
115 "activate":function (self) {
117 var fn = this.get('/LeftProjectTree').get('combo').getValue();
119 this.get('/StandardErrorDialog').show("Select a project")
122 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
123 var pr = pm.getByFn(fn);
126 this.get('/DialogConfirm').show("Are you sure you want to delete project '" + pr.name + "'", function() {
127 pm.deleteProject(fn);
135 xtype: Gtk.SeparatorMenuItem,
142 use_underline : true,
144 "activate":function (self) {
156 use_underline : true,
164 pack : "set_submenu",
170 use_underline : true,
172 "activate":function (self) {
173 this.get('/About').el.run();
202 label : "Select Project",
204 pack : "pack_start,false,true",
206 XObject.prototype.init.call(this);
207 this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
210 "activate":function (self) {
211 var nb = this.get('/LeftTopPanel.notebook');
212 if (this.el.expanded) {
215 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
218 var model = this.get('/LeftProjectTree.combomodel');
219 // print ("loading Projects?")
220 //console.dump(pm.projects);
221 model.loadData(pm.projects);
224 nb.el.set_current_page(1);
225 //pm.on('changed', function() {
226 //console.log("CAUGHT project manager change");
227 // _combo.model.loadData(pm.projects);
231 nb.el.set_current_page(0);
233 "enter_notify_event":function (self, event) {
234 this.el.expanded = !this.el.expanded;
235 //if (this.el.expanded ) {
236 this.listeners.activate.call(this);
248 pack : "pack_start,true,true",
250 XObject.prototype.init.call(this);
251 this.el.set_current_page(0);
256 xtype: Gtk.ScrolledWindow,
258 shadow_type : Gtk.ShadowType.IN,
260 XObject.prototype.init.call(this);
261 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
264 getPaleteProvider : function() {
265 var model = this.get('model');
266 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
267 return pm.getPalete(model.file.getType());
269 renderView : function() {
270 var render = this.getRenderer();
271 var model = this.get('model');
273 render.renderJS(model.toJS(false,true)[0]);
275 print("NO RENDER JS METHOD?");
278 getRenderer : function() {
280 switch( this.getActiveFile().getType()) {
282 return this.get('/RightBrowser.view');
284 return this.get('/RightGtkView');
288 getActivePath : function() {
289 var model = this.get('model');
290 var view = this.get('view');
291 if (view.selection.count_selected_rows() < 1) {
294 var iter = new Gtk.TreeIter();
296 view.selection.get_selected(model.el, iter);
297 return model.el.get_path(iter).to_string();
299 getActiveFile : function() {
300 return this.get('model').file;
302 getActiveElement : function() {
304 var path = this.getActivePath();
308 var iter = new Gtk.TreeIter();
309 this.get('model').el.get_iter_from_string(iter, path);
311 var value = new GObject.Value('');
312 this.get('model').el.get_value(iter, 2, value);
314 return JSON.parse(value.value);
321 headers_visible : false,
322 enable_tree_lines : true,
325 XObject.prototype.init.call(this);
326 var description = new Pango.FontDescription.c_new();
327 description.set_size(8000);
328 this.el.modify_font(description);
330 this.selection = this.el.get_selection();
331 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
334 // is this really needed??
335 this.selection.signal['changed'].connect(function() {
336 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
337 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
341 Gtk.drag_source_set (
342 this.el, /* widget will be drag-able */
343 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
344 null, /* lists of target to support */
345 0, /* size of list */
346 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
349 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
351 Gtk.drag_source_add_text_targets(this.el);
354 this.el, /* widget that will accept a drop */
355 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
356 null, /* lists of target to support */
357 0, /* size of list */
358 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
361 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
362 Gtk.drag_dest_add_text_targets(this.el);
364 highlight : function(treepath_ar) {
366 // highlighting for drag/drop
367 if (treepath_ar.length && treepath_ar[0].length ) {
368 this.el.set_drag_dest_row(
369 new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);
371 this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
375 selectNode : function(treepath_str) {
376 //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
377 var tp = new Gtk.TreePath.from_string(treepath_str);
378 this.el.set_cursor(tp, null, false);
379 this.el.scroll_to_cell(tp, null, false, 0,0);
382 "button_press_event":function (self, ev) {
383 console.log("button press?");
384 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
385 print("click" + ev.type);
391 this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
393 if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();
395 this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
396 this.get('/LeftTreeMenu').el.show_all();
397 this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
398 print("click:" + res.path.to_string());
401 "drag_begin":function (self, drag_context) {
402 print('SOURCE: drag-begin');
403 this.targetData = false;
404 // find what is selected in our tree...
405 var iter = new Gtk.TreeIter();
406 var s = this.selection;
407 s.get_selected(this.get('/LeftTree.model').el, iter);
409 // set some properties of the tree for use by the dropped element.
410 var value = new GObject.Value('');
411 this.get('/LeftTree.model').el.get_value(iter, 2, value);
412 var data = JSON.parse(value.value);
413 var xname = this.get('/LeftTree.model').file.guessName(data);
415 this.el.dragData = xname;
416 this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);
419 // make the drag icon a picture of the node that was selected
420 var path = this.get('/LeftTree.model').el.get_path(iter);
421 this.el.treepath = path.to_string();
423 var pix = this.el.create_row_drag_icon ( path);
425 Gtk.drag_set_icon_pixmap (ctx,
434 "drag_end":function (self, drag_context) {
435 Seed.print('LEFT-TREE: drag-end');
436 this.el.dragData = false;
437 this.el.dropList = false;
438 this.targetData = false;
439 this.get('/LeftTree.view').highlight(false);
442 "drag_motion":function (self, ctx, x, y, time) {
443 console.log("LEFT-TREE: drag-motion");
444 var src = Gtk.drag_get_source_widget(ctx);
446 // a drag from elsewhere...- prevent drop..
448 print("no drag data!");
449 Gdk.drag_status(ctx, 0, time);
450 this.targetData = false;
453 var action = Gdk.DragAction.COPY;
454 if (src == this.el) {
455 // unless we are copying!!! ctl button..
456 action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
460 if (!this.get('/LeftTree.model').el.iter_n_children(null)) {
461 // no children.. -- asume it's ok..
462 this.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];
463 Gdk.drag_status(ctx, action ,time);
467 print("GETTING POS");
468 var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);
469 print("ISOVER? " + isOver);
471 Gdk.drag_status(ctx, 0 ,time);
472 return false; // not over apoint!?!
474 // drag node is parent of child..
475 console.log("SRC TREEPATH: " + src.treepath);
476 console.log("TARGET TREEPATH: " + data.path.to_string());
478 // nned to check a few here..
479 //Gtk.TreeViewDropPosition.INTO_OR_AFTER
480 //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
481 //Gtk.TreeViewDropPosition.AFTER
482 //Gtk.TreeViewDropPosition.BEFORE
484 if (typeof(src.treepath) != 'undefined' &&
485 src.treepath == data.path.to_string().substring(0,src.treepath.length)) {
486 print("subpath drag");
487 Gdk.drag_status(ctx, 0 ,time);
492 //print("DUMPING DATA");
493 //console.dump(data);
496 print(data.path.to_string() +' => '+ data.pos);
497 var tg = this.get('/LeftTree.model').findDropNodeByPath(
498 data.path.to_string(), src.dropList, data.pos);
500 this.get('/LeftTree.view').highlight(tg);
502 print("Can not find drop node path");
503 this.targetData = false;
504 Gdk.drag_status(ctx, 0, time);
508 this.targetData = tg;
511 Gdk.drag_status(ctx, action ,time);
515 "drag_drop":function (w, ctx, x, y, time) {
516 Seed.print("TARGET: drag-drop");
520 w, /* will receive 'drag-data-received' signal */
521 ctx, /* represents the current state of the DnD */
522 this.get('/Window').atoms["STRING"], /* the target type we want */
523 time /* time stamp */
527 /* No target offered by source => error */
532 "drag_data_received":function (self, ctx, x, y, sel_data, info, time) {
533 print("Tree: drag-data-received");
535 var delete_selection_data = false;
536 var dnd_success = false;
537 /* Deal with what we are given from source */
538 if( sel_data && sel_data.length ) {
540 if (ctx.action == Gdk.DragAction.ASK) {
541 /* Ask the user to move or copy, then set the ctx action. */
544 if (ctx.action == Gdk.DragAction.MOVE) {
545 //delete_selection_data = true;
548 var source = Gtk.drag_get_source_widget(ctx);
550 if (this.targetData) {
551 if (source != this.el) {
552 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
554 // drag around.. - reorder..
555 this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);
559 //Seed.print(this.targetData);
565 // we can send stuff to souce here...
571 if (dnd_success == false)
573 Seed.print ("DnD data transfer failed!\n");
576 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
579 "cursor_changed":function (self) {
580 if (this.blockChanges) { // probably not needed..
583 var render = this.get('/LeftTree').getRenderer();
586 if (this.selection.count_selected_rows() < 1) {
587 this.get('/LeftPanel.model').load( false);
588 this.get('/MidPropTree').activeElement = false;
589 this.get('/MidPropTree').hideWin();
591 var pm = this.get('/RightPalete.model');
592 if (!this.get('/LeftTree').getPaleteProvider()) {
593 // it may not be loaded yet..
596 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
597 this.get('/LeftTree.model').listAllTypes()));
598 if (render && render.redraw) {
604 //console.log('changed');
605 var s = this.selection;
606 var iter = new Gtk.TreeIter();
607 s.get_selected(this.get('/LeftTree.model').el, iter);
611 var value = new GObject.Value('');
612 this.get('/LeftTree.model').el.get_value(iter, 2, value);
613 this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
615 var data = JSON.parse(value.value);
616 this.get('/MidPropTree').activeElement = data;
617 this.get('/MidPropTree').hideWin();
618 this.get('/LeftPanel.model').load( data);
620 console.log(value.value);
621 // _g.button.set_label(''+value.get_string());
623 var pm =this.get('/RightPalete.model');
624 pm.load( this.get('/RightPalete').provider.gatherList(
625 this.get('/LeftTree.model').listAllTypes()));
628 if (render && render.redraw) {
632 //Seed.print( value.get_string());
639 xtype: Gtk.TreeStore,
643 XObject.prototype.init.call(this);
644 this.el.set_column_types ( 3, [
645 GObject.TYPE_STRING, // title
646 GObject.TYPE_STRING, // tip
647 GObject.TYPE_STRING // source..
651 changed : function(n, refresh) {
652 print("MODEL CHANGED CALLED" + this.activePath);
653 if (this.activePath) {
654 var iter = new Gtk.TreeIter();
655 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
656 this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
657 this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
659 this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
661 //this.currentTree = this.toJS(false, true)[0];
662 this.file.items = this.toJS(false, false);
663 print("AFTER CHANGED");
664 //console.dump(this.file.items);
666 this.currentTree = this.file.items[0];
667 //console.log(this.file.toSource());
670 print("REDNER BROWSER?!");
671 this.get('/LeftTree').renderView();
673 var pm = this.get('/RightPalete.model');
674 if (!this.get('/RightPalete').provider) {
680 pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
681 //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
685 loadFile : function(f) {
691 console.log('missing file');
695 // load the file if not loaded..
696 if (f.items === false) {
698 f.loadItems(function() {
704 if (f.items.length && typeof(f.items[0]) == 'string') {
706 this.get('/RightEditor').el.show();
707 this.get('/RightEditor.view').load( f.items[0]);
711 //console.dump(f.items);
713 this.get('/LeftTree.view').el.expand_all();
715 if (!f.items.length) {
718 this.get('/Window.leftvpaned').el.set_position(80);
720 this.get('/LeftTree.view').el.set_cursor(
721 new Gtk.TreePath.from_string('0'), null, false);
725 this.get('/Window.leftvpaned').el.set_position(200);
729 //print("hide right editior");
730 this.get('/RightEditor').el.hide();
731 //print("set current tree");
732 this.currentTree = this.toJS(false, false)[0];
733 //console.dump(this.currentTree);
734 this.currentTree = this.currentTree || { items: [] };
735 this.get('/LeftTree').renderView();
736 //console.dump(this.map);
737 //var RightPalete = imports.Builder.RightPalete.RightPalete;
738 var pm = this.get('/RightPalete.model');
741 this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
743 if (!this.get('/RightPalete').provider) {
744 print ("********* PALETE PROVIDER MISSING?!!");
746 this.get('/LeftTree').renderView();
748 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
752 this.get('/Window.view-notebook').el.set_current_page(
753 this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
756 findDropNode : function(treepath_str, targets) {
758 // this is used by the dragdrop code in the roo version AFAIR..
760 var path = treepath_str.replace(/^builder-/, '');
761 // treemap is depreciated... - should really check if model has any entries..
763 if (!this.el.iter_n_children(null)) {
765 return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];
767 print("FIND treepath: " + path);
768 //console.dump(this.treemap);
770 if (!treepath_str.match(/^builder-/)) {
771 return []; // nothing!
773 if (targets === true) {
776 return this.findDropNodeByPath(path,targets)
778 findDropNodeByPath : function(treepath_str, targets, pref) {
779 var path = treepath_str + ''; // dupe it..
780 pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
782 //console.dump(this.treemap);
783 while (path.length) {
784 print("LOOKING FOR PATH: " + path);
785 var node_data = this.singleNodeToJS(path);
786 if (node_data === false) {
787 print("node not found");
791 var xname = this.get('/LeftTree.model').file.guessName(node_data);
794 targets.forEach(function(tg) {
798 if ((tg == xname) ) {
801 if (tg.indexOf(xname +':') === 0) {
803 prop = tg.split(':').pop();
808 if (last) { // pref is after/before..
809 // then it's after last
811 return []; // do not allow..
813 return [ last, pref , prop];
816 return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
818 var par = path.split(':');
821 path = par.join(':');
827 dropNode : function(target_data, node) {
830 console.dump(target_data);
831 var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
833 print("add " + tp + "@" + target_data[1] );
836 if (tp && target_data[1] < 2) { // before or after..
837 var ar = target_data[0].split(':');
839 parent = new Gtk.TreePath.from_string( ar.join(':') );
842 var n_iter = new Gtk.TreeIter();
843 var iter_par = new Gtk.TreeIter();
844 var iter_after = after ? new Gtk.TreeIter() : false;
848 if (parent !== false) {
849 this.el.get_iter(iter_par, parent);
856 print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
857 this.el.get_iter(iter_after, after);
858 this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
859 n_iter, iter_par, iter_after);
862 this.el.append(n_iter, iter_par);
866 if (typeof(node) == 'string') {
867 var ar = node.split('.');
868 var xtype = ar.pop();
871 '|xns' : ar.join('.'),
874 if (target_data.length == 3 && target_data[2].length) {
875 node['*prop'] = target_data[2];
879 // work out what kind of packing to use..
880 if (typeof(node.pack) == 'undefined' && parent !== false) {
881 var pal = this.get('/LeftTree').getPaleteProvider();
883 var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
884 print ("PNAME : " + pname);
885 var cname = pal.guessName(node);
886 print ("CNAME : " + cname);
887 node.pack = pal.getDefaultPack(pname, cname);
898 // load children - if it has any..
901 this.load(xitems, n_iter);
903 if (tp && (xitems || after)) {
904 this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
906 // wee need to get the empty proptypes from somewhere..
908 //var olditer = this.activeIter;
909 this.activePath = this.el.get_path(n_iter).to_string();
911 // changed actually set's the node data..
912 this.changed(node, true);
916 this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
918 //Builder.MidPropTree._model.load(node);
919 //Builder.MidPropTree._win.hideWin();
920 //Builder.LeftPanel._model.load( node);
924 moveNode : function(target_data, action) {
925 //print("MOVE NODE");
926 // console.dump(target_data);
927 var old_iter = new Gtk.TreeIter();
928 var s = this.get('/LeftTree.view').selection;
929 s.get_selected(this.el, old_iter);
930 var node = this.nodeToJS(old_iter,false);
931 //console.dump(node);
934 // needs to drop first, otherwise the target_data
935 // treepath will be invalid.
937 this.dropNode(target_data, node);
938 if (action & Gdk.DragAction.MOVE) {
939 // print("REMOVING OLD NODE");
940 this.el.remove(old_iter);
944 this.activePath= false;
945 this.changed(false,true);
947 deleteSelected : function() {
948 this.get('/LeftTree.view').blockChanges = true;
949 var old_iter = new Gtk.TreeIter();
950 var s = this.get('/LeftTree.view').selection;
951 s.get_selected(this.el, old_iter);
952 var path = this.el.get_path(old_iter).to_string();
954 this.activePath= false;
957 this.activePath= false;
958 var iter = new Gtk.TreeIter();
959 this.el.get_iter_from_string(iter, path);
960 this.el.remove(iter);
962 // rebuild treemap. -- depreciated.!!
965 //this.toJS(null, true) // does not do anything?
966 this.activePath= false;
967 this.changed(false,true);
968 this.get('/LeftTree.view').blockChanges = false;
971 listAllTypes : function() {
972 var s = this.get('/LeftTree.view').selection;
973 print ("LIST ALL TYPES: " + s.count_selected_rows() );
975 if (s.count_selected_rows() > 0) {
976 var iter = new Gtk.TreeIter();
977 s.get_selected(this.el, iter);
979 // set some properties of the tree for use by the dropped element.
980 var value = new GObject.Value('');
981 this.el.get_value(iter, 2, value);
982 var data = JSON.parse(value.value);
985 var xname = this.get('/LeftTree.model').file.guessName(data);
986 console.log('selected:' + xname);
990 return []; // could not find it..
998 li.forEach(function(el) {
999 // this is specific to roo!!!?
1001 var fullpath = _this.file.guessName(el);
1002 if (fullpath.length && ret.indexOf(fullpath) < 0) {
1007 if (el.items && el.items.length) {
1016 addall([this.currentTree]);
1018 // only if we have nothing, should we add '*top'
1022 //console.log('all types in tree');
1023 //console.dump(ret);
1028 singleNodeToJS : function (treepath)
1030 var iter = new Gtk.TreeIter();
1031 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
1035 var iv = this.getIterValue(iter, 2);
1037 return JSON.parse(iv);
1040 nodeToJS : function (iter, with_id)
1042 var par = new Gtk.TreeIter();
1043 var iv = this.getIterValue(iter, 2);
1044 // print("IV" + iv);
1045 var k = JSON.parse(iv);
1046 if (k.json && !this.el.iter_parent( par, iter )) {
1051 var treepath_str = this.el.get_path(iter).to_string();
1052 // not sure how we can handle mixed id stuff..
1053 if (typeof(k.id) == 'undefined') {
1054 k.id = 'builder-'+ treepath_str ;
1058 this.treemap[ treepath_str ] = k;
1059 k.xtreepath = treepath_str ;
1062 if (this.el.iter_has_child(iter)) {
1063 citer = new Gtk.TreeIter();
1064 this.el.iter_children(citer, iter);
1065 k.items = this.toJS(citer,with_id);
1069 toJS : function(iter, with_id)
1071 //Seed.print("WITHID: "+ with_id);
1078 iter = new Gtk.TreeIter();
1079 if (!this.el.get_iter_first(iter)) {
1089 var k = this.nodeToJS(iter, with_id);
1093 if (!this.el.iter_next(iter)) {
1099 // convert the list into a json string..
1103 getIterValue : function (iter, col) {
1104 var gval = new GObject.Value('');
1105 this.el.get_value(iter, col ,gval);
1110 nodeTitle : function(c, renderfull) {
1113 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
1114 if (sr) txt.push('<s>');
1115 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
1117 if (renderfull && c['|xns']) {
1118 txt.push(c['|xns']);
1121 if (c.xtype) { txt.push(c.xtype); }
1122 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1123 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1124 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1127 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1128 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1129 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1130 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1131 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1132 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1133 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1134 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1135 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1137 // for flat classes...
1138 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1139 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1142 if (sr) txt.push('</s>');
1143 return (txt.length == 0 ? "Element" : txt.join(" "));
1145 nodeToJSON : function(c) {
1153 return JSON.stringify(o);
1155 load : function(tr,iter)
1157 var citer = new Gtk.TreeIter();
1158 //this.insert(citer,iter,0);
1159 for(var i =0 ; i < tr.length; i++) {
1161 this.el.insert(citer,iter,-1);
1163 this.el.append(citer);
1166 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1167 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTip(tr[i]) ]);
1168 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1169 if (tr[i].items && tr[i].items.length) {
1170 this.load(tr[i].items, citer);
1174 nodeTip : function(c) {
1175 var ret = this.nodeTitle(c,true);
1181 if (!i.length || i[0] != '|') {
1187 if (typeof(c[i]) != 'string') {
1190 //print("prop : " + i + ':' + c[i]);
1191 if (!c[i].match(new RegExp('function'))) {
1194 funcs += "\n<b>" + i.substring(1) + '</b> : ' + c[i].split(/\n/).shift();
1198 ret+="\n\nMethods:" + funcs;
1205 xtype: Gtk.TreeViewColumn,
1206 pack : "append_column",
1208 XObject.prototype.init.call(this);
1209 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1213 xtype: Gtk.CellRendererText,
1223 id : "LeftTreeMenu",
1226 xtype: Gtk.MenuItem,
1228 label : "Delete Element",
1230 "activate":function (self) {
1232 this.get('/LeftTree.model').deleteSelected();
1243 id : "LeftProjectTree",
1244 showNoProjectSelected : function() {
1245 this.get('/StandardErrorDialog').show("Select a Project first.");
1247 getActiveProject : function() {
1248 return this.project;
1251 "leave_notify_event":function (self, event) {
1258 pack : "pack_start,false,false",
1261 xtype: Gtk.ComboBox,
1264 XObject.prototype.init.call(this);
1265 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1267 getValue : function() {
1268 var ix = this.el.get_active();
1272 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1273 if (typeof(data[ix]) == 'undefined') {
1278 setValue : function(fn)
1282 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1283 data.forEach(function(n, ix) {
1291 "changed":function (self) {
1292 var fn = this.getValue();
1293 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1294 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1299 xtype: Gtk.CellRendererText,
1300 pack : "pack_start,true",
1304 xtype: Gtk.ListStore,
1307 XObject.prototype.init.call(this);
1308 this.el.set_column_types ( 2, [
1309 GObject.TYPE_STRING, // real key
1310 GObject.TYPE_STRING // real type
1314 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1316 pm.on('changed', function() {
1317 print("caught changed hook on project manager - reloading data");
1318 _this.loadData(pm.projects);
1322 loadData : function(data) {
1323 var ov = this.get('/LeftProjectTree.combo').getValue();
1325 var iter = new Gtk.TreeIter();
1327 data.forEach(function(p) {
1332 el.set_value(iter, 0, p.fn);
1333 el.set_value(iter, 1, p.name);
1337 this.get('/LeftProjectTree.combo').setValue(ov);
1346 xtype: Gtk.ScrolledWindow,
1348 shadow_type : Gtk.ShadowType.IN,
1350 XObject.prototype.init.call(this);
1351 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1355 xtype: Gtk.TreeView,
1356 headers_visible : false,
1357 enable_tree_lines : true,
1360 XObject.prototype.init.call(this);
1361 var description = new Pango.FontDescription.c_new();
1362 description.set_size(8000);
1363 this.el.modify_font(description);
1365 this.selection = this.el.get_selection();
1366 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1370 "cursor_changed":function (self) {
1371 var iter = new Gtk.TreeIter();
1373 if (this.selection.count_selected_rows() < 1) {
1374 //XN.get('Builder.LeftTree.model').
1375 this.get('/LeftTree.model').load( false);
1379 var model = this.get('/LeftProjectTree.model');
1380 //console.log('changed');
1381 var s = this.selection;
1382 s.get_selected(model, iter);
1383 value = new GObject.Value('');
1384 model.el.get_value(iter, 2, value);
1386 console.log(value.value);// id..
1388 var file = this.get('/LeftProjectTree').project.getById(value.value);
1395 var nb = this.get('/LeftTopPanel.expander');
1396 nb.el.expanded = false;
1397 nb.listeners.activate.call(nb);
1398 //_expander.el.set_expanded(false);
1400 var ltm = this.get('/LeftTree.model');
1408 xtype: Gtk.TreeStore,
1412 XObject.prototype.init.call(this);
1413 this.el.set_column_types ( 3, [
1414 GObject.TYPE_STRING, // title
1415 GObject.TYPE_STRING, // tip
1416 GObject.TYPE_STRING // id..
1420 loadProject : function(pr) {
1421 print("LOAD PROJECT");
1427 this.get('/LeftProjectTree').project = pr;
1428 this.load(pr.toTree());
1429 this.get('/LeftProjectTree.view').el.expand_all();
1431 load : function(tr,iter) {
1432 // console.dump(tr);
1433 console.log('Project tree load: ' + tr.length);
1434 var citer = new Gtk.TreeIter();
1435 //this.insert(citer,iter,0);
1438 tr.forEach(function (r) {
1440 _this.el.append(citer);
1442 _this.el.insert(citer,iter,-1);
1444 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1445 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1446 _this.el.set_value(citer, 2, '' + r.id ); //id
1447 if (r.cn && r.cn.length) {
1448 _this.load(r.cn, citer);
1453 getValue : function(iter, col) {
1454 var gval = new GObject.Value('');
1455 this.el.get_value(iter, col ,gval);
1456 return '' + gval.value;
1460 xtype: Gtk.TreeViewColumn,
1461 pack : "append_column",
1463 XObject.prototype.init.call(this);
1464 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1468 xtype: Gtk.CellRendererText,
1491 pack : "pack_start,false,true,0",
1498 "button_press_event":function (self, event) {
1499 this.get('/MidPropTree.model').showData('props');
1511 stock : Gtk.STOCK_ADD,
1512 icon_size : Gtk.IconSize.MENU
1527 "button_press_event":function (self, event) {
1528 this.get('/MidPropTree.model').showData('events');
1540 stock : Gtk.STOCK_ADD,
1541 icon_size : Gtk.IconSize.MENU
1556 "button_press_event":function (self, ev) {
1557 var p = this.get('/AddPropertyPopup');
1561 p.el.set_screen(Gdk.Screen.get_default());
1563 p.el.popup(null, null, null, null, 3, ev.button.time);
1575 stock : Gtk.STOCK_ADD,
1576 icon_size : Gtk.IconSize.MENU
1588 id : "AddPropertyPopup",
1591 xtype: Gtk.MenuItem,
1593 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1596 "activate":function (self) {
1598 this.get('/LeftPanel.model').add( {
1609 xtype: Gtk.MenuItem,
1611 tooltip_markup : "Add what type of packing is to be used",
1614 "activate":function (self) {
1616 this.get('/LeftPanel.model').add( {
1626 xtype: Gtk.MenuItem,
1628 tooltip_markup : "Override the init method",
1631 "activate":function (self) {
1633 this.get('/LeftPanel.model').add( {
1636 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1643 xtype: Gtk.SeparatorMenuItem,
1647 xtype: Gtk.MenuItem,
1649 tooltip_markup : "Add a user defined string property",
1652 "activate":function (self) {
1654 this.get('/LeftPanel.model').add( {
1664 xtype: Gtk.MenuItem,
1666 tooltip_markup : "Add a user defined number property",
1669 "activate":function (self) {
1671 this.get('/LeftPanel.model').add( {
1681 xtype: Gtk.MenuItem,
1683 tooltip_markup : "Add a user defined boolean property",
1686 "activate":function (self) {
1688 this.get('/LeftPanel.model').add( {
1698 xtype: Gtk.SeparatorMenuItem,
1702 xtype: Gtk.MenuItem,
1704 tooltip_markup : "Add a user function boolean property",
1707 "activate":function (self) {
1709 this.get('/LeftPanel.model').add( {
1712 val : "function() {\n \n}\n",
1725 xtype: Gtk.ScrolledWindow,
1728 shadow_type : Gtk.ShadowType.IN,
1731 XObject.prototype.init.call(this);
1732 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1736 xtype: Gtk.TreeView,
1739 headers_visible : false,
1740 enable_tree_lines : true,
1742 XObject.prototype.init.call(this);
1744 this.selection = this.el.get_selection();
1745 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1748 var description = new Pango.FontDescription.c_new();
1749 description.set_size(8000);
1750 this.el.modify_font(description);
1753 "button_press_event":function (self, ev) {
1757 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1758 return false; //not on a element.
1762 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1764 if (res.column.title != 'value') {
1765 return false; // ignore..
1767 if ( this.get('/LeftPanel').editing) {
1770 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1771 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1772 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1776 var provider = this.get('/LeftTree').getPaleteProvider();
1778 var opts = provider.findOptions(type);
1780 if (opts === false) {
1781 this.get('/LeftPanel').editableColumn.setOptions([]);
1782 renderer.has_entry = true;
1784 LeftPanel.editableColumn.setOptions(opts);
1785 renderer.has_entry = false;
1789 //Seed.print("click" + ev.type);
1790 //console.dump(res);
1796 if (res.column.title == 'value') {
1799 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1800 var p = this.get('/LeftPanelPopup');
1805 p.el.set_screen(Gdk.Screen.get_default());
1807 p.el.popup(null, null, null, null, 3, ev.button.time);
1808 //Seed.print("click:" + res.column.title);
1816 xtype: Gtk.TreeStore,
1820 XObject.prototype.init.call(this);
1821 this.el.set_column_types ( 5, [
1822 GObject.TYPE_STRING, // 0 real key
1823 GObject.TYPE_STRING, // 1 real value
1824 GObject.TYPE_STRING, // 2 visable key
1825 GObject.TYPE_STRING, // 3 visable value
1826 GObject.TYPE_STRING, // 4 need to store type of!!!
1830 toShort : function(str) {
1831 var a = typeof(str) == 'string' ? str.split("\n") : [];
1832 return a.length > 1 ? a[0] + '....' : '' + str;
1834 load : function(ar) {
1837 this.get('/RightEditor').el.hide();
1844 var provider = this.get('/LeftTree').getPaleteProvider();
1847 var iter = new Gtk.TreeIter();
1849 if (typeof(ar[i]) == 'object') {
1853 var type = provider.findType(ar, i, ar[i]);
1855 this.el.append(iter);
1856 var p = this.el.get_path(iter).to_string();
1858 this.el.set_value(iter, 0, i);
1859 this.el.set_value(iter, 1, '' + ar[i]);
1860 this.el.set_value(iter, 2, i);
1861 this.el.set_value(iter, 3, this.toShort(ar[i]));
1862 this.el.set_value(iter, 4, type);
1864 ar.listeners = ar.listeners || {};
1865 for (var i in ar.listeners ) {
1866 this.el.append(iter);
1867 var p = this.el.get_path(iter).to_string();
1870 this.el.set_value(iter, 0, '!'+ i );
1871 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1872 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1874 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1875 this.el.set_value(iter, 4, 'function');
1879 add : function(info) {
1880 // info includes key, val, skel, etype..
1882 type = info.type.toLowerCase();
1883 var data = this.toJS();
1885 if (info.etype == 'events') {
1886 data.listeners = data.listeners || { };
1887 if (typeof(data.listeners[info.key]) != 'undefined') {
1888 return; //already set!
1891 if (typeof(data[info.key]) != 'undefined') {
1896 if (typeof(info.val) == 'undefined') {
1899 if (info.type == 'boolean') {
1902 if (type == 'number') {
1910 if (info.etype == 'events') {
1912 data.listeners[info.key] = info.val;
1915 data[info.key] = info.val;
1919 var map = this.load(data);
1921 // flag it as changed to the interface..
1923 this.get('/LeftTree.model').changed(data, true);
1926 this.startEditing(map[k]);
1929 LeftPanel.get('view').el.row_activated(
1930 new Gtk.TreePath.from_string(map[k]),
1931 LeftPanel.editableColumn.el
1935 startEditing : function(path,col) {
1937 * start editing path (or selected if not set..)
1938 * @param {String|false} path (optional) treepath to edit - selected tree gets
1939 * edited by default.
1940 * @param {Number} 0 or 1 (optional)- column to edit.
1943 if (typeof(path) == 'string') {
1944 tp = new Gtk.TreePath.from_string(path);
1946 var iter = new Gtk.TreeIter();
1947 var s = this.get('/LeftPanel.view').selection;
1948 s.get_selected(this.el, iter);
1949 tp = this.el.get_path(iter);
1950 path = tp.to_string();
1954 // which colum is to be edited..
1956 if (typeof(col) == 'undefined') {
1957 var k = this.getValue(path, 0);
1958 colObj = (!k.length || k == '|') ?
1959 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1961 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1964 // make sure the pulldown is set correctly..
1965 // not really needed for second col...
1967 var provider = this.get('/LeftTree').getPaleteProvider();
1969 var type = this.get('/LeftPanel.model').getType(path);
1970 var opts = provider.findOptions(type);
1971 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1973 if (opts === false) {
1974 this.get('/LeftPanel').editableColumn.setOptions([]);
1975 renderer.has_entry = true; /// probably does not have any effect.
1977 this.get('/LeftPanel').editableColumn.setOptions(opts);
1978 renderer.has_entry = false;
1982 // iter now has row...
1983 GLib.timeout_add(0, 100, function() {
1985 colObj.items[0].el.editable = true; // esp. need for col 0..
1986 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1995 deleteSelected : function() {
1996 var data = this.toJS();
1997 var iter = new Gtk.TreeIter();
1998 var s = this.get('/LeftPanel.view').selection;
1999 s.get_selected(this.el, iter);
2002 var gval = new GObject.Value('');
2003 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
2005 var val = gval.value;
2006 if (val[0] == '!') {
2008 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
2011 delete data.listeners[ val.substring(1)];
2012 if (!XObject.keys(data.listeners).length) {
2013 delete data.listeners;
2017 if (typeof(data[val]) == 'undefined') {
2025 this.get('/LeftTree.model').changed(data, true);
2029 changed : function(str, doRefresh) {
2030 if (!this.activePath) {
2033 var iter = new Gtk.TreeIter();
2034 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
2036 this.el.set_value(iter, 1, '' +str);
2037 this.el.set_value(iter, 3, '' + this.toShort(str));
2038 // update the tree...
2040 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
2043 var iter = new Gtk.TreeIter();
2044 this.get('/LeftPanel.model').el.get_iter_first(iter);
2049 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
2052 ar.listeners = ar.listeners || {};
2053 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
2056 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
2059 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
2065 //print(JSON.stringify(ar));
2069 getType : function(treepath) {
2070 return this.getValue(treepath, 4);
2072 getValue : function(treepath_str, col) {
2073 var iter = new Gtk.TreeIter();
2074 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
2076 var gval = new GObject.Value('');
2077 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
2078 var val = '' + gval.value;
2082 var type = this.getType(this.el.get_path(iter).to_string());
2083 //print("TYPE: " +type + " - val:" + val);
2084 switch(type.toLowerCase()) {
2090 return parseFloat(val); // Nan ?? invalid!!?
2092 return val == 'true' ? true : false;
2098 editSelected : function(e) {
2099 print("EDIT SELECTED?");
2100 var iter = new Gtk.TreeIter();
2101 var s = this.get('/LeftPanel.view').selection;
2102 s.get_selected(this.get('/LeftPanel.model').el, iter);
2103 var m = this.get('/LeftPanel.model')
2105 var gval = new GObject.Value('');
2106 this.el.get_value(iter, 0 ,gval);
2107 var val = '' + gval.value;
2109 gval = new GObject.Value('');
2110 this.el.get_value(iter, 1 ,gval);
2111 var rval = gval.value;
2112 var activePath = this.el.get_path(iter).to_string();
2113 this.activePath = activePath ;
2114 // was activeIter...
2117 var showEditor = false;
2119 if (val[0] == '!') {
2122 if (val[0] == '|') {
2123 if (rval.match(/function/g) || rval.match(/\n/g)) {
2130 this.activePath = false;
2131 GLib.timeout_add(0, 1, function() {
2132 // Gdk.threads_enter();
2133 _this.get('/BottomPane').el.show();
2134 _this.get('/RightEditor').el.show();
2135 _this.get('/RightEditor.view').load( rval );
2139 _this.activePath = activePath ;
2141 // Gdk.threads_leave();
2146 this.get('/BottomPane').el.hide();
2147 this.get('/RightEditor').el.hide();
2149 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2155 xtype: Gtk.TreeViewColumn,
2156 pack : "append_column",
2158 XObject.prototype.init.call(this);
2160 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2161 this.get('/LeftPanel').propertyColumn = this;
2166 xtype: Gtk.CellRendererText,
2167 pack : "pack_start",
2169 "editing_started":function (self, editable, path) {
2171 this.get('/LeftPanel.model').activePath = path;
2174 "edited":function (self, object, p0) {
2175 var model = this.get('/LeftPanel.model');
2176 var path = model.activePath;
2177 var iter = new Gtk.TreeIter();
2178 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2179 model.el.set_value(iter, 0, p0);
2180 model.el.set_value(iter, 2, p0);
2182 model.activePath = false;
2184 this.get('/LeftTree.model').changed(model.toJS(), true);
2185 this.el.editable = false;
2192 xtype: Gtk.TreeViewColumn,
2193 pack : "append_column",
2195 XObject.prototype.init.call(this);
2196 this.el.add_attribute(this.items[0].el , 'text', 3 );
2197 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2198 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2199 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2201 this.get('/LeftPanel').editableColumn= this;
2203 setOptions : function(ar) {
2204 var m = this.items[0].el.model;
2206 var iter = new Gtk.TreeIter();
2207 ar.forEach(function(i) {
2210 m.set_value(iter, 0, i);
2216 xtype: Gtk.CellRendererCombo,
2217 pack : "pack_start",
2222 XObject.prototype.init.call(this);
2223 this.el.model = new Gtk.ListStore();
2224 this.el.model.set_column_types ( 1, [
2225 GObject.TYPE_STRING // 0 real key
2229 "edited":function (self, object, p0) {
2230 this.get('/LeftPanel').editing = false;
2231 print("EDITED? p:" + p0 + " t:" + p0);
2232 this.get('/LeftPanel.model').changed(p0, true);
2233 this.get('/LeftPanel.model').activePath = false;
2235 "editing_started":function (self, editable, path) {
2236 this.get('/LeftPanel').editing = true;
2237 // console.log('editing started');
2238 // r.has_entry = false;
2239 this.get('/LeftPanel.model').editSelected(editable);
2250 id : "LeftPanelPopup",
2253 xtype: Gtk.MenuItem,
2257 "activate":function (self) {
2258 this.get('/LeftPanel.model').deleteSelected();
2263 xtype: Gtk.MenuItem,
2267 "activate":function (self) {
2268 this.get('/LeftPanel.model').startEditing(false, 0);
2281 xtype: Gtk.ScrolledWindow,
2282 pack : "pack_end,false,true,0",
2284 shadow_type : Gtk.ShadowType.IN,
2286 XObject.prototype.init.call(this);
2287 XObject.prototype.init.call(this);
2288 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2289 this.el.set_size_request ( 150, -1 );
2292 activeElement : false,
2293 hideWin : function() {
2300 if (this.get('/Window.left').el.position < 160) {
2303 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2310 xtype: Gtk.TreeView,
2311 enable_tree_lines : true,
2312 headers_visible : false,
2315 XObject.prototype.init.call(this);
2317 var description = new Pango.FontDescription.c_new();
2318 description.set_size(8000);
2319 this.el.modify_font(description);
2321 //this.selection = this.el.get_selection();
2322 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2331 "cursor_changed":function (self) {
2332 var iter = new Gtk.TreeIter();
2334 //console.log('changed');
2335 var m = this.get('model');
2336 if (!this.selection){
2337 this.selection = this.el.get_selection();
2340 var s = this.selection;
2341 if (!s.get_selected(m.el, iter)) {
2344 var tp = m.el.get_path(iter).to_string();
2349 var key = m.getValue(tp, 0);
2351 var type = m.getValue(tp, 1);
2352 var skel = m.getValue(tp, 3);
2353 var etype = m.getValue(tp, 5);
2356 this.get('/MidPropTree').hideWin();
2358 if (type == 'function') {
2360 if (etype != 'events') {
2364 this.get('/LeftPanel.model').add({
2373 if (type.indexOf('.') > -1 ||
2374 type == 'boolean') {
2378 this.get('/LeftPanel.model').add( {
2388 xtype: Gtk.ListStore,
2391 XObject.prototype.init.call(this);
2392 this.el.set_column_types ( 6, [
2393 GObject.TYPE_STRING, // real key
2394 GObject.TYPE_STRING, // real type
2395 GObject.TYPE_STRING, // docs ?
2396 GObject.TYPE_STRING, // visable desc
2397 GObject.TYPE_STRING, // function desc
2398 GObject.TYPE_STRING // element type (event|prop)
2402 getValue : function(treepath, col)
2404 var tp = new Gtk.TreePath.from_string (treepath);
2405 var iter = new Gtk.TreeIter();
2406 this.el.get_iter (iter, tp);
2407 var value = new GObject.Value('');
2408 this.el.get_value(iter, col, value);
2412 showData : function(type) {
2414 if (!this.get('/MidPropTree').activeElement || !type) {
2415 return; // no active element
2418 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2419 var palete = this.get('/LeftTree').getPaleteProvider();
2423 Seed.print('Showing right?');
2424 if (!this.get('/MidPropTree').shown) {
2426 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2427 this.get('/MidPropTree').el.show();
2428 this.get('/MidPropTree').shown = true;
2431 var elementList = palete.getPropertiesFor(fullpath, type);
2432 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2433 // console.dump(elementList);
2436 var iter = new Gtk.TreeIter();
2437 for(var i =0 ; i < elementList.length; i++) {
2438 var p=elementList[i];
2439 this.el.append(iter);
2440 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2441 //GObject.TYPE_STRING, // real key
2442 // GObject.TYPE_STRING, // real type
2443 // GObject.TYPE_STRING, // docs ?
2444 // GObject.TYPE_STRING // func def?
2447 this.el.set_value(iter, 0, p.name);
2448 this.el.set_value(iter, 1, p.type);
2449 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2450 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2451 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2452 this.el.set_value(iter, 5, type);
2460 xtype: Gtk.TreeViewColumn,
2462 this.el = new Gtk.TreeViewColumn();
2463 this.parent.el.append_column(this.el);
2465 XObject.prototype.init.call(this);
2466 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2471 xtype: Gtk.CellRendererText,
2472 pack : "pack_start,true"
2496 xtype: Gtk.Notebook,
2497 pack : "pack_start,true,true",
2498 id : "view-help-nb",
2500 XObject.prototype.init.call(this);
2501 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" }));
2502 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" }));
2506 xtype: Gtk.Notebook,
2508 id : "view-notebook",
2511 XObject.prototype.init.call(this);
2512 this.el.set_current_page(0);
2514 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2515 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2522 id : "RightBrowser",
2529 pack : "pack_start,false,true,0",
2533 pack : "pack_start,false,false,0",
2536 "button_press_event":function (self, event) {
2537 var js = this.get('/LeftTree.model').toJS();
2539 this.get('/RightBrowser.view').renderJS(js[0]);
2547 pack : "pack_start,false,false,0",
2548 label : "Set extra HTML in render",
2550 "button_press_event":function (self, event) {
2551 this.get('/RooProjectProperties').show();
2558 pack : "pack_start,false,false,0",
2559 label : "test in Firefox",
2561 "button_press_event":function (self, event)
2563 /* Firefox testing for debugging..
2564 - we can create a /tmp directory, and put.
2565 builder.html, builder.html.js, link roojs1
2566 add at the end of builder.html Roo.onload(function() {
2568 if (!this.get('/Window.LeftTree').getActiveFile()) {
2572 var js = this.get('/LeftTree.model').toJS();
2573 if (!js || !js[0]) {
2576 var project = this.get('/Window.LeftTree').getActiveFile().project;
2577 //print (project.fn);
2579 project.runhtml = project.runhtml || '';
2582 var File = imports.File.File;
2584 var target = "/tmp/firetest"; // fixme..
2585 if (!File.isDirectory(target)) {
2588 File.copy(__script_path__ + '/../builder.html.js', target+ '/builder.html.js', Gio.FileCopyFlags.OVERWRITE);
2589 if (!File.exists( target+ '/roojs1')) {
2590 File.link( target+ '/roojs1', __script_path__ + '/../roojs1');
2595 var html = imports.File.File.read(__script_path__ + '/../builder.html');
2596 html = html.replace('</head>', project.runhtml + '</head>');
2599 var jsstr = JSON.stringify(js[0]);
2601 var runbuilder = '<script type="text/javascript">' + "\n" +
2602 " Builder.render(" + jsstr + ");\n" +
2605 html = html.replace('</body>', runbuilder + '</body>');
2607 File.write( target+ '/builder.html', html);
2609 this.get('/Terminal').feed("RUN DIR:" + target);
2611 this.get('/Terminal').el.fork_command( null , [], [], target
2612 , false,false,false);
2613 var cmd = "firefox file://" + target + "/builder.html \n";
2614 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2622 xtype: Gtk.ScrolledWindow,
2624 shadow_type : Gtk.ShadowType.IN,
2626 XObject.prototype.init.call(this);
2627 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2631 xtype: WebKit.WebView,
2635 XObject.prototype.init.call(this);
2636 // this may not work!?
2637 this.el.open('file:///' + __script_path__ + '/../builder.html');
2641 this.el, /* widget that will accept a drop */
2642 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2643 null, /* lists of target to support */
2644 0, /* size of list */
2645 Gdk.DragAction.COPY /* what to do with data after dropped */
2648 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2649 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2651 renderJS : function(data) {
2652 print("HTML RENDERING");
2653 /// prevent looping..
2654 //if (this.pendingRedraw) {
2655 // print("pending redraw active?!");
2660 if (!this.get('/Window.LeftTree').getActiveFile()) {
2664 var project = this.get('/Window.LeftTree').getActiveFile().project;
2665 //print (project.fn);
2667 project.runhtml = project.runhtml || '';
2670 this.runhtml = this.runhtml || '';
2672 if (project.runhtml != this.runhtml) {
2673 // then we need to reload the browser using
2674 // load_html_string..
2676 // then trigger a redraw once it's loaded..
2677 this.pendingRedraw = true;
2679 this.runhtml = project.runhtml;
2681 var html = imports.File.File.read(__script_path__ + '/../builder.html');
2682 html = html.replace('</head>', this.runhtml + '</head>');
2683 print("LOAD HTML " + html);
2684 this.el.load_html_string( html , 'file:///' + __script_path__ + '/../builder.html');
2685 // should trigger load_finished!
2690 this.pendingRedraw = false;
2693 this.renderedData = data;
2694 var str = JSON.stringify(data) ;
2697 console.log('not loaded yet');
2699 //Seed.print("RENDER:" + str);
2700 //imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2702 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2705 "load_finished":function (self, object) {
2706 // if (this.ready) { // dont do it twice!
2710 this.pendingRedraw = false;
2711 var js = this.get('/LeftTree.model').toJS();
2713 this.renderJS(js[0]);
2717 "script_alert":function (self, object, p0) {
2720 return true; // do not display anything...
2722 "console_message":function (self, object, p0, p1) {
2723 // console.log(object);
2724 if (!object.match(/^\{/)) {
2726 this.get('/Terminal').feed(object);
2727 return true; // do not handle!!! -> later maybe in console..
2729 // console.log(object);
2730 var val = JSON.parse(object);
2732 if (typeof(val['hover-node']) != 'undefined') {
2733 this.activeNode = val['hover-node'];
2734 console.log('active node: ' + this.activeNode);
2739 if (typeof(val['id']) != 'undefined') {
2740 // this.activeNode = val['id'];
2741 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2745 this.get('/LeftTree.view').selectNode(tg[0]);
2749 if (ret && typeof(val['set']) != 'undefined') {
2750 this.get('/LeftPanel.model').add({
2754 //console.log('active node: ' + this.activeNode);
2757 //Seed.print('a:'+a);
2758 //Seed.print('b:'+b);
2759 //Seed.print('c:'+c);
2762 "drag_motion":function (w, ctx, x, y, time, ud) {
2763 // console.log('DRAG MOTION');
2765 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2766 this.targetData = [];
2767 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2769 // A) find out from drag all the places that node could be dropped.
2770 var src = Gtk.drag_get_source_widget(ctx);
2771 if (!src.dropList) {
2772 Gdk.drag_status(ctx, 0, time);
2775 // b) get what we are over.. (from activeNode)
2776 // tree is empty.. - list should be correct..
2777 if (!this.get('/LeftTree.model').currentTree) {
2778 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2782 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2784 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2787 Gdk.drag_status(ctx, 0,time);
2788 this.get('/LeftTree.view').highlight(false);
2792 // if we have a target..
2793 // -> highlight it! (in browser)
2794 // -> highlight it! (in tree)
2796 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2797 this.get('/LeftTree.view').highlight(tg);
2798 this.targetData = tg;
2799 // for tree we should handle this...
2802 "drag_drop":function (w, ctx, x, y,time, ud) {
2803 print("TARGET: drag-drop");
2804 var is_valid_drop_site = true;
2809 w, /* will receive 'drag-data-received' signal */
2810 ctx, /* represents the current state of the DnD */
2811 this.get('/Window').atoms["STRING"], /* the target type we want */
2812 time /* time stamp */
2816 /* No target offered by source => error */
2819 return is_valid_drop_site;
2821 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2823 print("Browser: drag-data-received");
2824 var delete_selection_data = false;
2825 vardnd_success = false;
2826 /* Deal with what we are given from source */
2827 if( sel_data && sel_data.length ) {
2829 if (ctx.action == Gdk.DragAction.ASK) {
2830 /* Ask the user to move or copy, then set the ctx action. */
2833 if (ctx.action == Gdk.DragAction.MOVE) {
2834 delete_selection_data = true;
2836 var source = Gtk.drag_get_source_widget(ctx);
2838 print("Browser: source.DRAGDATA? " + source.dragData);
2839 if (this.targetData) {
2840 print(this.targetData);
2841 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2850 if (dnd_success == false)
2852 Seed.print ("DnD data transfer failed!\n");
2855 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2867 id : "RightGtkView",
2868 renderJS : function(data, withDebug)
2870 this.highlightWidget = false;
2874 this.withDebug = false;
2876 if (this.renderedEl) {
2877 this.get('view').el.remove(this.renderedEl);
2878 this.renderedEl.destroy();
2879 this.renderedEl = false;
2882 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2883 // in theory tree is actually window..
2885 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2890 this.get('view').el.set_size_request(
2891 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2894 this.renderedEl.set_size_request(
2895 tree.default_width || 600,
2896 tree.default_height || 400
2898 this.get('view').el.show_all();
2903 showInWindow : function() {
2904 print("GET PROEJCT");
2905 var pr = this.get('/LeftProjectTree').getActiveProject();
2907 console.log(pr.paths);
2910 var src= this.buildJS(
2911 this.get('/LeftTree.model').toJS()[0],
2916 //var x = new imports.sandbox.Context();
2920 Seed.check_syntax('var e = ' + src);
2923 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2924 this.get('/Terminal').feed(console._dump(e)+"\n");
2926 var lines = src.split("\n");
2927 var start = Math.max(0, e.line - 10);
2928 var end = Math.min(lines.length, e.line + 10);
2929 for (var i =start ; i < end; i++) {
2931 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2934 this.get('/Terminal').feed(lines[i] + "\n");
2941 this.get('/BottomPane').el.set_current_page(1);
2942 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2943 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2944 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2946 var _top = x.get_global_object()._top;
2948 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2950 if (_top.el.popup) {
2951 _top.el.popup(null, null, null, null, 3, null);
2955 viewAdd : function(item, par)
2957 // does something similar to xobject..
2958 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2960 if (item.pack===false || item.pack === 'false') { // no ;
2963 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2964 var ns = imports.gi[item['|xns']];
2965 var ctr = ns[item['xtype']];
2967 for(var k in item) {
2969 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2984 if (k[0] == '|' && typeof(kv) == 'string') {
2986 if (kv.match(new RegExp('function'))) {
2989 print("WASL " + k + '=' + kv);
2991 eval( 'kv = ' + kv);
2992 } catch(e) { continue; }
2995 // print(k + '=' + kv);
2997 if (k[0] == '|') { // should be boolean or number..
2999 //print(k + '=' + kv);
3002 if (k == 'show_tabs') { // force tab showing for notebooks.
3005 print(k + '=' + typeof(kv) + " : " + kv);
3011 var el = new ctr(ctr_args);
3014 //console.dump(item.pack);
3021 if (typeof(item.pack) == 'string') {
3023 item.pack.split(',').forEach(function(e, i) {
3025 if (e == 'false') { args.push( false); return; }
3026 if (e == 'true') { args.push( true); return; }
3027 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
3030 //print(args.join(","));
3032 pack_m = args.shift();
3034 pack_m = item.pack.shift();
3039 if (pack_m && typeof(par[pack_m]) == 'undefined') {
3041 name: "ArgumentError",
3042 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
3043 "ADDING : " + item.id + " " + el
3052 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
3053 //Seed.print('args: ' + args.length);
3055 par[pack_m].apply(par, args);
3059 item.items = item.items || [];
3060 item.items.forEach(function(ch) {
3061 _this.viewAdd(ch, el);
3066 // add the signal handlers.
3067 // is it a widget!?!!?
3073 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
3074 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
3075 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
3076 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
3077 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
3087 widgetExposeEvent : function(w, evt, ud, item) {
3089 if (this.inRender) {
3093 if ( this.highlightWidget) {
3094 this.inRender = true;
3095 if (item.xtreepath.substring(0, this.activePath.length) == this.activePath) {
3096 Gdk.draw_rectangle(this.highlightWidget.window, this.gc, false, this.box.x , this.box.y, this.box.w, this.box.h);
3098 this.inRender = false;
3103 if (this.activePath != item.xtreepath) {
3107 // print("HIGHLIGHT: " + item.xtreepath ); // draw highlight??
3108 // work out the coords of the window..
3110 var dr = widget.window;
3111 this.gc = (new Gdk.GC.c_new(dr));
3112 this.gc.set_rgb_fg_color(new Gdk.Color({ red: 0xFFFF, green: 0, blue : 0 }));
3113 this.gc.set_line_attributes(4, Gdk.LineStyle.SOLID, Gdk.CapStyle.ROUND , Gdk.JoinStyle.ROUND);
3117 var r = evt.expose.area;
3118 // console.dump([r.x, r.y, r.width, r.height ] );
3120 // print(widget.get_parent().toString().match(/GtkScrolledWindow/);
3121 if (widget.get_parent().toString().match(/GtkScrolledWindow/)) { // eak
3122 // happens with gtkscrollview embedded stuff..
3123 var np =this.activePath.split(':');
3125 this.activePath = np.join(':');
3126 this.renderedEl.queue_draw();
3142 this.inRender = true;
3145 this.highlightWidget = widget;
3150 // print("DRAW BOX");
3151 //console.dump(this.box);
3152 Gdk.draw_rectangle(widget.window, this.gc, false, this.box.x , this.box.y, this.box.w,this.box.h);
3153 this.inRender = false;
3156 widgetDragMotionEvent : function() {
3157 print("WIDGET DRAGMOTION");
3160 widgetDragDropEvent : function() {
3161 print("WIDGET DRAGDROP");
3164 widgetPressEvent : function(w,e,u,d) {
3165 if (this.get('view').pressed) {
3168 this.get('view').pressed = true;
3169 print("WIDGET PRESS " + d.xtreepath );
3170 this.get('/LeftTree.view').selectNode( d.xtreepath );
3173 widgetReleaseEvent : function() {
3174 this.get('view').pressed = false;
3177 redraw : function() {
3178 this.highlightWidget = false;
3179 print("REDRAW CALLED");
3180 this.activePath = this.get('/LeftTree').getActivePath();
3181 if (this.renderedEl) {
3182 print("QUEUE DRAW CALLING");
3183 this.renderedEl.queue_draw();
3189 pack : "pack_start,false,true,0",
3193 pack : "pack_start,false,false,0",
3194 label : "Run The Application",
3196 "button_press_event":function (self, event) {
3197 // call render on left tree - with special option!?!
3199 //print("GET PROEJCT");
3200 var pr = this.get('/LeftProjectTree').getActiveProject();
3203 for (var i in pr.paths) {
3207 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
3208 this.get('/Terminal').feed("RUN DIR:" + dir);
3210 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
3211 , false,false,false);
3212 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
3213 this.get('/Terminal').el.feed_child(cmd, cmd.length);
3223 xtype: Gtk.ScrolledWindow,
3226 shadow_type : Gtk.ShadowType.IN,
3228 XObject.prototype.init.call(this);
3229 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3233 xtype: Gtk.EventBox,
3234 pack : "add_with_viewport",
3236 XObject.prototype.init.call(this);
3237 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
3238 red: 0x9F00, green: 0xB800 , blue : 0xA800
3246 XObject.prototype.init.call(this);
3247 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
3248 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
3253 xtype: Gtk.EventBox,
3256 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
3257 XObject.prototype.init.call(this);
3261 this.el, /* widget that will accept a drop */
3262 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
3263 null, /* lists of target to support */
3264 0, /* size of list */
3265 Gdk.DragAction.COPY /* what to do with data after dropped */
3268 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
3269 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
3272 getActiveNode : function(x,y)
3274 // workout what node is here..
3275 return '0'; // top..
3279 "drag_motion":function (self, ctx, x, y, time) {
3281 // A) find out from drag all the places that node could be dropped.
3282 var src = Gtk.drag_get_source_widget(ctx);
3283 if (!src.dropList) {
3284 Gdk.drag_status(ctx, 0, time);
3287 // b) get what we are over.. (from activeNode)
3288 // tree is empty.. - list should be correct..
3289 if (!this.get('/LeftTree.model').currentTree) {
3290 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3294 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
3295 var activeNode = this.getActiveNode(x, y);
3298 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
3301 Gdk.drag_status(ctx, 0,time);
3302 this.get('/LeftTree.view').highlight(false);
3306 // if we have a target..
3307 // -> highlight it! (in browser)
3308 // -> highlight it! (in tree)
3310 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3311 this.get('/LeftTree.view').highlight(tg);
3312 this.targetData = tg;
3313 // for tree we should handle this...
3316 "drag_drop":function (self,ctx, x, y, time) {
3317 Seed.print("TARGET: drag-drop");
3318 var is_valid_drop_site = true;
3323 self, /* will receive 'drag-data-received' signal */
3324 ctx, /* represents the current state of the this.gDnD */
3325 this.get('/Window').atoms["STRING"], /* the target type we want */
3326 time /* time stamp */
3330 /* No target offered by source => error */
3333 return is_valid_drop_site;
3336 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3338 Seed.print("GtkView: drag-data-received");
3339 var delete_selection_data = false;
3340 var dnd_success = false;
3341 /* Deal with what we are given from source */
3342 if( sel_data && sel_data.length ) {
3344 if (ctx.action == Gdk.DragAction.ASK) {
3345 /* Ask the user to move or copy, then set the ctx action. */
3348 if (ctx.action == Gdk.DragAction.MOVE) {
3349 delete_selection_data = true;
3351 var source = Gtk.drag_get_source_widget(ctx);
3353 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3354 if (this.targetData) {
3355 Seed.print(this.targetData);
3356 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3365 if (dnd_success == false)
3367 Seed.print ("DnD data transfer failed!\n");
3370 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3373 "button_press_event":function (self, event) {
3374 this.pressed = false;
3390 xtype: Gtk.ScrolledWindow,
3395 var file = this.get('/LeftTree').getActiveFile();
3399 var activeEl = this.get('/LeftTree').getActiveElement();
3400 var xtype = file.guessName( activeEl )
3401 if (!xtype || !xtype.length) {
3404 this.get('/Window.view-help-nb').el.set_current_page(1);
3406 // get the active element being edited.
3407 var helpurl = file.getHelpUrl(xtype);
3409 // now load the help info in the page..
3410 this.get('help-view').el.open(helpurl);
3414 xtype: WebKit.WebView,
3418 XObject.prototype.init.call(this);
3419 this.get('/Window.help-view').el.open(
3420 "http://devel.akbkhome.com/seed/");
3432 xtype: Gtk.Notebook,
3435 XObject.prototype.init.call(this);
3436 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3437 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3442 xtype: Gtk.ScrolledWindow,
3447 xtype: GtkSource.View,
3451 XObject.prototype.init.call(this);
3452 var description = Pango.Font.description_from_string("monospace")
3453 description.set_size(8000);
3454 this.el.modify_font(description);
3457 load : function(str) {
3459 // show the help page for the active node..
3460 this.get('/Help').show();
3463 this.get('/BottomPane').el.set_current_page(0);
3464 this.el.get_buffer().set_text(str, str.length);
3465 var lm = GtkSource.LanguageManager.get_default();
3467 this.el.get_buffer().set_language(lm.get_language('js'));
3468 var buf = this.el.get_buffer();
3469 var cursor = buf.get_mark("insert");
3470 var iter= new Gtk.TextIter;
3471 buf.get_iter_at_mark(iter, cursor);
3473 iter.set_line_offset(4);
3474 buf.move_mark(cursor, iter);
3477 cursor = buf.get_mark("selection_bound");
3478 iter= new Gtk.TextIter;
3479 buf.get_iter_at_mark(iter, cursor);
3481 iter.set_line_offset(4);
3482 buf.move_mark(cursor, iter);
3484 this.el.grab_focus();
3486 insert_spaces_instead_of_tabs : true,
3489 show_line_numbers : true,
3492 xtype: GtkSource.Buffer,
3493 pack : "set_buffer",
3495 "changed":function (self) {
3496 var s = new Gtk.TextIter();
3497 var e = new Gtk.TextIter();
3498 this.el.get_start_iter(s);
3499 this.el.get_end_iter(e);
3500 var str = this.el.get_text(s,e,true);
3502 Seed.check_syntax('var e = ' + str);
3504 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3505 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3507 print("SYNTAX ERROR IN EDITOR");
3512 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3513 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3516 this.get('/LeftPanel.model').changed( str , false);
3525 xtype: Gtk.ScrolledWindow,
3529 xtype: Vte.Terminal,
3532 feed : function(istr) {
3533 var str = istr.replace(/\n/g, "\r\n") + "\r\n";
3534 // we should make ourselves visable!!!
3535 this.get('/BottomPane').el.show();
3536 this.get('/BottomPane').el.set_current_page(1);
3538 this.el.feed(str ,str.length);
3540 scroll_on_output : true,
3542 XObject.prototype.init.call(this);
3543 this.el.set_size (80, 1000);
3545 scrollback_lines : 1000
3555 pack : "pack_start,false,false",
3559 this.get('buttonbar').el.show();
3560 this.get('viewbox').el.hide();
3561 print("TRIED TO HIDE");
3564 this.get('buttonbar').el.hide();
3565 this.get('viewbox').el.show();
3566 // this.get('model').expanded();
3578 pack : "pack_start,false,true",
3580 "clicked":function (self) {
3581 this.get('/RightPalete').show();
3588 stock : Gtk.STOCK_GOTO_FIRST,
3589 icon_size : Gtk.IconSize.MENU
3599 XObject.prototype.init.call(this);
3600 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3603 "enter_notify_event":function (self, event) {
3604 this.get('/RightPalete').show();
3618 pack : "pack_start,false,true",
3627 pack : "pack_start,false,true",
3629 "clicked":function (self) {
3630 this.get('/RightPalete').hide();
3637 stock : Gtk.STOCK_GOTO_LAST,
3638 icon_size : Gtk.IconSize.MENU
3645 xtype: Gtk.ScrolledWindow,
3648 XObject.prototype.init.call(this);
3649 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3650 this.el.set_size_request(-1,200);
3652 shadow_type : Gtk.ShadowType.IN,
3655 xtype: Gtk.TreeView,
3658 XObject.prototype.init.call(this);
3659 this.el.set_size_request(150,-1);
3660 // set_reorderable: [1]
3662 var description = new Pango.FontDescription.c_new();
3663 description.set_size(8000);
3664 this.el.modify_font(description);
3666 this.selection = this.el.get_selection();
3667 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3668 // this.selection.signal['changed'].connect(function() {
3669 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3671 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3673 Gtk.drag_source_set (
3674 this.el, /* widget will be drag-able */
3675 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3676 null, /* lists of target to support */
3677 0, /* size of list */
3678 Gdk.DragAction.COPY /* what to do with data after dropped */
3680 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3682 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3683 Gtk.drag_source_add_text_targets(this.el);
3685 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3686 targets = new Gtk.TargetList();
3687 targets.add( LeftTree.atoms["STRING"], 0, 0);
3688 targets.add_text_targets( 1 );
3689 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3691 //if you want to allow text to be output elsewhere..
3692 //Gtk.drag_source_add_text_targets(this.el);
3696 headers_visible : false,
3697 enable_tree_lines : true,
3699 "drag_begin":function (self, ctx) {
3700 // we could fill this in now...
3701 Seed.print('SOURCE: drag-begin');
3705 var iter = new Gtk.TreeIter();
3706 var s = this.selection;
3707 s.get_selected(this.get('/RightPalete.model').el, iter);
3708 var path = this.get('/RightPalete.model').el.get_path(iter);
3710 var pix = this.el.create_row_drag_icon ( path);
3713 Gtk.drag_set_icon_pixmap (ctx,
3720 var value = new GObject.Value('');
3721 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3722 if (!this.get('/RightPalete').provider) {
3725 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3726 this.el.dragData = value.value;
3733 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3734 //Seed.print('Palete: drag-data-get: ' + target_type);
3735 if (this.el.dragData && this.el.dragData.length ) {
3736 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3740 //this.el.dragData = "TEST from source widget";
3744 "drag_end":function (self, drag_context) {
3745 Seed.print('SOURCE: drag-end');
3746 this.el.dragData = false;
3747 this.el.dropList = false;
3748 this.get('/LeftTree.view').highlight(false);
3754 xtype: Gtk.ListStore,
3757 XObject.prototype.init.call(this);
3758 this.el.set_column_types ( 2, [
3759 GObject.TYPE_STRING, // title
3760 GObject.TYPE_STRING // tip
3765 load : function(tr,iter)
3770 //console.log('Project tree load: ' + tr.length);
3771 var citer = new Gtk.TreeIter();
3772 //this.insert(citer,iter,0);
3773 for(var i =0 ; i < tr.length; i++) {
3776 this.el.append(citer);
3778 this.el.insert(citer,iter,-1);
3783 this.el.set_value(citer, 0, '' + r ); // title
3785 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3786 //if (r.cn && r.cn.length) {
3787 // this.load(r.cn, citer);
3793 getValue : function (iter, col) {
3794 var gval = new GObject.Value('');
3795 this.el.get_value(iter, col ,gval);
3802 xtype: Gtk.TreeViewColumn,
3803 pack : "append_column",
3805 XObject.prototype.init.call(this);
3806 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3810 xtype: Gtk.CellRendererText,
3832 XObject.cache['/Window'] = Window;