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, renderfull) {
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']+ ':'); }
1093 if (renderfull && c['|xns']) {
1094 txt.push(c['|xns']);
1097 if (c.xtype) { txt.push(c.xtype); }
1098 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1099 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1100 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1103 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1104 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1105 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1106 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1107 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1108 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1109 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1110 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1111 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1113 // for flat classes...
1114 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1115 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1118 if (sr) txt.push('</s>');
1119 return (txt.length == 0 ? "Element" : txt.join(" "));
1121 nodeToJSON : function(c) {
1129 return JSON.stringify(o);
1131 load : function(tr,iter)
1133 var citer = new Gtk.TreeIter();
1134 //this.insert(citer,iter,0);
1135 for(var i =0 ; i < tr.length; i++) {
1137 this.el.insert(citer,iter,-1);
1139 this.el.append(citer);
1142 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1143 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTip(tr[i]) ]);
1144 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1145 if (tr[i].items && tr[i].items.length) {
1146 this.load(tr[i].items, citer);
1150 nodeTip : function(c) {
1151 var ret = this.nodeTitle(c,true);
1157 if (!i.length || i[0] != '|') {
1163 if (typeof(c[i]) != 'string') {
1166 //print("prop : " + i + ':' + c[i]);
1167 if (!c[i].match(new RegExp('function'))) {
1170 funcs += "\n<b>" + i.substring(1) + '</b> : ' + c[i].split(/\n/).shift();
1174 ret+="\n\nMethods:" + funcs;
1181 xtype: Gtk.TreeViewColumn,
1182 pack : "append_column",
1184 XObject.prototype.init.call(this);
1185 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1189 xtype: Gtk.CellRendererText,
1199 id : "LeftTreeMenu",
1202 xtype: Gtk.MenuItem,
1204 label : "Delete Element",
1206 "activate":function (self) {
1208 this.get('/LeftTree.model').deleteSelected();
1219 id : "LeftProjectTree",
1220 showNoProjectSelected : function() {
1221 this.get('/StandardErrorDialog').show("Select a Project first.");
1223 getActiveProject : function() {
1224 return this.project;
1227 "leave_notify_event":function (self, event) {
1234 pack : "pack_start,false,false",
1237 xtype: Gtk.ComboBox,
1240 XObject.prototype.init.call(this);
1241 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1243 getValue : function() {
1244 var ix = this.el.get_active();
1248 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1249 if (typeof(data[ix]) == 'undefined') {
1254 setValue : function(fn)
1258 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1259 data.forEach(function(n, ix) {
1267 "changed":function (self) {
1268 var fn = this.getValue();
1269 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1270 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1275 xtype: Gtk.CellRendererText,
1276 pack : "pack_start,true",
1280 xtype: Gtk.ListStore,
1283 XObject.prototype.init.call(this);
1284 this.el.set_column_types ( 2, [
1285 GObject.TYPE_STRING, // real key
1286 GObject.TYPE_STRING // real type
1290 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1292 pm.on('changed', function() {
1293 print("caught changed hook on project manager - reloading data");
1294 _this.loadData(pm.projects);
1298 loadData : function(data) {
1299 var ov = this.get('/LeftProjectTree.combo').getValue();
1301 var iter = new Gtk.TreeIter();
1303 data.forEach(function(p) {
1308 el.set_value(iter, 0, p.fn);
1309 el.set_value(iter, 1, p.name);
1313 this.get('/LeftProjectTree.combo').setValue(ov);
1322 xtype: Gtk.ScrolledWindow,
1324 shadow_type : Gtk.ShadowType.IN,
1326 XObject.prototype.init.call(this);
1327 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1331 xtype: Gtk.TreeView,
1332 headers_visible : false,
1333 enable_tree_lines : true,
1336 XObject.prototype.init.call(this);
1337 var description = new Pango.FontDescription.c_new();
1338 description.set_size(8000);
1339 this.el.modify_font(description);
1341 this.selection = this.el.get_selection();
1342 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1346 "cursor_changed":function (self) {
1347 var iter = new Gtk.TreeIter();
1349 if (this.selection.count_selected_rows() < 1) {
1350 //XN.get('Builder.LeftTree.model').
1351 this.get('/LeftTree.model').load( false);
1355 var model = this.get('/LeftProjectTree.model');
1356 //console.log('changed');
1357 var s = this.selection;
1358 s.get_selected(model, iter);
1359 value = new GObject.Value('');
1360 model.el.get_value(iter, 2, value);
1362 console.log(value.value);// id..
1364 var file = this.get('/LeftProjectTree').project.getById(value.value);
1371 var nb = this.get('/LeftTopPanel.expander');
1372 nb.el.expanded = false;
1373 nb.listeners.activate.call(nb);
1374 //_expander.el.set_expanded(false);
1376 var ltm = this.get('/LeftTree.model');
1384 xtype: Gtk.TreeStore,
1388 XObject.prototype.init.call(this);
1389 this.el.set_column_types ( 3, [
1390 GObject.TYPE_STRING, // title
1391 GObject.TYPE_STRING, // tip
1392 GObject.TYPE_STRING // id..
1396 loadProject : function(pr) {
1397 print("LOAD PROJECT");
1403 this.get('/LeftProjectTree').project = pr;
1404 this.load(pr.toTree());
1405 this.get('/LeftProjectTree.view').el.expand_all();
1407 load : function(tr,iter) {
1408 // console.dump(tr);
1409 console.log('Project tree load: ' + tr.length);
1410 var citer = new Gtk.TreeIter();
1411 //this.insert(citer,iter,0);
1414 tr.forEach(function (r) {
1416 _this.el.append(citer);
1418 _this.el.insert(citer,iter,-1);
1420 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1421 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1422 _this.el.set_value(citer, 2, '' + r.id ); //id
1423 if (r.cn && r.cn.length) {
1424 _this.load(r.cn, citer);
1429 getValue : function(iter, col) {
1430 var gval = new GObject.Value('');
1431 this.el.get_value(iter, col ,gval);
1432 return '' + gval.value;
1436 xtype: Gtk.TreeViewColumn,
1437 pack : "append_column",
1439 XObject.prototype.init.call(this);
1440 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1444 xtype: Gtk.CellRendererText,
1467 pack : "pack_start,false,true,0",
1474 "button_press_event":function (self, event) {
1475 this.get('/MidPropTree.model').showData('props');
1487 stock : Gtk.STOCK_ADD,
1488 icon_size : Gtk.IconSize.MENU
1503 "button_press_event":function (self, event) {
1504 this.get('/MidPropTree.model').showData('events');
1516 stock : Gtk.STOCK_ADD,
1517 icon_size : Gtk.IconSize.MENU
1532 "button_press_event":function (self, ev) {
1533 var p = this.get('/AddPropertyPopup');
1537 p.el.set_screen(Gdk.Screen.get_default());
1539 p.el.popup(null, null, null, null, 3, ev.button.time);
1551 stock : Gtk.STOCK_ADD,
1552 icon_size : Gtk.IconSize.MENU
1564 id : "AddPropertyPopup",
1567 xtype: Gtk.MenuItem,
1569 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1572 "activate":function (self) {
1574 this.get('/LeftPanel.model').add( {
1585 xtype: Gtk.MenuItem,
1587 tooltip_markup : "Add what type of packing is to be used",
1590 "activate":function (self) {
1592 this.get('/LeftPanel.model').add( {
1602 xtype: Gtk.MenuItem,
1604 tooltip_markup : "Override the init method",
1607 "activate":function (self) {
1609 this.get('/LeftPanel.model').add( {
1612 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1619 xtype: Gtk.SeparatorMenuItem,
1623 xtype: Gtk.MenuItem,
1625 tooltip_markup : "Add a user defined string property",
1628 "activate":function (self) {
1630 this.get('/LeftPanel.model').add( {
1640 xtype: Gtk.MenuItem,
1642 tooltip_markup : "Add a user defined number property",
1645 "activate":function (self) {
1647 this.get('/LeftPanel.model').add( {
1657 xtype: Gtk.MenuItem,
1659 tooltip_markup : "Add a user defined boolean property",
1662 "activate":function (self) {
1664 this.get('/LeftPanel.model').add( {
1674 xtype: Gtk.SeparatorMenuItem,
1678 xtype: Gtk.MenuItem,
1680 tooltip_markup : "Add a user function boolean property",
1683 "activate":function (self) {
1685 this.get('/LeftPanel.model').add( {
1688 val : "function() {\n \n}\n",
1701 xtype: Gtk.ScrolledWindow,
1704 shadow_type : Gtk.ShadowType.IN,
1707 XObject.prototype.init.call(this);
1708 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1712 xtype: Gtk.TreeView,
1715 headers_visible : false,
1716 enable_tree_lines : true,
1718 XObject.prototype.init.call(this);
1720 this.selection = this.el.get_selection();
1721 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1724 var description = new Pango.FontDescription.c_new();
1725 description.set_size(8000);
1726 this.el.modify_font(description);
1729 "button_press_event":function (self, ev) {
1733 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1734 return false; //not on a element.
1738 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1740 if (res.column.title != 'value') {
1741 return false; // ignore..
1743 if ( this.get('/LeftPanel').editing) {
1746 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1747 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1748 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1752 var provider = this.get('/LeftTree').getPaleteProvider();
1754 var opts = provider.findOptions(type);
1756 if (opts === false) {
1757 this.get('/LeftPanel').editableColumn.setOptions([]);
1758 renderer.has_entry = true;
1760 LeftPanel.editableColumn.setOptions(opts);
1761 renderer.has_entry = false;
1765 //Seed.print("click" + ev.type);
1766 //console.dump(res);
1772 if (res.column.title == 'value') {
1775 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1776 var p = this.get('/LeftPanelPopup');
1781 p.el.set_screen(Gdk.Screen.get_default());
1783 p.el.popup(null, null, null, null, 3, ev.button.time);
1784 //Seed.print("click:" + res.column.title);
1792 xtype: Gtk.TreeStore,
1796 XObject.prototype.init.call(this);
1797 this.el.set_column_types ( 5, [
1798 GObject.TYPE_STRING, // 0 real key
1799 GObject.TYPE_STRING, // 1 real value
1800 GObject.TYPE_STRING, // 2 visable key
1801 GObject.TYPE_STRING, // 3 visable value
1802 GObject.TYPE_STRING, // 4 need to store type of!!!
1806 toShort : function(str) {
1807 var a = typeof(str) == 'string' ? str.split("\n") : [];
1808 return a.length > 1 ? a[0] + '....' : '' + str;
1810 load : function(ar) {
1813 this.get('/RightEditor').el.hide();
1820 var provider = this.get('/LeftTree').getPaleteProvider();
1823 var iter = new Gtk.TreeIter();
1825 if (typeof(ar[i]) == 'object') {
1829 var type = provider.findType(ar, i, ar[i]);
1831 this.el.append(iter);
1832 var p = this.el.get_path(iter).to_string();
1834 this.el.set_value(iter, 0, i);
1835 this.el.set_value(iter, 1, '' + ar[i]);
1836 this.el.set_value(iter, 2, i);
1837 this.el.set_value(iter, 3, this.toShort(ar[i]));
1838 this.el.set_value(iter, 4, type);
1840 ar.listeners = ar.listeners || {};
1841 for (var i in ar.listeners ) {
1842 this.el.append(iter);
1843 var p = this.el.get_path(iter).to_string();
1846 this.el.set_value(iter, 0, '!'+ i );
1847 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1848 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1850 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1851 this.el.set_value(iter, 4, 'function');
1855 add : function(info) {
1856 // info includes key, val, skel, etype..
1858 type = info.type.toLowerCase();
1859 var data = this.toJS();
1861 if (info.etype == 'events') {
1862 data.listeners = data.listeners || { };
1863 if (typeof(data.listeners[info.key]) != 'undefined') {
1864 return; //already set!
1867 if (typeof(data[info.key]) != 'undefined') {
1872 if (typeof(info.val) == 'undefined') {
1875 if (info.type == 'boolean') {
1878 if (type == 'number') {
1886 if (info.etype == 'events') {
1888 data.listeners[info.key] = info.val;
1891 data[info.key] = info.val;
1895 var map = this.load(data);
1897 // flag it as changed to the interface..
1899 this.get('/LeftTree.model').changed(data, true);
1902 this.startEditing(map[k]);
1905 LeftPanel.get('view').el.row_activated(
1906 new Gtk.TreePath.from_string(map[k]),
1907 LeftPanel.editableColumn.el
1911 startEditing : function(path,col) {
1913 * start editing path (or selected if not set..)
1914 * @param {String|false} path (optional) treepath to edit - selected tree gets
1915 * edited by default.
1916 * @param {Number} 0 or 1 (optional)- column to edit.
1919 if (typeof(path) == 'string') {
1920 tp = new Gtk.TreePath.from_string(path);
1922 var iter = new Gtk.TreeIter();
1923 var s = this.get('/LeftPanel.view').selection;
1924 s.get_selected(this.el, iter);
1925 tp = this.el.get_path(iter);
1926 path = tp.to_string();
1930 // which colum is to be edited..
1932 if (typeof(col) == 'undefined') {
1933 var k = this.getValue(path, 0);
1934 colObj = (!k.length || k == '|') ?
1935 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1937 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1940 // make sure the pulldown is set correctly..
1941 // not really needed for second col...
1943 var provider = this.get('/LeftTree').getPaleteProvider();
1945 var type = this.get('/LeftPanel.model').getType(path);
1946 var opts = provider.findOptions(type);
1947 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1949 if (opts === false) {
1950 this.get('/LeftPanel').editableColumn.setOptions([]);
1951 renderer.has_entry = true; /// probably does not have any effect.
1953 this.get('/LeftPanel').editableColumn.setOptions(opts);
1954 renderer.has_entry = false;
1958 // iter now has row...
1959 GLib.timeout_add(0, 100, function() {
1961 colObj.items[0].el.editable = true; // esp. need for col 0..
1962 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1971 deleteSelected : function() {
1972 var data = this.toJS();
1973 var iter = new Gtk.TreeIter();
1974 var s = this.get('/LeftPanel.view').selection;
1975 s.get_selected(this.el, iter);
1978 var gval = new GObject.Value('');
1979 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1981 var val = gval.value;
1982 if (val[0] == '!') {
1984 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1987 delete data.listeners[ val.substring(1)];
1988 if (!XObject.keys(data.listeners).length) {
1989 delete data.listeners;
1993 if (typeof(data[val]) == 'undefined') {
2001 this.get('/LeftTree.model').changed(data, true);
2005 changed : function(str, doRefresh) {
2006 if (!this.activePath) {
2009 var iter = new Gtk.TreeIter();
2010 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
2012 this.el.set_value(iter, 1, '' +str);
2013 this.el.set_value(iter, 3, '' + this.toShort(str));
2014 // update the tree...
2016 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
2019 var iter = new Gtk.TreeIter();
2020 this.get('/LeftPanel.model').el.get_iter_first(iter);
2025 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
2028 ar.listeners = ar.listeners || {};
2029 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
2032 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
2035 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
2041 //print(JSON.stringify(ar));
2045 getType : function(treepath) {
2046 return this.getValue(treepath, 4);
2048 getValue : function(treepath_str, col) {
2049 var iter = new Gtk.TreeIter();
2050 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
2052 var gval = new GObject.Value('');
2053 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
2054 var val = '' + gval.value;
2058 var type = this.getType(this.el.get_path(iter).to_string());
2059 //print("TYPE: " +type + " - val:" + val);
2060 switch(type.toLowerCase()) {
2066 return parseFloat(val); // Nan ?? invalid!!?
2068 return val == 'true' ? true : false;
2074 editSelected : function(e) {
2075 print("EDIT SELECTED?");
2076 var iter = new Gtk.TreeIter();
2077 var s = this.get('/LeftPanel.view').selection;
2078 s.get_selected(this.get('/LeftPanel.model').el, iter);
2079 var m = this.get('/LeftPanel.model')
2081 var gval = new GObject.Value('');
2082 this.el.get_value(iter, 0 ,gval);
2083 var val = '' + gval.value;
2085 gval = new GObject.Value('');
2086 this.el.get_value(iter, 1 ,gval);
2087 var rval = gval.value;
2088 var activePath = this.el.get_path(iter).to_string();
2089 this.activePath = activePath ;
2090 // was activeIter...
2093 var showEditor = false;
2095 if (val[0] == '!') {
2098 if (val[0] == '|') {
2099 if (rval.match(/function/g) || rval.match(/\n/g)) {
2106 this.activePath = false;
2107 GLib.timeout_add(0, 1, function() {
2108 // Gdk.threads_enter();
2109 _this.get('/BottomPane').el.show();
2110 _this.get('/RightEditor').el.show();
2111 _this.get('/RightEditor.view').load( rval );
2115 _this.activePath = activePath ;
2117 // Gdk.threads_leave();
2122 this.get('/BottomPane').el.hide();
2123 this.get('/RightEditor').el.hide();
2125 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2131 xtype: Gtk.TreeViewColumn,
2132 pack : "append_column",
2134 XObject.prototype.init.call(this);
2136 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2137 this.get('/LeftPanel').propertyColumn = this;
2142 xtype: Gtk.CellRendererText,
2143 pack : "pack_start",
2145 "editing_started":function (self, editable, path) {
2147 this.get('/LeftPanel.model').activePath = path;
2150 "edited":function (self, object, p0) {
2151 var model = this.get('/LeftPanel.model');
2152 var path = model.activePath;
2153 var iter = new Gtk.TreeIter();
2154 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2155 model.el.set_value(iter, 0, p0);
2156 model.el.set_value(iter, 2, p0);
2158 model.activePath = false;
2160 this.get('/LeftTree.model').changed(model.toJS(), true);
2161 this.el.editable = false;
2168 xtype: Gtk.TreeViewColumn,
2169 pack : "append_column",
2171 XObject.prototype.init.call(this);
2172 this.el.add_attribute(this.items[0].el , 'text', 3 );
2173 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2174 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2175 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2177 this.get('/LeftPanel').editableColumn= this;
2179 setOptions : function(ar) {
2180 var m = this.items[0].el.model;
2182 var iter = new Gtk.TreeIter();
2183 ar.forEach(function(i) {
2186 m.set_value(iter, 0, i);
2192 xtype: Gtk.CellRendererCombo,
2193 pack : "pack_start",
2198 XObject.prototype.init.call(this);
2199 this.el.model = new Gtk.ListStore();
2200 this.el.model.set_column_types ( 1, [
2201 GObject.TYPE_STRING // 0 real key
2205 "edited":function (self, object, p0) {
2206 this.get('/LeftPanel').editing = false;
2207 print("EDITED? p:" + p0 + " t:" + p0);
2208 this.get('/LeftPanel.model').changed(p0, true);
2209 this.get('/LeftPanel.model').activePath = false;
2211 "editing_started":function (self, editable, path) {
2212 this.get('/LeftPanel').editing = true;
2213 // console.log('editing started');
2214 // r.has_entry = false;
2215 this.get('/LeftPanel.model').editSelected(editable);
2226 id : "LeftPanelPopup",
2229 xtype: Gtk.MenuItem,
2233 "activate":function (self) {
2234 this.get('/LeftPanel.model').deleteSelected();
2239 xtype: Gtk.MenuItem,
2243 "activate":function (self) {
2244 this.get('/LeftPanel.model').startEditing(false, 0);
2257 xtype: Gtk.ScrolledWindow,
2258 pack : "pack_end,false,true,0",
2260 shadow_type : Gtk.ShadowType.IN,
2262 XObject.prototype.init.call(this);
2263 XObject.prototype.init.call(this);
2264 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2265 this.el.set_size_request ( 150, -1 );
2268 activeElement : false,
2269 hideWin : function() {
2276 if (this.get('/Window.left').el.position < 160) {
2279 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2286 xtype: Gtk.TreeView,
2287 enable_tree_lines : true,
2288 headers_visible : false,
2291 XObject.prototype.init.call(this);
2293 var description = new Pango.FontDescription.c_new();
2294 description.set_size(8000);
2295 this.el.modify_font(description);
2297 //this.selection = this.el.get_selection();
2298 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2307 "cursor_changed":function (self) {
2308 var iter = new Gtk.TreeIter();
2310 //console.log('changed');
2311 var m = this.get('model');
2312 if (!this.selection){
2313 this.selection = this.el.get_selection();
2316 var s = this.selection;
2317 if (!s.get_selected(m.el, iter)) {
2320 var tp = m.el.get_path(iter).to_string();
2325 var key = m.getValue(tp, 0);
2327 var type = m.getValue(tp, 1);
2328 var skel = m.getValue(tp, 3);
2329 var etype = m.getValue(tp, 5);
2332 this.get('/MidPropTree').hideWin();
2334 if (type == 'function') {
2336 if (etype != 'events') {
2340 this.get('/LeftPanel.model').add({
2349 if (type.indexOf('.') > -1 ||
2350 type == 'boolean') {
2354 this.get('/LeftPanel.model').add( {
2364 xtype: Gtk.ListStore,
2367 XObject.prototype.init.call(this);
2368 this.el.set_column_types ( 6, [
2369 GObject.TYPE_STRING, // real key
2370 GObject.TYPE_STRING, // real type
2371 GObject.TYPE_STRING, // docs ?
2372 GObject.TYPE_STRING, // visable desc
2373 GObject.TYPE_STRING, // function desc
2374 GObject.TYPE_STRING // element type (event|prop)
2378 getValue : function(treepath, col)
2380 var tp = new Gtk.TreePath.from_string (treepath);
2381 var iter = new Gtk.TreeIter();
2382 this.el.get_iter (iter, tp);
2383 var value = new GObject.Value('');
2384 this.el.get_value(iter, col, value);
2388 showData : function(type) {
2390 if (!this.get('/MidPropTree').activeElement || !type) {
2391 return; // no active element
2394 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2395 var palete = this.get('/LeftTree').getPaleteProvider();
2399 Seed.print('Showing right?');
2400 if (!this.get('/MidPropTree').shown) {
2402 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2403 this.get('/MidPropTree').el.show();
2404 this.get('/MidPropTree').shown = true;
2407 var elementList = palete.getPropertiesFor(fullpath, type);
2408 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2409 // console.dump(elementList);
2412 var iter = new Gtk.TreeIter();
2413 for(var i =0 ; i < elementList.length; i++) {
2414 var p=elementList[i];
2415 this.el.append(iter);
2416 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2417 //GObject.TYPE_STRING, // real key
2418 // GObject.TYPE_STRING, // real type
2419 // GObject.TYPE_STRING, // docs ?
2420 // GObject.TYPE_STRING // func def?
2423 this.el.set_value(iter, 0, p.name);
2424 this.el.set_value(iter, 1, p.type);
2425 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2426 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2427 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2428 this.el.set_value(iter, 5, type);
2436 xtype: Gtk.TreeViewColumn,
2438 this.el = new Gtk.TreeViewColumn();
2439 this.parent.el.append_column(this.el);
2441 XObject.prototype.init.call(this);
2442 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2447 xtype: Gtk.CellRendererText,
2448 pack : "pack_start,true"
2472 xtype: Gtk.Notebook,
2473 pack : "pack_start,true,true",
2474 id : "view-help-nb",
2476 XObject.prototype.init.call(this);
2477 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" }));
2478 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" }));
2482 xtype: Gtk.Notebook,
2484 id : "view-notebook",
2487 XObject.prototype.init.call(this);
2488 this.el.set_current_page(0);
2490 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2491 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2498 id : "RightBrowser",
2505 pack : "pack_start,false,true,0",
2509 pack : "pack_start,false,false,0",
2512 "button_press_event":function (self, event) {
2513 var js = this.get('/LeftTree.model').toJS();
2515 this.get('/RightBrowser.view').renderJS(js[0]);
2523 pack : "pack_start,false,false,0",
2524 label : "Set extra HTML in render",
2526 "button_press_event":function (self, event) {
2527 this.get('/RooProjectProperties').show();
2534 pack : "pack_start,false,false,0",
2535 label : "test in Firefox",
2537 "button_press_event":function (self, event)
2539 /* Firefox testing for debugging..
2540 - we can create a /tmp directory, and put.
2541 builder.html, builder.html.js, link roojs1
2542 add at the end of builder.html Roo.onload(function() {
2544 if (!this.get('/Window.LeftTree').getActiveFile()) {
2548 var js = this.get('/LeftTree.model').toJS();
2549 if (!js || !js[0]) {
2552 var project = this.get('/Window.LeftTree').getActiveFile().project;
2553 //print (project.fn);
2555 project.runhtml = project.runhtml || '';
2558 var File = imports.File.File;
2560 var target = "/tmp/firetest"; // fixme..
2561 if (!File.isDirectory(target)) {
2564 File.copy(__script_path__ + '/../builder.html.js', target+ '/builder.html.js', Gio.FileCopyFlags.OVERWRITE);
2565 if (!File.exists( target+ '/roojs1')) {
2566 File.link( target+ '/roojs1', __script_path__ + '/../roojs1');
2571 var html = imports.File.File.read(__script_path__ + '/../builder.html');
2572 html = html.replace('</head>', project.runhtml + '</head>');
2575 var jsstr = JSON.stringify(js[0]);
2577 var runbuilder = '<script type="text/javascript">' + "\n" +
2578 " Builder.render(" + jsstr + ");\n" +
2581 html = html.replace('</body>', runbuilder + '</body>');
2583 File.write( target+ '/builder.html', html);
2585 this.get('/Terminal').feed("RUN DIR:" + target);
2587 this.get('/Terminal').el.fork_command( null , [], [], target
2588 , false,false,false);
2589 var cmd = "firefox file://" + target + "/builder.html \n";
2590 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2598 xtype: Gtk.ScrolledWindow,
2600 shadow_type : Gtk.ShadowType.IN,
2602 XObject.prototype.init.call(this);
2603 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2607 xtype: WebKit.WebView,
2611 XObject.prototype.init.call(this);
2612 // this may not work!?
2613 this.el.open('file:///' + __script_path__ + '/../builder.html');
2617 this.el, /* widget that will accept a drop */
2618 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2619 null, /* lists of target to support */
2620 0, /* size of list */
2621 Gdk.DragAction.COPY /* what to do with data after dropped */
2624 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2625 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2627 renderJS : function(data) {
2628 print("HTML RENDERING");
2629 /// prevent looping..
2630 //if (this.pendingRedraw) {
2631 // print("pending redraw active?!");
2636 if (!this.get('/Window.LeftTree').getActiveFile()) {
2640 var project = this.get('/Window.LeftTree').getActiveFile().project;
2641 //print (project.fn);
2643 project.runhtml = project.runhtml || '';
2646 this.runhtml = this.runhtml || '';
2648 if (project.runhtml != this.runhtml) {
2649 // then we need to reload the browser using
2650 // load_html_string..
2652 // then trigger a redraw once it's loaded..
2653 this.pendingRedraw = true;
2655 this.runhtml = project.runhtml;
2657 var html = imports.File.File.read(__script_path__ + '/../builder.html');
2658 html = html.replace('</head>', this.runhtml + '</head>');
2659 print("LOAD HTML " + html);
2660 this.el.load_html_string( html , 'file:///' + __script_path__ + '/../builder.html');
2661 // should trigger load_finished!
2666 this.pendingRedraw = false;
2669 this.renderedData = data;
2670 var str = JSON.stringify(data) ;
2673 console.log('not loaded yet');
2675 //Seed.print("RENDER:" + str);
2676 //imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2678 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2681 "load_finished":function (self, object) {
2682 // if (this.ready) { // dont do it twice!
2686 this.pendingRedraw = false;
2687 var js = this.get('/LeftTree.model').toJS();
2689 this.renderJS(js[0]);
2693 "script_alert":function (self, object, p0) {
2696 return true; // do not display anything...
2698 "console_message":function (self, object, p0, p1) {
2699 // console.log(object);
2700 if (!object.match(/^\{/)) {
2702 this.get('/Terminal').feed(object);
2703 return true; // do not handle!!! -> later maybe in console..
2705 // console.log(object);
2706 var val = JSON.parse(object);
2708 if (typeof(val['hover-node']) != 'undefined') {
2709 this.activeNode = val['hover-node'];
2710 console.log('active node: ' + this.activeNode);
2715 if (typeof(val['id']) != 'undefined') {
2716 // this.activeNode = val['id'];
2717 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2721 this.get('/LeftTree.view').selectNode(tg[0]);
2725 if (ret && typeof(val['set']) != 'undefined') {
2726 this.get('/LeftPanel.model').add({
2730 //console.log('active node: ' + this.activeNode);
2733 //Seed.print('a:'+a);
2734 //Seed.print('b:'+b);
2735 //Seed.print('c:'+c);
2738 "drag_motion":function (w, ctx, x, y, time, ud) {
2739 // console.log('DRAG MOTION');
2741 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2742 this.targetData = [];
2743 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2745 // A) find out from drag all the places that node could be dropped.
2746 var src = Gtk.drag_get_source_widget(ctx);
2747 if (!src.dropList) {
2748 Gdk.drag_status(ctx, 0, time);
2751 // b) get what we are over.. (from activeNode)
2752 // tree is empty.. - list should be correct..
2753 if (!this.get('/LeftTree.model').currentTree) {
2754 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2758 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2760 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2763 Gdk.drag_status(ctx, 0,time);
2764 this.get('/LeftTree.view').highlight(false);
2768 // if we have a target..
2769 // -> highlight it! (in browser)
2770 // -> highlight it! (in tree)
2772 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2773 this.get('/LeftTree.view').highlight(tg);
2774 this.targetData = tg;
2775 // for tree we should handle this...
2778 "drag_drop":function (w, ctx, x, y,time, ud) {
2779 print("TARGET: drag-drop");
2780 var is_valid_drop_site = true;
2785 w, /* will receive 'drag-data-received' signal */
2786 ctx, /* represents the current state of the DnD */
2787 this.get('/Window').atoms["STRING"], /* the target type we want */
2788 time /* time stamp */
2792 /* No target offered by source => error */
2795 return is_valid_drop_site;
2797 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2799 print("Browser: drag-data-received");
2800 var delete_selection_data = false;
2801 vardnd_success = false;
2802 /* Deal with what we are given from source */
2803 if( sel_data && sel_data.length ) {
2805 if (ctx.action == Gdk.DragAction.ASK) {
2806 /* Ask the user to move or copy, then set the ctx action. */
2809 if (ctx.action == Gdk.DragAction.MOVE) {
2810 delete_selection_data = true;
2812 var source = Gtk.drag_get_source_widget(ctx);
2814 print("Browser: source.DRAGDATA? " + source.dragData);
2815 if (this.targetData) {
2816 print(this.targetData);
2817 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2826 if (dnd_success == false)
2828 Seed.print ("DnD data transfer failed!\n");
2831 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2843 id : "RightGtkView",
2844 renderJS : function(data, withDebug)
2846 this.highlightWidget = false;
2850 this.withDebug = false;
2852 if (this.renderedEl) {
2853 this.get('view').el.remove(this.renderedEl);
2854 this.renderedEl.destroy();
2855 this.renderedEl = false;
2858 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2859 // in theory tree is actually window..
2861 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2866 this.get('view').el.set_size_request(
2867 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2870 this.renderedEl.set_size_request(
2871 tree.default_width || 600,
2872 tree.default_height || 400
2874 this.get('view').el.show_all();
2879 showInWindow : function() {
2880 print("GET PROEJCT");
2881 var pr = this.get('/LeftProjectTree').getActiveProject();
2883 console.log(pr.paths);
2886 var src= this.buildJS(
2887 this.get('/LeftTree.model').toJS()[0],
2892 //var x = new imports.sandbox.Context();
2896 Seed.check_syntax('var e = ' + src);
2899 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2900 this.get('/Terminal').feed(console._dump(e)+"\n");
2902 var lines = src.split("\n");
2903 var start = Math.max(0, e.line - 10);
2904 var end = Math.min(lines.length, e.line + 10);
2905 for (var i =start ; i < end; i++) {
2907 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2910 this.get('/Terminal').feed(lines[i] + "\n");
2917 this.get('/BottomPane').el.set_current_page(1);
2918 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2919 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2920 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2922 var _top = x.get_global_object()._top;
2924 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2926 if (_top.el.popup) {
2927 _top.el.popup(null, null, null, null, 3, null);
2931 viewAdd : function(item, par)
2933 // does something similar to xobject..
2934 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2936 if (item.pack===false || item.pack === 'false') { // no ;
2939 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2940 var ns = imports.gi[item['|xns']];
2941 var ctr = ns[item['xtype']];
2943 for(var k in item) {
2945 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2960 if (k[0] == '|' && typeof(kv) == 'string') {
2962 if (kv.match(new RegExp('function'))) {
2965 print("WASL " + k + '=' + kv);
2967 eval( 'kv = ' + kv);
2968 } catch(e) { continue; }
2971 // print(k + '=' + kv);
2973 if (k[0] == '|') { // should be boolean or number..
2975 //print(k + '=' + kv);
2978 if (k == 'show_tabs') { // force tab showing for notebooks.
2981 print(k + '=' + typeof(kv) + " : " + kv);
2987 var el = new ctr(ctr_args);
2990 //console.dump(item.pack);
2997 if (typeof(item.pack) == 'string') {
2999 item.pack.split(',').forEach(function(e, i) {
3001 if (e == 'false') { args.push( false); return; }
3002 if (e == 'true') { args.push( true); return; }
3003 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
3006 //print(args.join(","));
3008 pack_m = args.shift();
3010 pack_m = item.pack.shift();
3015 if (pack_m && typeof(par[pack_m]) == 'undefined') {
3017 name: "ArgumentError",
3018 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
3019 "ADDING : " + item.id + " " + el
3028 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
3029 //Seed.print('args: ' + args.length);
3031 par[pack_m].apply(par, args);
3035 item.items = item.items || [];
3036 item.items.forEach(function(ch) {
3037 _this.viewAdd(ch, el);
3042 // add the signal handlers.
3043 // is it a widget!?!!?
3049 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
3050 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
3051 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
3052 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
3053 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
3063 widgetExposeEvent : function(w, evt, ud, item) {
3065 if (this.inRender) {
3069 if ( this.highlightWidget) {
3070 this.inRender = true;
3071 if (item.xtreepath.substring(0, this.activePath.length) == this.activePath) {
3072 Gdk.draw_rectangle(this.highlightWidget.window, this.gc, false, this.box.x , this.box.y, this.box.w, this.box.h);
3074 this.inRender = false;
3079 if (this.activePath != item.xtreepath) {
3083 // print("HIGHLIGHT: " + item.xtreepath ); // draw highlight??
3084 // work out the coords of the window..
3086 var dr = widget.window;
3087 this.gc = (new Gdk.GC.c_new(dr));
3088 this.gc.set_rgb_fg_color(new Gdk.Color({ red: 0xFFFF, green: 0, blue : 0 }));
3089 this.gc.set_line_attributes(4, Gdk.LineStyle.SOLID, Gdk.CapStyle.ROUND , Gdk.JoinStyle.ROUND);
3093 var r = evt.expose.area;
3094 // console.dump([r.x, r.y, r.width, r.height ] );
3096 // print(widget.get_parent().toString().match(/GtkScrolledWindow/);
3097 if (widget.get_parent().toString().match(/GtkScrolledWindow/)) { // eak
3098 // happens with gtkscrollview embedded stuff..
3099 var np =this.activePath.split(':');
3101 this.activePath = np.join(':');
3102 this.renderedEl.queue_draw();
3118 this.inRender = true;
3121 this.highlightWidget = widget;
3126 // print("DRAW BOX");
3127 //console.dump(this.box);
3128 Gdk.draw_rectangle(widget.window, this.gc, false, this.box.x , this.box.y, this.box.w,this.box.h);
3129 this.inRender = false;
3132 widgetDragMotionEvent : function() {
3133 print("WIDGET DRAGMOTION");
3136 widgetDragDropEvent : function() {
3137 print("WIDGET DRAGDROP");
3140 widgetPressEvent : function(w,e,u,d) {
3141 if (this.get('view').pressed) {
3144 this.get('view').pressed = true;
3145 print("WIDGET PRESS " + d.xtreepath );
3146 this.get('/LeftTree.view').selectNode( d.xtreepath );
3149 widgetReleaseEvent : function() {
3150 this.get('view').pressed = false;
3153 redraw : function() {
3154 this.highlightWidget = false;
3155 print("REDRAW CALLED");
3156 this.activePath = this.get('/LeftTree').getActivePath();
3157 if (this.renderedEl) {
3158 print("QUEUE DRAW CALLING");
3159 this.renderedEl.queue_draw();
3165 pack : "pack_start,false,true,0",
3169 pack : "pack_start,false,false,0",
3170 label : "Run The Application",
3172 "button_press_event":function (self, event) {
3173 // call render on left tree - with special option!?!
3175 //print("GET PROEJCT");
3176 var pr = this.get('/LeftProjectTree').getActiveProject();
3179 for (var i in pr.paths) {
3183 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
3184 this.get('/Terminal').feed("RUN DIR:" + dir);
3186 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
3187 , false,false,false);
3188 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
3189 this.get('/Terminal').el.feed_child(cmd, cmd.length);
3199 xtype: Gtk.ScrolledWindow,
3202 shadow_type : Gtk.ShadowType.IN,
3204 XObject.prototype.init.call(this);
3205 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3209 xtype: Gtk.EventBox,
3210 pack : "add_with_viewport",
3212 XObject.prototype.init.call(this);
3213 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
3214 red: 0x9F00, green: 0xB800 , blue : 0xA800
3222 XObject.prototype.init.call(this);
3223 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
3224 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
3229 xtype: Gtk.EventBox,
3232 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
3233 XObject.prototype.init.call(this);
3237 this.el, /* widget that will accept a drop */
3238 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
3239 null, /* lists of target to support */
3240 0, /* size of list */
3241 Gdk.DragAction.COPY /* what to do with data after dropped */
3244 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
3245 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
3248 getActiveNode : function(x,y)
3250 // workout what node is here..
3251 return '0'; // top..
3255 "drag_motion":function (self, ctx, x, y, time) {
3257 // A) find out from drag all the places that node could be dropped.
3258 var src = Gtk.drag_get_source_widget(ctx);
3259 if (!src.dropList) {
3260 Gdk.drag_status(ctx, 0, time);
3263 // b) get what we are over.. (from activeNode)
3264 // tree is empty.. - list should be correct..
3265 if (!this.get('/LeftTree.model').currentTree) {
3266 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3270 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
3271 var activeNode = this.getActiveNode(x, y);
3274 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
3277 Gdk.drag_status(ctx, 0,time);
3278 this.get('/LeftTree.view').highlight(false);
3282 // if we have a target..
3283 // -> highlight it! (in browser)
3284 // -> highlight it! (in tree)
3286 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3287 this.get('/LeftTree.view').highlight(tg);
3288 this.targetData = tg;
3289 // for tree we should handle this...
3292 "drag_drop":function (self,ctx, x, y, time) {
3293 Seed.print("TARGET: drag-drop");
3294 var is_valid_drop_site = true;
3299 self, /* will receive 'drag-data-received' signal */
3300 ctx, /* represents the current state of the this.gDnD */
3301 this.get('/Window').atoms["STRING"], /* the target type we want */
3302 time /* time stamp */
3306 /* No target offered by source => error */
3309 return is_valid_drop_site;
3312 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3314 Seed.print("GtkView: drag-data-received");
3315 var delete_selection_data = false;
3316 var dnd_success = false;
3317 /* Deal with what we are given from source */
3318 if( sel_data && sel_data.length ) {
3320 if (ctx.action == Gdk.DragAction.ASK) {
3321 /* Ask the user to move or copy, then set the ctx action. */
3324 if (ctx.action == Gdk.DragAction.MOVE) {
3325 delete_selection_data = true;
3327 var source = Gtk.drag_get_source_widget(ctx);
3329 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3330 if (this.targetData) {
3331 Seed.print(this.targetData);
3332 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3341 if (dnd_success == false)
3343 Seed.print ("DnD data transfer failed!\n");
3346 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3349 "button_press_event":function (self, event) {
3350 this.pressed = false;
3366 xtype: Gtk.ScrolledWindow,
3371 var file = this.get('/LeftTree').getActiveFile();
3375 var activeEl = this.get('/LeftTree').getActiveElement();
3376 var xtype = file.guessName( activeEl )
3377 if (!xtype || !xtype.length) {
3380 this.get('/Window.view-help-nb').el.set_current_page(1);
3382 // get the active element being edited.
3383 var helpurl = file.getHelpUrl(xtype);
3385 // now load the help info in the page..
3386 this.get('help-view').el.open(helpurl);
3390 xtype: WebKit.WebView,
3394 XObject.prototype.init.call(this);
3395 this.get('/Window.help-view').el.open(
3396 "http://devel.akbkhome.com/seed/");
3408 xtype: Gtk.Notebook,
3411 XObject.prototype.init.call(this);
3412 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3413 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3418 xtype: Gtk.ScrolledWindow,
3423 xtype: GtkSource.View,
3427 XObject.prototype.init.call(this);
3428 var description = Pango.Font.description_from_string("monospace")
3429 description.set_size(8000);
3430 this.el.modify_font(description);
3433 load : function(str) {
3435 // show the help page for the active node..
3436 this.get('/Help').show();
3439 this.get('/BottomPane').el.set_current_page(0);
3440 this.el.get_buffer().set_text(str, str.length);
3441 var lm = GtkSource.LanguageManager.get_default();
3443 this.el.get_buffer().set_language(lm.get_language('js'));
3444 var buf = this.el.get_buffer();
3445 var cursor = buf.get_mark("insert");
3446 var iter= new Gtk.TextIter;
3447 buf.get_iter_at_mark(iter, cursor);
3449 iter.set_line_offset(4);
3450 buf.move_mark(cursor, iter);
3453 cursor = buf.get_mark("selection_bound");
3454 iter= new Gtk.TextIter;
3455 buf.get_iter_at_mark(iter, cursor);
3457 iter.set_line_offset(4);
3458 buf.move_mark(cursor, iter);
3460 this.el.grab_focus();
3462 insert_spaces_instead_of_tabs : true,
3465 show_line_numbers : true,
3468 xtype: GtkSource.Buffer,
3469 pack : "set_buffer",
3471 "changed":function (self) {
3472 var s = new Gtk.TextIter();
3473 var e = new Gtk.TextIter();
3474 this.el.get_start_iter(s);
3475 this.el.get_end_iter(e);
3476 var str = this.el.get_text(s,e,true);
3478 Seed.check_syntax('var e = ' + str);
3480 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3481 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3483 print("SYNTAX ERROR IN EDITOR");
3488 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3489 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3492 this.get('/LeftPanel.model').changed( str , false);
3501 xtype: Gtk.ScrolledWindow,
3505 xtype: Vte.Terminal,
3508 feed : function(istr) {
3509 var str = istr.replace(/\n/g, "\r\n") + "\r\n";
3510 // we should make ourselves visable!!!
3511 this.get('/BottomPane').el.show();
3512 this.get('/BottomPane').el.set_current_page(1);
3514 this.el.feed(str ,str.length);
3516 scroll_on_output : true,
3518 XObject.prototype.init.call(this);
3519 this.el.set_size (80, 1000);
3521 scrollback_lines : 1000
3531 pack : "pack_start,false,false",
3535 this.get('buttonbar').el.show();
3536 this.get('viewbox').el.hide();
3537 print("TRIED TO HIDE");
3540 this.get('buttonbar').el.hide();
3541 this.get('viewbox').el.show();
3542 // this.get('model').expanded();
3554 pack : "pack_start,false,true",
3556 "clicked":function (self) {
3557 this.get('/RightPalete').show();
3564 stock : Gtk.STOCK_GOTO_FIRST,
3565 icon_size : Gtk.IconSize.MENU
3575 XObject.prototype.init.call(this);
3576 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3579 "enter_notify_event":function (self, event) {
3580 this.get('/RightPalete').show();
3594 pack : "pack_start,false,true",
3603 pack : "pack_start,false,true",
3605 "clicked":function (self) {
3606 this.get('/RightPalete').hide();
3613 stock : Gtk.STOCK_GOTO_LAST,
3614 icon_size : Gtk.IconSize.MENU
3621 xtype: Gtk.ScrolledWindow,
3624 XObject.prototype.init.call(this);
3625 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3626 this.el.set_size_request(-1,200);
3628 shadow_type : Gtk.ShadowType.IN,
3631 xtype: Gtk.TreeView,
3634 XObject.prototype.init.call(this);
3635 this.el.set_size_request(150,-1);
3636 // set_reorderable: [1]
3638 var description = new Pango.FontDescription.c_new();
3639 description.set_size(8000);
3640 this.el.modify_font(description);
3642 this.selection = this.el.get_selection();
3643 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3644 // this.selection.signal['changed'].connect(function() {
3645 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3647 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3649 Gtk.drag_source_set (
3650 this.el, /* widget will be drag-able */
3651 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3652 null, /* lists of target to support */
3653 0, /* size of list */
3654 Gdk.DragAction.COPY /* what to do with data after dropped */
3656 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3658 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3659 Gtk.drag_source_add_text_targets(this.el);
3661 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3662 targets = new Gtk.TargetList();
3663 targets.add( LeftTree.atoms["STRING"], 0, 0);
3664 targets.add_text_targets( 1 );
3665 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3667 //if you want to allow text to be output elsewhere..
3668 //Gtk.drag_source_add_text_targets(this.el);
3672 headers_visible : false,
3673 enable_tree_lines : true,
3675 "drag_begin":function (self, ctx) {
3676 // we could fill this in now...
3677 Seed.print('SOURCE: drag-begin');
3681 var iter = new Gtk.TreeIter();
3682 var s = this.selection;
3683 s.get_selected(this.get('/RightPalete.model').el, iter);
3684 var path = this.get('/RightPalete.model').el.get_path(iter);
3686 var pix = this.el.create_row_drag_icon ( path);
3689 Gtk.drag_set_icon_pixmap (ctx,
3696 var value = new GObject.Value('');
3697 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3698 if (!this.get('/RightPalete').provider) {
3701 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3702 this.el.dragData = value.value;
3709 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3710 //Seed.print('Palete: drag-data-get: ' + target_type);
3711 if (this.el.dragData && this.el.dragData.length ) {
3712 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3716 //this.el.dragData = "TEST from source widget";
3720 "drag_end":function (self, drag_context) {
3721 Seed.print('SOURCE: drag-end');
3722 this.el.dragData = false;
3723 this.el.dropList = false;
3724 this.get('/LeftTree.view').highlight(false);
3730 xtype: Gtk.ListStore,
3733 XObject.prototype.init.call(this);
3734 this.el.set_column_types ( 2, [
3735 GObject.TYPE_STRING, // title
3736 GObject.TYPE_STRING // tip
3741 load : function(tr,iter)
3746 //console.log('Project tree load: ' + tr.length);
3747 var citer = new Gtk.TreeIter();
3748 //this.insert(citer,iter,0);
3749 for(var i =0 ; i < tr.length; i++) {
3752 this.el.append(citer);
3754 this.el.insert(citer,iter,-1);
3759 this.el.set_value(citer, 0, '' + r ); // title
3761 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3762 //if (r.cn && r.cn.length) {
3763 // this.load(r.cn, citer);
3769 getValue : function (iter, col) {
3770 var gval = new GObject.Value('');
3771 this.el.get_value(iter, col ,gval);
3778 xtype: Gtk.TreeViewColumn,
3779 pack : "append_column",
3781 XObject.prototype.init.call(this);
3782 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3786 xtype: Gtk.CellRendererText,
3808 XObject.cache['/Window'] = Window;