3 Pango = imports.gi.Pango;
4 GLib = imports.gi.GLib;
6 GObject = imports.gi.GObject;
7 GtkSource = imports.gi.GtkSource;
8 WebKit = imports.gi.WebKit;
10 console = imports.console;
11 XObject = imports.XObject.XObject;
14 type : Gtk.WindowType.TOPLEVEL,
15 title : "Application Builder",
19 "STRING" : Gdk.atom_intern("STRING")
21 this.targetList = new Gtk.TargetList();
22 this.targetList.add( this.atoms["STRING"], 0, 0);
23 //imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();
25 "style \"gtkcombobox-style\" {\n" +
26 " GtkComboBox::appears-as-list = 1\n" +
28 "class \"GtkComboBox\" style \"gtkcombobox-style\"\n");
29 XObject.prototype.init.call(this);
39 "delete_event":function (self, event) {
42 "destroy":function (self) {
45 "show":function (self) {
46 print("WINDOW SHOWING - trying to hide");
47 imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();
48 this.get('/MidPropTree').hideWin();
49 this.get('/RightPalete').hide();
50 this.get('/BottomPane').el.hide();
61 pack : "pack_start,false,false",
75 label : "New _Project",
77 "activate":function (self) {
79 this.get('/EditProject').show({
80 success : function(pr) {
81 _this.get('/LeftProjectTree').get('combo').setValue(pr.fn);
92 "activate":function (self) {
93 var fn = this.get('/LeftProjectTree.combo').getValue();
95 this.get('/LeftProjectTree').showNoProjectSelected();
98 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
99 this.get('/DialogNewComponent').show({
100 project : pm.getByFn(fn)
106 xtype: Gtk.SeparatorMenuItem,
111 use_underline : true,
113 label : "D_elete Project",
115 "activate":function (self) {
117 var fn = this.get('/LeftProjectTree').get('combo').getValue();
119 this.get('/StandardErrorDialog').show("Select a project")
122 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
123 var pr = pm.getByFn(fn);
126 this.get('/DialogConfirm').show("Are you sure you want to delete project '" + pr.name + "'", function() {
127 pm.deleteProject(fn);
135 xtype: Gtk.SeparatorMenuItem,
142 use_underline : true,
144 "activate":function (self) {
178 label : "Select Project",
180 pack : "pack_start,false,true",
182 XObject.prototype.init.call(this);
183 this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
186 "activate":function (self) {
187 var nb = this.get('/LeftTopPanel.notebook');
188 if (this.el.expanded) {
191 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
194 var model = this.get('/LeftProjectTree.combomodel');
195 // print ("loading Projects?")
196 //console.dump(pm.projects);
197 model.loadData(pm.projects);
200 nb.el.set_current_page(1);
201 //pm.on('changed', function() {
202 //console.log("CAUGHT project manager change");
203 // _combo.model.loadData(pm.projects);
207 nb.el.set_current_page(0);
209 "enter_notify_event":function (self, event) {
210 this.el.expanded = !this.el.expanded;
211 //if (this.el.expanded ) {
212 this.listeners.activate.call(this);
224 pack : "pack_start,true,true",
226 XObject.prototype.init.call(this);
227 this.el.set_current_page(0);
232 xtype: Gtk.ScrolledWindow,
234 shadow_type : Gtk.ShadowType.IN,
236 XObject.prototype.init.call(this);
237 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
240 getPaleteProvider : function() {
241 var model = this.get('model');
242 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
243 return pm.getPalete(model.file.getType());
245 renderView : function() {
246 var render = this.getRenderer();
247 var model = this.get('model');
249 render.renderJS(model.toJS(false,true)[0]);
251 print("NO RENDER JS METHOD?");
254 getRenderer : function() {
256 switch( this.getActiveFile().getType()) {
258 return this.get('/RightBrowser.view');
260 return this.get('/RightGtkView');
264 getActivePath : function() {
265 var model = this.get('model');
266 var view = this.get('view');
267 if (view.selection.count_selected_rows() < 1) {
270 var iter = new Gtk.TreeIter();
272 view.selection.get_selected(model.el, iter);
273 return model.el.get_path(iter).to_string();
275 getActiveFile : function() {
276 return this.get('model').file;
278 getActiveElement : function() {
280 var path = this.getActivePath();
284 var iter = new Gtk.TreeIter();
285 this.get('model').el.get_iter_from_string(iter, path);
287 var value = new GObject.Value('');
288 this.get('model').el.get_value(iter, 2, value);
290 return JSON.parse(value.value);
297 headers_visible : false,
298 enable_tree_lines : true,
301 XObject.prototype.init.call(this);
302 var description = new Pango.FontDescription.c_new();
303 description.set_size(8000);
304 this.el.modify_font(description);
306 this.selection = this.el.get_selection();
307 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
310 // is this really needed??
311 this.selection.signal['changed'].connect(function() {
312 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
313 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
317 Gtk.drag_source_set (
318 this.el, /* widget will be drag-able */
319 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
320 null, /* lists of target to support */
321 0, /* size of list */
322 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
325 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
327 Gtk.drag_source_add_text_targets(this.el);
330 this.el, /* widget that will accept a drop */
331 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
332 null, /* lists of target to support */
333 0, /* size of list */
334 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
337 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
338 Gtk.drag_dest_add_text_targets(this.el);
340 highlight : function(treepath_ar) {
342 // highlighting for drag/drop
343 if (treepath_ar.length && treepath_ar[0].length ) {
344 this.el.set_drag_dest_row(
345 new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);
347 this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
351 selectNode : function(treepath_str) {
352 //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
353 var tp = new Gtk.TreePath.from_string(treepath_str);
354 this.el.set_cursor(tp, null, false);
355 this.el.scroll_to_cell(tp, null, false, 0,0);
358 "button_press_event":function (self, ev) {
359 console.log("button press?");
360 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
361 print("click" + ev.type);
367 this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
369 if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();
371 this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
372 this.get('/LeftTreeMenu').el.show_all();
373 this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
374 print("click:" + res.path.to_string());
377 "drag_begin":function (self, drag_context) {
378 print('SOURCE: drag-begin');
379 this.targetData = false;
380 // find what is selected in our tree...
381 var iter = new Gtk.TreeIter();
382 var s = this.selection;
383 s.get_selected(this.get('/LeftTree.model').el, iter);
385 // set some properties of the tree for use by the dropped element.
386 var value = new GObject.Value('');
387 this.get('/LeftTree.model').el.get_value(iter, 2, value);
388 var data = JSON.parse(value.value);
389 var xname = this.get('/LeftTree.model').file.guessName(data);
391 this.el.dragData = xname;
392 this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);
395 // make the drag icon a picture of the node that was selected
396 var path = this.get('/LeftTree.model').el.get_path(iter);
397 this.el.treepath = path.to_string();
399 var pix = this.el.create_row_drag_icon ( path);
401 Gtk.drag_set_icon_pixmap (ctx,
410 "drag_end":function (self, drag_context) {
411 Seed.print('LEFT-TREE: drag-end');
412 this.el.dragData = false;
413 this.el.dropList = false;
414 this.targetData = false;
415 this.get('/LeftTree.view').highlight(false);
418 "drag_motion":function (self, ctx, x, y, time) {
419 console.log("LEFT-TREE: drag-motion");
420 var src = Gtk.drag_get_source_widget(ctx);
422 // a drag from elsewhere...- prevent drop..
424 print("no drag data!");
425 Gdk.drag_status(ctx, 0, time);
426 this.targetData = false;
429 var action = Gdk.DragAction.COPY;
430 if (src == this.el) {
431 // unless we are copying!!! ctl button..
432 action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
436 if (!this.get('/LeftTree.model').el.iter_n_children(null)) {
437 // no children.. -- asume it's ok..
438 this.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];
439 Gdk.drag_status(ctx, action ,time);
443 print("GETTING POS");
444 var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);
445 print("ISOVER? " + isOver);
447 Gdk.drag_status(ctx, 0 ,time);
448 return false; // not over apoint!?!
450 // drag node is parent of child..
451 console.log("SRC TREEPATH: " + src.treepath);
452 console.log("TARGET TREEPATH: " + data.path.to_string());
454 // nned to check a few here..
455 //Gtk.TreeViewDropPosition.INTO_OR_AFTER
456 //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
457 //Gtk.TreeViewDropPosition.AFTER
458 //Gtk.TreeViewDropPosition.BEFORE
460 if (typeof(src.treepath) != 'undefined' &&
461 src.treepath == data.path.to_string().substring(0,src.treepath.length)) {
462 print("subpath drag");
463 Gdk.drag_status(ctx, 0 ,time);
468 //print("DUMPING DATA");
469 //console.dump(data);
472 print(data.path.to_string() +' => '+ data.pos);
473 var tg = this.get('/LeftTree.model').findDropNodeByPath(
474 data.path.to_string(), src.dropList, data.pos);
476 this.get('/LeftTree.view').highlight(tg);
478 print("Can not find drop node path");
479 this.targetData = false;
480 Gdk.drag_status(ctx, 0, time);
484 this.targetData = tg;
487 Gdk.drag_status(ctx, action ,time);
491 "drag_drop":function (w, ctx, x, y, time) {
492 Seed.print("TARGET: drag-drop");
496 w, /* will receive 'drag-data-received' signal */
497 ctx, /* represents the current state of the DnD */
498 this.get('/Window').atoms["STRING"], /* the target type we want */
499 time /* time stamp */
503 /* No target offered by source => error */
508 "drag_data_received":function (self, ctx, x, y, sel_data, info, time) {
509 print("Tree: drag-data-received");
511 var delete_selection_data = false;
512 var dnd_success = false;
513 /* Deal with what we are given from source */
514 if( sel_data && sel_data.length ) {
516 if (ctx.action == Gdk.DragAction.ASK) {
517 /* Ask the user to move or copy, then set the ctx action. */
520 if (ctx.action == Gdk.DragAction.MOVE) {
521 //delete_selection_data = true;
524 var source = Gtk.drag_get_source_widget(ctx);
526 if (this.targetData) {
527 if (source != this.el) {
528 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
530 // drag around.. - reorder..
531 this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);
535 //Seed.print(this.targetData);
541 // we can send stuff to souce here...
547 if (dnd_success == false)
549 Seed.print ("DnD data transfer failed!\n");
552 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
555 "cursor_changed":function (self) {
556 if (this.blockChanges) { // probably not needed..
559 var render = this.get('/LeftTree').getRenderer();
562 if (this.selection.count_selected_rows() < 1) {
563 this.get('/LeftPanel.model').load( false);
564 this.get('/MidPropTree').activeElement = false;
565 this.get('/MidPropTree').hideWin();
567 var pm = this.get('/RightPalete.model');
568 if (!this.get('/LeftTree').getPaleteProvider()) {
569 // it may not be loaded yet..
572 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
573 this.get('/LeftTree.model').listAllTypes()));
574 if (render && render.redraw) {
580 //console.log('changed');
581 var s = this.selection;
582 var iter = new Gtk.TreeIter();
583 s.get_selected(this.get('/LeftTree.model').el, iter);
587 var value = new GObject.Value('');
588 this.get('/LeftTree.model').el.get_value(iter, 2, value);
589 this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
591 var data = JSON.parse(value.value);
592 this.get('/MidPropTree').activeElement = data;
593 this.get('/MidPropTree').hideWin();
594 this.get('/LeftPanel.model').load( data);
596 console.log(value.value);
597 // _g.button.set_label(''+value.get_string());
599 var pm =this.get('/RightPalete.model');
600 pm.load( this.get('/RightPalete').provider.gatherList(
601 this.get('/LeftTree.model').listAllTypes()));
604 if (render && render.redraw) {
608 //Seed.print( value.get_string());
615 xtype: Gtk.TreeStore,
619 XObject.prototype.init.call(this);
620 this.el.set_column_types ( 3, [
621 GObject.TYPE_STRING, // title
622 GObject.TYPE_STRING, // tip
623 GObject.TYPE_STRING // source..
627 changed : function(n, refresh) {
628 print("MODEL CHANGED CALLED" + this.activePath);
629 if (this.activePath) {
630 var iter = new Gtk.TreeIter();
631 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
632 this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
633 this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
635 this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
637 //this.currentTree = this.toJS(false, true)[0];
638 this.file.items = this.toJS(false, false);
639 print("AFTER CHANGED");
640 //console.dump(this.file.items);
642 this.currentTree = this.file.items[0];
643 //console.log(this.file.toSource());
646 print("REDNER BROWSER?!");
647 this.get('/LeftTree').renderView();
649 var pm = this.get('/RightPalete.model');
650 if (!this.get('/RightPalete').provider) {
656 pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
657 //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
661 loadFile : function(f) {
667 console.log('missing file');
671 // load the file if not loaded..
672 if (f.items === false) {
674 f.loadItems(function() {
680 if (f.items.length && typeof(f.items[0]) == 'string') {
682 this.get('/RightEditor').el.show();
683 this.get('/RightEditor.view').load( f.items[0]);
687 //console.dump(f.items);
689 this.get('/LeftTree.view').el.expand_all();
691 if (!f.items.length) {
694 this.get('/Window.leftvpaned').el.set_position(80);
696 this.get('/LeftTree.view').el.set_cursor(
697 new Gtk.TreePath.from_string('0'), null, false);
701 this.get('/Window.leftvpaned').el.set_position(200);
705 //print("hide right editior");
706 this.get('/RightEditor').el.hide();
707 //print("set current tree");
708 this.currentTree = this.toJS(false, false)[0];
709 //console.dump(this.currentTree);
710 this.currentTree = this.currentTree || { items: [] };
711 this.get('/LeftTree').renderView();
712 //console.dump(this.map);
713 //var RightPalete = imports.Builder.RightPalete.RightPalete;
714 var pm = this.get('/RightPalete.model');
717 this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
719 if (!this.get('/RightPalete').provider) {
720 print ("********* PALETE PROVIDER MISSING?!!");
722 this.get('/LeftTree').renderView();
724 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
728 this.get('/Window.view-notebook').el.set_current_page(
729 this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
732 findDropNode : function(treepath_str, targets) {
734 // this is used by the dragdrop code in the roo version AFAIR..
736 var path = treepath_str.replace(/^builder-/, '');
737 // treemap is depreciated... - should really check if model has any entries..
739 if (!this.el.iter_n_children(null)) {
741 return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];
743 print("FIND treepath: " + path);
744 //console.dump(this.treemap);
746 if (!treepath_str.match(/^builder-/)) {
747 return []; // nothing!
749 if (targets === true) {
752 return this.findDropNodeByPath(path,targets)
754 findDropNodeByPath : function(treepath_str, targets, pref) {
755 var path = treepath_str + ''; // dupe it..
756 pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
758 //console.dump(this.treemap);
759 while (path.length) {
760 print("LOOKING FOR PATH: " + path);
761 var node_data = this.singleNodeToJS(path);
762 if (node_data === false) {
763 print("node not found");
767 var xname = this.get('/LeftTree.model').file.guessName(node_data);
770 targets.forEach(function(tg) {
774 if ((tg == xname) ) {
777 if (tg.indexOf(xname +':') === 0) {
779 prop = tg.split(':').pop();
784 if (last) { // pref is after/before..
785 // then it's after last
787 return []; // do not allow..
789 return [ last, pref , prop];
792 return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
794 var par = path.split(':');
797 path = par.join(':');
803 dropNode : function(target_data, node) {
806 console.dump(target_data);
807 var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
809 print("add " + tp + "@" + target_data[1] );
812 if (tp && target_data[1] < 2) { // before or after..
813 var ar = target_data[0].split(':');
815 parent = new Gtk.TreePath.from_string( ar.join(':') );
818 var n_iter = new Gtk.TreeIter();
819 var iter_par = new Gtk.TreeIter();
820 var iter_after = after ? new Gtk.TreeIter() : false;
824 if (parent !== false) {
825 this.el.get_iter(iter_par, parent);
832 print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
833 this.el.get_iter(iter_after, after);
834 this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
835 n_iter, iter_par, iter_after);
838 this.el.append(n_iter, iter_par);
842 if (typeof(node) == 'string') {
843 var ar = node.split('.');
844 var xtype = ar.pop();
847 '|xns' : ar.join('.'),
850 if (target_data.length == 3 && target_data[2].length) {
851 node['*prop'] = target_data[2];
855 // work out what kind of packing to use..
856 if (typeof(node.pack) == 'undefined' && parent !== false) {
857 var pal = this.get('/LeftTree').getPaleteProvider();
859 var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
860 print ("PNAME : " + pname);
861 var cname = pal.guessName(node);
862 print ("CNAME : " + cname);
863 node.pack = pal.getDefaultPack(pname, cname);
874 // load children - if it has any..
877 this.load(xitems, n_iter);
879 if (tp && (xitems || after)) {
880 this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
882 // wee need to get the empty proptypes from somewhere..
884 //var olditer = this.activeIter;
885 this.activePath = this.el.get_path(n_iter).to_string();
887 // changed actually set's the node data..
888 this.changed(node, true);
892 this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
894 //Builder.MidPropTree._model.load(node);
895 //Builder.MidPropTree._win.hideWin();
896 //Builder.LeftPanel._model.load( node);
900 moveNode : function(target_data, action) {
901 //print("MOVE NODE");
902 // console.dump(target_data);
903 var old_iter = new Gtk.TreeIter();
904 var s = this.get('/LeftTree.view').selection;
905 s.get_selected(this.el, old_iter);
906 var node = this.nodeToJS(old_iter,false);
907 //console.dump(node);
910 // needs to drop first, otherwise the target_data
911 // treepath will be invalid.
913 this.dropNode(target_data, node);
914 if (action & Gdk.DragAction.MOVE) {
915 // print("REMOVING OLD NODE");
916 this.el.remove(old_iter);
920 this.activePath= false;
921 this.changed(false,true);
923 deleteSelected : function() {
924 this.get('/LeftTree.view').blockChanges = true;
925 var old_iter = new Gtk.TreeIter();
926 var s = this.get('/LeftTree.view').selection;
927 s.get_selected(this.el, old_iter);
928 var path = this.el.get_path(old_iter).to_string();
930 this.activePath= false;
933 this.activePath= false;
934 var iter = new Gtk.TreeIter();
935 this.el.get_iter_from_string(iter, path);
936 this.el.remove(iter);
938 // rebuild treemap. -- depreciated.!!
941 //this.toJS(null, true) // does not do anything?
942 this.activePath= false;
943 this.changed(false,true);
944 this.get('/LeftTree.view').blockChanges = false;
947 listAllTypes : function() {
948 var s = this.get('/LeftTree.view').selection;
949 print ("LIST ALL TYPES: " + s.count_selected_rows() );
951 if (s.count_selected_rows() > 0) {
952 var iter = new Gtk.TreeIter();
953 s.get_selected(this.el, iter);
955 // set some properties of the tree for use by the dropped element.
956 var value = new GObject.Value('');
957 this.el.get_value(iter, 2, value);
958 var data = JSON.parse(value.value);
961 var xname = this.get('/LeftTree.model').file.guessName(data);
962 console.log('selected:' + xname);
966 return []; // could not find it..
974 li.forEach(function(el) {
975 // this is specific to roo!!!?
977 var fullpath = _this.file.guessName(el);
978 if (fullpath.length && ret.indexOf(fullpath) < 0) {
983 if (el.items && el.items.length) {
992 addall([this.currentTree]);
994 // only if we have nothing, should we add '*top'
998 //console.log('all types in tree');
1004 singleNodeToJS : function (treepath)
1006 var iter = new Gtk.TreeIter();
1007 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
1011 var iv = this.getIterValue(iter, 2);
1013 return JSON.parse(iv);
1016 nodeToJS : function (iter, with_id)
1018 var par = new Gtk.TreeIter();
1019 var iv = this.getIterValue(iter, 2);
1020 // print("IV" + iv);
1021 var k = JSON.parse(iv);
1022 if (k.json && !this.el.iter_parent( par, iter )) {
1027 var treepath_str = this.el.get_path(iter).to_string();
1028 // not sure how we can handle mixed id stuff..
1029 if (typeof(k.id) == 'undefined') {
1030 k.id = 'builder-'+ treepath_str ;
1034 this.treemap[ treepath_str ] = k;
1035 k.xtreepath = treepath_str ;
1038 if (this.el.iter_has_child(iter)) {
1039 citer = new Gtk.TreeIter();
1040 this.el.iter_children(citer, iter);
1041 k.items = this.toJS(citer,with_id);
1045 toJS : function(iter, with_id)
1047 //Seed.print("WITHID: "+ with_id);
1054 iter = new Gtk.TreeIter();
1055 if (!this.el.get_iter_first(iter)) {
1065 var k = this.nodeToJS(iter, with_id);
1069 if (!this.el.iter_next(iter)) {
1075 // convert the list into a json string..
1079 getIterValue : function (iter, col) {
1080 var gval = new GObject.Value('');
1081 this.el.get_value(iter, col ,gval);
1086 nodeTitle : function(c) {
1089 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
1090 if (sr) txt.push('<s>');
1091 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
1092 if (c.xtype) { txt.push(c.xtype); }
1093 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1094 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1095 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1098 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1099 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1100 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1101 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1102 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1103 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1104 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1105 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1106 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1108 // for flat classes...
1109 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1110 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1113 if (sr) txt.push('</s>');
1114 return (txt.length == 0 ? "Element" : txt.join(" "));
1116 nodeToJSON : function(c) {
1124 return JSON.stringify(o);
1126 load : function(tr,iter)
1128 var citer = new Gtk.TreeIter();
1129 //this.insert(citer,iter,0);
1130 for(var i =0 ; i < tr.length; i++) {
1132 this.el.insert(citer,iter,-1);
1134 this.el.append(citer);
1137 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1138 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTip(tr[i]) ]);
1139 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1140 if (tr[i].items && tr[i].items.length) {
1141 this.load(tr[i].items, citer);
1145 nodeTip : function(c) {
1146 var ret = this.nodeTitle(c);
1152 if (!i.length || i[0] != '|') {
1158 if (typeof(c[i]) != 'string') {
1161 //print("prop : " + i + ':' + c[i]);
1162 if (!c[i].match(new RegExp('function'))) {
1165 funcs += "\n<b>" + i.substring(1) + '</b> : ' + c[i].split(/\n/).shift();
1169 ret+="\n\nMethods:" + funcs;
1176 xtype: Gtk.TreeViewColumn,
1177 pack : "append_column",
1179 XObject.prototype.init.call(this);
1180 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1184 xtype: Gtk.CellRendererText,
1194 id : "LeftTreeMenu",
1197 xtype: Gtk.MenuItem,
1199 label : "Delete Element",
1201 "activate":function (self) {
1203 this.get('/LeftTree.model').deleteSelected();
1214 id : "LeftProjectTree",
1215 showNoProjectSelected : function() {
1216 this.get('/StandardErrorDialog').show("Select a Project first.");
1218 getActiveProject : function() {
1219 return this.project;
1222 "leave_notify_event":function (self, event) {
1229 pack : "pack_start,false,false",
1232 xtype: Gtk.ComboBox,
1235 XObject.prototype.init.call(this);
1236 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1238 getValue : function() {
1239 var ix = this.el.get_active();
1243 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1244 if (typeof(data[ix]) == 'undefined') {
1249 setValue : function(fn)
1253 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1254 data.forEach(function(n, ix) {
1262 "changed":function (self) {
1263 var fn = this.getValue();
1264 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1265 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1270 xtype: Gtk.CellRendererText,
1271 pack : "pack_start,true",
1275 xtype: Gtk.ListStore,
1278 XObject.prototype.init.call(this);
1279 this.el.set_column_types ( 2, [
1280 GObject.TYPE_STRING, // real key
1281 GObject.TYPE_STRING // real type
1285 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1287 pm.on('changed', function() {
1288 print("caught changed hook on project manager - reloading data");
1289 _this.loadData(pm.projects);
1293 loadData : function(data) {
1294 var ov = this.get('/LeftProjectTree.combo').getValue();
1296 var iter = new Gtk.TreeIter();
1298 data.forEach(function(p) {
1303 el.set_value(iter, 0, p.fn);
1304 el.set_value(iter, 1, p.name);
1308 this.get('/LeftProjectTree.combo').setValue(ov);
1317 xtype: Gtk.ScrolledWindow,
1319 shadow_type : Gtk.ShadowType.IN,
1321 XObject.prototype.init.call(this);
1322 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1326 xtype: Gtk.TreeView,
1327 headers_visible : false,
1328 enable_tree_lines : true,
1331 XObject.prototype.init.call(this);
1332 var description = new Pango.FontDescription.c_new();
1333 description.set_size(8000);
1334 this.el.modify_font(description);
1336 this.selection = this.el.get_selection();
1337 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1341 "cursor_changed":function (self) {
1342 var iter = new Gtk.TreeIter();
1344 if (this.selection.count_selected_rows() < 1) {
1345 //XN.get('Builder.LeftTree.model').
1346 this.get('/LeftTree.model').load( false);
1350 var model = this.get('/LeftProjectTree.model');
1351 //console.log('changed');
1352 var s = this.selection;
1353 s.get_selected(model, iter);
1354 value = new GObject.Value('');
1355 model.el.get_value(iter, 2, value);
1357 console.log(value.value);// id..
1359 var file = this.get('/LeftProjectTree').project.getById(value.value);
1366 var nb = this.get('/LeftTopPanel.expander');
1367 nb.el.expanded = false;
1368 nb.listeners.activate.call(nb);
1369 //_expander.el.set_expanded(false);
1371 var ltm = this.get('/LeftTree.model');
1379 xtype: Gtk.TreeStore,
1383 XObject.prototype.init.call(this);
1384 this.el.set_column_types ( 3, [
1385 GObject.TYPE_STRING, // title
1386 GObject.TYPE_STRING, // tip
1387 GObject.TYPE_STRING // id..
1391 loadProject : function(pr) {
1392 print("LOAD PROJECT");
1398 this.get('/LeftProjectTree').project = pr;
1399 this.load(pr.toTree());
1400 this.get('/LeftProjectTree.view').el.expand_all();
1402 load : function(tr,iter) {
1403 // console.dump(tr);
1404 console.log('Project tree load: ' + tr.length);
1405 var citer = new Gtk.TreeIter();
1406 //this.insert(citer,iter,0);
1409 tr.forEach(function (r) {
1411 _this.el.append(citer);
1413 _this.el.insert(citer,iter,-1);
1415 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1416 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1417 _this.el.set_value(citer, 2, '' + r.id ); //id
1418 if (r.cn && r.cn.length) {
1419 _this.load(r.cn, citer);
1424 getValue : function(iter, col) {
1425 var gval = new GObject.Value('');
1426 this.el.get_value(iter, col ,gval);
1427 return '' + gval.value;
1431 xtype: Gtk.TreeViewColumn,
1432 pack : "append_column",
1434 XObject.prototype.init.call(this);
1435 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1439 xtype: Gtk.CellRendererText,
1462 pack : "pack_start,false,true,0",
1469 "button_press_event":function (self, event) {
1470 this.get('/MidPropTree.model').showData('props');
1482 stock : Gtk.STOCK_ADD,
1483 icon_size : Gtk.IconSize.MENU
1498 "button_press_event":function (self, event) {
1499 this.get('/MidPropTree.model').showData('events');
1511 stock : Gtk.STOCK_ADD,
1512 icon_size : Gtk.IconSize.MENU
1527 "button_press_event":function (self, ev) {
1528 var p = this.get('/AddPropertyPopup');
1532 p.el.set_screen(Gdk.Screen.get_default());
1534 p.el.popup(null, null, null, null, 3, ev.button.time);
1546 stock : Gtk.STOCK_ADD,
1547 icon_size : Gtk.IconSize.MENU
1559 id : "AddPropertyPopup",
1562 xtype: Gtk.MenuItem,
1564 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1567 "activate":function (self) {
1569 this.get('/LeftPanel.model').add( {
1580 xtype: Gtk.MenuItem,
1582 tooltip_markup : "Add what type of packing is to be used",
1585 "activate":function (self) {
1587 this.get('/LeftPanel.model').add( {
1597 xtype: Gtk.MenuItem,
1599 tooltip_markup : "Override the init method",
1602 "activate":function (self) {
1604 this.get('/LeftPanel.model').add( {
1607 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1614 xtype: Gtk.SeparatorMenuItem,
1618 xtype: Gtk.MenuItem,
1620 tooltip_markup : "Add a user defined string property",
1623 "activate":function (self) {
1625 this.get('/LeftPanel.model').add( {
1635 xtype: Gtk.MenuItem,
1637 tooltip_markup : "Add a user defined number property",
1640 "activate":function (self) {
1642 this.get('/LeftPanel.model').add( {
1652 xtype: Gtk.MenuItem,
1654 tooltip_markup : "Add a user defined boolean property",
1657 "activate":function (self) {
1659 this.get('/LeftPanel.model').add( {
1669 xtype: Gtk.SeparatorMenuItem,
1673 xtype: Gtk.MenuItem,
1675 tooltip_markup : "Add a user function boolean property",
1678 "activate":function (self) {
1680 this.get('/LeftPanel.model').add( {
1683 val : "function() {\n \n}\n",
1696 xtype: Gtk.ScrolledWindow,
1699 shadow_type : Gtk.ShadowType.IN,
1702 XObject.prototype.init.call(this);
1703 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1707 xtype: Gtk.TreeView,
1710 headers_visible : false,
1711 enable_tree_lines : true,
1713 XObject.prototype.init.call(this);
1715 this.selection = this.el.get_selection();
1716 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1719 var description = new Pango.FontDescription.c_new();
1720 description.set_size(8000);
1721 this.el.modify_font(description);
1724 "button_press_event":function (self, ev) {
1728 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1729 return false; //not on a element.
1733 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1735 if (res.column.title != 'value') {
1736 return false; // ignore..
1738 if ( this.get('/LeftPanel').editing) {
1741 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1742 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1743 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1747 var provider = this.get('/LeftTree').getPaleteProvider();
1749 var opts = provider.findOptions(type);
1751 if (opts === false) {
1752 this.get('/LeftPanel').editableColumn.setOptions([]);
1753 renderer.has_entry = true;
1755 LeftPanel.editableColumn.setOptions(opts);
1756 renderer.has_entry = false;
1760 //Seed.print("click" + ev.type);
1761 //console.dump(res);
1767 if (res.column.title == 'value') {
1770 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1771 var p = this.get('/LeftPanelPopup');
1776 p.el.set_screen(Gdk.Screen.get_default());
1778 p.el.popup(null, null, null, null, 3, ev.button.time);
1779 //Seed.print("click:" + res.column.title);
1787 xtype: Gtk.TreeStore,
1791 XObject.prototype.init.call(this);
1792 this.el.set_column_types ( 5, [
1793 GObject.TYPE_STRING, // 0 real key
1794 GObject.TYPE_STRING, // 1 real value
1795 GObject.TYPE_STRING, // 2 visable key
1796 GObject.TYPE_STRING, // 3 visable value
1797 GObject.TYPE_STRING, // 4 need to store type of!!!
1801 toShort : function(str) {
1802 var a = typeof(str) == 'string' ? str.split("\n") : [];
1803 return a.length > 1 ? a[0] + '....' : '' + str;
1805 load : function(ar) {
1808 this.get('/RightEditor').el.hide();
1815 var provider = this.get('/LeftTree').getPaleteProvider();
1818 var iter = new Gtk.TreeIter();
1820 if (typeof(ar[i]) == 'object') {
1824 var type = provider.findType(ar, i, ar[i]);
1826 this.el.append(iter);
1827 var p = this.el.get_path(iter).to_string();
1829 this.el.set_value(iter, 0, i);
1830 this.el.set_value(iter, 1, '' + ar[i]);
1831 this.el.set_value(iter, 2, i);
1832 this.el.set_value(iter, 3, this.toShort(ar[i]));
1833 this.el.set_value(iter, 4, type);
1835 ar.listeners = ar.listeners || {};
1836 for (var i in ar.listeners ) {
1837 this.el.append(iter);
1838 var p = this.el.get_path(iter).to_string();
1841 this.el.set_value(iter, 0, '!'+ i );
1842 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1843 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1845 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1846 this.el.set_value(iter, 4, 'function');
1850 add : function(info) {
1851 // info includes key, val, skel, etype..
1853 type = info.type.toLowerCase();
1854 var data = this.toJS();
1856 if (info.etype == 'events') {
1857 data.listeners = data.listeners || { };
1858 if (typeof(data.listeners[info.key]) != 'undefined') {
1859 return; //already set!
1862 if (typeof(data[info.key]) != 'undefined') {
1867 if (typeof(info.val) == 'undefined') {
1870 if (info.type == 'boolean') {
1873 if (type == 'number') {
1881 if (info.etype == 'events') {
1883 data.listeners[info.key] = info.val;
1886 data[info.key] = info.val;
1890 var map = this.load(data);
1892 // flag it as changed to the interface..
1894 this.get('/LeftTree.model').changed(data, true);
1897 this.startEditing(map[k]);
1900 LeftPanel.get('view').el.row_activated(
1901 new Gtk.TreePath.from_string(map[k]),
1902 LeftPanel.editableColumn.el
1906 startEditing : function(path,col) {
1908 * start editing path (or selected if not set..)
1909 * @param {String|false} path (optional) treepath to edit - selected tree gets
1910 * edited by default.
1911 * @param {Number} 0 or 1 (optional)- column to edit.
1914 if (typeof(path) == 'string') {
1915 tp = new Gtk.TreePath.from_string(path);
1917 var iter = new Gtk.TreeIter();
1918 var s = this.get('/LeftPanel.view').selection;
1919 s.get_selected(this.el, iter);
1920 tp = this.el.get_path(iter);
1921 path = tp.to_string();
1925 // which colum is to be edited..
1927 if (typeof(col) == 'undefined') {
1928 var k = this.getValue(path, 0);
1929 colObj = (!k.length || k == '|') ?
1930 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1932 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1935 // make sure the pulldown is set correctly..
1936 // not really needed for second col...
1938 var provider = this.get('/LeftTree').getPaleteProvider();
1940 var type = this.get('/LeftPanel.model').getType(path);
1941 var opts = provider.findOptions(type);
1942 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1944 if (opts === false) {
1945 this.get('/LeftPanel').editableColumn.setOptions([]);
1946 renderer.has_entry = true; /// probably does not have any effect.
1948 this.get('/LeftPanel').editableColumn.setOptions(opts);
1949 renderer.has_entry = false;
1953 // iter now has row...
1954 GLib.timeout_add(0, 100, function() {
1956 colObj.items[0].el.editable = true; // esp. need for col 0..
1957 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1966 deleteSelected : function() {
1967 var data = this.toJS();
1968 var iter = new Gtk.TreeIter();
1969 var s = this.get('/LeftPanel.view').selection;
1970 s.get_selected(this.el, iter);
1973 var gval = new GObject.Value('');
1974 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1976 var val = gval.value;
1977 if (val[0] == '!') {
1979 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1982 delete data.listeners[ val.substring(1)];
1983 if (!XObject.keys(data.listeners).length) {
1984 delete data.listeners;
1988 if (typeof(data[val]) == 'undefined') {
1996 this.get('/LeftTree.model').changed(data, true);
2000 changed : function(str, doRefresh) {
2001 if (!this.activePath) {
2004 var iter = new Gtk.TreeIter();
2005 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
2007 this.el.set_value(iter, 1, '' +str);
2008 this.el.set_value(iter, 3, '' + this.toShort(str));
2009 // update the tree...
2011 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
2014 var iter = new Gtk.TreeIter();
2015 this.get('/LeftPanel.model').el.get_iter_first(iter);
2020 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
2023 ar.listeners = ar.listeners || {};
2024 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
2027 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
2030 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
2036 //print(JSON.stringify(ar));
2040 getType : function(treepath) {
2041 return this.getValue(treepath, 4);
2043 getValue : function(treepath_str, col) {
2044 var iter = new Gtk.TreeIter();
2045 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
2047 var gval = new GObject.Value('');
2048 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
2049 var val = '' + gval.value;
2053 var type = this.getType(this.el.get_path(iter).to_string());
2054 //print("TYPE: " +type + " - val:" + val);
2055 switch(type.toLowerCase()) {
2061 return parseFloat(val); // Nan ?? invalid!!?
2063 return val == 'true' ? true : false;
2069 editSelected : function(e) {
2070 print("EDIT SELECTED?");
2071 var iter = new Gtk.TreeIter();
2072 var s = this.get('/LeftPanel.view').selection;
2073 s.get_selected(this.get('/LeftPanel.model').el, iter);
2074 var m = this.get('/LeftPanel.model')
2076 var gval = new GObject.Value('');
2077 this.el.get_value(iter, 0 ,gval);
2078 var val = '' + gval.value;
2080 gval = new GObject.Value('');
2081 this.el.get_value(iter, 1 ,gval);
2082 var rval = gval.value;
2083 var activePath = this.el.get_path(iter).to_string();
2084 this.activePath = activePath ;
2085 // was activeIter...
2088 var showEditor = false;
2090 if (val[0] == '!') {
2093 if (val[0] == '|') {
2094 if (rval.match(/function/g) || rval.match(/\n/g)) {
2101 this.activePath = false;
2102 GLib.timeout_add(0, 1, function() {
2103 // Gdk.threads_enter();
2104 _this.get('/BottomPane').el.show();
2105 _this.get('/RightEditor').el.show();
2106 _this.get('/RightEditor.view').load( rval );
2110 _this.activePath = activePath ;
2112 // Gdk.threads_leave();
2117 this.get('/BottomPane').el.hide();
2118 this.get('/RightEditor').el.hide();
2120 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2126 xtype: Gtk.TreeViewColumn,
2127 pack : "append_column",
2129 XObject.prototype.init.call(this);
2131 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2132 this.get('/LeftPanel').propertyColumn = this;
2137 xtype: Gtk.CellRendererText,
2138 pack : "pack_start",
2140 "editing_started":function (self, editable, path) {
2142 this.get('/LeftPanel.model').activePath = path;
2145 "edited":function (self, object, p0) {
2146 var model = this.get('/LeftPanel.model');
2147 var path = model.activePath;
2148 var iter = new Gtk.TreeIter();
2149 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2150 model.el.set_value(iter, 0, p0);
2151 model.el.set_value(iter, 2, p0);
2153 model.activePath = false;
2155 this.get('/LeftTree.model').changed(model.toJS(), true);
2156 this.el.editable = false;
2163 xtype: Gtk.TreeViewColumn,
2164 pack : "append_column",
2166 XObject.prototype.init.call(this);
2167 this.el.add_attribute(this.items[0].el , 'text', 3 );
2168 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2169 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2170 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2172 this.get('/LeftPanel').editableColumn= this;
2174 setOptions : function(ar) {
2175 var m = this.items[0].el.model;
2177 var iter = new Gtk.TreeIter();
2178 ar.forEach(function(i) {
2181 m.set_value(iter, 0, i);
2187 xtype: Gtk.CellRendererCombo,
2188 pack : "pack_start",
2193 XObject.prototype.init.call(this);
2194 this.el.model = new Gtk.ListStore();
2195 this.el.model.set_column_types ( 1, [
2196 GObject.TYPE_STRING // 0 real key
2200 "edited":function (self, object, p0) {
2201 this.get('/LeftPanel').editing = false;
2202 print("EDITED? p:" + p0 + " t:" + p0);
2203 this.get('/LeftPanel.model').changed(p0, true);
2204 this.get('/LeftPanel.model').activePath = false;
2206 "editing_started":function (self, editable, path) {
2207 this.get('/LeftPanel').editing = true;
2208 // console.log('editing started');
2209 // r.has_entry = false;
2210 this.get('/LeftPanel.model').editSelected(editable);
2221 id : "LeftPanelPopup",
2224 xtype: Gtk.MenuItem,
2228 "activate":function (self) {
2229 this.get('/LeftPanel.model').deleteSelected();
2234 xtype: Gtk.MenuItem,
2238 "activate":function (self) {
2239 this.get('/LeftPanel.model').startEditing(false, 0);
2252 xtype: Gtk.ScrolledWindow,
2253 pack : "pack_end,false,true,0",
2255 shadow_type : Gtk.ShadowType.IN,
2257 XObject.prototype.init.call(this);
2258 XObject.prototype.init.call(this);
2259 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2260 this.el.set_size_request ( 150, -1 );
2263 activeElement : false,
2264 hideWin : function() {
2271 if (this.get('/Window.left').el.position < 160) {
2274 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2281 xtype: Gtk.TreeView,
2282 enable_tree_lines : true,
2283 headers_visible : false,
2286 XObject.prototype.init.call(this);
2288 var description = new Pango.FontDescription.c_new();
2289 description.set_size(8000);
2290 this.el.modify_font(description);
2292 //this.selection = this.el.get_selection();
2293 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2302 "cursor_changed":function (self) {
2303 var iter = new Gtk.TreeIter();
2305 //console.log('changed');
2306 var m = this.get('model');
2307 if (!this.selection){
2308 this.selection = this.el.get_selection();
2311 var s = this.selection;
2312 if (!s.get_selected(m.el, iter)) {
2315 var tp = m.el.get_path(iter).to_string();
2320 var key = m.getValue(tp, 0);
2322 var type = m.getValue(tp, 1);
2323 var skel = m.getValue(tp, 3);
2324 var etype = m.getValue(tp, 5);
2327 this.get('/MidPropTree').hideWin();
2329 if (type == 'function') {
2331 if (etype != 'events') {
2335 this.get('/LeftPanel.model').add({
2344 if (type.indexOf('.') > -1 ||
2345 type == 'boolean') {
2349 this.get('/LeftPanel.model').add( {
2359 xtype: Gtk.ListStore,
2362 XObject.prototype.init.call(this);
2363 this.el.set_column_types ( 6, [
2364 GObject.TYPE_STRING, // real key
2365 GObject.TYPE_STRING, // real type
2366 GObject.TYPE_STRING, // docs ?
2367 GObject.TYPE_STRING, // visable desc
2368 GObject.TYPE_STRING, // function desc
2369 GObject.TYPE_STRING // element type (event|prop)
2373 getValue : function(treepath, col)
2375 var tp = new Gtk.TreePath.from_string (treepath);
2376 var iter = new Gtk.TreeIter();
2377 this.el.get_iter (iter, tp);
2378 var value = new GObject.Value('');
2379 this.el.get_value(iter, col, value);
2383 showData : function(type) {
2385 if (!this.get('/MidPropTree').activeElement || !type) {
2386 return; // no active element
2389 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2390 var palete = this.get('/LeftTree').getPaleteProvider();
2394 Seed.print('Showing right?');
2395 if (!this.get('/MidPropTree').shown) {
2397 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2398 this.get('/MidPropTree').el.show();
2399 this.get('/MidPropTree').shown = true;
2402 var elementList = palete.getPropertiesFor(fullpath, type);
2403 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2404 // console.dump(elementList);
2407 var iter = new Gtk.TreeIter();
2408 for(var i =0 ; i < elementList.length; i++) {
2409 var p=elementList[i];
2410 this.el.append(iter);
2411 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2412 //GObject.TYPE_STRING, // real key
2413 // GObject.TYPE_STRING, // real type
2414 // GObject.TYPE_STRING, // docs ?
2415 // GObject.TYPE_STRING // func def?
2418 this.el.set_value(iter, 0, p.name);
2419 this.el.set_value(iter, 1, p.type);
2420 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2421 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2422 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2423 this.el.set_value(iter, 5, type);
2431 xtype: Gtk.TreeViewColumn,
2433 this.el = new Gtk.TreeViewColumn();
2434 this.parent.el.append_column(this.el);
2436 XObject.prototype.init.call(this);
2437 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2442 xtype: Gtk.CellRendererText,
2443 pack : "pack_start,true"
2467 xtype: Gtk.Notebook,
2468 pack : "pack_start,true,true",
2469 id : "view-help-nb",
2471 XObject.prototype.init.call(this);
2472 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" }));
2473 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" }));
2477 xtype: Gtk.Notebook,
2479 id : "view-notebook",
2482 XObject.prototype.init.call(this);
2483 this.el.set_current_page(0);
2485 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2486 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2493 id : "RightBrowser",
2500 pack : "pack_start,false,true,0",
2504 pack : "pack_start,false,false,0",
2507 "button_press_event":function (self, event) {
2508 var js = this.get('/LeftTree.model').toJS();
2510 this.get('/RightBrowser.view').renderJS(js[0]);
2519 label : "Set extra HTML in render",
2521 "button_press_event":function (self, event) {
2522 this.get('/RooProjectProperties').show();
2530 xtype: Gtk.ScrolledWindow,
2532 shadow_type : Gtk.ShadowType.IN,
2534 XObject.prototype.init.call(this);
2535 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2539 xtype: WebKit.WebView,
2543 XObject.prototype.init.call(this);
2544 // this may not work!?
2545 this.el.open('file:///' + __script_path__ + '/../builder.html');
2549 this.el, /* widget that will accept a drop */
2550 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2551 null, /* lists of target to support */
2552 0, /* size of list */
2553 Gdk.DragAction.COPY /* what to do with data after dropped */
2556 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2557 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2559 renderJS : function(data) {
2560 print("HTML RENDERING");
2561 /// prevent looping..
2562 //if (this.pendingRedraw) {
2563 // print("pending redraw active?!");
2568 if (!this.get('/Window.LeftTree').getActiveFile()) {
2572 var project = this.get('/Window.LeftTree').getActiveFile().project;
2573 //print (project.fn);
2575 project.runhtml = project.runhtml || '';
2578 this.runhtml = this.runhtml || '';
2580 if (project.runhtml != this.runhtml) {
2581 // then we need to reload the browser using
2582 // load_html_string..
2584 // then trigger a redraw once it's loaded..
2585 this.pendingRedraw = true;
2587 this.runhtml = project.runhtml;
2589 var html = imports.File.File.read(__script_path__ + '/../builder.html');
2590 html = html.replace('</head>', this.runhtml + '</head>');
2591 print("LOAD HTML " + html);
2592 this.el.load_html_string( html , 'file:///' + __script_path__ + '/../builder.html');
2593 // should trigger load_finished!
2598 this.pendingRedraw = false;
2601 this.renderedData = data;
2602 var str = JSON.stringify(data) ;
2605 console.log('not loaded yet');
2607 //Seed.print("RENDER:" + str);
2608 //imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2610 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2613 "load_finished":function (self, object) {
2614 // if (this.ready) { // dont do it twice!
2618 this.pendingRedraw = false;
2619 var js = this.get('/LeftTree.model').toJS();
2621 this.renderJS(js[0]);
2625 "script_alert":function (self, object, p0) {
2628 return true; // do not display anything...
2630 "console_message":function (self, object, p0, p1) {
2631 // console.log(object);
2632 if (!object.match(/^\{/)) {
2634 this.get('/Terminal').feed(object);
2635 return true; // do not handle!!! -> later maybe in console..
2637 // console.log(object);
2638 var val = JSON.parse(object);
2640 if (typeof(val['hover-node']) != 'undefined') {
2641 this.activeNode = val['hover-node'];
2642 console.log('active node: ' + this.activeNode);
2647 if (typeof(val['id']) != 'undefined') {
2648 // this.activeNode = val['id'];
2649 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2653 this.get('/LeftTree.view').selectNode(tg[0]);
2657 if (ret && typeof(val['set']) != 'undefined') {
2658 this.get('/LeftPanel.model').add({
2662 //console.log('active node: ' + this.activeNode);
2665 //Seed.print('a:'+a);
2666 //Seed.print('b:'+b);
2667 //Seed.print('c:'+c);
2670 "drag_motion":function (w, ctx, x, y, time, ud) {
2671 // console.log('DRAG MOTION');
2673 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2674 this.targetData = [];
2675 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2677 // A) find out from drag all the places that node could be dropped.
2678 var src = Gtk.drag_get_source_widget(ctx);
2679 if (!src.dropList) {
2680 Gdk.drag_status(ctx, 0, time);
2683 // b) get what we are over.. (from activeNode)
2684 // tree is empty.. - list should be correct..
2685 if (!this.get('/LeftTree.model').currentTree) {
2686 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2690 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2692 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2695 Gdk.drag_status(ctx, 0,time);
2696 this.get('/LeftTree.view').highlight(false);
2700 // if we have a target..
2701 // -> highlight it! (in browser)
2702 // -> highlight it! (in tree)
2704 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2705 this.get('/LeftTree.view').highlight(tg);
2706 this.targetData = tg;
2707 // for tree we should handle this...
2710 "drag_drop":function (w, ctx, x, y,time, ud) {
2711 print("TARGET: drag-drop");
2712 var is_valid_drop_site = true;
2717 w, /* will receive 'drag-data-received' signal */
2718 ctx, /* represents the current state of the DnD */
2719 this.get('/Window').atoms["STRING"], /* the target type we want */
2720 time /* time stamp */
2724 /* No target offered by source => error */
2727 return is_valid_drop_site;
2729 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2731 print("Browser: drag-data-received");
2732 var delete_selection_data = false;
2733 vardnd_success = false;
2734 /* Deal with what we are given from source */
2735 if( sel_data && sel_data.length ) {
2737 if (ctx.action == Gdk.DragAction.ASK) {
2738 /* Ask the user to move or copy, then set the ctx action. */
2741 if (ctx.action == Gdk.DragAction.MOVE) {
2742 delete_selection_data = true;
2744 var source = Gtk.drag_get_source_widget(ctx);
2746 print("Browser: source.DRAGDATA? " + source.dragData);
2747 if (this.targetData) {
2748 print(this.targetData);
2749 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2758 if (dnd_success == false)
2760 Seed.print ("DnD data transfer failed!\n");
2763 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2775 id : "RightGtkView",
2776 renderJS : function(data, withDebug)
2778 this.highlightWidget = false;
2782 this.withDebug = false;
2784 if (this.renderedEl) {
2785 this.get('view').el.remove(this.renderedEl);
2786 this.renderedEl.destroy();
2787 this.renderedEl = false;
2790 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2791 // in theory tree is actually window..
2793 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2798 this.get('view').el.set_size_request(
2799 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2802 this.renderedEl.set_size_request(
2803 tree.default_width || 600,
2804 tree.default_height || 400
2806 this.get('view').el.show_all();
2811 showInWindow : function() {
2812 print("GET PROEJCT");
2813 var pr = this.get('/LeftProjectTree').getActiveProject();
2815 console.log(pr.paths);
2818 var src= this.buildJS(
2819 this.get('/LeftTree.model').toJS()[0],
2824 //var x = new imports.sandbox.Context();
2828 Seed.check_syntax('var e = ' + src);
2831 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2832 this.get('/Terminal').feed(console._dump(e)+"\n");
2834 var lines = src.split("\n");
2835 var start = Math.max(0, e.line - 10);
2836 var end = Math.min(lines.length, e.line + 10);
2837 for (var i =start ; i < end; i++) {
2839 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2842 this.get('/Terminal').feed(lines[i] + "\n");
2849 this.get('/BottomPane').el.set_current_page(1);
2850 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2851 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2852 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2854 var _top = x.get_global_object()._top;
2856 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2858 if (_top.el.popup) {
2859 _top.el.popup(null, null, null, null, 3, null);
2863 viewAdd : function(item, par)
2865 // does something similar to xobject..
2866 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2868 if (item.pack===false || item.pack === 'false') { // no ;
2871 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2872 var ns = imports.gi[item['|xns']];
2873 var ctr = ns[item['xtype']];
2875 for(var k in item) {
2877 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2892 if (k[0] == '|' && typeof(kv) == 'string') {
2894 if (kv.match(new RegExp('function'))) {
2897 print("WASL " + k + '=' + kv);
2899 eval( 'kv = ' + kv);
2900 } catch(e) { continue; }
2903 // print(k + '=' + kv);
2905 if (k[0] == '|') { // should be boolean or number..
2907 //print(k + '=' + kv);
2910 if (k == 'show_tabs') { // force tab showing for notebooks.
2913 print(k + '=' + typeof(kv) + " : " + kv);
2919 var el = new ctr(ctr_args);
2922 //console.dump(item.pack);
2929 if (typeof(item.pack) == 'string') {
2931 item.pack.split(',').forEach(function(e, i) {
2933 if (e == 'false') { args.push( false); return; }
2934 if (e == 'true') { args.push( true); return; }
2935 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2938 //print(args.join(","));
2940 pack_m = args.shift();
2942 pack_m = item.pack.shift();
2947 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2949 name: "ArgumentError",
2950 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2951 "ADDING : " + item.id + " " + el
2960 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2961 //Seed.print('args: ' + args.length);
2963 par[pack_m].apply(par, args);
2967 item.items = item.items || [];
2968 item.items.forEach(function(ch) {
2969 _this.viewAdd(ch, el);
2974 // add the signal handlers.
2975 // is it a widget!?!!?
2981 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2982 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2983 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2984 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2985 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2995 widgetExposeEvent : function(w, evt, ud, item) {
2997 if (this.inRender) {
3001 if ( this.highlightWidget) {
3002 this.inRender = true;
3003 if (item.xtreepath.substring(0, this.activePath.length) == this.activePath) {
3004 Gdk.draw_rectangle(this.highlightWidget.window, this.gc, false, this.box.x , this.box.y, this.box.w, this.box.h);
3006 this.inRender = false;
3011 if (this.activePath != item.xtreepath) {
3015 // print("HIGHLIGHT: " + item.xtreepath ); // draw highlight??
3016 // work out the coords of the window..
3018 var dr = widget.window;
3019 this.gc = (new Gdk.GC.c_new(dr));
3020 this.gc.set_rgb_fg_color(new Gdk.Color({ red: 0xFFFF, green: 0, blue : 0 }));
3021 this.gc.set_line_attributes(4, Gdk.LineStyle.SOLID, Gdk.CapStyle.ROUND , Gdk.JoinStyle.ROUND);
3025 var r = evt.expose.area;
3026 // console.dump([r.x, r.y, r.width, r.height ] );
3028 // print(widget.get_parent().toString().match(/GtkScrolledWindow/);
3029 if (widget.get_parent().toString().match(/GtkScrolledWindow/)) { // eak
3030 // happens with gtkscrollview embedded stuff..
3031 var np =this.activePath.split(':');
3033 this.activePath = np.join(':');
3034 this.renderedEl.queue_draw();
3050 this.inRender = true;
3053 this.highlightWidget = widget;
3058 // print("DRAW BOX");
3059 //console.dump(this.box);
3060 Gdk.draw_rectangle(widget.window, this.gc, false, this.box.x , this.box.y, this.box.w,this.box.h);
3061 this.inRender = false;
3064 widgetDragMotionEvent : function() {
3065 print("WIDGET DRAGMOTION");
3068 widgetDragDropEvent : function() {
3069 print("WIDGET DRAGDROP");
3072 widgetPressEvent : function(w,e,u,d) {
3073 if (this.get('view').pressed) {
3076 this.get('view').pressed = true;
3077 print("WIDGET PRESS " + d.xtreepath );
3078 this.get('/LeftTree.view').selectNode( d.xtreepath );
3081 widgetReleaseEvent : function() {
3082 this.get('view').pressed = false;
3085 redraw : function() {
3086 this.highlightWidget = false;
3087 print("REDRAW CALLED");
3088 this.activePath = this.get('/LeftTree').getActivePath();
3089 if (this.renderedEl) {
3090 print("QUEUE DRAW CALLING");
3091 this.renderedEl.queue_draw();
3097 pack : "pack_start,false,true,0",
3101 pack : "pack_start,false,false,0",
3102 label : "Run The Application",
3104 "button_press_event":function (self, event) {
3105 // call render on left tree - with special option!?!
3107 //print("GET PROEJCT");
3108 var pr = this.get('/LeftProjectTree').getActiveProject();
3111 for (var i in pr.paths) {
3115 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
3116 this.get('/Terminal').feed("RUN DIR:" + dir);
3118 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
3119 , false,false,false);
3120 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
3121 this.get('/Terminal').el.feed_child(cmd, cmd.length);
3131 xtype: Gtk.ScrolledWindow,
3134 shadow_type : Gtk.ShadowType.IN,
3136 XObject.prototype.init.call(this);
3137 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3141 xtype: Gtk.EventBox,
3142 pack : "add_with_viewport",
3144 XObject.prototype.init.call(this);
3145 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
3146 red: 0x9F00, green: 0xB800 , blue : 0xA800
3154 XObject.prototype.init.call(this);
3155 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
3156 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
3161 xtype: Gtk.EventBox,
3164 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
3165 XObject.prototype.init.call(this);
3169 this.el, /* widget that will accept a drop */
3170 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
3171 null, /* lists of target to support */
3172 0, /* size of list */
3173 Gdk.DragAction.COPY /* what to do with data after dropped */
3176 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
3177 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
3180 getActiveNode : function(x,y)
3182 // workout what node is here..
3183 return '0'; // top..
3187 "drag_motion":function (self, ctx, x, y, time) {
3189 // A) find out from drag all the places that node could be dropped.
3190 var src = Gtk.drag_get_source_widget(ctx);
3191 if (!src.dropList) {
3192 Gdk.drag_status(ctx, 0, time);
3195 // b) get what we are over.. (from activeNode)
3196 // tree is empty.. - list should be correct..
3197 if (!this.get('/LeftTree.model').currentTree) {
3198 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3202 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
3203 var activeNode = this.getActiveNode(x, y);
3206 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
3209 Gdk.drag_status(ctx, 0,time);
3210 this.get('/LeftTree.view').highlight(false);
3214 // if we have a target..
3215 // -> highlight it! (in browser)
3216 // -> highlight it! (in tree)
3218 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3219 this.get('/LeftTree.view').highlight(tg);
3220 this.targetData = tg;
3221 // for tree we should handle this...
3224 "drag_drop":function (self,ctx, x, y, time) {
3225 Seed.print("TARGET: drag-drop");
3226 var is_valid_drop_site = true;
3231 self, /* will receive 'drag-data-received' signal */
3232 ctx, /* represents the current state of the this.gDnD */
3233 this.get('/Window').atoms["STRING"], /* the target type we want */
3234 time /* time stamp */
3238 /* No target offered by source => error */
3241 return is_valid_drop_site;
3244 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3246 Seed.print("GtkView: drag-data-received");
3247 var delete_selection_data = false;
3248 var dnd_success = false;
3249 /* Deal with what we are given from source */
3250 if( sel_data && sel_data.length ) {
3252 if (ctx.action == Gdk.DragAction.ASK) {
3253 /* Ask the user to move or copy, then set the ctx action. */
3256 if (ctx.action == Gdk.DragAction.MOVE) {
3257 delete_selection_data = true;
3259 var source = Gtk.drag_get_source_widget(ctx);
3261 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3262 if (this.targetData) {
3263 Seed.print(this.targetData);
3264 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3273 if (dnd_success == false)
3275 Seed.print ("DnD data transfer failed!\n");
3278 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3281 "button_press_event":function (self, event) {
3282 this.pressed = false;
3298 xtype: Gtk.ScrolledWindow,
3303 var file = this.get('/LeftTree').getActiveFile();
3307 var activeEl = this.get('/LeftTree').getActiveElement();
3308 var xtype = file.guessName( activeEl )
3309 if (!xtype || !xtype.length) {
3312 this.get('/Window.view-help-nb').el.set_current_page(1);
3314 // get the active element being edited.
3315 var helpurl = file.getHelpUrl(xtype);
3317 // now load the help info in the page..
3318 this.get('help-view').el.open(helpurl);
3322 xtype: WebKit.WebView,
3326 XObject.prototype.init.call(this);
3327 this.get('/Window.help-view').el.open(
3328 "http://devel.akbkhome.com/seed/");
3340 xtype: Gtk.Notebook,
3343 XObject.prototype.init.call(this);
3344 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3345 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3350 xtype: Gtk.ScrolledWindow,
3355 xtype: GtkSource.View,
3359 XObject.prototype.init.call(this);
3360 var description = Pango.Font.description_from_string("monospace")
3361 description.set_size(8000);
3362 this.el.modify_font(description);
3365 load : function(str) {
3367 // show the help page for the active node..
3368 this.get('/Help').show();
3371 this.get('/BottomPane').el.set_current_page(0);
3372 this.el.get_buffer().set_text(str, str.length);
3373 var lm = GtkSource.LanguageManager.get_default();
3375 this.el.get_buffer().set_language(lm.get_language('js'));
3376 var buf = this.el.get_buffer();
3377 var cursor = buf.get_mark("insert");
3378 var iter= new Gtk.TextIter;
3379 buf.get_iter_at_mark(iter, cursor);
3381 iter.set_line_offset(4);
3382 buf.move_mark(cursor, iter);
3385 cursor = buf.get_mark("selection_bound");
3386 iter= new Gtk.TextIter;
3387 buf.get_iter_at_mark(iter, cursor);
3389 iter.set_line_offset(4);
3390 buf.move_mark(cursor, iter);
3392 this.el.grab_focus();
3394 insert_spaces_instead_of_tabs : true,
3397 show_line_numbers : true,
3400 xtype: GtkSource.Buffer,
3401 pack : "set_buffer",
3403 "changed":function (self) {
3404 var s = new Gtk.TextIter();
3405 var e = new Gtk.TextIter();
3406 this.el.get_start_iter(s);
3407 this.el.get_end_iter(e);
3408 var str = this.el.get_text(s,e,true);
3410 Seed.check_syntax('var e = ' + str);
3412 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3413 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3415 print("SYNTAX ERROR IN EDITOR");
3420 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3421 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3424 this.get('/LeftPanel.model').changed( str , false);
3433 xtype: Gtk.ScrolledWindow,
3437 xtype: Vte.Terminal,
3440 feed : function(istr) {
3441 var str = istr.replace(/\n/g, "\r\n") + "\r\n";
3442 // we should make ourselves visable!!!
3443 this.get('/BottomPane').el.show();
3444 this.get('/BottomPane').el.set_current_page(1);
3446 this.el.feed(str ,str.length);
3448 scroll_on_output : true,
3450 XObject.prototype.init.call(this);
3451 this.el.set_size (80, 1000);
3453 scrollback_lines : 1000
3463 pack : "pack_start,false,false",
3467 this.get('buttonbar').el.show();
3468 this.get('viewbox').el.hide();
3469 print("TRIED TO HIDE");
3472 this.get('buttonbar').el.hide();
3473 this.get('viewbox').el.show();
3474 // this.get('model').expanded();
3486 pack : "pack_start,false,true",
3488 "clicked":function (self) {
3489 this.get('/RightPalete').show();
3496 stock : Gtk.STOCK_GOTO_FIRST,
3497 icon_size : Gtk.IconSize.MENU
3507 XObject.prototype.init.call(this);
3508 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3511 "enter_notify_event":function (self, event) {
3512 this.get('/RightPalete').show();
3526 pack : "pack_start,false,true",
3535 pack : "pack_start,false,true",
3537 "clicked":function (self) {
3538 this.get('/RightPalete').hide();
3545 stock : Gtk.STOCK_GOTO_LAST,
3546 icon_size : Gtk.IconSize.MENU
3553 xtype: Gtk.ScrolledWindow,
3556 XObject.prototype.init.call(this);
3557 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3558 this.el.set_size_request(-1,200);
3560 shadow_type : Gtk.ShadowType.IN,
3563 xtype: Gtk.TreeView,
3566 XObject.prototype.init.call(this);
3567 this.el.set_size_request(150,-1);
3568 // set_reorderable: [1]
3570 var description = new Pango.FontDescription.c_new();
3571 description.set_size(8000);
3572 this.el.modify_font(description);
3574 this.selection = this.el.get_selection();
3575 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3576 // this.selection.signal['changed'].connect(function() {
3577 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3579 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3581 Gtk.drag_source_set (
3582 this.el, /* widget will be drag-able */
3583 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3584 null, /* lists of target to support */
3585 0, /* size of list */
3586 Gdk.DragAction.COPY /* what to do with data after dropped */
3588 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3590 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3591 Gtk.drag_source_add_text_targets(this.el);
3593 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3594 targets = new Gtk.TargetList();
3595 targets.add( LeftTree.atoms["STRING"], 0, 0);
3596 targets.add_text_targets( 1 );
3597 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3599 //if you want to allow text to be output elsewhere..
3600 //Gtk.drag_source_add_text_targets(this.el);
3604 headers_visible : false,
3605 enable_tree_lines : true,
3607 "drag_begin":function (self, ctx) {
3608 // we could fill this in now...
3609 Seed.print('SOURCE: drag-begin');
3613 var iter = new Gtk.TreeIter();
3614 var s = this.selection;
3615 s.get_selected(this.get('/RightPalete.model').el, iter);
3616 var path = this.get('/RightPalete.model').el.get_path(iter);
3618 var pix = this.el.create_row_drag_icon ( path);
3621 Gtk.drag_set_icon_pixmap (ctx,
3628 var value = new GObject.Value('');
3629 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3630 if (!this.get('/RightPalete').provider) {
3633 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3634 this.el.dragData = value.value;
3641 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3642 //Seed.print('Palete: drag-data-get: ' + target_type);
3643 if (this.el.dragData && this.el.dragData.length ) {
3644 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3648 //this.el.dragData = "TEST from source widget";
3652 "drag_end":function (self, drag_context) {
3653 Seed.print('SOURCE: drag-end');
3654 this.el.dragData = false;
3655 this.el.dropList = false;
3656 this.get('/LeftTree.view').highlight(false);
3662 xtype: Gtk.ListStore,
3665 XObject.prototype.init.call(this);
3666 this.el.set_column_types ( 2, [
3667 GObject.TYPE_STRING, // title
3668 GObject.TYPE_STRING // tip
3673 load : function(tr,iter)
3678 //console.log('Project tree load: ' + tr.length);
3679 var citer = new Gtk.TreeIter();
3680 //this.insert(citer,iter,0);
3681 for(var i =0 ; i < tr.length; i++) {
3684 this.el.append(citer);
3686 this.el.insert(citer,iter,-1);
3691 this.el.set_value(citer, 0, '' + r ); // title
3693 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3694 //if (r.cn && r.cn.length) {
3695 // this.load(r.cn, citer);
3701 getValue : function (iter, col) {
3702 var gval = new GObject.Value('');
3703 this.el.get_value(iter, col ,gval);
3710 xtype: Gtk.TreeViewColumn,
3711 pack : "append_column",
3713 XObject.prototype.init.call(this);
3714 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3718 xtype: Gtk.CellRendererText,
3740 XObject.cache['/Window'] = Window;