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();
60 pack : "pack_start,false,false",
72 label : "New Project",
74 "activate":function (self) {
75 this.get('/EditProject').show({
76 success : function(pr) {
77 this.get('/LeftProjectTree').get('combo').setValue(pr.fn);
87 "activate":function (self) {
88 var fn = this.get('/LeftProjectTree.combo').getValue();
90 this.get('/LeftProjectTree').showNoProjectSelected();
93 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
94 this.get('/DialogNewComponent').show({
95 project : pm.getByFn(fn)
101 xtype: Gtk.SeparatorMenuItem,
106 label : "Add Directory to Project",
109 "activate":function (self) {
110 var fn = this.get('/LeftProjectTree').get('combo').getValue();
112 this.get('/LeftProjectTree').showNoProjectSelected();
117 var dc = new Gtk.FileChooserDialog({
118 action : Gtk.FileChooserAction.SELECT_FOLDER,
120 'select-multiple' : false,
121 "show-hidden" : true,
123 dc.add_button("Add To Project", Gtk.ResponseType.ACCEPT );
124 dc.add_button("Cancel",Gtk.ResponseType.CANCEL);
126 if (dc.run() != Gtk.ResponseType.ACCEPT) {
132 //Seed.print(dc.get_filename());
133 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
134 pm.getByFn(fn).add(dc.get_filename(), 'dir');
140 xtype: Gtk.SeparatorMenuItem,
148 "activate":function (self) {
182 label : "Select Project",
184 pack : "pack_start,false,true",
186 XObject.prototype.init.call(this);
187 this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
190 "activate":function (self) {
191 var nb = this.get('/LeftTopPanel.notebook');
192 if (this.el.expanded) {
195 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
198 var model = this.get('/LeftProjectTree.combomodel');
199 // print ("loading Projects?")
200 //console.dump(pm.projects);
201 model.loadData(pm.projects);
204 nb.el.set_current_page(1);
205 //pm.on('changed', function() {
206 //console.log("CAUGHT project manager change");
207 // _combo.model.loadData(pm.projects);
211 nb.el.set_current_page(0);
213 "enter_notify_event":function (self, event) {
214 this.el.expanded = !this.el.expanded;
215 //if (this.el.expanded ) {
216 this.listeners.activate.call(this);
228 pack : "pack_start,true,true",
230 XObject.prototype.init.call(this);
231 this.el.set_current_page(0);
236 xtype: Gtk.ScrolledWindow,
238 shadow_type : Gtk.ShadowType.IN,
240 XObject.prototype.init.call(this);
241 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
244 getPaleteProvider : function() {
245 var model = this.get('model');
246 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
247 return pm.getPalete(model.file.getType());
249 renderView : function() {
250 var model = this.get('model');
251 print("RENDER VIEW?" + model.file.getType());
252 switch( model.file.getType()) {
254 this.get('/RightBrowser.view').renderJS(model.toJS(false,true)[0]);
256 this.get('/RightGtkView').renderJS(model.toJS(false,true)[0]);
264 headers_visible : false,
265 enable_tree_lines : true,
268 XObject.prototype.init.call(this);
269 var description = new Pango.FontDescription.c_new();
270 description.set_size(8000);
271 this.el.modify_font(description);
273 this.selection = this.el.get_selection();
274 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
276 this.selection.signal['changed'].connect(function() {
277 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
278 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
282 Gtk.drag_source_set (
283 this.el, /* widget will be drag-able */
284 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
285 null, /* lists of target to support */
286 0, /* size of list */
287 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
290 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
292 Gtk.drag_source_add_text_targets(this.el);
295 this.el, /* widget that will accept a drop */
296 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
297 null, /* lists of target to support */
298 0, /* size of list */
299 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
302 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
303 Gtk.drag_dest_add_text_targets(this.el);
305 highlight : function(treepath_ar) {
306 if (treepath_ar.length && treepath_ar[0].length ) {
307 this.el.set_drag_dest_row(
308 new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);
310 this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
314 selectNode : function(treepath_str) {
315 //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
316 var tp = new Gtk.TreePath.from_string(treepath_str);
317 this.el.set_cursor(tp, null, false);
318 this.el.scroll_to_cell(tp, null, false, 0,0);
321 "button_press_event":function (self, ev) {
322 console.log("button press?");
323 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
324 print("click" + ev.type);
330 this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
332 if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();
334 this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
335 this.get('/LeftTreeMenu').el.show_all();
336 this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
337 print("click:" + res.path.to_string());
340 "drag_begin":function (self, drag_context) {
341 print('SOURCE: drag-begin');
342 this.targetData = false;
343 // find what is selected in our tree...
344 var iter = new Gtk.TreeIter();
345 var s = this.selection;
346 s.get_selected(this.get('/LeftTree.model').el, iter);
348 // set some properties of the tree for use by the dropped element.
349 var value = new GObject.Value('');
350 this.get('/LeftTree.model').el.get_value(iter, 2, value);
351 var data = JSON.parse(value.value);
352 var xname = this.get('/LeftTree.model').file.guessName(data);
354 this.el.dragData = xname;
355 this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);
358 // make the drag icon a picture of the node that was selected
359 var path = this.get('/LeftTree.model').el.get_path(iter);
360 this.el.treepath = path.to_string();
362 var pix = this.el.create_row_drag_icon ( path);
364 Gtk.drag_set_icon_pixmap (ctx,
373 "drag_end":function (self, drag_context) {
374 Seed.print('LEFT-TREE: drag-end');
375 this.el.dragData = false;
376 this.el.dropList = false;
377 this.targetData = false;
378 this.get('/LeftTree.view').highlight(false);
381 "drag_motion":function (self, ctx, x, y, time) {
382 console.log("LEFT-TREE: drag-motion");
383 var src = Gtk.drag_get_source_widget(ctx);
385 // a drag from elsewhere...- prevent drop..
387 print("no drag data!");
388 Gdk.drag_status(ctx, 0, time);
389 this.targetData = false;
392 var action = Gdk.DragAction.COPY;
393 if (src == this.el) {
394 // unless we are copying!!! ctl button..
395 action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
399 if (!this.get('/LeftTree.model').el.iter_n_children(null)) {
400 // no children.. -- asume it's ok..
401 this.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];
402 Gdk.drag_status(ctx, action ,time);
406 print("GETTING POS");
407 var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);
408 print("ISOVER? " + isOver);
410 Gdk.drag_status(ctx, 0 ,time);
411 return false; // not over apoint!?!
413 // drag node is parent of child..
414 console.log("SRC TREEPATH: " + src.treepath);
415 console.log("TARGET TREEPATH: " + data.path.to_string());
417 // nned to check a few here..
418 //Gtk.TreeViewDropPosition.INTO_OR_AFTER
419 //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
420 //Gtk.TreeViewDropPosition.AFTER
421 //Gtk.TreeViewDropPosition.BEFORE
423 if (typeof(src.treepath) != 'undefined' &&
424 src.treepath == data.path.to_string().substring(0,src.treepath.length)) {
425 print("subpath drag");
426 Gdk.drag_status(ctx, 0 ,time);
431 //print("DUMPING DATA");
432 //console.dump(data);
435 print(data.path.to_string() +' => '+ data.pos);
436 var tg = this.get('/LeftTree.model').findDropNodeByPath(
437 data.path.to_string(), src.dropList, data.pos);
439 this.get('/LeftTree.view').highlight(tg);
441 print("Can not find drop node path");
442 this.targetData = false;
443 Gdk.drag_status(ctx, 0, time);
447 this.targetData = tg;
450 Gdk.drag_status(ctx, action ,time);
454 "drag_drop":function (w, ctx, x, y, time) {
455 Seed.print("TARGET: drag-drop");
459 w, /* will receive 'drag-data-received' signal */
460 ctx, /* represents the current state of the DnD */
461 this.get('/Window').atoms["STRING"], /* the target type we want */
462 time /* time stamp */
466 /* No target offered by source => error */
471 "drag_data_received":function (self, ctx, x, y, sel_data, info, time) {
472 print("Tree: drag-data-received");
474 var delete_selection_data = false;
475 var dnd_success = false;
476 /* Deal with what we are given from source */
477 if( sel_data && sel_data.length ) {
479 if (ctx.action == Gdk.DragAction.ASK) {
480 /* Ask the user to move or copy, then set the ctx action. */
483 if (ctx.action == Gdk.DragAction.MOVE) {
484 //delete_selection_data = true;
487 var source = Gtk.drag_get_source_widget(ctx);
489 if (this.targetData) {
490 if (source != this.el) {
491 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
493 // drag around.. - reorder..
494 this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);
498 //Seed.print(this.targetData);
504 // we can send stuff to souce here...
510 if (dnd_success == false)
512 Seed.print ("DnD data transfer failed!\n");
515 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
518 "cursor_changed":function (self) {
519 if (this.blockChanges) {
522 var iter = new Gtk.TreeIter();
524 if (this.selection.count_selected_rows() < 1) {
525 this.get('/LeftPanel.model').load( false);
526 this.get('/MidPropTree').activeElement = false;
527 this.get('/MidPropTree').hideWin();
529 var pm = this.get('/RightPalete.model');
530 if (!this.get('/LeftTree').getPaleteProvider()) {
531 // it may not be loaded yet..
534 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
535 this.get('/LeftTree.model').listAllTypes()));
540 //console.log('changed');
541 var s = this.selection;
542 s.get_selected(this.get('/LeftTree.model').el, iter);
546 value = new GObject.Value('');
547 this.get('/LeftTree.model').el.get_value(iter, 2, value);
548 this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
550 var data = JSON.parse(value.value);
551 this.get('/MidPropTree').activeElement = data;
552 this.get('/MidPropTree').hideWin();
553 this.get('/LeftPanel.model').load( data);
555 console.log(value.value);
556 // _g.button.set_label(''+value.get_string());
558 var pm =this.get('/RightPalete.model');
559 pm.load( this.get('/RightPalete').provider.gatherList(
560 this.get('/LeftTree.model').listAllTypes()));
565 //Seed.print( value.get_string());
572 xtype: Gtk.TreeStore,
576 XObject.prototype.init.call(this);
577 this.el.set_column_types ( 3, [
578 GObject.TYPE_STRING, // title
579 GObject.TYPE_STRING, // tip
580 GObject.TYPE_STRING // source..
584 changed : function(n, refresh) {
585 print("MODEL CHANGED CALLED" + this.activePath);
586 if (this.activePath) {
587 var iter = new Gtk.TreeIter();
588 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
589 this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
590 this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
592 this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
594 //this.currentTree = this.toJS(false, true)[0];
595 this.file.items = this.toJS(false, false);
596 print("AFTER CHANGED");
597 //console.dump(this.file.items);
599 this.currentTree = this.file.items[0];
600 //console.log(this.file.toSource());
603 print("REDNER BROWSER?!");
604 this.get('/LeftTree').renderView();
606 var pm = this.get('/RightPalete.model');
607 if (!this.get('/RightPalete').provider) {
613 pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
614 //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
618 loadFile : function(f) {
624 console.log('missing file');
628 // load the file if not loaded..
629 if (f.items === false) {
631 f.loadItems(function() {
637 if (f.items.length && typeof(f.items[0]) == 'string') {
639 this.get('/RightEditor').el.show();
640 this.get('/RightEditor.view').load( f.items[0]);
644 //console.dump(f.items);
646 this.get('/LeftTree.view').el.expand_all();
648 if (!f.items.length) {
651 this.get('/Window.leftvpaned').el.set_position(80);
653 this.get('/LeftTree.view').el.set_cursor(
654 new Gtk.TreePath.from_string('0'), null, false);
658 this.get('/Window.leftvpaned').el.set_position(200);
662 //print("hide right editior");
663 this.get('/RightEditor').el.hide();
664 //print("set current tree");
665 this.currentTree = this.toJS(false, false)[0];
666 //console.dump(this.currentTree);
667 this.currentTree = this.currentTree || { items: [] };
668 this.get('/LeftTree').renderView();
669 //console.dump(this.map);
670 //var RightPalete = imports.Builder.RightPalete.RightPalete;
671 var pm = this.get('/RightPalete.model');
674 this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
676 if (!this.get('/RightPalete').provider) {
677 print ("********* PALETE PROVIDER MISSING?!!");
679 this.get('/LeftTree').renderView();
681 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
685 this.get('/Window.view-notebook').el.set_current_page(
686 this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
689 findDropNode : function(treepath_str, targets) {
691 // this is used by the dragdrop code in the roo version AFAIR..
693 var path = treepath_str.replace(/^builder-/, '');
694 // treemap is depreciated... - should really check if model has any entries..
696 if (!this.el.iter_n_children(null)) {
698 return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];
700 print("FIND treepath: " + path);
701 //console.dump(this.treemap);
703 if (!treepath_str.match(/^builder-/)) {
704 return []; // nothing!
706 if (targets === true) {
709 return this.findDropNodeByPath(path,targets)
711 findDropNodeByPath : function(treepath_str, targets, pref) {
712 var path = treepath_str + ''; // dupe it..
713 pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
715 //console.dump(this.treemap);
716 while (path.length) {
717 print("LOOKING FOR PATH: " + path);
718 var node_data = this.singleNodeToJS(path);
719 if (node_data === false) {
720 print("node not found");
724 var xname = this.get('/LeftTree.model').file.guessName(node_data);
727 targets.forEach(function(tg) {
731 if ((tg == xname) ) {
734 if (tg.indexOf(xname +':') === 0) {
736 prop = tg.split(':').pop();
741 if (last) { // pref is after/before..
742 // then it's after last
744 return []; // do not allow..
746 return [ last, pref , prop];
749 return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
751 var par = path.split(':');
754 path = par.join(':');
760 dropNode : function(target_data, node) {
763 console.dump(target_data);
764 var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
766 print("add " + tp + "@" + target_data[1] );
769 if (tp && target_data[1] < 2) { // before or after..
770 var ar = target_data[0].split(':');
772 parent = new Gtk.TreePath.from_string( ar.join(':') );
775 var n_iter = new Gtk.TreeIter();
776 var iter_par = new Gtk.TreeIter();
777 var iter_after = after ? new Gtk.TreeIter() : false;
781 if (parent !== false) {
782 this.el.get_iter(iter_par, parent);
789 print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
790 this.el.get_iter(iter_after, after);
791 this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
792 n_iter, iter_par, iter_after);
795 this.el.append(n_iter, iter_par);
799 if (typeof(node) == 'string') {
800 var ar = node.split('.');
801 var xtype = ar.pop();
804 '|xns' : ar.join('.'),
807 if (target_data.length == 3 && target_data[2].length) {
808 node['*prop'] = target_data[2];
812 // work out what kind of packing to use..
813 if (typeof(node.pack) == 'undefined' && parent !== false) {
814 var pal = this.get('/LeftTree').getPaleteProvider();
816 var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
817 print ("PNAME : " + pname);
818 var cname = pal.guessName(node);
819 print ("CNAME : " + cname);
820 node.pack = pal.getDefaultPack(pname, cname);
831 // load children - if it has any..
834 this.load(xitems, n_iter);
836 if (tp && (xitems || after)) {
837 this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
839 // wee need to get the empty proptypes from somewhere..
841 //var olditer = this.activeIter;
842 this.activePath = this.el.get_path(n_iter).to_string();
844 // changed actually set's the node data..
845 this.changed(node, true);
849 this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
851 //Builder.MidPropTree._model.load(node);
852 //Builder.MidPropTree._win.hideWin();
853 //Builder.LeftPanel._model.load( node);
857 moveNode : function(target_data, action) {
858 //print("MOVE NODE");
859 // console.dump(target_data);
860 var old_iter = new Gtk.TreeIter();
861 var s = this.get('/LeftTree.view').selection;
862 s.get_selected(this.el, old_iter);
863 var node = this.nodeToJS(old_iter,false);
864 //console.dump(node);
867 // needs to drop first, otherwise the target_data
868 // treepath will be invalid.
870 this.dropNode(target_data, node);
871 if (action & Gdk.DragAction.MOVE) {
872 // print("REMOVING OLD NODE");
873 this.el.remove(old_iter);
877 this.activeIter = false;
878 this.changed(false,true);
880 deleteSelected : function() {
881 this.get('/LeftTree.view').blockChanges = true;
882 var old_iter = new Gtk.TreeIter();
883 var s = this.get('/LeftTree.view').selection;
884 s.get_selected(this.el, old_iter);
885 var path = this.el.get_path(old_iter).to_string();
886 print("DELETE " + path);
887 this.activeIter = false;
890 this.activeIter = false;
891 var iter = new Gtk.TreeIter();
892 this.el.get_iter_from_string(iter, path);
893 this.el.remove(iter);
895 // rebuild treemap. -- depreciated.!!
898 //this.toJS(null, true) // does not do anything?
900 this.changed(false,true);
901 this.get('/LeftTree.view').blockChanges = false;
904 listAllTypes : function() {
905 var s = this.get('/LeftTree.view').selection;
906 print ("LIST ALL TYPES: " + s.count_selected_rows() );
908 if (s.count_selected_rows() > 0) {
909 var iter = new Gtk.TreeIter();
910 s.get_selected(this.el, iter);
912 // set some properties of the tree for use by the dropped element.
913 var value = new GObject.Value('');
914 this.el.get_value(iter, 2, value);
915 var data = JSON.parse(value.value);
918 var xname = this.get('/LeftTree.model').file.guessName(data);
919 console.log('selected:' + xname);
923 return []; // could not find it..
931 li.forEach(function(el) {
932 // this is specific to roo!!!?
934 var fullpath = _this.file.guessName(el);
935 if (fullpath.length && ret.indexOf(fullpath) < 0) {
940 if (el.items && el.items.length) {
949 addall([this.currentTree]);
951 // only if we have nothing, should we add '*top'
955 //console.log('all types in tree');
961 singleNodeToJS : function (treepath)
963 var iter = new Gtk.TreeIter();
964 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
968 var iv = this.getIterValue(iter, 2);
970 return JSON.parse(iv);
973 nodeToJS : function (iter, with_id)
975 var par = new Gtk.TreeIter();
976 var iv = this.getIterValue(iter, 2);
978 var k = JSON.parse(iv);
979 if (k.json && !this.el.iter_parent( par, iter )) {
984 var treepath_str = this.el.get_path(iter).to_string();
985 // not sure how we can handle mixed id stuff..
986 if (typeof(k.id) == 'undefined') {
987 k.id = 'builder-'+ treepath_str ;
991 this.treemap[ treepath_str ] = k;
992 k.xtreepath = treepath_str ;
995 if (this.el.iter_has_child(iter)) {
996 citer = new Gtk.TreeIter();
997 this.el.iter_children(citer, iter);
998 k.items = this.toJS(citer,with_id);
1002 toJS : function(iter, with_id)
1004 //Seed.print("WITHID: "+ with_id);
1011 iter = new Gtk.TreeIter();
1012 if (!this.el.get_iter_first(iter)) {
1022 var k = this.nodeToJS(iter, with_id);
1026 if (!this.el.iter_next(iter)) {
1032 // convert the list into a json string..
1036 getIterValue : function (iter, col) {
1037 var gval = new GObject.Value('');
1038 this.el.get_value(iter, col ,gval);
1043 nodeTitle : function(c) {
1046 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
1047 if (sr) txt.push('<s>');
1048 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
1049 if (c.xtype) { txt.push(c.xtype); }
1050 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1051 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1052 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1055 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1056 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1057 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1058 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1059 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1060 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1061 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1062 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1063 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1065 // for flat classes...
1066 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1067 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1070 if (sr) txt.push('</s>');
1071 return (txt.length == 0 ? "Element" : txt.join(" "));
1073 nodeToJSON : function(c) {
1081 return JSON.stringify(o);
1083 load : function(tr,iter)
1085 var citer = new Gtk.TreeIter();
1086 //this.insert(citer,iter,0);
1087 for(var i =0 ; i < tr.length; i++) {
1089 this.el.insert(citer,iter,-1);
1091 this.el.append(citer);
1094 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1095 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1096 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1097 if (tr[i].items && tr[i].items.length) {
1098 this.load(tr[i].items, citer);
1104 xtype: Gtk.TreeViewColumn,
1105 pack : "append_column",
1107 XObject.prototype.init.call(this);
1108 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1112 xtype: Gtk.CellRendererText,
1122 id : "LeftTreeMenu",
1125 xtype: Gtk.MenuItem,
1127 label : "Delete Element",
1129 "activate":function (self) {
1131 this.get('/LeftTree.model').deleteSelected();
1142 id : "LeftProjectTree",
1143 showNoProjectSelected : function() {
1144 this.get('/StandardErrorDialog').show("Select a Project first.");
1146 getActiveProject : function() {
1147 return this.project;
1150 "leave_notify_event":function (self, event) {
1157 pack : "pack_start,false,false",
1160 xtype: Gtk.ComboBox,
1163 XObject.prototype.init.call(this);
1164 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1166 getValue : function() {
1167 var ix = this.el.get_active();
1171 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1174 setValue : function(fn)
1178 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1179 data.forEach(function(n, ix) {
1187 "changed":function (self) {
1188 var fn = this.getValue();
1189 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1190 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1195 xtype: Gtk.CellRendererText,
1196 pack : "pack_start,true",
1200 xtype: Gtk.ListStore,
1203 XObject.prototype.init.call(this);
1204 this.el.set_column_types ( 2, [
1205 GObject.TYPE_STRING, // real key
1206 GObject.TYPE_STRING // real type
1212 loadData : function(data) {
1213 var ov = this.get('/LeftProjectTree.combo').getValue();
1215 var iter = new Gtk.TreeIter();
1217 data.forEach(function(p) {
1222 el.set_value(iter, 0, p.fn);
1223 el.set_value(iter, 1, p.name);
1227 this.get('/LeftProjectTree.combo').setValue(ov);
1236 xtype: Gtk.ScrolledWindow,
1238 shadow_type : Gtk.ShadowType.IN,
1240 XObject.prototype.init.call(this);
1241 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1245 xtype: Gtk.TreeView,
1246 headers_visible : false,
1247 enable_tree_lines : true,
1250 XObject.prototype.init.call(this);
1251 var description = new Pango.FontDescription.c_new();
1252 description.set_size(8000);
1253 this.el.modify_font(description);
1255 this.selection = this.el.get_selection();
1256 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1260 "cursor_changed":function (self) {
1261 var iter = new Gtk.TreeIter();
1263 if (this.selection.count_selected_rows() < 1) {
1264 //XN.get('Builder.LeftTree.model').
1265 this.get('/LeftTree.model').load( false);
1269 var model = this.get('/LeftProjectTree.model');
1270 //console.log('changed');
1271 var s = this.selection;
1272 s.get_selected(model, iter);
1273 value = new GObject.Value('');
1274 model.el.get_value(iter, 2, value);
1276 console.log(value.value);// id..
1278 var file = this.get('/LeftProjectTree').project.getById(value.value);
1285 var nb = this.get('/LeftTopPanel.expander');
1286 nb.el.expanded = false;
1287 nb.listeners.activate.call(nb);
1288 //_expander.el.set_expanded(false);
1290 var ltm = this.get('/LeftTree.model');
1298 xtype: Gtk.TreeStore,
1302 XObject.prototype.init.call(this);
1303 this.el.set_column_types ( 3, [
1304 GObject.TYPE_STRING, // title
1305 GObject.TYPE_STRING, // tip
1306 GObject.TYPE_STRING // id..
1310 loadProject : function(pr) {
1315 this.get('/LeftProjectTree').project = pr;
1316 this.load(pr.toTree());
1317 this.get('/LeftProjectTree.view').el.expand_all();
1319 load : function(tr,iter) {
1321 console.log('Project tree load: ' + tr.length);
1322 var citer = new Gtk.TreeIter();
1323 //this.insert(citer,iter,0);
1326 tr.forEach(function (r) {
1328 _this.el.append(citer);
1330 _this.el.insert(citer,iter,-1);
1332 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1333 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1334 _this.el.set_value(citer, 2, '' + r.id ); //id
1335 if (r.cn && r.cn.length) {
1336 _this.load(r.cn, citer);
1341 getValue : function(iter, col) {
1342 var gval = new GObject.Value('');
1343 this.el.get_value(iter, col ,gval);
1344 return '' + gval.value;
1348 xtype: Gtk.TreeViewColumn,
1349 pack : "append_column",
1351 XObject.prototype.init.call(this);
1352 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1356 xtype: Gtk.CellRendererText,
1379 pack : "pack_start,false,true,0",
1386 "button_press_event":function (self, event) {
1387 this.get('/MidPropTree.model').showData('props');
1399 stock : Gtk.STOCK_ADD,
1400 icon_size : Gtk.IconSize.MENU
1415 "button_press_event":function (self, event) {
1416 this.get('/MidPropTree.model').showData('events');
1428 stock : Gtk.STOCK_ADD,
1429 icon_size : Gtk.IconSize.MENU
1444 "button_press_event":function (self, ev) {
1445 var p = this.get('/AddPropertyPopup');
1449 p.el.set_screen(Gdk.Screen.get_default());
1451 p.el.popup(null, null, null, null, 3, ev.button.time);
1463 stock : Gtk.STOCK_ADD,
1464 icon_size : Gtk.IconSize.MENU
1476 id : "AddPropertyPopup",
1479 xtype: Gtk.MenuItem,
1481 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1484 "activate":function (self) {
1486 this.get('/LeftPanel.model').add( {
1497 xtype: Gtk.MenuItem,
1499 tooltip_markup : "Add what type of packing is to be used",
1502 "activate":function (self) {
1504 this.get('/LeftPanel.model').add( {
1514 xtype: Gtk.MenuItem,
1516 tooltip_markup : "Override the init method",
1519 "activate":function (self) {
1521 this.get('/LeftPanel.model').add( {
1524 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1531 xtype: Gtk.SeparatorMenuItem,
1535 xtype: Gtk.MenuItem,
1537 tooltip_markup : "Add a user defined string property",
1540 "activate":function (self) {
1542 this.get('/LeftPanel.model').add( {
1552 xtype: Gtk.MenuItem,
1554 tooltip_markup : "Add a user defined number property",
1557 "activate":function (self) {
1559 this.get('/LeftPanel.model').add( {
1569 xtype: Gtk.MenuItem,
1571 tooltip_markup : "Add a user defined boolean property",
1574 "activate":function (self) {
1576 this.get('/LeftPanel.model').add( {
1586 xtype: Gtk.SeparatorMenuItem,
1590 xtype: Gtk.MenuItem,
1592 tooltip_markup : "Add a user function boolean property",
1595 "activate":function (self) {
1597 this.get('/LeftPanel.model').add( {
1600 val : "function() {\n \n}\n",
1613 xtype: Gtk.ScrolledWindow,
1616 shadow_type : Gtk.ShadowType.IN,
1619 XObject.prototype.init.call(this);
1620 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1624 xtype: Gtk.TreeView,
1627 headers_visible : false,
1628 enable_tree_lines : true,
1630 XObject.prototype.init.call(this);
1632 this.selection = this.el.get_selection();
1633 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1636 var description = new Pango.FontDescription.c_new();
1637 description.set_size(8000);
1638 this.el.modify_font(description);
1641 "button_press_event":function (self, ev) {
1645 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1646 return false; //not on a element.
1650 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1652 if (res.column.title != 'value') {
1653 return false; // ignore..
1655 if ( this.get('/LeftPanel').editing) {
1658 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1659 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1660 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1664 var provider = this.get('/LeftTree').getPaleteProvider();
1666 var opts = provider.findOptions(type);
1668 if (opts === false) {
1669 this.get('/LeftPanel').editableColumn.setOptions([]);
1670 renderer.has_entry = true;
1672 LeftPanel.editableColumn.setOptions(opts);
1673 renderer.has_entry = false;
1677 //Seed.print("click" + ev.type);
1678 //console.dump(res);
1684 if (res.column.title == 'value') {
1687 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1688 var p = this.get('/LeftPanelPopup');
1693 p.el.set_screen(Gdk.Screen.get_default());
1695 p.el.popup(null, null, null, null, 3, ev.button.time);
1696 //Seed.print("click:" + res.column.title);
1704 xtype: Gtk.TreeStore,
1708 XObject.prototype.init.call(this);
1709 this.el.set_column_types ( 5, [
1710 GObject.TYPE_STRING, // 0 real key
1711 GObject.TYPE_STRING, // 1 real value
1712 GObject.TYPE_STRING, // 2 visable key
1713 GObject.TYPE_STRING, // 3 visable value
1714 GObject.TYPE_STRING, // 4 need to store type of!!!
1718 toShort : function(str) {
1719 var a = typeof(str) == 'string' ? str.split("\n") : [];
1720 return a.length > 1 ? a[0] + '....' : '' + str;
1722 load : function(ar) {
1725 this.get('/RightEditor').el.hide();
1732 var provider = this.get('/LeftTree').getPaleteProvider();
1735 var iter = new Gtk.TreeIter();
1737 if (typeof(ar[i]) == 'object') {
1741 var type = provider.findType(ar, i, ar[i]);
1743 this.el.append(iter);
1744 var p = this.el.get_path(iter).to_string();
1746 this.el.set_value(iter, 0, i);
1747 this.el.set_value(iter, 1, '' + ar[i]);
1748 this.el.set_value(iter, 2, i);
1749 this.el.set_value(iter, 3, this.toShort(ar[i]));
1750 this.el.set_value(iter, 4, type);
1752 ar.listeners = ar.listeners || {};
1753 for (var i in ar.listeners ) {
1754 this.el.append(iter);
1755 var p = this.el.get_path(iter).to_string();
1758 this.el.set_value(iter, 0, '!'+ i );
1759 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1760 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1762 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1763 this.el.set_value(iter, 4, 'function');
1767 add : function(info) {
1768 // info includes key, val, skel, etype..
1770 type = info.type.toLowerCase();
1771 var data = this.toJS();
1773 if (info.etype == 'events') {
1774 data.listeners = data.listeners || { };
1775 if (typeof(data.listeners[info.key]) != 'undefined') {
1776 return; //already set!
1779 if (typeof(data[info.key]) != 'undefined') {
1784 if (typeof(info.val) == 'undefined') {
1787 if (info.type == 'boolean') {
1790 if (type == 'number') {
1798 if (info.etype == 'events') {
1800 data.listeners[info.key] = info.val;
1803 data[info.key] = info.val;
1807 var map = this.load(data);
1809 // flag it as changed to the interface..
1811 this.get('/LeftTree.model').changed(data, true);
1814 this.startEditing(map[k]);
1817 LeftPanel.get('view').el.row_activated(
1818 new Gtk.TreePath.from_string(map[k]),
1819 LeftPanel.editableColumn.el
1823 startEditing : function(path,col) {
1825 * start editing path (or selected if not set..)
1826 * @param {String|false} path (optional) treepath to edit - selected tree gets
1827 * edited by default.
1828 * @param {Number} 0 or 1 (optional)- column to edit.
1831 if (typeof(path) == 'string') {
1832 tp = new Gtk.TreePath.from_string(path);
1834 var iter = new Gtk.TreeIter();
1835 var s = this.get('/LeftPanel.view').selection;
1836 s.get_selected(this.el, iter);
1837 tp = this.el.get_path(iter);
1838 path = tp.to_string();
1842 // which colum is to be edited..
1844 if (typeof(col) == 'undefined') {
1845 var k = this.getValue(path, 0);
1846 colObj = (!k.length || k == '|') ?
1847 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1849 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1852 // make sure the pulldown is set correctly..
1853 // not really needed for second col...
1855 var provider = this.get('/LeftTree').getPaleteProvider();
1857 var type = this.get('/LeftPanel.model').getType(path);
1858 var opts = provider.findOptions(type);
1859 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1861 if (opts === false) {
1862 this.get('/LeftPanel').editableColumn.setOptions([]);
1863 renderer.has_entry = true; /// probably does not have any effect.
1865 this.get('/LeftPanel').editableColumn.setOptions(opts);
1866 renderer.has_entry = false;
1870 // iter now has row...
1871 GLib.timeout_add(0, 100, function() {
1873 colObj.items[0].el.editable = true; // esp. need for col 0..
1874 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1883 deleteSelected : function() {
1884 var data = this.toJS();
1885 var iter = new Gtk.TreeIter();
1886 var s = this.get('/LeftPanel.view').selection;
1887 s.get_selected(this.el, iter);
1890 var gval = new GObject.Value('');
1891 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1893 var val = gval.value;
1894 if (val[0] == '!') {
1896 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1899 delete data.listeners[ val.substring(1)];
1900 if (!XObject.keys(data.listeners).length) {
1901 delete data.listeners;
1905 if (typeof(data[val]) == 'undefined') {
1913 this.get('/LeftTree.model').changed(data, true);
1917 changed : function(str, doRefresh) {
1918 if (!this.activePath) {
1921 var iter = new Gtk.TreeIter();
1922 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1924 this.el.set_value(iter, 1, '' +str);
1925 this.el.set_value(iter, 3, '' + this.toShort(str));
1926 // update the tree...
1928 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
1931 var iter = new Gtk.TreeIter();
1932 this.get('/LeftPanel.model').el.get_iter_first(iter);
1937 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
1940 ar.listeners = ar.listeners || {};
1941 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
1944 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
1947 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
1953 //print(JSON.stringify(ar));
1957 getType : function(treepath) {
1958 return this.getValue(treepath, 4);
1960 getValue : function(treepath_str, col) {
1961 var iter = new Gtk.TreeIter();
1962 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
1964 var gval = new GObject.Value('');
1965 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
1966 var val = '' + gval.value;
1970 var type = this.getType(this.el.get_path(iter).to_string());
1971 //print("TYPE: " +type + " - val:" + val);
1972 switch(type.toLowerCase()) {
1976 return parseFloat(val); // Nan ?? invalid!!?
1978 return val == 'true' ? true : false;
1984 editSelected : function(e) {
1985 print("EDIT SELECTED?");
1986 var iter = new Gtk.TreeIter();
1987 var s = this.get('/LeftPanel.view').selection;
1988 s.get_selected(this.get('/LeftPanel.model').el, iter);
1989 var m = this.get('/LeftPanel.model')
1991 var gval = new GObject.Value('');
1992 this.el.get_value(iter, 0 ,gval);
1993 var val = '' + gval.value;
1995 gval = new GObject.Value('');
1996 this.el.get_value(iter, 1 ,gval);
1997 var rval = gval.value;
1998 var activePath = this.el.get_path(iter).to_string();
1999 this.activePath = activePath ;
2000 // was activeIter...
2003 var showEditor = false;
2005 if (val[0] == '!') {
2008 if (val[0] == '|') {
2009 if (rval.match(/function/g) || rval.match(/\n/g)) {
2016 this.activePath = false;
2017 GLib.timeout_add(0, 1, function() {
2018 // Gdk.threads_enter();
2019 _this.get('/RightEditor').el.show();
2020 _this.get('/RightEditor.view').load( rval );
2024 _this.activePath = activePath ;
2026 // Gdk.threads_leave();
2032 this.get('/RightEditor').el.hide();
2034 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2040 xtype: Gtk.TreeViewColumn,
2041 pack : "append_column",
2043 XObject.prototype.init.call(this);
2045 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2046 this.get('/LeftPanel').propertyColumn = this;
2051 xtype: Gtk.CellRendererText,
2052 pack : "pack_start",
2054 "editing_started":function (self, editable, path) {
2056 this.get('/LeftPanel.model').activePath = path;
2059 "edited":function (self, object, p0) {
2060 var model = this.get('/LeftPanel.model');
2061 var path = model.activePath;
2062 var iter = new Gtk.TreeIter();
2063 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2064 model.el.set_value(iter, 0, p0);
2065 model.el.set_value(iter, 2, p0);
2067 model.activePath = false;
2069 this.get('/LeftTree.model').changed(model.toJS(), true);
2070 this.el.editable = false;
2077 xtype: Gtk.TreeViewColumn,
2078 pack : "append_column",
2080 XObject.prototype.init.call(this);
2081 this.el.add_attribute(this.items[0].el , 'text', 3 );
2082 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2083 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2084 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2086 this.get('/LeftPanel').editableColumn= this;
2088 setOptions : function(ar) {
2089 var m = this.items[0].el.model;
2091 var iter = new Gtk.TreeIter();
2092 ar.forEach(function(i) {
2095 m.set_value(iter, 0, i);
2101 xtype: Gtk.CellRendererCombo,
2102 pack : "pack_start",
2107 XObject.prototype.init.call(this);
2108 this.el.model = new Gtk.ListStore();
2109 this.el.model.set_column_types ( 1, [
2110 GObject.TYPE_STRING // 0 real key
2114 "edited":function (self, object, p0) {
2115 this.get('/LeftPanel').editing = false;
2116 print("EDITED? p:" + p0 + " t:" + p0);
2117 this.get('/LeftPanel.model').changed(p0, true);
2118 this.get('/LeftPanel.model').activePath = false;
2120 "editing_started":function (self, editable, path) {
2121 this.get('/LeftPanel').editing = true;
2122 // console.log('editing started');
2123 // r.has_entry = false;
2124 this.get('/LeftPanel.model').editSelected(editable);
2135 id : "LeftPanelPopup",
2138 xtype: Gtk.MenuItem,
2142 "activate":function (self) {
2143 this.get('/LeftPanel.model').deleteSelected();
2148 xtype: Gtk.MenuItem,
2152 "activate":function (self) {
2153 this.get('/LeftPanel.model').startEditing(false, 0);
2166 xtype: Gtk.ScrolledWindow,
2167 pack : "pack_end,false,true,0",
2169 shadow_type : Gtk.ShadowType.IN,
2171 XObject.prototype.init.call(this);
2172 XObject.prototype.init.call(this);
2173 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2174 this.el.set_size_request ( 150, -1 );
2177 activeElement : false,
2178 hideWin : function() {
2185 if (this.get('/Window.left').el.position < 160) {
2188 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2195 xtype: Gtk.TreeView,
2196 enable_tree_lines : true,
2197 headers_visible : false,
2200 XObject.prototype.init.call(this);
2202 var description = new Pango.FontDescription.c_new();
2203 description.set_size(8000);
2204 this.el.modify_font(description);
2206 //this.selection = this.el.get_selection();
2207 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2216 "cursor_changed":function (self) {
2217 var iter = new Gtk.TreeIter();
2219 //console.log('changed');
2220 var m = this.get('model');
2221 if (!this.selection){
2222 this.selection = this.el.get_selection();
2225 var s = this.selection;
2226 if (!s.get_selected(m.el, iter)) {
2229 var tp = m.el.get_path(iter).to_string();
2234 var key = m.getValue(tp, 0);
2236 var type = m.getValue(tp, 1);
2237 var skel = m.getValue(tp, 3);
2238 var etype = m.getValue(tp, 5);
2241 this.get('/MidPropTree').hideWin();
2243 if (type == 'function') {
2245 if (etype != 'events') {
2249 this.get('/LeftPanel.model').add({
2258 if (type.indexOf('.') > -1 ||
2259 type == 'boolean') {
2263 this.get('/LeftPanel.model').add( {
2273 xtype: Gtk.ListStore,
2276 XObject.prototype.init.call(this);
2277 this.el.set_column_types ( 6, [
2278 GObject.TYPE_STRING, // real key
2279 GObject.TYPE_STRING, // real type
2280 GObject.TYPE_STRING, // docs ?
2281 GObject.TYPE_STRING, // visable desc
2282 GObject.TYPE_STRING, // function desc
2283 GObject.TYPE_STRING // element type (event|prop)
2287 getValue : function(treepath, col)
2289 var tp = new Gtk.TreePath.from_string (treepath);
2290 var iter = new Gtk.TreeIter();
2291 this.el.get_iter (iter, tp);
2292 var value = new GObject.Value('');
2293 this.el.get_value(iter, col, value);
2297 showData : function(type) {
2299 if (!this.get('/MidPropTree').activeElement || !type) {
2300 return; // no active element
2303 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2304 var palete = this.get('/LeftTree').getPaleteProvider();
2308 Seed.print('Showing right?');
2309 if (!this.get('/MidPropTree').shown) {
2311 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2312 this.get('/MidPropTree').el.show();
2313 this.get('/MidPropTree').shown = true;
2316 var elementList = palete.getPropertiesFor(fullpath, type);
2317 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2318 // console.dump(elementList);
2321 var iter = new Gtk.TreeIter();
2322 for(var i =0 ; i < elementList.length; i++) {
2323 var p=elementList[i];
2324 this.el.append(iter);
2325 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2326 //GObject.TYPE_STRING, // real key
2327 // GObject.TYPE_STRING, // real type
2328 // GObject.TYPE_STRING, // docs ?
2329 // GObject.TYPE_STRING // func def?
2332 this.el.set_value(iter, 0, p.name);
2333 this.el.set_value(iter, 1, p.type);
2334 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2335 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2336 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2337 this.el.set_value(iter, 5, type);
2345 xtype: Gtk.TreeViewColumn,
2347 this.el = new Gtk.TreeViewColumn();
2348 this.parent.el.append_column(this.el);
2350 XObject.prototype.init.call(this);
2351 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2356 xtype: Gtk.CellRendererText,
2357 pack : "pack_start,true"
2381 xtype: Gtk.Notebook,
2382 pack : "pack_start,true,true",
2383 id : "view-notebook",
2386 XObject.prototype.init.call(this);
2387 this.el.set_current_page(0);
2389 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2390 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2397 id : "RightBrowser",
2401 pack : "pack_start,false,true,0",
2405 pack : "pack_start,false,false,0",
2406 label : "Dump HTML to console",
2408 "activate":function (self) {
2409 this.get('/RightBrowser.view').el.execute_script(
2410 "console.log(document.body.innerHTML);");
2411 this.get('/RightBrowser.view').el.execute_script(
2412 "console.log(Builder.dump(Builder));");
2419 xtype: Gtk.ScrolledWindow,
2421 shadow_type : Gtk.ShadowType.IN,
2423 XObject.prototype.init.call(this);
2424 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2428 xtype: WebKit.WebView,
2432 XObject.prototype.init.call(this);
2433 // this may not work!?
2434 this.el.open('file:///' + __script_path__ + '/../builder.html');
2438 this.el, /* widget that will accept a drop */
2439 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2440 null, /* lists of target to support */
2441 0, /* size of list */
2442 Gdk.DragAction.COPY /* what to do with data after dropped */
2445 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2446 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2448 renderJS : function(data) {
2449 this.renderedData = data;
2450 var str = JSON.stringify(data) ;
2453 console.log('not loaded yet');
2455 Seed.print("RENDER:" + str);
2456 imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2457 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2460 "load_finished":function (self, object) {
2461 if (this.ready) { // dont do it twice!
2466 this.renderJS(this.get('/LeftTree.model').toJS()[0]);
2468 "script_alert":function (self, object, p0) {
2471 return true; // do not display anything...
2473 "console_message":function (self, object, p0, p1) {
2474 console.log(object);
2475 if (!object.match(/^\{/)) {
2476 return false; // do not handle!!! -> later maybe in console..
2478 console.log(object);
2479 var val = JSON.parse(object);
2481 if (typeof(val['hover-node']) != 'undefined') {
2482 this.activeNode = val['hover-node'];
2483 console.log('active node: ' + this.activeNode);
2488 if (typeof(val['id']) != 'undefined') {
2489 // this.activeNode = val['id'];
2490 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2494 this.get('/LeftTree.view').selectNode(tg[0]);
2498 if (ret && typeof(val['set']) != 'undefined') {
2499 this.get('/LeftPanel.model').add({
2503 //console.log('active node: ' + this.activeNode);
2506 //Seed.print('a:'+a);
2507 //Seed.print('b:'+b);
2508 //Seed.print('c:'+c);
2511 "drag_motion":function (w, ctx, x, y, time, ud) {
2512 // console.log('DRAG MOTION');
2514 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2515 this.targetData = [];
2516 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2518 // A) find out from drag all the places that node could be dropped.
2519 var src = Gtk.drag_get_source_widget(ctx);
2520 if (!src.dropList) {
2521 Gdk.drag_status(ctx, 0, time);
2524 // b) get what we are over.. (from activeNode)
2525 // tree is empty.. - list should be correct..
2526 if (!this.get('/LeftTree.model').currentTree) {
2527 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2531 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2533 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2536 Gdk.drag_status(ctx, 0,time);
2537 this.get('/LeftTree.view').highlight(false);
2541 // if we have a target..
2542 // -> highlight it! (in browser)
2543 // -> highlight it! (in tree)
2545 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2546 this.get('/LeftTree.view').highlight(tg);
2547 this.targetData = tg;
2548 // for tree we should handle this...
2551 "drag_drop":function (w, ctx, x, y,time, ud) {
2552 print("TARGET: drag-drop");
2553 var is_valid_drop_site = true;
2558 w, /* will receive 'drag-data-received' signal */
2559 ctx, /* represents the current state of the DnD */
2560 this.get('/Window').atoms["STRING"], /* the target type we want */
2561 time /* time stamp */
2565 /* No target offered by source => error */
2568 return is_valid_drop_site;
2570 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2572 print("Browser: drag-data-received");
2573 var delete_selection_data = false;
2574 vardnd_success = false;
2575 /* Deal with what we are given from source */
2576 if( sel_data && sel_data.length ) {
2578 if (ctx.action == Gdk.DragAction.ASK) {
2579 /* Ask the user to move or copy, then set the ctx action. */
2582 if (ctx.action == Gdk.DragAction.MOVE) {
2583 delete_selection_data = true;
2585 var source = Gtk.drag_get_source_widget(ctx);
2587 print("Browser: source.DRAGDATA? " + source.dragData);
2588 if (this.targetData) {
2589 print(this.targetData);
2590 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2599 if (dnd_success == false)
2601 Seed.print ("DnD data transfer failed!\n");
2604 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2616 id : "RightGtkView",
2617 renderJS : function(data, withDebug)
2622 this.withDebug = false;
2624 if (this.renderedEl) {
2625 this.get('view').el.remove(this.renderedEl);
2626 this.renderedEl.destroy();
2627 this.renderedEl = false;
2630 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2631 // in theory tree is actually window..
2633 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2638 this.get('view').el.set_size_request(
2639 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2642 this.renderedEl.set_size_request(
2643 tree.default_width || 600,
2644 tree.default_height || 400
2646 this.get('view').el.show_all();
2651 showInWindow : function() {
2652 print("GET PROEJCT");
2653 var pr = this.get('/LeftProjectTree').getActiveProject();
2655 console.log(pr.paths);
2658 var src= this.buildJS(
2659 this.get('/LeftTree.model').toJS()[0],
2664 //var x = new imports.sandbox.Context();
2668 Seed.check_syntax('var e = ' + src);
2671 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2672 this.get('/Terminal').feed(console._dump(e)+"\n");
2674 var lines = src.split("\n");
2675 var start = Math.max(0, e.line - 10);
2676 var end = Math.min(lines.length, e.line + 10);
2677 for (var i =start ; i < end; i++) {
2679 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2682 this.get('/Terminal').feed(lines[i] + "\n");
2689 this.get('/BottomPane').el.set_current_page(1);
2690 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2691 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2692 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2694 var _top = x.get_global_object()._top;
2696 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2698 if (_top.el.popup) {
2699 _top.el.popup(null, null, null, null, 3, null);
2703 viewAdd : function(item, par)
2705 // does something similar to xobject..
2706 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2708 if (item.pack===false || item.pack === 'false') { // no ;
2711 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2712 var ns = imports.gi[item['|xns']];
2713 var ctr = ns[item['xtype']];
2715 for(var k in item) {
2717 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2732 if (k[0] == '|' && typeof(kv) == 'string') {
2734 if (kv.match(new RegExp('function'))) {
2737 print("WASL " + k + '=' + kv);
2739 eval( 'kv = ' + kv);
2740 } catch(e) { continue; }
2743 print(k + '=' + kv);
2745 if (k[0] == '|') { // should be boolean or number..
2748 if (k == 'show_tabs') { // force tab showing for notebooks.
2756 var el = new ctr(ctr_args);
2759 //console.dump(item.pack);
2766 if (typeof(item.pack) == 'string') {
2768 item.pack.split(',').forEach(function(e, i) {
2770 if (e == 'false') { args.push( false); return; }
2771 if (e == 'true') { args.push( true); return; }
2772 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2775 //print(args.join(","));
2777 pack_m = args.shift();
2779 pack_m = item.pack.shift();
2784 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2786 name: "ArgumentError",
2787 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2788 "ADDING : " + item.id + " " + el
2797 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2798 //Seed.print('args: ' + args.length);
2800 par[pack_m].apply(par, args);
2804 item.items = item.items || [];
2805 item.items.forEach(function(ch) {
2806 _this.viewAdd(ch, el);
2811 // add the signal handlers.
2812 // is it a widget!?!!?
2818 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2819 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2820 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2821 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2822 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2832 widgetExposeEvent : function() {
2833 /// print("WIDGET EXPOSE"); // draw highlight??
2836 widgetDragMotionEvent : function() {
2837 print("WIDGET DRAGMOTION");
2840 widgetDragDropEvent : function() {
2841 print("WIDGET DRAGDROP");
2844 widgetPressEvent : function(w,e,u,d) {
2845 if (this.get('view').pressed) {
2848 this.get('view').pressed = true;
2849 print("WIDGET PRESS " + d.xtreepath );
2850 this.get('/LeftTree.view').selectNode( d.xtreepath );
2853 widgetReleaseEvent : function() {
2854 this.get('view').pressed = false;
2860 pack : "pack_start,false,true,0",
2864 pack : "pack_start,false,false,0",
2865 label : "Run The Application",
2867 "button_press_event":function (self, event) {
2868 // call render on left tree - with special option!?!
2872 print("GET PROEJCT");
2873 var pr = this.get('/LeftProjectTree').getActiveProject();
2876 for (var i in pr.paths) {
2880 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
2881 print ("RUN DIR:" + dir);
2883 this.get('/BottomPane').el.set_current_page(1);
2884 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
2885 , false,false,false);
2886 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
2887 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2897 xtype: Gtk.ScrolledWindow,
2900 shadow_type : Gtk.ShadowType.IN,
2902 XObject.prototype.init.call(this);
2903 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2907 xtype: Gtk.EventBox,
2910 XObject.prototype.init.call(this);
2911 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
2912 red: 0x9F00, green: 0xB800 , blue : 0xA800
2920 XObject.prototype.init.call(this);
2921 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
2922 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
2927 xtype: Gtk.EventBox,
2930 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
2931 XObject.prototype.init.call(this);
2935 this.el, /* widget that will accept a drop */
2936 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2937 null, /* lists of target to support */
2938 0, /* size of list */
2939 Gdk.DragAction.COPY /* what to do with data after dropped */
2942 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2943 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2946 getActiveNode : function(x,y)
2948 // workout what node is here..
2949 return '0'; // top..
2953 "drag_motion":function (self, ctx, x, y, time) {
2955 // A) find out from drag all the places that node could be dropped.
2956 var src = Gtk.drag_get_source_widget(ctx);
2957 if (!src.dropList) {
2958 Gdk.drag_status(ctx, 0, time);
2961 // b) get what we are over.. (from activeNode)
2962 // tree is empty.. - list should be correct..
2963 if (!this.get('/LeftTree.model').currentTree) {
2964 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2968 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2969 var activeNode = this.getActiveNode(x, y);
2972 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
2975 Gdk.drag_status(ctx, 0,time);
2976 this.get('/LeftTree.view').highlight(false);
2980 // if we have a target..
2981 // -> highlight it! (in browser)
2982 // -> highlight it! (in tree)
2984 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2985 this.get('/LeftTree.view').highlight(tg);
2986 this.targetData = tg;
2987 // for tree we should handle this...
2990 "drag_drop":function (self,ctx, x, y, time) {
2991 Seed.print("TARGET: drag-drop");
2992 var is_valid_drop_site = true;
2997 self, /* will receive 'drag-data-received' signal */
2998 ctx, /* represents the current state of the this.gDnD */
2999 this.get('/Window').atoms["STRING"], /* the target type we want */
3000 time /* time stamp */
3004 /* No target offered by source => error */
3007 return is_valid_drop_site;
3010 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3012 Seed.print("GtkView: drag-data-received");
3013 var delete_selection_data = false;
3014 var dnd_success = false;
3015 /* Deal with what we are given from source */
3016 if( sel_data && sel_data.length ) {
3018 if (ctx.action == Gdk.DragAction.ASK) {
3019 /* Ask the user to move or copy, then set the ctx action. */
3022 if (ctx.action == Gdk.DragAction.MOVE) {
3023 delete_selection_data = true;
3025 var source = Gtk.drag_get_source_widget(ctx);
3027 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3028 if (this.targetData) {
3029 Seed.print(this.targetData);
3030 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3039 if (dnd_success == false)
3041 Seed.print ("DnD data transfer failed!\n");
3044 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3047 "button_press_event":function (self, event) {
3048 this.pressed = false;
3066 xtype: Gtk.Notebook,
3069 XObject.prototype.init.call(this);
3070 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3071 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3076 xtype: Gtk.ScrolledWindow,
3081 xtype: GtkSource.View,
3085 XObject.prototype.init.call(this);
3086 var description = Pango.Font.description_from_string("monospace")
3087 description.set_size(8000);
3088 this.el.modify_font(description);
3091 load : function(str) {
3092 this.get('/BottomPane').el.set_current_page(0);
3093 this.el.get_buffer().set_text(str, str.length);
3094 var lm = GtkSource.LanguageManager.get_default();
3096 this.el.get_buffer().set_language(lm.get_language('js'));
3097 var buf = this.el.get_buffer();
3098 var cursor = buf.get_mark("insert");
3099 var iter= new Gtk.TextIter;
3100 buf.get_iter_at_mark(iter, cursor);
3102 iter.set_line_offset(4);
3103 buf.move_mark(cursor, iter);
3106 cursor = buf.get_mark("selection_bound");
3107 iter= new Gtk.TextIter;
3108 buf.get_iter_at_mark(iter, cursor);
3110 iter.set_line_offset(4);
3111 buf.move_mark(cursor, iter);
3113 this.el.grab_focus();
3117 xtype: GtkSource.Buffer,
3118 pack : "set_buffer",
3120 "changed":function (self) {
3121 var s = new Gtk.TextIter();
3122 var e = new Gtk.TextIter();
3123 this.el.get_start_iter(s);
3124 this.el.get_end_iter(e);
3125 var str = this.el.get_text(s,e,true);
3127 Seed.check_syntax('var e = ' + str);
3129 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3130 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3132 print("SYNTAX ERROR IN EDITOR");
3137 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3138 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3141 this.get('/LeftPanel.model').changed( str , false);
3150 xtype: Gtk.ScrolledWindow,
3154 xtype: Vte.Terminal,
3157 feed : function(str) {
3158 this.el.feed(str,str.length);
3169 pack : "pack_start,false,false",
3173 this.get('buttonbar').el.show();
3174 this.get('viewbox').el.hide();
3175 print("TRIED TO HIDE");
3178 this.get('buttonbar').el.hide();
3179 this.get('viewbox').el.show();
3180 // this.get('model').expanded();
3192 pack : "pack_start,false,true",
3194 "clicked":function (self) {
3195 this.get('/RightPalete').show();
3202 stock : Gtk.STOCK_GOTO_FIRST,
3203 icon_size : Gtk.IconSize.MENU
3213 XObject.prototype.init.call(this);
3214 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3217 "enter_notify_event":function (self, event) {
3218 this.get('/RightPalete').show();
3232 pack : "pack_start,false,true",
3241 pack : "pack_start,false,true",
3243 "clicked":function (self) {
3244 this.get('/RightPalete').hide();
3251 stock : Gtk.STOCK_GOTO_LAST,
3252 icon_size : Gtk.IconSize.MENU
3259 xtype: Gtk.ScrolledWindow,
3262 XObject.prototype.init.call(this);
3263 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3264 this.el.set_size_request(-1,200);
3266 shadow_type : Gtk.ShadowType.IN,
3269 xtype: Gtk.TreeView,
3272 XObject.prototype.init.call(this);
3273 this.el.set_size_request(150,-1);
3274 // set_reorderable: [1]
3276 var description = new Pango.FontDescription.c_new();
3277 description.set_size(8000);
3278 this.el.modify_font(description);
3280 this.selection = this.el.get_selection();
3281 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3282 // this.selection.signal['changed'].connect(function() {
3283 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3285 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3287 Gtk.drag_source_set (
3288 this.el, /* widget will be drag-able */
3289 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3290 null, /* lists of target to support */
3291 0, /* size of list */
3292 Gdk.DragAction.COPY /* what to do with data after dropped */
3294 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3296 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3297 Gtk.drag_source_add_text_targets(this.el);
3299 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3300 targets = new Gtk.TargetList();
3301 targets.add( LeftTree.atoms["STRING"], 0, 0);
3302 targets.add_text_targets( 1 );
3303 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3305 //if you want to allow text to be output elsewhere..
3306 //Gtk.drag_source_add_text_targets(this.el);
3310 headers_visible : false,
3311 enable_tree_lines : true,
3313 "drag_begin":function (self, ctx) {
3314 // we could fill this in now...
3315 Seed.print('SOURCE: drag-begin');
3319 var iter = new Gtk.TreeIter();
3320 var s = this.selection;
3321 s.get_selected(this.get('/RightPalete.model').el, iter);
3322 var path = this.get('/RightPalete.model').el.get_path(iter);
3324 var pix = this.el.create_row_drag_icon ( path);
3327 Gtk.drag_set_icon_pixmap (ctx,
3334 var value = new GObject.Value('');
3335 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3336 if (!this.get('/RightPalete').provider) {
3339 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3340 this.el.dragData = value.value;
3347 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3348 //Seed.print('Palete: drag-data-get: ' + target_type);
3349 if (this.el.dragData && this.el.dragData.length ) {
3350 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3354 //this.el.dragData = "TEST from source widget";
3358 "drag_end":function (self, drag_context) {
3359 Seed.print('SOURCE: drag-end');
3360 this.el.dragData = false;
3361 this.el.dropList = false;
3362 this.get('/LeftTree.view').highlight(false);
3368 xtype: Gtk.ListStore,
3371 XObject.prototype.init.call(this);
3372 this.el.set_column_types ( 2, [
3373 GObject.TYPE_STRING, // title
3374 GObject.TYPE_STRING // tip
3379 load : function(tr,iter)
3384 //console.log('Project tree load: ' + tr.length);
3385 var citer = new Gtk.TreeIter();
3386 //this.insert(citer,iter,0);
3387 for(var i =0 ; i < tr.length; i++) {
3390 this.el.append(citer);
3392 this.el.insert(citer,iter,-1);
3397 this.el.set_value(citer, 0, '' + r ); // title
3399 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3400 //if (r.cn && r.cn.length) {
3401 // this.load(r.cn, citer);
3407 getValue : function (iter, col) {
3408 var gval = new GObject.Value('');
3409 this.el.get_value(iter, col ,gval);
3416 xtype: Gtk.TreeViewColumn,
3417 pack : "append_column",
3419 XObject.prototype.init.call(this);
3420 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3424 xtype: Gtk.CellRendererText,
3446 XObject.cache['/Window'] = Window;