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) {
1374 print("LOAD PROJECT");
1380 this.get('/LeftProjectTree').project = pr;
1381 this.load(pr.toTree());
1382 this.get('/LeftProjectTree.view').el.expand_all();
1384 load : function(tr,iter) {
1386 console.log('Project tree load: ' + tr.length);
1387 var citer = new Gtk.TreeIter();
1388 //this.insert(citer,iter,0);
1391 tr.forEach(function (r) {
1393 _this.el.append(citer);
1395 _this.el.insert(citer,iter,-1);
1397 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1398 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1399 _this.el.set_value(citer, 2, '' + r.id ); //id
1400 if (r.cn && r.cn.length) {
1401 _this.load(r.cn, citer);
1406 getValue : function(iter, col) {
1407 var gval = new GObject.Value('');
1408 this.el.get_value(iter, col ,gval);
1409 return '' + gval.value;
1413 xtype: Gtk.TreeViewColumn,
1414 pack : "append_column",
1416 XObject.prototype.init.call(this);
1417 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1421 xtype: Gtk.CellRendererText,
1444 pack : "pack_start,false,true,0",
1451 "button_press_event":function (self, event) {
1452 this.get('/MidPropTree.model').showData('props');
1464 stock : Gtk.STOCK_ADD,
1465 icon_size : Gtk.IconSize.MENU
1480 "button_press_event":function (self, event) {
1481 this.get('/MidPropTree.model').showData('events');
1493 stock : Gtk.STOCK_ADD,
1494 icon_size : Gtk.IconSize.MENU
1509 "button_press_event":function (self, ev) {
1510 var p = this.get('/AddPropertyPopup');
1514 p.el.set_screen(Gdk.Screen.get_default());
1516 p.el.popup(null, null, null, null, 3, ev.button.time);
1528 stock : Gtk.STOCK_ADD,
1529 icon_size : Gtk.IconSize.MENU
1541 id : "AddPropertyPopup",
1544 xtype: Gtk.MenuItem,
1546 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1549 "activate":function (self) {
1551 this.get('/LeftPanel.model').add( {
1562 xtype: Gtk.MenuItem,
1564 tooltip_markup : "Add what type of packing is to be used",
1567 "activate":function (self) {
1569 this.get('/LeftPanel.model').add( {
1579 xtype: Gtk.MenuItem,
1581 tooltip_markup : "Override the init method",
1584 "activate":function (self) {
1586 this.get('/LeftPanel.model').add( {
1589 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1596 xtype: Gtk.SeparatorMenuItem,
1600 xtype: Gtk.MenuItem,
1602 tooltip_markup : "Add a user defined string property",
1605 "activate":function (self) {
1607 this.get('/LeftPanel.model').add( {
1617 xtype: Gtk.MenuItem,
1619 tooltip_markup : "Add a user defined number property",
1622 "activate":function (self) {
1624 this.get('/LeftPanel.model').add( {
1634 xtype: Gtk.MenuItem,
1636 tooltip_markup : "Add a user defined boolean property",
1639 "activate":function (self) {
1641 this.get('/LeftPanel.model').add( {
1651 xtype: Gtk.SeparatorMenuItem,
1655 xtype: Gtk.MenuItem,
1657 tooltip_markup : "Add a user function boolean property",
1660 "activate":function (self) {
1662 this.get('/LeftPanel.model').add( {
1665 val : "function() {\n \n}\n",
1678 xtype: Gtk.ScrolledWindow,
1681 shadow_type : Gtk.ShadowType.IN,
1684 XObject.prototype.init.call(this);
1685 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1689 xtype: Gtk.TreeView,
1692 headers_visible : false,
1693 enable_tree_lines : true,
1695 XObject.prototype.init.call(this);
1697 this.selection = this.el.get_selection();
1698 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1701 var description = new Pango.FontDescription.c_new();
1702 description.set_size(8000);
1703 this.el.modify_font(description);
1706 "button_press_event":function (self, ev) {
1710 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1711 return false; //not on a element.
1715 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1717 if (res.column.title != 'value') {
1718 return false; // ignore..
1720 if ( this.get('/LeftPanel').editing) {
1723 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1724 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1725 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1729 var provider = this.get('/LeftTree').getPaleteProvider();
1731 var opts = provider.findOptions(type);
1733 if (opts === false) {
1734 this.get('/LeftPanel').editableColumn.setOptions([]);
1735 renderer.has_entry = true;
1737 LeftPanel.editableColumn.setOptions(opts);
1738 renderer.has_entry = false;
1742 //Seed.print("click" + ev.type);
1743 //console.dump(res);
1749 if (res.column.title == 'value') {
1752 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1753 var p = this.get('/LeftPanelPopup');
1758 p.el.set_screen(Gdk.Screen.get_default());
1760 p.el.popup(null, null, null, null, 3, ev.button.time);
1761 //Seed.print("click:" + res.column.title);
1769 xtype: Gtk.TreeStore,
1773 XObject.prototype.init.call(this);
1774 this.el.set_column_types ( 5, [
1775 GObject.TYPE_STRING, // 0 real key
1776 GObject.TYPE_STRING, // 1 real value
1777 GObject.TYPE_STRING, // 2 visable key
1778 GObject.TYPE_STRING, // 3 visable value
1779 GObject.TYPE_STRING, // 4 need to store type of!!!
1783 toShort : function(str) {
1784 var a = typeof(str) == 'string' ? str.split("\n") : [];
1785 return a.length > 1 ? a[0] + '....' : '' + str;
1787 load : function(ar) {
1790 this.get('/RightEditor').el.hide();
1797 var provider = this.get('/LeftTree').getPaleteProvider();
1800 var iter = new Gtk.TreeIter();
1802 if (typeof(ar[i]) == 'object') {
1806 var type = provider.findType(ar, i, ar[i]);
1808 this.el.append(iter);
1809 var p = this.el.get_path(iter).to_string();
1811 this.el.set_value(iter, 0, i);
1812 this.el.set_value(iter, 1, '' + ar[i]);
1813 this.el.set_value(iter, 2, i);
1814 this.el.set_value(iter, 3, this.toShort(ar[i]));
1815 this.el.set_value(iter, 4, type);
1817 ar.listeners = ar.listeners || {};
1818 for (var i in ar.listeners ) {
1819 this.el.append(iter);
1820 var p = this.el.get_path(iter).to_string();
1823 this.el.set_value(iter, 0, '!'+ i );
1824 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1825 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1827 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1828 this.el.set_value(iter, 4, 'function');
1832 add : function(info) {
1833 // info includes key, val, skel, etype..
1835 type = info.type.toLowerCase();
1836 var data = this.toJS();
1838 if (info.etype == 'events') {
1839 data.listeners = data.listeners || { };
1840 if (typeof(data.listeners[info.key]) != 'undefined') {
1841 return; //already set!
1844 if (typeof(data[info.key]) != 'undefined') {
1849 if (typeof(info.val) == 'undefined') {
1852 if (info.type == 'boolean') {
1855 if (type == 'number') {
1863 if (info.etype == 'events') {
1865 data.listeners[info.key] = info.val;
1868 data[info.key] = info.val;
1872 var map = this.load(data);
1874 // flag it as changed to the interface..
1876 this.get('/LeftTree.model').changed(data, true);
1879 this.startEditing(map[k]);
1882 LeftPanel.get('view').el.row_activated(
1883 new Gtk.TreePath.from_string(map[k]),
1884 LeftPanel.editableColumn.el
1888 startEditing : function(path,col) {
1890 * start editing path (or selected if not set..)
1891 * @param {String|false} path (optional) treepath to edit - selected tree gets
1892 * edited by default.
1893 * @param {Number} 0 or 1 (optional)- column to edit.
1896 if (typeof(path) == 'string') {
1897 tp = new Gtk.TreePath.from_string(path);
1899 var iter = new Gtk.TreeIter();
1900 var s = this.get('/LeftPanel.view').selection;
1901 s.get_selected(this.el, iter);
1902 tp = this.el.get_path(iter);
1903 path = tp.to_string();
1907 // which colum is to be edited..
1909 if (typeof(col) == 'undefined') {
1910 var k = this.getValue(path, 0);
1911 colObj = (!k.length || k == '|') ?
1912 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1914 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1917 // make sure the pulldown is set correctly..
1918 // not really needed for second col...
1920 var provider = this.get('/LeftTree').getPaleteProvider();
1922 var type = this.get('/LeftPanel.model').getType(path);
1923 var opts = provider.findOptions(type);
1924 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1926 if (opts === false) {
1927 this.get('/LeftPanel').editableColumn.setOptions([]);
1928 renderer.has_entry = true; /// probably does not have any effect.
1930 this.get('/LeftPanel').editableColumn.setOptions(opts);
1931 renderer.has_entry = false;
1935 // iter now has row...
1936 GLib.timeout_add(0, 100, function() {
1938 colObj.items[0].el.editable = true; // esp. need for col 0..
1939 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1948 deleteSelected : function() {
1949 var data = this.toJS();
1950 var iter = new Gtk.TreeIter();
1951 var s = this.get('/LeftPanel.view').selection;
1952 s.get_selected(this.el, iter);
1955 var gval = new GObject.Value('');
1956 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1958 var val = gval.value;
1959 if (val[0] == '!') {
1961 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1964 delete data.listeners[ val.substring(1)];
1965 if (!XObject.keys(data.listeners).length) {
1966 delete data.listeners;
1970 if (typeof(data[val]) == 'undefined') {
1978 this.get('/LeftTree.model').changed(data, true);
1982 changed : function(str, doRefresh) {
1983 if (!this.activePath) {
1986 var iter = new Gtk.TreeIter();
1987 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1989 this.el.set_value(iter, 1, '' +str);
1990 this.el.set_value(iter, 3, '' + this.toShort(str));
1991 // update the tree...
1993 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
1996 var iter = new Gtk.TreeIter();
1997 this.get('/LeftPanel.model').el.get_iter_first(iter);
2002 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
2005 ar.listeners = ar.listeners || {};
2006 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
2009 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
2012 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
2018 //print(JSON.stringify(ar));
2022 getType : function(treepath) {
2023 return this.getValue(treepath, 4);
2025 getValue : function(treepath_str, col) {
2026 var iter = new Gtk.TreeIter();
2027 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
2029 var gval = new GObject.Value('');
2030 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
2031 var val = '' + gval.value;
2035 var type = this.getType(this.el.get_path(iter).to_string());
2036 //print("TYPE: " +type + " - val:" + val);
2037 switch(type.toLowerCase()) {
2041 return parseFloat(val); // Nan ?? invalid!!?
2043 return val == 'true' ? true : false;
2049 editSelected : function(e) {
2050 print("EDIT SELECTED?");
2051 var iter = new Gtk.TreeIter();
2052 var s = this.get('/LeftPanel.view').selection;
2053 s.get_selected(this.get('/LeftPanel.model').el, iter);
2054 var m = this.get('/LeftPanel.model')
2056 var gval = new GObject.Value('');
2057 this.el.get_value(iter, 0 ,gval);
2058 var val = '' + gval.value;
2060 gval = new GObject.Value('');
2061 this.el.get_value(iter, 1 ,gval);
2062 var rval = gval.value;
2063 var activePath = this.el.get_path(iter).to_string();
2064 this.activePath = activePath ;
2065 // was activeIter...
2068 var showEditor = false;
2070 if (val[0] == '!') {
2073 if (val[0] == '|') {
2074 if (rval.match(/function/g) || rval.match(/\n/g)) {
2081 this.activePath = false;
2082 GLib.timeout_add(0, 1, function() {
2083 // Gdk.threads_enter();
2084 _this.get('/BottomPane').el.show();
2085 _this.get('/RightEditor').el.show();
2086 _this.get('/RightEditor.view').load( rval );
2090 _this.activePath = activePath ;
2092 // Gdk.threads_leave();
2097 this.get('/BottomPane').el.hide();
2098 this.get('/RightEditor').el.hide();
2100 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2106 xtype: Gtk.TreeViewColumn,
2107 pack : "append_column",
2109 XObject.prototype.init.call(this);
2111 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2112 this.get('/LeftPanel').propertyColumn = this;
2117 xtype: Gtk.CellRendererText,
2118 pack : "pack_start",
2120 "editing_started":function (self, editable, path) {
2122 this.get('/LeftPanel.model').activePath = path;
2125 "edited":function (self, object, p0) {
2126 var model = this.get('/LeftPanel.model');
2127 var path = model.activePath;
2128 var iter = new Gtk.TreeIter();
2129 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2130 model.el.set_value(iter, 0, p0);
2131 model.el.set_value(iter, 2, p0);
2133 model.activePath = false;
2135 this.get('/LeftTree.model').changed(model.toJS(), true);
2136 this.el.editable = false;
2143 xtype: Gtk.TreeViewColumn,
2144 pack : "append_column",
2146 XObject.prototype.init.call(this);
2147 this.el.add_attribute(this.items[0].el , 'text', 3 );
2148 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2149 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2150 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2152 this.get('/LeftPanel').editableColumn= this;
2154 setOptions : function(ar) {
2155 var m = this.items[0].el.model;
2157 var iter = new Gtk.TreeIter();
2158 ar.forEach(function(i) {
2161 m.set_value(iter, 0, i);
2167 xtype: Gtk.CellRendererCombo,
2168 pack : "pack_start",
2173 XObject.prototype.init.call(this);
2174 this.el.model = new Gtk.ListStore();
2175 this.el.model.set_column_types ( 1, [
2176 GObject.TYPE_STRING // 0 real key
2180 "edited":function (self, object, p0) {
2181 this.get('/LeftPanel').editing = false;
2182 print("EDITED? p:" + p0 + " t:" + p0);
2183 this.get('/LeftPanel.model').changed(p0, true);
2184 this.get('/LeftPanel.model').activePath = false;
2186 "editing_started":function (self, editable, path) {
2187 this.get('/LeftPanel').editing = true;
2188 // console.log('editing started');
2189 // r.has_entry = false;
2190 this.get('/LeftPanel.model').editSelected(editable);
2201 id : "LeftPanelPopup",
2204 xtype: Gtk.MenuItem,
2208 "activate":function (self) {
2209 this.get('/LeftPanel.model').deleteSelected();
2214 xtype: Gtk.MenuItem,
2218 "activate":function (self) {
2219 this.get('/LeftPanel.model').startEditing(false, 0);
2232 xtype: Gtk.ScrolledWindow,
2233 pack : "pack_end,false,true,0",
2235 shadow_type : Gtk.ShadowType.IN,
2237 XObject.prototype.init.call(this);
2238 XObject.prototype.init.call(this);
2239 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2240 this.el.set_size_request ( 150, -1 );
2243 activeElement : false,
2244 hideWin : function() {
2251 if (this.get('/Window.left').el.position < 160) {
2254 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2261 xtype: Gtk.TreeView,
2262 enable_tree_lines : true,
2263 headers_visible : false,
2266 XObject.prototype.init.call(this);
2268 var description = new Pango.FontDescription.c_new();
2269 description.set_size(8000);
2270 this.el.modify_font(description);
2272 //this.selection = this.el.get_selection();
2273 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2282 "cursor_changed":function (self) {
2283 var iter = new Gtk.TreeIter();
2285 //console.log('changed');
2286 var m = this.get('model');
2287 if (!this.selection){
2288 this.selection = this.el.get_selection();
2291 var s = this.selection;
2292 if (!s.get_selected(m.el, iter)) {
2295 var tp = m.el.get_path(iter).to_string();
2300 var key = m.getValue(tp, 0);
2302 var type = m.getValue(tp, 1);
2303 var skel = m.getValue(tp, 3);
2304 var etype = m.getValue(tp, 5);
2307 this.get('/MidPropTree').hideWin();
2309 if (type == 'function') {
2311 if (etype != 'events') {
2315 this.get('/LeftPanel.model').add({
2324 if (type.indexOf('.') > -1 ||
2325 type == 'boolean') {
2329 this.get('/LeftPanel.model').add( {
2339 xtype: Gtk.ListStore,
2342 XObject.prototype.init.call(this);
2343 this.el.set_column_types ( 6, [
2344 GObject.TYPE_STRING, // real key
2345 GObject.TYPE_STRING, // real type
2346 GObject.TYPE_STRING, // docs ?
2347 GObject.TYPE_STRING, // visable desc
2348 GObject.TYPE_STRING, // function desc
2349 GObject.TYPE_STRING // element type (event|prop)
2353 getValue : function(treepath, col)
2355 var tp = new Gtk.TreePath.from_string (treepath);
2356 var iter = new Gtk.TreeIter();
2357 this.el.get_iter (iter, tp);
2358 var value = new GObject.Value('');
2359 this.el.get_value(iter, col, value);
2363 showData : function(type) {
2365 if (!this.get('/MidPropTree').activeElement || !type) {
2366 return; // no active element
2369 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2370 var palete = this.get('/LeftTree').getPaleteProvider();
2374 Seed.print('Showing right?');
2375 if (!this.get('/MidPropTree').shown) {
2377 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2378 this.get('/MidPropTree').el.show();
2379 this.get('/MidPropTree').shown = true;
2382 var elementList = palete.getPropertiesFor(fullpath, type);
2383 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2384 // console.dump(elementList);
2387 var iter = new Gtk.TreeIter();
2388 for(var i =0 ; i < elementList.length; i++) {
2389 var p=elementList[i];
2390 this.el.append(iter);
2391 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2392 //GObject.TYPE_STRING, // real key
2393 // GObject.TYPE_STRING, // real type
2394 // GObject.TYPE_STRING, // docs ?
2395 // GObject.TYPE_STRING // func def?
2398 this.el.set_value(iter, 0, p.name);
2399 this.el.set_value(iter, 1, p.type);
2400 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2401 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2402 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2403 this.el.set_value(iter, 5, type);
2411 xtype: Gtk.TreeViewColumn,
2413 this.el = new Gtk.TreeViewColumn();
2414 this.parent.el.append_column(this.el);
2416 XObject.prototype.init.call(this);
2417 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2422 xtype: Gtk.CellRendererText,
2423 pack : "pack_start,true"
2447 xtype: Gtk.Notebook,
2448 pack : "pack_start,true,true",
2449 id : "view-help-nb",
2451 XObject.prototype.init.call(this);
2452 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" }));
2453 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" }));
2457 xtype: Gtk.Notebook,
2459 id : "view-notebook",
2462 XObject.prototype.init.call(this);
2463 this.el.set_current_page(0);
2465 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2466 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2473 id : "RightBrowser",
2474 renderJS : function(data) {
2475 var v = this.get('view');
2476 v.renderedData = data;
2477 var str = JSON.stringify(data) ;
2480 console.log('not loaded yet');
2482 Seed.print("RENDER:" + str);
2483 // imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2484 v.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2491 pack : "pack_start,false,true,0",
2495 pack : "pack_start,false,false,0",
2496 label : "Dump HTML to console",
2498 "activate":function (self) {
2499 this.get('/RightBrowser.view').el.execute_script(
2500 "console.log(document.body.innerHTML);");
2501 this.get('/RightBrowser.view').el.execute_script(
2502 "console.log(Builder.dump(Builder));");
2509 xtype: Gtk.ScrolledWindow,
2511 shadow_type : Gtk.ShadowType.IN,
2513 XObject.prototype.init.call(this);
2514 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2518 xtype: WebKit.WebView,
2522 XObject.prototype.init.call(this);
2523 // this may not work!?
2524 this.el.open('file:///' + __script_path__ + '/../builder.html');
2528 this.el, /* widget that will accept a drop */
2529 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2530 null, /* lists of target to support */
2531 0, /* size of list */
2532 Gdk.DragAction.COPY /* what to do with data after dropped */
2535 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2536 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2538 renderJS : function(data) {
2539 this.renderedData = data;
2540 var str = JSON.stringify(data) ;
2543 console.log('not loaded yet');
2545 Seed.print("RENDER:" + str);
2546 imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2547 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2550 "load_finished":function (self, object) {
2551 if (this.ready) { // dont do it twice!
2556 this.renderJS(this.get('/LeftTree.model').toJS()[0]);
2558 "script_alert":function (self, object, p0) {
2561 return true; // do not display anything...
2563 "console_message":function (self, object, p0, p1) {
2564 console.log(object);
2565 if (!object.match(/^\{/)) {
2566 return false; // do not handle!!! -> later maybe in console..
2568 console.log(object);
2569 var val = JSON.parse(object);
2571 if (typeof(val['hover-node']) != 'undefined') {
2572 this.activeNode = val['hover-node'];
2573 console.log('active node: ' + this.activeNode);
2578 if (typeof(val['id']) != 'undefined') {
2579 // this.activeNode = val['id'];
2580 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2584 this.get('/LeftTree.view').selectNode(tg[0]);
2588 if (ret && typeof(val['set']) != 'undefined') {
2589 this.get('/LeftPanel.model').add({
2593 //console.log('active node: ' + this.activeNode);
2596 //Seed.print('a:'+a);
2597 //Seed.print('b:'+b);
2598 //Seed.print('c:'+c);
2601 "drag_motion":function (w, ctx, x, y, time, ud) {
2602 // console.log('DRAG MOTION');
2604 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2605 this.targetData = [];
2606 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2608 // A) find out from drag all the places that node could be dropped.
2609 var src = Gtk.drag_get_source_widget(ctx);
2610 if (!src.dropList) {
2611 Gdk.drag_status(ctx, 0, time);
2614 // b) get what we are over.. (from activeNode)
2615 // tree is empty.. - list should be correct..
2616 if (!this.get('/LeftTree.model').currentTree) {
2617 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2621 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2623 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2626 Gdk.drag_status(ctx, 0,time);
2627 this.get('/LeftTree.view').highlight(false);
2631 // if we have a target..
2632 // -> highlight it! (in browser)
2633 // -> highlight it! (in tree)
2635 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2636 this.get('/LeftTree.view').highlight(tg);
2637 this.targetData = tg;
2638 // for tree we should handle this...
2641 "drag_drop":function (w, ctx, x, y,time, ud) {
2642 print("TARGET: drag-drop");
2643 var is_valid_drop_site = true;
2648 w, /* will receive 'drag-data-received' signal */
2649 ctx, /* represents the current state of the DnD */
2650 this.get('/Window').atoms["STRING"], /* the target type we want */
2651 time /* time stamp */
2655 /* No target offered by source => error */
2658 return is_valid_drop_site;
2660 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2662 print("Browser: drag-data-received");
2663 var delete_selection_data = false;
2664 vardnd_success = false;
2665 /* Deal with what we are given from source */
2666 if( sel_data && sel_data.length ) {
2668 if (ctx.action == Gdk.DragAction.ASK) {
2669 /* Ask the user to move or copy, then set the ctx action. */
2672 if (ctx.action == Gdk.DragAction.MOVE) {
2673 delete_selection_data = true;
2675 var source = Gtk.drag_get_source_widget(ctx);
2677 print("Browser: source.DRAGDATA? " + source.dragData);
2678 if (this.targetData) {
2679 print(this.targetData);
2680 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2689 if (dnd_success == false)
2691 Seed.print ("DnD data transfer failed!\n");
2694 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2706 id : "RightGtkView",
2707 renderJS : function(data, withDebug)
2712 this.withDebug = false;
2714 if (this.renderedEl) {
2715 this.get('view').el.remove(this.renderedEl);
2716 this.renderedEl.destroy();
2717 this.renderedEl = false;
2720 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2721 // in theory tree is actually window..
2723 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2728 this.get('view').el.set_size_request(
2729 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2732 this.renderedEl.set_size_request(
2733 tree.default_width || 600,
2734 tree.default_height || 400
2736 this.get('view').el.show_all();
2741 showInWindow : function() {
2742 print("GET PROEJCT");
2743 var pr = this.get('/LeftProjectTree').getActiveProject();
2745 console.log(pr.paths);
2748 var src= this.buildJS(
2749 this.get('/LeftTree.model').toJS()[0],
2754 //var x = new imports.sandbox.Context();
2758 Seed.check_syntax('var e = ' + src);
2761 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2762 this.get('/Terminal').feed(console._dump(e)+"\n");
2764 var lines = src.split("\n");
2765 var start = Math.max(0, e.line - 10);
2766 var end = Math.min(lines.length, e.line + 10);
2767 for (var i =start ; i < end; i++) {
2769 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2772 this.get('/Terminal').feed(lines[i] + "\n");
2779 this.get('/BottomPane').el.set_current_page(1);
2780 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2781 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2782 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2784 var _top = x.get_global_object()._top;
2786 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2788 if (_top.el.popup) {
2789 _top.el.popup(null, null, null, null, 3, null);
2793 viewAdd : function(item, par)
2795 // does something similar to xobject..
2796 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2798 if (item.pack===false || item.pack === 'false') { // no ;
2801 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2802 var ns = imports.gi[item['|xns']];
2803 var ctr = ns[item['xtype']];
2805 for(var k in item) {
2807 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2822 if (k[0] == '|' && typeof(kv) == 'string') {
2824 if (kv.match(new RegExp('function'))) {
2827 print("WASL " + k + '=' + kv);
2829 eval( 'kv = ' + kv);
2830 } catch(e) { continue; }
2833 print(k + '=' + kv);
2835 if (k[0] == '|') { // should be boolean or number..
2837 print(k + '=' + kv);
2840 if (k == 'show_tabs') { // force tab showing for notebooks.
2848 var el = new ctr(ctr_args);
2851 //console.dump(item.pack);
2858 if (typeof(item.pack) == 'string') {
2860 item.pack.split(',').forEach(function(e, i) {
2862 if (e == 'false') { args.push( false); return; }
2863 if (e == 'true') { args.push( true); return; }
2864 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2867 //print(args.join(","));
2869 pack_m = args.shift();
2871 pack_m = item.pack.shift();
2876 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2878 name: "ArgumentError",
2879 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2880 "ADDING : " + item.id + " " + el
2889 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2890 //Seed.print('args: ' + args.length);
2892 par[pack_m].apply(par, args);
2896 item.items = item.items || [];
2897 item.items.forEach(function(ch) {
2898 _this.viewAdd(ch, el);
2903 // add the signal handlers.
2904 // is it a widget!?!!?
2910 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2911 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2912 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2913 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2914 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2924 widgetExposeEvent : function(w, evt, ud, item) {
2926 if (this.inRender) {
2930 if ( this.highlightWidget) {
2931 this.inRender = true;
2932 if (item.xtreepath.substring(0, this.activePath.length) == this.activePath) {
2933 Gdk.draw_rectangle(this.highlightWidget.window, this.gc, false, this.box.x , this.box.y, this.box.w, this.box.h);
2935 this.inRender = false;
2940 if (this.activePath != item.xtreepath) {
2944 // print("HIGHLIGHT: " + item.xtreepath ); // draw highlight??
2945 // work out the coords of the window..
2947 var dr = widget.window;
2948 this.gc = (new Gdk.GC.c_new(dr));
2949 this.gc.set_rgb_fg_color(new Gdk.Color({ red: 0xFFFF, green: 0, blue : 0 }));
2950 this.gc.set_line_attributes(4, Gdk.LineStyle.SOLID, Gdk.CapStyle.ROUND , Gdk.JoinStyle.ROUND);
2954 var r = evt.expose.area;
2955 // console.dump([r.x, r.y, r.width, r.height ] );
2957 // print(widget.get_parent().toString().match(/GtkScrolledWindow/);
2958 if (widget.get_parent().toString().match(/GtkScrolledWindow/)) { // eak
2959 // happens with gtkscrollview embedded stuff..
2960 var np =this.activePath.split(':');
2962 this.activePath = np.join(':');
2963 this.renderedEl.queue_draw();
2979 this.inRender = true;
2982 this.highlightWidget = widget;
2987 // print("DRAW BOX");
2988 //console.dump(this.box);
2989 Gdk.draw_rectangle(widget.window, this.gc, false, this.box.x , this.box.y, this.box.w,this.box.h);
2990 this.inRender = false;
2993 widgetDragMotionEvent : function() {
2994 print("WIDGET DRAGMOTION");
2997 widgetDragDropEvent : function() {
2998 print("WIDGET DRAGDROP");
3001 widgetPressEvent : function(w,e,u,d) {
3002 if (this.get('view').pressed) {
3005 this.get('view').pressed = true;
3006 print("WIDGET PRESS " + d.xtreepath );
3007 this.get('/LeftTree.view').selectNode( d.xtreepath );
3010 widgetReleaseEvent : function() {
3011 this.get('view').pressed = false;
3014 redraw : function() {
3015 this.highlightWidget = false;
3016 print("REDRAW CALLED");
3017 this.activePath = this.get('/LeftTree').getActivePath();
3018 if (this.renderedEl) {
3019 print("QUEUE DRAW CALLING");
3020 this.renderedEl.queue_draw();
3026 pack : "pack_start,false,true,0",
3030 pack : "pack_start,false,false,0",
3031 label : "Run The Application",
3033 "button_press_event":function (self, event) {
3034 // call render on left tree - with special option!?!
3038 print("GET PROEJCT");
3039 var pr = this.get('/LeftProjectTree').getActiveProject();
3042 for (var i in pr.paths) {
3046 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
3047 print ("RUN DIR:" + dir);
3048 this.get('/BottomPane').el.show();
3049 this.get('/BottomPane').el.set_current_page(1);
3050 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
3051 , false,false,false);
3052 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
3053 this.get('/Terminal').el.feed_child(cmd, cmd.length);
3063 xtype: Gtk.ScrolledWindow,
3066 shadow_type : Gtk.ShadowType.IN,
3068 XObject.prototype.init.call(this);
3069 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3073 xtype: Gtk.EventBox,
3074 pack : "add_with_viewport",
3076 XObject.prototype.init.call(this);
3077 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
3078 red: 0x9F00, green: 0xB800 , blue : 0xA800
3086 XObject.prototype.init.call(this);
3087 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
3088 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
3093 xtype: Gtk.EventBox,
3096 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
3097 XObject.prototype.init.call(this);
3101 this.el, /* widget that will accept a drop */
3102 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
3103 null, /* lists of target to support */
3104 0, /* size of list */
3105 Gdk.DragAction.COPY /* what to do with data after dropped */
3108 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
3109 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
3112 getActiveNode : function(x,y)
3114 // workout what node is here..
3115 return '0'; // top..
3119 "drag_motion":function (self, ctx, x, y, time) {
3121 // A) find out from drag all the places that node could be dropped.
3122 var src = Gtk.drag_get_source_widget(ctx);
3123 if (!src.dropList) {
3124 Gdk.drag_status(ctx, 0, time);
3127 // b) get what we are over.. (from activeNode)
3128 // tree is empty.. - list should be correct..
3129 if (!this.get('/LeftTree.model').currentTree) {
3130 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3134 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
3135 var activeNode = this.getActiveNode(x, y);
3138 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
3141 Gdk.drag_status(ctx, 0,time);
3142 this.get('/LeftTree.view').highlight(false);
3146 // if we have a target..
3147 // -> highlight it! (in browser)
3148 // -> highlight it! (in tree)
3150 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3151 this.get('/LeftTree.view').highlight(tg);
3152 this.targetData = tg;
3153 // for tree we should handle this...
3156 "drag_drop":function (self,ctx, x, y, time) {
3157 Seed.print("TARGET: drag-drop");
3158 var is_valid_drop_site = true;
3163 self, /* will receive 'drag-data-received' signal */
3164 ctx, /* represents the current state of the this.gDnD */
3165 this.get('/Window').atoms["STRING"], /* the target type we want */
3166 time /* time stamp */
3170 /* No target offered by source => error */
3173 return is_valid_drop_site;
3176 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3178 Seed.print("GtkView: drag-data-received");
3179 var delete_selection_data = false;
3180 var dnd_success = false;
3181 /* Deal with what we are given from source */
3182 if( sel_data && sel_data.length ) {
3184 if (ctx.action == Gdk.DragAction.ASK) {
3185 /* Ask the user to move or copy, then set the ctx action. */
3188 if (ctx.action == Gdk.DragAction.MOVE) {
3189 delete_selection_data = true;
3191 var source = Gtk.drag_get_source_widget(ctx);
3193 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3194 if (this.targetData) {
3195 Seed.print(this.targetData);
3196 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3205 if (dnd_success == false)
3207 Seed.print ("DnD data transfer failed!\n");
3210 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3213 "button_press_event":function (self, event) {
3214 this.pressed = false;
3230 xtype: Gtk.ScrolledWindow,
3235 xtype: WebKit.WebView,
3239 XObject.prototype.init.call(this);
3240 this.get('/Window.help-view').el.open(
3241 "http://devel.akbkhome.com/seed/");
3252 xtype: Gtk.Notebook,
3255 XObject.prototype.init.call(this);
3256 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3257 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3262 xtype: Gtk.ScrolledWindow,
3267 xtype: GtkSource.View,
3271 XObject.prototype.init.call(this);
3272 var description = Pango.Font.description_from_string("monospace")
3273 description.set_size(8000);
3274 this.el.modify_font(description);
3277 load : function(str) {
3279 // show the help page for the active node..
3280 this.get('/Window.view-help-nb').el.set_current_page(1);
3282 // get the active element being edited.
3283 var xtype = this.get('/LeftTree.model').file.guessName(
3284 this.get('/MidPropTree').activeElement);
3285 // now load the help info in the page..
3286 this.get('/Window.help-view').el.open(
3287 "http://devel.akbkhome.com/seed/" + xtype + ".html");
3290 this.get('/BottomPane').el.set_current_page(0);
3291 this.el.get_buffer().set_text(str, str.length);
3292 var lm = GtkSource.LanguageManager.get_default();
3294 this.el.get_buffer().set_language(lm.get_language('js'));
3295 var buf = this.el.get_buffer();
3296 var cursor = buf.get_mark("insert");
3297 var iter= new Gtk.TextIter;
3298 buf.get_iter_at_mark(iter, cursor);
3300 iter.set_line_offset(4);
3301 buf.move_mark(cursor, iter);
3304 cursor = buf.get_mark("selection_bound");
3305 iter= new Gtk.TextIter;
3306 buf.get_iter_at_mark(iter, cursor);
3308 iter.set_line_offset(4);
3309 buf.move_mark(cursor, iter);
3311 this.el.grab_focus();
3313 insert_spaces_instead_of_tabs : true,
3316 show_line_numbers : true,
3319 xtype: GtkSource.Buffer,
3320 pack : "set_buffer",
3322 "changed":function (self) {
3323 var s = new Gtk.TextIter();
3324 var e = new Gtk.TextIter();
3325 this.el.get_start_iter(s);
3326 this.el.get_end_iter(e);
3327 var str = this.el.get_text(s,e,true);
3329 Seed.check_syntax('var e = ' + str);
3331 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3332 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3334 print("SYNTAX ERROR IN EDITOR");
3339 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3340 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3343 this.get('/LeftPanel.model').changed( str , false);
3352 xtype: Gtk.ScrolledWindow,
3356 xtype: Vte.Terminal,
3359 feed : function(str) {
3360 this.el.feed(str,str.length);
3371 pack : "pack_start,false,false",
3375 this.get('buttonbar').el.show();
3376 this.get('viewbox').el.hide();
3377 print("TRIED TO HIDE");
3380 this.get('buttonbar').el.hide();
3381 this.get('viewbox').el.show();
3382 // this.get('model').expanded();
3394 pack : "pack_start,false,true",
3396 "clicked":function (self) {
3397 this.get('/RightPalete').show();
3404 stock : Gtk.STOCK_GOTO_FIRST,
3405 icon_size : Gtk.IconSize.MENU
3415 XObject.prototype.init.call(this);
3416 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3419 "enter_notify_event":function (self, event) {
3420 this.get('/RightPalete').show();
3434 pack : "pack_start,false,true",
3443 pack : "pack_start,false,true",
3445 "clicked":function (self) {
3446 this.get('/RightPalete').hide();
3453 stock : Gtk.STOCK_GOTO_LAST,
3454 icon_size : Gtk.IconSize.MENU
3461 xtype: Gtk.ScrolledWindow,
3464 XObject.prototype.init.call(this);
3465 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3466 this.el.set_size_request(-1,200);
3468 shadow_type : Gtk.ShadowType.IN,
3471 xtype: Gtk.TreeView,
3474 XObject.prototype.init.call(this);
3475 this.el.set_size_request(150,-1);
3476 // set_reorderable: [1]
3478 var description = new Pango.FontDescription.c_new();
3479 description.set_size(8000);
3480 this.el.modify_font(description);
3482 this.selection = this.el.get_selection();
3483 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3484 // this.selection.signal['changed'].connect(function() {
3485 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3487 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3489 Gtk.drag_source_set (
3490 this.el, /* widget will be drag-able */
3491 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3492 null, /* lists of target to support */
3493 0, /* size of list */
3494 Gdk.DragAction.COPY /* what to do with data after dropped */
3496 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3498 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3499 Gtk.drag_source_add_text_targets(this.el);
3501 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3502 targets = new Gtk.TargetList();
3503 targets.add( LeftTree.atoms["STRING"], 0, 0);
3504 targets.add_text_targets( 1 );
3505 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3507 //if you want to allow text to be output elsewhere..
3508 //Gtk.drag_source_add_text_targets(this.el);
3512 headers_visible : false,
3513 enable_tree_lines : true,
3515 "drag_begin":function (self, ctx) {
3516 // we could fill this in now...
3517 Seed.print('SOURCE: drag-begin');
3521 var iter = new Gtk.TreeIter();
3522 var s = this.selection;
3523 s.get_selected(this.get('/RightPalete.model').el, iter);
3524 var path = this.get('/RightPalete.model').el.get_path(iter);
3526 var pix = this.el.create_row_drag_icon ( path);
3529 Gtk.drag_set_icon_pixmap (ctx,
3536 var value = new GObject.Value('');
3537 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3538 if (!this.get('/RightPalete').provider) {
3541 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3542 this.el.dragData = value.value;
3549 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3550 //Seed.print('Palete: drag-data-get: ' + target_type);
3551 if (this.el.dragData && this.el.dragData.length ) {
3552 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3556 //this.el.dragData = "TEST from source widget";
3560 "drag_end":function (self, drag_context) {
3561 Seed.print('SOURCE: drag-end');
3562 this.el.dragData = false;
3563 this.el.dropList = false;
3564 this.get('/LeftTree.view').highlight(false);
3570 xtype: Gtk.ListStore,
3573 XObject.prototype.init.call(this);
3574 this.el.set_column_types ( 2, [
3575 GObject.TYPE_STRING, // title
3576 GObject.TYPE_STRING // tip
3581 load : function(tr,iter)
3586 //console.log('Project tree load: ' + tr.length);
3587 var citer = new Gtk.TreeIter();
3588 //this.insert(citer,iter,0);
3589 for(var i =0 ; i < tr.length; i++) {
3592 this.el.append(citer);
3594 this.el.insert(citer,iter,-1);
3599 this.el.set_value(citer, 0, '' + r ); // title
3601 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3602 //if (r.cn && r.cn.length) {
3603 // this.load(r.cn, citer);
3609 getValue : function (iter, col) {
3610 var gval = new GObject.Value('');
3611 this.el.get_value(iter, col ,gval);
3618 xtype: Gtk.TreeViewColumn,
3619 pack : "append_column",
3621 XObject.prototype.init.call(this);
3622 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3626 xtype: Gtk.CellRendererText,
3648 XObject.cache['/Window'] = Window;