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]);
2518 pack : "pack_start,false,false,0",
2519 label : "Set extra HTML in render",
2521 "button_press_event":function (self, event) {
2522 this.get('/RooProjectProperties').show();
2529 pack : "pack_start,false,false,0",
2530 label : "test in Firefox",
2532 "button_press_event":function (self, event)
2534 /* Firefox testing for debugging..
2535 - we can create a /tmp directory, and put.
2536 builder.html, builder.html.js, link roojs1
2537 add at the end of builder.html Roo.onload(function() {
2539 if (!this.get('/Window.LeftTree').getActiveFile()) {
2543 var js = this.get('/LeftTree.model').toJS();
2544 if (!js || !js[0]) {
2547 var project = this.get('/Window.LeftTree').getActiveFile().project;
2548 //print (project.fn);
2550 project.runhtml = project.runhtml || '';
2553 var File = imports.File.File;
2555 var target = "/tmp/firetest"; // fixme..
2556 if (!File.isDirectory(target)) {
2559 File.copy(__script_path__ + '/../builder.html.js', target+ '/builder.html.js', Gio.FileCopyFlags.OVERWRITE);
2560 if (!File.exists( target+ '/roojs1')) {
2561 File.link( target+ '/roojs1', __script_path__ + '/../roojs1');
2566 var html = imports.File.File.read(__script_path__ + '/../builder.html');
2567 html = html.replace('</head>', project.runhtml + '</head>');
2570 var jsstr = JSON.stringify(js[0]);
2572 var runbuilder = '<script type="text/javascript">' + "\n" +
2573 "Roo.onReady(function() { Builder.render(" + jsstr + "); });\n" +
2576 html = html.replace('</body>', runbuilder + '</body>');
2578 File.write( target+ '/builder.html', html);
2588 xtype: Gtk.ScrolledWindow,
2590 shadow_type : Gtk.ShadowType.IN,
2592 XObject.prototype.init.call(this);
2593 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2597 xtype: WebKit.WebView,
2601 XObject.prototype.init.call(this);
2602 // this may not work!?
2603 this.el.open('file:///' + __script_path__ + '/../builder.html');
2607 this.el, /* widget that will accept a drop */
2608 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2609 null, /* lists of target to support */
2610 0, /* size of list */
2611 Gdk.DragAction.COPY /* what to do with data after dropped */
2614 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2615 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2617 renderJS : function(data) {
2618 print("HTML RENDERING");
2619 /// prevent looping..
2620 //if (this.pendingRedraw) {
2621 // print("pending redraw active?!");
2626 if (!this.get('/Window.LeftTree').getActiveFile()) {
2630 var project = this.get('/Window.LeftTree').getActiveFile().project;
2631 //print (project.fn);
2633 project.runhtml = project.runhtml || '';
2636 this.runhtml = this.runhtml || '';
2638 if (project.runhtml != this.runhtml) {
2639 // then we need to reload the browser using
2640 // load_html_string..
2642 // then trigger a redraw once it's loaded..
2643 this.pendingRedraw = true;
2645 this.runhtml = project.runhtml;
2647 var html = imports.File.File.read(__script_path__ + '/../builder.html');
2648 html = html.replace('</head>', this.runhtml + '</head>');
2649 print("LOAD HTML " + html);
2650 this.el.load_html_string( html , 'file:///' + __script_path__ + '/../builder.html');
2651 // should trigger load_finished!
2656 this.pendingRedraw = false;
2659 this.renderedData = data;
2660 var str = JSON.stringify(data) ;
2663 console.log('not loaded yet');
2665 //Seed.print("RENDER:" + str);
2666 //imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2668 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2671 "load_finished":function (self, object) {
2672 // if (this.ready) { // dont do it twice!
2676 this.pendingRedraw = false;
2677 var js = this.get('/LeftTree.model').toJS();
2679 this.renderJS(js[0]);
2683 "script_alert":function (self, object, p0) {
2686 return true; // do not display anything...
2688 "console_message":function (self, object, p0, p1) {
2689 // console.log(object);
2690 if (!object.match(/^\{/)) {
2692 this.get('/Terminal').feed(object);
2693 return true; // do not handle!!! -> later maybe in console..
2695 // console.log(object);
2696 var val = JSON.parse(object);
2698 if (typeof(val['hover-node']) != 'undefined') {
2699 this.activeNode = val['hover-node'];
2700 console.log('active node: ' + this.activeNode);
2705 if (typeof(val['id']) != 'undefined') {
2706 // this.activeNode = val['id'];
2707 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2711 this.get('/LeftTree.view').selectNode(tg[0]);
2715 if (ret && typeof(val['set']) != 'undefined') {
2716 this.get('/LeftPanel.model').add({
2720 //console.log('active node: ' + this.activeNode);
2723 //Seed.print('a:'+a);
2724 //Seed.print('b:'+b);
2725 //Seed.print('c:'+c);
2728 "drag_motion":function (w, ctx, x, y, time, ud) {
2729 // console.log('DRAG MOTION');
2731 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2732 this.targetData = [];
2733 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2735 // A) find out from drag all the places that node could be dropped.
2736 var src = Gtk.drag_get_source_widget(ctx);
2737 if (!src.dropList) {
2738 Gdk.drag_status(ctx, 0, time);
2741 // b) get what we are over.. (from activeNode)
2742 // tree is empty.. - list should be correct..
2743 if (!this.get('/LeftTree.model').currentTree) {
2744 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2748 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2750 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2753 Gdk.drag_status(ctx, 0,time);
2754 this.get('/LeftTree.view').highlight(false);
2758 // if we have a target..
2759 // -> highlight it! (in browser)
2760 // -> highlight it! (in tree)
2762 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2763 this.get('/LeftTree.view').highlight(tg);
2764 this.targetData = tg;
2765 // for tree we should handle this...
2768 "drag_drop":function (w, ctx, x, y,time, ud) {
2769 print("TARGET: drag-drop");
2770 var is_valid_drop_site = true;
2775 w, /* will receive 'drag-data-received' signal */
2776 ctx, /* represents the current state of the DnD */
2777 this.get('/Window').atoms["STRING"], /* the target type we want */
2778 time /* time stamp */
2782 /* No target offered by source => error */
2785 return is_valid_drop_site;
2787 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2789 print("Browser: drag-data-received");
2790 var delete_selection_data = false;
2791 vardnd_success = false;
2792 /* Deal with what we are given from source */
2793 if( sel_data && sel_data.length ) {
2795 if (ctx.action == Gdk.DragAction.ASK) {
2796 /* Ask the user to move or copy, then set the ctx action. */
2799 if (ctx.action == Gdk.DragAction.MOVE) {
2800 delete_selection_data = true;
2802 var source = Gtk.drag_get_source_widget(ctx);
2804 print("Browser: source.DRAGDATA? " + source.dragData);
2805 if (this.targetData) {
2806 print(this.targetData);
2807 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2816 if (dnd_success == false)
2818 Seed.print ("DnD data transfer failed!\n");
2821 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2833 id : "RightGtkView",
2834 renderJS : function(data, withDebug)
2836 this.highlightWidget = false;
2840 this.withDebug = false;
2842 if (this.renderedEl) {
2843 this.get('view').el.remove(this.renderedEl);
2844 this.renderedEl.destroy();
2845 this.renderedEl = false;
2848 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2849 // in theory tree is actually window..
2851 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2856 this.get('view').el.set_size_request(
2857 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2860 this.renderedEl.set_size_request(
2861 tree.default_width || 600,
2862 tree.default_height || 400
2864 this.get('view').el.show_all();
2869 showInWindow : function() {
2870 print("GET PROEJCT");
2871 var pr = this.get('/LeftProjectTree').getActiveProject();
2873 console.log(pr.paths);
2876 var src= this.buildJS(
2877 this.get('/LeftTree.model').toJS()[0],
2882 //var x = new imports.sandbox.Context();
2886 Seed.check_syntax('var e = ' + src);
2889 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2890 this.get('/Terminal').feed(console._dump(e)+"\n");
2892 var lines = src.split("\n");
2893 var start = Math.max(0, e.line - 10);
2894 var end = Math.min(lines.length, e.line + 10);
2895 for (var i =start ; i < end; i++) {
2897 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2900 this.get('/Terminal').feed(lines[i] + "\n");
2907 this.get('/BottomPane').el.set_current_page(1);
2908 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2909 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2910 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2912 var _top = x.get_global_object()._top;
2914 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2916 if (_top.el.popup) {
2917 _top.el.popup(null, null, null, null, 3, null);
2921 viewAdd : function(item, par)
2923 // does something similar to xobject..
2924 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2926 if (item.pack===false || item.pack === 'false') { // no ;
2929 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2930 var ns = imports.gi[item['|xns']];
2931 var ctr = ns[item['xtype']];
2933 for(var k in item) {
2935 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2950 if (k[0] == '|' && typeof(kv) == 'string') {
2952 if (kv.match(new RegExp('function'))) {
2955 print("WASL " + k + '=' + kv);
2957 eval( 'kv = ' + kv);
2958 } catch(e) { continue; }
2961 // print(k + '=' + kv);
2963 if (k[0] == '|') { // should be boolean or number..
2965 //print(k + '=' + kv);
2968 if (k == 'show_tabs') { // force tab showing for notebooks.
2971 print(k + '=' + typeof(kv) + " : " + kv);
2977 var el = new ctr(ctr_args);
2980 //console.dump(item.pack);
2987 if (typeof(item.pack) == 'string') {
2989 item.pack.split(',').forEach(function(e, i) {
2991 if (e == 'false') { args.push( false); return; }
2992 if (e == 'true') { args.push( true); return; }
2993 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2996 //print(args.join(","));
2998 pack_m = args.shift();
3000 pack_m = item.pack.shift();
3005 if (pack_m && typeof(par[pack_m]) == 'undefined') {
3007 name: "ArgumentError",
3008 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
3009 "ADDING : " + item.id + " " + el
3018 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
3019 //Seed.print('args: ' + args.length);
3021 par[pack_m].apply(par, args);
3025 item.items = item.items || [];
3026 item.items.forEach(function(ch) {
3027 _this.viewAdd(ch, el);
3032 // add the signal handlers.
3033 // is it a widget!?!!?
3039 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
3040 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
3041 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
3042 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
3043 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
3053 widgetExposeEvent : function(w, evt, ud, item) {
3055 if (this.inRender) {
3059 if ( this.highlightWidget) {
3060 this.inRender = true;
3061 if (item.xtreepath.substring(0, this.activePath.length) == this.activePath) {
3062 Gdk.draw_rectangle(this.highlightWidget.window, this.gc, false, this.box.x , this.box.y, this.box.w, this.box.h);
3064 this.inRender = false;
3069 if (this.activePath != item.xtreepath) {
3073 // print("HIGHLIGHT: " + item.xtreepath ); // draw highlight??
3074 // work out the coords of the window..
3076 var dr = widget.window;
3077 this.gc = (new Gdk.GC.c_new(dr));
3078 this.gc.set_rgb_fg_color(new Gdk.Color({ red: 0xFFFF, green: 0, blue : 0 }));
3079 this.gc.set_line_attributes(4, Gdk.LineStyle.SOLID, Gdk.CapStyle.ROUND , Gdk.JoinStyle.ROUND);
3083 var r = evt.expose.area;
3084 // console.dump([r.x, r.y, r.width, r.height ] );
3086 // print(widget.get_parent().toString().match(/GtkScrolledWindow/);
3087 if (widget.get_parent().toString().match(/GtkScrolledWindow/)) { // eak
3088 // happens with gtkscrollview embedded stuff..
3089 var np =this.activePath.split(':');
3091 this.activePath = np.join(':');
3092 this.renderedEl.queue_draw();
3108 this.inRender = true;
3111 this.highlightWidget = widget;
3116 // print("DRAW BOX");
3117 //console.dump(this.box);
3118 Gdk.draw_rectangle(widget.window, this.gc, false, this.box.x , this.box.y, this.box.w,this.box.h);
3119 this.inRender = false;
3122 widgetDragMotionEvent : function() {
3123 print("WIDGET DRAGMOTION");
3126 widgetDragDropEvent : function() {
3127 print("WIDGET DRAGDROP");
3130 widgetPressEvent : function(w,e,u,d) {
3131 if (this.get('view').pressed) {
3134 this.get('view').pressed = true;
3135 print("WIDGET PRESS " + d.xtreepath );
3136 this.get('/LeftTree.view').selectNode( d.xtreepath );
3139 widgetReleaseEvent : function() {
3140 this.get('view').pressed = false;
3143 redraw : function() {
3144 this.highlightWidget = false;
3145 print("REDRAW CALLED");
3146 this.activePath = this.get('/LeftTree').getActivePath();
3147 if (this.renderedEl) {
3148 print("QUEUE DRAW CALLING");
3149 this.renderedEl.queue_draw();
3155 pack : "pack_start,false,true,0",
3159 pack : "pack_start,false,false,0",
3160 label : "Run The Application",
3162 "button_press_event":function (self, event) {
3163 // call render on left tree - with special option!?!
3165 //print("GET PROEJCT");
3166 var pr = this.get('/LeftProjectTree').getActiveProject();
3169 for (var i in pr.paths) {
3173 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
3174 this.get('/Terminal').feed("RUN DIR:" + dir);
3176 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
3177 , false,false,false);
3178 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
3179 this.get('/Terminal').el.feed_child(cmd, cmd.length);
3189 xtype: Gtk.ScrolledWindow,
3192 shadow_type : Gtk.ShadowType.IN,
3194 XObject.prototype.init.call(this);
3195 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3199 xtype: Gtk.EventBox,
3200 pack : "add_with_viewport",
3202 XObject.prototype.init.call(this);
3203 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
3204 red: 0x9F00, green: 0xB800 , blue : 0xA800
3212 XObject.prototype.init.call(this);
3213 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
3214 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
3219 xtype: Gtk.EventBox,
3222 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
3223 XObject.prototype.init.call(this);
3227 this.el, /* widget that will accept a drop */
3228 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
3229 null, /* lists of target to support */
3230 0, /* size of list */
3231 Gdk.DragAction.COPY /* what to do with data after dropped */
3234 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
3235 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
3238 getActiveNode : function(x,y)
3240 // workout what node is here..
3241 return '0'; // top..
3245 "drag_motion":function (self, ctx, x, y, time) {
3247 // A) find out from drag all the places that node could be dropped.
3248 var src = Gtk.drag_get_source_widget(ctx);
3249 if (!src.dropList) {
3250 Gdk.drag_status(ctx, 0, time);
3253 // b) get what we are over.. (from activeNode)
3254 // tree is empty.. - list should be correct..
3255 if (!this.get('/LeftTree.model').currentTree) {
3256 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3260 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
3261 var activeNode = this.getActiveNode(x, y);
3264 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
3267 Gdk.drag_status(ctx, 0,time);
3268 this.get('/LeftTree.view').highlight(false);
3272 // if we have a target..
3273 // -> highlight it! (in browser)
3274 // -> highlight it! (in tree)
3276 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3277 this.get('/LeftTree.view').highlight(tg);
3278 this.targetData = tg;
3279 // for tree we should handle this...
3282 "drag_drop":function (self,ctx, x, y, time) {
3283 Seed.print("TARGET: drag-drop");
3284 var is_valid_drop_site = true;
3289 self, /* will receive 'drag-data-received' signal */
3290 ctx, /* represents the current state of the this.gDnD */
3291 this.get('/Window').atoms["STRING"], /* the target type we want */
3292 time /* time stamp */
3296 /* No target offered by source => error */
3299 return is_valid_drop_site;
3302 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3304 Seed.print("GtkView: drag-data-received");
3305 var delete_selection_data = false;
3306 var dnd_success = false;
3307 /* Deal with what we are given from source */
3308 if( sel_data && sel_data.length ) {
3310 if (ctx.action == Gdk.DragAction.ASK) {
3311 /* Ask the user to move or copy, then set the ctx action. */
3314 if (ctx.action == Gdk.DragAction.MOVE) {
3315 delete_selection_data = true;
3317 var source = Gtk.drag_get_source_widget(ctx);
3319 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3320 if (this.targetData) {
3321 Seed.print(this.targetData);
3322 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3331 if (dnd_success == false)
3333 Seed.print ("DnD data transfer failed!\n");
3336 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3339 "button_press_event":function (self, event) {
3340 this.pressed = false;
3356 xtype: Gtk.ScrolledWindow,
3361 var file = this.get('/LeftTree').getActiveFile();
3365 var activeEl = this.get('/LeftTree').getActiveElement();
3366 var xtype = file.guessName( activeEl )
3367 if (!xtype || !xtype.length) {
3370 this.get('/Window.view-help-nb').el.set_current_page(1);
3372 // get the active element being edited.
3373 var helpurl = file.getHelpUrl(xtype);
3375 // now load the help info in the page..
3376 this.get('help-view').el.open(helpurl);
3380 xtype: WebKit.WebView,
3384 XObject.prototype.init.call(this);
3385 this.get('/Window.help-view').el.open(
3386 "http://devel.akbkhome.com/seed/");
3398 xtype: Gtk.Notebook,
3401 XObject.prototype.init.call(this);
3402 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3403 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3408 xtype: Gtk.ScrolledWindow,
3413 xtype: GtkSource.View,
3417 XObject.prototype.init.call(this);
3418 var description = Pango.Font.description_from_string("monospace")
3419 description.set_size(8000);
3420 this.el.modify_font(description);
3423 load : function(str) {
3425 // show the help page for the active node..
3426 this.get('/Help').show();
3429 this.get('/BottomPane').el.set_current_page(0);
3430 this.el.get_buffer().set_text(str, str.length);
3431 var lm = GtkSource.LanguageManager.get_default();
3433 this.el.get_buffer().set_language(lm.get_language('js'));
3434 var buf = this.el.get_buffer();
3435 var cursor = buf.get_mark("insert");
3436 var iter= new Gtk.TextIter;
3437 buf.get_iter_at_mark(iter, cursor);
3439 iter.set_line_offset(4);
3440 buf.move_mark(cursor, iter);
3443 cursor = buf.get_mark("selection_bound");
3444 iter= new Gtk.TextIter;
3445 buf.get_iter_at_mark(iter, cursor);
3447 iter.set_line_offset(4);
3448 buf.move_mark(cursor, iter);
3450 this.el.grab_focus();
3452 insert_spaces_instead_of_tabs : true,
3455 show_line_numbers : true,
3458 xtype: GtkSource.Buffer,
3459 pack : "set_buffer",
3461 "changed":function (self) {
3462 var s = new Gtk.TextIter();
3463 var e = new Gtk.TextIter();
3464 this.el.get_start_iter(s);
3465 this.el.get_end_iter(e);
3466 var str = this.el.get_text(s,e,true);
3468 Seed.check_syntax('var e = ' + str);
3470 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3471 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3473 print("SYNTAX ERROR IN EDITOR");
3478 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3479 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3482 this.get('/LeftPanel.model').changed( str , false);
3491 xtype: Gtk.ScrolledWindow,
3495 xtype: Vte.Terminal,
3498 feed : function(istr) {
3499 var str = istr.replace(/\n/g, "\r\n") + "\r\n";
3500 // we should make ourselves visable!!!
3501 this.get('/BottomPane').el.show();
3502 this.get('/BottomPane').el.set_current_page(1);
3504 this.el.feed(str ,str.length);
3506 scroll_on_output : true,
3508 XObject.prototype.init.call(this);
3509 this.el.set_size (80, 1000);
3511 scrollback_lines : 1000
3521 pack : "pack_start,false,false",
3525 this.get('buttonbar').el.show();
3526 this.get('viewbox').el.hide();
3527 print("TRIED TO HIDE");
3530 this.get('buttonbar').el.hide();
3531 this.get('viewbox').el.show();
3532 // this.get('model').expanded();
3544 pack : "pack_start,false,true",
3546 "clicked":function (self) {
3547 this.get('/RightPalete').show();
3554 stock : Gtk.STOCK_GOTO_FIRST,
3555 icon_size : Gtk.IconSize.MENU
3565 XObject.prototype.init.call(this);
3566 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3569 "enter_notify_event":function (self, event) {
3570 this.get('/RightPalete').show();
3584 pack : "pack_start,false,true",
3593 pack : "pack_start,false,true",
3595 "clicked":function (self) {
3596 this.get('/RightPalete').hide();
3603 stock : Gtk.STOCK_GOTO_LAST,
3604 icon_size : Gtk.IconSize.MENU
3611 xtype: Gtk.ScrolledWindow,
3614 XObject.prototype.init.call(this);
3615 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3616 this.el.set_size_request(-1,200);
3618 shadow_type : Gtk.ShadowType.IN,
3621 xtype: Gtk.TreeView,
3624 XObject.prototype.init.call(this);
3625 this.el.set_size_request(150,-1);
3626 // set_reorderable: [1]
3628 var description = new Pango.FontDescription.c_new();
3629 description.set_size(8000);
3630 this.el.modify_font(description);
3632 this.selection = this.el.get_selection();
3633 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3634 // this.selection.signal['changed'].connect(function() {
3635 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3637 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3639 Gtk.drag_source_set (
3640 this.el, /* widget will be drag-able */
3641 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3642 null, /* lists of target to support */
3643 0, /* size of list */
3644 Gdk.DragAction.COPY /* what to do with data after dropped */
3646 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3648 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3649 Gtk.drag_source_add_text_targets(this.el);
3651 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3652 targets = new Gtk.TargetList();
3653 targets.add( LeftTree.atoms["STRING"], 0, 0);
3654 targets.add_text_targets( 1 );
3655 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3657 //if you want to allow text to be output elsewhere..
3658 //Gtk.drag_source_add_text_targets(this.el);
3662 headers_visible : false,
3663 enable_tree_lines : true,
3665 "drag_begin":function (self, ctx) {
3666 // we could fill this in now...
3667 Seed.print('SOURCE: drag-begin');
3671 var iter = new Gtk.TreeIter();
3672 var s = this.selection;
3673 s.get_selected(this.get('/RightPalete.model').el, iter);
3674 var path = this.get('/RightPalete.model').el.get_path(iter);
3676 var pix = this.el.create_row_drag_icon ( path);
3679 Gtk.drag_set_icon_pixmap (ctx,
3686 var value = new GObject.Value('');
3687 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3688 if (!this.get('/RightPalete').provider) {
3691 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3692 this.el.dragData = value.value;
3699 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3700 //Seed.print('Palete: drag-data-get: ' + target_type);
3701 if (this.el.dragData && this.el.dragData.length ) {
3702 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3706 //this.el.dragData = "TEST from source widget";
3710 "drag_end":function (self, drag_context) {
3711 Seed.print('SOURCE: drag-end');
3712 this.el.dragData = false;
3713 this.el.dropList = false;
3714 this.get('/LeftTree.view').highlight(false);
3720 xtype: Gtk.ListStore,
3723 XObject.prototype.init.call(this);
3724 this.el.set_column_types ( 2, [
3725 GObject.TYPE_STRING, // title
3726 GObject.TYPE_STRING // tip
3731 load : function(tr,iter)
3736 //console.log('Project tree load: ' + tr.length);
3737 var citer = new Gtk.TreeIter();
3738 //this.insert(citer,iter,0);
3739 for(var i =0 ; i < tr.length; i++) {
3742 this.el.append(citer);
3744 this.el.insert(citer,iter,-1);
3749 this.el.set_value(citer, 0, '' + r ); // title
3751 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3752 //if (r.cn && r.cn.length) {
3753 // this.load(r.cn, citer);
3759 getValue : function (iter, col) {
3760 var gval = new GObject.Value('');
3761 this.el.get_value(iter, col ,gval);
3768 xtype: Gtk.TreeViewColumn,
3769 pack : "append_column",
3771 XObject.prototype.init.call(this);
3772 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3776 xtype: Gtk.CellRendererText,
3798 XObject.cache['/Window'] = Window;