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()) {
2059 return parseFloat(val); // Nan ?? invalid!!?
2061 return val == 'true' ? true : false;
2067 editSelected : function(e) {
2068 print("EDIT SELECTED?");
2069 var iter = new Gtk.TreeIter();
2070 var s = this.get('/LeftPanel.view').selection;
2071 s.get_selected(this.get('/LeftPanel.model').el, iter);
2072 var m = this.get('/LeftPanel.model')
2074 var gval = new GObject.Value('');
2075 this.el.get_value(iter, 0 ,gval);
2076 var val = '' + gval.value;
2078 gval = new GObject.Value('');
2079 this.el.get_value(iter, 1 ,gval);
2080 var rval = gval.value;
2081 var activePath = this.el.get_path(iter).to_string();
2082 this.activePath = activePath ;
2083 // was activeIter...
2086 var showEditor = false;
2088 if (val[0] == '!') {
2091 if (val[0] == '|') {
2092 if (rval.match(/function/g) || rval.match(/\n/g)) {
2099 this.activePath = false;
2100 GLib.timeout_add(0, 1, function() {
2101 // Gdk.threads_enter();
2102 _this.get('/BottomPane').el.show();
2103 _this.get('/RightEditor').el.show();
2104 _this.get('/RightEditor.view').load( rval );
2108 _this.activePath = activePath ;
2110 // Gdk.threads_leave();
2115 this.get('/BottomPane').el.hide();
2116 this.get('/RightEditor').el.hide();
2118 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2124 xtype: Gtk.TreeViewColumn,
2125 pack : "append_column",
2127 XObject.prototype.init.call(this);
2129 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2130 this.get('/LeftPanel').propertyColumn = this;
2135 xtype: Gtk.CellRendererText,
2136 pack : "pack_start",
2138 "editing_started":function (self, editable, path) {
2140 this.get('/LeftPanel.model').activePath = path;
2143 "edited":function (self, object, p0) {
2144 var model = this.get('/LeftPanel.model');
2145 var path = model.activePath;
2146 var iter = new Gtk.TreeIter();
2147 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2148 model.el.set_value(iter, 0, p0);
2149 model.el.set_value(iter, 2, p0);
2151 model.activePath = false;
2153 this.get('/LeftTree.model').changed(model.toJS(), true);
2154 this.el.editable = false;
2161 xtype: Gtk.TreeViewColumn,
2162 pack : "append_column",
2164 XObject.prototype.init.call(this);
2165 this.el.add_attribute(this.items[0].el , 'text', 3 );
2166 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2167 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2168 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2170 this.get('/LeftPanel').editableColumn= this;
2172 setOptions : function(ar) {
2173 var m = this.items[0].el.model;
2175 var iter = new Gtk.TreeIter();
2176 ar.forEach(function(i) {
2179 m.set_value(iter, 0, i);
2185 xtype: Gtk.CellRendererCombo,
2186 pack : "pack_start",
2191 XObject.prototype.init.call(this);
2192 this.el.model = new Gtk.ListStore();
2193 this.el.model.set_column_types ( 1, [
2194 GObject.TYPE_STRING // 0 real key
2198 "edited":function (self, object, p0) {
2199 this.get('/LeftPanel').editing = false;
2200 print("EDITED? p:" + p0 + " t:" + p0);
2201 this.get('/LeftPanel.model').changed(p0, true);
2202 this.get('/LeftPanel.model').activePath = false;
2204 "editing_started":function (self, editable, path) {
2205 this.get('/LeftPanel').editing = true;
2206 // console.log('editing started');
2207 // r.has_entry = false;
2208 this.get('/LeftPanel.model').editSelected(editable);
2219 id : "LeftPanelPopup",
2222 xtype: Gtk.MenuItem,
2226 "activate":function (self) {
2227 this.get('/LeftPanel.model').deleteSelected();
2232 xtype: Gtk.MenuItem,
2236 "activate":function (self) {
2237 this.get('/LeftPanel.model').startEditing(false, 0);
2250 xtype: Gtk.ScrolledWindow,
2251 pack : "pack_end,false,true,0",
2253 shadow_type : Gtk.ShadowType.IN,
2255 XObject.prototype.init.call(this);
2256 XObject.prototype.init.call(this);
2257 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2258 this.el.set_size_request ( 150, -1 );
2261 activeElement : false,
2262 hideWin : function() {
2269 if (this.get('/Window.left').el.position < 160) {
2272 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2279 xtype: Gtk.TreeView,
2280 enable_tree_lines : true,
2281 headers_visible : false,
2284 XObject.prototype.init.call(this);
2286 var description = new Pango.FontDescription.c_new();
2287 description.set_size(8000);
2288 this.el.modify_font(description);
2290 //this.selection = this.el.get_selection();
2291 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2300 "cursor_changed":function (self) {
2301 var iter = new Gtk.TreeIter();
2303 //console.log('changed');
2304 var m = this.get('model');
2305 if (!this.selection){
2306 this.selection = this.el.get_selection();
2309 var s = this.selection;
2310 if (!s.get_selected(m.el, iter)) {
2313 var tp = m.el.get_path(iter).to_string();
2318 var key = m.getValue(tp, 0);
2320 var type = m.getValue(tp, 1);
2321 var skel = m.getValue(tp, 3);
2322 var etype = m.getValue(tp, 5);
2325 this.get('/MidPropTree').hideWin();
2327 if (type == 'function') {
2329 if (etype != 'events') {
2333 this.get('/LeftPanel.model').add({
2342 if (type.indexOf('.') > -1 ||
2343 type == 'boolean') {
2347 this.get('/LeftPanel.model').add( {
2357 xtype: Gtk.ListStore,
2360 XObject.prototype.init.call(this);
2361 this.el.set_column_types ( 6, [
2362 GObject.TYPE_STRING, // real key
2363 GObject.TYPE_STRING, // real type
2364 GObject.TYPE_STRING, // docs ?
2365 GObject.TYPE_STRING, // visable desc
2366 GObject.TYPE_STRING, // function desc
2367 GObject.TYPE_STRING // element type (event|prop)
2371 getValue : function(treepath, col)
2373 var tp = new Gtk.TreePath.from_string (treepath);
2374 var iter = new Gtk.TreeIter();
2375 this.el.get_iter (iter, tp);
2376 var value = new GObject.Value('');
2377 this.el.get_value(iter, col, value);
2381 showData : function(type) {
2383 if (!this.get('/MidPropTree').activeElement || !type) {
2384 return; // no active element
2387 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2388 var palete = this.get('/LeftTree').getPaleteProvider();
2392 Seed.print('Showing right?');
2393 if (!this.get('/MidPropTree').shown) {
2395 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2396 this.get('/MidPropTree').el.show();
2397 this.get('/MidPropTree').shown = true;
2400 var elementList = palete.getPropertiesFor(fullpath, type);
2401 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2402 // console.dump(elementList);
2405 var iter = new Gtk.TreeIter();
2406 for(var i =0 ; i < elementList.length; i++) {
2407 var p=elementList[i];
2408 this.el.append(iter);
2409 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2410 //GObject.TYPE_STRING, // real key
2411 // GObject.TYPE_STRING, // real type
2412 // GObject.TYPE_STRING, // docs ?
2413 // GObject.TYPE_STRING // func def?
2416 this.el.set_value(iter, 0, p.name);
2417 this.el.set_value(iter, 1, p.type);
2418 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2419 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2420 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2421 this.el.set_value(iter, 5, type);
2429 xtype: Gtk.TreeViewColumn,
2431 this.el = new Gtk.TreeViewColumn();
2432 this.parent.el.append_column(this.el);
2434 XObject.prototype.init.call(this);
2435 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2440 xtype: Gtk.CellRendererText,
2441 pack : "pack_start,true"
2465 xtype: Gtk.Notebook,
2466 pack : "pack_start,true,true",
2467 id : "view-help-nb",
2469 XObject.prototype.init.call(this);
2470 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" }));
2471 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" }));
2475 xtype: Gtk.Notebook,
2477 id : "view-notebook",
2480 XObject.prototype.init.call(this);
2481 this.el.set_current_page(0);
2483 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2484 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2491 id : "RightBrowser",
2498 pack : "pack_start,false,true,0",
2502 pack : "pack_start,false,false,0",
2503 label : "Dump HTML to console",
2505 "activate":function (self) {
2506 this.get('/RightBrowser.view').el.execute_script(
2507 "console.log(document.body.innerHTML);");
2508 this.get('/RightBrowser.view').el.execute_script(
2509 "console.log(Builder.dump(Builder));");
2516 label : "Set Default Javascript",
2518 "button_press_event":function (self, event) {
2519 this.get('/RooProjectProperties').show();
2527 xtype: Gtk.ScrolledWindow,
2529 shadow_type : Gtk.ShadowType.IN,
2531 XObject.prototype.init.call(this);
2532 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2536 xtype: WebKit.WebView,
2540 XObject.prototype.init.call(this);
2541 // this may not work!?
2542 this.el.open('file:///' + __script_path__ + '/../builder.html');
2546 this.el, /* widget that will accept a drop */
2547 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2548 null, /* lists of target to support */
2549 0, /* size of list */
2550 Gdk.DragAction.COPY /* what to do with data after dropped */
2553 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2554 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2556 renderJS : function(data) {
2557 print("HTML RENDERING");
2558 /// prevent looping..
2559 //if (this.pendingRedraw) {
2560 // print("pending redraw active?!");
2565 if (!this.get('/Window.LeftTree').getActiveFile()) {
2569 var project = this.get('/Window.LeftTree').getActiveFile().project;
2570 //print (project.fn);
2572 project.runhtml = project.runhtml || '';
2575 this.runhtml = this.runhtml || '';
2577 if (project.runhtml != this.runhtml) {
2578 // then we need to reload the browser using
2579 // load_html_string..
2581 // then trigger a redraw once it's loaded..
2582 this.pendingRedraw = true;
2584 this.runhtml = project.runhtml;
2586 var html = imports.File.File.read(__script_path__ + '/../builder.html');
2587 html = html.replace('</head>', this.runhtml + '</head>');
2588 print("LOAD HTML " + html);
2589 this.el.load_html_string( html , 'file:///' + __script_path__ + '/../builder.html');
2590 // should trigger load_finished!
2595 this.pendingRedraw = false;
2598 this.renderedData = data;
2599 var str = JSON.stringify(data) ;
2602 console.log('not loaded yet');
2604 //Seed.print("RENDER:" + str);
2605 //imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2607 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2610 "load_finished":function (self, object) {
2611 // if (this.ready) { // dont do it twice!
2615 this.pendingRedraw = false;
2616 var js = this.get('/LeftTree.model').toJS();
2618 this.renderJS(js[0]);
2622 "script_alert":function (self, object, p0) {
2625 return true; // do not display anything...
2627 "console_message":function (self, object, p0, p1) {
2628 console.log(object);
2629 if (!object.match(/^\{/)) {
2630 return false; // do not handle!!! -> later maybe in console..
2632 console.log(object);
2633 var val = JSON.parse(object);
2635 if (typeof(val['hover-node']) != 'undefined') {
2636 this.activeNode = val['hover-node'];
2637 console.log('active node: ' + this.activeNode);
2642 if (typeof(val['id']) != 'undefined') {
2643 // this.activeNode = val['id'];
2644 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2648 this.get('/LeftTree.view').selectNode(tg[0]);
2652 if (ret && typeof(val['set']) != 'undefined') {
2653 this.get('/LeftPanel.model').add({
2657 //console.log('active node: ' + this.activeNode);
2660 //Seed.print('a:'+a);
2661 //Seed.print('b:'+b);
2662 //Seed.print('c:'+c);
2665 "drag_motion":function (w, ctx, x, y, time, ud) {
2666 // console.log('DRAG MOTION');
2668 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2669 this.targetData = [];
2670 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2672 // A) find out from drag all the places that node could be dropped.
2673 var src = Gtk.drag_get_source_widget(ctx);
2674 if (!src.dropList) {
2675 Gdk.drag_status(ctx, 0, time);
2678 // b) get what we are over.. (from activeNode)
2679 // tree is empty.. - list should be correct..
2680 if (!this.get('/LeftTree.model').currentTree) {
2681 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2685 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2687 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2690 Gdk.drag_status(ctx, 0,time);
2691 this.get('/LeftTree.view').highlight(false);
2695 // if we have a target..
2696 // -> highlight it! (in browser)
2697 // -> highlight it! (in tree)
2699 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2700 this.get('/LeftTree.view').highlight(tg);
2701 this.targetData = tg;
2702 // for tree we should handle this...
2705 "drag_drop":function (w, ctx, x, y,time, ud) {
2706 print("TARGET: drag-drop");
2707 var is_valid_drop_site = true;
2712 w, /* will receive 'drag-data-received' signal */
2713 ctx, /* represents the current state of the DnD */
2714 this.get('/Window').atoms["STRING"], /* the target type we want */
2715 time /* time stamp */
2719 /* No target offered by source => error */
2722 return is_valid_drop_site;
2724 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2726 print("Browser: drag-data-received");
2727 var delete_selection_data = false;
2728 vardnd_success = false;
2729 /* Deal with what we are given from source */
2730 if( sel_data && sel_data.length ) {
2732 if (ctx.action == Gdk.DragAction.ASK) {
2733 /* Ask the user to move or copy, then set the ctx action. */
2736 if (ctx.action == Gdk.DragAction.MOVE) {
2737 delete_selection_data = true;
2739 var source = Gtk.drag_get_source_widget(ctx);
2741 print("Browser: source.DRAGDATA? " + source.dragData);
2742 if (this.targetData) {
2743 print(this.targetData);
2744 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2753 if (dnd_success == false)
2755 Seed.print ("DnD data transfer failed!\n");
2758 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2770 id : "RightGtkView",
2771 renderJS : function(data, withDebug)
2773 this.highlightWidget = false;
2777 this.withDebug = false;
2779 if (this.renderedEl) {
2780 this.get('view').el.remove(this.renderedEl);
2781 this.renderedEl.destroy();
2782 this.renderedEl = false;
2785 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2786 // in theory tree is actually window..
2788 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2793 this.get('view').el.set_size_request(
2794 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2797 this.renderedEl.set_size_request(
2798 tree.default_width || 600,
2799 tree.default_height || 400
2801 this.get('view').el.show_all();
2806 showInWindow : function() {
2807 print("GET PROEJCT");
2808 var pr = this.get('/LeftProjectTree').getActiveProject();
2810 console.log(pr.paths);
2813 var src= this.buildJS(
2814 this.get('/LeftTree.model').toJS()[0],
2819 //var x = new imports.sandbox.Context();
2823 Seed.check_syntax('var e = ' + src);
2826 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2827 this.get('/Terminal').feed(console._dump(e)+"\n");
2829 var lines = src.split("\n");
2830 var start = Math.max(0, e.line - 10);
2831 var end = Math.min(lines.length, e.line + 10);
2832 for (var i =start ; i < end; i++) {
2834 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2837 this.get('/Terminal').feed(lines[i] + "\n");
2844 this.get('/BottomPane').el.set_current_page(1);
2845 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2846 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2847 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2849 var _top = x.get_global_object()._top;
2851 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2853 if (_top.el.popup) {
2854 _top.el.popup(null, null, null, null, 3, null);
2858 viewAdd : function(item, par)
2860 // does something similar to xobject..
2861 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2863 if (item.pack===false || item.pack === 'false') { // no ;
2866 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2867 var ns = imports.gi[item['|xns']];
2868 var ctr = ns[item['xtype']];
2870 for(var k in item) {
2872 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2887 if (k[0] == '|' && typeof(kv) == 'string') {
2889 if (kv.match(new RegExp('function'))) {
2892 print("WASL " + k + '=' + kv);
2894 eval( 'kv = ' + kv);
2895 } catch(e) { continue; }
2898 // print(k + '=' + kv);
2900 if (k[0] == '|') { // should be boolean or number..
2902 //print(k + '=' + kv);
2905 if (k == 'show_tabs') { // force tab showing for notebooks.
2908 print(k + '=' + typeof(kv) + " : " + kv);
2914 var el = new ctr(ctr_args);
2917 //console.dump(item.pack);
2924 if (typeof(item.pack) == 'string') {
2926 item.pack.split(',').forEach(function(e, i) {
2928 if (e == 'false') { args.push( false); return; }
2929 if (e == 'true') { args.push( true); return; }
2930 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2933 //print(args.join(","));
2935 pack_m = args.shift();
2937 pack_m = item.pack.shift();
2942 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2944 name: "ArgumentError",
2945 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2946 "ADDING : " + item.id + " " + el
2955 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2956 //Seed.print('args: ' + args.length);
2958 par[pack_m].apply(par, args);
2962 item.items = item.items || [];
2963 item.items.forEach(function(ch) {
2964 _this.viewAdd(ch, el);
2969 // add the signal handlers.
2970 // is it a widget!?!!?
2976 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2977 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2978 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2979 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2980 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2990 widgetExposeEvent : function(w, evt, ud, item) {
2992 if (this.inRender) {
2996 if ( this.highlightWidget) {
2997 this.inRender = true;
2998 if (item.xtreepath.substring(0, this.activePath.length) == this.activePath) {
2999 Gdk.draw_rectangle(this.highlightWidget.window, this.gc, false, this.box.x , this.box.y, this.box.w, this.box.h);
3001 this.inRender = false;
3006 if (this.activePath != item.xtreepath) {
3010 // print("HIGHLIGHT: " + item.xtreepath ); // draw highlight??
3011 // work out the coords of the window..
3013 var dr = widget.window;
3014 this.gc = (new Gdk.GC.c_new(dr));
3015 this.gc.set_rgb_fg_color(new Gdk.Color({ red: 0xFFFF, green: 0, blue : 0 }));
3016 this.gc.set_line_attributes(4, Gdk.LineStyle.SOLID, Gdk.CapStyle.ROUND , Gdk.JoinStyle.ROUND);
3020 var r = evt.expose.area;
3021 // console.dump([r.x, r.y, r.width, r.height ] );
3023 // print(widget.get_parent().toString().match(/GtkScrolledWindow/);
3024 if (widget.get_parent().toString().match(/GtkScrolledWindow/)) { // eak
3025 // happens with gtkscrollview embedded stuff..
3026 var np =this.activePath.split(':');
3028 this.activePath = np.join(':');
3029 this.renderedEl.queue_draw();
3045 this.inRender = true;
3048 this.highlightWidget = widget;
3053 // print("DRAW BOX");
3054 //console.dump(this.box);
3055 Gdk.draw_rectangle(widget.window, this.gc, false, this.box.x , this.box.y, this.box.w,this.box.h);
3056 this.inRender = false;
3059 widgetDragMotionEvent : function() {
3060 print("WIDGET DRAGMOTION");
3063 widgetDragDropEvent : function() {
3064 print("WIDGET DRAGDROP");
3067 widgetPressEvent : function(w,e,u,d) {
3068 if (this.get('view').pressed) {
3071 this.get('view').pressed = true;
3072 print("WIDGET PRESS " + d.xtreepath );
3073 this.get('/LeftTree.view').selectNode( d.xtreepath );
3076 widgetReleaseEvent : function() {
3077 this.get('view').pressed = false;
3080 redraw : function() {
3081 this.highlightWidget = false;
3082 print("REDRAW CALLED");
3083 this.activePath = this.get('/LeftTree').getActivePath();
3084 if (this.renderedEl) {
3085 print("QUEUE DRAW CALLING");
3086 this.renderedEl.queue_draw();
3092 pack : "pack_start,false,true,0",
3096 pack : "pack_start,false,false,0",
3097 label : "Run The Application",
3099 "button_press_event":function (self, event) {
3100 // call render on left tree - with special option!?!
3104 print("GET PROEJCT");
3105 var pr = this.get('/LeftProjectTree').getActiveProject();
3108 for (var i in pr.paths) {
3112 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
3113 print ("RUN DIR:" + dir);
3114 this.get('/BottomPane').el.show();
3115 this.get('/BottomPane').el.set_current_page(1);
3116 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
3117 , false,false,false);
3118 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
3119 this.get('/Terminal').el.feed_child(cmd, cmd.length);
3129 xtype: Gtk.ScrolledWindow,
3132 shadow_type : Gtk.ShadowType.IN,
3134 XObject.prototype.init.call(this);
3135 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3139 xtype: Gtk.EventBox,
3140 pack : "add_with_viewport",
3142 XObject.prototype.init.call(this);
3143 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
3144 red: 0x9F00, green: 0xB800 , blue : 0xA800
3152 XObject.prototype.init.call(this);
3153 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
3154 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
3159 xtype: Gtk.EventBox,
3162 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
3163 XObject.prototype.init.call(this);
3167 this.el, /* widget that will accept a drop */
3168 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
3169 null, /* lists of target to support */
3170 0, /* size of list */
3171 Gdk.DragAction.COPY /* what to do with data after dropped */
3174 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
3175 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
3178 getActiveNode : function(x,y)
3180 // workout what node is here..
3181 return '0'; // top..
3185 "drag_motion":function (self, ctx, x, y, time) {
3187 // A) find out from drag all the places that node could be dropped.
3188 var src = Gtk.drag_get_source_widget(ctx);
3189 if (!src.dropList) {
3190 Gdk.drag_status(ctx, 0, time);
3193 // b) get what we are over.. (from activeNode)
3194 // tree is empty.. - list should be correct..
3195 if (!this.get('/LeftTree.model').currentTree) {
3196 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3200 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
3201 var activeNode = this.getActiveNode(x, y);
3204 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
3207 Gdk.drag_status(ctx, 0,time);
3208 this.get('/LeftTree.view').highlight(false);
3212 // if we have a target..
3213 // -> highlight it! (in browser)
3214 // -> highlight it! (in tree)
3216 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3217 this.get('/LeftTree.view').highlight(tg);
3218 this.targetData = tg;
3219 // for tree we should handle this...
3222 "drag_drop":function (self,ctx, x, y, time) {
3223 Seed.print("TARGET: drag-drop");
3224 var is_valid_drop_site = true;
3229 self, /* will receive 'drag-data-received' signal */
3230 ctx, /* represents the current state of the this.gDnD */
3231 this.get('/Window').atoms["STRING"], /* the target type we want */
3232 time /* time stamp */
3236 /* No target offered by source => error */
3239 return is_valid_drop_site;
3242 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3244 Seed.print("GtkView: drag-data-received");
3245 var delete_selection_data = false;
3246 var dnd_success = false;
3247 /* Deal with what we are given from source */
3248 if( sel_data && sel_data.length ) {
3250 if (ctx.action == Gdk.DragAction.ASK) {
3251 /* Ask the user to move or copy, then set the ctx action. */
3254 if (ctx.action == Gdk.DragAction.MOVE) {
3255 delete_selection_data = true;
3257 var source = Gtk.drag_get_source_widget(ctx);
3259 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3260 if (this.targetData) {
3261 Seed.print(this.targetData);
3262 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3271 if (dnd_success == false)
3273 Seed.print ("DnD data transfer failed!\n");
3276 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3279 "button_press_event":function (self, event) {
3280 this.pressed = false;
3296 xtype: Gtk.ScrolledWindow,
3301 var file = this.get('/LeftTree').getActiveFile();
3305 var activeEl = this.get('/LeftTree').getActiveElement();
3306 var xtype = file.guessName( activeEl )
3307 if (!xtype || !xtype.length) {
3310 this.get('/Window.view-help-nb').el.set_current_page(1);
3312 // get the active element being edited.
3313 var helpurl = file.getHelpUrl(xtype);
3315 // now load the help info in the page..
3316 this.get('help-view').el.open(helpurl);
3320 xtype: WebKit.WebView,
3324 XObject.prototype.init.call(this);
3325 this.get('/Window.help-view').el.open(
3326 "http://devel.akbkhome.com/seed/");
3337 xtype: Gtk.Notebook,
3340 XObject.prototype.init.call(this);
3341 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3342 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3347 xtype: Gtk.ScrolledWindow,
3352 xtype: GtkSource.View,
3356 XObject.prototype.init.call(this);
3357 var description = Pango.Font.description_from_string("monospace")
3358 description.set_size(8000);
3359 this.el.modify_font(description);
3362 load : function(str) {
3364 // show the help page for the active node..
3365 this.get('/Help').show();
3368 this.get('/BottomPane').el.set_current_page(0);
3369 this.el.get_buffer().set_text(str, str.length);
3370 var lm = GtkSource.LanguageManager.get_default();
3372 this.el.get_buffer().set_language(lm.get_language('js'));
3373 var buf = this.el.get_buffer();
3374 var cursor = buf.get_mark("insert");
3375 var iter= new Gtk.TextIter;
3376 buf.get_iter_at_mark(iter, cursor);
3378 iter.set_line_offset(4);
3379 buf.move_mark(cursor, iter);
3382 cursor = buf.get_mark("selection_bound");
3383 iter= new Gtk.TextIter;
3384 buf.get_iter_at_mark(iter, cursor);
3386 iter.set_line_offset(4);
3387 buf.move_mark(cursor, iter);
3389 this.el.grab_focus();
3391 insert_spaces_instead_of_tabs : true,
3394 show_line_numbers : true,
3397 xtype: GtkSource.Buffer,
3398 pack : "set_buffer",
3400 "changed":function (self) {
3401 var s = new Gtk.TextIter();
3402 var e = new Gtk.TextIter();
3403 this.el.get_start_iter(s);
3404 this.el.get_end_iter(e);
3405 var str = this.el.get_text(s,e,true);
3407 Seed.check_syntax('var e = ' + str);
3409 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3410 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3412 print("SYNTAX ERROR IN EDITOR");
3417 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3418 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3421 this.get('/LeftPanel.model').changed( str , false);
3430 xtype: Gtk.ScrolledWindow,
3434 xtype: Vte.Terminal,
3437 feed : function(str) {
3438 this.el.feed(str,str.length);
3449 pack : "pack_start,false,false",
3453 this.get('buttonbar').el.show();
3454 this.get('viewbox').el.hide();
3455 print("TRIED TO HIDE");
3458 this.get('buttonbar').el.hide();
3459 this.get('viewbox').el.show();
3460 // this.get('model').expanded();
3472 pack : "pack_start,false,true",
3474 "clicked":function (self) {
3475 this.get('/RightPalete').show();
3482 stock : Gtk.STOCK_GOTO_FIRST,
3483 icon_size : Gtk.IconSize.MENU
3493 XObject.prototype.init.call(this);
3494 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3497 "enter_notify_event":function (self, event) {
3498 this.get('/RightPalete').show();
3512 pack : "pack_start,false,true",
3521 pack : "pack_start,false,true",
3523 "clicked":function (self) {
3524 this.get('/RightPalete').hide();
3531 stock : Gtk.STOCK_GOTO_LAST,
3532 icon_size : Gtk.IconSize.MENU
3539 xtype: Gtk.ScrolledWindow,
3542 XObject.prototype.init.call(this);
3543 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3544 this.el.set_size_request(-1,200);
3546 shadow_type : Gtk.ShadowType.IN,
3549 xtype: Gtk.TreeView,
3552 XObject.prototype.init.call(this);
3553 this.el.set_size_request(150,-1);
3554 // set_reorderable: [1]
3556 var description = new Pango.FontDescription.c_new();
3557 description.set_size(8000);
3558 this.el.modify_font(description);
3560 this.selection = this.el.get_selection();
3561 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3562 // this.selection.signal['changed'].connect(function() {
3563 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3565 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3567 Gtk.drag_source_set (
3568 this.el, /* widget will be drag-able */
3569 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3570 null, /* lists of target to support */
3571 0, /* size of list */
3572 Gdk.DragAction.COPY /* what to do with data after dropped */
3574 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3576 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3577 Gtk.drag_source_add_text_targets(this.el);
3579 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3580 targets = new Gtk.TargetList();
3581 targets.add( LeftTree.atoms["STRING"], 0, 0);
3582 targets.add_text_targets( 1 );
3583 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3585 //if you want to allow text to be output elsewhere..
3586 //Gtk.drag_source_add_text_targets(this.el);
3590 headers_visible : false,
3591 enable_tree_lines : true,
3593 "drag_begin":function (self, ctx) {
3594 // we could fill this in now...
3595 Seed.print('SOURCE: drag-begin');
3599 var iter = new Gtk.TreeIter();
3600 var s = this.selection;
3601 s.get_selected(this.get('/RightPalete.model').el, iter);
3602 var path = this.get('/RightPalete.model').el.get_path(iter);
3604 var pix = this.el.create_row_drag_icon ( path);
3607 Gtk.drag_set_icon_pixmap (ctx,
3614 var value = new GObject.Value('');
3615 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3616 if (!this.get('/RightPalete').provider) {
3619 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3620 this.el.dragData = value.value;
3627 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3628 //Seed.print('Palete: drag-data-get: ' + target_type);
3629 if (this.el.dragData && this.el.dragData.length ) {
3630 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3634 //this.el.dragData = "TEST from source widget";
3638 "drag_end":function (self, drag_context) {
3639 Seed.print('SOURCE: drag-end');
3640 this.el.dragData = false;
3641 this.el.dropList = false;
3642 this.get('/LeftTree.view').highlight(false);
3648 xtype: Gtk.ListStore,
3651 XObject.prototype.init.call(this);
3652 this.el.set_column_types ( 2, [
3653 GObject.TYPE_STRING, // title
3654 GObject.TYPE_STRING // tip
3659 load : function(tr,iter)
3664 //console.log('Project tree load: ' + tr.length);
3665 var citer = new Gtk.TreeIter();
3666 //this.insert(citer,iter,0);
3667 for(var i =0 ; i < tr.length; i++) {
3670 this.el.append(citer);
3672 this.el.insert(citer,iter,-1);
3677 this.el.set_value(citer, 0, '' + r ); // title
3679 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3680 //if (r.cn && r.cn.length) {
3681 // this.load(r.cn, citer);
3687 getValue : function (iter, col) {
3688 var gval = new GObject.Value('');
3689 this.el.get_value(iter, col ,gval);
3696 xtype: Gtk.TreeViewColumn,
3697 pack : "append_column",
3699 XObject.prototype.init.call(this);
3700 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3704 xtype: Gtk.CellRendererText,
3726 XObject.cache['/Window'] = Window;