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]);
252 getRenderer : function() {
253 var model = this.get('model');
254 // print("RENDER VIEW?" + model.file.getType());
255 switch( model.file.getType()) {
257 this.get('/RightBrowser.view');
259 return this.get('/RightGtkView');
263 getActivePath : function() {
264 var model = this.get('model');
265 var view = this.get('view');
266 if (view.selection.count_selected_rows() < 1) {
269 var iter = new Gtk.TreeIter();
271 view.selection.get_selected(model.el, iter);
272 return model.el.get_path(iter).to_string();
279 headers_visible : false,
280 enable_tree_lines : true,
283 XObject.prototype.init.call(this);
284 var description = new Pango.FontDescription.c_new();
285 description.set_size(8000);
286 this.el.modify_font(description);
288 this.selection = this.el.get_selection();
289 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
292 // is this really needed??
293 this.selection.signal['changed'].connect(function() {
294 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
295 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
299 Gtk.drag_source_set (
300 this.el, /* widget will be drag-able */
301 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
302 null, /* lists of target to support */
303 0, /* size of list */
304 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
307 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
309 Gtk.drag_source_add_text_targets(this.el);
312 this.el, /* widget that will accept a drop */
313 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
314 null, /* lists of target to support */
315 0, /* size of list */
316 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
319 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
320 Gtk.drag_dest_add_text_targets(this.el);
322 highlight : function(treepath_ar) {
324 // highlighting for drag/drop
325 if (treepath_ar.length && treepath_ar[0].length ) {
326 this.el.set_drag_dest_row(
327 new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);
329 this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
333 selectNode : function(treepath_str) {
334 //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
335 var tp = new Gtk.TreePath.from_string(treepath_str);
336 this.el.set_cursor(tp, null, false);
337 this.el.scroll_to_cell(tp, null, false, 0,0);
340 "button_press_event":function (self, ev) {
341 console.log("button press?");
342 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
343 print("click" + ev.type);
349 this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
351 if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();
353 this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
354 this.get('/LeftTreeMenu').el.show_all();
355 this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
356 print("click:" + res.path.to_string());
359 "drag_begin":function (self, drag_context) {
360 print('SOURCE: drag-begin');
361 this.targetData = false;
362 // find what is selected in our tree...
363 var iter = new Gtk.TreeIter();
364 var s = this.selection;
365 s.get_selected(this.get('/LeftTree.model').el, iter);
367 // set some properties of the tree for use by the dropped element.
368 var value = new GObject.Value('');
369 this.get('/LeftTree.model').el.get_value(iter, 2, value);
370 var data = JSON.parse(value.value);
371 var xname = this.get('/LeftTree.model').file.guessName(data);
373 this.el.dragData = xname;
374 this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);
377 // make the drag icon a picture of the node that was selected
378 var path = this.get('/LeftTree.model').el.get_path(iter);
379 this.el.treepath = path.to_string();
381 var pix = this.el.create_row_drag_icon ( path);
383 Gtk.drag_set_icon_pixmap (ctx,
392 "drag_end":function (self, drag_context) {
393 Seed.print('LEFT-TREE: drag-end');
394 this.el.dragData = false;
395 this.el.dropList = false;
396 this.targetData = false;
397 this.get('/LeftTree.view').highlight(false);
400 "drag_motion":function (self, ctx, x, y, time) {
401 console.log("LEFT-TREE: drag-motion");
402 var src = Gtk.drag_get_source_widget(ctx);
404 // a drag from elsewhere...- prevent drop..
406 print("no drag data!");
407 Gdk.drag_status(ctx, 0, time);
408 this.targetData = false;
411 var action = Gdk.DragAction.COPY;
412 if (src == this.el) {
413 // unless we are copying!!! ctl button..
414 action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
418 if (!this.get('/LeftTree.model').el.iter_n_children(null)) {
419 // no children.. -- asume it's ok..
420 this.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];
421 Gdk.drag_status(ctx, action ,time);
425 print("GETTING POS");
426 var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);
427 print("ISOVER? " + isOver);
429 Gdk.drag_status(ctx, 0 ,time);
430 return false; // not over apoint!?!
432 // drag node is parent of child..
433 console.log("SRC TREEPATH: " + src.treepath);
434 console.log("TARGET TREEPATH: " + data.path.to_string());
436 // nned to check a few here..
437 //Gtk.TreeViewDropPosition.INTO_OR_AFTER
438 //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
439 //Gtk.TreeViewDropPosition.AFTER
440 //Gtk.TreeViewDropPosition.BEFORE
442 if (typeof(src.treepath) != 'undefined' &&
443 src.treepath == data.path.to_string().substring(0,src.treepath.length)) {
444 print("subpath drag");
445 Gdk.drag_status(ctx, 0 ,time);
450 //print("DUMPING DATA");
451 //console.dump(data);
454 print(data.path.to_string() +' => '+ data.pos);
455 var tg = this.get('/LeftTree.model').findDropNodeByPath(
456 data.path.to_string(), src.dropList, data.pos);
458 this.get('/LeftTree.view').highlight(tg);
460 print("Can not find drop node path");
461 this.targetData = false;
462 Gdk.drag_status(ctx, 0, time);
466 this.targetData = tg;
469 Gdk.drag_status(ctx, action ,time);
473 "drag_drop":function (w, ctx, x, y, time) {
474 Seed.print("TARGET: drag-drop");
478 w, /* will receive 'drag-data-received' signal */
479 ctx, /* represents the current state of the DnD */
480 this.get('/Window').atoms["STRING"], /* the target type we want */
481 time /* time stamp */
485 /* No target offered by source => error */
490 "drag_data_received":function (self, ctx, x, y, sel_data, info, time) {
491 print("Tree: drag-data-received");
493 var delete_selection_data = false;
494 var dnd_success = false;
495 /* Deal with what we are given from source */
496 if( sel_data && sel_data.length ) {
498 if (ctx.action == Gdk.DragAction.ASK) {
499 /* Ask the user to move or copy, then set the ctx action. */
502 if (ctx.action == Gdk.DragAction.MOVE) {
503 //delete_selection_data = true;
506 var source = Gtk.drag_get_source_widget(ctx);
508 if (this.targetData) {
509 if (source != this.el) {
510 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
512 // drag around.. - reorder..
513 this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);
517 //Seed.print(this.targetData);
523 // we can send stuff to souce here...
529 if (dnd_success == false)
531 Seed.print ("DnD data transfer failed!\n");
534 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
537 "cursor_changed":function (self) {
538 if (this.blockChanges) { // probably not needed..
541 var render = this.get('/LeftTree').getRenderer();
544 if (this.selection.count_selected_rows() < 1) {
545 this.get('/LeftPanel.model').load( false);
546 this.get('/MidPropTree').activeElement = false;
547 this.get('/MidPropTree').hideWin();
549 var pm = this.get('/RightPalete.model');
550 if (!this.get('/LeftTree').getPaleteProvider()) {
551 // it may not be loaded yet..
554 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
555 this.get('/LeftTree.model').listAllTypes()));
556 if (render && render.redraw) {
562 //console.log('changed');
563 var s = this.selection;
564 var iter = new Gtk.TreeIter();
565 s.get_selected(this.get('/LeftTree.model').el, iter);
569 value = new GObject.Value('');
570 this.get('/LeftTree.model').el.get_value(iter, 2, value);
571 this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
573 var data = JSON.parse(value.value);
574 this.get('/MidPropTree').activeElement = data;
575 this.get('/MidPropTree').hideWin();
576 this.get('/LeftPanel.model').load( data);
578 console.log(value.value);
579 // _g.button.set_label(''+value.get_string());
581 var pm =this.get('/RightPalete.model');
582 pm.load( this.get('/RightPalete').provider.gatherList(
583 this.get('/LeftTree.model').listAllTypes()));
586 if (render && render.redraw) {
590 //Seed.print( value.get_string());
597 xtype: Gtk.TreeStore,
601 XObject.prototype.init.call(this);
602 this.el.set_column_types ( 3, [
603 GObject.TYPE_STRING, // title
604 GObject.TYPE_STRING, // tip
605 GObject.TYPE_STRING // source..
609 changed : function(n, refresh) {
610 print("MODEL CHANGED CALLED" + this.activePath);
611 if (this.activePath) {
612 var iter = new Gtk.TreeIter();
613 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
614 this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
615 this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
617 this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
619 //this.currentTree = this.toJS(false, true)[0];
620 this.file.items = this.toJS(false, false);
621 print("AFTER CHANGED");
622 //console.dump(this.file.items);
624 this.currentTree = this.file.items[0];
625 //console.log(this.file.toSource());
628 print("REDNER BROWSER?!");
629 this.get('/LeftTree').renderView();
631 var pm = this.get('/RightPalete.model');
632 if (!this.get('/RightPalete').provider) {
638 pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
639 //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
643 loadFile : function(f) {
649 console.log('missing file');
653 // load the file if not loaded..
654 if (f.items === false) {
656 f.loadItems(function() {
662 if (f.items.length && typeof(f.items[0]) == 'string') {
664 this.get('/RightEditor').el.show();
665 this.get('/RightEditor.view').load( f.items[0]);
669 //console.dump(f.items);
671 this.get('/LeftTree.view').el.expand_all();
673 if (!f.items.length) {
676 this.get('/Window.leftvpaned').el.set_position(80);
678 this.get('/LeftTree.view').el.set_cursor(
679 new Gtk.TreePath.from_string('0'), null, false);
683 this.get('/Window.leftvpaned').el.set_position(200);
687 //print("hide right editior");
688 this.get('/RightEditor').el.hide();
689 //print("set current tree");
690 this.currentTree = this.toJS(false, false)[0];
691 //console.dump(this.currentTree);
692 this.currentTree = this.currentTree || { items: [] };
693 this.get('/LeftTree').renderView();
694 //console.dump(this.map);
695 //var RightPalete = imports.Builder.RightPalete.RightPalete;
696 var pm = this.get('/RightPalete.model');
699 this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
701 if (!this.get('/RightPalete').provider) {
702 print ("********* PALETE PROVIDER MISSING?!!");
704 this.get('/LeftTree').renderView();
706 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
710 this.get('/Window.view-notebook').el.set_current_page(
711 this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
714 findDropNode : function(treepath_str, targets) {
716 // this is used by the dragdrop code in the roo version AFAIR..
718 var path = treepath_str.replace(/^builder-/, '');
719 // treemap is depreciated... - should really check if model has any entries..
721 if (!this.el.iter_n_children(null)) {
723 return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];
725 print("FIND treepath: " + path);
726 //console.dump(this.treemap);
728 if (!treepath_str.match(/^builder-/)) {
729 return []; // nothing!
731 if (targets === true) {
734 return this.findDropNodeByPath(path,targets)
736 findDropNodeByPath : function(treepath_str, targets, pref) {
737 var path = treepath_str + ''; // dupe it..
738 pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
740 //console.dump(this.treemap);
741 while (path.length) {
742 print("LOOKING FOR PATH: " + path);
743 var node_data = this.singleNodeToJS(path);
744 if (node_data === false) {
745 print("node not found");
749 var xname = this.get('/LeftTree.model').file.guessName(node_data);
752 targets.forEach(function(tg) {
756 if ((tg == xname) ) {
759 if (tg.indexOf(xname +':') === 0) {
761 prop = tg.split(':').pop();
766 if (last) { // pref is after/before..
767 // then it's after last
769 return []; // do not allow..
771 return [ last, pref , prop];
774 return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
776 var par = path.split(':');
779 path = par.join(':');
785 dropNode : function(target_data, node) {
788 console.dump(target_data);
789 var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
791 print("add " + tp + "@" + target_data[1] );
794 if (tp && target_data[1] < 2) { // before or after..
795 var ar = target_data[0].split(':');
797 parent = new Gtk.TreePath.from_string( ar.join(':') );
800 var n_iter = new Gtk.TreeIter();
801 var iter_par = new Gtk.TreeIter();
802 var iter_after = after ? new Gtk.TreeIter() : false;
806 if (parent !== false) {
807 this.el.get_iter(iter_par, parent);
814 print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
815 this.el.get_iter(iter_after, after);
816 this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
817 n_iter, iter_par, iter_after);
820 this.el.append(n_iter, iter_par);
824 if (typeof(node) == 'string') {
825 var ar = node.split('.');
826 var xtype = ar.pop();
829 '|xns' : ar.join('.'),
832 if (target_data.length == 3 && target_data[2].length) {
833 node['*prop'] = target_data[2];
837 // work out what kind of packing to use..
838 if (typeof(node.pack) == 'undefined' && parent !== false) {
839 var pal = this.get('/LeftTree').getPaleteProvider();
841 var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
842 print ("PNAME : " + pname);
843 var cname = pal.guessName(node);
844 print ("CNAME : " + cname);
845 node.pack = pal.getDefaultPack(pname, cname);
856 // load children - if it has any..
859 this.load(xitems, n_iter);
861 if (tp && (xitems || after)) {
862 this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
864 // wee need to get the empty proptypes from somewhere..
866 //var olditer = this.activeIter;
867 this.activePath = this.el.get_path(n_iter).to_string();
869 // changed actually set's the node data..
870 this.changed(node, true);
874 this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
876 //Builder.MidPropTree._model.load(node);
877 //Builder.MidPropTree._win.hideWin();
878 //Builder.LeftPanel._model.load( node);
882 moveNode : function(target_data, action) {
883 //print("MOVE NODE");
884 // console.dump(target_data);
885 var old_iter = new Gtk.TreeIter();
886 var s = this.get('/LeftTree.view').selection;
887 s.get_selected(this.el, old_iter);
888 var node = this.nodeToJS(old_iter,false);
889 //console.dump(node);
892 // needs to drop first, otherwise the target_data
893 // treepath will be invalid.
895 this.dropNode(target_data, node);
896 if (action & Gdk.DragAction.MOVE) {
897 // print("REMOVING OLD NODE");
898 this.el.remove(old_iter);
902 this.activePath= false;
903 this.changed(false,true);
905 deleteSelected : function() {
906 this.get('/LeftTree.view').blockChanges = true;
907 var old_iter = new Gtk.TreeIter();
908 var s = this.get('/LeftTree.view').selection;
909 s.get_selected(this.el, old_iter);
910 var path = this.el.get_path(old_iter).to_string();
912 this.activePath= false;
915 this.activePath= false;
916 var iter = new Gtk.TreeIter();
917 this.el.get_iter_from_string(iter, path);
918 this.el.remove(iter);
920 // rebuild treemap. -- depreciated.!!
923 //this.toJS(null, true) // does not do anything?
924 this.activePath= false;
925 this.changed(false,true);
926 this.get('/LeftTree.view').blockChanges = false;
929 listAllTypes : function() {
930 var s = this.get('/LeftTree.view').selection;
931 print ("LIST ALL TYPES: " + s.count_selected_rows() );
933 if (s.count_selected_rows() > 0) {
934 var iter = new Gtk.TreeIter();
935 s.get_selected(this.el, iter);
937 // set some properties of the tree for use by the dropped element.
938 var value = new GObject.Value('');
939 this.el.get_value(iter, 2, value);
940 var data = JSON.parse(value.value);
943 var xname = this.get('/LeftTree.model').file.guessName(data);
944 console.log('selected:' + xname);
948 return []; // could not find it..
956 li.forEach(function(el) {
957 // this is specific to roo!!!?
959 var fullpath = _this.file.guessName(el);
960 if (fullpath.length && ret.indexOf(fullpath) < 0) {
965 if (el.items && el.items.length) {
974 addall([this.currentTree]);
976 // only if we have nothing, should we add '*top'
980 //console.log('all types in tree');
986 singleNodeToJS : function (treepath)
988 var iter = new Gtk.TreeIter();
989 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
993 var iv = this.getIterValue(iter, 2);
995 return JSON.parse(iv);
998 nodeToJS : function (iter, with_id)
1000 var par = new Gtk.TreeIter();
1001 var iv = this.getIterValue(iter, 2);
1002 // print("IV" + iv);
1003 var k = JSON.parse(iv);
1004 if (k.json && !this.el.iter_parent( par, iter )) {
1009 var treepath_str = this.el.get_path(iter).to_string();
1010 // not sure how we can handle mixed id stuff..
1011 if (typeof(k.id) == 'undefined') {
1012 k.id = 'builder-'+ treepath_str ;
1016 this.treemap[ treepath_str ] = k;
1017 k.xtreepath = treepath_str ;
1020 if (this.el.iter_has_child(iter)) {
1021 citer = new Gtk.TreeIter();
1022 this.el.iter_children(citer, iter);
1023 k.items = this.toJS(citer,with_id);
1027 toJS : function(iter, with_id)
1029 //Seed.print("WITHID: "+ with_id);
1036 iter = new Gtk.TreeIter();
1037 if (!this.el.get_iter_first(iter)) {
1047 var k = this.nodeToJS(iter, with_id);
1051 if (!this.el.iter_next(iter)) {
1057 // convert the list into a json string..
1061 getIterValue : function (iter, col) {
1062 var gval = new GObject.Value('');
1063 this.el.get_value(iter, col ,gval);
1068 nodeTitle : function(c) {
1071 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
1072 if (sr) txt.push('<s>');
1073 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
1074 if (c.xtype) { txt.push(c.xtype); }
1075 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1076 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1077 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1080 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1081 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1082 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1083 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1084 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1085 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1086 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1087 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1088 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1090 // for flat classes...
1091 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1092 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1095 if (sr) txt.push('</s>');
1096 return (txt.length == 0 ? "Element" : txt.join(" "));
1098 nodeToJSON : function(c) {
1106 return JSON.stringify(o);
1108 load : function(tr,iter)
1110 var citer = new Gtk.TreeIter();
1111 //this.insert(citer,iter,0);
1112 for(var i =0 ; i < tr.length; i++) {
1114 this.el.insert(citer,iter,-1);
1116 this.el.append(citer);
1119 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1120 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTip(tr[i]) ]);
1121 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1122 if (tr[i].items && tr[i].items.length) {
1123 this.load(tr[i].items, citer);
1127 nodeTip : function(c) {
1128 var ret = this.nodeTitle(c);
1134 if (!i.length || i[0] != '|') {
1140 if (typeof(c[i]) != 'string') {
1143 //print("prop : " + i + ':' + c[i]);
1144 if (!c[i].match(new RegExp('function'))) {
1147 funcs += "\n<b>" + i.substring(1) + '</b> : ' + c[i].split(/\n/).shift();
1151 ret+="\n\nMethods:" + funcs;
1158 xtype: Gtk.TreeViewColumn,
1159 pack : "append_column",
1161 XObject.prototype.init.call(this);
1162 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1166 xtype: Gtk.CellRendererText,
1176 id : "LeftTreeMenu",
1179 xtype: Gtk.MenuItem,
1181 label : "Delete Element",
1183 "activate":function (self) {
1185 this.get('/LeftTree.model').deleteSelected();
1196 id : "LeftProjectTree",
1197 showNoProjectSelected : function() {
1198 this.get('/StandardErrorDialog').show("Select a Project first.");
1200 getActiveProject : function() {
1201 return this.project;
1204 "leave_notify_event":function (self, event) {
1211 pack : "pack_start,false,false",
1214 xtype: Gtk.ComboBox,
1217 XObject.prototype.init.call(this);
1218 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1220 getValue : function() {
1221 var ix = this.el.get_active();
1225 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1226 if (typeof(data[ix]) == 'undefined') {
1231 setValue : function(fn)
1235 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1236 data.forEach(function(n, ix) {
1244 "changed":function (self) {
1245 var fn = this.getValue();
1246 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1247 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1252 xtype: Gtk.CellRendererText,
1253 pack : "pack_start,true",
1257 xtype: Gtk.ListStore,
1260 XObject.prototype.init.call(this);
1261 this.el.set_column_types ( 2, [
1262 GObject.TYPE_STRING, // real key
1263 GObject.TYPE_STRING // real type
1267 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1269 pm.on('changed', function() {
1270 print("caught changed hook on project manager - reloading data");
1271 _this.loadData(pm.projects);
1275 loadData : function(data) {
1276 var ov = this.get('/LeftProjectTree.combo').getValue();
1278 var iter = new Gtk.TreeIter();
1280 data.forEach(function(p) {
1285 el.set_value(iter, 0, p.fn);
1286 el.set_value(iter, 1, p.name);
1290 this.get('/LeftProjectTree.combo').setValue(ov);
1299 xtype: Gtk.ScrolledWindow,
1301 shadow_type : Gtk.ShadowType.IN,
1303 XObject.prototype.init.call(this);
1304 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1308 xtype: Gtk.TreeView,
1309 headers_visible : false,
1310 enable_tree_lines : true,
1313 XObject.prototype.init.call(this);
1314 var description = new Pango.FontDescription.c_new();
1315 description.set_size(8000);
1316 this.el.modify_font(description);
1318 this.selection = this.el.get_selection();
1319 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1323 "cursor_changed":function (self) {
1324 var iter = new Gtk.TreeIter();
1326 if (this.selection.count_selected_rows() < 1) {
1327 //XN.get('Builder.LeftTree.model').
1328 this.get('/LeftTree.model').load( false);
1332 var model = this.get('/LeftProjectTree.model');
1333 //console.log('changed');
1334 var s = this.selection;
1335 s.get_selected(model, iter);
1336 value = new GObject.Value('');
1337 model.el.get_value(iter, 2, value);
1339 console.log(value.value);// id..
1341 var file = this.get('/LeftProjectTree').project.getById(value.value);
1348 var nb = this.get('/LeftTopPanel.expander');
1349 nb.el.expanded = false;
1350 nb.listeners.activate.call(nb);
1351 //_expander.el.set_expanded(false);
1353 var ltm = this.get('/LeftTree.model');
1361 xtype: Gtk.TreeStore,
1365 XObject.prototype.init.call(this);
1366 this.el.set_column_types ( 3, [
1367 GObject.TYPE_STRING, // title
1368 GObject.TYPE_STRING, // tip
1369 GObject.TYPE_STRING // id..
1373 loadProject : function(pr) {
1378 this.get('/LeftProjectTree').project = pr;
1379 this.load(pr.toTree());
1380 this.get('/LeftProjectTree.view').el.expand_all();
1382 load : function(tr,iter) {
1384 console.log('Project tree load: ' + tr.length);
1385 var citer = new Gtk.TreeIter();
1386 //this.insert(citer,iter,0);
1389 tr.forEach(function (r) {
1391 _this.el.append(citer);
1393 _this.el.insert(citer,iter,-1);
1395 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1396 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1397 _this.el.set_value(citer, 2, '' + r.id ); //id
1398 if (r.cn && r.cn.length) {
1399 _this.load(r.cn, citer);
1404 getValue : function(iter, col) {
1405 var gval = new GObject.Value('');
1406 this.el.get_value(iter, col ,gval);
1407 return '' + gval.value;
1411 xtype: Gtk.TreeViewColumn,
1412 pack : "append_column",
1414 XObject.prototype.init.call(this);
1415 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1419 xtype: Gtk.CellRendererText,
1442 pack : "pack_start,false,true,0",
1449 "button_press_event":function (self, event) {
1450 this.get('/MidPropTree.model').showData('props');
1462 stock : Gtk.STOCK_ADD,
1463 icon_size : Gtk.IconSize.MENU
1478 "button_press_event":function (self, event) {
1479 this.get('/MidPropTree.model').showData('events');
1491 stock : Gtk.STOCK_ADD,
1492 icon_size : Gtk.IconSize.MENU
1507 "button_press_event":function (self, ev) {
1508 var p = this.get('/AddPropertyPopup');
1512 p.el.set_screen(Gdk.Screen.get_default());
1514 p.el.popup(null, null, null, null, 3, ev.button.time);
1526 stock : Gtk.STOCK_ADD,
1527 icon_size : Gtk.IconSize.MENU
1539 id : "AddPropertyPopup",
1542 xtype: Gtk.MenuItem,
1544 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1547 "activate":function (self) {
1549 this.get('/LeftPanel.model').add( {
1560 xtype: Gtk.MenuItem,
1562 tooltip_markup : "Add what type of packing is to be used",
1565 "activate":function (self) {
1567 this.get('/LeftPanel.model').add( {
1577 xtype: Gtk.MenuItem,
1579 tooltip_markup : "Override the init method",
1582 "activate":function (self) {
1584 this.get('/LeftPanel.model').add( {
1587 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1594 xtype: Gtk.SeparatorMenuItem,
1598 xtype: Gtk.MenuItem,
1600 tooltip_markup : "Add a user defined string property",
1603 "activate":function (self) {
1605 this.get('/LeftPanel.model').add( {
1615 xtype: Gtk.MenuItem,
1617 tooltip_markup : "Add a user defined number property",
1620 "activate":function (self) {
1622 this.get('/LeftPanel.model').add( {
1632 xtype: Gtk.MenuItem,
1634 tooltip_markup : "Add a user defined boolean property",
1637 "activate":function (self) {
1639 this.get('/LeftPanel.model').add( {
1649 xtype: Gtk.SeparatorMenuItem,
1653 xtype: Gtk.MenuItem,
1655 tooltip_markup : "Add a user function boolean property",
1658 "activate":function (self) {
1660 this.get('/LeftPanel.model').add( {
1663 val : "function() {\n \n}\n",
1676 xtype: Gtk.ScrolledWindow,
1679 shadow_type : Gtk.ShadowType.IN,
1682 XObject.prototype.init.call(this);
1683 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1687 xtype: Gtk.TreeView,
1690 headers_visible : false,
1691 enable_tree_lines : true,
1693 XObject.prototype.init.call(this);
1695 this.selection = this.el.get_selection();
1696 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1699 var description = new Pango.FontDescription.c_new();
1700 description.set_size(8000);
1701 this.el.modify_font(description);
1704 "button_press_event":function (self, ev) {
1708 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1709 return false; //not on a element.
1713 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1715 if (res.column.title != 'value') {
1716 return false; // ignore..
1718 if ( this.get('/LeftPanel').editing) {
1721 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1722 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1723 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1727 var provider = this.get('/LeftTree').getPaleteProvider();
1729 var opts = provider.findOptions(type);
1731 if (opts === false) {
1732 this.get('/LeftPanel').editableColumn.setOptions([]);
1733 renderer.has_entry = true;
1735 LeftPanel.editableColumn.setOptions(opts);
1736 renderer.has_entry = false;
1740 //Seed.print("click" + ev.type);
1741 //console.dump(res);
1747 if (res.column.title == 'value') {
1750 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1751 var p = this.get('/LeftPanelPopup');
1756 p.el.set_screen(Gdk.Screen.get_default());
1758 p.el.popup(null, null, null, null, 3, ev.button.time);
1759 //Seed.print("click:" + res.column.title);
1767 xtype: Gtk.TreeStore,
1771 XObject.prototype.init.call(this);
1772 this.el.set_column_types ( 5, [
1773 GObject.TYPE_STRING, // 0 real key
1774 GObject.TYPE_STRING, // 1 real value
1775 GObject.TYPE_STRING, // 2 visable key
1776 GObject.TYPE_STRING, // 3 visable value
1777 GObject.TYPE_STRING, // 4 need to store type of!!!
1781 toShort : function(str) {
1782 var a = typeof(str) == 'string' ? str.split("\n") : [];
1783 return a.length > 1 ? a[0] + '....' : '' + str;
1785 load : function(ar) {
1788 this.get('/RightEditor').el.hide();
1795 var provider = this.get('/LeftTree').getPaleteProvider();
1798 var iter = new Gtk.TreeIter();
1800 if (typeof(ar[i]) == 'object') {
1804 var type = provider.findType(ar, i, ar[i]);
1806 this.el.append(iter);
1807 var p = this.el.get_path(iter).to_string();
1809 this.el.set_value(iter, 0, i);
1810 this.el.set_value(iter, 1, '' + ar[i]);
1811 this.el.set_value(iter, 2, i);
1812 this.el.set_value(iter, 3, this.toShort(ar[i]));
1813 this.el.set_value(iter, 4, type);
1815 ar.listeners = ar.listeners || {};
1816 for (var i in ar.listeners ) {
1817 this.el.append(iter);
1818 var p = this.el.get_path(iter).to_string();
1821 this.el.set_value(iter, 0, '!'+ i );
1822 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1823 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1825 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1826 this.el.set_value(iter, 4, 'function');
1830 add : function(info) {
1831 // info includes key, val, skel, etype..
1833 type = info.type.toLowerCase();
1834 var data = this.toJS();
1836 if (info.etype == 'events') {
1837 data.listeners = data.listeners || { };
1838 if (typeof(data.listeners[info.key]) != 'undefined') {
1839 return; //already set!
1842 if (typeof(data[info.key]) != 'undefined') {
1847 if (typeof(info.val) == 'undefined') {
1850 if (info.type == 'boolean') {
1853 if (type == 'number') {
1861 if (info.etype == 'events') {
1863 data.listeners[info.key] = info.val;
1866 data[info.key] = info.val;
1870 var map = this.load(data);
1872 // flag it as changed to the interface..
1874 this.get('/LeftTree.model').changed(data, true);
1877 this.startEditing(map[k]);
1880 LeftPanel.get('view').el.row_activated(
1881 new Gtk.TreePath.from_string(map[k]),
1882 LeftPanel.editableColumn.el
1886 startEditing : function(path,col) {
1888 * start editing path (or selected if not set..)
1889 * @param {String|false} path (optional) treepath to edit - selected tree gets
1890 * edited by default.
1891 * @param {Number} 0 or 1 (optional)- column to edit.
1894 if (typeof(path) == 'string') {
1895 tp = new Gtk.TreePath.from_string(path);
1897 var iter = new Gtk.TreeIter();
1898 var s = this.get('/LeftPanel.view').selection;
1899 s.get_selected(this.el, iter);
1900 tp = this.el.get_path(iter);
1901 path = tp.to_string();
1905 // which colum is to be edited..
1907 if (typeof(col) == 'undefined') {
1908 var k = this.getValue(path, 0);
1909 colObj = (!k.length || k == '|') ?
1910 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1912 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1915 // make sure the pulldown is set correctly..
1916 // not really needed for second col...
1918 var provider = this.get('/LeftTree').getPaleteProvider();
1920 var type = this.get('/LeftPanel.model').getType(path);
1921 var opts = provider.findOptions(type);
1922 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1924 if (opts === false) {
1925 this.get('/LeftPanel').editableColumn.setOptions([]);
1926 renderer.has_entry = true; /// probably does not have any effect.
1928 this.get('/LeftPanel').editableColumn.setOptions(opts);
1929 renderer.has_entry = false;
1933 // iter now has row...
1934 GLib.timeout_add(0, 100, function() {
1936 colObj.items[0].el.editable = true; // esp. need for col 0..
1937 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1946 deleteSelected : function() {
1947 var data = this.toJS();
1948 var iter = new Gtk.TreeIter();
1949 var s = this.get('/LeftPanel.view').selection;
1950 s.get_selected(this.el, iter);
1953 var gval = new GObject.Value('');
1954 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1956 var val = gval.value;
1957 if (val[0] == '!') {
1959 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1962 delete data.listeners[ val.substring(1)];
1963 if (!XObject.keys(data.listeners).length) {
1964 delete data.listeners;
1968 if (typeof(data[val]) == 'undefined') {
1976 this.get('/LeftTree.model').changed(data, true);
1980 changed : function(str, doRefresh) {
1981 if (!this.activePath) {
1984 var iter = new Gtk.TreeIter();
1985 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1987 this.el.set_value(iter, 1, '' +str);
1988 this.el.set_value(iter, 3, '' + this.toShort(str));
1989 // update the tree...
1991 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
1994 var iter = new Gtk.TreeIter();
1995 this.get('/LeftPanel.model').el.get_iter_first(iter);
2000 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
2003 ar.listeners = ar.listeners || {};
2004 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
2007 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
2010 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
2016 //print(JSON.stringify(ar));
2020 getType : function(treepath) {
2021 return this.getValue(treepath, 4);
2023 getValue : function(treepath_str, col) {
2024 var iter = new Gtk.TreeIter();
2025 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
2027 var gval = new GObject.Value('');
2028 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
2029 var val = '' + gval.value;
2033 var type = this.getType(this.el.get_path(iter).to_string());
2034 //print("TYPE: " +type + " - val:" + val);
2035 switch(type.toLowerCase()) {
2039 return parseFloat(val); // Nan ?? invalid!!?
2041 return val == 'true' ? true : false;
2047 editSelected : function(e) {
2048 print("EDIT SELECTED?");
2049 var iter = new Gtk.TreeIter();
2050 var s = this.get('/LeftPanel.view').selection;
2051 s.get_selected(this.get('/LeftPanel.model').el, iter);
2052 var m = this.get('/LeftPanel.model')
2054 var gval = new GObject.Value('');
2055 this.el.get_value(iter, 0 ,gval);
2056 var val = '' + gval.value;
2058 gval = new GObject.Value('');
2059 this.el.get_value(iter, 1 ,gval);
2060 var rval = gval.value;
2061 var activePath = this.el.get_path(iter).to_string();
2062 this.activePath = activePath ;
2063 // was activeIter...
2066 var showEditor = false;
2068 if (val[0] == '!') {
2071 if (val[0] == '|') {
2072 if (rval.match(/function/g) || rval.match(/\n/g)) {
2079 this.activePath = false;
2080 GLib.timeout_add(0, 1, function() {
2081 // Gdk.threads_enter();
2082 _this.get('/BottomPane').el.show();
2083 _this.get('/RightEditor').el.show();
2084 _this.get('/RightEditor.view').load( rval );
2088 _this.activePath = activePath ;
2090 // Gdk.threads_leave();
2095 this.get('/BottomPane').el.hide();
2096 this.get('/RightEditor').el.hide();
2098 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2104 xtype: Gtk.TreeViewColumn,
2105 pack : "append_column",
2107 XObject.prototype.init.call(this);
2109 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2110 this.get('/LeftPanel').propertyColumn = this;
2115 xtype: Gtk.CellRendererText,
2116 pack : "pack_start",
2118 "editing_started":function (self, editable, path) {
2120 this.get('/LeftPanel.model').activePath = path;
2123 "edited":function (self, object, p0) {
2124 var model = this.get('/LeftPanel.model');
2125 var path = model.activePath;
2126 var iter = new Gtk.TreeIter();
2127 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2128 model.el.set_value(iter, 0, p0);
2129 model.el.set_value(iter, 2, p0);
2131 model.activePath = false;
2133 this.get('/LeftTree.model').changed(model.toJS(), true);
2134 this.el.editable = false;
2141 xtype: Gtk.TreeViewColumn,
2142 pack : "append_column",
2144 XObject.prototype.init.call(this);
2145 this.el.add_attribute(this.items[0].el , 'text', 3 );
2146 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2147 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2148 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2150 this.get('/LeftPanel').editableColumn= this;
2152 setOptions : function(ar) {
2153 var m = this.items[0].el.model;
2155 var iter = new Gtk.TreeIter();
2156 ar.forEach(function(i) {
2159 m.set_value(iter, 0, i);
2165 xtype: Gtk.CellRendererCombo,
2166 pack : "pack_start",
2171 XObject.prototype.init.call(this);
2172 this.el.model = new Gtk.ListStore();
2173 this.el.model.set_column_types ( 1, [
2174 GObject.TYPE_STRING // 0 real key
2178 "edited":function (self, object, p0) {
2179 this.get('/LeftPanel').editing = false;
2180 print("EDITED? p:" + p0 + " t:" + p0);
2181 this.get('/LeftPanel.model').changed(p0, true);
2182 this.get('/LeftPanel.model').activePath = false;
2184 "editing_started":function (self, editable, path) {
2185 this.get('/LeftPanel').editing = true;
2186 // console.log('editing started');
2187 // r.has_entry = false;
2188 this.get('/LeftPanel.model').editSelected(editable);
2199 id : "LeftPanelPopup",
2202 xtype: Gtk.MenuItem,
2206 "activate":function (self) {
2207 this.get('/LeftPanel.model').deleteSelected();
2212 xtype: Gtk.MenuItem,
2216 "activate":function (self) {
2217 this.get('/LeftPanel.model').startEditing(false, 0);
2230 xtype: Gtk.ScrolledWindow,
2231 pack : "pack_end,false,true,0",
2233 shadow_type : Gtk.ShadowType.IN,
2235 XObject.prototype.init.call(this);
2236 XObject.prototype.init.call(this);
2237 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2238 this.el.set_size_request ( 150, -1 );
2241 activeElement : false,
2242 hideWin : function() {
2249 if (this.get('/Window.left').el.position < 160) {
2252 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2259 xtype: Gtk.TreeView,
2260 enable_tree_lines : true,
2261 headers_visible : false,
2264 XObject.prototype.init.call(this);
2266 var description = new Pango.FontDescription.c_new();
2267 description.set_size(8000);
2268 this.el.modify_font(description);
2270 //this.selection = this.el.get_selection();
2271 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2280 "cursor_changed":function (self) {
2281 var iter = new Gtk.TreeIter();
2283 //console.log('changed');
2284 var m = this.get('model');
2285 if (!this.selection){
2286 this.selection = this.el.get_selection();
2289 var s = this.selection;
2290 if (!s.get_selected(m.el, iter)) {
2293 var tp = m.el.get_path(iter).to_string();
2298 var key = m.getValue(tp, 0);
2300 var type = m.getValue(tp, 1);
2301 var skel = m.getValue(tp, 3);
2302 var etype = m.getValue(tp, 5);
2305 this.get('/MidPropTree').hideWin();
2307 if (type == 'function') {
2309 if (etype != 'events') {
2313 this.get('/LeftPanel.model').add({
2322 if (type.indexOf('.') > -1 ||
2323 type == 'boolean') {
2327 this.get('/LeftPanel.model').add( {
2337 xtype: Gtk.ListStore,
2340 XObject.prototype.init.call(this);
2341 this.el.set_column_types ( 6, [
2342 GObject.TYPE_STRING, // real key
2343 GObject.TYPE_STRING, // real type
2344 GObject.TYPE_STRING, // docs ?
2345 GObject.TYPE_STRING, // visable desc
2346 GObject.TYPE_STRING, // function desc
2347 GObject.TYPE_STRING // element type (event|prop)
2351 getValue : function(treepath, col)
2353 var tp = new Gtk.TreePath.from_string (treepath);
2354 var iter = new Gtk.TreeIter();
2355 this.el.get_iter (iter, tp);
2356 var value = new GObject.Value('');
2357 this.el.get_value(iter, col, value);
2361 showData : function(type) {
2363 if (!this.get('/MidPropTree').activeElement || !type) {
2364 return; // no active element
2367 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2368 var palete = this.get('/LeftTree').getPaleteProvider();
2372 Seed.print('Showing right?');
2373 if (!this.get('/MidPropTree').shown) {
2375 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2376 this.get('/MidPropTree').el.show();
2377 this.get('/MidPropTree').shown = true;
2380 var elementList = palete.getPropertiesFor(fullpath, type);
2381 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2382 // console.dump(elementList);
2385 var iter = new Gtk.TreeIter();
2386 for(var i =0 ; i < elementList.length; i++) {
2387 var p=elementList[i];
2388 this.el.append(iter);
2389 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2390 //GObject.TYPE_STRING, // real key
2391 // GObject.TYPE_STRING, // real type
2392 // GObject.TYPE_STRING, // docs ?
2393 // GObject.TYPE_STRING // func def?
2396 this.el.set_value(iter, 0, p.name);
2397 this.el.set_value(iter, 1, p.type);
2398 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2399 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2400 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2401 this.el.set_value(iter, 5, type);
2409 xtype: Gtk.TreeViewColumn,
2411 this.el = new Gtk.TreeViewColumn();
2412 this.parent.el.append_column(this.el);
2414 XObject.prototype.init.call(this);
2415 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2420 xtype: Gtk.CellRendererText,
2421 pack : "pack_start,true"
2445 xtype: Gtk.Notebook,
2446 pack : "pack_start,true,true",
2447 id : "view-help-nb",
2449 XObject.prototype.init.call(this);
2450 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" }));
2451 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" }));
2455 xtype: Gtk.Notebook,
2457 id : "view-notebook",
2460 XObject.prototype.init.call(this);
2461 this.el.set_current_page(0);
2463 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2464 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2471 id : "RightBrowser",
2475 pack : "pack_start,false,true,0",
2479 pack : "pack_start,false,false,0",
2480 label : "Dump HTML to console",
2482 "activate":function (self) {
2483 this.get('/RightBrowser.view').el.execute_script(
2484 "console.log(document.body.innerHTML);");
2485 this.get('/RightBrowser.view').el.execute_script(
2486 "console.log(Builder.dump(Builder));");
2493 xtype: Gtk.ScrolledWindow,
2495 shadow_type : Gtk.ShadowType.IN,
2497 XObject.prototype.init.call(this);
2498 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2502 xtype: WebKit.WebView,
2506 XObject.prototype.init.call(this);
2507 // this may not work!?
2508 this.el.open('file:///' + __script_path__ + '/../builder.html');
2512 this.el, /* widget that will accept a drop */
2513 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2514 null, /* lists of target to support */
2515 0, /* size of list */
2516 Gdk.DragAction.COPY /* what to do with data after dropped */
2519 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2520 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2522 renderJS : function(data) {
2523 this.renderedData = data;
2524 var str = JSON.stringify(data) ;
2527 console.log('not loaded yet');
2529 Seed.print("RENDER:" + str);
2530 imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2531 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2534 "load_finished":function (self, object) {
2535 if (this.ready) { // dont do it twice!
2540 this.renderJS(this.get('/LeftTree.model').toJS()[0]);
2542 "script_alert":function (self, object, p0) {
2545 return true; // do not display anything...
2547 "console_message":function (self, object, p0, p1) {
2548 console.log(object);
2549 if (!object.match(/^\{/)) {
2550 return false; // do not handle!!! -> later maybe in console..
2552 console.log(object);
2553 var val = JSON.parse(object);
2555 if (typeof(val['hover-node']) != 'undefined') {
2556 this.activeNode = val['hover-node'];
2557 console.log('active node: ' + this.activeNode);
2562 if (typeof(val['id']) != 'undefined') {
2563 // this.activeNode = val['id'];
2564 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2568 this.get('/LeftTree.view').selectNode(tg[0]);
2572 if (ret && typeof(val['set']) != 'undefined') {
2573 this.get('/LeftPanel.model').add({
2577 //console.log('active node: ' + this.activeNode);
2580 //Seed.print('a:'+a);
2581 //Seed.print('b:'+b);
2582 //Seed.print('c:'+c);
2585 "drag_motion":function (w, ctx, x, y, time, ud) {
2586 // console.log('DRAG MOTION');
2588 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2589 this.targetData = [];
2590 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2592 // A) find out from drag all the places that node could be dropped.
2593 var src = Gtk.drag_get_source_widget(ctx);
2594 if (!src.dropList) {
2595 Gdk.drag_status(ctx, 0, time);
2598 // b) get what we are over.. (from activeNode)
2599 // tree is empty.. - list should be correct..
2600 if (!this.get('/LeftTree.model').currentTree) {
2601 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2605 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2607 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2610 Gdk.drag_status(ctx, 0,time);
2611 this.get('/LeftTree.view').highlight(false);
2615 // if we have a target..
2616 // -> highlight it! (in browser)
2617 // -> highlight it! (in tree)
2619 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2620 this.get('/LeftTree.view').highlight(tg);
2621 this.targetData = tg;
2622 // for tree we should handle this...
2625 "drag_drop":function (w, ctx, x, y,time, ud) {
2626 print("TARGET: drag-drop");
2627 var is_valid_drop_site = true;
2632 w, /* will receive 'drag-data-received' signal */
2633 ctx, /* represents the current state of the DnD */
2634 this.get('/Window').atoms["STRING"], /* the target type we want */
2635 time /* time stamp */
2639 /* No target offered by source => error */
2642 return is_valid_drop_site;
2644 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2646 print("Browser: drag-data-received");
2647 var delete_selection_data = false;
2648 vardnd_success = false;
2649 /* Deal with what we are given from source */
2650 if( sel_data && sel_data.length ) {
2652 if (ctx.action == Gdk.DragAction.ASK) {
2653 /* Ask the user to move or copy, then set the ctx action. */
2656 if (ctx.action == Gdk.DragAction.MOVE) {
2657 delete_selection_data = true;
2659 var source = Gtk.drag_get_source_widget(ctx);
2661 print("Browser: source.DRAGDATA? " + source.dragData);
2662 if (this.targetData) {
2663 print(this.targetData);
2664 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2673 if (dnd_success == false)
2675 Seed.print ("DnD data transfer failed!\n");
2678 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2690 id : "RightGtkView",
2691 renderJS : function(data, withDebug)
2696 this.withDebug = false;
2698 if (this.renderedEl) {
2699 this.get('view').el.remove(this.renderedEl);
2700 this.renderedEl.destroy();
2701 this.renderedEl = false;
2704 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2705 // in theory tree is actually window..
2707 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2712 this.get('view').el.set_size_request(
2713 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2716 this.renderedEl.set_size_request(
2717 tree.default_width || 600,
2718 tree.default_height || 400
2720 this.get('view').el.show_all();
2725 showInWindow : function() {
2726 print("GET PROEJCT");
2727 var pr = this.get('/LeftProjectTree').getActiveProject();
2729 console.log(pr.paths);
2732 var src= this.buildJS(
2733 this.get('/LeftTree.model').toJS()[0],
2738 //var x = new imports.sandbox.Context();
2742 Seed.check_syntax('var e = ' + src);
2745 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2746 this.get('/Terminal').feed(console._dump(e)+"\n");
2748 var lines = src.split("\n");
2749 var start = Math.max(0, e.line - 10);
2750 var end = Math.min(lines.length, e.line + 10);
2751 for (var i =start ; i < end; i++) {
2753 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2756 this.get('/Terminal').feed(lines[i] + "\n");
2763 this.get('/BottomPane').el.set_current_page(1);
2764 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2765 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2766 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2768 var _top = x.get_global_object()._top;
2770 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2772 if (_top.el.popup) {
2773 _top.el.popup(null, null, null, null, 3, null);
2777 viewAdd : function(item, par)
2779 // does something similar to xobject..
2780 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2782 if (item.pack===false || item.pack === 'false') { // no ;
2785 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2786 var ns = imports.gi[item['|xns']];
2787 var ctr = ns[item['xtype']];
2789 for(var k in item) {
2791 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2806 if (k[0] == '|' && typeof(kv) == 'string') {
2808 if (kv.match(new RegExp('function'))) {
2811 print("WASL " + k + '=' + kv);
2813 eval( 'kv = ' + kv);
2814 } catch(e) { continue; }
2817 print(k + '=' + kv);
2819 if (k[0] == '|') { // should be boolean or number..
2821 print(k + '=' + kv);
2824 if (k == 'show_tabs') { // force tab showing for notebooks.
2832 var el = new ctr(ctr_args);
2835 //console.dump(item.pack);
2842 if (typeof(item.pack) == 'string') {
2844 item.pack.split(',').forEach(function(e, i) {
2846 if (e == 'false') { args.push( false); return; }
2847 if (e == 'true') { args.push( true); return; }
2848 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2851 //print(args.join(","));
2853 pack_m = args.shift();
2855 pack_m = item.pack.shift();
2860 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2862 name: "ArgumentError",
2863 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2864 "ADDING : " + item.id + " " + el
2873 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2874 //Seed.print('args: ' + args.length);
2876 par[pack_m].apply(par, args);
2880 item.items = item.items || [];
2881 item.items.forEach(function(ch) {
2882 _this.viewAdd(ch, el);
2887 // add the signal handlers.
2888 // is it a widget!?!!?
2894 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2895 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2896 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2897 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2898 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2908 widgetExposeEvent : function(w, evt, ud, item) {
2910 if (this.inRender) {
2914 if ( this.highlightWidget) {
2915 this.inRender = true;
2916 if (item.xtreepath.substring(0, this.activePath.length) == this.activePath) {
2917 Gdk.draw_rectangle(this.highlightWidget.window, this.gc, false, this.box.x , this.box.y, this.box.w, this.box.h);
2919 this.inRender = false;
2924 if (this.activePath != item.xtreepath) {
2928 // print("HIGHLIGHT: " + item.xtreepath ); // draw highlight??
2929 // work out the coords of the window..
2931 var dr = widget.window;
2932 this.gc = (new Gdk.GC.c_new(dr));
2933 this.gc.set_rgb_fg_color(new Gdk.Color({ red: 0xFFFF, green: 0, blue : 0 }));
2934 this.gc.set_line_attributes(4, Gdk.LineStyle.SOLID, Gdk.CapStyle.ROUND , Gdk.JoinStyle.ROUND);
2938 var r = evt.expose.area;
2939 // console.dump([r.x, r.y, r.width, r.height ] );
2941 // print(widget.get_parent().toString().match(/GtkScrolledWindow/);
2942 if (widget.get_parent().toString().match(/GtkScrolledWindow/)) { // eak
2943 // happens with gtkscrollview embedded stuff..
2944 var np =this.activePath.split(':');
2946 this.activePath = np.join(':');
2947 this.renderedEl.queue_draw();
2963 this.inRender = true;
2966 this.highlightWidget = widget;
2971 // print("DRAW BOX");
2972 //console.dump(this.box);
2973 Gdk.draw_rectangle(widget.window, this.gc, false, this.box.x , this.box.y, this.box.w,this.box.h);
2974 this.inRender = false;
2977 widgetDragMotionEvent : function() {
2978 print("WIDGET DRAGMOTION");
2981 widgetDragDropEvent : function() {
2982 print("WIDGET DRAGDROP");
2985 widgetPressEvent : function(w,e,u,d) {
2986 if (this.get('view').pressed) {
2989 this.get('view').pressed = true;
2990 print("WIDGET PRESS " + d.xtreepath );
2991 this.get('/LeftTree.view').selectNode( d.xtreepath );
2994 widgetReleaseEvent : function() {
2995 this.get('view').pressed = false;
2998 redraw : function() {
2999 this.highlightWidget = false;
3000 print("REDRAW CALLED");
3001 this.activePath = this.get('/LeftTree').getActivePath();
3002 if (this.renderedEl) {
3003 print("QUEUE DRAW CALLING");
3004 this.renderedEl.queue_draw();
3010 pack : "pack_start,false,true,0",
3014 pack : "pack_start,false,false,0",
3015 label : "Run The Application",
3017 "button_press_event":function (self, event) {
3018 // call render on left tree - with special option!?!
3022 print("GET PROEJCT");
3023 var pr = this.get('/LeftProjectTree').getActiveProject();
3026 for (var i in pr.paths) {
3030 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
3031 print ("RUN DIR:" + dir);
3032 this.get('/BottomPane').el.show();
3033 this.get('/BottomPane').el.set_current_page(1);
3034 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
3035 , false,false,false);
3036 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
3037 this.get('/Terminal').el.feed_child(cmd, cmd.length);
3047 xtype: Gtk.ScrolledWindow,
3050 shadow_type : Gtk.ShadowType.IN,
3052 XObject.prototype.init.call(this);
3053 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3057 xtype: Gtk.EventBox,
3058 pack : "add_with_viewport",
3060 XObject.prototype.init.call(this);
3061 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
3062 red: 0x9F00, green: 0xB800 , blue : 0xA800
3070 XObject.prototype.init.call(this);
3071 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
3072 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
3077 xtype: Gtk.EventBox,
3080 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
3081 XObject.prototype.init.call(this);
3085 this.el, /* widget that will accept a drop */
3086 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
3087 null, /* lists of target to support */
3088 0, /* size of list */
3089 Gdk.DragAction.COPY /* what to do with data after dropped */
3092 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
3093 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
3096 getActiveNode : function(x,y)
3098 // workout what node is here..
3099 return '0'; // top..
3103 "drag_motion":function (self, ctx, x, y, time) {
3105 // A) find out from drag all the places that node could be dropped.
3106 var src = Gtk.drag_get_source_widget(ctx);
3107 if (!src.dropList) {
3108 Gdk.drag_status(ctx, 0, time);
3111 // b) get what we are over.. (from activeNode)
3112 // tree is empty.. - list should be correct..
3113 if (!this.get('/LeftTree.model').currentTree) {
3114 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3118 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
3119 var activeNode = this.getActiveNode(x, y);
3122 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
3125 Gdk.drag_status(ctx, 0,time);
3126 this.get('/LeftTree.view').highlight(false);
3130 // if we have a target..
3131 // -> highlight it! (in browser)
3132 // -> highlight it! (in tree)
3134 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3135 this.get('/LeftTree.view').highlight(tg);
3136 this.targetData = tg;
3137 // for tree we should handle this...
3140 "drag_drop":function (self,ctx, x, y, time) {
3141 Seed.print("TARGET: drag-drop");
3142 var is_valid_drop_site = true;
3147 self, /* will receive 'drag-data-received' signal */
3148 ctx, /* represents the current state of the this.gDnD */
3149 this.get('/Window').atoms["STRING"], /* the target type we want */
3150 time /* time stamp */
3154 /* No target offered by source => error */
3157 return is_valid_drop_site;
3160 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3162 Seed.print("GtkView: drag-data-received");
3163 var delete_selection_data = false;
3164 var dnd_success = false;
3165 /* Deal with what we are given from source */
3166 if( sel_data && sel_data.length ) {
3168 if (ctx.action == Gdk.DragAction.ASK) {
3169 /* Ask the user to move or copy, then set the ctx action. */
3172 if (ctx.action == Gdk.DragAction.MOVE) {
3173 delete_selection_data = true;
3175 var source = Gtk.drag_get_source_widget(ctx);
3177 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3178 if (this.targetData) {
3179 Seed.print(this.targetData);
3180 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3189 if (dnd_success == false)
3191 Seed.print ("DnD data transfer failed!\n");
3194 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3197 "button_press_event":function (self, event) {
3198 this.pressed = false;
3214 xtype: Gtk.ScrolledWindow,
3219 xtype: WebKit.WebView,
3223 XObject.prototype.init.call(this);
3224 this.get('/Window.help-view').el.open(
3225 "http://devel.akbkhome.com/seed/");
3236 xtype: Gtk.Notebook,
3239 XObject.prototype.init.call(this);
3240 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3241 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3246 xtype: Gtk.ScrolledWindow,
3251 xtype: GtkSource.View,
3255 XObject.prototype.init.call(this);
3256 var description = Pango.Font.description_from_string("monospace")
3257 description.set_size(8000);
3258 this.el.modify_font(description);
3261 load : function(str) {
3263 // show the help page for the active node..
3264 this.get('/Window.view-help-nb').el.set_current_page(1);
3266 // get the active element being edited.
3267 var xtype = this.get('/LeftTree.model').file.guessName(
3268 this.get('/MidPropTree').activeElement);
3269 // now load the help info in the page..
3270 this.get('/Window.help-view').el.open(
3271 "http://devel.akbkhome.com/seed/" + xtype + ".html");
3274 this.get('/BottomPane').el.set_current_page(0);
3275 this.el.get_buffer().set_text(str, str.length);
3276 var lm = GtkSource.LanguageManager.get_default();
3278 this.el.get_buffer().set_language(lm.get_language('js'));
3279 var buf = this.el.get_buffer();
3280 var cursor = buf.get_mark("insert");
3281 var iter= new Gtk.TextIter;
3282 buf.get_iter_at_mark(iter, cursor);
3284 iter.set_line_offset(4);
3285 buf.move_mark(cursor, iter);
3288 cursor = buf.get_mark("selection_bound");
3289 iter= new Gtk.TextIter;
3290 buf.get_iter_at_mark(iter, cursor);
3292 iter.set_line_offset(4);
3293 buf.move_mark(cursor, iter);
3295 this.el.grab_focus();
3297 insert_spaces_instead_of_tabs : true,
3300 show_line_numbers : true,
3303 xtype: GtkSource.Buffer,
3304 pack : "set_buffer",
3306 "changed":function (self) {
3307 var s = new Gtk.TextIter();
3308 var e = new Gtk.TextIter();
3309 this.el.get_start_iter(s);
3310 this.el.get_end_iter(e);
3311 var str = this.el.get_text(s,e,true);
3313 Seed.check_syntax('var e = ' + str);
3315 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3316 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3318 print("SYNTAX ERROR IN EDITOR");
3323 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3324 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3327 this.get('/LeftPanel.model').changed( str , false);
3336 xtype: Gtk.ScrolledWindow,
3340 xtype: Vte.Terminal,
3343 feed : function(str) {
3344 this.el.feed(str,str.length);
3355 pack : "pack_start,false,false",
3359 this.get('buttonbar').el.show();
3360 this.get('viewbox').el.hide();
3361 print("TRIED TO HIDE");
3364 this.get('buttonbar').el.hide();
3365 this.get('viewbox').el.show();
3366 // this.get('model').expanded();
3378 pack : "pack_start,false,true",
3380 "clicked":function (self) {
3381 this.get('/RightPalete').show();
3388 stock : Gtk.STOCK_GOTO_FIRST,
3389 icon_size : Gtk.IconSize.MENU
3399 XObject.prototype.init.call(this);
3400 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3403 "enter_notify_event":function (self, event) {
3404 this.get('/RightPalete').show();
3418 pack : "pack_start,false,true",
3427 pack : "pack_start,false,true",
3429 "clicked":function (self) {
3430 this.get('/RightPalete').hide();
3437 stock : Gtk.STOCK_GOTO_LAST,
3438 icon_size : Gtk.IconSize.MENU
3445 xtype: Gtk.ScrolledWindow,
3448 XObject.prototype.init.call(this);
3449 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3450 this.el.set_size_request(-1,200);
3452 shadow_type : Gtk.ShadowType.IN,
3455 xtype: Gtk.TreeView,
3458 XObject.prototype.init.call(this);
3459 this.el.set_size_request(150,-1);
3460 // set_reorderable: [1]
3462 var description = new Pango.FontDescription.c_new();
3463 description.set_size(8000);
3464 this.el.modify_font(description);
3466 this.selection = this.el.get_selection();
3467 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3468 // this.selection.signal['changed'].connect(function() {
3469 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3471 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3473 Gtk.drag_source_set (
3474 this.el, /* widget will be drag-able */
3475 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3476 null, /* lists of target to support */
3477 0, /* size of list */
3478 Gdk.DragAction.COPY /* what to do with data after dropped */
3480 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3482 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3483 Gtk.drag_source_add_text_targets(this.el);
3485 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3486 targets = new Gtk.TargetList();
3487 targets.add( LeftTree.atoms["STRING"], 0, 0);
3488 targets.add_text_targets( 1 );
3489 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3491 //if you want to allow text to be output elsewhere..
3492 //Gtk.drag_source_add_text_targets(this.el);
3496 headers_visible : false,
3497 enable_tree_lines : true,
3499 "drag_begin":function (self, ctx) {
3500 // we could fill this in now...
3501 Seed.print('SOURCE: drag-begin');
3505 var iter = new Gtk.TreeIter();
3506 var s = this.selection;
3507 s.get_selected(this.get('/RightPalete.model').el, iter);
3508 var path = this.get('/RightPalete.model').el.get_path(iter);
3510 var pix = this.el.create_row_drag_icon ( path);
3513 Gtk.drag_set_icon_pixmap (ctx,
3520 var value = new GObject.Value('');
3521 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3522 if (!this.get('/RightPalete').provider) {
3525 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3526 this.el.dragData = value.value;
3533 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3534 //Seed.print('Palete: drag-data-get: ' + target_type);
3535 if (this.el.dragData && this.el.dragData.length ) {
3536 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3540 //this.el.dragData = "TEST from source widget";
3544 "drag_end":function (self, drag_context) {
3545 Seed.print('SOURCE: drag-end');
3546 this.el.dragData = false;
3547 this.el.dropList = false;
3548 this.get('/LeftTree.view').highlight(false);
3554 xtype: Gtk.ListStore,
3557 XObject.prototype.init.call(this);
3558 this.el.set_column_types ( 2, [
3559 GObject.TYPE_STRING, // title
3560 GObject.TYPE_STRING // tip
3565 load : function(tr,iter)
3570 //console.log('Project tree load: ' + tr.length);
3571 var citer = new Gtk.TreeIter();
3572 //this.insert(citer,iter,0);
3573 for(var i =0 ; i < tr.length; i++) {
3576 this.el.append(citer);
3578 this.el.insert(citer,iter,-1);
3583 this.el.set_value(citer, 0, '' + r ); // title
3585 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3586 //if (r.cn && r.cn.length) {
3587 // this.load(r.cn, citer);
3593 getValue : function (iter, col) {
3594 var gval = new GObject.Value('');
3595 this.el.get_value(iter, col ,gval);
3602 xtype: Gtk.TreeViewColumn,
3603 pack : "append_column",
3605 XObject.prototype.init.call(this);
3606 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3610 xtype: Gtk.CellRendererText,
3632 XObject.cache['/Window'] = Window;