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);
38 setTitle : function(str) {
39 this.el.set_title(this.title + ' - ' + str);
42 delete_event : function (self, event) {
45 destroy : function (self) {
48 show : function (self) {
49 print("WINDOW SHOWING - trying to hide");
50 imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();
51 this.get('/MidPropTree').hideWin();
52 this.get('/RightPalete').hide();
53 this.get('/BottomPane').el.hide();
64 pack : "pack_start,false,false",
78 label : "New _Project",
80 activate : function (self) {
82 this.get('/EditProject').show({
83 success : function(pr) {
84 _this.get('/LeftProjectTree').get('combo').setValue(pr.fn);
95 activate : function (self) {
96 var fn = this.get('/LeftProjectTree.combo').getValue();
98 this.get('/LeftProjectTree').showNoProjectSelected();
101 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
102 this.get('/DialogNewComponent').show({
103 project : pm.getByFn(fn)
109 xtype: Gtk.SeparatorMenuItem,
114 use_underline : true,
116 label : "D_elete Project",
118 activate : function (self) {
120 var fn = this.get('/LeftProjectTree').get('combo').getValue();
122 this.get('/StandardErrorDialog').show("Select a project")
125 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
126 var pr = pm.getByFn(fn);
129 this.get('/DialogConfirm').show("Are you sure you want to delete project '" + pr.name + "'", function() {
130 pm.deleteProject(fn);
138 xtype: Gtk.SeparatorMenuItem,
145 use_underline : true,
147 activate : function (self) {
159 use_underline : true,
166 pack : "set_submenu",
175 use_underline : true,
177 activate : function (self) {
178 this.get('/About').el.run();
207 label : "Select Project",
209 pack : "pack_start,false,true",
211 XObject.prototype.init.call(this);
212 this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
215 activate : function (self) {
216 var nb = this.get('/LeftTopPanel.notebook');
217 if (this.el.expanded) {
220 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
223 var model = this.get('/LeftProjectTree.combomodel');
224 // print ("loading Projects?")
225 //console.dump(pm.projects);
226 model.loadData(pm.projects);
229 nb.el.set_current_page(1);
230 //pm.on('changed', function() {
231 //console.log("CAUGHT project manager change");
232 // _combo.model.loadData(pm.projects);
236 nb.el.set_current_page(0);
238 enter_notify_event : function (self, event) {
239 this.el.expanded = !this.el.expanded;
240 //if (this.el.expanded ) {
241 this.listeners.activate.call(this);
253 pack : "pack_start,true,true",
255 XObject.prototype.init.call(this);
256 this.el.set_current_page(0);
261 xtype: Gtk.ScrolledWindow,
263 shadow_type : Gtk.ShadowType.IN,
265 XObject.prototype.init.call(this);
266 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
269 getPaleteProvider : function() {
270 var model = this.get('model');
271 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
272 return pm.getPalete(model.file.getType());
274 renderView : function() {
275 var render = this.getRenderer();
276 var model = this.get('model');
278 render.renderJS(model.toJS(false,true)[0]);
280 print("NO RENDER JS METHOD?");
283 getRenderer : function() {
285 switch( this.getActiveFile().getType()) {
287 return this.get('/RightBrowser.view');
289 return this.get('/RightGtkView');
293 getActivePath : function() {
294 var model = this.get('model');
295 var view = this.get('view');
296 if (view.selection.count_selected_rows() < 1) {
299 var iter = new Gtk.TreeIter();
301 view.selection.get_selected(model.el, iter);
302 return model.el.get_path(iter).to_string();
304 getActiveFile : function() {
305 return this.get('model').file;
307 getActiveElement : function() {
309 var path = this.getActivePath();
313 var iter = new Gtk.TreeIter();
314 this.get('model').el.get_iter_from_string(iter, path);
316 var value = new GObject.Value('');
317 this.get('model').el.get_value(iter, 2, value);
319 return JSON.parse(value.value);
326 headers_visible : false,
327 enable_tree_lines : true,
330 XObject.prototype.init.call(this);
331 var description = new Pango.FontDescription.c_new();
332 description.set_size(8000);
333 this.el.modify_font(description);
335 this.selection = this.el.get_selection();
336 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
339 // is this really needed??
340 this.selection.signal['changed'].connect(function() {
341 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
342 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
346 Gtk.drag_source_set (
347 this.el, /* widget will be drag-able */
348 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
349 null, /* lists of target to support */
350 0, /* size of list */
351 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
354 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
356 Gtk.drag_source_add_text_targets(this.el);
359 this.el, /* widget that will accept a drop */
360 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
361 null, /* lists of target to support */
362 0, /* size of list */
363 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
366 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
367 Gtk.drag_dest_add_text_targets(this.el);
369 highlight : function(treepath_ar) {
371 // highlighting for drag/drop
372 if (treepath_ar.length && treepath_ar[0].length ) {
373 this.el.set_drag_dest_row(
374 new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);
376 this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
380 selectNode : function(treepath_str) {
381 //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
382 var tp = new Gtk.TreePath.from_string(treepath_str);
383 this.el.set_cursor(tp, null, false);
384 this.el.scroll_to_cell(tp, null, false, 0,0);
387 button_press_event : function (self, ev) {
388 console.log("button press?");
389 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
390 print("click" + ev.type);
396 this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
398 if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();
400 this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
401 this.get('/LeftTreeMenu').el.show_all();
402 this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
403 print("click:" + res.path.to_string());
406 drag_begin : function (self, drag_context) {
407 print('SOURCE: drag-begin');
408 this.targetData = false;
409 // find what is selected in our tree...
410 var iter = new Gtk.TreeIter();
411 var s = this.selection;
412 s.get_selected(this.get('/LeftTree.model').el, iter);
414 // set some properties of the tree for use by the dropped element.
415 var value = new GObject.Value('');
416 this.get('/LeftTree.model').el.get_value(iter, 2, value);
417 var data = JSON.parse(value.value);
418 var xname = this.get('/LeftTree.model').file.guessName(data);
420 this.el.dragData = xname;
421 this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);
424 // make the drag icon a picture of the node that was selected
425 var path = this.get('/LeftTree.model').el.get_path(iter);
426 this.el.treepath = path.to_string();
428 var pix = this.el.create_row_drag_icon ( path);
430 Gtk.drag_set_icon_pixmap (ctx,
439 drag_end : function (self, drag_context) {
440 Seed.print('LEFT-TREE: drag-end');
441 this.el.dragData = false;
442 this.el.dropList = false;
443 this.targetData = false;
444 this.get('/LeftTree.view').highlight(false);
447 drag_motion : function (self, ctx, x, y, time) {
448 console.log("LEFT-TREE: drag-motion");
449 var src = Gtk.drag_get_source_widget(ctx);
451 // a drag from elsewhere...- prevent drop..
453 print("no drag data!");
454 Gdk.drag_status(ctx, 0, time);
455 this.targetData = false;
458 var action = Gdk.DragAction.COPY;
459 if (src == this.el) {
460 // unless we are copying!!! ctl button..
461 action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
465 if (!this.get('/LeftTree.model').el.iter_n_children(null)) {
466 // no children.. -- asume it's ok..
467 this.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];
468 Gdk.drag_status(ctx, action ,time);
472 print("GETTING POS");
473 var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);
474 print("ISOVER? " + isOver);
476 Gdk.drag_status(ctx, 0 ,time);
477 return false; // not over apoint!?!
479 // drag node is parent of child..
480 console.log("SRC TREEPATH: " + src.treepath);
481 console.log("TARGET TREEPATH: " + data.path.to_string());
483 // nned to check a few here..
484 //Gtk.TreeViewDropPosition.INTO_OR_AFTER
485 //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
486 //Gtk.TreeViewDropPosition.AFTER
487 //Gtk.TreeViewDropPosition.BEFORE
489 if (typeof(src.treepath) != 'undefined' &&
490 src.treepath == data.path.to_string().substring(0,src.treepath.length)) {
491 print("subpath drag");
492 Gdk.drag_status(ctx, 0 ,time);
497 //print("DUMPING DATA");
498 //console.dump(data);
501 print(data.path.to_string() +' => '+ data.pos);
502 var tg = this.get('/LeftTree.model').findDropNodeByPath(
503 data.path.to_string(), src.dropList, data.pos);
505 this.get('/LeftTree.view').highlight(tg);
507 print("Can not find drop node path");
508 this.targetData = false;
509 Gdk.drag_status(ctx, 0, time);
513 this.targetData = tg;
516 Gdk.drag_status(ctx, action ,time);
520 drag_drop : function (w, ctx, x, y, time) {
521 Seed.print("TARGET: drag-drop");
525 w, /* will receive 'drag-data-received' signal */
526 ctx, /* represents the current state of the DnD */
527 this.get('/Window').atoms["STRING"], /* the target type we want */
528 time /* time stamp */
532 /* No target offered by source => error */
537 drag_data_received : function (self, ctx, x, y, sel_data, info, time) {
538 print("Tree: drag-data-received");
540 var delete_selection_data = false;
541 var dnd_success = false;
542 /* Deal with what we are given from source */
543 if( sel_data && sel_data.length ) {
545 if (ctx.action == Gdk.DragAction.ASK) {
546 /* Ask the user to move or copy, then set the ctx action. */
549 if (ctx.action == Gdk.DragAction.MOVE) {
550 //delete_selection_data = true;
553 var source = Gtk.drag_get_source_widget(ctx);
555 if (this.targetData) {
556 if (source != this.el) {
557 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
559 // drag around.. - reorder..
560 this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);
564 //Seed.print(this.targetData);
570 // we can send stuff to souce here...
576 if (dnd_success == false)
578 Seed.print ("DnD data transfer failed!\n");
581 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
584 cursor_changed : function (self) {
585 if (this.blockChanges) { // probably not needed..
588 var render = this.get('/LeftTree').getRenderer();
591 if (this.selection.count_selected_rows() < 1) {
592 this.get('/LeftPanel.model').load( false);
593 this.get('/MidPropTree').activeElement = false;
594 this.get('/MidPropTree').hideWin();
596 var pm = this.get('/RightPalete.model');
597 if (!this.get('/LeftTree').getPaleteProvider()) {
598 // it may not be loaded yet..
601 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
602 this.get('/LeftTree.model').listAllTypes()));
603 if (render && render.redraw) {
609 //console.log('changed');
610 var s = this.selection;
611 var iter = new Gtk.TreeIter();
612 s.get_selected(this.get('/LeftTree.model').el, iter);
616 var value = new GObject.Value('');
617 this.get('/LeftTree.model').el.get_value(iter, 2, value);
618 this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
620 var data = JSON.parse(value.value);
621 this.get('/MidPropTree').activeElement = data;
622 this.get('/MidPropTree').hideWin();
623 this.get('/LeftPanel.model').load( data);
625 console.log(value.value);
626 // _g.button.set_label(''+value.get_string());
628 var pm =this.get('/RightPalete.model');
629 pm.load( this.get('/RightPalete').provider.gatherList(
630 this.get('/LeftTree.model').listAllTypes()));
633 if (render && render.redraw) {
637 //Seed.print( value.get_string());
644 xtype: Gtk.TreeStore,
648 XObject.prototype.init.call(this);
649 this.el.set_column_types ( 3, [
650 GObject.TYPE_STRING, // title
651 GObject.TYPE_STRING, // tip
652 GObject.TYPE_STRING // source..
656 changed : function(n, refresh) {
657 print("MODEL CHANGED CALLED" + this.activePath);
658 if (this.activePath) {
659 var iter = new Gtk.TreeIter();
660 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
661 this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
662 this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
664 this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
666 //this.currentTree = this.toJS(false, true)[0];
667 this.file.items = this.toJS(false, false);
668 print("AFTER CHANGED");
669 //console.dump(this.file.items);
671 this.currentTree = this.file.items[0];
672 //console.log(this.file.toSource());
675 print("REDNER BROWSER?!");
676 this.get('/LeftTree').renderView();
678 var pm = this.get('/RightPalete.model');
679 if (!this.get('/RightPalete').provider) {
685 pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
686 //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
690 loadFile : function(f) {
696 console.log('missing file');
700 // load the file if not loaded..
701 if (f.items === false) {
703 f.loadItems(function() {
709 this.get('/Window').setTitle(f.project.getName() + ' - ' + f.name);
711 if (f.items.length && typeof(f.items[0]) == 'string') {
713 this.get('/RightEditor').el.show();
714 this.get('/RightEditor.view').load( f.items[0]);
718 //console.dump(f.items);
720 this.get('/LeftTree.view').el.expand_all();
722 if (!f.items.length) {
725 this.get('/Window.leftvpaned').el.set_position(80);
727 this.get('/LeftTree.view').el.set_cursor(
728 new Gtk.TreePath.from_string('0'), null, false);
732 this.get('/Window.leftvpaned').el.set_position(200);
736 //print("hide right editior");
737 this.get('/RightEditor').el.hide();
738 //print("set current tree");
739 this.currentTree = this.toJS(false, false)[0];
740 //console.dump(this.currentTree);
741 this.currentTree = this.currentTree || { items: [] };
742 this.get('/LeftTree').renderView();
743 //console.dump(this.map);
744 //var RightPalete = imports.Builder.RightPalete.RightPalete;
745 var pm = this.get('/RightPalete.model');
748 this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
750 if (!this.get('/RightPalete').provider) {
751 print ("********* PALETE PROVIDER MISSING?!!");
753 this.get('/LeftTree').renderView();
755 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
759 this.get('/Window.view-notebook').el.set_current_page(
760 this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
763 findDropNode : function(treepath_str, targets) {
765 // this is used by the dragdrop code in the roo version AFAIR..
767 var path = treepath_str.replace(/^builder-/, '');
768 // treemap is depreciated... - should really check if model has any entries..
770 if (!this.el.iter_n_children(null)) {
772 return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];
774 print("FIND treepath: " + path);
775 //console.dump(this.treemap);
777 if (!treepath_str.match(/^builder-/)) {
778 return []; // nothing!
780 if (targets === true) {
783 return this.findDropNodeByPath(path,targets)
785 findDropNodeByPath : function(treepath_str, targets, pref) {
786 var path = treepath_str + ''; // dupe it..
787 pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
789 //console.dump(this.treemap);
790 while (path.length) {
791 print("LOOKING FOR PATH: " + path);
792 var node_data = this.singleNodeToJS(path);
793 if (node_data === false) {
794 print("node not found");
798 var xname = this.get('/LeftTree.model').file.guessName(node_data);
801 targets.forEach(function(tg) {
805 if ((tg == xname) ) {
808 if (tg.indexOf(xname +':') === 0) {
810 prop = tg.split(':').pop();
815 if (last) { // pref is after/before..
816 // then it's after last
818 return []; // do not allow..
820 return [ last, pref , prop];
823 return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
825 var par = path.split(':');
828 path = par.join(':');
834 dropNode : function(target_data, node) {
837 console.dump(target_data);
838 var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
840 print("add " + tp + "@" + target_data[1] );
843 if (tp && target_data[1] < 2) { // before or after..
844 var ar = target_data[0].split(':');
846 parent = new Gtk.TreePath.from_string( ar.join(':') );
849 var n_iter = new Gtk.TreeIter();
850 var iter_par = new Gtk.TreeIter();
851 var iter_after = after ? new Gtk.TreeIter() : false;
855 if (parent !== false) {
856 this.el.get_iter(iter_par, parent);
863 print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
864 this.el.get_iter(iter_after, after);
865 this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
866 n_iter, iter_par, iter_after);
869 this.el.append(n_iter, iter_par);
873 if (typeof(node) == 'string') {
874 var ar = node.split('.');
875 var xtype = ar.pop();
878 '|xns' : ar.join('.'),
881 if (target_data.length == 3 && target_data[2].length) {
882 node['*prop'] = target_data[2];
886 // work out what kind of packing to use..
887 if (typeof(node.pack) == 'undefined' && parent !== false) {
888 var pal = this.get('/LeftTree').getPaleteProvider();
890 var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
891 print ("PNAME : " + pname);
892 var cname = pal.guessName(node);
893 print ("CNAME : " + cname);
894 node.pack = pal.getDefaultPack(pname, cname);
905 // load children - if it has any..
908 this.load(xitems, n_iter);
910 if (tp && (xitems || after)) {
911 this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
913 // wee need to get the empty proptypes from somewhere..
915 //var olditer = this.activeIter;
916 this.activePath = this.el.get_path(n_iter).to_string();
918 // changed actually set's the node data..
919 this.changed(node, true);
923 this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
925 //Builder.MidPropTree._model.load(node);
926 //Builder.MidPropTree._win.hideWin();
927 //Builder.LeftPanel._model.load( node);
931 moveNode : function(target_data, action) {
932 //print("MOVE NODE");
933 // console.dump(target_data);
934 var old_iter = new Gtk.TreeIter();
935 var s = this.get('/LeftTree.view').selection;
936 s.get_selected(this.el, old_iter);
937 var node = this.nodeToJS(old_iter,false);
938 //console.dump(node);
941 // needs to drop first, otherwise the target_data
942 // treepath will be invalid.
944 this.dropNode(target_data, node);
945 if (action & Gdk.DragAction.MOVE) {
946 // print("REMOVING OLD NODE");
947 this.el.remove(old_iter);
951 this.activePath= false;
952 this.changed(false,true);
954 deleteSelected : function() {
955 this.get('/LeftTree.view').blockChanges = true;
956 var old_iter = new Gtk.TreeIter();
957 var s = this.get('/LeftTree.view').selection;
958 s.get_selected(this.el, old_iter);
959 var path = this.el.get_path(old_iter).to_string();
961 this.activePath= false;
964 this.activePath= false;
965 var iter = new Gtk.TreeIter();
966 this.el.get_iter_from_string(iter, path);
967 this.el.remove(iter);
969 // rebuild treemap. -- depreciated.!!
972 //this.toJS(null, true) // does not do anything?
973 this.activePath= false;
974 this.changed(false,true);
975 this.get('/LeftTree.view').blockChanges = false;
978 listAllTypes : function() {
979 var s = this.get('/LeftTree.view').selection;
980 print ("LIST ALL TYPES: " + s.count_selected_rows() );
982 if (s.count_selected_rows() > 0) {
983 var iter = new Gtk.TreeIter();
984 s.get_selected(this.el, iter);
986 // set some properties of the tree for use by the dropped element.
987 var value = new GObject.Value('');
988 this.el.get_value(iter, 2, value);
989 var data = JSON.parse(value.value);
992 var xname = this.get('/LeftTree.model').file.guessName(data);
993 console.log('selected:' + xname);
997 return []; // could not find it..
1005 li.forEach(function(el) {
1006 // this is specific to roo!!!?
1008 var fullpath = _this.file.guessName(el);
1009 if (fullpath.length && ret.indexOf(fullpath) < 0) {
1014 if (el.items && el.items.length) {
1023 addall([this.currentTree]);
1025 // only if we have nothing, should we add '*top'
1029 //console.log('all types in tree');
1030 //console.dump(ret);
1035 singleNodeToJS : function (treepath)
1037 var iter = new Gtk.TreeIter();
1038 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
1042 var iv = this.getIterValue(iter, 2);
1044 return JSON.parse(iv);
1047 nodeToJS : function (iter, with_id)
1049 var par = new Gtk.TreeIter();
1050 var iv = this.getIterValue(iter, 2);
1051 // print("IV" + iv);
1052 var k = JSON.parse(iv);
1053 if (k.json && !this.el.iter_parent( par, iter )) {
1058 var treepath_str = this.el.get_path(iter).to_string();
1059 // not sure how we can handle mixed id stuff..
1060 if (typeof(k.id) == 'undefined') {
1061 k.id = 'builder-'+ treepath_str ;
1065 this.treemap[ treepath_str ] = k;
1066 k.xtreepath = treepath_str ;
1069 if (this.el.iter_has_child(iter)) {
1070 citer = new Gtk.TreeIter();
1071 this.el.iter_children(citer, iter);
1072 k.items = this.toJS(citer,with_id);
1076 toJS : function(iter, with_id)
1078 //Seed.print("WITHID: "+ with_id);
1085 iter = new Gtk.TreeIter();
1086 if (!this.el.get_iter_first(iter)) {
1096 var k = this.nodeToJS(iter, with_id);
1100 if (!this.el.iter_next(iter)) {
1106 // convert the list into a json string..
1110 getIterValue : function (iter, col) {
1111 var gval = new GObject.Value('');
1112 this.el.get_value(iter, col ,gval);
1117 nodeTitle : function(c, renderfull) {
1120 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
1121 if (sr) txt.push('<s>');
1122 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
1124 if (renderfull && c['|xns']) {
1125 txt.push(c['|xns']);
1128 if (c.xtype) { txt.push(c.xtype); }
1129 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1130 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1131 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1134 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1135 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1136 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1137 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1138 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1139 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1140 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1141 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1142 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1144 // for flat classes...
1145 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1146 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1149 if (sr) txt.push('</s>');
1150 return (txt.length == 0 ? "Element" : txt.join(" "));
1152 nodeToJSON : function(c) {
1160 return JSON.stringify(o);
1162 load : function(tr,iter)
1164 var citer = new Gtk.TreeIter();
1165 //this.insert(citer,iter,0);
1166 for(var i =0 ; i < tr.length; i++) {
1168 this.el.insert(citer,iter,-1);
1170 this.el.append(citer);
1173 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1174 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTip(tr[i]) ]);
1175 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1176 if (tr[i].items && tr[i].items.length) {
1177 this.load(tr[i].items, citer);
1181 nodeTip : function(c) {
1182 var ret = this.nodeTitle(c,true);
1188 if (!i.length || i[0] != '|') {
1194 if (typeof(c[i]) != 'string') {
1197 //print("prop : " + i + ':' + c[i]);
1198 if (!c[i].match(new RegExp('function'))) {
1201 funcs += "\n<b>" + i.substring(1) + '</b> : ' + c[i].split(/\n/).shift();
1205 ret+="\n\nMethods:" + funcs;
1212 xtype: Gtk.TreeViewColumn,
1213 pack : "append_column",
1215 XObject.prototype.init.call(this);
1216 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1220 xtype: Gtk.CellRendererText,
1230 id : "LeftTreeMenu",
1233 xtype: Gtk.MenuItem,
1235 label : "Delete Element",
1237 activate : function (self) {
1239 this.get('/LeftTree.model').deleteSelected();
1250 id : "LeftProjectTree",
1251 showNoProjectSelected : function() {
1252 this.get('/StandardErrorDialog').show("Select a Project first.");
1254 getActiveProject : function() {
1255 return this.project;
1258 leave_notify_event : function (self, event) {
1265 pack : "pack_start,false,false",
1268 xtype: Gtk.ComboBox,
1271 XObject.prototype.init.call(this);
1272 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1274 getValue : function() {
1275 var ix = this.el.get_active();
1279 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1280 if (typeof(data[ix]) == 'undefined') {
1285 setValue : function(fn)
1289 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1290 data.forEach(function(n, ix) {
1298 changed : function (self) {
1299 var fn = this.getValue();
1300 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1301 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1306 xtype: Gtk.CellRendererText,
1307 pack : "pack_start,true",
1311 xtype: Gtk.ListStore,
1314 XObject.prototype.init.call(this);
1315 this.el.set_column_types ( 2, [
1316 GObject.TYPE_STRING, // real key
1317 GObject.TYPE_STRING // real type
1321 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1323 pm.on('changed', function() {
1324 print("caught changed hook on project manager - reloading data");
1325 _this.loadData(pm.projects);
1329 loadData : function(data) {
1330 var ov = this.get('/LeftProjectTree.combo').getValue();
1332 var iter = new Gtk.TreeIter();
1334 data.forEach(function(p) {
1339 el.set_value(iter, 0, p.fn);
1340 el.set_value(iter, 1, p.name);
1344 this.get('/LeftProjectTree.combo').setValue(ov);
1353 xtype: Gtk.ScrolledWindow,
1355 shadow_type : Gtk.ShadowType.IN,
1357 XObject.prototype.init.call(this);
1358 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1362 xtype: Gtk.TreeView,
1363 headers_visible : false,
1364 enable_tree_lines : true,
1367 XObject.prototype.init.call(this);
1368 var description = new Pango.FontDescription.c_new();
1369 description.set_size(8000);
1370 this.el.modify_font(description);
1372 this.selection = this.el.get_selection();
1373 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1377 cursor_changed : function (self) {
1378 var iter = new Gtk.TreeIter();
1380 if (this.selection.count_selected_rows() < 1) {
1381 //XN.get('Builder.LeftTree.model').
1382 this.get('/LeftTree.model').load( false);
1386 var model = this.get('/LeftProjectTree.model');
1387 //console.log('changed');
1388 var s = this.selection;
1389 s.get_selected(model, iter);
1390 value = new GObject.Value('');
1391 model.el.get_value(iter, 2, value);
1393 console.log(value.value);// id..
1395 var file = this.get('/LeftProjectTree').project.getById(value.value);
1402 var nb = this.get('/LeftTopPanel.expander');
1403 nb.el.expanded = false;
1404 nb.listeners.activate.call(nb);
1405 //_expander.el.set_expanded(false);
1407 var ltm = this.get('/LeftTree.model');
1415 xtype: Gtk.TreeStore,
1419 XObject.prototype.init.call(this);
1420 this.el.set_column_types ( 3, [
1421 GObject.TYPE_STRING, // title
1422 GObject.TYPE_STRING, // tip
1423 GObject.TYPE_STRING // id..
1427 loadProject : function(pr) {
1428 print("LOAD PROJECT");
1434 this.get('/LeftProjectTree').project = pr;
1435 this.load(pr.toTree());
1436 this.get('/LeftProjectTree.view').el.expand_all();
1438 load : function(tr,iter) {
1439 // console.dump(tr);
1440 console.log('Project tree load: ' + tr.length);
1441 var citer = new Gtk.TreeIter();
1442 //this.insert(citer,iter,0);
1445 tr.forEach(function (r) {
1447 _this.el.append(citer);
1449 _this.el.insert(citer,iter,-1);
1451 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1452 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1453 _this.el.set_value(citer, 2, '' + r.id ); //id
1454 if (r.cn && r.cn.length) {
1455 _this.load(r.cn, citer);
1460 getValue : function(iter, col) {
1461 var gval = new GObject.Value('');
1462 this.el.get_value(iter, col ,gval);
1463 return '' + gval.value;
1467 xtype: Gtk.TreeViewColumn,
1468 pack : "append_column",
1470 XObject.prototype.init.call(this);
1471 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1475 xtype: Gtk.CellRendererText,
1498 pack : "pack_start,false,true,0",
1505 button_press_event : function (self, event) {
1506 this.get('/MidPropTree.model').showData('props');
1518 stock : Gtk.STOCK_ADD,
1519 icon_size : Gtk.IconSize.MENU
1534 button_press_event : function (self, event) {
1535 this.get('/MidPropTree.model').showData('events');
1547 stock : Gtk.STOCK_ADD,
1548 icon_size : Gtk.IconSize.MENU
1563 button_press_event : function (self, ev) {
1564 var p = this.get('/AddPropertyPopup');
1568 p.el.set_screen(Gdk.Screen.get_default());
1570 p.el.popup(null, null, null, null, 3, ev.button.time);
1582 stock : Gtk.STOCK_ADD,
1583 icon_size : Gtk.IconSize.MENU
1595 id : "AddPropertyPopup",
1598 xtype: Gtk.MenuItem,
1600 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1603 activate : function (self) {
1605 this.get('/LeftPanel.model').add( {
1616 xtype: Gtk.MenuItem,
1618 tooltip_markup : "Add what type of packing is to be used",
1621 activate : function (self) {
1623 this.get('/LeftPanel.model').add( {
1633 xtype: Gtk.MenuItem,
1635 tooltip_markup : "Override the init method",
1638 activate : function (self) {
1640 this.get('/LeftPanel.model').add( {
1643 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1650 xtype: Gtk.SeparatorMenuItem,
1654 xtype: Gtk.MenuItem,
1656 tooltip_markup : "Add a user defined string property",
1659 activate : function (self) {
1661 this.get('/LeftPanel.model').add( {
1671 xtype: Gtk.MenuItem,
1673 tooltip_markup : "Add a user defined number property",
1676 activate : function (self) {
1678 this.get('/LeftPanel.model').add( {
1688 xtype: Gtk.MenuItem,
1690 tooltip_markup : "Add a user defined boolean property",
1693 activate : function (self) {
1695 this.get('/LeftPanel.model').add( {
1705 xtype: Gtk.SeparatorMenuItem,
1709 xtype: Gtk.MenuItem,
1711 tooltip_markup : "Add a user function boolean property",
1714 activate : function (self) {
1716 this.get('/LeftPanel.model').add( {
1719 val : "function() {\n \n}\n",
1732 xtype: Gtk.ScrolledWindow,
1735 shadow_type : Gtk.ShadowType.IN,
1738 XObject.prototype.init.call(this);
1739 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1743 xtype: Gtk.TreeView,
1746 headers_visible : false,
1747 enable_tree_lines : true,
1749 XObject.prototype.init.call(this);
1751 this.selection = this.el.get_selection();
1752 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1755 var description = new Pango.FontDescription.c_new();
1756 description.set_size(8000);
1757 this.el.modify_font(description);
1760 button_press_event : function (self, ev) {
1764 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1765 return false; //not on a element.
1769 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1771 if (res.column.title != 'value') {
1772 return false; // ignore..
1774 if ( this.get('/LeftPanel').editing) {
1777 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1778 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1779 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1783 var provider = this.get('/LeftTree').getPaleteProvider();
1785 var opts = provider.findOptions(type);
1787 if (opts === false) {
1788 this.get('/LeftPanel').editableColumn.setOptions([]);
1789 renderer.has_entry = true;
1791 LeftPanel.editableColumn.setOptions(opts);
1792 renderer.has_entry = false;
1796 //Seed.print("click" + ev.type);
1797 //console.dump(res);
1803 if (res.column.title == 'value') {
1806 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1807 var p = this.get('/LeftPanelPopup');
1812 p.el.set_screen(Gdk.Screen.get_default());
1814 p.el.popup(null, null, null, null, 3, ev.button.time);
1815 //Seed.print("click:" + res.column.title);
1823 xtype: Gtk.TreeStore,
1827 XObject.prototype.init.call(this);
1828 this.el.set_column_types ( 6, [
1829 GObject.TYPE_STRING, // 0 real key
1830 GObject.TYPE_STRING, // 1 real value
1831 GObject.TYPE_STRING, // 2 visable key
1832 GObject.TYPE_STRING, // 3 visable value
1833 GObject.TYPE_STRING, // 4 need to store type of!!!
1834 GObject.TYPE_STRING // 5 tooltip
1838 toShort : function(str) {
1839 var a = typeof(str) == 'string' ? str.split("\n") : [];
1840 return a.length > 1 ? a[0] + '....' : '' + str;
1842 load : function(ar) {
1845 this.get('/RightEditor').el.hide();
1852 var provider = this.get('/LeftTree').getPaleteProvider();
1853 var iter = new Gtk.TreeIter();
1856 var keys = XObject.keys(ar);
1858 ar.listeners = ar.listeners || {};
1860 for (var i in ar.listeners ) {
1861 this.el.append(iter);
1862 var p = this.el.get_path(iter).to_string();
1865 this.el.set_value(iter, 0, '!'+ i );
1866 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1867 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1869 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1870 this.el.set_value(iter, 4, 'function');
1871 this.el.set_value(iter, 5, i + ' : ' + ar.listeners[i]);
1877 keys.forEach(function(i) {
1878 if (typeof(ar[i]) == 'object') {
1882 var type = provider.findType(ar, i, ar[i]);
1884 _this.el.append(iter);
1885 var p = _this.el.get_path(iter).to_string();
1887 _this.el.set_value(iter, 0, ''+i);
1888 _this.el.set_value(iter, 1, '' + ar[i]);
1889 _this.el.set_value(iter, 2, ''+i);
1890 _this.el.set_value(iter, 3, ''+ _this.toShort(ar[i]));
1891 _this.el.set_value(iter, 4, ''+type);
1892 _this.el.set_value(iter, 5, type + ' : ' + ar[i]);
1896 add : function(info) {
1897 // info includes key, val, skel, etype..
1899 type = info.type.toLowerCase();
1900 var data = this.toJS();
1902 if (info.etype == 'events') {
1903 data.listeners = data.listeners || { };
1904 if (typeof(data.listeners[info.key]) != 'undefined') {
1905 return; //already set!
1908 if (typeof(data[info.key]) != 'undefined') {
1913 if (typeof(info.val) == 'undefined') {
1916 if (info.type == 'boolean') {
1919 if (type == 'number') {
1927 if (info.etype == 'events') {
1929 data.listeners[info.key] = info.val;
1932 data[info.key] = info.val;
1936 var map = this.load(data);
1938 // flag it as changed to the interface..
1940 this.get('/LeftTree.model').changed(data, true);
1943 this.startEditing(map[k]);
1946 LeftPanel.get('view').el.row_activated(
1947 new Gtk.TreePath.from_string(map[k]),
1948 LeftPanel.editableColumn.el
1952 startEditing : function(path,col) {
1954 * start editing path (or selected if not set..)
1955 * @param {String|false} path (optional) treepath to edit - selected tree gets
1956 * edited by default.
1957 * @param {Number} 0 or 1 (optional)- column to edit.
1960 if (typeof(path) == 'string') {
1961 tp = new Gtk.TreePath.from_string(path);
1963 var iter = new Gtk.TreeIter();
1964 var s = this.get('/LeftPanel.view').selection;
1965 s.get_selected(this.el, iter);
1966 tp = this.el.get_path(iter);
1967 path = tp.to_string();
1971 // which colum is to be edited..
1973 if (typeof(col) == 'undefined') {
1974 var k = this.getValue(path, 0);
1975 colObj = (!k.length || k == '|') ?
1976 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1978 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1981 // make sure the pulldown is set correctly..
1982 // not really needed for second col...
1984 var provider = this.get('/LeftTree').getPaleteProvider();
1986 var type = this.get('/LeftPanel.model').getType(path);
1987 var opts = provider.findOptions(type);
1988 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1990 if (opts === false) {
1991 this.get('/LeftPanel').editableColumn.setOptions([]);
1992 renderer.has_entry = true; /// probably does not have any effect.
1994 this.get('/LeftPanel').editableColumn.setOptions(opts);
1995 renderer.has_entry = false;
1999 // iter now has row...
2000 GLib.timeout_add(0, 100, function() {
2002 colObj.items[0].el.editable = true; // esp. need for col 0..
2003 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
2012 deleteSelected : function() {
2013 var data = this.toJS();
2014 var iter = new Gtk.TreeIter();
2015 var s = this.get('/LeftPanel.view').selection;
2016 s.get_selected(this.el, iter);
2019 var gval = new GObject.Value('');
2020 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
2022 var val = gval.value;
2023 if (val[0] == '!') {
2025 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
2028 delete data.listeners[ val.substring(1)];
2029 if (!XObject.keys(data.listeners).length) {
2030 delete data.listeners;
2034 if (typeof(data[val]) == 'undefined') {
2042 this.get('/LeftTree.model').changed(data, true);
2046 changed : function(str, doRefresh) {
2047 if (!this.activePath) {
2050 var iter = new Gtk.TreeIter();
2051 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
2053 this.el.set_value(iter, 1, '' +str);
2054 this.el.set_value(iter, 3, '' + this.toShort(str));
2055 // update the tree...
2057 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
2060 var iter = new Gtk.TreeIter();
2061 this.get('/LeftPanel.model').el.get_iter_first(iter);
2066 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
2069 ar.listeners = ar.listeners || {};
2070 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
2073 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
2076 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
2082 //print(JSON.stringify(ar));
2086 getType : function(treepath) {
2087 return this.getValue(treepath, 4);
2089 getValue : function(treepath_str, col) {
2090 var iter = new Gtk.TreeIter();
2091 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
2093 var gval = new GObject.Value('');
2094 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
2095 var val = '' + gval.value;
2099 var type = this.getType(this.el.get_path(iter).to_string());
2100 print("TYPE: " +type + " - val:" + val);
2101 switch(type.toLowerCase()) {
2107 return parseFloat(val); // Nan ?? invalid!!?
2109 return val == 'true' ? true : false;
2115 editSelected : function(e) {
2116 print("EDIT SELECTED?");
2117 var iter = new Gtk.TreeIter();
2118 var s = this.get('/LeftPanel.view').selection;
2119 s.get_selected(this.get('/LeftPanel.model').el, iter);
2120 var m = this.get('/LeftPanel.model')
2122 var gval = new GObject.Value('');
2123 this.el.get_value(iter, 0 ,gval);
2124 var val = '' + gval.value;
2126 gval = new GObject.Value('');
2127 this.el.get_value(iter, 1 ,gval);
2128 var rval = gval.value;
2129 var activePath = this.el.get_path(iter).to_string();
2130 this.activePath = activePath ;
2131 // was activeIter...
2134 var showEditor = false;
2136 if (val[0] == '!') {
2139 if (val[0] == '|') {
2140 if (rval.match(/function/g) || rval.match(/\n/g)) {
2147 this.activePath = false;
2148 GLib.timeout_add(0, 1, function() {
2149 // Gdk.threads_enter();
2150 _this.get('/BottomPane').el.show();
2151 _this.get('/RightEditor').el.show();
2152 _this.get('/RightEditor.view').load( rval );
2156 _this.activePath = activePath ;
2158 // Gdk.threads_leave();
2163 this.get('/BottomPane').el.hide();
2164 this.get('/RightEditor').el.hide();
2166 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2172 xtype: Gtk.TreeViewColumn,
2173 pack : "append_column",
2175 XObject.prototype.init.call(this);
2177 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2178 this.get('/LeftPanel').propertyColumn = this;
2183 xtype: Gtk.CellRendererText,
2184 pack : "pack_start",
2186 editing_started : function (self, editable, path) {
2188 this.get('/LeftPanel.model').activePath = path;
2191 edited : function (self, object, p0) {
2192 var model = this.get('/LeftPanel.model');
2193 var path = model.activePath;
2194 var iter = new Gtk.TreeIter();
2195 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2196 model.el.set_value(iter, 0, p0);
2197 model.el.set_value(iter, 2, p0);
2199 model.activePath = false;
2201 this.get('/LeftTree.model').changed(model.toJS(), true);
2202 this.el.editable = false;
2209 xtype: Gtk.TreeViewColumn,
2210 pack : "append_column",
2212 XObject.prototype.init.call(this);
2213 this.el.add_attribute(this.items[0].el , 'text', 3 );
2214 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2215 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2216 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2218 this.get('/LeftPanel').editableColumn= this;
2220 setOptions : function(ar) {
2221 var m = this.items[0].el.model;
2223 var iter = new Gtk.TreeIter();
2224 ar.forEach(function(i) {
2227 m.set_value(iter, 0, i);
2233 xtype: Gtk.CellRendererCombo,
2234 pack : "pack_start",
2239 XObject.prototype.init.call(this);
2240 this.el.model = new Gtk.ListStore();
2241 this.el.model.set_column_types ( 1, [
2242 GObject.TYPE_STRING // 0 real key
2246 edited : function (self, object, p0) {
2247 this.get('/LeftPanel').editing = false;
2248 print("EDITED? p:" + p0 + " t:" + p0);
2249 this.get('/LeftPanel.model').changed(p0, true);
2250 this.get('/LeftPanel.model').activePath = false;
2252 editing_started : function (self, editable, path) {
2253 this.get('/LeftPanel').editing = true;
2254 // console.log('editing started');
2255 // r.has_entry = false;
2256 this.get('/LeftPanel.model').editSelected(editable);
2267 id : "LeftPanelPopup",
2270 xtype: Gtk.MenuItem,
2274 activate : function (self) {
2275 this.get('/LeftPanel.model').deleteSelected();
2280 xtype: Gtk.MenuItem,
2284 activate : function (self) {
2285 this.get('/LeftPanel.model').startEditing(false, 0);
2298 xtype: Gtk.ScrolledWindow,
2299 pack : "pack_end,false,true,0",
2301 shadow_type : Gtk.ShadowType.IN,
2303 XObject.prototype.init.call(this);
2304 XObject.prototype.init.call(this);
2305 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2306 this.el.set_size_request ( 150, -1 );
2309 activeElement : false,
2310 hideWin : function() {
2317 if (this.get('/Window.left').el.position < 160) {
2320 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2327 xtype: Gtk.TreeView,
2328 enable_tree_lines : true,
2329 headers_visible : false,
2332 XObject.prototype.init.call(this);
2334 var description = new Pango.FontDescription.c_new();
2335 description.set_size(8000);
2336 this.el.modify_font(description);
2338 //this.selection = this.el.get_selection();
2339 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2348 cursor_changed : function (self) {
2349 var iter = new Gtk.TreeIter();
2351 //console.log('changed');
2352 var m = this.get('model');
2353 if (!this.selection){
2354 this.selection = this.el.get_selection();
2357 var s = this.selection;
2358 if (!s.get_selected(m.el, iter)) {
2361 var tp = m.el.get_path(iter).to_string();
2366 var key = m.getValue(tp, 0);
2368 var type = m.getValue(tp, 1);
2369 var skel = m.getValue(tp, 3);
2370 var etype = m.getValue(tp, 5);
2373 this.get('/MidPropTree').hideWin();
2375 if (type == 'function') {
2377 if (etype != 'events') {
2381 this.get('/LeftPanel.model').add({
2390 if (type.indexOf('.') > -1 ||
2391 type == 'boolean') {
2395 this.get('/LeftPanel.model').add( {
2405 xtype: Gtk.ListStore,
2408 XObject.prototype.init.call(this);
2409 this.el.set_column_types ( 6, [
2410 GObject.TYPE_STRING, // real key
2411 GObject.TYPE_STRING, // real type
2412 GObject.TYPE_STRING, // docs ?
2413 GObject.TYPE_STRING, // visable desc
2414 GObject.TYPE_STRING, // function desc
2415 GObject.TYPE_STRING // element type (event|prop)
2419 getValue : function(treepath, col)
2421 var tp = new Gtk.TreePath.from_string (treepath);
2422 var iter = new Gtk.TreeIter();
2423 this.el.get_iter (iter, tp);
2424 var value = new GObject.Value('');
2425 this.el.get_value(iter, col, value);
2429 showData : function(type) {
2431 if (!this.get('/MidPropTree').activeElement || !type) {
2432 return; // no active element
2435 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2436 var palete = this.get('/LeftTree').getPaleteProvider();
2440 Seed.print('Showing right?');
2441 if (!this.get('/MidPropTree').shown) {
2443 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2444 this.get('/MidPropTree').el.show();
2445 this.get('/MidPropTree').shown = true;
2448 var elementList = palete.getPropertiesFor(fullpath, type);
2449 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2450 // console.dump(elementList);
2453 var iter = new Gtk.TreeIter();
2454 for(var i =0 ; i < elementList.length; i++) {
2455 var p=elementList[i];
2456 this.el.append(iter);
2457 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2458 //GObject.TYPE_STRING, // real key
2459 // GObject.TYPE_STRING, // real type
2460 // GObject.TYPE_STRING, // docs ?
2461 // GObject.TYPE_STRING // func def?
2464 this.el.set_value(iter, 0, p.name);
2465 this.el.set_value(iter, 1, p.type);
2466 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2467 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2468 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2469 this.el.set_value(iter, 5, type);
2477 xtype: Gtk.TreeViewColumn,
2479 this.el = new Gtk.TreeViewColumn();
2480 this.parent.el.append_column(this.el);
2482 XObject.prototype.init.call(this);
2483 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2488 xtype: Gtk.CellRendererText,
2489 pack : "pack_start,true"
2513 xtype: Gtk.Notebook,
2514 pack : "pack_start,true,true",
2515 id : "view-help-nb",
2517 XObject.prototype.init.call(this);
2518 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" }));
2519 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" }));
2523 xtype: Gtk.Notebook,
2525 id : "view-notebook",
2528 XObject.prototype.init.call(this);
2529 this.el.set_current_page(0);
2531 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2532 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2539 id : "RightBrowser",
2546 pack : "pack_start,false,true,0",
2550 pack : "pack_start,false,false,0",
2553 button_press_event : function (self, event) {
2554 var js = this.get('/LeftTree.model').toJS();
2556 this.get('/RightBrowser.view').renderJS(js[0]);
2564 pack : "pack_start,false,false,0",
2565 label : "Set extra HTML in render",
2567 button_press_event : function (self, event) {
2568 this.get('/RooProjectProperties').show();
2575 pack : "pack_start,false,false,0",
2576 label : "test in Firefox",
2578 button_press_event : function (self, event)
2580 /* Firefox testing for debugging..
2581 - we can create a /tmp directory, and put.
2582 builder.html, builder.html.js, link roojs1
2583 add at the end of builder.html Roo.onload(function() {
2585 if (!this.get('/Window.LeftTree').getActiveFile()) {
2589 var js = this.get('/LeftTree.model').toJS();
2590 if (!js || !js[0]) {
2593 var project = this.get('/Window.LeftTree').getActiveFile().project;
2594 //print (project.fn);
2596 project.runhtml = project.runhtml || '';
2599 var File = imports.File.File;
2601 var target = "/tmp/firetest"; // fixme..
2602 if (!File.isDirectory(target)) {
2605 File.copy(__script_path__ + '/../builder.html.js', target+ '/builder.html.js', Gio.FileCopyFlags.OVERWRITE);
2606 if (!File.exists( target+ '/roojs1')) {
2607 File.link( target+ '/roojs1', __script_path__ + '/../roojs1');
2612 var html = imports.File.File.read(__script_path__ + '/../builder.html');
2613 html = html.replace('</head>', project.runhtml + '</head>');
2616 var jsstr = JSON.stringify(js[0]);
2618 var runbuilder = '<script type="text/javascript">' + "\n" +
2619 " Builder.render(" + jsstr + ");\n" +
2622 html = html.replace('</body>', runbuilder + '</body>');
2624 File.write( target+ '/builder.html', html);
2626 this.get('/Terminal').feed("RUN DIR:" + target);
2628 this.get('/Terminal').el.fork_command( null , [], [], target
2629 , false,false,false);
2630 var cmd = "firefox file://" + target + "/builder.html \n";
2631 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2639 xtype: Gtk.ScrolledWindow,
2641 shadow_type : Gtk.ShadowType.IN,
2643 XObject.prototype.init.call(this);
2644 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2648 xtype: WebKit.WebView,
2652 XObject.prototype.init.call(this);
2653 // this may not work!?
2654 this.el.open('file:///' + __script_path__ + '/../builder.html');
2658 this.el, /* widget that will accept a drop */
2659 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2660 null, /* lists of target to support */
2661 0, /* size of list */
2662 Gdk.DragAction.COPY /* what to do with data after dropped */
2665 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2666 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2668 renderJS : function(data) {
2669 print("HTML RENDERING");
2670 /// prevent looping..
2671 //if (this.pendingRedraw) {
2672 // print("pending redraw active?!");
2677 if (!this.get('/Window.LeftTree').getActiveFile()) {
2681 var project = this.get('/Window.LeftTree').getActiveFile().project;
2682 //print (project.fn);
2684 project.runhtml = project.runhtml || '';
2687 this.runhtml = this.runhtml || '';
2689 if (project.runhtml != this.runhtml) {
2690 // then we need to reload the browser using
2691 // load_html_string..
2693 // then trigger a redraw once it's loaded..
2694 this.pendingRedraw = true;
2696 this.runhtml = project.runhtml;
2698 var html = imports.File.File.read(__script_path__ + '/../builder.html');
2699 html = html.replace('</head>', this.runhtml + '</head>');
2700 print("LOAD HTML " + html);
2701 this.el.load_html_string( html , 'file:///' + __script_path__ + '/../builder.html');
2702 // should trigger load_finished!
2707 this.pendingRedraw = false;
2710 this.renderedData = data;
2711 var str = JSON.stringify(data) ;
2714 console.log('not loaded yet');
2716 //Seed.print("RENDER:" + str);
2717 //imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2719 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2722 load_finished : function (self, object) {
2723 // if (this.ready) { // dont do it twice!
2727 this.pendingRedraw = false;
2728 var js = this.get('/LeftTree.model').toJS();
2730 this.renderJS(js[0]);
2734 script_alert : function (self, object, p0) {
2737 return true; // do not display anything...
2739 console_message : function (self, object, p0, p1) {
2740 // console.log(object);
2741 if (!object.match(/^\{/)) {
2743 this.get('/Terminal').feed(object);
2744 return true; // do not handle!!! -> later maybe in console..
2746 // console.log(object);
2747 var val = JSON.parse(object);
2749 if (typeof(val['hover-node']) != 'undefined') {
2750 this.activeNode = val['hover-node'];
2751 console.log('active node: ' + this.activeNode);
2756 if (typeof(val['id']) != 'undefined') {
2757 // this.activeNode = val['id'];
2758 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2762 this.get('/LeftTree.view').selectNode(tg[0]);
2766 if (ret && typeof(val['set']) != 'undefined') {
2767 this.get('/LeftPanel.model').add({
2771 //console.log('active node: ' + this.activeNode);
2774 //Seed.print('a:'+a);
2775 //Seed.print('b:'+b);
2776 //Seed.print('c:'+c);
2779 drag_motion : function (w, ctx, x, y, time, ud) {
2780 // console.log('DRAG MOTION');
2782 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2783 this.targetData = [];
2784 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2786 // A) find out from drag all the places that node could be dropped.
2787 var src = Gtk.drag_get_source_widget(ctx);
2788 if (!src.dropList) {
2789 Gdk.drag_status(ctx, 0, time);
2792 // b) get what we are over.. (from activeNode)
2793 // tree is empty.. - list should be correct..
2794 if (!this.get('/LeftTree.model').currentTree) {
2795 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2799 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2801 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2804 Gdk.drag_status(ctx, 0,time);
2805 this.get('/LeftTree.view').highlight(false);
2809 // if we have a target..
2810 // -> highlight it! (in browser)
2811 // -> highlight it! (in tree)
2813 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2814 this.get('/LeftTree.view').highlight(tg);
2815 this.targetData = tg;
2816 // for tree we should handle this...
2819 drag_drop : function (w, ctx, x, y,time, ud) {
2820 print("TARGET: drag-drop");
2821 var is_valid_drop_site = true;
2826 w, /* will receive 'drag-data-received' signal */
2827 ctx, /* represents the current state of the DnD */
2828 this.get('/Window').atoms["STRING"], /* the target type we want */
2829 time /* time stamp */
2833 /* No target offered by source => error */
2836 return is_valid_drop_site;
2838 drag_data_received : function (w, ctx, x, y, sel_data, target_type, time, ud)
2840 print("Browser: drag-data-received");
2841 var delete_selection_data = false;
2842 vardnd_success = false;
2843 /* Deal with what we are given from source */
2844 if( sel_data && sel_data.length ) {
2846 if (ctx.action == Gdk.DragAction.ASK) {
2847 /* Ask the user to move or copy, then set the ctx action. */
2850 if (ctx.action == Gdk.DragAction.MOVE) {
2851 delete_selection_data = true;
2853 var source = Gtk.drag_get_source_widget(ctx);
2855 print("Browser: source.DRAGDATA? " + source.dragData);
2856 if (this.targetData) {
2857 print(this.targetData);
2858 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2867 if (dnd_success == false)
2869 Seed.print ("DnD data transfer failed!\n");
2872 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2884 id : "RightGtkView",
2885 renderJS : function(data, withDebug)
2887 this.highlightWidget = false;
2891 this.withDebug = false;
2893 if (this.renderedEl) {
2894 this.get('view').el.remove(this.renderedEl);
2895 this.renderedEl.destroy();
2896 this.renderedEl = false;
2899 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2900 // in theory tree is actually window..
2902 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2907 this.get('view').el.set_size_request(
2908 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2911 this.renderedEl.set_size_request(
2912 tree.default_width || 600,
2913 tree.default_height || 400
2915 this.get('view').el.show_all();
2920 showInWindow : function() {
2921 print("GET PROEJCT");
2922 var pr = this.get('/LeftProjectTree').getActiveProject();
2924 console.log(pr.paths);
2927 var src= this.buildJS(
2928 this.get('/LeftTree.model').toJS()[0],
2933 //var x = new imports.sandbox.Context();
2937 Seed.check_syntax('var e = ' + src);
2940 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2941 this.get('/Terminal').feed(console._dump(e)+"\n");
2943 var lines = src.split("\n");
2944 var start = Math.max(0, e.line - 10);
2945 var end = Math.min(lines.length, e.line + 10);
2946 for (var i =start ; i < end; i++) {
2948 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2951 this.get('/Terminal').feed(lines[i] + "\n");
2958 this.get('/BottomPane').el.set_current_page(1);
2959 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2960 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2961 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2963 var _top = x.get_global_object()._top;
2965 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2967 if (_top.el.popup) {
2968 _top.el.popup(null, null, null, null, 3, null);
2972 viewAdd : function(item, par)
2974 // does something similar to xobject..
2975 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2977 if (item.pack===false || item.pack === 'false') { // no ;
2980 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2981 var ns = imports.gi[item['|xns']];
2982 var ctr = ns[item['xtype']];
2984 for(var k in item) {
2986 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
3001 if (k[0] == '|' && typeof(kv) == 'string') {
3003 if (kv.match(new RegExp('function'))) {
3006 print("WASL " + k + '=' + kv);
3008 eval( 'kv = ' + kv);
3009 } catch(e) { continue; }
3012 // print(k + '=' + kv);
3014 if (k[0] == '|') { // should be boolean or number..
3016 //print(k + '=' + kv);
3019 if (k == 'show_tabs') { // force tab showing for notebooks.
3022 print(k + '=' + typeof(kv) + " : " + kv);
3028 var el = new ctr(ctr_args);
3031 //console.dump(item.pack);
3038 if (typeof(item.pack) == 'string') {
3040 item.pack.split(',').forEach(function(e, i) {
3042 if (e == 'false') { args.push( false); return; }
3043 if (e == 'true') { args.push( true); return; }
3044 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
3047 //print(args.join(","));
3049 pack_m = args.shift();
3051 pack_m = item.pack.shift();
3056 if (pack_m && typeof(par[pack_m]) == 'undefined') {
3058 name: "ArgumentError",
3059 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
3060 "ADDING : " + item.id + " " + el
3069 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
3070 //Seed.print('args: ' + args.length);
3072 par[pack_m].apply(par, args);
3076 item.items = item.items || [];
3077 item.items.forEach(function(ch) {
3078 _this.viewAdd(ch, el);
3083 // add the signal handlers.
3084 // is it a widget!?!!?
3090 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
3091 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
3092 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
3093 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
3094 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
3104 widgetExposeEvent : function(w, evt, ud, item) {
3106 if (this.inRender) {
3110 if ( this.highlightWidget) {
3111 this.inRender = true;
3112 if (item.xtreepath.substring(0, this.activePath.length) == this.activePath) {
3113 Gdk.draw_rectangle(this.highlightWidget.window, this.gc, false, this.box.x , this.box.y, this.box.w, this.box.h);
3115 this.inRender = false;
3120 if (this.activePath != item.xtreepath) {
3124 // print("HIGHLIGHT: " + item.xtreepath ); // draw highlight??
3125 // work out the coords of the window..
3127 var dr = widget.window;
3128 this.gc = (new Gdk.GC.c_new(dr));
3129 this.gc.set_rgb_fg_color(new Gdk.Color({ red: 0xFFFF, green: 0, blue : 0 }));
3130 this.gc.set_line_attributes(4, Gdk.LineStyle.SOLID, Gdk.CapStyle.ROUND , Gdk.JoinStyle.ROUND);
3134 var r = evt.expose.area;
3135 // console.dump([r.x, r.y, r.width, r.height ] );
3137 // print(widget.get_parent().toString().match(/GtkScrolledWindow/);
3138 if (widget.get_parent().toString().match(/GtkScrolledWindow/)) { // eak
3139 // happens with gtkscrollview embedded stuff..
3140 var np =this.activePath.split(':');
3142 this.activePath = np.join(':');
3143 this.renderedEl.queue_draw();
3159 this.inRender = true;
3162 this.highlightWidget = widget;
3167 // print("DRAW BOX");
3168 //console.dump(this.box);
3169 Gdk.draw_rectangle(widget.window, this.gc, false, this.box.x , this.box.y, this.box.w,this.box.h);
3170 this.inRender = false;
3173 widgetDragMotionEvent : function() {
3174 print("WIDGET DRAGMOTION");
3177 widgetDragDropEvent : function() {
3178 print("WIDGET DRAGDROP");
3181 widgetPressEvent : function(w,e,u,d) {
3182 if (this.get('view').pressed) {
3185 this.get('view').pressed = true;
3186 print("WIDGET PRESS " + d.xtreepath );
3187 this.get('/LeftTree.view').selectNode( d.xtreepath );
3190 widgetReleaseEvent : function() {
3191 this.get('view').pressed = false;
3194 redraw : function() {
3195 this.highlightWidget = false;
3196 print("REDRAW CALLED");
3197 this.activePath = this.get('/LeftTree').getActivePath();
3198 if (this.renderedEl) {
3199 print("QUEUE DRAW CALLING");
3200 this.renderedEl.queue_draw();
3206 pack : "pack_start,false,true,0",
3210 pack : "pack_start,false,false,0",
3211 label : "Run The Application",
3213 button_press_event : function (self, event) {
3214 // call render on left tree - with special option!?!
3216 //print("GET PROEJCT");
3217 var pr = this.get('/LeftProjectTree').getActiveProject();
3220 for (var i in pr.paths) {
3224 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
3225 this.get('/Terminal').feed("RUN DIR:" + dir);
3227 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
3228 , false,false,false);
3229 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
3230 this.get('/Terminal').el.feed_child(cmd, cmd.length);
3240 xtype: Gtk.ScrolledWindow,
3243 shadow_type : Gtk.ShadowType.IN,
3245 XObject.prototype.init.call(this);
3246 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3250 xtype: Gtk.EventBox,
3251 pack : "add_with_viewport",
3253 XObject.prototype.init.call(this);
3254 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
3255 red: 0x9F00, green: 0xB800 , blue : 0xA800
3263 XObject.prototype.init.call(this);
3264 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
3265 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
3270 xtype: Gtk.EventBox,
3273 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
3274 XObject.prototype.init.call(this);
3278 this.el, /* widget that will accept a drop */
3279 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
3280 null, /* lists of target to support */
3281 0, /* size of list */
3282 Gdk.DragAction.COPY /* what to do with data after dropped */
3285 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
3286 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
3289 getActiveNode : function(x,y)
3291 // workout what node is here..
3292 return '0'; // top..
3296 drag_motion : function (self, ctx, x, y, time) {
3298 // A) find out from drag all the places that node could be dropped.
3299 var src = Gtk.drag_get_source_widget(ctx);
3300 if (!src.dropList) {
3301 Gdk.drag_status(ctx, 0, time);
3304 // b) get what we are over.. (from activeNode)
3305 // tree is empty.. - list should be correct..
3306 if (!this.get('/LeftTree.model').currentTree) {
3307 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3311 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
3312 var activeNode = this.getActiveNode(x, y);
3315 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
3318 Gdk.drag_status(ctx, 0,time);
3319 this.get('/LeftTree.view').highlight(false);
3323 // if we have a target..
3324 // -> highlight it! (in browser)
3325 // -> highlight it! (in tree)
3327 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3328 this.get('/LeftTree.view').highlight(tg);
3329 this.targetData = tg;
3330 // for tree we should handle this...
3333 drag_drop : function (self,ctx, x, y, time) {
3334 Seed.print("TARGET: drag-drop");
3335 var is_valid_drop_site = true;
3340 self, /* will receive 'drag-data-received' signal */
3341 ctx, /* represents the current state of the this.gDnD */
3342 this.get('/Window').atoms["STRING"], /* the target type we want */
3343 time /* time stamp */
3347 /* No target offered by source => error */
3350 return is_valid_drop_site;
3353 drag_data_received : function (w, ctx, x, y, sel_data, target_type, time, ud)
3355 Seed.print("GtkView: drag-data-received");
3356 var delete_selection_data = false;
3357 var dnd_success = false;
3358 /* Deal with what we are given from source */
3359 if( sel_data && sel_data.length ) {
3361 if (ctx.action == Gdk.DragAction.ASK) {
3362 /* Ask the user to move or copy, then set the ctx action. */
3365 if (ctx.action == Gdk.DragAction.MOVE) {
3366 delete_selection_data = true;
3368 var source = Gtk.drag_get_source_widget(ctx);
3370 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3371 if (this.targetData) {
3372 Seed.print(this.targetData);
3373 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3382 if (dnd_success == false)
3384 Seed.print ("DnD data transfer failed!\n");
3387 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3390 button_press_event : function (self, event) {
3391 this.pressed = false;
3407 xtype: Gtk.ScrolledWindow,
3412 var file = this.get('/LeftTree').getActiveFile();
3416 var activeEl = this.get('/LeftTree').getActiveElement();
3417 var xtype = file.guessName( activeEl )
3418 if (!xtype || !xtype.length) {
3421 this.get('/Window.view-help-nb').el.set_current_page(1);
3423 // get the active element being edited.
3424 var helpurl = file.getHelpUrl(xtype);
3426 // now load the help info in the page..
3427 this.get('help-view').el.open(helpurl);
3431 xtype: WebKit.WebView,
3435 XObject.prototype.init.call(this);
3436 this.get('/Window.help-view').el.open(
3437 "http://devel.akbkhome.com/seed/");
3449 xtype: Gtk.Notebook,
3452 XObject.prototype.init.call(this);
3453 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3454 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3459 xtype: Gtk.ScrolledWindow,
3464 xtype: GtkSource.View,
3468 XObject.prototype.init.call(this);
3469 var description = Pango.Font.description_from_string("monospace")
3470 description.set_size(8000);
3471 this.el.modify_font(description);
3474 load : function(str) {
3476 // show the help page for the active node..
3477 this.get('/Help').show();
3480 this.get('/BottomPane').el.set_current_page(0);
3481 this.el.get_buffer().set_text(str, str.length);
3482 var lm = GtkSource.LanguageManager.get_default();
3484 this.el.get_buffer().set_language(lm.get_language('js'));
3485 var buf = this.el.get_buffer();
3486 var cursor = buf.get_mark("insert");
3487 var iter= new Gtk.TextIter;
3488 buf.get_iter_at_mark(iter, cursor);
3490 iter.set_line_offset(4);
3491 buf.move_mark(cursor, iter);
3494 cursor = buf.get_mark("selection_bound");
3495 iter= new Gtk.TextIter;
3496 buf.get_iter_at_mark(iter, cursor);
3498 iter.set_line_offset(4);
3499 buf.move_mark(cursor, iter);
3501 this.el.grab_focus();
3503 insert_spaces_instead_of_tabs : true,
3506 show_line_numbers : true,
3509 xtype: GtkSource.Buffer,
3510 pack : "set_buffer",
3512 changed : function (self) {
3513 var s = new Gtk.TextIter();
3514 var e = new Gtk.TextIter();
3515 this.el.get_start_iter(s);
3516 this.el.get_end_iter(e);
3517 var str = this.el.get_text(s,e,true);
3519 Seed.check_syntax('var e = ' + str);
3521 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3522 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3524 print("SYNTAX ERROR IN EDITOR");
3529 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3530 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3533 this.get('/LeftPanel.model').changed( str , false);
3542 xtype: Gtk.ScrolledWindow,
3546 xtype: Vte.Terminal,
3549 feed : function(istr) {
3550 var str = istr.replace(/\n/g, "\r\n") + "\r\n";
3551 // we should make ourselves visable!!!
3552 this.get('/BottomPane').el.show();
3553 this.get('/BottomPane').el.set_current_page(1);
3555 this.el.feed(str ,str.length);
3557 scroll_on_output : true,
3559 XObject.prototype.init.call(this);
3560 this.el.set_size (80, 1000);
3562 scrollback_lines : 1000
3572 pack : "pack_start,false,false",
3576 this.get('buttonbar').el.show();
3577 this.get('viewbox').el.hide();
3578 print("TRIED TO HIDE");
3581 this.get('buttonbar').el.hide();
3582 this.get('viewbox').el.show();
3583 // this.get('model').expanded();
3595 pack : "pack_start,false,true",
3597 clicked : function (self) {
3598 this.get('/RightPalete').show();
3605 stock : Gtk.STOCK_GOTO_FIRST,
3606 icon_size : Gtk.IconSize.MENU
3616 XObject.prototype.init.call(this);
3617 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3620 enter_notify_event : function (self, event) {
3621 this.get('/RightPalete').show();
3635 pack : "pack_start,false,true",
3644 pack : "pack_start,false,true",
3646 clicked : function (self) {
3647 this.get('/RightPalete').hide();
3654 stock : Gtk.STOCK_GOTO_LAST,
3655 icon_size : Gtk.IconSize.MENU
3662 xtype: Gtk.ScrolledWindow,
3665 XObject.prototype.init.call(this);
3666 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3667 this.el.set_size_request(-1,200);
3669 shadow_type : Gtk.ShadowType.IN,
3672 xtype: Gtk.TreeView,
3675 XObject.prototype.init.call(this);
3676 this.el.set_size_request(150,-1);
3677 // set_reorderable: [1]
3679 var description = new Pango.FontDescription.c_new();
3680 description.set_size(8000);
3681 this.el.modify_font(description);
3683 this.selection = this.el.get_selection();
3684 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3685 // this.selection.signal['changed'].connect(function() {
3686 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3688 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3690 Gtk.drag_source_set (
3691 this.el, /* widget will be drag-able */
3692 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3693 null, /* lists of target to support */
3694 0, /* size of list */
3695 Gdk.DragAction.COPY /* what to do with data after dropped */
3697 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3699 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3700 Gtk.drag_source_add_text_targets(this.el);
3702 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3703 targets = new Gtk.TargetList();
3704 targets.add( LeftTree.atoms["STRING"], 0, 0);
3705 targets.add_text_targets( 1 );
3706 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3708 //if you want to allow text to be output elsewhere..
3709 //Gtk.drag_source_add_text_targets(this.el);
3713 headers_visible : false,
3714 enable_tree_lines : true,
3716 drag_begin : function (self, ctx) {
3717 // we could fill this in now...
3718 Seed.print('SOURCE: drag-begin');
3722 var iter = new Gtk.TreeIter();
3723 var s = this.selection;
3724 s.get_selected(this.get('/RightPalete.model').el, iter);
3725 var path = this.get('/RightPalete.model').el.get_path(iter);
3727 var pix = this.el.create_row_drag_icon ( path);
3730 Gtk.drag_set_icon_pixmap (ctx,
3737 var value = new GObject.Value('');
3738 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3739 if (!this.get('/RightPalete').provider) {
3742 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3743 this.el.dragData = value.value;
3750 drag_data_get : function (self, drag_context, selection_data, info, time) {
3751 //Seed.print('Palete: drag-data-get: ' + target_type);
3752 if (this.el.dragData && this.el.dragData.length ) {
3753 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3757 //this.el.dragData = "TEST from source widget";
3761 drag_end : function (self, drag_context) {
3762 Seed.print('SOURCE: drag-end');
3763 this.el.dragData = false;
3764 this.el.dropList = false;
3765 this.get('/LeftTree.view').highlight(false);
3771 xtype: Gtk.ListStore,
3774 XObject.prototype.init.call(this);
3775 this.el.set_column_types ( 2, [
3776 GObject.TYPE_STRING, // title
3777 GObject.TYPE_STRING // tip
3782 load : function(tr,iter)
3787 //console.log('Project tree load: ' + tr.length);
3788 var citer = new Gtk.TreeIter();
3789 //this.insert(citer,iter,0);
3790 for(var i =0 ; i < tr.length; i++) {
3793 this.el.append(citer);
3795 this.el.insert(citer,iter,-1);
3800 this.el.set_value(citer, 0, '' + r ); // title
3802 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3803 //if (r.cn && r.cn.length) {
3804 // this.load(r.cn, citer);
3810 getValue : function (iter, col) {
3811 var gval = new GObject.Value('');
3812 this.el.get_value(iter, col ,gval);
3819 xtype: Gtk.TreeViewColumn,
3820 pack : "append_column",
3822 XObject.prototype.init.call(this);
3823 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3827 xtype: Gtk.CellRendererText,
3849 XObject.cache['/Window'] = Window;