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",
74 label : "New _Project",
76 "activate":function (self) {
78 this.get('/EditProject').show({
79 success : function(pr) {
80 _this.get('/LeftProjectTree').get('combo').setValue(pr.fn);
91 "activate":function (self) {
92 var fn = this.get('/LeftProjectTree.combo').getValue();
94 this.get('/LeftProjectTree').showNoProjectSelected();
97 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
98 this.get('/DialogNewComponent').show({
99 project : pm.getByFn(fn)
105 xtype: Gtk.SeparatorMenuItem,
110 use_underline : true,
112 label : "D_elete Project",
114 "activate":function (self) {
116 var fn = this.get('/LeftProjectTree').get('combo').getValue();
118 this.get('/StandardErrorDialog').show("Select a project")
121 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
122 var pr = pm.getByFn(fn);
125 this.get('/DialogConfirm').show("Are you sure you want to delete project '" + pr.name + "'", function() {
126 pm.deleteProject(fn);
134 xtype: Gtk.SeparatorMenuItem,
141 use_underline : true,
143 "activate":function (self) {
177 label : "Select Project",
179 pack : "pack_start,false,true",
181 XObject.prototype.init.call(this);
182 this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
185 "activate":function (self) {
186 var nb = this.get('/LeftTopPanel.notebook');
187 if (this.el.expanded) {
190 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
193 var model = this.get('/LeftProjectTree.combomodel');
194 // print ("loading Projects?")
195 //console.dump(pm.projects);
196 model.loadData(pm.projects);
199 nb.el.set_current_page(1);
200 //pm.on('changed', function() {
201 //console.log("CAUGHT project manager change");
202 // _combo.model.loadData(pm.projects);
206 nb.el.set_current_page(0);
208 "enter_notify_event":function (self, event) {
209 this.el.expanded = !this.el.expanded;
210 //if (this.el.expanded ) {
211 this.listeners.activate.call(this);
223 pack : "pack_start,true,true",
225 XObject.prototype.init.call(this);
226 this.el.set_current_page(0);
231 xtype: Gtk.ScrolledWindow,
233 shadow_type : Gtk.ShadowType.IN,
235 XObject.prototype.init.call(this);
236 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
239 getPaleteProvider : function() {
240 var model = this.get('model');
241 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
242 return pm.getPalete(model.file.getType());
244 renderView : function() {
245 var model = this.get('model');
246 print("RENDER VIEW?" + model.file.getType());
247 switch( model.file.getType()) {
249 this.get('/RightBrowser.view').renderJS(model.toJS(false,true)[0]);
251 this.get('/RightGtkView').renderJS(model.toJS(false,true)[0]);
259 headers_visible : false,
260 enable_tree_lines : true,
263 XObject.prototype.init.call(this);
264 var description = new Pango.FontDescription.c_new();
265 description.set_size(8000);
266 this.el.modify_font(description);
268 this.selection = this.el.get_selection();
269 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
271 this.selection.signal['changed'].connect(function() {
272 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
273 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
277 Gtk.drag_source_set (
278 this.el, /* widget will be drag-able */
279 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
280 null, /* lists of target to support */
281 0, /* size of list */
282 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
285 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
287 Gtk.drag_source_add_text_targets(this.el);
290 this.el, /* widget that will accept a drop */
291 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
292 null, /* lists of target to support */
293 0, /* size of list */
294 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
297 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
298 Gtk.drag_dest_add_text_targets(this.el);
300 highlight : function(treepath_ar) {
301 if (treepath_ar.length && treepath_ar[0].length ) {
302 this.el.set_drag_dest_row(
303 new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);
305 this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
309 selectNode : function(treepath_str) {
310 //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
311 var tp = new Gtk.TreePath.from_string(treepath_str);
312 this.el.set_cursor(tp, null, false);
313 this.el.scroll_to_cell(tp, null, false, 0,0);
316 "button_press_event":function (self, ev) {
317 console.log("button press?");
318 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
319 print("click" + ev.type);
325 this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
327 if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();
329 this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
330 this.get('/LeftTreeMenu').el.show_all();
331 this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
332 print("click:" + res.path.to_string());
335 "drag_begin":function (self, drag_context) {
336 print('SOURCE: drag-begin');
337 this.targetData = false;
338 // find what is selected in our tree...
339 var iter = new Gtk.TreeIter();
340 var s = this.selection;
341 s.get_selected(this.get('/LeftTree.model').el, iter);
343 // set some properties of the tree for use by the dropped element.
344 var value = new GObject.Value('');
345 this.get('/LeftTree.model').el.get_value(iter, 2, value);
346 var data = JSON.parse(value.value);
347 var xname = this.get('/LeftTree.model').file.guessName(data);
349 this.el.dragData = xname;
350 this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);
353 // make the drag icon a picture of the node that was selected
354 var path = this.get('/LeftTree.model').el.get_path(iter);
355 this.el.treepath = path.to_string();
357 var pix = this.el.create_row_drag_icon ( path);
359 Gtk.drag_set_icon_pixmap (ctx,
368 "drag_end":function (self, drag_context) {
369 Seed.print('LEFT-TREE: drag-end');
370 this.el.dragData = false;
371 this.el.dropList = false;
372 this.targetData = false;
373 this.get('/LeftTree.view').highlight(false);
376 "drag_motion":function (self, ctx, x, y, time) {
377 console.log("LEFT-TREE: drag-motion");
378 var src = Gtk.drag_get_source_widget(ctx);
380 // a drag from elsewhere...- prevent drop..
382 print("no drag data!");
383 Gdk.drag_status(ctx, 0, time);
384 this.targetData = false;
387 var action = Gdk.DragAction.COPY;
388 if (src == this.el) {
389 // unless we are copying!!! ctl button..
390 action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
394 if (!this.get('/LeftTree.model').el.iter_n_children(null)) {
395 // no children.. -- asume it's ok..
396 this.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];
397 Gdk.drag_status(ctx, action ,time);
401 print("GETTING POS");
402 var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);
403 print("ISOVER? " + isOver);
405 Gdk.drag_status(ctx, 0 ,time);
406 return false; // not over apoint!?!
408 // drag node is parent of child..
409 console.log("SRC TREEPATH: " + src.treepath);
410 console.log("TARGET TREEPATH: " + data.path.to_string());
412 // nned to check a few here..
413 //Gtk.TreeViewDropPosition.INTO_OR_AFTER
414 //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
415 //Gtk.TreeViewDropPosition.AFTER
416 //Gtk.TreeViewDropPosition.BEFORE
418 if (typeof(src.treepath) != 'undefined' &&
419 src.treepath == data.path.to_string().substring(0,src.treepath.length)) {
420 print("subpath drag");
421 Gdk.drag_status(ctx, 0 ,time);
426 //print("DUMPING DATA");
427 //console.dump(data);
430 print(data.path.to_string() +' => '+ data.pos);
431 var tg = this.get('/LeftTree.model').findDropNodeByPath(
432 data.path.to_string(), src.dropList, data.pos);
434 this.get('/LeftTree.view').highlight(tg);
436 print("Can not find drop node path");
437 this.targetData = false;
438 Gdk.drag_status(ctx, 0, time);
442 this.targetData = tg;
445 Gdk.drag_status(ctx, action ,time);
449 "drag_drop":function (w, ctx, x, y, time) {
450 Seed.print("TARGET: drag-drop");
454 w, /* will receive 'drag-data-received' signal */
455 ctx, /* represents the current state of the DnD */
456 this.get('/Window').atoms["STRING"], /* the target type we want */
457 time /* time stamp */
461 /* No target offered by source => error */
466 "drag_data_received":function (self, ctx, x, y, sel_data, info, time) {
467 print("Tree: drag-data-received");
469 var delete_selection_data = false;
470 var dnd_success = false;
471 /* Deal with what we are given from source */
472 if( sel_data && sel_data.length ) {
474 if (ctx.action == Gdk.DragAction.ASK) {
475 /* Ask the user to move or copy, then set the ctx action. */
478 if (ctx.action == Gdk.DragAction.MOVE) {
479 //delete_selection_data = true;
482 var source = Gtk.drag_get_source_widget(ctx);
484 if (this.targetData) {
485 if (source != this.el) {
486 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
488 // drag around.. - reorder..
489 this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);
493 //Seed.print(this.targetData);
499 // we can send stuff to souce here...
505 if (dnd_success == false)
507 Seed.print ("DnD data transfer failed!\n");
510 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
513 "cursor_changed":function (self) {
514 if (this.blockChanges) {
517 var iter = new Gtk.TreeIter();
519 if (this.selection.count_selected_rows() < 1) {
520 this.get('/LeftPanel.model').load( false);
521 this.get('/MidPropTree').activeElement = false;
522 this.get('/MidPropTree').hideWin();
524 var pm = this.get('/RightPalete.model');
525 if (!this.get('/LeftTree').getPaleteProvider()) {
526 // it may not be loaded yet..
529 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
530 this.get('/LeftTree.model').listAllTypes()));
535 //console.log('changed');
536 var s = this.selection;
537 s.get_selected(this.get('/LeftTree.model').el, iter);
541 value = new GObject.Value('');
542 this.get('/LeftTree.model').el.get_value(iter, 2, value);
543 this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
545 var data = JSON.parse(value.value);
546 this.get('/MidPropTree').activeElement = data;
547 this.get('/MidPropTree').hideWin();
548 this.get('/LeftPanel.model').load( data);
550 console.log(value.value);
551 // _g.button.set_label(''+value.get_string());
553 var pm =this.get('/RightPalete.model');
554 pm.load( this.get('/RightPalete').provider.gatherList(
555 this.get('/LeftTree.model').listAllTypes()));
560 //Seed.print( value.get_string());
567 xtype: Gtk.TreeStore,
571 XObject.prototype.init.call(this);
572 this.el.set_column_types ( 3, [
573 GObject.TYPE_STRING, // title
574 GObject.TYPE_STRING, // tip
575 GObject.TYPE_STRING // source..
579 changed : function(n, refresh) {
580 print("MODEL CHANGED CALLED" + this.activePath);
581 if (this.activePath) {
582 var iter = new Gtk.TreeIter();
583 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
584 this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
585 this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
587 this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
589 //this.currentTree = this.toJS(false, true)[0];
590 this.file.items = this.toJS(false, false);
591 print("AFTER CHANGED");
592 //console.dump(this.file.items);
594 this.currentTree = this.file.items[0];
595 //console.log(this.file.toSource());
598 print("REDNER BROWSER?!");
599 this.get('/LeftTree').renderView();
601 var pm = this.get('/RightPalete.model');
602 if (!this.get('/RightPalete').provider) {
608 pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
609 //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
613 loadFile : function(f) {
619 console.log('missing file');
623 // load the file if not loaded..
624 if (f.items === false) {
626 f.loadItems(function() {
632 if (f.items.length && typeof(f.items[0]) == 'string') {
634 this.get('/RightEditor').el.show();
635 this.get('/RightEditor.view').load( f.items[0]);
639 //console.dump(f.items);
641 this.get('/LeftTree.view').el.expand_all();
643 if (!f.items.length) {
646 this.get('/Window.leftvpaned').el.set_position(80);
648 this.get('/LeftTree.view').el.set_cursor(
649 new Gtk.TreePath.from_string('0'), null, false);
653 this.get('/Window.leftvpaned').el.set_position(200);
657 //print("hide right editior");
658 this.get('/RightEditor').el.hide();
659 //print("set current tree");
660 this.currentTree = this.toJS(false, false)[0];
661 //console.dump(this.currentTree);
662 this.currentTree = this.currentTree || { items: [] };
663 this.get('/LeftTree').renderView();
664 //console.dump(this.map);
665 //var RightPalete = imports.Builder.RightPalete.RightPalete;
666 var pm = this.get('/RightPalete.model');
669 this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
671 if (!this.get('/RightPalete').provider) {
672 print ("********* PALETE PROVIDER MISSING?!!");
674 this.get('/LeftTree').renderView();
676 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
680 this.get('/Window.view-notebook').el.set_current_page(
681 this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
684 findDropNode : function(treepath_str, targets) {
686 // this is used by the dragdrop code in the roo version AFAIR..
688 var path = treepath_str.replace(/^builder-/, '');
689 // treemap is depreciated... - should really check if model has any entries..
691 if (!this.el.iter_n_children(null)) {
693 return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];
695 print("FIND treepath: " + path);
696 //console.dump(this.treemap);
698 if (!treepath_str.match(/^builder-/)) {
699 return []; // nothing!
701 if (targets === true) {
704 return this.findDropNodeByPath(path,targets)
706 findDropNodeByPath : function(treepath_str, targets, pref) {
707 var path = treepath_str + ''; // dupe it..
708 pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
710 //console.dump(this.treemap);
711 while (path.length) {
712 print("LOOKING FOR PATH: " + path);
713 var node_data = this.singleNodeToJS(path);
714 if (node_data === false) {
715 print("node not found");
719 var xname = this.get('/LeftTree.model').file.guessName(node_data);
722 targets.forEach(function(tg) {
726 if ((tg == xname) ) {
729 if (tg.indexOf(xname +':') === 0) {
731 prop = tg.split(':').pop();
736 if (last) { // pref is after/before..
737 // then it's after last
739 return []; // do not allow..
741 return [ last, pref , prop];
744 return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
746 var par = path.split(':');
749 path = par.join(':');
755 dropNode : function(target_data, node) {
758 console.dump(target_data);
759 var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
761 print("add " + tp + "@" + target_data[1] );
764 if (tp && target_data[1] < 2) { // before or after..
765 var ar = target_data[0].split(':');
767 parent = new Gtk.TreePath.from_string( ar.join(':') );
770 var n_iter = new Gtk.TreeIter();
771 var iter_par = new Gtk.TreeIter();
772 var iter_after = after ? new Gtk.TreeIter() : false;
776 if (parent !== false) {
777 this.el.get_iter(iter_par, parent);
784 print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
785 this.el.get_iter(iter_after, after);
786 this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
787 n_iter, iter_par, iter_after);
790 this.el.append(n_iter, iter_par);
794 if (typeof(node) == 'string') {
795 var ar = node.split('.');
796 var xtype = ar.pop();
799 '|xns' : ar.join('.'),
802 if (target_data.length == 3 && target_data[2].length) {
803 node['*prop'] = target_data[2];
807 // work out what kind of packing to use..
808 if (typeof(node.pack) == 'undefined' && parent !== false) {
809 var pal = this.get('/LeftTree').getPaleteProvider();
811 var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
812 print ("PNAME : " + pname);
813 var cname = pal.guessName(node);
814 print ("CNAME : " + cname);
815 node.pack = pal.getDefaultPack(pname, cname);
826 // load children - if it has any..
829 this.load(xitems, n_iter);
831 if (tp && (xitems || after)) {
832 this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
834 // wee need to get the empty proptypes from somewhere..
836 //var olditer = this.activeIter;
837 this.activePath = this.el.get_path(n_iter).to_string();
839 // changed actually set's the node data..
840 this.changed(node, true);
844 this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
846 //Builder.MidPropTree._model.load(node);
847 //Builder.MidPropTree._win.hideWin();
848 //Builder.LeftPanel._model.load( node);
852 moveNode : function(target_data, action) {
853 //print("MOVE NODE");
854 // console.dump(target_data);
855 var old_iter = new Gtk.TreeIter();
856 var s = this.get('/LeftTree.view').selection;
857 s.get_selected(this.el, old_iter);
858 var node = this.nodeToJS(old_iter,false);
859 //console.dump(node);
862 // needs to drop first, otherwise the target_data
863 // treepath will be invalid.
865 this.dropNode(target_data, node);
866 if (action & Gdk.DragAction.MOVE) {
867 // print("REMOVING OLD NODE");
868 this.el.remove(old_iter);
872 this.activePath= false;
873 this.changed(false,true);
875 deleteSelected : function() {
876 this.get('/LeftTree.view').blockChanges = true;
877 var old_iter = new Gtk.TreeIter();
878 var s = this.get('/LeftTree.view').selection;
879 s.get_selected(this.el, old_iter);
880 var path = this.el.get_path(old_iter).to_string();
882 this.activePath= false;
885 this.activePath= false;
886 var iter = new Gtk.TreeIter();
887 this.el.get_iter_from_string(iter, path);
888 this.el.remove(iter);
890 // rebuild treemap. -- depreciated.!!
893 //this.toJS(null, true) // does not do anything?
894 this.activePath= false;
895 this.changed(false,true);
896 this.get('/LeftTree.view').blockChanges = false;
899 listAllTypes : function() {
900 var s = this.get('/LeftTree.view').selection;
901 print ("LIST ALL TYPES: " + s.count_selected_rows() );
903 if (s.count_selected_rows() > 0) {
904 var iter = new Gtk.TreeIter();
905 s.get_selected(this.el, iter);
907 // set some properties of the tree for use by the dropped element.
908 var value = new GObject.Value('');
909 this.el.get_value(iter, 2, value);
910 var data = JSON.parse(value.value);
913 var xname = this.get('/LeftTree.model').file.guessName(data);
914 console.log('selected:' + xname);
918 return []; // could not find it..
926 li.forEach(function(el) {
927 // this is specific to roo!!!?
929 var fullpath = _this.file.guessName(el);
930 if (fullpath.length && ret.indexOf(fullpath) < 0) {
935 if (el.items && el.items.length) {
944 addall([this.currentTree]);
946 // only if we have nothing, should we add '*top'
950 //console.log('all types in tree');
956 singleNodeToJS : function (treepath)
958 var iter = new Gtk.TreeIter();
959 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
963 var iv = this.getIterValue(iter, 2);
965 return JSON.parse(iv);
968 nodeToJS : function (iter, with_id)
970 var par = new Gtk.TreeIter();
971 var iv = this.getIterValue(iter, 2);
973 var k = JSON.parse(iv);
974 if (k.json && !this.el.iter_parent( par, iter )) {
979 var treepath_str = this.el.get_path(iter).to_string();
980 // not sure how we can handle mixed id stuff..
981 if (typeof(k.id) == 'undefined') {
982 k.id = 'builder-'+ treepath_str ;
986 this.treemap[ treepath_str ] = k;
987 k.xtreepath = treepath_str ;
990 if (this.el.iter_has_child(iter)) {
991 citer = new Gtk.TreeIter();
992 this.el.iter_children(citer, iter);
993 k.items = this.toJS(citer,with_id);
997 toJS : function(iter, with_id)
999 //Seed.print("WITHID: "+ with_id);
1006 iter = new Gtk.TreeIter();
1007 if (!this.el.get_iter_first(iter)) {
1017 var k = this.nodeToJS(iter, with_id);
1021 if (!this.el.iter_next(iter)) {
1027 // convert the list into a json string..
1031 getIterValue : function (iter, col) {
1032 var gval = new GObject.Value('');
1033 this.el.get_value(iter, col ,gval);
1038 nodeTitle : function(c) {
1041 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
1042 if (sr) txt.push('<s>');
1043 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
1044 if (c.xtype) { txt.push(c.xtype); }
1045 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1046 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1047 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1050 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1051 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1052 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1053 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1054 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1055 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1056 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1057 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1058 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1060 // for flat classes...
1061 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1062 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1065 if (sr) txt.push('</s>');
1066 return (txt.length == 0 ? "Element" : txt.join(" "));
1068 nodeToJSON : function(c) {
1076 return JSON.stringify(o);
1078 load : function(tr,iter)
1080 var citer = new Gtk.TreeIter();
1081 //this.insert(citer,iter,0);
1082 for(var i =0 ; i < tr.length; i++) {
1084 this.el.insert(citer,iter,-1);
1086 this.el.append(citer);
1089 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1090 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1091 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1092 if (tr[i].items && tr[i].items.length) {
1093 this.load(tr[i].items, citer);
1099 xtype: Gtk.TreeViewColumn,
1100 pack : "append_column",
1102 XObject.prototype.init.call(this);
1103 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1107 xtype: Gtk.CellRendererText,
1117 id : "LeftTreeMenu",
1120 xtype: Gtk.MenuItem,
1122 label : "Delete Element",
1124 "activate":function (self) {
1126 this.get('/LeftTree.model').deleteSelected();
1137 id : "LeftProjectTree",
1138 showNoProjectSelected : function() {
1139 this.get('/StandardErrorDialog').show("Select a Project first.");
1141 getActiveProject : function() {
1142 return this.project;
1145 "leave_notify_event":function (self, event) {
1152 pack : "pack_start,false,false",
1155 xtype: Gtk.ComboBox,
1158 XObject.prototype.init.call(this);
1159 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1161 getValue : function() {
1162 var ix = this.el.get_active();
1166 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1169 setValue : function(fn)
1173 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1174 data.forEach(function(n, ix) {
1182 "changed":function (self) {
1183 var fn = this.getValue();
1184 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1185 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1190 xtype: Gtk.CellRendererText,
1191 pack : "pack_start,true",
1195 xtype: Gtk.ListStore,
1198 XObject.prototype.init.call(this);
1199 this.el.set_column_types ( 2, [
1200 GObject.TYPE_STRING, // real key
1201 GObject.TYPE_STRING // real type
1207 loadData : function(data) {
1208 var ov = this.get('/LeftProjectTree.combo').getValue();
1210 var iter = new Gtk.TreeIter();
1212 data.forEach(function(p) {
1217 el.set_value(iter, 0, p.fn);
1218 el.set_value(iter, 1, p.name);
1222 this.get('/LeftProjectTree.combo').setValue(ov);
1231 xtype: Gtk.ScrolledWindow,
1233 shadow_type : Gtk.ShadowType.IN,
1235 XObject.prototype.init.call(this);
1236 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1240 xtype: Gtk.TreeView,
1241 headers_visible : false,
1242 enable_tree_lines : true,
1245 XObject.prototype.init.call(this);
1246 var description = new Pango.FontDescription.c_new();
1247 description.set_size(8000);
1248 this.el.modify_font(description);
1250 this.selection = this.el.get_selection();
1251 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1255 "cursor_changed":function (self) {
1256 var iter = new Gtk.TreeIter();
1258 if (this.selection.count_selected_rows() < 1) {
1259 //XN.get('Builder.LeftTree.model').
1260 this.get('/LeftTree.model').load( false);
1264 var model = this.get('/LeftProjectTree.model');
1265 //console.log('changed');
1266 var s = this.selection;
1267 s.get_selected(model, iter);
1268 value = new GObject.Value('');
1269 model.el.get_value(iter, 2, value);
1271 console.log(value.value);// id..
1273 var file = this.get('/LeftProjectTree').project.getById(value.value);
1280 var nb = this.get('/LeftTopPanel.expander');
1281 nb.el.expanded = false;
1282 nb.listeners.activate.call(nb);
1283 //_expander.el.set_expanded(false);
1285 var ltm = this.get('/LeftTree.model');
1293 xtype: Gtk.TreeStore,
1297 XObject.prototype.init.call(this);
1298 this.el.set_column_types ( 3, [
1299 GObject.TYPE_STRING, // title
1300 GObject.TYPE_STRING, // tip
1301 GObject.TYPE_STRING // id..
1305 loadProject : function(pr) {
1310 this.get('/LeftProjectTree').project = pr;
1311 this.load(pr.toTree());
1312 this.get('/LeftProjectTree.view').el.expand_all();
1314 load : function(tr,iter) {
1316 console.log('Project tree load: ' + tr.length);
1317 var citer = new Gtk.TreeIter();
1318 //this.insert(citer,iter,0);
1321 tr.forEach(function (r) {
1323 _this.el.append(citer);
1325 _this.el.insert(citer,iter,-1);
1327 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1328 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1329 _this.el.set_value(citer, 2, '' + r.id ); //id
1330 if (r.cn && r.cn.length) {
1331 _this.load(r.cn, citer);
1336 getValue : function(iter, col) {
1337 var gval = new GObject.Value('');
1338 this.el.get_value(iter, col ,gval);
1339 return '' + gval.value;
1343 xtype: Gtk.TreeViewColumn,
1344 pack : "append_column",
1346 XObject.prototype.init.call(this);
1347 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1351 xtype: Gtk.CellRendererText,
1374 pack : "pack_start,false,true,0",
1381 "button_press_event":function (self, event) {
1382 this.get('/MidPropTree.model').showData('props');
1394 stock : Gtk.STOCK_ADD,
1395 icon_size : Gtk.IconSize.MENU
1410 "button_press_event":function (self, event) {
1411 this.get('/MidPropTree.model').showData('events');
1423 stock : Gtk.STOCK_ADD,
1424 icon_size : Gtk.IconSize.MENU
1439 "button_press_event":function (self, ev) {
1440 var p = this.get('/AddPropertyPopup');
1444 p.el.set_screen(Gdk.Screen.get_default());
1446 p.el.popup(null, null, null, null, 3, ev.button.time);
1458 stock : Gtk.STOCK_ADD,
1459 icon_size : Gtk.IconSize.MENU
1471 id : "AddPropertyPopup",
1474 xtype: Gtk.MenuItem,
1476 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1479 "activate":function (self) {
1481 this.get('/LeftPanel.model').add( {
1492 xtype: Gtk.MenuItem,
1494 tooltip_markup : "Add what type of packing is to be used",
1497 "activate":function (self) {
1499 this.get('/LeftPanel.model').add( {
1509 xtype: Gtk.MenuItem,
1511 tooltip_markup : "Override the init method",
1514 "activate":function (self) {
1516 this.get('/LeftPanel.model').add( {
1519 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1526 xtype: Gtk.SeparatorMenuItem,
1530 xtype: Gtk.MenuItem,
1532 tooltip_markup : "Add a user defined string property",
1535 "activate":function (self) {
1537 this.get('/LeftPanel.model').add( {
1547 xtype: Gtk.MenuItem,
1549 tooltip_markup : "Add a user defined number property",
1552 "activate":function (self) {
1554 this.get('/LeftPanel.model').add( {
1564 xtype: Gtk.MenuItem,
1566 tooltip_markup : "Add a user defined boolean property",
1569 "activate":function (self) {
1571 this.get('/LeftPanel.model').add( {
1581 xtype: Gtk.SeparatorMenuItem,
1585 xtype: Gtk.MenuItem,
1587 tooltip_markup : "Add a user function boolean property",
1590 "activate":function (self) {
1592 this.get('/LeftPanel.model').add( {
1595 val : "function() {\n \n}\n",
1608 xtype: Gtk.ScrolledWindow,
1611 shadow_type : Gtk.ShadowType.IN,
1614 XObject.prototype.init.call(this);
1615 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1619 xtype: Gtk.TreeView,
1622 headers_visible : false,
1623 enable_tree_lines : true,
1625 XObject.prototype.init.call(this);
1627 this.selection = this.el.get_selection();
1628 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1631 var description = new Pango.FontDescription.c_new();
1632 description.set_size(8000);
1633 this.el.modify_font(description);
1636 "button_press_event":function (self, ev) {
1640 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1641 return false; //not on a element.
1645 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1647 if (res.column.title != 'value') {
1648 return false; // ignore..
1650 if ( this.get('/LeftPanel').editing) {
1653 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1654 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1655 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1659 var provider = this.get('/LeftTree').getPaleteProvider();
1661 var opts = provider.findOptions(type);
1663 if (opts === false) {
1664 this.get('/LeftPanel').editableColumn.setOptions([]);
1665 renderer.has_entry = true;
1667 LeftPanel.editableColumn.setOptions(opts);
1668 renderer.has_entry = false;
1672 //Seed.print("click" + ev.type);
1673 //console.dump(res);
1679 if (res.column.title == 'value') {
1682 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1683 var p = this.get('/LeftPanelPopup');
1688 p.el.set_screen(Gdk.Screen.get_default());
1690 p.el.popup(null, null, null, null, 3, ev.button.time);
1691 //Seed.print("click:" + res.column.title);
1699 xtype: Gtk.TreeStore,
1703 XObject.prototype.init.call(this);
1704 this.el.set_column_types ( 5, [
1705 GObject.TYPE_STRING, // 0 real key
1706 GObject.TYPE_STRING, // 1 real value
1707 GObject.TYPE_STRING, // 2 visable key
1708 GObject.TYPE_STRING, // 3 visable value
1709 GObject.TYPE_STRING, // 4 need to store type of!!!
1713 toShort : function(str) {
1714 var a = typeof(str) == 'string' ? str.split("\n") : [];
1715 return a.length > 1 ? a[0] + '....' : '' + str;
1717 load : function(ar) {
1720 this.get('/RightEditor').el.hide();
1727 var provider = this.get('/LeftTree').getPaleteProvider();
1730 var iter = new Gtk.TreeIter();
1732 if (typeof(ar[i]) == 'object') {
1736 var type = provider.findType(ar, i, ar[i]);
1738 this.el.append(iter);
1739 var p = this.el.get_path(iter).to_string();
1741 this.el.set_value(iter, 0, i);
1742 this.el.set_value(iter, 1, '' + ar[i]);
1743 this.el.set_value(iter, 2, i);
1744 this.el.set_value(iter, 3, this.toShort(ar[i]));
1745 this.el.set_value(iter, 4, type);
1747 ar.listeners = ar.listeners || {};
1748 for (var i in ar.listeners ) {
1749 this.el.append(iter);
1750 var p = this.el.get_path(iter).to_string();
1753 this.el.set_value(iter, 0, '!'+ i );
1754 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1755 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1757 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1758 this.el.set_value(iter, 4, 'function');
1762 add : function(info) {
1763 // info includes key, val, skel, etype..
1765 type = info.type.toLowerCase();
1766 var data = this.toJS();
1768 if (info.etype == 'events') {
1769 data.listeners = data.listeners || { };
1770 if (typeof(data.listeners[info.key]) != 'undefined') {
1771 return; //already set!
1774 if (typeof(data[info.key]) != 'undefined') {
1779 if (typeof(info.val) == 'undefined') {
1782 if (info.type == 'boolean') {
1785 if (type == 'number') {
1793 if (info.etype == 'events') {
1795 data.listeners[info.key] = info.val;
1798 data[info.key] = info.val;
1802 var map = this.load(data);
1804 // flag it as changed to the interface..
1806 this.get('/LeftTree.model').changed(data, true);
1809 this.startEditing(map[k]);
1812 LeftPanel.get('view').el.row_activated(
1813 new Gtk.TreePath.from_string(map[k]),
1814 LeftPanel.editableColumn.el
1818 startEditing : function(path,col) {
1820 * start editing path (or selected if not set..)
1821 * @param {String|false} path (optional) treepath to edit - selected tree gets
1822 * edited by default.
1823 * @param {Number} 0 or 1 (optional)- column to edit.
1826 if (typeof(path) == 'string') {
1827 tp = new Gtk.TreePath.from_string(path);
1829 var iter = new Gtk.TreeIter();
1830 var s = this.get('/LeftPanel.view').selection;
1831 s.get_selected(this.el, iter);
1832 tp = this.el.get_path(iter);
1833 path = tp.to_string();
1837 // which colum is to be edited..
1839 if (typeof(col) == 'undefined') {
1840 var k = this.getValue(path, 0);
1841 colObj = (!k.length || k == '|') ?
1842 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1844 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1847 // make sure the pulldown is set correctly..
1848 // not really needed for second col...
1850 var provider = this.get('/LeftTree').getPaleteProvider();
1852 var type = this.get('/LeftPanel.model').getType(path);
1853 var opts = provider.findOptions(type);
1854 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1856 if (opts === false) {
1857 this.get('/LeftPanel').editableColumn.setOptions([]);
1858 renderer.has_entry = true; /// probably does not have any effect.
1860 this.get('/LeftPanel').editableColumn.setOptions(opts);
1861 renderer.has_entry = false;
1865 // iter now has row...
1866 GLib.timeout_add(0, 100, function() {
1868 colObj.items[0].el.editable = true; // esp. need for col 0..
1869 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1878 deleteSelected : function() {
1879 var data = this.toJS();
1880 var iter = new Gtk.TreeIter();
1881 var s = this.get('/LeftPanel.view').selection;
1882 s.get_selected(this.el, iter);
1885 var gval = new GObject.Value('');
1886 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1888 var val = gval.value;
1889 if (val[0] == '!') {
1891 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1894 delete data.listeners[ val.substring(1)];
1895 if (!XObject.keys(data.listeners).length) {
1896 delete data.listeners;
1900 if (typeof(data[val]) == 'undefined') {
1908 this.get('/LeftTree.model').changed(data, true);
1912 changed : function(str, doRefresh) {
1913 if (!this.activePath) {
1916 var iter = new Gtk.TreeIter();
1917 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1919 this.el.set_value(iter, 1, '' +str);
1920 this.el.set_value(iter, 3, '' + this.toShort(str));
1921 // update the tree...
1923 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
1926 var iter = new Gtk.TreeIter();
1927 this.get('/LeftPanel.model').el.get_iter_first(iter);
1932 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
1935 ar.listeners = ar.listeners || {};
1936 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
1939 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
1942 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
1948 //print(JSON.stringify(ar));
1952 getType : function(treepath) {
1953 return this.getValue(treepath, 4);
1955 getValue : function(treepath_str, col) {
1956 var iter = new Gtk.TreeIter();
1957 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
1959 var gval = new GObject.Value('');
1960 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
1961 var val = '' + gval.value;
1965 var type = this.getType(this.el.get_path(iter).to_string());
1966 //print("TYPE: " +type + " - val:" + val);
1967 switch(type.toLowerCase()) {
1971 return parseFloat(val); // Nan ?? invalid!!?
1973 return val == 'true' ? true : false;
1979 editSelected : function(e) {
1980 print("EDIT SELECTED?");
1981 var iter = new Gtk.TreeIter();
1982 var s = this.get('/LeftPanel.view').selection;
1983 s.get_selected(this.get('/LeftPanel.model').el, iter);
1984 var m = this.get('/LeftPanel.model')
1986 var gval = new GObject.Value('');
1987 this.el.get_value(iter, 0 ,gval);
1988 var val = '' + gval.value;
1990 gval = new GObject.Value('');
1991 this.el.get_value(iter, 1 ,gval);
1992 var rval = gval.value;
1993 var activePath = this.el.get_path(iter).to_string();
1994 this.activePath = activePath ;
1995 // was activeIter...
1998 var showEditor = false;
2000 if (val[0] == '!') {
2003 if (val[0] == '|') {
2004 if (rval.match(/function/g) || rval.match(/\n/g)) {
2011 this.activePath = false;
2012 GLib.timeout_add(0, 1, function() {
2013 // Gdk.threads_enter();
2014 _this.get('/RightEditor').el.show();
2015 _this.get('/RightEditor.view').load( rval );
2019 _this.activePath = activePath ;
2021 // Gdk.threads_leave();
2027 this.get('/RightEditor').el.hide();
2029 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2035 xtype: Gtk.TreeViewColumn,
2036 pack : "append_column",
2038 XObject.prototype.init.call(this);
2040 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2041 this.get('/LeftPanel').propertyColumn = this;
2046 xtype: Gtk.CellRendererText,
2047 pack : "pack_start",
2049 "editing_started":function (self, editable, path) {
2051 this.get('/LeftPanel.model').activePath = path;
2054 "edited":function (self, object, p0) {
2055 var model = this.get('/LeftPanel.model');
2056 var path = model.activePath;
2057 var iter = new Gtk.TreeIter();
2058 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2059 model.el.set_value(iter, 0, p0);
2060 model.el.set_value(iter, 2, p0);
2062 model.activePath = false;
2064 this.get('/LeftTree.model').changed(model.toJS(), true);
2065 this.el.editable = false;
2072 xtype: Gtk.TreeViewColumn,
2073 pack : "append_column",
2075 XObject.prototype.init.call(this);
2076 this.el.add_attribute(this.items[0].el , 'text', 3 );
2077 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2078 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2079 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2081 this.get('/LeftPanel').editableColumn= this;
2083 setOptions : function(ar) {
2084 var m = this.items[0].el.model;
2086 var iter = new Gtk.TreeIter();
2087 ar.forEach(function(i) {
2090 m.set_value(iter, 0, i);
2096 xtype: Gtk.CellRendererCombo,
2097 pack : "pack_start",
2102 XObject.prototype.init.call(this);
2103 this.el.model = new Gtk.ListStore();
2104 this.el.model.set_column_types ( 1, [
2105 GObject.TYPE_STRING // 0 real key
2109 "edited":function (self, object, p0) {
2110 this.get('/LeftPanel').editing = false;
2111 print("EDITED? p:" + p0 + " t:" + p0);
2112 this.get('/LeftPanel.model').changed(p0, true);
2113 this.get('/LeftPanel.model').activePath = false;
2115 "editing_started":function (self, editable, path) {
2116 this.get('/LeftPanel').editing = true;
2117 // console.log('editing started');
2118 // r.has_entry = false;
2119 this.get('/LeftPanel.model').editSelected(editable);
2130 id : "LeftPanelPopup",
2133 xtype: Gtk.MenuItem,
2137 "activate":function (self) {
2138 this.get('/LeftPanel.model').deleteSelected();
2143 xtype: Gtk.MenuItem,
2147 "activate":function (self) {
2148 this.get('/LeftPanel.model').startEditing(false, 0);
2161 xtype: Gtk.ScrolledWindow,
2162 pack : "pack_end,false,true,0",
2164 shadow_type : Gtk.ShadowType.IN,
2166 XObject.prototype.init.call(this);
2167 XObject.prototype.init.call(this);
2168 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2169 this.el.set_size_request ( 150, -1 );
2172 activeElement : false,
2173 hideWin : function() {
2180 if (this.get('/Window.left').el.position < 160) {
2183 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2190 xtype: Gtk.TreeView,
2191 enable_tree_lines : true,
2192 headers_visible : false,
2195 XObject.prototype.init.call(this);
2197 var description = new Pango.FontDescription.c_new();
2198 description.set_size(8000);
2199 this.el.modify_font(description);
2201 //this.selection = this.el.get_selection();
2202 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2211 "cursor_changed":function (self) {
2212 var iter = new Gtk.TreeIter();
2214 //console.log('changed');
2215 var m = this.get('model');
2216 if (!this.selection){
2217 this.selection = this.el.get_selection();
2220 var s = this.selection;
2221 if (!s.get_selected(m.el, iter)) {
2224 var tp = m.el.get_path(iter).to_string();
2229 var key = m.getValue(tp, 0);
2231 var type = m.getValue(tp, 1);
2232 var skel = m.getValue(tp, 3);
2233 var etype = m.getValue(tp, 5);
2236 this.get('/MidPropTree').hideWin();
2238 if (type == 'function') {
2240 if (etype != 'events') {
2244 this.get('/LeftPanel.model').add({
2253 if (type.indexOf('.') > -1 ||
2254 type == 'boolean') {
2258 this.get('/LeftPanel.model').add( {
2268 xtype: Gtk.ListStore,
2271 XObject.prototype.init.call(this);
2272 this.el.set_column_types ( 6, [
2273 GObject.TYPE_STRING, // real key
2274 GObject.TYPE_STRING, // real type
2275 GObject.TYPE_STRING, // docs ?
2276 GObject.TYPE_STRING, // visable desc
2277 GObject.TYPE_STRING, // function desc
2278 GObject.TYPE_STRING // element type (event|prop)
2282 getValue : function(treepath, col)
2284 var tp = new Gtk.TreePath.from_string (treepath);
2285 var iter = new Gtk.TreeIter();
2286 this.el.get_iter (iter, tp);
2287 var value = new GObject.Value('');
2288 this.el.get_value(iter, col, value);
2292 showData : function(type) {
2294 if (!this.get('/MidPropTree').activeElement || !type) {
2295 return; // no active element
2298 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2299 var palete = this.get('/LeftTree').getPaleteProvider();
2303 Seed.print('Showing right?');
2304 if (!this.get('/MidPropTree').shown) {
2306 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2307 this.get('/MidPropTree').el.show();
2308 this.get('/MidPropTree').shown = true;
2311 var elementList = palete.getPropertiesFor(fullpath, type);
2312 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2313 // console.dump(elementList);
2316 var iter = new Gtk.TreeIter();
2317 for(var i =0 ; i < elementList.length; i++) {
2318 var p=elementList[i];
2319 this.el.append(iter);
2320 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2321 //GObject.TYPE_STRING, // real key
2322 // GObject.TYPE_STRING, // real type
2323 // GObject.TYPE_STRING, // docs ?
2324 // GObject.TYPE_STRING // func def?
2327 this.el.set_value(iter, 0, p.name);
2328 this.el.set_value(iter, 1, p.type);
2329 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2330 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2331 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2332 this.el.set_value(iter, 5, type);
2340 xtype: Gtk.TreeViewColumn,
2342 this.el = new Gtk.TreeViewColumn();
2343 this.parent.el.append_column(this.el);
2345 XObject.prototype.init.call(this);
2346 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2351 xtype: Gtk.CellRendererText,
2352 pack : "pack_start,true"
2376 xtype: Gtk.Notebook,
2377 pack : "pack_start,true,true",
2378 id : "view-help-nb",
2380 XObject.prototype.init.call(this);
2381 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" }));
2382 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" }));
2386 xtype: Gtk.Notebook,
2388 id : "view-notebook",
2391 XObject.prototype.init.call(this);
2392 this.el.set_current_page(0);
2394 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2395 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2402 id : "RightBrowser",
2406 pack : "pack_start,false,true,0",
2410 pack : "pack_start,false,false,0",
2411 label : "Dump HTML to console",
2413 "activate":function (self) {
2414 this.get('/RightBrowser.view').el.execute_script(
2415 "console.log(document.body.innerHTML);");
2416 this.get('/RightBrowser.view').el.execute_script(
2417 "console.log(Builder.dump(Builder));");
2424 xtype: Gtk.ScrolledWindow,
2426 shadow_type : Gtk.ShadowType.IN,
2428 XObject.prototype.init.call(this);
2429 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2433 xtype: WebKit.WebView,
2437 XObject.prototype.init.call(this);
2438 // this may not work!?
2439 this.el.open('file:///' + __script_path__ + '/../builder.html');
2443 this.el, /* widget that will accept a drop */
2444 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2445 null, /* lists of target to support */
2446 0, /* size of list */
2447 Gdk.DragAction.COPY /* what to do with data after dropped */
2450 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2451 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2453 renderJS : function(data) {
2454 this.renderedData = data;
2455 var str = JSON.stringify(data) ;
2458 console.log('not loaded yet');
2460 Seed.print("RENDER:" + str);
2461 imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2462 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2465 "load_finished":function (self, object) {
2466 if (this.ready) { // dont do it twice!
2471 this.renderJS(this.get('/LeftTree.model').toJS()[0]);
2473 "script_alert":function (self, object, p0) {
2476 return true; // do not display anything...
2478 "console_message":function (self, object, p0, p1) {
2479 console.log(object);
2480 if (!object.match(/^\{/)) {
2481 return false; // do not handle!!! -> later maybe in console..
2483 console.log(object);
2484 var val = JSON.parse(object);
2486 if (typeof(val['hover-node']) != 'undefined') {
2487 this.activeNode = val['hover-node'];
2488 console.log('active node: ' + this.activeNode);
2493 if (typeof(val['id']) != 'undefined') {
2494 // this.activeNode = val['id'];
2495 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2499 this.get('/LeftTree.view').selectNode(tg[0]);
2503 if (ret && typeof(val['set']) != 'undefined') {
2504 this.get('/LeftPanel.model').add({
2508 //console.log('active node: ' + this.activeNode);
2511 //Seed.print('a:'+a);
2512 //Seed.print('b:'+b);
2513 //Seed.print('c:'+c);
2516 "drag_motion":function (w, ctx, x, y, time, ud) {
2517 // console.log('DRAG MOTION');
2519 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2520 this.targetData = [];
2521 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2523 // A) find out from drag all the places that node could be dropped.
2524 var src = Gtk.drag_get_source_widget(ctx);
2525 if (!src.dropList) {
2526 Gdk.drag_status(ctx, 0, time);
2529 // b) get what we are over.. (from activeNode)
2530 // tree is empty.. - list should be correct..
2531 if (!this.get('/LeftTree.model').currentTree) {
2532 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2536 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2538 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2541 Gdk.drag_status(ctx, 0,time);
2542 this.get('/LeftTree.view').highlight(false);
2546 // if we have a target..
2547 // -> highlight it! (in browser)
2548 // -> highlight it! (in tree)
2550 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2551 this.get('/LeftTree.view').highlight(tg);
2552 this.targetData = tg;
2553 // for tree we should handle this...
2556 "drag_drop":function (w, ctx, x, y,time, ud) {
2557 print("TARGET: drag-drop");
2558 var is_valid_drop_site = true;
2563 w, /* will receive 'drag-data-received' signal */
2564 ctx, /* represents the current state of the DnD */
2565 this.get('/Window').atoms["STRING"], /* the target type we want */
2566 time /* time stamp */
2570 /* No target offered by source => error */
2573 return is_valid_drop_site;
2575 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2577 print("Browser: drag-data-received");
2578 var delete_selection_data = false;
2579 vardnd_success = false;
2580 /* Deal with what we are given from source */
2581 if( sel_data && sel_data.length ) {
2583 if (ctx.action == Gdk.DragAction.ASK) {
2584 /* Ask the user to move or copy, then set the ctx action. */
2587 if (ctx.action == Gdk.DragAction.MOVE) {
2588 delete_selection_data = true;
2590 var source = Gtk.drag_get_source_widget(ctx);
2592 print("Browser: source.DRAGDATA? " + source.dragData);
2593 if (this.targetData) {
2594 print(this.targetData);
2595 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2604 if (dnd_success == false)
2606 Seed.print ("DnD data transfer failed!\n");
2609 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2621 id : "RightGtkView",
2622 renderJS : function(data, withDebug)
2627 this.withDebug = false;
2629 if (this.renderedEl) {
2630 this.get('view').el.remove(this.renderedEl);
2631 this.renderedEl.destroy();
2632 this.renderedEl = false;
2635 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2636 // in theory tree is actually window..
2638 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2643 this.get('view').el.set_size_request(
2644 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2647 this.renderedEl.set_size_request(
2648 tree.default_width || 600,
2649 tree.default_height || 400
2651 this.get('view').el.show_all();
2656 showInWindow : function() {
2657 print("GET PROEJCT");
2658 var pr = this.get('/LeftProjectTree').getActiveProject();
2660 console.log(pr.paths);
2663 var src= this.buildJS(
2664 this.get('/LeftTree.model').toJS()[0],
2669 //var x = new imports.sandbox.Context();
2673 Seed.check_syntax('var e = ' + src);
2676 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2677 this.get('/Terminal').feed(console._dump(e)+"\n");
2679 var lines = src.split("\n");
2680 var start = Math.max(0, e.line - 10);
2681 var end = Math.min(lines.length, e.line + 10);
2682 for (var i =start ; i < end; i++) {
2684 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2687 this.get('/Terminal').feed(lines[i] + "\n");
2694 this.get('/BottomPane').el.set_current_page(1);
2695 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2696 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2697 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2699 var _top = x.get_global_object()._top;
2701 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2703 if (_top.el.popup) {
2704 _top.el.popup(null, null, null, null, 3, null);
2708 viewAdd : function(item, par)
2710 // does something similar to xobject..
2711 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2713 if (item.pack===false || item.pack === 'false') { // no ;
2716 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2717 var ns = imports.gi[item['|xns']];
2718 var ctr = ns[item['xtype']];
2720 for(var k in item) {
2722 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2737 if (k[0] == '|' && typeof(kv) == 'string') {
2739 if (kv.match(new RegExp('function'))) {
2742 print("WASL " + k + '=' + kv);
2744 eval( 'kv = ' + kv);
2745 } catch(e) { continue; }
2748 print(k + '=' + kv);
2750 if (k[0] == '|') { // should be boolean or number..
2753 if (k == 'show_tabs') { // force tab showing for notebooks.
2761 var el = new ctr(ctr_args);
2764 //console.dump(item.pack);
2771 if (typeof(item.pack) == 'string') {
2773 item.pack.split(',').forEach(function(e, i) {
2775 if (e == 'false') { args.push( false); return; }
2776 if (e == 'true') { args.push( true); return; }
2777 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2780 //print(args.join(","));
2782 pack_m = args.shift();
2784 pack_m = item.pack.shift();
2789 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2791 name: "ArgumentError",
2792 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2793 "ADDING : " + item.id + " " + el
2802 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2803 //Seed.print('args: ' + args.length);
2805 par[pack_m].apply(par, args);
2809 item.items = item.items || [];
2810 item.items.forEach(function(ch) {
2811 _this.viewAdd(ch, el);
2816 // add the signal handlers.
2817 // is it a widget!?!!?
2823 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2824 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2825 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2826 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2827 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2837 widgetExposeEvent : function() {
2838 /// print("WIDGET EXPOSE"); // draw highlight??
2841 widgetDragMotionEvent : function() {
2842 print("WIDGET DRAGMOTION");
2845 widgetDragDropEvent : function() {
2846 print("WIDGET DRAGDROP");
2849 widgetPressEvent : function(w,e,u,d) {
2850 if (this.get('view').pressed) {
2853 this.get('view').pressed = true;
2854 print("WIDGET PRESS " + d.xtreepath );
2855 this.get('/LeftTree.view').selectNode( d.xtreepath );
2858 widgetReleaseEvent : function() {
2859 this.get('view').pressed = false;
2865 pack : "pack_start,false,true,0",
2869 pack : "pack_start,false,false,0",
2870 label : "Run The Application",
2872 "button_press_event":function (self, event) {
2873 // call render on left tree - with special option!?!
2877 print("GET PROEJCT");
2878 var pr = this.get('/LeftProjectTree').getActiveProject();
2881 for (var i in pr.paths) {
2885 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
2886 print ("RUN DIR:" + dir);
2888 this.get('/BottomPane').el.set_current_page(1);
2889 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
2890 , false,false,false);
2891 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
2892 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2902 xtype: Gtk.ScrolledWindow,
2905 shadow_type : Gtk.ShadowType.IN,
2907 XObject.prototype.init.call(this);
2908 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2912 xtype: Gtk.EventBox,
2913 pack : "add_with_viewport",
2915 XObject.prototype.init.call(this);
2916 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
2917 red: 0x9F00, green: 0xB800 , blue : 0xA800
2925 XObject.prototype.init.call(this);
2926 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
2927 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
2932 xtype: Gtk.EventBox,
2935 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
2936 XObject.prototype.init.call(this);
2940 this.el, /* widget that will accept a drop */
2941 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2942 null, /* lists of target to support */
2943 0, /* size of list */
2944 Gdk.DragAction.COPY /* what to do with data after dropped */
2947 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2948 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2951 getActiveNode : function(x,y)
2953 // workout what node is here..
2954 return '0'; // top..
2958 "drag_motion":function (self, ctx, x, y, time) {
2960 // A) find out from drag all the places that node could be dropped.
2961 var src = Gtk.drag_get_source_widget(ctx);
2962 if (!src.dropList) {
2963 Gdk.drag_status(ctx, 0, time);
2966 // b) get what we are over.. (from activeNode)
2967 // tree is empty.. - list should be correct..
2968 if (!this.get('/LeftTree.model').currentTree) {
2969 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2973 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2974 var activeNode = this.getActiveNode(x, y);
2977 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
2980 Gdk.drag_status(ctx, 0,time);
2981 this.get('/LeftTree.view').highlight(false);
2985 // if we have a target..
2986 // -> highlight it! (in browser)
2987 // -> highlight it! (in tree)
2989 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2990 this.get('/LeftTree.view').highlight(tg);
2991 this.targetData = tg;
2992 // for tree we should handle this...
2995 "drag_drop":function (self,ctx, x, y, time) {
2996 Seed.print("TARGET: drag-drop");
2997 var is_valid_drop_site = true;
3002 self, /* will receive 'drag-data-received' signal */
3003 ctx, /* represents the current state of the this.gDnD */
3004 this.get('/Window').atoms["STRING"], /* the target type we want */
3005 time /* time stamp */
3009 /* No target offered by source => error */
3012 return is_valid_drop_site;
3015 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3017 Seed.print("GtkView: drag-data-received");
3018 var delete_selection_data = false;
3019 var dnd_success = false;
3020 /* Deal with what we are given from source */
3021 if( sel_data && sel_data.length ) {
3023 if (ctx.action == Gdk.DragAction.ASK) {
3024 /* Ask the user to move or copy, then set the ctx action. */
3027 if (ctx.action == Gdk.DragAction.MOVE) {
3028 delete_selection_data = true;
3030 var source = Gtk.drag_get_source_widget(ctx);
3032 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3033 if (this.targetData) {
3034 Seed.print(this.targetData);
3035 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3044 if (dnd_success == false)
3046 Seed.print ("DnD data transfer failed!\n");
3049 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3052 "button_press_event":function (self, event) {
3053 this.pressed = false;
3069 xtype: Gtk.ScrolledWindow,
3074 xtype: WebKit.WebView,
3078 XObject.prototype.init.call(this);
3079 this.get('/Window.help-view').el.open(
3080 "http://devel.akbkhome.com/seed/");
3091 xtype: Gtk.Notebook,
3094 XObject.prototype.init.call(this);
3095 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3096 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3101 xtype: Gtk.ScrolledWindow,
3106 xtype: GtkSource.View,
3110 XObject.prototype.init.call(this);
3111 var description = Pango.Font.description_from_string("monospace")
3112 description.set_size(8000);
3113 this.el.modify_font(description);
3116 load : function(str) {
3118 // show the help page for the active node..
3119 this.get('/Window.view-help-nb').el.set_current_page(1);
3121 // get the active element being edited.
3122 var xtype = this.get('/LeftTree.model').file.guessName(
3123 this.get('/MidPropTree').activeElement);
3124 // now load the help info in the page..
3125 this.get('/Window.help-view').el.open(
3126 "http://devel.akbkhome.com/seed/" + xtype + ".html");
3129 this.get('/BottomPane').el.set_current_page(0);
3130 this.el.get_buffer().set_text(str, str.length);
3131 var lm = GtkSource.LanguageManager.get_default();
3133 this.el.get_buffer().set_language(lm.get_language('js'));
3134 var buf = this.el.get_buffer();
3135 var cursor = buf.get_mark("insert");
3136 var iter= new Gtk.TextIter;
3137 buf.get_iter_at_mark(iter, cursor);
3139 iter.set_line_offset(4);
3140 buf.move_mark(cursor, iter);
3143 cursor = buf.get_mark("selection_bound");
3144 iter= new Gtk.TextIter;
3145 buf.get_iter_at_mark(iter, cursor);
3147 iter.set_line_offset(4);
3148 buf.move_mark(cursor, iter);
3150 this.el.grab_focus();
3154 xtype: GtkSource.Buffer,
3155 pack : "set_buffer",
3157 "changed":function (self) {
3158 var s = new Gtk.TextIter();
3159 var e = new Gtk.TextIter();
3160 this.el.get_start_iter(s);
3161 this.el.get_end_iter(e);
3162 var str = this.el.get_text(s,e,true);
3164 Seed.check_syntax('var e = ' + str);
3166 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3167 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3169 print("SYNTAX ERROR IN EDITOR");
3174 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3175 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3178 this.get('/LeftPanel.model').changed( str , false);
3187 xtype: Gtk.ScrolledWindow,
3191 xtype: Vte.Terminal,
3194 feed : function(str) {
3195 this.el.feed(str,str.length);
3206 pack : "pack_start,false,false",
3210 this.get('buttonbar').el.show();
3211 this.get('viewbox').el.hide();
3212 print("TRIED TO HIDE");
3215 this.get('buttonbar').el.hide();
3216 this.get('viewbox').el.show();
3217 // this.get('model').expanded();
3229 pack : "pack_start,false,true",
3231 "clicked":function (self) {
3232 this.get('/RightPalete').show();
3239 stock : Gtk.STOCK_GOTO_FIRST,
3240 icon_size : Gtk.IconSize.MENU
3250 XObject.prototype.init.call(this);
3251 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3254 "enter_notify_event":function (self, event) {
3255 this.get('/RightPalete').show();
3269 pack : "pack_start,false,true",
3278 pack : "pack_start,false,true",
3280 "clicked":function (self) {
3281 this.get('/RightPalete').hide();
3288 stock : Gtk.STOCK_GOTO_LAST,
3289 icon_size : Gtk.IconSize.MENU
3296 xtype: Gtk.ScrolledWindow,
3299 XObject.prototype.init.call(this);
3300 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3301 this.el.set_size_request(-1,200);
3303 shadow_type : Gtk.ShadowType.IN,
3306 xtype: Gtk.TreeView,
3309 XObject.prototype.init.call(this);
3310 this.el.set_size_request(150,-1);
3311 // set_reorderable: [1]
3313 var description = new Pango.FontDescription.c_new();
3314 description.set_size(8000);
3315 this.el.modify_font(description);
3317 this.selection = this.el.get_selection();
3318 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3319 // this.selection.signal['changed'].connect(function() {
3320 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3322 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3324 Gtk.drag_source_set (
3325 this.el, /* widget will be drag-able */
3326 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3327 null, /* lists of target to support */
3328 0, /* size of list */
3329 Gdk.DragAction.COPY /* what to do with data after dropped */
3331 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3333 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3334 Gtk.drag_source_add_text_targets(this.el);
3336 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3337 targets = new Gtk.TargetList();
3338 targets.add( LeftTree.atoms["STRING"], 0, 0);
3339 targets.add_text_targets( 1 );
3340 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3342 //if you want to allow text to be output elsewhere..
3343 //Gtk.drag_source_add_text_targets(this.el);
3347 headers_visible : false,
3348 enable_tree_lines : true,
3350 "drag_begin":function (self, ctx) {
3351 // we could fill this in now...
3352 Seed.print('SOURCE: drag-begin');
3356 var iter = new Gtk.TreeIter();
3357 var s = this.selection;
3358 s.get_selected(this.get('/RightPalete.model').el, iter);
3359 var path = this.get('/RightPalete.model').el.get_path(iter);
3361 var pix = this.el.create_row_drag_icon ( path);
3364 Gtk.drag_set_icon_pixmap (ctx,
3371 var value = new GObject.Value('');
3372 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3373 if (!this.get('/RightPalete').provider) {
3376 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3377 this.el.dragData = value.value;
3384 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3385 //Seed.print('Palete: drag-data-get: ' + target_type);
3386 if (this.el.dragData && this.el.dragData.length ) {
3387 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3391 //this.el.dragData = "TEST from source widget";
3395 "drag_end":function (self, drag_context) {
3396 Seed.print('SOURCE: drag-end');
3397 this.el.dragData = false;
3398 this.el.dropList = false;
3399 this.get('/LeftTree.view').highlight(false);
3405 xtype: Gtk.ListStore,
3408 XObject.prototype.init.call(this);
3409 this.el.set_column_types ( 2, [
3410 GObject.TYPE_STRING, // title
3411 GObject.TYPE_STRING // tip
3416 load : function(tr,iter)
3421 //console.log('Project tree load: ' + tr.length);
3422 var citer = new Gtk.TreeIter();
3423 //this.insert(citer,iter,0);
3424 for(var i =0 ; i < tr.length; i++) {
3427 this.el.append(citer);
3429 this.el.insert(citer,iter,-1);
3434 this.el.set_value(citer, 0, '' + r ); // title
3436 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3437 //if (r.cn && r.cn.length) {
3438 // this.load(r.cn, citer);
3444 getValue : function (iter, col) {
3445 var gval = new GObject.Value('');
3446 this.el.get_value(iter, col ,gval);
3453 xtype: Gtk.TreeViewColumn,
3454 pack : "append_column",
3456 XObject.prototype.init.call(this);
3457 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3461 xtype: Gtk.CellRendererText,
3483 XObject.cache['/Window'] = Window;