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;
1167 if (typeof(data[ix]) == 'undefined') {
1172 setValue : function(fn)
1176 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1177 data.forEach(function(n, ix) {
1185 "changed":function (self) {
1186 var fn = this.getValue();
1187 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1188 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1193 xtype: Gtk.CellRendererText,
1194 pack : "pack_start,true",
1198 xtype: Gtk.ListStore,
1201 XObject.prototype.init.call(this);
1202 this.el.set_column_types ( 2, [
1203 GObject.TYPE_STRING, // real key
1204 GObject.TYPE_STRING // real type
1208 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1210 pm.on('changed', function() {
1211 print("caught changed hook on project manager - reloading data");
1212 _this.loadData(pm.projects);
1216 loadData : function(data) {
1217 var ov = this.get('/LeftProjectTree.combo').getValue();
1219 var iter = new Gtk.TreeIter();
1221 data.forEach(function(p) {
1226 el.set_value(iter, 0, p.fn);
1227 el.set_value(iter, 1, p.name);
1231 this.get('/LeftProjectTree.combo').setValue(ov);
1240 xtype: Gtk.ScrolledWindow,
1242 shadow_type : Gtk.ShadowType.IN,
1244 XObject.prototype.init.call(this);
1245 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1249 xtype: Gtk.TreeView,
1250 headers_visible : false,
1251 enable_tree_lines : true,
1254 XObject.prototype.init.call(this);
1255 var description = new Pango.FontDescription.c_new();
1256 description.set_size(8000);
1257 this.el.modify_font(description);
1259 this.selection = this.el.get_selection();
1260 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1264 "cursor_changed":function (self) {
1265 var iter = new Gtk.TreeIter();
1267 if (this.selection.count_selected_rows() < 1) {
1268 //XN.get('Builder.LeftTree.model').
1269 this.get('/LeftTree.model').load( false);
1273 var model = this.get('/LeftProjectTree.model');
1274 //console.log('changed');
1275 var s = this.selection;
1276 s.get_selected(model, iter);
1277 value = new GObject.Value('');
1278 model.el.get_value(iter, 2, value);
1280 console.log(value.value);// id..
1282 var file = this.get('/LeftProjectTree').project.getById(value.value);
1289 var nb = this.get('/LeftTopPanel.expander');
1290 nb.el.expanded = false;
1291 nb.listeners.activate.call(nb);
1292 //_expander.el.set_expanded(false);
1294 var ltm = this.get('/LeftTree.model');
1302 xtype: Gtk.TreeStore,
1306 XObject.prototype.init.call(this);
1307 this.el.set_column_types ( 3, [
1308 GObject.TYPE_STRING, // title
1309 GObject.TYPE_STRING, // tip
1310 GObject.TYPE_STRING // id..
1314 loadProject : function(pr) {
1319 this.get('/LeftProjectTree').project = pr;
1320 this.load(pr.toTree());
1321 this.get('/LeftProjectTree.view').el.expand_all();
1323 load : function(tr,iter) {
1325 console.log('Project tree load: ' + tr.length);
1326 var citer = new Gtk.TreeIter();
1327 //this.insert(citer,iter,0);
1330 tr.forEach(function (r) {
1332 _this.el.append(citer);
1334 _this.el.insert(citer,iter,-1);
1336 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1337 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1338 _this.el.set_value(citer, 2, '' + r.id ); //id
1339 if (r.cn && r.cn.length) {
1340 _this.load(r.cn, citer);
1345 getValue : function(iter, col) {
1346 var gval = new GObject.Value('');
1347 this.el.get_value(iter, col ,gval);
1348 return '' + gval.value;
1352 xtype: Gtk.TreeViewColumn,
1353 pack : "append_column",
1355 XObject.prototype.init.call(this);
1356 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1360 xtype: Gtk.CellRendererText,
1383 pack : "pack_start,false,true,0",
1390 "button_press_event":function (self, event) {
1391 this.get('/MidPropTree.model').showData('props');
1403 stock : Gtk.STOCK_ADD,
1404 icon_size : Gtk.IconSize.MENU
1419 "button_press_event":function (self, event) {
1420 this.get('/MidPropTree.model').showData('events');
1432 stock : Gtk.STOCK_ADD,
1433 icon_size : Gtk.IconSize.MENU
1448 "button_press_event":function (self, ev) {
1449 var p = this.get('/AddPropertyPopup');
1453 p.el.set_screen(Gdk.Screen.get_default());
1455 p.el.popup(null, null, null, null, 3, ev.button.time);
1467 stock : Gtk.STOCK_ADD,
1468 icon_size : Gtk.IconSize.MENU
1480 id : "AddPropertyPopup",
1483 xtype: Gtk.MenuItem,
1485 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1488 "activate":function (self) {
1490 this.get('/LeftPanel.model').add( {
1501 xtype: Gtk.MenuItem,
1503 tooltip_markup : "Add what type of packing is to be used",
1506 "activate":function (self) {
1508 this.get('/LeftPanel.model').add( {
1518 xtype: Gtk.MenuItem,
1520 tooltip_markup : "Override the init method",
1523 "activate":function (self) {
1525 this.get('/LeftPanel.model').add( {
1528 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1535 xtype: Gtk.SeparatorMenuItem,
1539 xtype: Gtk.MenuItem,
1541 tooltip_markup : "Add a user defined string property",
1544 "activate":function (self) {
1546 this.get('/LeftPanel.model').add( {
1556 xtype: Gtk.MenuItem,
1558 tooltip_markup : "Add a user defined number property",
1561 "activate":function (self) {
1563 this.get('/LeftPanel.model').add( {
1573 xtype: Gtk.MenuItem,
1575 tooltip_markup : "Add a user defined boolean property",
1578 "activate":function (self) {
1580 this.get('/LeftPanel.model').add( {
1590 xtype: Gtk.SeparatorMenuItem,
1594 xtype: Gtk.MenuItem,
1596 tooltip_markup : "Add a user function boolean property",
1599 "activate":function (self) {
1601 this.get('/LeftPanel.model').add( {
1604 val : "function() {\n \n}\n",
1617 xtype: Gtk.ScrolledWindow,
1620 shadow_type : Gtk.ShadowType.IN,
1623 XObject.prototype.init.call(this);
1624 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1628 xtype: Gtk.TreeView,
1631 headers_visible : false,
1632 enable_tree_lines : true,
1634 XObject.prototype.init.call(this);
1636 this.selection = this.el.get_selection();
1637 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1640 var description = new Pango.FontDescription.c_new();
1641 description.set_size(8000);
1642 this.el.modify_font(description);
1645 "button_press_event":function (self, ev) {
1649 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1650 return false; //not on a element.
1654 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1656 if (res.column.title != 'value') {
1657 return false; // ignore..
1659 if ( this.get('/LeftPanel').editing) {
1662 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1663 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1664 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1668 var provider = this.get('/LeftTree').getPaleteProvider();
1670 var opts = provider.findOptions(type);
1672 if (opts === false) {
1673 this.get('/LeftPanel').editableColumn.setOptions([]);
1674 renderer.has_entry = true;
1676 LeftPanel.editableColumn.setOptions(opts);
1677 renderer.has_entry = false;
1681 //Seed.print("click" + ev.type);
1682 //console.dump(res);
1688 if (res.column.title == 'value') {
1691 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1692 var p = this.get('/LeftPanelPopup');
1697 p.el.set_screen(Gdk.Screen.get_default());
1699 p.el.popup(null, null, null, null, 3, ev.button.time);
1700 //Seed.print("click:" + res.column.title);
1708 xtype: Gtk.TreeStore,
1712 XObject.prototype.init.call(this);
1713 this.el.set_column_types ( 5, [
1714 GObject.TYPE_STRING, // 0 real key
1715 GObject.TYPE_STRING, // 1 real value
1716 GObject.TYPE_STRING, // 2 visable key
1717 GObject.TYPE_STRING, // 3 visable value
1718 GObject.TYPE_STRING, // 4 need to store type of!!!
1722 toShort : function(str) {
1723 var a = typeof(str) == 'string' ? str.split("\n") : [];
1724 return a.length > 1 ? a[0] + '....' : '' + str;
1726 load : function(ar) {
1729 this.get('/RightEditor').el.hide();
1736 var provider = this.get('/LeftTree').getPaleteProvider();
1739 var iter = new Gtk.TreeIter();
1741 if (typeof(ar[i]) == 'object') {
1745 var type = provider.findType(ar, i, ar[i]);
1747 this.el.append(iter);
1748 var p = this.el.get_path(iter).to_string();
1750 this.el.set_value(iter, 0, i);
1751 this.el.set_value(iter, 1, '' + ar[i]);
1752 this.el.set_value(iter, 2, i);
1753 this.el.set_value(iter, 3, this.toShort(ar[i]));
1754 this.el.set_value(iter, 4, type);
1756 ar.listeners = ar.listeners || {};
1757 for (var i in ar.listeners ) {
1758 this.el.append(iter);
1759 var p = this.el.get_path(iter).to_string();
1762 this.el.set_value(iter, 0, '!'+ i );
1763 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1764 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1766 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1767 this.el.set_value(iter, 4, 'function');
1771 add : function(info) {
1772 // info includes key, val, skel, etype..
1774 type = info.type.toLowerCase();
1775 var data = this.toJS();
1777 if (info.etype == 'events') {
1778 data.listeners = data.listeners || { };
1779 if (typeof(data.listeners[info.key]) != 'undefined') {
1780 return; //already set!
1783 if (typeof(data[info.key]) != 'undefined') {
1788 if (typeof(info.val) == 'undefined') {
1791 if (info.type == 'boolean') {
1794 if (type == 'number') {
1802 if (info.etype == 'events') {
1804 data.listeners[info.key] = info.val;
1807 data[info.key] = info.val;
1811 var map = this.load(data);
1813 // flag it as changed to the interface..
1815 this.get('/LeftTree.model').changed(data, true);
1818 this.startEditing(map[k]);
1821 LeftPanel.get('view').el.row_activated(
1822 new Gtk.TreePath.from_string(map[k]),
1823 LeftPanel.editableColumn.el
1827 startEditing : function(path,col) {
1829 * start editing path (or selected if not set..)
1830 * @param {String|false} path (optional) treepath to edit - selected tree gets
1831 * edited by default.
1832 * @param {Number} 0 or 1 (optional)- column to edit.
1835 if (typeof(path) == 'string') {
1836 tp = new Gtk.TreePath.from_string(path);
1838 var iter = new Gtk.TreeIter();
1839 var s = this.get('/LeftPanel.view').selection;
1840 s.get_selected(this.el, iter);
1841 tp = this.el.get_path(iter);
1842 path = tp.to_string();
1846 // which colum is to be edited..
1848 if (typeof(col) == 'undefined') {
1849 var k = this.getValue(path, 0);
1850 colObj = (!k.length || k == '|') ?
1851 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1853 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1856 // make sure the pulldown is set correctly..
1857 // not really needed for second col...
1859 var provider = this.get('/LeftTree').getPaleteProvider();
1861 var type = this.get('/LeftPanel.model').getType(path);
1862 var opts = provider.findOptions(type);
1863 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1865 if (opts === false) {
1866 this.get('/LeftPanel').editableColumn.setOptions([]);
1867 renderer.has_entry = true; /// probably does not have any effect.
1869 this.get('/LeftPanel').editableColumn.setOptions(opts);
1870 renderer.has_entry = false;
1874 // iter now has row...
1875 GLib.timeout_add(0, 100, function() {
1877 colObj.items[0].el.editable = true; // esp. need for col 0..
1878 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1887 deleteSelected : function() {
1888 var data = this.toJS();
1889 var iter = new Gtk.TreeIter();
1890 var s = this.get('/LeftPanel.view').selection;
1891 s.get_selected(this.el, iter);
1894 var gval = new GObject.Value('');
1895 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1897 var val = gval.value;
1898 if (val[0] == '!') {
1900 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1903 delete data.listeners[ val.substring(1)];
1904 if (!XObject.keys(data.listeners).length) {
1905 delete data.listeners;
1909 if (typeof(data[val]) == 'undefined') {
1917 this.get('/LeftTree.model').changed(data, true);
1921 changed : function(str, doRefresh) {
1922 if (!this.activePath) {
1925 var iter = new Gtk.TreeIter();
1926 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1928 this.el.set_value(iter, 1, '' +str);
1929 this.el.set_value(iter, 3, '' + this.toShort(str));
1930 // update the tree...
1932 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
1935 var iter = new Gtk.TreeIter();
1936 this.get('/LeftPanel.model').el.get_iter_first(iter);
1941 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
1944 ar.listeners = ar.listeners || {};
1945 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
1948 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
1951 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
1957 //print(JSON.stringify(ar));
1961 getType : function(treepath) {
1962 return this.getValue(treepath, 4);
1964 getValue : function(treepath_str, col) {
1965 var iter = new Gtk.TreeIter();
1966 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
1968 var gval = new GObject.Value('');
1969 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
1970 var val = '' + gval.value;
1974 var type = this.getType(this.el.get_path(iter).to_string());
1975 //print("TYPE: " +type + " - val:" + val);
1976 switch(type.toLowerCase()) {
1980 return parseFloat(val); // Nan ?? invalid!!?
1982 return val == 'true' ? true : false;
1988 editSelected : function(e) {
1989 print("EDIT SELECTED?");
1990 var iter = new Gtk.TreeIter();
1991 var s = this.get('/LeftPanel.view').selection;
1992 s.get_selected(this.get('/LeftPanel.model').el, iter);
1993 var m = this.get('/LeftPanel.model')
1995 var gval = new GObject.Value('');
1996 this.el.get_value(iter, 0 ,gval);
1997 var val = '' + gval.value;
1999 gval = new GObject.Value('');
2000 this.el.get_value(iter, 1 ,gval);
2001 var rval = gval.value;
2002 var activePath = this.el.get_path(iter).to_string();
2003 this.activePath = activePath ;
2004 // was activeIter...
2007 var showEditor = false;
2009 if (val[0] == '!') {
2012 if (val[0] == '|') {
2013 if (rval.match(/function/g) || rval.match(/\n/g)) {
2020 this.activePath = false;
2021 GLib.timeout_add(0, 1, function() {
2022 // Gdk.threads_enter();
2023 _this.get('/RightEditor').el.show();
2024 _this.get('/RightEditor.view').load( rval );
2028 _this.activePath = activePath ;
2030 // Gdk.threads_leave();
2036 this.get('/RightEditor').el.hide();
2038 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2044 xtype: Gtk.TreeViewColumn,
2045 pack : "append_column",
2047 XObject.prototype.init.call(this);
2049 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2050 this.get('/LeftPanel').propertyColumn = this;
2055 xtype: Gtk.CellRendererText,
2056 pack : "pack_start",
2058 "editing_started":function (self, editable, path) {
2060 this.get('/LeftPanel.model').activePath = path;
2063 "edited":function (self, object, p0) {
2064 var model = this.get('/LeftPanel.model');
2065 var path = model.activePath;
2066 var iter = new Gtk.TreeIter();
2067 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2068 model.el.set_value(iter, 0, p0);
2069 model.el.set_value(iter, 2, p0);
2071 model.activePath = false;
2073 this.get('/LeftTree.model').changed(model.toJS(), true);
2074 this.el.editable = false;
2081 xtype: Gtk.TreeViewColumn,
2082 pack : "append_column",
2084 XObject.prototype.init.call(this);
2085 this.el.add_attribute(this.items[0].el , 'text', 3 );
2086 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2087 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2088 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2090 this.get('/LeftPanel').editableColumn= this;
2092 setOptions : function(ar) {
2093 var m = this.items[0].el.model;
2095 var iter = new Gtk.TreeIter();
2096 ar.forEach(function(i) {
2099 m.set_value(iter, 0, i);
2105 xtype: Gtk.CellRendererCombo,
2106 pack : "pack_start",
2111 XObject.prototype.init.call(this);
2112 this.el.model = new Gtk.ListStore();
2113 this.el.model.set_column_types ( 1, [
2114 GObject.TYPE_STRING // 0 real key
2118 "edited":function (self, object, p0) {
2119 this.get('/LeftPanel').editing = false;
2120 print("EDITED? p:" + p0 + " t:" + p0);
2121 this.get('/LeftPanel.model').changed(p0, true);
2122 this.get('/LeftPanel.model').activePath = false;
2124 "editing_started":function (self, editable, path) {
2125 this.get('/LeftPanel').editing = true;
2126 // console.log('editing started');
2127 // r.has_entry = false;
2128 this.get('/LeftPanel.model').editSelected(editable);
2139 id : "LeftPanelPopup",
2142 xtype: Gtk.MenuItem,
2146 "activate":function (self) {
2147 this.get('/LeftPanel.model').deleteSelected();
2152 xtype: Gtk.MenuItem,
2156 "activate":function (self) {
2157 this.get('/LeftPanel.model').startEditing(false, 0);
2170 xtype: Gtk.ScrolledWindow,
2171 pack : "pack_end,false,true,0",
2173 shadow_type : Gtk.ShadowType.IN,
2175 XObject.prototype.init.call(this);
2176 XObject.prototype.init.call(this);
2177 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2178 this.el.set_size_request ( 150, -1 );
2181 activeElement : false,
2182 hideWin : function() {
2189 if (this.get('/Window.left').el.position < 160) {
2192 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2199 xtype: Gtk.TreeView,
2200 enable_tree_lines : true,
2201 headers_visible : false,
2204 XObject.prototype.init.call(this);
2206 var description = new Pango.FontDescription.c_new();
2207 description.set_size(8000);
2208 this.el.modify_font(description);
2210 //this.selection = this.el.get_selection();
2211 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2220 "cursor_changed":function (self) {
2221 var iter = new Gtk.TreeIter();
2223 //console.log('changed');
2224 var m = this.get('model');
2225 if (!this.selection){
2226 this.selection = this.el.get_selection();
2229 var s = this.selection;
2230 if (!s.get_selected(m.el, iter)) {
2233 var tp = m.el.get_path(iter).to_string();
2238 var key = m.getValue(tp, 0);
2240 var type = m.getValue(tp, 1);
2241 var skel = m.getValue(tp, 3);
2242 var etype = m.getValue(tp, 5);
2245 this.get('/MidPropTree').hideWin();
2247 if (type == 'function') {
2249 if (etype != 'events') {
2253 this.get('/LeftPanel.model').add({
2262 if (type.indexOf('.') > -1 ||
2263 type == 'boolean') {
2267 this.get('/LeftPanel.model').add( {
2277 xtype: Gtk.ListStore,
2280 XObject.prototype.init.call(this);
2281 this.el.set_column_types ( 6, [
2282 GObject.TYPE_STRING, // real key
2283 GObject.TYPE_STRING, // real type
2284 GObject.TYPE_STRING, // docs ?
2285 GObject.TYPE_STRING, // visable desc
2286 GObject.TYPE_STRING, // function desc
2287 GObject.TYPE_STRING // element type (event|prop)
2291 getValue : function(treepath, col)
2293 var tp = new Gtk.TreePath.from_string (treepath);
2294 var iter = new Gtk.TreeIter();
2295 this.el.get_iter (iter, tp);
2296 var value = new GObject.Value('');
2297 this.el.get_value(iter, col, value);
2301 showData : function(type) {
2303 if (!this.get('/MidPropTree').activeElement || !type) {
2304 return; // no active element
2307 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2308 var palete = this.get('/LeftTree').getPaleteProvider();
2312 Seed.print('Showing right?');
2313 if (!this.get('/MidPropTree').shown) {
2315 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2316 this.get('/MidPropTree').el.show();
2317 this.get('/MidPropTree').shown = true;
2320 var elementList = palete.getPropertiesFor(fullpath, type);
2321 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2322 // console.dump(elementList);
2325 var iter = new Gtk.TreeIter();
2326 for(var i =0 ; i < elementList.length; i++) {
2327 var p=elementList[i];
2328 this.el.append(iter);
2329 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2330 //GObject.TYPE_STRING, // real key
2331 // GObject.TYPE_STRING, // real type
2332 // GObject.TYPE_STRING, // docs ?
2333 // GObject.TYPE_STRING // func def?
2336 this.el.set_value(iter, 0, p.name);
2337 this.el.set_value(iter, 1, p.type);
2338 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2339 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2340 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2341 this.el.set_value(iter, 5, type);
2349 xtype: Gtk.TreeViewColumn,
2351 this.el = new Gtk.TreeViewColumn();
2352 this.parent.el.append_column(this.el);
2354 XObject.prototype.init.call(this);
2355 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2360 xtype: Gtk.CellRendererText,
2361 pack : "pack_start,true"
2385 xtype: Gtk.Notebook,
2386 pack : "pack_start,true,true",
2387 id : "view-help-nb",
2389 XObject.prototype.init.call(this);
2390 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" }));
2391 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" }));
2395 xtype: Gtk.Notebook,
2397 id : "view-notebook",
2400 XObject.prototype.init.call(this);
2401 this.el.set_current_page(0);
2403 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2404 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2411 id : "RightBrowser",
2415 pack : "pack_start,false,true,0",
2419 pack : "pack_start,false,false,0",
2420 label : "Dump HTML to console",
2422 "activate":function (self) {
2423 this.get('/RightBrowser.view').el.execute_script(
2424 "console.log(document.body.innerHTML);");
2425 this.get('/RightBrowser.view').el.execute_script(
2426 "console.log(Builder.dump(Builder));");
2433 xtype: Gtk.ScrolledWindow,
2435 shadow_type : Gtk.ShadowType.IN,
2437 XObject.prototype.init.call(this);
2438 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2442 xtype: WebKit.WebView,
2446 XObject.prototype.init.call(this);
2447 // this may not work!?
2448 this.el.open('file:///' + __script_path__ + '/../builder.html');
2452 this.el, /* widget that will accept a drop */
2453 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2454 null, /* lists of target to support */
2455 0, /* size of list */
2456 Gdk.DragAction.COPY /* what to do with data after dropped */
2459 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2460 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2462 renderJS : function(data) {
2463 this.renderedData = data;
2464 var str = JSON.stringify(data) ;
2467 console.log('not loaded yet');
2469 Seed.print("RENDER:" + str);
2470 imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2471 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2474 "load_finished":function (self, object) {
2475 if (this.ready) { // dont do it twice!
2480 this.renderJS(this.get('/LeftTree.model').toJS()[0]);
2482 "script_alert":function (self, object, p0) {
2485 return true; // do not display anything...
2487 "console_message":function (self, object, p0, p1) {
2488 console.log(object);
2489 if (!object.match(/^\{/)) {
2490 return false; // do not handle!!! -> later maybe in console..
2492 console.log(object);
2493 var val = JSON.parse(object);
2495 if (typeof(val['hover-node']) != 'undefined') {
2496 this.activeNode = val['hover-node'];
2497 console.log('active node: ' + this.activeNode);
2502 if (typeof(val['id']) != 'undefined') {
2503 // this.activeNode = val['id'];
2504 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2508 this.get('/LeftTree.view').selectNode(tg[0]);
2512 if (ret && typeof(val['set']) != 'undefined') {
2513 this.get('/LeftPanel.model').add({
2517 //console.log('active node: ' + this.activeNode);
2520 //Seed.print('a:'+a);
2521 //Seed.print('b:'+b);
2522 //Seed.print('c:'+c);
2525 "drag_motion":function (w, ctx, x, y, time, ud) {
2526 // console.log('DRAG MOTION');
2528 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2529 this.targetData = [];
2530 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2532 // A) find out from drag all the places that node could be dropped.
2533 var src = Gtk.drag_get_source_widget(ctx);
2534 if (!src.dropList) {
2535 Gdk.drag_status(ctx, 0, time);
2538 // b) get what we are over.. (from activeNode)
2539 // tree is empty.. - list should be correct..
2540 if (!this.get('/LeftTree.model').currentTree) {
2541 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2545 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2547 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2550 Gdk.drag_status(ctx, 0,time);
2551 this.get('/LeftTree.view').highlight(false);
2555 // if we have a target..
2556 // -> highlight it! (in browser)
2557 // -> highlight it! (in tree)
2559 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2560 this.get('/LeftTree.view').highlight(tg);
2561 this.targetData = tg;
2562 // for tree we should handle this...
2565 "drag_drop":function (w, ctx, x, y,time, ud) {
2566 print("TARGET: drag-drop");
2567 var is_valid_drop_site = true;
2572 w, /* will receive 'drag-data-received' signal */
2573 ctx, /* represents the current state of the DnD */
2574 this.get('/Window').atoms["STRING"], /* the target type we want */
2575 time /* time stamp */
2579 /* No target offered by source => error */
2582 return is_valid_drop_site;
2584 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2586 print("Browser: drag-data-received");
2587 var delete_selection_data = false;
2588 vardnd_success = false;
2589 /* Deal with what we are given from source */
2590 if( sel_data && sel_data.length ) {
2592 if (ctx.action == Gdk.DragAction.ASK) {
2593 /* Ask the user to move or copy, then set the ctx action. */
2596 if (ctx.action == Gdk.DragAction.MOVE) {
2597 delete_selection_data = true;
2599 var source = Gtk.drag_get_source_widget(ctx);
2601 print("Browser: source.DRAGDATA? " + source.dragData);
2602 if (this.targetData) {
2603 print(this.targetData);
2604 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2613 if (dnd_success == false)
2615 Seed.print ("DnD data transfer failed!\n");
2618 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2630 id : "RightGtkView",
2631 renderJS : function(data, withDebug)
2636 this.withDebug = false;
2638 if (this.renderedEl) {
2639 this.get('view').el.remove(this.renderedEl);
2640 this.renderedEl.destroy();
2641 this.renderedEl = false;
2644 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2645 // in theory tree is actually window..
2647 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2652 this.get('view').el.set_size_request(
2653 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2656 this.renderedEl.set_size_request(
2657 tree.default_width || 600,
2658 tree.default_height || 400
2660 this.get('view').el.show_all();
2665 showInWindow : function() {
2666 print("GET PROEJCT");
2667 var pr = this.get('/LeftProjectTree').getActiveProject();
2669 console.log(pr.paths);
2672 var src= this.buildJS(
2673 this.get('/LeftTree.model').toJS()[0],
2678 //var x = new imports.sandbox.Context();
2682 Seed.check_syntax('var e = ' + src);
2685 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2686 this.get('/Terminal').feed(console._dump(e)+"\n");
2688 var lines = src.split("\n");
2689 var start = Math.max(0, e.line - 10);
2690 var end = Math.min(lines.length, e.line + 10);
2691 for (var i =start ; i < end; i++) {
2693 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2696 this.get('/Terminal').feed(lines[i] + "\n");
2703 this.get('/BottomPane').el.set_current_page(1);
2704 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2705 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2706 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2708 var _top = x.get_global_object()._top;
2710 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2712 if (_top.el.popup) {
2713 _top.el.popup(null, null, null, null, 3, null);
2717 viewAdd : function(item, par)
2719 // does something similar to xobject..
2720 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2722 if (item.pack===false || item.pack === 'false') { // no ;
2725 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2726 var ns = imports.gi[item['|xns']];
2727 var ctr = ns[item['xtype']];
2729 for(var k in item) {
2731 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2746 if (k[0] == '|' && typeof(kv) == 'string') {
2748 if (kv.match(new RegExp('function'))) {
2751 print("WASL " + k + '=' + kv);
2753 eval( 'kv = ' + kv);
2754 } catch(e) { continue; }
2757 print(k + '=' + kv);
2759 if (k[0] == '|') { // should be boolean or number..
2761 print(k + '=' + kv);
2764 if (k == 'show_tabs') { // force tab showing for notebooks.
2772 var el = new ctr(ctr_args);
2775 //console.dump(item.pack);
2782 if (typeof(item.pack) == 'string') {
2784 item.pack.split(',').forEach(function(e, i) {
2786 if (e == 'false') { args.push( false); return; }
2787 if (e == 'true') { args.push( true); return; }
2788 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2791 //print(args.join(","));
2793 pack_m = args.shift();
2795 pack_m = item.pack.shift();
2800 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2802 name: "ArgumentError",
2803 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2804 "ADDING : " + item.id + " " + el
2813 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2814 //Seed.print('args: ' + args.length);
2816 par[pack_m].apply(par, args);
2820 item.items = item.items || [];
2821 item.items.forEach(function(ch) {
2822 _this.viewAdd(ch, el);
2827 // add the signal handlers.
2828 // is it a widget!?!!?
2834 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2835 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2836 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2837 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2838 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2848 widgetExposeEvent : function() {
2849 /// print("WIDGET EXPOSE"); // draw highlight??
2852 widgetDragMotionEvent : function() {
2853 print("WIDGET DRAGMOTION");
2856 widgetDragDropEvent : function() {
2857 print("WIDGET DRAGDROP");
2860 widgetPressEvent : function(w,e,u,d) {
2861 if (this.get('view').pressed) {
2864 this.get('view').pressed = true;
2865 print("WIDGET PRESS " + d.xtreepath );
2866 this.get('/LeftTree.view').selectNode( d.xtreepath );
2869 widgetReleaseEvent : function() {
2870 this.get('view').pressed = false;
2876 pack : "pack_start,false,true,0",
2880 pack : "pack_start,false,false,0",
2881 label : "Run The Application",
2883 "button_press_event":function (self, event) {
2884 // call render on left tree - with special option!?!
2888 print("GET PROEJCT");
2889 var pr = this.get('/LeftProjectTree').getActiveProject();
2892 for (var i in pr.paths) {
2896 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
2897 print ("RUN DIR:" + dir);
2899 this.get('/BottomPane').el.set_current_page(1);
2900 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
2901 , false,false,false);
2902 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
2903 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2913 xtype: Gtk.ScrolledWindow,
2916 shadow_type : Gtk.ShadowType.IN,
2918 XObject.prototype.init.call(this);
2919 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2923 xtype: Gtk.EventBox,
2924 pack : "add_with_viewport",
2926 XObject.prototype.init.call(this);
2927 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
2928 red: 0x9F00, green: 0xB800 , blue : 0xA800
2936 XObject.prototype.init.call(this);
2937 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
2938 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
2943 xtype: Gtk.EventBox,
2946 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
2947 XObject.prototype.init.call(this);
2951 this.el, /* widget that will accept a drop */
2952 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2953 null, /* lists of target to support */
2954 0, /* size of list */
2955 Gdk.DragAction.COPY /* what to do with data after dropped */
2958 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2959 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2962 getActiveNode : function(x,y)
2964 // workout what node is here..
2965 return '0'; // top..
2969 "drag_motion":function (self, ctx, x, y, time) {
2971 // A) find out from drag all the places that node could be dropped.
2972 var src = Gtk.drag_get_source_widget(ctx);
2973 if (!src.dropList) {
2974 Gdk.drag_status(ctx, 0, time);
2977 // b) get what we are over.. (from activeNode)
2978 // tree is empty.. - list should be correct..
2979 if (!this.get('/LeftTree.model').currentTree) {
2980 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2984 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2985 var activeNode = this.getActiveNode(x, y);
2988 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
2991 Gdk.drag_status(ctx, 0,time);
2992 this.get('/LeftTree.view').highlight(false);
2996 // if we have a target..
2997 // -> highlight it! (in browser)
2998 // -> highlight it! (in tree)
3000 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3001 this.get('/LeftTree.view').highlight(tg);
3002 this.targetData = tg;
3003 // for tree we should handle this...
3006 "drag_drop":function (self,ctx, x, y, time) {
3007 Seed.print("TARGET: drag-drop");
3008 var is_valid_drop_site = true;
3013 self, /* will receive 'drag-data-received' signal */
3014 ctx, /* represents the current state of the this.gDnD */
3015 this.get('/Window').atoms["STRING"], /* the target type we want */
3016 time /* time stamp */
3020 /* No target offered by source => error */
3023 return is_valid_drop_site;
3026 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3028 Seed.print("GtkView: drag-data-received");
3029 var delete_selection_data = false;
3030 var dnd_success = false;
3031 /* Deal with what we are given from source */
3032 if( sel_data && sel_data.length ) {
3034 if (ctx.action == Gdk.DragAction.ASK) {
3035 /* Ask the user to move or copy, then set the ctx action. */
3038 if (ctx.action == Gdk.DragAction.MOVE) {
3039 delete_selection_data = true;
3041 var source = Gtk.drag_get_source_widget(ctx);
3043 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3044 if (this.targetData) {
3045 Seed.print(this.targetData);
3046 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3055 if (dnd_success == false)
3057 Seed.print ("DnD data transfer failed!\n");
3060 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3063 "button_press_event":function (self, event) {
3064 this.pressed = false;
3080 xtype: Gtk.ScrolledWindow,
3085 xtype: WebKit.WebView,
3089 XObject.prototype.init.call(this);
3090 this.get('/Window.help-view').el.open(
3091 "http://devel.akbkhome.com/seed/");
3102 xtype: Gtk.Notebook,
3105 XObject.prototype.init.call(this);
3106 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3107 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3112 xtype: Gtk.ScrolledWindow,
3117 xtype: GtkSource.View,
3121 XObject.prototype.init.call(this);
3122 var description = Pango.Font.description_from_string("monospace")
3123 description.set_size(8000);
3124 this.el.modify_font(description);
3127 load : function(str) {
3129 // show the help page for the active node..
3130 this.get('/Window.view-help-nb').el.set_current_page(1);
3132 // get the active element being edited.
3133 var xtype = this.get('/LeftTree.model').file.guessName(
3134 this.get('/MidPropTree').activeElement);
3135 // now load the help info in the page..
3136 this.get('/Window.help-view').el.open(
3137 "http://devel.akbkhome.com/seed/" + xtype + ".html");
3140 this.get('/BottomPane').el.set_current_page(0);
3141 this.el.get_buffer().set_text(str, str.length);
3142 var lm = GtkSource.LanguageManager.get_default();
3144 this.el.get_buffer().set_language(lm.get_language('js'));
3145 var buf = this.el.get_buffer();
3146 var cursor = buf.get_mark("insert");
3147 var iter= new Gtk.TextIter;
3148 buf.get_iter_at_mark(iter, cursor);
3150 iter.set_line_offset(4);
3151 buf.move_mark(cursor, iter);
3154 cursor = buf.get_mark("selection_bound");
3155 iter= new Gtk.TextIter;
3156 buf.get_iter_at_mark(iter, cursor);
3158 iter.set_line_offset(4);
3159 buf.move_mark(cursor, iter);
3161 this.el.grab_focus();
3163 insert_spaces_instead_of_tabs : true,
3166 show_line_numbers : true,
3169 xtype: GtkSource.Buffer,
3170 pack : "set_buffer",
3172 "changed":function (self) {
3173 var s = new Gtk.TextIter();
3174 var e = new Gtk.TextIter();
3175 this.el.get_start_iter(s);
3176 this.el.get_end_iter(e);
3177 var str = this.el.get_text(s,e,true);
3179 Seed.check_syntax('var e = ' + str);
3181 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3182 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3184 print("SYNTAX ERROR IN EDITOR");
3189 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3190 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3193 this.get('/LeftPanel.model').changed( str , false);
3202 xtype: Gtk.ScrolledWindow,
3206 xtype: Vte.Terminal,
3209 feed : function(str) {
3210 this.el.feed(str,str.length);
3221 pack : "pack_start,false,false",
3225 this.get('buttonbar').el.show();
3226 this.get('viewbox').el.hide();
3227 print("TRIED TO HIDE");
3230 this.get('buttonbar').el.hide();
3231 this.get('viewbox').el.show();
3232 // this.get('model').expanded();
3244 pack : "pack_start,false,true",
3246 "clicked":function (self) {
3247 this.get('/RightPalete').show();
3254 stock : Gtk.STOCK_GOTO_FIRST,
3255 icon_size : Gtk.IconSize.MENU
3265 XObject.prototype.init.call(this);
3266 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3269 "enter_notify_event":function (self, event) {
3270 this.get('/RightPalete').show();
3284 pack : "pack_start,false,true",
3293 pack : "pack_start,false,true",
3295 "clicked":function (self) {
3296 this.get('/RightPalete').hide();
3303 stock : Gtk.STOCK_GOTO_LAST,
3304 icon_size : Gtk.IconSize.MENU
3311 xtype: Gtk.ScrolledWindow,
3314 XObject.prototype.init.call(this);
3315 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3316 this.el.set_size_request(-1,200);
3318 shadow_type : Gtk.ShadowType.IN,
3321 xtype: Gtk.TreeView,
3324 XObject.prototype.init.call(this);
3325 this.el.set_size_request(150,-1);
3326 // set_reorderable: [1]
3328 var description = new Pango.FontDescription.c_new();
3329 description.set_size(8000);
3330 this.el.modify_font(description);
3332 this.selection = this.el.get_selection();
3333 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3334 // this.selection.signal['changed'].connect(function() {
3335 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3337 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3339 Gtk.drag_source_set (
3340 this.el, /* widget will be drag-able */
3341 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3342 null, /* lists of target to support */
3343 0, /* size of list */
3344 Gdk.DragAction.COPY /* what to do with data after dropped */
3346 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3348 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3349 Gtk.drag_source_add_text_targets(this.el);
3351 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3352 targets = new Gtk.TargetList();
3353 targets.add( LeftTree.atoms["STRING"], 0, 0);
3354 targets.add_text_targets( 1 );
3355 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3357 //if you want to allow text to be output elsewhere..
3358 //Gtk.drag_source_add_text_targets(this.el);
3362 headers_visible : false,
3363 enable_tree_lines : true,
3365 "drag_begin":function (self, ctx) {
3366 // we could fill this in now...
3367 Seed.print('SOURCE: drag-begin');
3371 var iter = new Gtk.TreeIter();
3372 var s = this.selection;
3373 s.get_selected(this.get('/RightPalete.model').el, iter);
3374 var path = this.get('/RightPalete.model').el.get_path(iter);
3376 var pix = this.el.create_row_drag_icon ( path);
3379 Gtk.drag_set_icon_pixmap (ctx,
3386 var value = new GObject.Value('');
3387 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3388 if (!this.get('/RightPalete').provider) {
3391 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3392 this.el.dragData = value.value;
3399 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3400 //Seed.print('Palete: drag-data-get: ' + target_type);
3401 if (this.el.dragData && this.el.dragData.length ) {
3402 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3406 //this.el.dragData = "TEST from source widget";
3410 "drag_end":function (self, drag_context) {
3411 Seed.print('SOURCE: drag-end');
3412 this.el.dragData = false;
3413 this.el.dropList = false;
3414 this.get('/LeftTree.view').highlight(false);
3420 xtype: Gtk.ListStore,
3423 XObject.prototype.init.call(this);
3424 this.el.set_column_types ( 2, [
3425 GObject.TYPE_STRING, // title
3426 GObject.TYPE_STRING // tip
3431 load : function(tr,iter)
3436 //console.log('Project tree load: ' + tr.length);
3437 var citer = new Gtk.TreeIter();
3438 //this.insert(citer,iter,0);
3439 for(var i =0 ; i < tr.length; i++) {
3442 this.el.append(citer);
3444 this.el.insert(citer,iter,-1);
3449 this.el.set_value(citer, 0, '' + r ); // title
3451 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3452 //if (r.cn && r.cn.length) {
3453 // this.load(r.cn, citer);
3459 getValue : function (iter, col) {
3460 var gval = new GObject.Value('');
3461 this.el.get_value(iter, col ,gval);
3468 xtype: Gtk.TreeViewColumn,
3469 pack : "append_column",
3471 XObject.prototype.init.call(this);
3472 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3476 xtype: Gtk.CellRendererText,
3498 XObject.cache['/Window'] = Window;