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) {
178 label : "Select Project",
180 pack : "pack_start,false,true",
182 XObject.prototype.init.call(this);
183 this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
186 "activate":function (self) {
187 var nb = this.get('/LeftTopPanel.notebook');
188 if (this.el.expanded) {
191 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
194 var model = this.get('/LeftProjectTree.combomodel');
195 // print ("loading Projects?")
196 //console.dump(pm.projects);
197 model.loadData(pm.projects);
200 nb.el.set_current_page(1);
201 //pm.on('changed', function() {
202 //console.log("CAUGHT project manager change");
203 // _combo.model.loadData(pm.projects);
207 nb.el.set_current_page(0);
209 "enter_notify_event":function (self, event) {
210 this.el.expanded = !this.el.expanded;
211 //if (this.el.expanded ) {
212 this.listeners.activate.call(this);
224 pack : "pack_start,true,true",
226 XObject.prototype.init.call(this);
227 this.el.set_current_page(0);
232 xtype: Gtk.ScrolledWindow,
234 shadow_type : Gtk.ShadowType.IN,
236 XObject.prototype.init.call(this);
237 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
240 getPaleteProvider : function() {
241 var model = this.get('model');
242 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
243 return pm.getPalete(model.file.getType());
245 renderView : function() {
246 var render = this.getRenderer();
247 var model = this.get('model');
249 render.renderJS(model.toJS(false,true)[0]);
251 print("NO RENDER JS METHOD?");
254 getRenderer : function() {
256 switch( this.getActiveFile().getType()) {
258 return this.get('/RightBrowser.view');
260 return this.get('/RightGtkView');
264 getActivePath : function() {
265 var model = this.get('model');
266 var view = this.get('view');
267 if (view.selection.count_selected_rows() < 1) {
270 var iter = new Gtk.TreeIter();
272 view.selection.get_selected(model.el, iter);
273 return model.el.get_path(iter).to_string();
275 getActiveFile : function() {
276 return this.get('model').file;
283 headers_visible : false,
284 enable_tree_lines : true,
287 XObject.prototype.init.call(this);
288 var description = new Pango.FontDescription.c_new();
289 description.set_size(8000);
290 this.el.modify_font(description);
292 this.selection = this.el.get_selection();
293 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
296 // is this really needed??
297 this.selection.signal['changed'].connect(function() {
298 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
299 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
303 Gtk.drag_source_set (
304 this.el, /* widget will be drag-able */
305 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
306 null, /* lists of target to support */
307 0, /* size of list */
308 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
311 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
313 Gtk.drag_source_add_text_targets(this.el);
316 this.el, /* widget that will accept a drop */
317 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
318 null, /* lists of target to support */
319 0, /* size of list */
320 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
323 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
324 Gtk.drag_dest_add_text_targets(this.el);
326 highlight : function(treepath_ar) {
328 // highlighting for drag/drop
329 if (treepath_ar.length && treepath_ar[0].length ) {
330 this.el.set_drag_dest_row(
331 new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);
333 this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
337 selectNode : function(treepath_str) {
338 //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
339 var tp = new Gtk.TreePath.from_string(treepath_str);
340 this.el.set_cursor(tp, null, false);
341 this.el.scroll_to_cell(tp, null, false, 0,0);
344 "button_press_event":function (self, ev) {
345 console.log("button press?");
346 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
347 print("click" + ev.type);
353 this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
355 if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();
357 this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
358 this.get('/LeftTreeMenu').el.show_all();
359 this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
360 print("click:" + res.path.to_string());
363 "drag_begin":function (self, drag_context) {
364 print('SOURCE: drag-begin');
365 this.targetData = false;
366 // find what is selected in our tree...
367 var iter = new Gtk.TreeIter();
368 var s = this.selection;
369 s.get_selected(this.get('/LeftTree.model').el, iter);
371 // set some properties of the tree for use by the dropped element.
372 var value = new GObject.Value('');
373 this.get('/LeftTree.model').el.get_value(iter, 2, value);
374 var data = JSON.parse(value.value);
375 var xname = this.get('/LeftTree.model').file.guessName(data);
377 this.el.dragData = xname;
378 this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);
381 // make the drag icon a picture of the node that was selected
382 var path = this.get('/LeftTree.model').el.get_path(iter);
383 this.el.treepath = path.to_string();
385 var pix = this.el.create_row_drag_icon ( path);
387 Gtk.drag_set_icon_pixmap (ctx,
396 "drag_end":function (self, drag_context) {
397 Seed.print('LEFT-TREE: drag-end');
398 this.el.dragData = false;
399 this.el.dropList = false;
400 this.targetData = false;
401 this.get('/LeftTree.view').highlight(false);
404 "drag_motion":function (self, ctx, x, y, time) {
405 console.log("LEFT-TREE: drag-motion");
406 var src = Gtk.drag_get_source_widget(ctx);
408 // a drag from elsewhere...- prevent drop..
410 print("no drag data!");
411 Gdk.drag_status(ctx, 0, time);
412 this.targetData = false;
415 var action = Gdk.DragAction.COPY;
416 if (src == this.el) {
417 // unless we are copying!!! ctl button..
418 action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
422 if (!this.get('/LeftTree.model').el.iter_n_children(null)) {
423 // no children.. -- asume it's ok..
424 this.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];
425 Gdk.drag_status(ctx, action ,time);
429 print("GETTING POS");
430 var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);
431 print("ISOVER? " + isOver);
433 Gdk.drag_status(ctx, 0 ,time);
434 return false; // not over apoint!?!
436 // drag node is parent of child..
437 console.log("SRC TREEPATH: " + src.treepath);
438 console.log("TARGET TREEPATH: " + data.path.to_string());
440 // nned to check a few here..
441 //Gtk.TreeViewDropPosition.INTO_OR_AFTER
442 //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
443 //Gtk.TreeViewDropPosition.AFTER
444 //Gtk.TreeViewDropPosition.BEFORE
446 if (typeof(src.treepath) != 'undefined' &&
447 src.treepath == data.path.to_string().substring(0,src.treepath.length)) {
448 print("subpath drag");
449 Gdk.drag_status(ctx, 0 ,time);
454 //print("DUMPING DATA");
455 //console.dump(data);
458 print(data.path.to_string() +' => '+ data.pos);
459 var tg = this.get('/LeftTree.model').findDropNodeByPath(
460 data.path.to_string(), src.dropList, data.pos);
462 this.get('/LeftTree.view').highlight(tg);
464 print("Can not find drop node path");
465 this.targetData = false;
466 Gdk.drag_status(ctx, 0, time);
470 this.targetData = tg;
473 Gdk.drag_status(ctx, action ,time);
477 "drag_drop":function (w, ctx, x, y, time) {
478 Seed.print("TARGET: drag-drop");
482 w, /* will receive 'drag-data-received' signal */
483 ctx, /* represents the current state of the DnD */
484 this.get('/Window').atoms["STRING"], /* the target type we want */
485 time /* time stamp */
489 /* No target offered by source => error */
494 "drag_data_received":function (self, ctx, x, y, sel_data, info, time) {
495 print("Tree: drag-data-received");
497 var delete_selection_data = false;
498 var dnd_success = false;
499 /* Deal with what we are given from source */
500 if( sel_data && sel_data.length ) {
502 if (ctx.action == Gdk.DragAction.ASK) {
503 /* Ask the user to move or copy, then set the ctx action. */
506 if (ctx.action == Gdk.DragAction.MOVE) {
507 //delete_selection_data = true;
510 var source = Gtk.drag_get_source_widget(ctx);
512 if (this.targetData) {
513 if (source != this.el) {
514 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
516 // drag around.. - reorder..
517 this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);
521 //Seed.print(this.targetData);
527 // we can send stuff to souce here...
533 if (dnd_success == false)
535 Seed.print ("DnD data transfer failed!\n");
538 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
541 "cursor_changed":function (self) {
542 if (this.blockChanges) { // probably not needed..
545 var render = this.get('/LeftTree').getRenderer();
548 if (this.selection.count_selected_rows() < 1) {
549 this.get('/LeftPanel.model').load( false);
550 this.get('/MidPropTree').activeElement = false;
551 this.get('/MidPropTree').hideWin();
553 var pm = this.get('/RightPalete.model');
554 if (!this.get('/LeftTree').getPaleteProvider()) {
555 // it may not be loaded yet..
558 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
559 this.get('/LeftTree.model').listAllTypes()));
560 if (render && render.redraw) {
566 //console.log('changed');
567 var s = this.selection;
568 var iter = new Gtk.TreeIter();
569 s.get_selected(this.get('/LeftTree.model').el, iter);
573 var value = new GObject.Value('');
574 this.get('/LeftTree.model').el.get_value(iter, 2, value);
575 this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
577 var data = JSON.parse(value.value);
578 this.get('/MidPropTree').activeElement = data;
579 this.get('/MidPropTree').hideWin();
580 this.get('/LeftPanel.model').load( data);
582 console.log(value.value);
583 // _g.button.set_label(''+value.get_string());
585 var pm =this.get('/RightPalete.model');
586 pm.load( this.get('/RightPalete').provider.gatherList(
587 this.get('/LeftTree.model').listAllTypes()));
590 if (render && render.redraw) {
594 //Seed.print( value.get_string());
601 xtype: Gtk.TreeStore,
605 XObject.prototype.init.call(this);
606 this.el.set_column_types ( 3, [
607 GObject.TYPE_STRING, // title
608 GObject.TYPE_STRING, // tip
609 GObject.TYPE_STRING // source..
613 changed : function(n, refresh) {
614 print("MODEL CHANGED CALLED" + this.activePath);
615 if (this.activePath) {
616 var iter = new Gtk.TreeIter();
617 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
618 this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
619 this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
621 this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
623 //this.currentTree = this.toJS(false, true)[0];
624 this.file.items = this.toJS(false, false);
625 print("AFTER CHANGED");
626 //console.dump(this.file.items);
628 this.currentTree = this.file.items[0];
629 //console.log(this.file.toSource());
632 print("REDNER BROWSER?!");
633 this.get('/LeftTree').renderView();
635 var pm = this.get('/RightPalete.model');
636 if (!this.get('/RightPalete').provider) {
642 pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
643 //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
647 loadFile : function(f) {
653 console.log('missing file');
657 // load the file if not loaded..
658 if (f.items === false) {
660 f.loadItems(function() {
666 if (f.items.length && typeof(f.items[0]) == 'string') {
668 this.get('/RightEditor').el.show();
669 this.get('/RightEditor.view').load( f.items[0]);
673 //console.dump(f.items);
675 this.get('/LeftTree.view').el.expand_all();
677 if (!f.items.length) {
680 this.get('/Window.leftvpaned').el.set_position(80);
682 this.get('/LeftTree.view').el.set_cursor(
683 new Gtk.TreePath.from_string('0'), null, false);
687 this.get('/Window.leftvpaned').el.set_position(200);
691 //print("hide right editior");
692 this.get('/RightEditor').el.hide();
693 //print("set current tree");
694 this.currentTree = this.toJS(false, false)[0];
695 //console.dump(this.currentTree);
696 this.currentTree = this.currentTree || { items: [] };
697 this.get('/LeftTree').renderView();
698 //console.dump(this.map);
699 //var RightPalete = imports.Builder.RightPalete.RightPalete;
700 var pm = this.get('/RightPalete.model');
703 this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
705 if (!this.get('/RightPalete').provider) {
706 print ("********* PALETE PROVIDER MISSING?!!");
708 this.get('/LeftTree').renderView();
710 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
714 this.get('/Window.view-notebook').el.set_current_page(
715 this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
718 findDropNode : function(treepath_str, targets) {
720 // this is used by the dragdrop code in the roo version AFAIR..
722 var path = treepath_str.replace(/^builder-/, '');
723 // treemap is depreciated... - should really check if model has any entries..
725 if (!this.el.iter_n_children(null)) {
727 return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];
729 print("FIND treepath: " + path);
730 //console.dump(this.treemap);
732 if (!treepath_str.match(/^builder-/)) {
733 return []; // nothing!
735 if (targets === true) {
738 return this.findDropNodeByPath(path,targets)
740 findDropNodeByPath : function(treepath_str, targets, pref) {
741 var path = treepath_str + ''; // dupe it..
742 pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
744 //console.dump(this.treemap);
745 while (path.length) {
746 print("LOOKING FOR PATH: " + path);
747 var node_data = this.singleNodeToJS(path);
748 if (node_data === false) {
749 print("node not found");
753 var xname = this.get('/LeftTree.model').file.guessName(node_data);
756 targets.forEach(function(tg) {
760 if ((tg == xname) ) {
763 if (tg.indexOf(xname +':') === 0) {
765 prop = tg.split(':').pop();
770 if (last) { // pref is after/before..
771 // then it's after last
773 return []; // do not allow..
775 return [ last, pref , prop];
778 return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
780 var par = path.split(':');
783 path = par.join(':');
789 dropNode : function(target_data, node) {
792 console.dump(target_data);
793 var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
795 print("add " + tp + "@" + target_data[1] );
798 if (tp && target_data[1] < 2) { // before or after..
799 var ar = target_data[0].split(':');
801 parent = new Gtk.TreePath.from_string( ar.join(':') );
804 var n_iter = new Gtk.TreeIter();
805 var iter_par = new Gtk.TreeIter();
806 var iter_after = after ? new Gtk.TreeIter() : false;
810 if (parent !== false) {
811 this.el.get_iter(iter_par, parent);
818 print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
819 this.el.get_iter(iter_after, after);
820 this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
821 n_iter, iter_par, iter_after);
824 this.el.append(n_iter, iter_par);
828 if (typeof(node) == 'string') {
829 var ar = node.split('.');
830 var xtype = ar.pop();
833 '|xns' : ar.join('.'),
836 if (target_data.length == 3 && target_data[2].length) {
837 node['*prop'] = target_data[2];
841 // work out what kind of packing to use..
842 if (typeof(node.pack) == 'undefined' && parent !== false) {
843 var pal = this.get('/LeftTree').getPaleteProvider();
845 var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
846 print ("PNAME : " + pname);
847 var cname = pal.guessName(node);
848 print ("CNAME : " + cname);
849 node.pack = pal.getDefaultPack(pname, cname);
860 // load children - if it has any..
863 this.load(xitems, n_iter);
865 if (tp && (xitems || after)) {
866 this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
868 // wee need to get the empty proptypes from somewhere..
870 //var olditer = this.activeIter;
871 this.activePath = this.el.get_path(n_iter).to_string();
873 // changed actually set's the node data..
874 this.changed(node, true);
878 this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
880 //Builder.MidPropTree._model.load(node);
881 //Builder.MidPropTree._win.hideWin();
882 //Builder.LeftPanel._model.load( node);
886 moveNode : function(target_data, action) {
887 //print("MOVE NODE");
888 // console.dump(target_data);
889 var old_iter = new Gtk.TreeIter();
890 var s = this.get('/LeftTree.view').selection;
891 s.get_selected(this.el, old_iter);
892 var node = this.nodeToJS(old_iter,false);
893 //console.dump(node);
896 // needs to drop first, otherwise the target_data
897 // treepath will be invalid.
899 this.dropNode(target_data, node);
900 if (action & Gdk.DragAction.MOVE) {
901 // print("REMOVING OLD NODE");
902 this.el.remove(old_iter);
906 this.activePath= false;
907 this.changed(false,true);
909 deleteSelected : function() {
910 this.get('/LeftTree.view').blockChanges = true;
911 var old_iter = new Gtk.TreeIter();
912 var s = this.get('/LeftTree.view').selection;
913 s.get_selected(this.el, old_iter);
914 var path = this.el.get_path(old_iter).to_string();
916 this.activePath= false;
919 this.activePath= false;
920 var iter = new Gtk.TreeIter();
921 this.el.get_iter_from_string(iter, path);
922 this.el.remove(iter);
924 // rebuild treemap. -- depreciated.!!
927 //this.toJS(null, true) // does not do anything?
928 this.activePath= false;
929 this.changed(false,true);
930 this.get('/LeftTree.view').blockChanges = false;
933 listAllTypes : function() {
934 var s = this.get('/LeftTree.view').selection;
935 print ("LIST ALL TYPES: " + s.count_selected_rows() );
937 if (s.count_selected_rows() > 0) {
938 var iter = new Gtk.TreeIter();
939 s.get_selected(this.el, iter);
941 // set some properties of the tree for use by the dropped element.
942 var value = new GObject.Value('');
943 this.el.get_value(iter, 2, value);
944 var data = JSON.parse(value.value);
947 var xname = this.get('/LeftTree.model').file.guessName(data);
948 console.log('selected:' + xname);
952 return []; // could not find it..
960 li.forEach(function(el) {
961 // this is specific to roo!!!?
963 var fullpath = _this.file.guessName(el);
964 if (fullpath.length && ret.indexOf(fullpath) < 0) {
969 if (el.items && el.items.length) {
978 addall([this.currentTree]);
980 // only if we have nothing, should we add '*top'
984 //console.log('all types in tree');
990 singleNodeToJS : function (treepath)
992 var iter = new Gtk.TreeIter();
993 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
997 var iv = this.getIterValue(iter, 2);
999 return JSON.parse(iv);
1002 nodeToJS : function (iter, with_id)
1004 var par = new Gtk.TreeIter();
1005 var iv = this.getIterValue(iter, 2);
1006 // print("IV" + iv);
1007 var k = JSON.parse(iv);
1008 if (k.json && !this.el.iter_parent( par, iter )) {
1013 var treepath_str = this.el.get_path(iter).to_string();
1014 // not sure how we can handle mixed id stuff..
1015 if (typeof(k.id) == 'undefined') {
1016 k.id = 'builder-'+ treepath_str ;
1020 this.treemap[ treepath_str ] = k;
1021 k.xtreepath = treepath_str ;
1024 if (this.el.iter_has_child(iter)) {
1025 citer = new Gtk.TreeIter();
1026 this.el.iter_children(citer, iter);
1027 k.items = this.toJS(citer,with_id);
1031 toJS : function(iter, with_id)
1033 //Seed.print("WITHID: "+ with_id);
1040 iter = new Gtk.TreeIter();
1041 if (!this.el.get_iter_first(iter)) {
1051 var k = this.nodeToJS(iter, with_id);
1055 if (!this.el.iter_next(iter)) {
1061 // convert the list into a json string..
1065 getIterValue : function (iter, col) {
1066 var gval = new GObject.Value('');
1067 this.el.get_value(iter, col ,gval);
1072 nodeTitle : function(c) {
1075 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
1076 if (sr) txt.push('<s>');
1077 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
1078 if (c.xtype) { txt.push(c.xtype); }
1079 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1080 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1081 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1084 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1085 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1086 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1087 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1088 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1089 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1090 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1091 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1092 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1094 // for flat classes...
1095 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1096 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1099 if (sr) txt.push('</s>');
1100 return (txt.length == 0 ? "Element" : txt.join(" "));
1102 nodeToJSON : function(c) {
1110 return JSON.stringify(o);
1112 load : function(tr,iter)
1114 var citer = new Gtk.TreeIter();
1115 //this.insert(citer,iter,0);
1116 for(var i =0 ; i < tr.length; i++) {
1118 this.el.insert(citer,iter,-1);
1120 this.el.append(citer);
1123 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1124 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTip(tr[i]) ]);
1125 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1126 if (tr[i].items && tr[i].items.length) {
1127 this.load(tr[i].items, citer);
1131 nodeTip : function(c) {
1132 var ret = this.nodeTitle(c);
1138 if (!i.length || i[0] != '|') {
1144 if (typeof(c[i]) != 'string') {
1147 //print("prop : " + i + ':' + c[i]);
1148 if (!c[i].match(new RegExp('function'))) {
1151 funcs += "\n<b>" + i.substring(1) + '</b> : ' + c[i].split(/\n/).shift();
1155 ret+="\n\nMethods:" + funcs;
1162 xtype: Gtk.TreeViewColumn,
1163 pack : "append_column",
1165 XObject.prototype.init.call(this);
1166 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1170 xtype: Gtk.CellRendererText,
1180 id : "LeftTreeMenu",
1183 xtype: Gtk.MenuItem,
1185 label : "Delete Element",
1187 "activate":function (self) {
1189 this.get('/LeftTree.model').deleteSelected();
1200 id : "LeftProjectTree",
1201 showNoProjectSelected : function() {
1202 this.get('/StandardErrorDialog').show("Select a Project first.");
1204 getActiveProject : function() {
1205 return this.project;
1208 "leave_notify_event":function (self, event) {
1215 pack : "pack_start,false,false",
1218 xtype: Gtk.ComboBox,
1221 XObject.prototype.init.call(this);
1222 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1224 getValue : function() {
1225 var ix = this.el.get_active();
1229 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1230 if (typeof(data[ix]) == 'undefined') {
1235 setValue : function(fn)
1239 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1240 data.forEach(function(n, ix) {
1248 "changed":function (self) {
1249 var fn = this.getValue();
1250 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1251 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1256 xtype: Gtk.CellRendererText,
1257 pack : "pack_start,true",
1261 xtype: Gtk.ListStore,
1264 XObject.prototype.init.call(this);
1265 this.el.set_column_types ( 2, [
1266 GObject.TYPE_STRING, // real key
1267 GObject.TYPE_STRING // real type
1271 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1273 pm.on('changed', function() {
1274 print("caught changed hook on project manager - reloading data");
1275 _this.loadData(pm.projects);
1279 loadData : function(data) {
1280 var ov = this.get('/LeftProjectTree.combo').getValue();
1282 var iter = new Gtk.TreeIter();
1284 data.forEach(function(p) {
1289 el.set_value(iter, 0, p.fn);
1290 el.set_value(iter, 1, p.name);
1294 this.get('/LeftProjectTree.combo').setValue(ov);
1303 xtype: Gtk.ScrolledWindow,
1305 shadow_type : Gtk.ShadowType.IN,
1307 XObject.prototype.init.call(this);
1308 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1312 xtype: Gtk.TreeView,
1313 headers_visible : false,
1314 enable_tree_lines : true,
1317 XObject.prototype.init.call(this);
1318 var description = new Pango.FontDescription.c_new();
1319 description.set_size(8000);
1320 this.el.modify_font(description);
1322 this.selection = this.el.get_selection();
1323 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1327 "cursor_changed":function (self) {
1328 var iter = new Gtk.TreeIter();
1330 if (this.selection.count_selected_rows() < 1) {
1331 //XN.get('Builder.LeftTree.model').
1332 this.get('/LeftTree.model').load( false);
1336 var model = this.get('/LeftProjectTree.model');
1337 //console.log('changed');
1338 var s = this.selection;
1339 s.get_selected(model, iter);
1340 value = new GObject.Value('');
1341 model.el.get_value(iter, 2, value);
1343 console.log(value.value);// id..
1345 var file = this.get('/LeftProjectTree').project.getById(value.value);
1352 var nb = this.get('/LeftTopPanel.expander');
1353 nb.el.expanded = false;
1354 nb.listeners.activate.call(nb);
1355 //_expander.el.set_expanded(false);
1357 var ltm = this.get('/LeftTree.model');
1365 xtype: Gtk.TreeStore,
1369 XObject.prototype.init.call(this);
1370 this.el.set_column_types ( 3, [
1371 GObject.TYPE_STRING, // title
1372 GObject.TYPE_STRING, // tip
1373 GObject.TYPE_STRING // id..
1377 loadProject : function(pr) {
1378 print("LOAD PROJECT");
1384 this.get('/LeftProjectTree').project = pr;
1385 this.load(pr.toTree());
1386 this.get('/LeftProjectTree.view').el.expand_all();
1388 load : function(tr,iter) {
1389 // console.dump(tr);
1390 console.log('Project tree load: ' + tr.length);
1391 var citer = new Gtk.TreeIter();
1392 //this.insert(citer,iter,0);
1395 tr.forEach(function (r) {
1397 _this.el.append(citer);
1399 _this.el.insert(citer,iter,-1);
1401 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1402 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1403 _this.el.set_value(citer, 2, '' + r.id ); //id
1404 if (r.cn && r.cn.length) {
1405 _this.load(r.cn, citer);
1410 getValue : function(iter, col) {
1411 var gval = new GObject.Value('');
1412 this.el.get_value(iter, col ,gval);
1413 return '' + gval.value;
1417 xtype: Gtk.TreeViewColumn,
1418 pack : "append_column",
1420 XObject.prototype.init.call(this);
1421 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1425 xtype: Gtk.CellRendererText,
1448 pack : "pack_start,false,true,0",
1455 "button_press_event":function (self, event) {
1456 this.get('/MidPropTree.model').showData('props');
1468 stock : Gtk.STOCK_ADD,
1469 icon_size : Gtk.IconSize.MENU
1484 "button_press_event":function (self, event) {
1485 this.get('/MidPropTree.model').showData('events');
1497 stock : Gtk.STOCK_ADD,
1498 icon_size : Gtk.IconSize.MENU
1513 "button_press_event":function (self, ev) {
1514 var p = this.get('/AddPropertyPopup');
1518 p.el.set_screen(Gdk.Screen.get_default());
1520 p.el.popup(null, null, null, null, 3, ev.button.time);
1532 stock : Gtk.STOCK_ADD,
1533 icon_size : Gtk.IconSize.MENU
1545 id : "AddPropertyPopup",
1548 xtype: Gtk.MenuItem,
1550 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1553 "activate":function (self) {
1555 this.get('/LeftPanel.model').add( {
1566 xtype: Gtk.MenuItem,
1568 tooltip_markup : "Add what type of packing is to be used",
1571 "activate":function (self) {
1573 this.get('/LeftPanel.model').add( {
1583 xtype: Gtk.MenuItem,
1585 tooltip_markup : "Override the init method",
1588 "activate":function (self) {
1590 this.get('/LeftPanel.model').add( {
1593 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1600 xtype: Gtk.SeparatorMenuItem,
1604 xtype: Gtk.MenuItem,
1606 tooltip_markup : "Add a user defined string property",
1609 "activate":function (self) {
1611 this.get('/LeftPanel.model').add( {
1621 xtype: Gtk.MenuItem,
1623 tooltip_markup : "Add a user defined number property",
1626 "activate":function (self) {
1628 this.get('/LeftPanel.model').add( {
1638 xtype: Gtk.MenuItem,
1640 tooltip_markup : "Add a user defined boolean property",
1643 "activate":function (self) {
1645 this.get('/LeftPanel.model').add( {
1655 xtype: Gtk.SeparatorMenuItem,
1659 xtype: Gtk.MenuItem,
1661 tooltip_markup : "Add a user function boolean property",
1664 "activate":function (self) {
1666 this.get('/LeftPanel.model').add( {
1669 val : "function() {\n \n}\n",
1682 xtype: Gtk.ScrolledWindow,
1685 shadow_type : Gtk.ShadowType.IN,
1688 XObject.prototype.init.call(this);
1689 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1693 xtype: Gtk.TreeView,
1696 headers_visible : false,
1697 enable_tree_lines : true,
1699 XObject.prototype.init.call(this);
1701 this.selection = this.el.get_selection();
1702 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1705 var description = new Pango.FontDescription.c_new();
1706 description.set_size(8000);
1707 this.el.modify_font(description);
1710 "button_press_event":function (self, ev) {
1714 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1715 return false; //not on a element.
1719 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1721 if (res.column.title != 'value') {
1722 return false; // ignore..
1724 if ( this.get('/LeftPanel').editing) {
1727 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1728 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1729 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1733 var provider = this.get('/LeftTree').getPaleteProvider();
1735 var opts = provider.findOptions(type);
1737 if (opts === false) {
1738 this.get('/LeftPanel').editableColumn.setOptions([]);
1739 renderer.has_entry = true;
1741 LeftPanel.editableColumn.setOptions(opts);
1742 renderer.has_entry = false;
1746 //Seed.print("click" + ev.type);
1747 //console.dump(res);
1753 if (res.column.title == 'value') {
1756 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1757 var p = this.get('/LeftPanelPopup');
1762 p.el.set_screen(Gdk.Screen.get_default());
1764 p.el.popup(null, null, null, null, 3, ev.button.time);
1765 //Seed.print("click:" + res.column.title);
1773 xtype: Gtk.TreeStore,
1777 XObject.prototype.init.call(this);
1778 this.el.set_column_types ( 5, [
1779 GObject.TYPE_STRING, // 0 real key
1780 GObject.TYPE_STRING, // 1 real value
1781 GObject.TYPE_STRING, // 2 visable key
1782 GObject.TYPE_STRING, // 3 visable value
1783 GObject.TYPE_STRING, // 4 need to store type of!!!
1787 toShort : function(str) {
1788 var a = typeof(str) == 'string' ? str.split("\n") : [];
1789 return a.length > 1 ? a[0] + '....' : '' + str;
1791 load : function(ar) {
1794 this.get('/RightEditor').el.hide();
1801 var provider = this.get('/LeftTree').getPaleteProvider();
1804 var iter = new Gtk.TreeIter();
1806 if (typeof(ar[i]) == 'object') {
1810 var type = provider.findType(ar, i, ar[i]);
1812 this.el.append(iter);
1813 var p = this.el.get_path(iter).to_string();
1815 this.el.set_value(iter, 0, i);
1816 this.el.set_value(iter, 1, '' + ar[i]);
1817 this.el.set_value(iter, 2, i);
1818 this.el.set_value(iter, 3, this.toShort(ar[i]));
1819 this.el.set_value(iter, 4, type);
1821 ar.listeners = ar.listeners || {};
1822 for (var i in ar.listeners ) {
1823 this.el.append(iter);
1824 var p = this.el.get_path(iter).to_string();
1827 this.el.set_value(iter, 0, '!'+ i );
1828 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1829 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1831 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1832 this.el.set_value(iter, 4, 'function');
1836 add : function(info) {
1837 // info includes key, val, skel, etype..
1839 type = info.type.toLowerCase();
1840 var data = this.toJS();
1842 if (info.etype == 'events') {
1843 data.listeners = data.listeners || { };
1844 if (typeof(data.listeners[info.key]) != 'undefined') {
1845 return; //already set!
1848 if (typeof(data[info.key]) != 'undefined') {
1853 if (typeof(info.val) == 'undefined') {
1856 if (info.type == 'boolean') {
1859 if (type == 'number') {
1867 if (info.etype == 'events') {
1869 data.listeners[info.key] = info.val;
1872 data[info.key] = info.val;
1876 var map = this.load(data);
1878 // flag it as changed to the interface..
1880 this.get('/LeftTree.model').changed(data, true);
1883 this.startEditing(map[k]);
1886 LeftPanel.get('view').el.row_activated(
1887 new Gtk.TreePath.from_string(map[k]),
1888 LeftPanel.editableColumn.el
1892 startEditing : function(path,col) {
1894 * start editing path (or selected if not set..)
1895 * @param {String|false} path (optional) treepath to edit - selected tree gets
1896 * edited by default.
1897 * @param {Number} 0 or 1 (optional)- column to edit.
1900 if (typeof(path) == 'string') {
1901 tp = new Gtk.TreePath.from_string(path);
1903 var iter = new Gtk.TreeIter();
1904 var s = this.get('/LeftPanel.view').selection;
1905 s.get_selected(this.el, iter);
1906 tp = this.el.get_path(iter);
1907 path = tp.to_string();
1911 // which colum is to be edited..
1913 if (typeof(col) == 'undefined') {
1914 var k = this.getValue(path, 0);
1915 colObj = (!k.length || k == '|') ?
1916 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1918 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1921 // make sure the pulldown is set correctly..
1922 // not really needed for second col...
1924 var provider = this.get('/LeftTree').getPaleteProvider();
1926 var type = this.get('/LeftPanel.model').getType(path);
1927 var opts = provider.findOptions(type);
1928 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1930 if (opts === false) {
1931 this.get('/LeftPanel').editableColumn.setOptions([]);
1932 renderer.has_entry = true; /// probably does not have any effect.
1934 this.get('/LeftPanel').editableColumn.setOptions(opts);
1935 renderer.has_entry = false;
1939 // iter now has row...
1940 GLib.timeout_add(0, 100, function() {
1942 colObj.items[0].el.editable = true; // esp. need for col 0..
1943 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1952 deleteSelected : function() {
1953 var data = this.toJS();
1954 var iter = new Gtk.TreeIter();
1955 var s = this.get('/LeftPanel.view').selection;
1956 s.get_selected(this.el, iter);
1959 var gval = new GObject.Value('');
1960 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1962 var val = gval.value;
1963 if (val[0] == '!') {
1965 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1968 delete data.listeners[ val.substring(1)];
1969 if (!XObject.keys(data.listeners).length) {
1970 delete data.listeners;
1974 if (typeof(data[val]) == 'undefined') {
1982 this.get('/LeftTree.model').changed(data, true);
1986 changed : function(str, doRefresh) {
1987 if (!this.activePath) {
1990 var iter = new Gtk.TreeIter();
1991 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1993 this.el.set_value(iter, 1, '' +str);
1994 this.el.set_value(iter, 3, '' + this.toShort(str));
1995 // update the tree...
1997 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
2000 var iter = new Gtk.TreeIter();
2001 this.get('/LeftPanel.model').el.get_iter_first(iter);
2006 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
2009 ar.listeners = ar.listeners || {};
2010 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
2013 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
2016 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
2022 //print(JSON.stringify(ar));
2026 getType : function(treepath) {
2027 return this.getValue(treepath, 4);
2029 getValue : function(treepath_str, col) {
2030 var iter = new Gtk.TreeIter();
2031 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
2033 var gval = new GObject.Value('');
2034 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
2035 var val = '' + gval.value;
2039 var type = this.getType(this.el.get_path(iter).to_string());
2040 //print("TYPE: " +type + " - val:" + val);
2041 switch(type.toLowerCase()) {
2045 return parseFloat(val); // Nan ?? invalid!!?
2047 return val == 'true' ? true : false;
2053 editSelected : function(e) {
2054 print("EDIT SELECTED?");
2055 var iter = new Gtk.TreeIter();
2056 var s = this.get('/LeftPanel.view').selection;
2057 s.get_selected(this.get('/LeftPanel.model').el, iter);
2058 var m = this.get('/LeftPanel.model')
2060 var gval = new GObject.Value('');
2061 this.el.get_value(iter, 0 ,gval);
2062 var val = '' + gval.value;
2064 gval = new GObject.Value('');
2065 this.el.get_value(iter, 1 ,gval);
2066 var rval = gval.value;
2067 var activePath = this.el.get_path(iter).to_string();
2068 this.activePath = activePath ;
2069 // was activeIter...
2072 var showEditor = false;
2074 if (val[0] == '!') {
2077 if (val[0] == '|') {
2078 if (rval.match(/function/g) || rval.match(/\n/g)) {
2085 this.activePath = false;
2086 GLib.timeout_add(0, 1, function() {
2087 // Gdk.threads_enter();
2088 _this.get('/BottomPane').el.show();
2089 _this.get('/RightEditor').el.show();
2090 _this.get('/RightEditor.view').load( rval );
2094 _this.activePath = activePath ;
2096 // Gdk.threads_leave();
2101 this.get('/BottomPane').el.hide();
2102 this.get('/RightEditor').el.hide();
2104 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2110 xtype: Gtk.TreeViewColumn,
2111 pack : "append_column",
2113 XObject.prototype.init.call(this);
2115 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2116 this.get('/LeftPanel').propertyColumn = this;
2121 xtype: Gtk.CellRendererText,
2122 pack : "pack_start",
2124 "editing_started":function (self, editable, path) {
2126 this.get('/LeftPanel.model').activePath = path;
2129 "edited":function (self, object, p0) {
2130 var model = this.get('/LeftPanel.model');
2131 var path = model.activePath;
2132 var iter = new Gtk.TreeIter();
2133 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2134 model.el.set_value(iter, 0, p0);
2135 model.el.set_value(iter, 2, p0);
2137 model.activePath = false;
2139 this.get('/LeftTree.model').changed(model.toJS(), true);
2140 this.el.editable = false;
2147 xtype: Gtk.TreeViewColumn,
2148 pack : "append_column",
2150 XObject.prototype.init.call(this);
2151 this.el.add_attribute(this.items[0].el , 'text', 3 );
2152 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2153 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2154 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2156 this.get('/LeftPanel').editableColumn= this;
2158 setOptions : function(ar) {
2159 var m = this.items[0].el.model;
2161 var iter = new Gtk.TreeIter();
2162 ar.forEach(function(i) {
2165 m.set_value(iter, 0, i);
2171 xtype: Gtk.CellRendererCombo,
2172 pack : "pack_start",
2177 XObject.prototype.init.call(this);
2178 this.el.model = new Gtk.ListStore();
2179 this.el.model.set_column_types ( 1, [
2180 GObject.TYPE_STRING // 0 real key
2184 "edited":function (self, object, p0) {
2185 this.get('/LeftPanel').editing = false;
2186 print("EDITED? p:" + p0 + " t:" + p0);
2187 this.get('/LeftPanel.model').changed(p0, true);
2188 this.get('/LeftPanel.model').activePath = false;
2190 "editing_started":function (self, editable, path) {
2191 this.get('/LeftPanel').editing = true;
2192 // console.log('editing started');
2193 // r.has_entry = false;
2194 this.get('/LeftPanel.model').editSelected(editable);
2205 id : "LeftPanelPopup",
2208 xtype: Gtk.MenuItem,
2212 "activate":function (self) {
2213 this.get('/LeftPanel.model').deleteSelected();
2218 xtype: Gtk.MenuItem,
2222 "activate":function (self) {
2223 this.get('/LeftPanel.model').startEditing(false, 0);
2236 xtype: Gtk.ScrolledWindow,
2237 pack : "pack_end,false,true,0",
2239 shadow_type : Gtk.ShadowType.IN,
2241 XObject.prototype.init.call(this);
2242 XObject.prototype.init.call(this);
2243 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2244 this.el.set_size_request ( 150, -1 );
2247 activeElement : false,
2248 hideWin : function() {
2255 if (this.get('/Window.left').el.position < 160) {
2258 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2265 xtype: Gtk.TreeView,
2266 enable_tree_lines : true,
2267 headers_visible : false,
2270 XObject.prototype.init.call(this);
2272 var description = new Pango.FontDescription.c_new();
2273 description.set_size(8000);
2274 this.el.modify_font(description);
2276 //this.selection = this.el.get_selection();
2277 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2286 "cursor_changed":function (self) {
2287 var iter = new Gtk.TreeIter();
2289 //console.log('changed');
2290 var m = this.get('model');
2291 if (!this.selection){
2292 this.selection = this.el.get_selection();
2295 var s = this.selection;
2296 if (!s.get_selected(m.el, iter)) {
2299 var tp = m.el.get_path(iter).to_string();
2304 var key = m.getValue(tp, 0);
2306 var type = m.getValue(tp, 1);
2307 var skel = m.getValue(tp, 3);
2308 var etype = m.getValue(tp, 5);
2311 this.get('/MidPropTree').hideWin();
2313 if (type == 'function') {
2315 if (etype != 'events') {
2319 this.get('/LeftPanel.model').add({
2328 if (type.indexOf('.') > -1 ||
2329 type == 'boolean') {
2333 this.get('/LeftPanel.model').add( {
2343 xtype: Gtk.ListStore,
2346 XObject.prototype.init.call(this);
2347 this.el.set_column_types ( 6, [
2348 GObject.TYPE_STRING, // real key
2349 GObject.TYPE_STRING, // real type
2350 GObject.TYPE_STRING, // docs ?
2351 GObject.TYPE_STRING, // visable desc
2352 GObject.TYPE_STRING, // function desc
2353 GObject.TYPE_STRING // element type (event|prop)
2357 getValue : function(treepath, col)
2359 var tp = new Gtk.TreePath.from_string (treepath);
2360 var iter = new Gtk.TreeIter();
2361 this.el.get_iter (iter, tp);
2362 var value = new GObject.Value('');
2363 this.el.get_value(iter, col, value);
2367 showData : function(type) {
2369 if (!this.get('/MidPropTree').activeElement || !type) {
2370 return; // no active element
2373 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2374 var palete = this.get('/LeftTree').getPaleteProvider();
2378 Seed.print('Showing right?');
2379 if (!this.get('/MidPropTree').shown) {
2381 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2382 this.get('/MidPropTree').el.show();
2383 this.get('/MidPropTree').shown = true;
2386 var elementList = palete.getPropertiesFor(fullpath, type);
2387 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2388 // console.dump(elementList);
2391 var iter = new Gtk.TreeIter();
2392 for(var i =0 ; i < elementList.length; i++) {
2393 var p=elementList[i];
2394 this.el.append(iter);
2395 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2396 //GObject.TYPE_STRING, // real key
2397 // GObject.TYPE_STRING, // real type
2398 // GObject.TYPE_STRING, // docs ?
2399 // GObject.TYPE_STRING // func def?
2402 this.el.set_value(iter, 0, p.name);
2403 this.el.set_value(iter, 1, p.type);
2404 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2405 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2406 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2407 this.el.set_value(iter, 5, type);
2415 xtype: Gtk.TreeViewColumn,
2417 this.el = new Gtk.TreeViewColumn();
2418 this.parent.el.append_column(this.el);
2420 XObject.prototype.init.call(this);
2421 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2426 xtype: Gtk.CellRendererText,
2427 pack : "pack_start,true"
2451 xtype: Gtk.Notebook,
2452 pack : "pack_start,true,true",
2453 id : "view-help-nb",
2455 XObject.prototype.init.call(this);
2456 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" }));
2457 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" }));
2461 xtype: Gtk.Notebook,
2463 id : "view-notebook",
2466 XObject.prototype.init.call(this);
2467 this.el.set_current_page(0);
2469 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2470 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2477 id : "RightBrowser",
2484 pack : "pack_start,false,true,0",
2488 pack : "pack_start,false,false,0",
2489 label : "Dump HTML to console",
2491 "activate":function (self) {
2492 this.get('/RightBrowser.view').el.execute_script(
2493 "console.log(document.body.innerHTML);");
2494 this.get('/RightBrowser.view').el.execute_script(
2495 "console.log(Builder.dump(Builder));");
2502 label : "Set Default Javascript",
2504 "button_press_event":function (self, event) {
2505 this.get('/RooProjectProperties').show();
2513 xtype: Gtk.ScrolledWindow,
2515 shadow_type : Gtk.ShadowType.IN,
2517 XObject.prototype.init.call(this);
2518 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2522 xtype: WebKit.WebView,
2526 XObject.prototype.init.call(this);
2527 // this may not work!?
2528 this.el.open('file:///' + __script_path__ + '/../builder.html');
2532 this.el, /* widget that will accept a drop */
2533 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2534 null, /* lists of target to support */
2535 0, /* size of list */
2536 Gdk.DragAction.COPY /* what to do with data after dropped */
2539 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2540 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2542 renderJS : function(data) {
2543 //print("HTML RENDERING");
2544 /// prevent looping..
2545 if (this.pendingRedraw) {
2550 if (!this.get('/Window.LeftTree').getActiveFile()) {
2554 var project = this.get('/Window.LeftTree').getActiveFile().project;
2555 //print (project.fn);
2557 project.runhtml = project.runhtml || '';
2560 this.runhtml = this.runhtml || '';
2562 if (project.runhtml != this.runhtml) {
2563 // then we need to reload the browser using
2564 // load_html_string..
2566 // then trigger a redraw once it's loaded..
2567 this.pendingRedraw = true;
2569 this.runhtml = project.runhtml;
2571 var html = imports.File.File.read(script_path__ + '/../builder.html');
2572 var html = html.replace('</head>', this.runhtml + '</head>');
2574 this.el.load_html_string( html , 'file:///' + __script_path__ + '/../builder.html');
2575 // should trigger load_finished!
2580 this.pendingRedraw = false;
2583 this.renderedData = data;
2584 var str = JSON.stringify(data) ;
2587 console.log('not loaded yet');
2589 //Seed.print("RENDER:" + str);
2590 //imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2592 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2595 "load_finished":function (self, object) {
2596 if (this.ready) { // dont do it twice!
2600 this.pendingRedraw = false;
2601 var js = this.get('/LeftTree.model').toJS();
2603 this.renderJS(js[0]);
2607 "script_alert":function (self, object, p0) {
2610 return true; // do not display anything...
2612 "console_message":function (self, object, p0, p1) {
2613 console.log(object);
2614 if (!object.match(/^\{/)) {
2615 return false; // do not handle!!! -> later maybe in console..
2617 console.log(object);
2618 var val = JSON.parse(object);
2620 if (typeof(val['hover-node']) != 'undefined') {
2621 this.activeNode = val['hover-node'];
2622 console.log('active node: ' + this.activeNode);
2627 if (typeof(val['id']) != 'undefined') {
2628 // this.activeNode = val['id'];
2629 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2633 this.get('/LeftTree.view').selectNode(tg[0]);
2637 if (ret && typeof(val['set']) != 'undefined') {
2638 this.get('/LeftPanel.model').add({
2642 //console.log('active node: ' + this.activeNode);
2645 //Seed.print('a:'+a);
2646 //Seed.print('b:'+b);
2647 //Seed.print('c:'+c);
2650 "drag_motion":function (w, ctx, x, y, time, ud) {
2651 // console.log('DRAG MOTION');
2653 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2654 this.targetData = [];
2655 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2657 // A) find out from drag all the places that node could be dropped.
2658 var src = Gtk.drag_get_source_widget(ctx);
2659 if (!src.dropList) {
2660 Gdk.drag_status(ctx, 0, time);
2663 // b) get what we are over.. (from activeNode)
2664 // tree is empty.. - list should be correct..
2665 if (!this.get('/LeftTree.model').currentTree) {
2666 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2670 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2672 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2675 Gdk.drag_status(ctx, 0,time);
2676 this.get('/LeftTree.view').highlight(false);
2680 // if we have a target..
2681 // -> highlight it! (in browser)
2682 // -> highlight it! (in tree)
2684 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2685 this.get('/LeftTree.view').highlight(tg);
2686 this.targetData = tg;
2687 // for tree we should handle this...
2690 "drag_drop":function (w, ctx, x, y,time, ud) {
2691 print("TARGET: drag-drop");
2692 var is_valid_drop_site = true;
2697 w, /* will receive 'drag-data-received' signal */
2698 ctx, /* represents the current state of the DnD */
2699 this.get('/Window').atoms["STRING"], /* the target type we want */
2700 time /* time stamp */
2704 /* No target offered by source => error */
2707 return is_valid_drop_site;
2709 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2711 print("Browser: drag-data-received");
2712 var delete_selection_data = false;
2713 vardnd_success = false;
2714 /* Deal with what we are given from source */
2715 if( sel_data && sel_data.length ) {
2717 if (ctx.action == Gdk.DragAction.ASK) {
2718 /* Ask the user to move or copy, then set the ctx action. */
2721 if (ctx.action == Gdk.DragAction.MOVE) {
2722 delete_selection_data = true;
2724 var source = Gtk.drag_get_source_widget(ctx);
2726 print("Browser: source.DRAGDATA? " + source.dragData);
2727 if (this.targetData) {
2728 print(this.targetData);
2729 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2738 if (dnd_success == false)
2740 Seed.print ("DnD data transfer failed!\n");
2743 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2755 id : "RightGtkView",
2756 renderJS : function(data, withDebug)
2758 this.highlightWidget = false;
2762 this.withDebug = false;
2764 if (this.renderedEl) {
2765 this.get('view').el.remove(this.renderedEl);
2766 this.renderedEl.destroy();
2767 this.renderedEl = false;
2770 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2771 // in theory tree is actually window..
2773 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2778 this.get('view').el.set_size_request(
2779 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2782 this.renderedEl.set_size_request(
2783 tree.default_width || 600,
2784 tree.default_height || 400
2786 this.get('view').el.show_all();
2791 showInWindow : function() {
2792 print("GET PROEJCT");
2793 var pr = this.get('/LeftProjectTree').getActiveProject();
2795 console.log(pr.paths);
2798 var src= this.buildJS(
2799 this.get('/LeftTree.model').toJS()[0],
2804 //var x = new imports.sandbox.Context();
2808 Seed.check_syntax('var e = ' + src);
2811 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2812 this.get('/Terminal').feed(console._dump(e)+"\n");
2814 var lines = src.split("\n");
2815 var start = Math.max(0, e.line - 10);
2816 var end = Math.min(lines.length, e.line + 10);
2817 for (var i =start ; i < end; i++) {
2819 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2822 this.get('/Terminal').feed(lines[i] + "\n");
2829 this.get('/BottomPane').el.set_current_page(1);
2830 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2831 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2832 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2834 var _top = x.get_global_object()._top;
2836 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2838 if (_top.el.popup) {
2839 _top.el.popup(null, null, null, null, 3, null);
2843 viewAdd : function(item, par)
2845 // does something similar to xobject..
2846 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2848 if (item.pack===false || item.pack === 'false') { // no ;
2851 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2852 var ns = imports.gi[item['|xns']];
2853 var ctr = ns[item['xtype']];
2855 for(var k in item) {
2857 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2872 if (k[0] == '|' && typeof(kv) == 'string') {
2874 if (kv.match(new RegExp('function'))) {
2877 print("WASL " + k + '=' + kv);
2879 eval( 'kv = ' + kv);
2880 } catch(e) { continue; }
2883 // print(k + '=' + kv);
2885 if (k[0] == '|') { // should be boolean or number..
2887 //print(k + '=' + kv);
2890 if (k == 'show_tabs') { // force tab showing for notebooks.
2893 print(k + '=' + typeof(kv) + " : " + kv);
2899 var el = new ctr(ctr_args);
2902 //console.dump(item.pack);
2909 if (typeof(item.pack) == 'string') {
2911 item.pack.split(',').forEach(function(e, i) {
2913 if (e == 'false') { args.push( false); return; }
2914 if (e == 'true') { args.push( true); return; }
2915 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2918 //print(args.join(","));
2920 pack_m = args.shift();
2922 pack_m = item.pack.shift();
2927 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2929 name: "ArgumentError",
2930 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2931 "ADDING : " + item.id + " " + el
2940 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2941 //Seed.print('args: ' + args.length);
2943 par[pack_m].apply(par, args);
2947 item.items = item.items || [];
2948 item.items.forEach(function(ch) {
2949 _this.viewAdd(ch, el);
2954 // add the signal handlers.
2955 // is it a widget!?!!?
2961 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2962 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2963 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2964 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2965 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2975 widgetExposeEvent : function(w, evt, ud, item) {
2977 if (this.inRender) {
2981 if ( this.highlightWidget) {
2982 this.inRender = true;
2983 if (item.xtreepath.substring(0, this.activePath.length) == this.activePath) {
2984 Gdk.draw_rectangle(this.highlightWidget.window, this.gc, false, this.box.x , this.box.y, this.box.w, this.box.h);
2986 this.inRender = false;
2991 if (this.activePath != item.xtreepath) {
2995 // print("HIGHLIGHT: " + item.xtreepath ); // draw highlight??
2996 // work out the coords of the window..
2998 var dr = widget.window;
2999 this.gc = (new Gdk.GC.c_new(dr));
3000 this.gc.set_rgb_fg_color(new Gdk.Color({ red: 0xFFFF, green: 0, blue : 0 }));
3001 this.gc.set_line_attributes(4, Gdk.LineStyle.SOLID, Gdk.CapStyle.ROUND , Gdk.JoinStyle.ROUND);
3005 var r = evt.expose.area;
3006 // console.dump([r.x, r.y, r.width, r.height ] );
3008 // print(widget.get_parent().toString().match(/GtkScrolledWindow/);
3009 if (widget.get_parent().toString().match(/GtkScrolledWindow/)) { // eak
3010 // happens with gtkscrollview embedded stuff..
3011 var np =this.activePath.split(':');
3013 this.activePath = np.join(':');
3014 this.renderedEl.queue_draw();
3030 this.inRender = true;
3033 this.highlightWidget = widget;
3038 // print("DRAW BOX");
3039 //console.dump(this.box);
3040 Gdk.draw_rectangle(widget.window, this.gc, false, this.box.x , this.box.y, this.box.w,this.box.h);
3041 this.inRender = false;
3044 widgetDragMotionEvent : function() {
3045 print("WIDGET DRAGMOTION");
3048 widgetDragDropEvent : function() {
3049 print("WIDGET DRAGDROP");
3052 widgetPressEvent : function(w,e,u,d) {
3053 if (this.get('view').pressed) {
3056 this.get('view').pressed = true;
3057 print("WIDGET PRESS " + d.xtreepath );
3058 this.get('/LeftTree.view').selectNode( d.xtreepath );
3061 widgetReleaseEvent : function() {
3062 this.get('view').pressed = false;
3065 redraw : function() {
3066 this.highlightWidget = false;
3067 print("REDRAW CALLED");
3068 this.activePath = this.get('/LeftTree').getActivePath();
3069 if (this.renderedEl) {
3070 print("QUEUE DRAW CALLING");
3071 this.renderedEl.queue_draw();
3077 pack : "pack_start,false,true,0",
3081 pack : "pack_start,false,false,0",
3082 label : "Run The Application",
3084 "button_press_event":function (self, event) {
3085 // call render on left tree - with special option!?!
3089 print("GET PROEJCT");
3090 var pr = this.get('/LeftProjectTree').getActiveProject();
3093 for (var i in pr.paths) {
3097 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
3098 print ("RUN DIR:" + dir);
3099 this.get('/BottomPane').el.show();
3100 this.get('/BottomPane').el.set_current_page(1);
3101 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
3102 , false,false,false);
3103 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
3104 this.get('/Terminal').el.feed_child(cmd, cmd.length);
3114 xtype: Gtk.ScrolledWindow,
3117 shadow_type : Gtk.ShadowType.IN,
3119 XObject.prototype.init.call(this);
3120 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3124 xtype: Gtk.EventBox,
3125 pack : "add_with_viewport",
3127 XObject.prototype.init.call(this);
3128 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
3129 red: 0x9F00, green: 0xB800 , blue : 0xA800
3137 XObject.prototype.init.call(this);
3138 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
3139 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
3144 xtype: Gtk.EventBox,
3147 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
3148 XObject.prototype.init.call(this);
3152 this.el, /* widget that will accept a drop */
3153 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
3154 null, /* lists of target to support */
3155 0, /* size of list */
3156 Gdk.DragAction.COPY /* what to do with data after dropped */
3159 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
3160 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
3163 getActiveNode : function(x,y)
3165 // workout what node is here..
3166 return '0'; // top..
3170 "drag_motion":function (self, ctx, x, y, time) {
3172 // A) find out from drag all the places that node could be dropped.
3173 var src = Gtk.drag_get_source_widget(ctx);
3174 if (!src.dropList) {
3175 Gdk.drag_status(ctx, 0, time);
3178 // b) get what we are over.. (from activeNode)
3179 // tree is empty.. - list should be correct..
3180 if (!this.get('/LeftTree.model').currentTree) {
3181 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3185 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
3186 var activeNode = this.getActiveNode(x, y);
3189 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
3192 Gdk.drag_status(ctx, 0,time);
3193 this.get('/LeftTree.view').highlight(false);
3197 // if we have a target..
3198 // -> highlight it! (in browser)
3199 // -> highlight it! (in tree)
3201 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3202 this.get('/LeftTree.view').highlight(tg);
3203 this.targetData = tg;
3204 // for tree we should handle this...
3207 "drag_drop":function (self,ctx, x, y, time) {
3208 Seed.print("TARGET: drag-drop");
3209 var is_valid_drop_site = true;
3214 self, /* will receive 'drag-data-received' signal */
3215 ctx, /* represents the current state of the this.gDnD */
3216 this.get('/Window').atoms["STRING"], /* the target type we want */
3217 time /* time stamp */
3221 /* No target offered by source => error */
3224 return is_valid_drop_site;
3227 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3229 Seed.print("GtkView: drag-data-received");
3230 var delete_selection_data = false;
3231 var dnd_success = false;
3232 /* Deal with what we are given from source */
3233 if( sel_data && sel_data.length ) {
3235 if (ctx.action == Gdk.DragAction.ASK) {
3236 /* Ask the user to move or copy, then set the ctx action. */
3239 if (ctx.action == Gdk.DragAction.MOVE) {
3240 delete_selection_data = true;
3242 var source = Gtk.drag_get_source_widget(ctx);
3244 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3245 if (this.targetData) {
3246 Seed.print(this.targetData);
3247 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3256 if (dnd_success == false)
3258 Seed.print ("DnD data transfer failed!\n");
3261 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3264 "button_press_event":function (self, event) {
3265 this.pressed = false;
3281 xtype: Gtk.ScrolledWindow,
3286 xtype: WebKit.WebView,
3290 XObject.prototype.init.call(this);
3291 this.get('/Window.help-view').el.open(
3292 "http://devel.akbkhome.com/seed/");
3303 xtype: Gtk.Notebook,
3306 XObject.prototype.init.call(this);
3307 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3308 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3313 xtype: Gtk.ScrolledWindow,
3318 xtype: GtkSource.View,
3322 XObject.prototype.init.call(this);
3323 var description = Pango.Font.description_from_string("monospace")
3324 description.set_size(8000);
3325 this.el.modify_font(description);
3328 load : function(str) {
3330 // show the help page for the active node..
3331 this.get('/Window.view-help-nb').el.set_current_page(1);
3333 // get the active element being edited.
3334 var xtype = this.get('/LeftTree.model').file.guessName(
3335 this.get('/MidPropTree').activeElement);
3336 // now load the help info in the page..
3337 this.get('/Window.help-view').el.open(
3338 "http://devel.akbkhome.com/seed/" + xtype + ".html");
3341 this.get('/BottomPane').el.set_current_page(0);
3342 this.el.get_buffer().set_text(str, str.length);
3343 var lm = GtkSource.LanguageManager.get_default();
3345 this.el.get_buffer().set_language(lm.get_language('js'));
3346 var buf = this.el.get_buffer();
3347 var cursor = buf.get_mark("insert");
3348 var iter= new Gtk.TextIter;
3349 buf.get_iter_at_mark(iter, cursor);
3351 iter.set_line_offset(4);
3352 buf.move_mark(cursor, iter);
3355 cursor = buf.get_mark("selection_bound");
3356 iter= new Gtk.TextIter;
3357 buf.get_iter_at_mark(iter, cursor);
3359 iter.set_line_offset(4);
3360 buf.move_mark(cursor, iter);
3362 this.el.grab_focus();
3364 insert_spaces_instead_of_tabs : true,
3367 show_line_numbers : true,
3370 xtype: GtkSource.Buffer,
3371 pack : "set_buffer",
3373 "changed":function (self) {
3374 var s = new Gtk.TextIter();
3375 var e = new Gtk.TextIter();
3376 this.el.get_start_iter(s);
3377 this.el.get_end_iter(e);
3378 var str = this.el.get_text(s,e,true);
3380 Seed.check_syntax('var e = ' + str);
3382 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3383 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3385 print("SYNTAX ERROR IN EDITOR");
3390 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3391 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3394 this.get('/LeftPanel.model').changed( str , false);
3403 xtype: Gtk.ScrolledWindow,
3407 xtype: Vte.Terminal,
3410 feed : function(str) {
3411 this.el.feed(str,str.length);
3422 pack : "pack_start,false,false",
3426 this.get('buttonbar').el.show();
3427 this.get('viewbox').el.hide();
3428 print("TRIED TO HIDE");
3431 this.get('buttonbar').el.hide();
3432 this.get('viewbox').el.show();
3433 // this.get('model').expanded();
3445 pack : "pack_start,false,true",
3447 "clicked":function (self) {
3448 this.get('/RightPalete').show();
3455 stock : Gtk.STOCK_GOTO_FIRST,
3456 icon_size : Gtk.IconSize.MENU
3466 XObject.prototype.init.call(this);
3467 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3470 "enter_notify_event":function (self, event) {
3471 this.get('/RightPalete').show();
3485 pack : "pack_start,false,true",
3494 pack : "pack_start,false,true",
3496 "clicked":function (self) {
3497 this.get('/RightPalete').hide();
3504 stock : Gtk.STOCK_GOTO_LAST,
3505 icon_size : Gtk.IconSize.MENU
3512 xtype: Gtk.ScrolledWindow,
3515 XObject.prototype.init.call(this);
3516 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3517 this.el.set_size_request(-1,200);
3519 shadow_type : Gtk.ShadowType.IN,
3522 xtype: Gtk.TreeView,
3525 XObject.prototype.init.call(this);
3526 this.el.set_size_request(150,-1);
3527 // set_reorderable: [1]
3529 var description = new Pango.FontDescription.c_new();
3530 description.set_size(8000);
3531 this.el.modify_font(description);
3533 this.selection = this.el.get_selection();
3534 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3535 // this.selection.signal['changed'].connect(function() {
3536 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3538 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3540 Gtk.drag_source_set (
3541 this.el, /* widget will be drag-able */
3542 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3543 null, /* lists of target to support */
3544 0, /* size of list */
3545 Gdk.DragAction.COPY /* what to do with data after dropped */
3547 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3549 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3550 Gtk.drag_source_add_text_targets(this.el);
3552 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3553 targets = new Gtk.TargetList();
3554 targets.add( LeftTree.atoms["STRING"], 0, 0);
3555 targets.add_text_targets( 1 );
3556 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3558 //if you want to allow text to be output elsewhere..
3559 //Gtk.drag_source_add_text_targets(this.el);
3563 headers_visible : false,
3564 enable_tree_lines : true,
3566 "drag_begin":function (self, ctx) {
3567 // we could fill this in now...
3568 Seed.print('SOURCE: drag-begin');
3572 var iter = new Gtk.TreeIter();
3573 var s = this.selection;
3574 s.get_selected(this.get('/RightPalete.model').el, iter);
3575 var path = this.get('/RightPalete.model').el.get_path(iter);
3577 var pix = this.el.create_row_drag_icon ( path);
3580 Gtk.drag_set_icon_pixmap (ctx,
3587 var value = new GObject.Value('');
3588 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3589 if (!this.get('/RightPalete').provider) {
3592 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3593 this.el.dragData = value.value;
3600 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3601 //Seed.print('Palete: drag-data-get: ' + target_type);
3602 if (this.el.dragData && this.el.dragData.length ) {
3603 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3607 //this.el.dragData = "TEST from source widget";
3611 "drag_end":function (self, drag_context) {
3612 Seed.print('SOURCE: drag-end');
3613 this.el.dragData = false;
3614 this.el.dropList = false;
3615 this.get('/LeftTree.view').highlight(false);
3621 xtype: Gtk.ListStore,
3624 XObject.prototype.init.call(this);
3625 this.el.set_column_types ( 2, [
3626 GObject.TYPE_STRING, // title
3627 GObject.TYPE_STRING // tip
3632 load : function(tr,iter)
3637 //console.log('Project tree load: ' + tr.length);
3638 var citer = new Gtk.TreeIter();
3639 //this.insert(citer,iter,0);
3640 for(var i =0 ; i < tr.length; i++) {
3643 this.el.append(citer);
3645 this.el.insert(citer,iter,-1);
3650 this.el.set_value(citer, 0, '' + r ); // title
3652 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3653 //if (r.cn && r.cn.length) {
3654 // this.load(r.cn, citer);
3660 getValue : function (iter, col) {
3661 var gval = new GObject.Value('');
3662 this.el.get_value(iter, col ,gval);
3669 xtype: Gtk.TreeViewColumn,
3670 pack : "append_column",
3672 XObject.prototype.init.call(this);
3673 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3677 xtype: Gtk.CellRendererText,
3699 XObject.cache['/Window'] = Window;