3 Pango = imports.gi.Pango;
4 GLib = imports.gi.GLib;
6 GObject = imports.gi.GObject;
7 GtkSource = imports.gi.GtkSource;
8 WebKit = imports.gi.WebKit;
10 console = imports.console;
11 XObject = imports.XObject.XObject;
14 type : Gtk.WindowType.TOPLEVEL,
15 title : "Application Builder",
19 "STRING" : Gdk.atom_intern("STRING")
21 this.targetList = new Gtk.TargetList();
22 this.targetList.add( this.atoms["STRING"], 0, 0);
23 //imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();
25 "style \"gtkcombobox-style\" {\n" +
26 " GtkComboBox::appears-as-list = 1\n" +
28 "class \"GtkComboBox\" style \"gtkcombobox-style\"\n");
29 XObject.prototype.init.call(this);
39 "delete_event":function (self, event) {
42 "destroy":function (self) {
45 "show":function (self) {
46 print("WINDOW SHOWING - trying to hide");
47 imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();
48 this.get('/MidPropTree').hideWin();
49 this.get('/RightPalete').hide();
50 this.get('/BottomPane').el.hide();
61 pack : "pack_start,false,false",
75 label : "New _Project",
77 "activate":function (self) {
79 this.get('/EditProject').show({
80 success : function(pr) {
81 _this.get('/LeftProjectTree').get('combo').setValue(pr.fn);
92 "activate":function (self) {
93 var fn = this.get('/LeftProjectTree.combo').getValue();
95 this.get('/LeftProjectTree').showNoProjectSelected();
98 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
99 this.get('/DialogNewComponent').show({
100 project : pm.getByFn(fn)
106 xtype: Gtk.SeparatorMenuItem,
111 use_underline : true,
113 label : "D_elete Project",
115 "activate":function (self) {
117 var fn = this.get('/LeftProjectTree').get('combo').getValue();
119 this.get('/StandardErrorDialog').show("Select a project")
122 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
123 var pr = pm.getByFn(fn);
126 this.get('/DialogConfirm').show("Are you sure you want to delete project '" + pr.name + "'", function() {
127 pm.deleteProject(fn);
135 xtype: Gtk.SeparatorMenuItem,
142 use_underline : true,
144 "activate":function (self) {
178 label : "Select Project",
180 pack : "pack_start,false,true",
182 XObject.prototype.init.call(this);
183 this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
186 "activate":function (self) {
187 var nb = this.get('/LeftTopPanel.notebook');
188 if (this.el.expanded) {
191 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
194 var model = this.get('/LeftProjectTree.combomodel');
195 // print ("loading Projects?")
196 //console.dump(pm.projects);
197 model.loadData(pm.projects);
200 nb.el.set_current_page(1);
201 //pm.on('changed', function() {
202 //console.log("CAUGHT project manager change");
203 // _combo.model.loadData(pm.projects);
207 nb.el.set_current_page(0);
209 "enter_notify_event":function (self, event) {
210 this.el.expanded = !this.el.expanded;
211 //if (this.el.expanded ) {
212 this.listeners.activate.call(this);
224 pack : "pack_start,true,true",
226 XObject.prototype.init.call(this);
227 this.el.set_current_page(0);
232 xtype: Gtk.ScrolledWindow,
234 shadow_type : Gtk.ShadowType.IN,
236 XObject.prototype.init.call(this);
237 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
240 getPaleteProvider : function() {
241 var model = this.get('model');
242 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
243 return pm.getPalete(model.file.getType());
245 renderView : function() {
246 var render = this.getRenderer();
247 var model = this.get('model');
249 render.renderJS(model.toJS(false,true)[0]);
251 print("NO RENDER JS METHOD?");
254 getRenderer : function() {
255 var model = this.get('model');
256 print("RENDER VIEW?" + model.file.getType());
257 switch( model.file.getType()) {
259 return this.get('/RightBrowser.view');
261 return this.get('/RightGtkView');
265 getActivePath : function() {
266 var model = this.get('model');
267 var view = this.get('view');
268 if (view.selection.count_selected_rows() < 1) {
271 var iter = new Gtk.TreeIter();
273 view.selection.get_selected(model.el, iter);
274 return model.el.get_path(iter).to_string();
281 headers_visible : false,
282 enable_tree_lines : true,
285 XObject.prototype.init.call(this);
286 var description = new Pango.FontDescription.c_new();
287 description.set_size(8000);
288 this.el.modify_font(description);
290 this.selection = this.el.get_selection();
291 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
294 // is this really needed??
295 this.selection.signal['changed'].connect(function() {
296 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
297 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
301 Gtk.drag_source_set (
302 this.el, /* widget will be drag-able */
303 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
304 null, /* lists of target to support */
305 0, /* size of list */
306 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
309 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
311 Gtk.drag_source_add_text_targets(this.el);
314 this.el, /* widget that will accept a drop */
315 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
316 null, /* lists of target to support */
317 0, /* size of list */
318 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
321 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
322 Gtk.drag_dest_add_text_targets(this.el);
324 highlight : function(treepath_ar) {
326 // highlighting for drag/drop
327 if (treepath_ar.length && treepath_ar[0].length ) {
328 this.el.set_drag_dest_row(
329 new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);
331 this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
335 selectNode : function(treepath_str) {
336 //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
337 var tp = new Gtk.TreePath.from_string(treepath_str);
338 this.el.set_cursor(tp, null, false);
339 this.el.scroll_to_cell(tp, null, false, 0,0);
342 "button_press_event":function (self, ev) {
343 console.log("button press?");
344 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
345 print("click" + ev.type);
351 this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
353 if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();
355 this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
356 this.get('/LeftTreeMenu').el.show_all();
357 this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
358 print("click:" + res.path.to_string());
361 "drag_begin":function (self, drag_context) {
362 print('SOURCE: drag-begin');
363 this.targetData = false;
364 // find what is selected in our tree...
365 var iter = new Gtk.TreeIter();
366 var s = this.selection;
367 s.get_selected(this.get('/LeftTree.model').el, iter);
369 // set some properties of the tree for use by the dropped element.
370 var value = new GObject.Value('');
371 this.get('/LeftTree.model').el.get_value(iter, 2, value);
372 var data = JSON.parse(value.value);
373 var xname = this.get('/LeftTree.model').file.guessName(data);
375 this.el.dragData = xname;
376 this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);
379 // make the drag icon a picture of the node that was selected
380 var path = this.get('/LeftTree.model').el.get_path(iter);
381 this.el.treepath = path.to_string();
383 var pix = this.el.create_row_drag_icon ( path);
385 Gtk.drag_set_icon_pixmap (ctx,
394 "drag_end":function (self, drag_context) {
395 Seed.print('LEFT-TREE: drag-end');
396 this.el.dragData = false;
397 this.el.dropList = false;
398 this.targetData = false;
399 this.get('/LeftTree.view').highlight(false);
402 "drag_motion":function (self, ctx, x, y, time) {
403 console.log("LEFT-TREE: drag-motion");
404 var src = Gtk.drag_get_source_widget(ctx);
406 // a drag from elsewhere...- prevent drop..
408 print("no drag data!");
409 Gdk.drag_status(ctx, 0, time);
410 this.targetData = false;
413 var action = Gdk.DragAction.COPY;
414 if (src == this.el) {
415 // unless we are copying!!! ctl button..
416 action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
420 if (!this.get('/LeftTree.model').el.iter_n_children(null)) {
421 // no children.. -- asume it's ok..
422 this.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];
423 Gdk.drag_status(ctx, action ,time);
427 print("GETTING POS");
428 var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);
429 print("ISOVER? " + isOver);
431 Gdk.drag_status(ctx, 0 ,time);
432 return false; // not over apoint!?!
434 // drag node is parent of child..
435 console.log("SRC TREEPATH: " + src.treepath);
436 console.log("TARGET TREEPATH: " + data.path.to_string());
438 // nned to check a few here..
439 //Gtk.TreeViewDropPosition.INTO_OR_AFTER
440 //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
441 //Gtk.TreeViewDropPosition.AFTER
442 //Gtk.TreeViewDropPosition.BEFORE
444 if (typeof(src.treepath) != 'undefined' &&
445 src.treepath == data.path.to_string().substring(0,src.treepath.length)) {
446 print("subpath drag");
447 Gdk.drag_status(ctx, 0 ,time);
452 //print("DUMPING DATA");
453 //console.dump(data);
456 print(data.path.to_string() +' => '+ data.pos);
457 var tg = this.get('/LeftTree.model').findDropNodeByPath(
458 data.path.to_string(), src.dropList, data.pos);
460 this.get('/LeftTree.view').highlight(tg);
462 print("Can not find drop node path");
463 this.targetData = false;
464 Gdk.drag_status(ctx, 0, time);
468 this.targetData = tg;
471 Gdk.drag_status(ctx, action ,time);
475 "drag_drop":function (w, ctx, x, y, time) {
476 Seed.print("TARGET: drag-drop");
480 w, /* will receive 'drag-data-received' signal */
481 ctx, /* represents the current state of the DnD */
482 this.get('/Window').atoms["STRING"], /* the target type we want */
483 time /* time stamp */
487 /* No target offered by source => error */
492 "drag_data_received":function (self, ctx, x, y, sel_data, info, time) {
493 print("Tree: drag-data-received");
495 var delete_selection_data = false;
496 var dnd_success = false;
497 /* Deal with what we are given from source */
498 if( sel_data && sel_data.length ) {
500 if (ctx.action == Gdk.DragAction.ASK) {
501 /* Ask the user to move or copy, then set the ctx action. */
504 if (ctx.action == Gdk.DragAction.MOVE) {
505 //delete_selection_data = true;
508 var source = Gtk.drag_get_source_widget(ctx);
510 if (this.targetData) {
511 if (source != this.el) {
512 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
514 // drag around.. - reorder..
515 this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);
519 //Seed.print(this.targetData);
525 // we can send stuff to souce here...
531 if (dnd_success == false)
533 Seed.print ("DnD data transfer failed!\n");
536 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
539 "cursor_changed":function (self) {
540 if (this.blockChanges) { // probably not needed..
543 var render = this.get('/LeftTree').getRenderer();
546 if (this.selection.count_selected_rows() < 1) {
547 this.get('/LeftPanel.model').load( false);
548 this.get('/MidPropTree').activeElement = false;
549 this.get('/MidPropTree').hideWin();
551 var pm = this.get('/RightPalete.model');
552 if (!this.get('/LeftTree').getPaleteProvider()) {
553 // it may not be loaded yet..
556 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
557 this.get('/LeftTree.model').listAllTypes()));
558 if (render && render.redraw) {
564 //console.log('changed');
565 var s = this.selection;
566 var iter = new Gtk.TreeIter();
567 s.get_selected(this.get('/LeftTree.model').el, iter);
571 value = new GObject.Value('');
572 this.get('/LeftTree.model').el.get_value(iter, 2, value);
573 this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
575 var data = JSON.parse(value.value);
576 this.get('/MidPropTree').activeElement = data;
577 this.get('/MidPropTree').hideWin();
578 this.get('/LeftPanel.model').load( data);
580 console.log(value.value);
581 // _g.button.set_label(''+value.get_string());
583 var pm =this.get('/RightPalete.model');
584 pm.load( this.get('/RightPalete').provider.gatherList(
585 this.get('/LeftTree.model').listAllTypes()));
588 if (render && render.redraw) {
592 //Seed.print( value.get_string());
599 xtype: Gtk.TreeStore,
603 XObject.prototype.init.call(this);
604 this.el.set_column_types ( 3, [
605 GObject.TYPE_STRING, // title
606 GObject.TYPE_STRING, // tip
607 GObject.TYPE_STRING // source..
611 changed : function(n, refresh) {
612 print("MODEL CHANGED CALLED" + this.activePath);
613 if (this.activePath) {
614 var iter = new Gtk.TreeIter();
615 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
616 this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
617 this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
619 this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
621 //this.currentTree = this.toJS(false, true)[0];
622 this.file.items = this.toJS(false, false);
623 print("AFTER CHANGED");
624 //console.dump(this.file.items);
626 this.currentTree = this.file.items[0];
627 //console.log(this.file.toSource());
630 print("REDNER BROWSER?!");
631 this.get('/LeftTree').renderView();
633 var pm = this.get('/RightPalete.model');
634 if (!this.get('/RightPalete').provider) {
640 pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
641 //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
645 loadFile : function(f) {
651 console.log('missing file');
655 // load the file if not loaded..
656 if (f.items === false) {
658 f.loadItems(function() {
664 if (f.items.length && typeof(f.items[0]) == 'string') {
666 this.get('/RightEditor').el.show();
667 this.get('/RightEditor.view').load( f.items[0]);
671 //console.dump(f.items);
673 this.get('/LeftTree.view').el.expand_all();
675 if (!f.items.length) {
678 this.get('/Window.leftvpaned').el.set_position(80);
680 this.get('/LeftTree.view').el.set_cursor(
681 new Gtk.TreePath.from_string('0'), null, false);
685 this.get('/Window.leftvpaned').el.set_position(200);
689 //print("hide right editior");
690 this.get('/RightEditor').el.hide();
691 //print("set current tree");
692 this.currentTree = this.toJS(false, false)[0];
693 //console.dump(this.currentTree);
694 this.currentTree = this.currentTree || { items: [] };
695 this.get('/LeftTree').renderView();
696 //console.dump(this.map);
697 //var RightPalete = imports.Builder.RightPalete.RightPalete;
698 var pm = this.get('/RightPalete.model');
701 this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
703 if (!this.get('/RightPalete').provider) {
704 print ("********* PALETE PROVIDER MISSING?!!");
706 this.get('/LeftTree').renderView();
708 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
712 this.get('/Window.view-notebook').el.set_current_page(
713 this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
716 findDropNode : function(treepath_str, targets) {
718 // this is used by the dragdrop code in the roo version AFAIR..
720 var path = treepath_str.replace(/^builder-/, '');
721 // treemap is depreciated... - should really check if model has any entries..
723 if (!this.el.iter_n_children(null)) {
725 return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];
727 print("FIND treepath: " + path);
728 //console.dump(this.treemap);
730 if (!treepath_str.match(/^builder-/)) {
731 return []; // nothing!
733 if (targets === true) {
736 return this.findDropNodeByPath(path,targets)
738 findDropNodeByPath : function(treepath_str, targets, pref) {
739 var path = treepath_str + ''; // dupe it..
740 pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
742 //console.dump(this.treemap);
743 while (path.length) {
744 print("LOOKING FOR PATH: " + path);
745 var node_data = this.singleNodeToJS(path);
746 if (node_data === false) {
747 print("node not found");
751 var xname = this.get('/LeftTree.model').file.guessName(node_data);
754 targets.forEach(function(tg) {
758 if ((tg == xname) ) {
761 if (tg.indexOf(xname +':') === 0) {
763 prop = tg.split(':').pop();
768 if (last) { // pref is after/before..
769 // then it's after last
771 return []; // do not allow..
773 return [ last, pref , prop];
776 return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
778 var par = path.split(':');
781 path = par.join(':');
787 dropNode : function(target_data, node) {
790 console.dump(target_data);
791 var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
793 print("add " + tp + "@" + target_data[1] );
796 if (tp && target_data[1] < 2) { // before or after..
797 var ar = target_data[0].split(':');
799 parent = new Gtk.TreePath.from_string( ar.join(':') );
802 var n_iter = new Gtk.TreeIter();
803 var iter_par = new Gtk.TreeIter();
804 var iter_after = after ? new Gtk.TreeIter() : false;
808 if (parent !== false) {
809 this.el.get_iter(iter_par, parent);
816 print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
817 this.el.get_iter(iter_after, after);
818 this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
819 n_iter, iter_par, iter_after);
822 this.el.append(n_iter, iter_par);
826 if (typeof(node) == 'string') {
827 var ar = node.split('.');
828 var xtype = ar.pop();
831 '|xns' : ar.join('.'),
834 if (target_data.length == 3 && target_data[2].length) {
835 node['*prop'] = target_data[2];
839 // work out what kind of packing to use..
840 if (typeof(node.pack) == 'undefined' && parent !== false) {
841 var pal = this.get('/LeftTree').getPaleteProvider();
843 var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
844 print ("PNAME : " + pname);
845 var cname = pal.guessName(node);
846 print ("CNAME : " + cname);
847 node.pack = pal.getDefaultPack(pname, cname);
858 // load children - if it has any..
861 this.load(xitems, n_iter);
863 if (tp && (xitems || after)) {
864 this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
866 // wee need to get the empty proptypes from somewhere..
868 //var olditer = this.activeIter;
869 this.activePath = this.el.get_path(n_iter).to_string();
871 // changed actually set's the node data..
872 this.changed(node, true);
876 this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
878 //Builder.MidPropTree._model.load(node);
879 //Builder.MidPropTree._win.hideWin();
880 //Builder.LeftPanel._model.load( node);
884 moveNode : function(target_data, action) {
885 //print("MOVE NODE");
886 // console.dump(target_data);
887 var old_iter = new Gtk.TreeIter();
888 var s = this.get('/LeftTree.view').selection;
889 s.get_selected(this.el, old_iter);
890 var node = this.nodeToJS(old_iter,false);
891 //console.dump(node);
894 // needs to drop first, otherwise the target_data
895 // treepath will be invalid.
897 this.dropNode(target_data, node);
898 if (action & Gdk.DragAction.MOVE) {
899 // print("REMOVING OLD NODE");
900 this.el.remove(old_iter);
904 this.activePath= false;
905 this.changed(false,true);
907 deleteSelected : function() {
908 this.get('/LeftTree.view').blockChanges = true;
909 var old_iter = new Gtk.TreeIter();
910 var s = this.get('/LeftTree.view').selection;
911 s.get_selected(this.el, old_iter);
912 var path = this.el.get_path(old_iter).to_string();
914 this.activePath= false;
917 this.activePath= false;
918 var iter = new Gtk.TreeIter();
919 this.el.get_iter_from_string(iter, path);
920 this.el.remove(iter);
922 // rebuild treemap. -- depreciated.!!
925 //this.toJS(null, true) // does not do anything?
926 this.activePath= false;
927 this.changed(false,true);
928 this.get('/LeftTree.view').blockChanges = false;
931 listAllTypes : function() {
932 var s = this.get('/LeftTree.view').selection;
933 print ("LIST ALL TYPES: " + s.count_selected_rows() );
935 if (s.count_selected_rows() > 0) {
936 var iter = new Gtk.TreeIter();
937 s.get_selected(this.el, iter);
939 // set some properties of the tree for use by the dropped element.
940 var value = new GObject.Value('');
941 this.el.get_value(iter, 2, value);
942 var data = JSON.parse(value.value);
945 var xname = this.get('/LeftTree.model').file.guessName(data);
946 console.log('selected:' + xname);
950 return []; // could not find it..
958 li.forEach(function(el) {
959 // this is specific to roo!!!?
961 var fullpath = _this.file.guessName(el);
962 if (fullpath.length && ret.indexOf(fullpath) < 0) {
967 if (el.items && el.items.length) {
976 addall([this.currentTree]);
978 // only if we have nothing, should we add '*top'
982 //console.log('all types in tree');
988 singleNodeToJS : function (treepath)
990 var iter = new Gtk.TreeIter();
991 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
995 var iv = this.getIterValue(iter, 2);
997 return JSON.parse(iv);
1000 nodeToJS : function (iter, with_id)
1002 var par = new Gtk.TreeIter();
1003 var iv = this.getIterValue(iter, 2);
1004 // print("IV" + iv);
1005 var k = JSON.parse(iv);
1006 if (k.json && !this.el.iter_parent( par, iter )) {
1011 var treepath_str = this.el.get_path(iter).to_string();
1012 // not sure how we can handle mixed id stuff..
1013 if (typeof(k.id) == 'undefined') {
1014 k.id = 'builder-'+ treepath_str ;
1018 this.treemap[ treepath_str ] = k;
1019 k.xtreepath = treepath_str ;
1022 if (this.el.iter_has_child(iter)) {
1023 citer = new Gtk.TreeIter();
1024 this.el.iter_children(citer, iter);
1025 k.items = this.toJS(citer,with_id);
1029 toJS : function(iter, with_id)
1031 //Seed.print("WITHID: "+ with_id);
1038 iter = new Gtk.TreeIter();
1039 if (!this.el.get_iter_first(iter)) {
1049 var k = this.nodeToJS(iter, with_id);
1053 if (!this.el.iter_next(iter)) {
1059 // convert the list into a json string..
1063 getIterValue : function (iter, col) {
1064 var gval = new GObject.Value('');
1065 this.el.get_value(iter, col ,gval);
1070 nodeTitle : function(c) {
1073 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
1074 if (sr) txt.push('<s>');
1075 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
1076 if (c.xtype) { txt.push(c.xtype); }
1077 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1078 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1079 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1082 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1083 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1084 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1085 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1086 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1087 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1088 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1089 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1090 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1092 // for flat classes...
1093 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1094 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1097 if (sr) txt.push('</s>');
1098 return (txt.length == 0 ? "Element" : txt.join(" "));
1100 nodeToJSON : function(c) {
1108 return JSON.stringify(o);
1110 load : function(tr,iter)
1112 var citer = new Gtk.TreeIter();
1113 //this.insert(citer,iter,0);
1114 for(var i =0 ; i < tr.length; i++) {
1116 this.el.insert(citer,iter,-1);
1118 this.el.append(citer);
1121 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1122 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTip(tr[i]) ]);
1123 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1124 if (tr[i].items && tr[i].items.length) {
1125 this.load(tr[i].items, citer);
1129 nodeTip : function(c) {
1130 var ret = this.nodeTitle(c);
1136 if (!i.length || i[0] != '|') {
1142 if (typeof(c[i]) != 'string') {
1145 //print("prop : " + i + ':' + c[i]);
1146 if (!c[i].match(new RegExp('function'))) {
1149 funcs += "\n<b>" + i.substring(1) + '</b> : ' + c[i].split(/\n/).shift();
1153 ret+="\n\nMethods:" + funcs;
1160 xtype: Gtk.TreeViewColumn,
1161 pack : "append_column",
1163 XObject.prototype.init.call(this);
1164 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1168 xtype: Gtk.CellRendererText,
1178 id : "LeftTreeMenu",
1181 xtype: Gtk.MenuItem,
1183 label : "Delete Element",
1185 "activate":function (self) {
1187 this.get('/LeftTree.model').deleteSelected();
1198 id : "LeftProjectTree",
1199 showNoProjectSelected : function() {
1200 this.get('/StandardErrorDialog').show("Select a Project first.");
1202 getActiveProject : function() {
1203 return this.project;
1206 "leave_notify_event":function (self, event) {
1213 pack : "pack_start,false,false",
1216 xtype: Gtk.ComboBox,
1219 XObject.prototype.init.call(this);
1220 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1222 getValue : function() {
1223 var ix = this.el.get_active();
1227 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1228 if (typeof(data[ix]) == 'undefined') {
1233 setValue : function(fn)
1237 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1238 data.forEach(function(n, ix) {
1246 "changed":function (self) {
1247 var fn = this.getValue();
1248 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1249 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1254 xtype: Gtk.CellRendererText,
1255 pack : "pack_start,true",
1259 xtype: Gtk.ListStore,
1262 XObject.prototype.init.call(this);
1263 this.el.set_column_types ( 2, [
1264 GObject.TYPE_STRING, // real key
1265 GObject.TYPE_STRING // real type
1269 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1271 pm.on('changed', function() {
1272 print("caught changed hook on project manager - reloading data");
1273 _this.loadData(pm.projects);
1277 loadData : function(data) {
1278 var ov = this.get('/LeftProjectTree.combo').getValue();
1280 var iter = new Gtk.TreeIter();
1282 data.forEach(function(p) {
1287 el.set_value(iter, 0, p.fn);
1288 el.set_value(iter, 1, p.name);
1292 this.get('/LeftProjectTree.combo').setValue(ov);
1301 xtype: Gtk.ScrolledWindow,
1303 shadow_type : Gtk.ShadowType.IN,
1305 XObject.prototype.init.call(this);
1306 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1310 xtype: Gtk.TreeView,
1311 headers_visible : false,
1312 enable_tree_lines : true,
1315 XObject.prototype.init.call(this);
1316 var description = new Pango.FontDescription.c_new();
1317 description.set_size(8000);
1318 this.el.modify_font(description);
1320 this.selection = this.el.get_selection();
1321 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1325 "cursor_changed":function (self) {
1326 var iter = new Gtk.TreeIter();
1328 if (this.selection.count_selected_rows() < 1) {
1329 //XN.get('Builder.LeftTree.model').
1330 this.get('/LeftTree.model').load( false);
1334 var model = this.get('/LeftProjectTree.model');
1335 //console.log('changed');
1336 var s = this.selection;
1337 s.get_selected(model, iter);
1338 value = new GObject.Value('');
1339 model.el.get_value(iter, 2, value);
1341 console.log(value.value);// id..
1343 var file = this.get('/LeftProjectTree').project.getById(value.value);
1350 var nb = this.get('/LeftTopPanel.expander');
1351 nb.el.expanded = false;
1352 nb.listeners.activate.call(nb);
1353 //_expander.el.set_expanded(false);
1355 var ltm = this.get('/LeftTree.model');
1363 xtype: Gtk.TreeStore,
1367 XObject.prototype.init.call(this);
1368 this.el.set_column_types ( 3, [
1369 GObject.TYPE_STRING, // title
1370 GObject.TYPE_STRING, // tip
1371 GObject.TYPE_STRING // id..
1375 loadProject : function(pr) {
1376 print("LOAD PROJECT");
1382 this.get('/LeftProjectTree').project = pr;
1383 this.load(pr.toTree());
1384 this.get('/LeftProjectTree.view').el.expand_all();
1386 load : function(tr,iter) {
1388 console.log('Project tree load: ' + tr.length);
1389 var citer = new Gtk.TreeIter();
1390 //this.insert(citer,iter,0);
1393 tr.forEach(function (r) {
1395 _this.el.append(citer);
1397 _this.el.insert(citer,iter,-1);
1399 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1400 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1401 _this.el.set_value(citer, 2, '' + r.id ); //id
1402 if (r.cn && r.cn.length) {
1403 _this.load(r.cn, citer);
1408 getValue : function(iter, col) {
1409 var gval = new GObject.Value('');
1410 this.el.get_value(iter, col ,gval);
1411 return '' + gval.value;
1415 xtype: Gtk.TreeViewColumn,
1416 pack : "append_column",
1418 XObject.prototype.init.call(this);
1419 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1423 xtype: Gtk.CellRendererText,
1446 pack : "pack_start,false,true,0",
1453 "button_press_event":function (self, event) {
1454 this.get('/MidPropTree.model').showData('props');
1466 stock : Gtk.STOCK_ADD,
1467 icon_size : Gtk.IconSize.MENU
1482 "button_press_event":function (self, event) {
1483 this.get('/MidPropTree.model').showData('events');
1495 stock : Gtk.STOCK_ADD,
1496 icon_size : Gtk.IconSize.MENU
1511 "button_press_event":function (self, ev) {
1512 var p = this.get('/AddPropertyPopup');
1516 p.el.set_screen(Gdk.Screen.get_default());
1518 p.el.popup(null, null, null, null, 3, ev.button.time);
1530 stock : Gtk.STOCK_ADD,
1531 icon_size : Gtk.IconSize.MENU
1543 id : "AddPropertyPopup",
1546 xtype: Gtk.MenuItem,
1548 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1551 "activate":function (self) {
1553 this.get('/LeftPanel.model').add( {
1564 xtype: Gtk.MenuItem,
1566 tooltip_markup : "Add what type of packing is to be used",
1569 "activate":function (self) {
1571 this.get('/LeftPanel.model').add( {
1581 xtype: Gtk.MenuItem,
1583 tooltip_markup : "Override the init method",
1586 "activate":function (self) {
1588 this.get('/LeftPanel.model').add( {
1591 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1598 xtype: Gtk.SeparatorMenuItem,
1602 xtype: Gtk.MenuItem,
1604 tooltip_markup : "Add a user defined string property",
1607 "activate":function (self) {
1609 this.get('/LeftPanel.model').add( {
1619 xtype: Gtk.MenuItem,
1621 tooltip_markup : "Add a user defined number property",
1624 "activate":function (self) {
1626 this.get('/LeftPanel.model').add( {
1636 xtype: Gtk.MenuItem,
1638 tooltip_markup : "Add a user defined boolean property",
1641 "activate":function (self) {
1643 this.get('/LeftPanel.model').add( {
1653 xtype: Gtk.SeparatorMenuItem,
1657 xtype: Gtk.MenuItem,
1659 tooltip_markup : "Add a user function boolean property",
1662 "activate":function (self) {
1664 this.get('/LeftPanel.model').add( {
1667 val : "function() {\n \n}\n",
1680 xtype: Gtk.ScrolledWindow,
1683 shadow_type : Gtk.ShadowType.IN,
1686 XObject.prototype.init.call(this);
1687 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1691 xtype: Gtk.TreeView,
1694 headers_visible : false,
1695 enable_tree_lines : true,
1697 XObject.prototype.init.call(this);
1699 this.selection = this.el.get_selection();
1700 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1703 var description = new Pango.FontDescription.c_new();
1704 description.set_size(8000);
1705 this.el.modify_font(description);
1708 "button_press_event":function (self, ev) {
1712 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1713 return false; //not on a element.
1717 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1719 if (res.column.title != 'value') {
1720 return false; // ignore..
1722 if ( this.get('/LeftPanel').editing) {
1725 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1726 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1727 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1731 var provider = this.get('/LeftTree').getPaleteProvider();
1733 var opts = provider.findOptions(type);
1735 if (opts === false) {
1736 this.get('/LeftPanel').editableColumn.setOptions([]);
1737 renderer.has_entry = true;
1739 LeftPanel.editableColumn.setOptions(opts);
1740 renderer.has_entry = false;
1744 //Seed.print("click" + ev.type);
1745 //console.dump(res);
1751 if (res.column.title == 'value') {
1754 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1755 var p = this.get('/LeftPanelPopup');
1760 p.el.set_screen(Gdk.Screen.get_default());
1762 p.el.popup(null, null, null, null, 3, ev.button.time);
1763 //Seed.print("click:" + res.column.title);
1771 xtype: Gtk.TreeStore,
1775 XObject.prototype.init.call(this);
1776 this.el.set_column_types ( 5, [
1777 GObject.TYPE_STRING, // 0 real key
1778 GObject.TYPE_STRING, // 1 real value
1779 GObject.TYPE_STRING, // 2 visable key
1780 GObject.TYPE_STRING, // 3 visable value
1781 GObject.TYPE_STRING, // 4 need to store type of!!!
1785 toShort : function(str) {
1786 var a = typeof(str) == 'string' ? str.split("\n") : [];
1787 return a.length > 1 ? a[0] + '....' : '' + str;
1789 load : function(ar) {
1792 this.get('/RightEditor').el.hide();
1799 var provider = this.get('/LeftTree').getPaleteProvider();
1802 var iter = new Gtk.TreeIter();
1804 if (typeof(ar[i]) == 'object') {
1808 var type = provider.findType(ar, i, ar[i]);
1810 this.el.append(iter);
1811 var p = this.el.get_path(iter).to_string();
1813 this.el.set_value(iter, 0, i);
1814 this.el.set_value(iter, 1, '' + ar[i]);
1815 this.el.set_value(iter, 2, i);
1816 this.el.set_value(iter, 3, this.toShort(ar[i]));
1817 this.el.set_value(iter, 4, type);
1819 ar.listeners = ar.listeners || {};
1820 for (var i in ar.listeners ) {
1821 this.el.append(iter);
1822 var p = this.el.get_path(iter).to_string();
1825 this.el.set_value(iter, 0, '!'+ i );
1826 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1827 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1829 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1830 this.el.set_value(iter, 4, 'function');
1834 add : function(info) {
1835 // info includes key, val, skel, etype..
1837 type = info.type.toLowerCase();
1838 var data = this.toJS();
1840 if (info.etype == 'events') {
1841 data.listeners = data.listeners || { };
1842 if (typeof(data.listeners[info.key]) != 'undefined') {
1843 return; //already set!
1846 if (typeof(data[info.key]) != 'undefined') {
1851 if (typeof(info.val) == 'undefined') {
1854 if (info.type == 'boolean') {
1857 if (type == 'number') {
1865 if (info.etype == 'events') {
1867 data.listeners[info.key] = info.val;
1870 data[info.key] = info.val;
1874 var map = this.load(data);
1876 // flag it as changed to the interface..
1878 this.get('/LeftTree.model').changed(data, true);
1881 this.startEditing(map[k]);
1884 LeftPanel.get('view').el.row_activated(
1885 new Gtk.TreePath.from_string(map[k]),
1886 LeftPanel.editableColumn.el
1890 startEditing : function(path,col) {
1892 * start editing path (or selected if not set..)
1893 * @param {String|false} path (optional) treepath to edit - selected tree gets
1894 * edited by default.
1895 * @param {Number} 0 or 1 (optional)- column to edit.
1898 if (typeof(path) == 'string') {
1899 tp = new Gtk.TreePath.from_string(path);
1901 var iter = new Gtk.TreeIter();
1902 var s = this.get('/LeftPanel.view').selection;
1903 s.get_selected(this.el, iter);
1904 tp = this.el.get_path(iter);
1905 path = tp.to_string();
1909 // which colum is to be edited..
1911 if (typeof(col) == 'undefined') {
1912 var k = this.getValue(path, 0);
1913 colObj = (!k.length || k == '|') ?
1914 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1916 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1919 // make sure the pulldown is set correctly..
1920 // not really needed for second col...
1922 var provider = this.get('/LeftTree').getPaleteProvider();
1924 var type = this.get('/LeftPanel.model').getType(path);
1925 var opts = provider.findOptions(type);
1926 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1928 if (opts === false) {
1929 this.get('/LeftPanel').editableColumn.setOptions([]);
1930 renderer.has_entry = true; /// probably does not have any effect.
1932 this.get('/LeftPanel').editableColumn.setOptions(opts);
1933 renderer.has_entry = false;
1937 // iter now has row...
1938 GLib.timeout_add(0, 100, function() {
1940 colObj.items[0].el.editable = true; // esp. need for col 0..
1941 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1950 deleteSelected : function() {
1951 var data = this.toJS();
1952 var iter = new Gtk.TreeIter();
1953 var s = this.get('/LeftPanel.view').selection;
1954 s.get_selected(this.el, iter);
1957 var gval = new GObject.Value('');
1958 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1960 var val = gval.value;
1961 if (val[0] == '!') {
1963 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1966 delete data.listeners[ val.substring(1)];
1967 if (!XObject.keys(data.listeners).length) {
1968 delete data.listeners;
1972 if (typeof(data[val]) == 'undefined') {
1980 this.get('/LeftTree.model').changed(data, true);
1984 changed : function(str, doRefresh) {
1985 if (!this.activePath) {
1988 var iter = new Gtk.TreeIter();
1989 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1991 this.el.set_value(iter, 1, '' +str);
1992 this.el.set_value(iter, 3, '' + this.toShort(str));
1993 // update the tree...
1995 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
1998 var iter = new Gtk.TreeIter();
1999 this.get('/LeftPanel.model').el.get_iter_first(iter);
2004 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
2007 ar.listeners = ar.listeners || {};
2008 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
2011 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
2014 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
2020 //print(JSON.stringify(ar));
2024 getType : function(treepath) {
2025 return this.getValue(treepath, 4);
2027 getValue : function(treepath_str, col) {
2028 var iter = new Gtk.TreeIter();
2029 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
2031 var gval = new GObject.Value('');
2032 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
2033 var val = '' + gval.value;
2037 var type = this.getType(this.el.get_path(iter).to_string());
2038 //print("TYPE: " +type + " - val:" + val);
2039 switch(type.toLowerCase()) {
2043 return parseFloat(val); // Nan ?? invalid!!?
2045 return val == 'true' ? true : false;
2051 editSelected : function(e) {
2052 print("EDIT SELECTED?");
2053 var iter = new Gtk.TreeIter();
2054 var s = this.get('/LeftPanel.view').selection;
2055 s.get_selected(this.get('/LeftPanel.model').el, iter);
2056 var m = this.get('/LeftPanel.model')
2058 var gval = new GObject.Value('');
2059 this.el.get_value(iter, 0 ,gval);
2060 var val = '' + gval.value;
2062 gval = new GObject.Value('');
2063 this.el.get_value(iter, 1 ,gval);
2064 var rval = gval.value;
2065 var activePath = this.el.get_path(iter).to_string();
2066 this.activePath = activePath ;
2067 // was activeIter...
2070 var showEditor = false;
2072 if (val[0] == '!') {
2075 if (val[0] == '|') {
2076 if (rval.match(/function/g) || rval.match(/\n/g)) {
2083 this.activePath = false;
2084 GLib.timeout_add(0, 1, function() {
2085 // Gdk.threads_enter();
2086 _this.get('/BottomPane').el.show();
2087 _this.get('/RightEditor').el.show();
2088 _this.get('/RightEditor.view').load( rval );
2092 _this.activePath = activePath ;
2094 // Gdk.threads_leave();
2099 this.get('/BottomPane').el.hide();
2100 this.get('/RightEditor').el.hide();
2102 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2108 xtype: Gtk.TreeViewColumn,
2109 pack : "append_column",
2111 XObject.prototype.init.call(this);
2113 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2114 this.get('/LeftPanel').propertyColumn = this;
2119 xtype: Gtk.CellRendererText,
2120 pack : "pack_start",
2122 "editing_started":function (self, editable, path) {
2124 this.get('/LeftPanel.model').activePath = path;
2127 "edited":function (self, object, p0) {
2128 var model = this.get('/LeftPanel.model');
2129 var path = model.activePath;
2130 var iter = new Gtk.TreeIter();
2131 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2132 model.el.set_value(iter, 0, p0);
2133 model.el.set_value(iter, 2, p0);
2135 model.activePath = false;
2137 this.get('/LeftTree.model').changed(model.toJS(), true);
2138 this.el.editable = false;
2145 xtype: Gtk.TreeViewColumn,
2146 pack : "append_column",
2148 XObject.prototype.init.call(this);
2149 this.el.add_attribute(this.items[0].el , 'text', 3 );
2150 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2151 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2152 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2154 this.get('/LeftPanel').editableColumn= this;
2156 setOptions : function(ar) {
2157 var m = this.items[0].el.model;
2159 var iter = new Gtk.TreeIter();
2160 ar.forEach(function(i) {
2163 m.set_value(iter, 0, i);
2169 xtype: Gtk.CellRendererCombo,
2170 pack : "pack_start",
2175 XObject.prototype.init.call(this);
2176 this.el.model = new Gtk.ListStore();
2177 this.el.model.set_column_types ( 1, [
2178 GObject.TYPE_STRING // 0 real key
2182 "edited":function (self, object, p0) {
2183 this.get('/LeftPanel').editing = false;
2184 print("EDITED? p:" + p0 + " t:" + p0);
2185 this.get('/LeftPanel.model').changed(p0, true);
2186 this.get('/LeftPanel.model').activePath = false;
2188 "editing_started":function (self, editable, path) {
2189 this.get('/LeftPanel').editing = true;
2190 // console.log('editing started');
2191 // r.has_entry = false;
2192 this.get('/LeftPanel.model').editSelected(editable);
2203 id : "LeftPanelPopup",
2206 xtype: Gtk.MenuItem,
2210 "activate":function (self) {
2211 this.get('/LeftPanel.model').deleteSelected();
2216 xtype: Gtk.MenuItem,
2220 "activate":function (self) {
2221 this.get('/LeftPanel.model').startEditing(false, 0);
2234 xtype: Gtk.ScrolledWindow,
2235 pack : "pack_end,false,true,0",
2237 shadow_type : Gtk.ShadowType.IN,
2239 XObject.prototype.init.call(this);
2240 XObject.prototype.init.call(this);
2241 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2242 this.el.set_size_request ( 150, -1 );
2245 activeElement : false,
2246 hideWin : function() {
2253 if (this.get('/Window.left').el.position < 160) {
2256 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2263 xtype: Gtk.TreeView,
2264 enable_tree_lines : true,
2265 headers_visible : false,
2268 XObject.prototype.init.call(this);
2270 var description = new Pango.FontDescription.c_new();
2271 description.set_size(8000);
2272 this.el.modify_font(description);
2274 //this.selection = this.el.get_selection();
2275 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2284 "cursor_changed":function (self) {
2285 var iter = new Gtk.TreeIter();
2287 //console.log('changed');
2288 var m = this.get('model');
2289 if (!this.selection){
2290 this.selection = this.el.get_selection();
2293 var s = this.selection;
2294 if (!s.get_selected(m.el, iter)) {
2297 var tp = m.el.get_path(iter).to_string();
2302 var key = m.getValue(tp, 0);
2304 var type = m.getValue(tp, 1);
2305 var skel = m.getValue(tp, 3);
2306 var etype = m.getValue(tp, 5);
2309 this.get('/MidPropTree').hideWin();
2311 if (type == 'function') {
2313 if (etype != 'events') {
2317 this.get('/LeftPanel.model').add({
2326 if (type.indexOf('.') > -1 ||
2327 type == 'boolean') {
2331 this.get('/LeftPanel.model').add( {
2341 xtype: Gtk.ListStore,
2344 XObject.prototype.init.call(this);
2345 this.el.set_column_types ( 6, [
2346 GObject.TYPE_STRING, // real key
2347 GObject.TYPE_STRING, // real type
2348 GObject.TYPE_STRING, // docs ?
2349 GObject.TYPE_STRING, // visable desc
2350 GObject.TYPE_STRING, // function desc
2351 GObject.TYPE_STRING // element type (event|prop)
2355 getValue : function(treepath, col)
2357 var tp = new Gtk.TreePath.from_string (treepath);
2358 var iter = new Gtk.TreeIter();
2359 this.el.get_iter (iter, tp);
2360 var value = new GObject.Value('');
2361 this.el.get_value(iter, col, value);
2365 showData : function(type) {
2367 if (!this.get('/MidPropTree').activeElement || !type) {
2368 return; // no active element
2371 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2372 var palete = this.get('/LeftTree').getPaleteProvider();
2376 Seed.print('Showing right?');
2377 if (!this.get('/MidPropTree').shown) {
2379 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2380 this.get('/MidPropTree').el.show();
2381 this.get('/MidPropTree').shown = true;
2384 var elementList = palete.getPropertiesFor(fullpath, type);
2385 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2386 // console.dump(elementList);
2389 var iter = new Gtk.TreeIter();
2390 for(var i =0 ; i < elementList.length; i++) {
2391 var p=elementList[i];
2392 this.el.append(iter);
2393 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2394 //GObject.TYPE_STRING, // real key
2395 // GObject.TYPE_STRING, // real type
2396 // GObject.TYPE_STRING, // docs ?
2397 // GObject.TYPE_STRING // func def?
2400 this.el.set_value(iter, 0, p.name);
2401 this.el.set_value(iter, 1, p.type);
2402 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2403 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2404 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2405 this.el.set_value(iter, 5, type);
2413 xtype: Gtk.TreeViewColumn,
2415 this.el = new Gtk.TreeViewColumn();
2416 this.parent.el.append_column(this.el);
2418 XObject.prototype.init.call(this);
2419 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2424 xtype: Gtk.CellRendererText,
2425 pack : "pack_start,true"
2449 xtype: Gtk.Notebook,
2450 pack : "pack_start,true,true",
2451 id : "view-help-nb",
2453 XObject.prototype.init.call(this);
2454 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" }));
2455 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" }));
2459 xtype: Gtk.Notebook,
2461 id : "view-notebook",
2464 XObject.prototype.init.call(this);
2465 this.el.set_current_page(0);
2467 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2468 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2475 id : "RightBrowser",
2482 pack : "pack_start,false,true,0",
2486 pack : "pack_start,false,false,0",
2487 label : "Dump HTML to console",
2489 "activate":function (self) {
2490 this.get('/RightBrowser.view').el.execute_script(
2491 "console.log(document.body.innerHTML);");
2492 this.get('/RightBrowser.view').el.execute_script(
2493 "console.log(Builder.dump(Builder));");
2500 xtype: Gtk.ScrolledWindow,
2502 shadow_type : Gtk.ShadowType.IN,
2504 XObject.prototype.init.call(this);
2505 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2509 xtype: WebKit.WebView,
2513 XObject.prototype.init.call(this);
2514 // this may not work!?
2515 this.el.open('file:///' + __script_path__ + '/../builder.html');
2519 this.el, /* widget that will accept a drop */
2520 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2521 null, /* lists of target to support */
2522 0, /* size of list */
2523 Gdk.DragAction.COPY /* what to do with data after dropped */
2526 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2527 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2529 renderJS : function(data) {
2530 print("HTML RENDERING");
2531 this.renderedData = data;
2532 var str = JSON.stringify(data) ;
2535 console.log('not loaded yet');
2537 Seed.print("RENDER:" + str);
2538 imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2539 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2542 "load_finished":function (self, object) {
2543 if (this.ready) { // dont do it twice!
2548 this.renderJS(this.get('/LeftTree.model').toJS()[0]);
2550 "script_alert":function (self, object, p0) {
2553 return true; // do not display anything...
2555 "console_message":function (self, object, p0, p1) {
2556 console.log(object);
2557 if (!object.match(/^\{/)) {
2558 return false; // do not handle!!! -> later maybe in console..
2560 console.log(object);
2561 var val = JSON.parse(object);
2563 if (typeof(val['hover-node']) != 'undefined') {
2564 this.activeNode = val['hover-node'];
2565 console.log('active node: ' + this.activeNode);
2570 if (typeof(val['id']) != 'undefined') {
2571 // this.activeNode = val['id'];
2572 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2576 this.get('/LeftTree.view').selectNode(tg[0]);
2580 if (ret && typeof(val['set']) != 'undefined') {
2581 this.get('/LeftPanel.model').add({
2585 //console.log('active node: ' + this.activeNode);
2588 //Seed.print('a:'+a);
2589 //Seed.print('b:'+b);
2590 //Seed.print('c:'+c);
2593 "drag_motion":function (w, ctx, x, y, time, ud) {
2594 // console.log('DRAG MOTION');
2596 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2597 this.targetData = [];
2598 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2600 // A) find out from drag all the places that node could be dropped.
2601 var src = Gtk.drag_get_source_widget(ctx);
2602 if (!src.dropList) {
2603 Gdk.drag_status(ctx, 0, time);
2606 // b) get what we are over.. (from activeNode)
2607 // tree is empty.. - list should be correct..
2608 if (!this.get('/LeftTree.model').currentTree) {
2609 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2613 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2615 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2618 Gdk.drag_status(ctx, 0,time);
2619 this.get('/LeftTree.view').highlight(false);
2623 // if we have a target..
2624 // -> highlight it! (in browser)
2625 // -> highlight it! (in tree)
2627 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2628 this.get('/LeftTree.view').highlight(tg);
2629 this.targetData = tg;
2630 // for tree we should handle this...
2633 "drag_drop":function (w, ctx, x, y,time, ud) {
2634 print("TARGET: drag-drop");
2635 var is_valid_drop_site = true;
2640 w, /* will receive 'drag-data-received' signal */
2641 ctx, /* represents the current state of the DnD */
2642 this.get('/Window').atoms["STRING"], /* the target type we want */
2643 time /* time stamp */
2647 /* No target offered by source => error */
2650 return is_valid_drop_site;
2652 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2654 print("Browser: drag-data-received");
2655 var delete_selection_data = false;
2656 vardnd_success = false;
2657 /* Deal with what we are given from source */
2658 if( sel_data && sel_data.length ) {
2660 if (ctx.action == Gdk.DragAction.ASK) {
2661 /* Ask the user to move or copy, then set the ctx action. */
2664 if (ctx.action == Gdk.DragAction.MOVE) {
2665 delete_selection_data = true;
2667 var source = Gtk.drag_get_source_widget(ctx);
2669 print("Browser: source.DRAGDATA? " + source.dragData);
2670 if (this.targetData) {
2671 print(this.targetData);
2672 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2681 if (dnd_success == false)
2683 Seed.print ("DnD data transfer failed!\n");
2686 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2698 id : "RightGtkView",
2699 renderJS : function(data, withDebug)
2704 this.withDebug = false;
2706 if (this.renderedEl) {
2707 this.get('view').el.remove(this.renderedEl);
2708 this.renderedEl.destroy();
2709 this.renderedEl = false;
2712 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2713 // in theory tree is actually window..
2715 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2720 this.get('view').el.set_size_request(
2721 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2724 this.renderedEl.set_size_request(
2725 tree.default_width || 600,
2726 tree.default_height || 400
2728 this.get('view').el.show_all();
2733 showInWindow : function() {
2734 print("GET PROEJCT");
2735 var pr = this.get('/LeftProjectTree').getActiveProject();
2737 console.log(pr.paths);
2740 var src= this.buildJS(
2741 this.get('/LeftTree.model').toJS()[0],
2746 //var x = new imports.sandbox.Context();
2750 Seed.check_syntax('var e = ' + src);
2753 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2754 this.get('/Terminal').feed(console._dump(e)+"\n");
2756 var lines = src.split("\n");
2757 var start = Math.max(0, e.line - 10);
2758 var end = Math.min(lines.length, e.line + 10);
2759 for (var i =start ; i < end; i++) {
2761 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2764 this.get('/Terminal').feed(lines[i] + "\n");
2771 this.get('/BottomPane').el.set_current_page(1);
2772 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2773 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2774 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2776 var _top = x.get_global_object()._top;
2778 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2780 if (_top.el.popup) {
2781 _top.el.popup(null, null, null, null, 3, null);
2785 viewAdd : function(item, par)
2787 // does something similar to xobject..
2788 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2790 if (item.pack===false || item.pack === 'false') { // no ;
2793 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2794 var ns = imports.gi[item['|xns']];
2795 var ctr = ns[item['xtype']];
2797 for(var k in item) {
2799 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2814 if (k[0] == '|' && typeof(kv) == 'string') {
2816 if (kv.match(new RegExp('function'))) {
2819 print("WASL " + k + '=' + kv);
2821 eval( 'kv = ' + kv);
2822 } catch(e) { continue; }
2825 print(k + '=' + kv);
2827 if (k[0] == '|') { // should be boolean or number..
2829 print(k + '=' + kv);
2832 if (k == 'show_tabs') { // force tab showing for notebooks.
2840 var el = new ctr(ctr_args);
2843 //console.dump(item.pack);
2850 if (typeof(item.pack) == 'string') {
2852 item.pack.split(',').forEach(function(e, i) {
2854 if (e == 'false') { args.push( false); return; }
2855 if (e == 'true') { args.push( true); return; }
2856 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2859 //print(args.join(","));
2861 pack_m = args.shift();
2863 pack_m = item.pack.shift();
2868 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2870 name: "ArgumentError",
2871 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2872 "ADDING : " + item.id + " " + el
2881 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2882 //Seed.print('args: ' + args.length);
2884 par[pack_m].apply(par, args);
2888 item.items = item.items || [];
2889 item.items.forEach(function(ch) {
2890 _this.viewAdd(ch, el);
2895 // add the signal handlers.
2896 // is it a widget!?!!?
2902 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2903 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2904 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2905 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2906 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2916 widgetExposeEvent : function(w, evt, ud, item) {
2918 if (this.inRender) {
2922 if ( this.highlightWidget) {
2923 this.inRender = true;
2924 if (item.xtreepath.substring(0, this.activePath.length) == this.activePath) {
2925 Gdk.draw_rectangle(this.highlightWidget.window, this.gc, false, this.box.x , this.box.y, this.box.w, this.box.h);
2927 this.inRender = false;
2932 if (this.activePath != item.xtreepath) {
2936 // print("HIGHLIGHT: " + item.xtreepath ); // draw highlight??
2937 // work out the coords of the window..
2939 var dr = widget.window;
2940 this.gc = (new Gdk.GC.c_new(dr));
2941 this.gc.set_rgb_fg_color(new Gdk.Color({ red: 0xFFFF, green: 0, blue : 0 }));
2942 this.gc.set_line_attributes(4, Gdk.LineStyle.SOLID, Gdk.CapStyle.ROUND , Gdk.JoinStyle.ROUND);
2946 var r = evt.expose.area;
2947 // console.dump([r.x, r.y, r.width, r.height ] );
2949 // print(widget.get_parent().toString().match(/GtkScrolledWindow/);
2950 if (widget.get_parent().toString().match(/GtkScrolledWindow/)) { // eak
2951 // happens with gtkscrollview embedded stuff..
2952 var np =this.activePath.split(':');
2954 this.activePath = np.join(':');
2955 this.renderedEl.queue_draw();
2971 this.inRender = true;
2974 this.highlightWidget = widget;
2979 // print("DRAW BOX");
2980 //console.dump(this.box);
2981 Gdk.draw_rectangle(widget.window, this.gc, false, this.box.x , this.box.y, this.box.w,this.box.h);
2982 this.inRender = false;
2985 widgetDragMotionEvent : function() {
2986 print("WIDGET DRAGMOTION");
2989 widgetDragDropEvent : function() {
2990 print("WIDGET DRAGDROP");
2993 widgetPressEvent : function(w,e,u,d) {
2994 if (this.get('view').pressed) {
2997 this.get('view').pressed = true;
2998 print("WIDGET PRESS " + d.xtreepath );
2999 this.get('/LeftTree.view').selectNode( d.xtreepath );
3002 widgetReleaseEvent : function() {
3003 this.get('view').pressed = false;
3006 redraw : function() {
3007 this.highlightWidget = false;
3008 print("REDRAW CALLED");
3009 this.activePath = this.get('/LeftTree').getActivePath();
3010 if (this.renderedEl) {
3011 print("QUEUE DRAW CALLING");
3012 this.renderedEl.queue_draw();
3018 pack : "pack_start,false,true,0",
3022 pack : "pack_start,false,false,0",
3023 label : "Run The Application",
3025 "button_press_event":function (self, event) {
3026 // call render on left tree - with special option!?!
3030 print("GET PROEJCT");
3031 var pr = this.get('/LeftProjectTree').getActiveProject();
3034 for (var i in pr.paths) {
3038 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
3039 print ("RUN DIR:" + dir);
3040 this.get('/BottomPane').el.show();
3041 this.get('/BottomPane').el.set_current_page(1);
3042 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
3043 , false,false,false);
3044 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
3045 this.get('/Terminal').el.feed_child(cmd, cmd.length);
3055 xtype: Gtk.ScrolledWindow,
3058 shadow_type : Gtk.ShadowType.IN,
3060 XObject.prototype.init.call(this);
3061 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3065 xtype: Gtk.EventBox,
3066 pack : "add_with_viewport",
3068 XObject.prototype.init.call(this);
3069 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
3070 red: 0x9F00, green: 0xB800 , blue : 0xA800
3078 XObject.prototype.init.call(this);
3079 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
3080 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
3085 xtype: Gtk.EventBox,
3088 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
3089 XObject.prototype.init.call(this);
3093 this.el, /* widget that will accept a drop */
3094 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
3095 null, /* lists of target to support */
3096 0, /* size of list */
3097 Gdk.DragAction.COPY /* what to do with data after dropped */
3100 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
3101 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
3104 getActiveNode : function(x,y)
3106 // workout what node is here..
3107 return '0'; // top..
3111 "drag_motion":function (self, ctx, x, y, time) {
3113 // A) find out from drag all the places that node could be dropped.
3114 var src = Gtk.drag_get_source_widget(ctx);
3115 if (!src.dropList) {
3116 Gdk.drag_status(ctx, 0, time);
3119 // b) get what we are over.. (from activeNode)
3120 // tree is empty.. - list should be correct..
3121 if (!this.get('/LeftTree.model').currentTree) {
3122 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3126 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
3127 var activeNode = this.getActiveNode(x, y);
3130 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
3133 Gdk.drag_status(ctx, 0,time);
3134 this.get('/LeftTree.view').highlight(false);
3138 // if we have a target..
3139 // -> highlight it! (in browser)
3140 // -> highlight it! (in tree)
3142 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3143 this.get('/LeftTree.view').highlight(tg);
3144 this.targetData = tg;
3145 // for tree we should handle this...
3148 "drag_drop":function (self,ctx, x, y, time) {
3149 Seed.print("TARGET: drag-drop");
3150 var is_valid_drop_site = true;
3155 self, /* will receive 'drag-data-received' signal */
3156 ctx, /* represents the current state of the this.gDnD */
3157 this.get('/Window').atoms["STRING"], /* the target type we want */
3158 time /* time stamp */
3162 /* No target offered by source => error */
3165 return is_valid_drop_site;
3168 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3170 Seed.print("GtkView: drag-data-received");
3171 var delete_selection_data = false;
3172 var dnd_success = false;
3173 /* Deal with what we are given from source */
3174 if( sel_data && sel_data.length ) {
3176 if (ctx.action == Gdk.DragAction.ASK) {
3177 /* Ask the user to move or copy, then set the ctx action. */
3180 if (ctx.action == Gdk.DragAction.MOVE) {
3181 delete_selection_data = true;
3183 var source = Gtk.drag_get_source_widget(ctx);
3185 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3186 if (this.targetData) {
3187 Seed.print(this.targetData);
3188 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3197 if (dnd_success == false)
3199 Seed.print ("DnD data transfer failed!\n");
3202 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3205 "button_press_event":function (self, event) {
3206 this.pressed = false;
3222 xtype: Gtk.ScrolledWindow,
3227 xtype: WebKit.WebView,
3231 XObject.prototype.init.call(this);
3232 this.get('/Window.help-view').el.open(
3233 "http://devel.akbkhome.com/seed/");
3244 xtype: Gtk.Notebook,
3247 XObject.prototype.init.call(this);
3248 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3249 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3254 xtype: Gtk.ScrolledWindow,
3259 xtype: GtkSource.View,
3263 XObject.prototype.init.call(this);
3264 var description = Pango.Font.description_from_string("monospace")
3265 description.set_size(8000);
3266 this.el.modify_font(description);
3269 load : function(str) {
3271 // show the help page for the active node..
3272 this.get('/Window.view-help-nb').el.set_current_page(1);
3274 // get the active element being edited.
3275 var xtype = this.get('/LeftTree.model').file.guessName(
3276 this.get('/MidPropTree').activeElement);
3277 // now load the help info in the page..
3278 this.get('/Window.help-view').el.open(
3279 "http://devel.akbkhome.com/seed/" + xtype + ".html");
3282 this.get('/BottomPane').el.set_current_page(0);
3283 this.el.get_buffer().set_text(str, str.length);
3284 var lm = GtkSource.LanguageManager.get_default();
3286 this.el.get_buffer().set_language(lm.get_language('js'));
3287 var buf = this.el.get_buffer();
3288 var cursor = buf.get_mark("insert");
3289 var iter= new Gtk.TextIter;
3290 buf.get_iter_at_mark(iter, cursor);
3292 iter.set_line_offset(4);
3293 buf.move_mark(cursor, iter);
3296 cursor = buf.get_mark("selection_bound");
3297 iter= new Gtk.TextIter;
3298 buf.get_iter_at_mark(iter, cursor);
3300 iter.set_line_offset(4);
3301 buf.move_mark(cursor, iter);
3303 this.el.grab_focus();
3305 insert_spaces_instead_of_tabs : true,
3308 show_line_numbers : true,
3311 xtype: GtkSource.Buffer,
3312 pack : "set_buffer",
3314 "changed":function (self) {
3315 var s = new Gtk.TextIter();
3316 var e = new Gtk.TextIter();
3317 this.el.get_start_iter(s);
3318 this.el.get_end_iter(e);
3319 var str = this.el.get_text(s,e,true);
3321 Seed.check_syntax('var e = ' + str);
3323 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3324 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3326 print("SYNTAX ERROR IN EDITOR");
3331 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3332 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3335 this.get('/LeftPanel.model').changed( str , false);
3344 xtype: Gtk.ScrolledWindow,
3348 xtype: Vte.Terminal,
3351 feed : function(str) {
3352 this.el.feed(str,str.length);
3363 pack : "pack_start,false,false",
3367 this.get('buttonbar').el.show();
3368 this.get('viewbox').el.hide();
3369 print("TRIED TO HIDE");
3372 this.get('buttonbar').el.hide();
3373 this.get('viewbox').el.show();
3374 // this.get('model').expanded();
3386 pack : "pack_start,false,true",
3388 "clicked":function (self) {
3389 this.get('/RightPalete').show();
3396 stock : Gtk.STOCK_GOTO_FIRST,
3397 icon_size : Gtk.IconSize.MENU
3407 XObject.prototype.init.call(this);
3408 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3411 "enter_notify_event":function (self, event) {
3412 this.get('/RightPalete').show();
3426 pack : "pack_start,false,true",
3435 pack : "pack_start,false,true",
3437 "clicked":function (self) {
3438 this.get('/RightPalete').hide();
3445 stock : Gtk.STOCK_GOTO_LAST,
3446 icon_size : Gtk.IconSize.MENU
3453 xtype: Gtk.ScrolledWindow,
3456 XObject.prototype.init.call(this);
3457 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3458 this.el.set_size_request(-1,200);
3460 shadow_type : Gtk.ShadowType.IN,
3463 xtype: Gtk.TreeView,
3466 XObject.prototype.init.call(this);
3467 this.el.set_size_request(150,-1);
3468 // set_reorderable: [1]
3470 var description = new Pango.FontDescription.c_new();
3471 description.set_size(8000);
3472 this.el.modify_font(description);
3474 this.selection = this.el.get_selection();
3475 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3476 // this.selection.signal['changed'].connect(function() {
3477 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3479 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3481 Gtk.drag_source_set (
3482 this.el, /* widget will be drag-able */
3483 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3484 null, /* lists of target to support */
3485 0, /* size of list */
3486 Gdk.DragAction.COPY /* what to do with data after dropped */
3488 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3490 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3491 Gtk.drag_source_add_text_targets(this.el);
3493 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3494 targets = new Gtk.TargetList();
3495 targets.add( LeftTree.atoms["STRING"], 0, 0);
3496 targets.add_text_targets( 1 );
3497 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3499 //if you want to allow text to be output elsewhere..
3500 //Gtk.drag_source_add_text_targets(this.el);
3504 headers_visible : false,
3505 enable_tree_lines : true,
3507 "drag_begin":function (self, ctx) {
3508 // we could fill this in now...
3509 Seed.print('SOURCE: drag-begin');
3513 var iter = new Gtk.TreeIter();
3514 var s = this.selection;
3515 s.get_selected(this.get('/RightPalete.model').el, iter);
3516 var path = this.get('/RightPalete.model').el.get_path(iter);
3518 var pix = this.el.create_row_drag_icon ( path);
3521 Gtk.drag_set_icon_pixmap (ctx,
3528 var value = new GObject.Value('');
3529 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3530 if (!this.get('/RightPalete').provider) {
3533 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3534 this.el.dragData = value.value;
3541 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3542 //Seed.print('Palete: drag-data-get: ' + target_type);
3543 if (this.el.dragData && this.el.dragData.length ) {
3544 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3548 //this.el.dragData = "TEST from source widget";
3552 "drag_end":function (self, drag_context) {
3553 Seed.print('SOURCE: drag-end');
3554 this.el.dragData = false;
3555 this.el.dropList = false;
3556 this.get('/LeftTree.view').highlight(false);
3562 xtype: Gtk.ListStore,
3565 XObject.prototype.init.call(this);
3566 this.el.set_column_types ( 2, [
3567 GObject.TYPE_STRING, // title
3568 GObject.TYPE_STRING // tip
3573 load : function(tr,iter)
3578 //console.log('Project tree load: ' + tr.length);
3579 var citer = new Gtk.TreeIter();
3580 //this.insert(citer,iter,0);
3581 for(var i =0 ; i < tr.length; i++) {
3584 this.el.append(citer);
3586 this.el.insert(citer,iter,-1);
3591 this.el.set_value(citer, 0, '' + r ); // title
3593 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3594 //if (r.cn && r.cn.length) {
3595 // this.load(r.cn, citer);
3601 getValue : function (iter, col) {
3602 var gval = new GObject.Value('');
3603 this.el.get_value(iter, col ,gval);
3610 xtype: Gtk.TreeViewColumn,
3611 pack : "append_column",
3613 XObject.prototype.init.call(this);
3614 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3618 xtype: Gtk.CellRendererText,
3640 XObject.cache['/Window'] = Window;