3 Pango = imports.gi.Pango;
4 GLib = imports.gi.GLib;
6 GObject = imports.gi.GObject;
7 GtkSource = imports.gi.GtkSource;
8 WebKit = imports.gi.WebKit;
10 console = imports.console;
11 XObject = imports.XObject.XObject;
14 type : Gtk.WindowType.TOPLEVEL,
15 title : "Application Builder",
19 "STRING" : Gdk.atom_intern("STRING")
21 this.targetList = new Gtk.TargetList();
22 this.targetList.add( this.atoms["STRING"], 0, 0);
23 //imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();
25 "style \"gtkcombobox-style\" {\n" +
26 " GtkComboBox::appears-as-list = 1\n" +
28 "class \"GtkComboBox\" style \"gtkcombobox-style\"\n");
29 XObject.prototype.init.call(this);
39 "delete_event":function (self, event) {
42 "destroy":function (self) {
45 "show":function (self) {
46 print("WINDOW SHOWING - trying to hide");
47 imports.Builder.Provider.ProjectManager.ProjectManager.loadConfig();
48 this.get('/MidPropTree').hideWin();
49 this.get('/RightPalete').hide();
50 this.get('/BottomPane').el.hide();
61 pack : "pack_start,false,false",
75 label : "New _Project",
77 "activate":function (self) {
79 this.get('/EditProject').show({
80 success : function(pr) {
81 _this.get('/LeftProjectTree').get('combo').setValue(pr.fn);
92 "activate":function (self) {
93 var fn = this.get('/LeftProjectTree.combo').getValue();
95 this.get('/LeftProjectTree').showNoProjectSelected();
98 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
99 this.get('/DialogNewComponent').show({
100 project : pm.getByFn(fn)
106 xtype: Gtk.SeparatorMenuItem,
111 use_underline : true,
113 label : "D_elete Project",
115 "activate":function (self) {
117 var fn = this.get('/LeftProjectTree').get('combo').getValue();
119 this.get('/StandardErrorDialog').show("Select a project")
122 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
123 var pr = pm.getByFn(fn);
126 this.get('/DialogConfirm').show("Are you sure you want to delete project '" + pr.name + "'", function() {
127 pm.deleteProject(fn);
135 xtype: Gtk.SeparatorMenuItem,
142 use_underline : true,
144 "activate":function (self) {
178 label : "Select Project",
180 pack : "pack_start,false,true",
182 XObject.prototype.init.call(this);
183 this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
186 "activate":function (self) {
187 var nb = this.get('/LeftTopPanel.notebook');
188 if (this.el.expanded) {
191 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
194 var model = this.get('/LeftProjectTree.combomodel');
195 // print ("loading Projects?")
196 //console.dump(pm.projects);
197 model.loadData(pm.projects);
200 nb.el.set_current_page(1);
201 //pm.on('changed', function() {
202 //console.log("CAUGHT project manager change");
203 // _combo.model.loadData(pm.projects);
207 nb.el.set_current_page(0);
209 "enter_notify_event":function (self, event) {
210 this.el.expanded = !this.el.expanded;
211 //if (this.el.expanded ) {
212 this.listeners.activate.call(this);
224 pack : "pack_start,true,true",
226 XObject.prototype.init.call(this);
227 this.el.set_current_page(0);
232 xtype: Gtk.ScrolledWindow,
234 shadow_type : Gtk.ShadowType.IN,
236 XObject.prototype.init.call(this);
237 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
240 getPaleteProvider : function() {
241 var model = this.get('model');
242 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
243 return pm.getPalete(model.file.getType());
245 renderView : function() {
246 var model = this.get('model');
247 print("RENDER VIEW?" + model.file.getType());
248 switch( model.file.getType()) {
250 this.get('/RightBrowser.view').renderJS(model.toJS(false,true)[0]);
252 this.get('/RightGtkView').renderJS(model.toJS(false,true)[0]);
260 headers_visible : false,
261 enable_tree_lines : true,
264 XObject.prototype.init.call(this);
265 var description = new Pango.FontDescription.c_new();
266 description.set_size(8000);
267 this.el.modify_font(description);
269 this.selection = this.el.get_selection();
270 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
272 this.selection.signal['changed'].connect(function() {
273 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
274 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
278 Gtk.drag_source_set (
279 this.el, /* widget will be drag-able */
280 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
281 null, /* lists of target to support */
282 0, /* size of list */
283 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
286 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
288 Gtk.drag_source_add_text_targets(this.el);
291 this.el, /* widget that will accept a drop */
292 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
293 null, /* lists of target to support */
294 0, /* size of list */
295 Gdk.DragAction.COPY | Gdk.DragAction.MOVE /* what to do with data after dropped */
298 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
299 Gtk.drag_dest_add_text_targets(this.el);
301 highlight : function(treepath_ar) {
302 if (treepath_ar.length && treepath_ar[0].length ) {
303 this.el.set_drag_dest_row(
304 new Gtk.TreePath.from_string( treepath_ar[0] ), treepath_ar[1]);
306 this.el.set_drag_dest_row(null, Gtk.TreeViewDropPosition.INTO_OR_AFTER);
310 selectNode : function(treepath_str) {
311 //this.selection.select_path(new Gtk.TreePath.from_string( treepath_str));
312 var tp = new Gtk.TreePath.from_string(treepath_str);
313 this.el.set_cursor(tp, null, false);
314 this.el.scroll_to_cell(tp, null, false, 0,0);
317 "button_press_event":function (self, ev) {
318 console.log("button press?");
319 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
320 print("click" + ev.type);
326 this.get('/LeftTree.view').el.get_path_at_pos(ev.button.x,ev.button.y, res);
328 if (!this.get('/LeftTreeMenu').el) this.get('/LeftTreeMenu').init();
330 this.get('/LeftTreeMenu').el.set_screen(Gdk.Screen.get_default());
331 this.get('/LeftTreeMenu').el.show_all();
332 this.get('/LeftTreeMenu').el.popup(null, null, null, null, 3, ev.button.time);
333 print("click:" + res.path.to_string());
336 "drag_begin":function (self, drag_context) {
337 print('SOURCE: drag-begin');
338 this.targetData = false;
339 // find what is selected in our tree...
340 var iter = new Gtk.TreeIter();
341 var s = this.selection;
342 s.get_selected(this.get('/LeftTree.model').el, iter);
344 // set some properties of the tree for use by the dropped element.
345 var value = new GObject.Value('');
346 this.get('/LeftTree.model').el.get_value(iter, 2, value);
347 var data = JSON.parse(value.value);
348 var xname = this.get('/LeftTree.model').file.guessName(data);
350 this.el.dragData = xname;
351 this.el.dropList = this.get('/LeftTree').getPaleteProvider().getDropList(xname);
354 // make the drag icon a picture of the node that was selected
355 var path = this.get('/LeftTree.model').el.get_path(iter);
356 this.el.treepath = path.to_string();
358 var pix = this.el.create_row_drag_icon ( path);
360 Gtk.drag_set_icon_pixmap (ctx,
369 "drag_end":function (self, drag_context) {
370 Seed.print('LEFT-TREE: drag-end');
371 this.el.dragData = false;
372 this.el.dropList = false;
373 this.targetData = false;
374 this.get('/LeftTree.view').highlight(false);
377 "drag_motion":function (self, ctx, x, y, time) {
378 console.log("LEFT-TREE: drag-motion");
379 var src = Gtk.drag_get_source_widget(ctx);
381 // a drag from elsewhere...- prevent drop..
383 print("no drag data!");
384 Gdk.drag_status(ctx, 0, time);
385 this.targetData = false;
388 var action = Gdk.DragAction.COPY;
389 if (src == this.el) {
390 // unless we are copying!!! ctl button..
391 action = ctx.actions & Gdk.DragAction.MOVE ? Gdk.DragAction.MOVE : Gdk.DragAction.COPY ;
395 if (!this.get('/LeftTree.model').el.iter_n_children(null)) {
396 // no children.. -- asume it's ok..
397 this.targetData = [ '' , Gtk.TreeViewDropPosition.INTO_OR_AFTER , ''];
398 Gdk.drag_status(ctx, action ,time);
402 print("GETTING POS");
403 var isOver = this.get('/LeftTree.view').el.get_dest_row_at_pos(x,y, data);
404 print("ISOVER? " + isOver);
406 Gdk.drag_status(ctx, 0 ,time);
407 return false; // not over apoint!?!
409 // drag node is parent of child..
410 console.log("SRC TREEPATH: " + src.treepath);
411 console.log("TARGET TREEPATH: " + data.path.to_string());
413 // nned to check a few here..
414 //Gtk.TreeViewDropPosition.INTO_OR_AFTER
415 //Gtk.TreeViewDropPosition.INTO_OR_BEFORE
416 //Gtk.TreeViewDropPosition.AFTER
417 //Gtk.TreeViewDropPosition.BEFORE
419 if (typeof(src.treepath) != 'undefined' &&
420 src.treepath == data.path.to_string().substring(0,src.treepath.length)) {
421 print("subpath drag");
422 Gdk.drag_status(ctx, 0 ,time);
427 //print("DUMPING DATA");
428 //console.dump(data);
431 print(data.path.to_string() +' => '+ data.pos);
432 var tg = this.get('/LeftTree.model').findDropNodeByPath(
433 data.path.to_string(), src.dropList, data.pos);
435 this.get('/LeftTree.view').highlight(tg);
437 print("Can not find drop node path");
438 this.targetData = false;
439 Gdk.drag_status(ctx, 0, time);
443 this.targetData = tg;
446 Gdk.drag_status(ctx, action ,time);
450 "drag_drop":function (w, ctx, x, y, time) {
451 Seed.print("TARGET: drag-drop");
455 w, /* will receive 'drag-data-received' signal */
456 ctx, /* represents the current state of the DnD */
457 this.get('/Window').atoms["STRING"], /* the target type we want */
458 time /* time stamp */
462 /* No target offered by source => error */
467 "drag_data_received":function (self, ctx, x, y, sel_data, info, time) {
468 print("Tree: drag-data-received");
470 var delete_selection_data = false;
471 var dnd_success = false;
472 /* Deal with what we are given from source */
473 if( sel_data && sel_data.length ) {
475 if (ctx.action == Gdk.DragAction.ASK) {
476 /* Ask the user to move or copy, then set the ctx action. */
479 if (ctx.action == Gdk.DragAction.MOVE) {
480 //delete_selection_data = true;
483 var source = Gtk.drag_get_source_widget(ctx);
485 if (this.targetData) {
486 if (source != this.el) {
487 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
489 // drag around.. - reorder..
490 this.get('/LeftTree.model').moveNode(this.targetData, ctx.action);
494 //Seed.print(this.targetData);
500 // we can send stuff to souce here...
506 if (dnd_success == false)
508 Seed.print ("DnD data transfer failed!\n");
511 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
514 "cursor_changed":function (self) {
515 if (this.blockChanges) {
518 var iter = new Gtk.TreeIter();
520 if (this.selection.count_selected_rows() < 1) {
521 this.get('/LeftPanel.model').load( false);
522 this.get('/MidPropTree').activeElement = false;
523 this.get('/MidPropTree').hideWin();
525 var pm = this.get('/RightPalete.model');
526 if (!this.get('/LeftTree').getPaleteProvider()) {
527 // it may not be loaded yet..
530 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
531 this.get('/LeftTree.model').listAllTypes()));
536 //console.log('changed');
537 var s = this.selection;
538 s.get_selected(this.get('/LeftTree.model').el, iter);
542 value = new GObject.Value('');
543 this.get('/LeftTree.model').el.get_value(iter, 2, value);
544 this.get('/LeftTree.model').activePath = this.get('/LeftTree.model').el.get_path(iter).to_string();
546 var data = JSON.parse(value.value);
547 this.get('/MidPropTree').activeElement = data;
548 this.get('/MidPropTree').hideWin();
549 this.get('/LeftPanel.model').load( data);
551 console.log(value.value);
552 // _g.button.set_label(''+value.get_string());
554 var pm =this.get('/RightPalete.model');
555 pm.load( this.get('/RightPalete').provider.gatherList(
556 this.get('/LeftTree.model').listAllTypes()));
561 //Seed.print( value.get_string());
568 xtype: Gtk.TreeStore,
572 XObject.prototype.init.call(this);
573 this.el.set_column_types ( 3, [
574 GObject.TYPE_STRING, // title
575 GObject.TYPE_STRING, // tip
576 GObject.TYPE_STRING // source..
580 changed : function(n, refresh) {
581 print("MODEL CHANGED CALLED" + this.activePath);
582 if (this.activePath) {
583 var iter = new Gtk.TreeIter();
584 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath))
585 this.el.set_value(iter, 0, [GObject.TYPE_STRING, this.nodeTitle(n)]);
586 this.el.set_value(iter, 1, [GObject.TYPE_STRING, this.nodeTitle(n)]);
588 this.el.set_value(iter, 2, [GObject.TYPE_STRING, this.nodeToJSON(n)]);
590 //this.currentTree = this.toJS(false, true)[0];
591 this.file.items = this.toJS(false, false);
592 print("AFTER CHANGED");
593 //console.dump(this.file.items);
595 this.currentTree = this.file.items[0];
596 //console.log(this.file.toSource());
599 print("REDNER BROWSER?!");
600 this.get('/LeftTree').renderView();
602 var pm = this.get('/RightPalete.model');
603 if (!this.get('/RightPalete').provider) {
609 pm.load( this.get('/RightPalete').provider.gatherList(this.listAllTypes()));
610 //imports['Builder/RightBrowser.js'].renderJS(this.toJS());
614 loadFile : function(f) {
620 console.log('missing file');
624 // load the file if not loaded..
625 if (f.items === false) {
627 f.loadItems(function() {
633 if (f.items.length && typeof(f.items[0]) == 'string') {
635 this.get('/RightEditor').el.show();
636 this.get('/RightEditor.view').load( f.items[0]);
640 //console.dump(f.items);
642 this.get('/LeftTree.view').el.expand_all();
644 if (!f.items.length) {
647 this.get('/Window.leftvpaned').el.set_position(80);
649 this.get('/LeftTree.view').el.set_cursor(
650 new Gtk.TreePath.from_string('0'), null, false);
654 this.get('/Window.leftvpaned').el.set_position(200);
658 //print("hide right editior");
659 this.get('/RightEditor').el.hide();
660 //print("set current tree");
661 this.currentTree = this.toJS(false, false)[0];
662 //console.dump(this.currentTree);
663 this.currentTree = this.currentTree || { items: [] };
664 this.get('/LeftTree').renderView();
665 //console.dump(this.map);
666 //var RightPalete = imports.Builder.RightPalete.RightPalete;
667 var pm = this.get('/RightPalete.model');
670 this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
672 if (!this.get('/RightPalete').provider) {
673 print ("********* PALETE PROVIDER MISSING?!!");
675 this.get('/LeftTree').renderView();
677 pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
681 this.get('/Window.view-notebook').el.set_current_page(
682 this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
685 findDropNode : function(treepath_str, targets) {
687 // this is used by the dragdrop code in the roo version AFAIR..
689 var path = treepath_str.replace(/^builder-/, '');
690 // treemap is depreciated... - should really check if model has any entries..
692 if (!this.el.iter_n_children(null)) {
694 return [ '', Gtk.TreeViewDropPosition.INTO_OR_AFTER];
696 print("FIND treepath: " + path);
697 //console.dump(this.treemap);
699 if (!treepath_str.match(/^builder-/)) {
700 return []; // nothing!
702 if (targets === true) {
705 return this.findDropNodeByPath(path,targets)
707 findDropNodeByPath : function(treepath_str, targets, pref) {
708 var path = treepath_str + ''; // dupe it..
709 pref = typeof(pref) == 'undefined' ? Gtk.TreeViewDropPosition.INTO_OR_AFTER : pref;
711 //console.dump(this.treemap);
712 while (path.length) {
713 print("LOOKING FOR PATH: " + path);
714 var node_data = this.singleNodeToJS(path);
715 if (node_data === false) {
716 print("node not found");
720 var xname = this.get('/LeftTree.model').file.guessName(node_data);
723 targets.forEach(function(tg) {
727 if ((tg == xname) ) {
730 if (tg.indexOf(xname +':') === 0) {
732 prop = tg.split(':').pop();
737 if (last) { // pref is after/before..
738 // then it's after last
740 return []; // do not allow..
742 return [ last, pref , prop];
745 return [ path , Gtk.TreeViewDropPosition.INTO_OR_AFTER , prop];
747 var par = path.split(':');
750 path = par.join(':');
756 dropNode : function(target_data, node) {
759 console.dump(target_data);
760 var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
762 print("add " + tp + "@" + target_data[1] );
765 if (tp && target_data[1] < 2) { // before or after..
766 var ar = target_data[0].split(':');
768 parent = new Gtk.TreePath.from_string( ar.join(':') );
771 var n_iter = new Gtk.TreeIter();
772 var iter_par = new Gtk.TreeIter();
773 var iter_after = after ? new Gtk.TreeIter() : false;
777 if (parent !== false) {
778 this.el.get_iter(iter_par, parent);
785 print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
786 this.el.get_iter(iter_after, after);
787 this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
788 n_iter, iter_par, iter_after);
791 this.el.append(n_iter, iter_par);
795 if (typeof(node) == 'string') {
796 var ar = node.split('.');
797 var xtype = ar.pop();
800 '|xns' : ar.join('.'),
803 if (target_data.length == 3 && target_data[2].length) {
804 node['*prop'] = target_data[2];
808 // work out what kind of packing to use..
809 if (typeof(node.pack) == 'undefined' && parent !== false) {
810 var pal = this.get('/LeftTree').getPaleteProvider();
812 var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
813 print ("PNAME : " + pname);
814 var cname = pal.guessName(node);
815 print ("CNAME : " + cname);
816 node.pack = pal.getDefaultPack(pname, cname);
827 // load children - if it has any..
830 this.load(xitems, n_iter);
832 if (tp && (xitems || after)) {
833 this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
835 // wee need to get the empty proptypes from somewhere..
837 //var olditer = this.activeIter;
838 this.activePath = this.el.get_path(n_iter).to_string();
840 // changed actually set's the node data..
841 this.changed(node, true);
845 this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
847 //Builder.MidPropTree._model.load(node);
848 //Builder.MidPropTree._win.hideWin();
849 //Builder.LeftPanel._model.load( node);
853 moveNode : function(target_data, action) {
854 //print("MOVE NODE");
855 // console.dump(target_data);
856 var old_iter = new Gtk.TreeIter();
857 var s = this.get('/LeftTree.view').selection;
858 s.get_selected(this.el, old_iter);
859 var node = this.nodeToJS(old_iter,false);
860 //console.dump(node);
863 // needs to drop first, otherwise the target_data
864 // treepath will be invalid.
866 this.dropNode(target_data, node);
867 if (action & Gdk.DragAction.MOVE) {
868 // print("REMOVING OLD NODE");
869 this.el.remove(old_iter);
873 this.activePath= false;
874 this.changed(false,true);
876 deleteSelected : function() {
877 this.get('/LeftTree.view').blockChanges = true;
878 var old_iter = new Gtk.TreeIter();
879 var s = this.get('/LeftTree.view').selection;
880 s.get_selected(this.el, old_iter);
881 var path = this.el.get_path(old_iter).to_string();
883 this.activePath= false;
886 this.activePath= false;
887 var iter = new Gtk.TreeIter();
888 this.el.get_iter_from_string(iter, path);
889 this.el.remove(iter);
891 // rebuild treemap. -- depreciated.!!
894 //this.toJS(null, true) // does not do anything?
895 this.activePath= false;
896 this.changed(false,true);
897 this.get('/LeftTree.view').blockChanges = false;
900 listAllTypes : function() {
901 var s = this.get('/LeftTree.view').selection;
902 print ("LIST ALL TYPES: " + s.count_selected_rows() );
904 if (s.count_selected_rows() > 0) {
905 var iter = new Gtk.TreeIter();
906 s.get_selected(this.el, iter);
908 // set some properties of the tree for use by the dropped element.
909 var value = new GObject.Value('');
910 this.el.get_value(iter, 2, value);
911 var data = JSON.parse(value.value);
914 var xname = this.get('/LeftTree.model').file.guessName(data);
915 console.log('selected:' + xname);
919 return []; // could not find it..
927 li.forEach(function(el) {
928 // this is specific to roo!!!?
930 var fullpath = _this.file.guessName(el);
931 if (fullpath.length && ret.indexOf(fullpath) < 0) {
936 if (el.items && el.items.length) {
945 addall([this.currentTree]);
947 // only if we have nothing, should we add '*top'
951 //console.log('all types in tree');
957 singleNodeToJS : function (treepath)
959 var iter = new Gtk.TreeIter();
960 if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
964 var iv = this.getIterValue(iter, 2);
966 return JSON.parse(iv);
969 nodeToJS : function (iter, with_id)
971 var par = new Gtk.TreeIter();
972 var iv = this.getIterValue(iter, 2);
974 var k = JSON.parse(iv);
975 if (k.json && !this.el.iter_parent( par, iter )) {
980 var treepath_str = this.el.get_path(iter).to_string();
981 // not sure how we can handle mixed id stuff..
982 if (typeof(k.id) == 'undefined') {
983 k.id = 'builder-'+ treepath_str ;
987 this.treemap[ treepath_str ] = k;
988 k.xtreepath = treepath_str ;
991 if (this.el.iter_has_child(iter)) {
992 citer = new Gtk.TreeIter();
993 this.el.iter_children(citer, iter);
994 k.items = this.toJS(citer,with_id);
998 toJS : function(iter, with_id)
1000 //Seed.print("WITHID: "+ with_id);
1007 iter = new Gtk.TreeIter();
1008 if (!this.el.get_iter_first(iter)) {
1018 var k = this.nodeToJS(iter, with_id);
1022 if (!this.el.iter_next(iter)) {
1028 // convert the list into a json string..
1032 getIterValue : function (iter, col) {
1033 var gval = new GObject.Value('');
1034 this.el.get_value(iter, col ,gval);
1039 nodeTitle : function(c) {
1042 var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
1043 if (sr) txt.push('<s>');
1044 if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
1045 if (c.xtype) { txt.push(c.xtype); }
1046 if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
1047 if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
1048 if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
1051 if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
1052 if (c.title) { txt.push('<b>' + c.title + '</b>'); }
1053 if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
1054 if (c.header) { txt.push('<b>' + c.header + '</b>'); }
1055 if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
1056 if (c.text) { txt.push('<b>' + c.text + '</b>'); }
1057 if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
1058 if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
1059 if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
1061 // for flat classes...
1062 if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
1063 if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
1066 if (sr) txt.push('</s>');
1067 return (txt.length == 0 ? "Element" : txt.join(" "));
1069 nodeToJSON : function(c) {
1077 return JSON.stringify(o);
1079 load : function(tr,iter)
1081 var citer = new Gtk.TreeIter();
1082 //this.insert(citer,iter,0);
1083 for(var i =0 ; i < tr.length; i++) {
1085 this.el.insert(citer,iter,-1);
1087 this.el.append(citer);
1090 this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1091 this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
1092 this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
1093 if (tr[i].items && tr[i].items.length) {
1094 this.load(tr[i].items, citer);
1100 xtype: Gtk.TreeViewColumn,
1101 pack : "append_column",
1103 XObject.prototype.init.call(this);
1104 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1108 xtype: Gtk.CellRendererText,
1118 id : "LeftTreeMenu",
1121 xtype: Gtk.MenuItem,
1123 label : "Delete Element",
1125 "activate":function (self) {
1127 this.get('/LeftTree.model').deleteSelected();
1138 id : "LeftProjectTree",
1139 showNoProjectSelected : function() {
1140 this.get('/StandardErrorDialog').show("Select a Project first.");
1142 getActiveProject : function() {
1143 return this.project;
1146 "leave_notify_event":function (self, event) {
1153 pack : "pack_start,false,false",
1156 xtype: Gtk.ComboBox,
1159 XObject.prototype.init.call(this);
1160 this.el.add_attribute(this.get('render').el , 'markup', 1 );
1162 getValue : function() {
1163 var ix = this.el.get_active();
1167 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1168 if (typeof(data[ix]) == 'undefined') {
1173 setValue : function(fn)
1177 var data = imports.Builder.Provider.ProjectManager.ProjectManager.projects;
1178 data.forEach(function(n, ix) {
1186 "changed":function (self) {
1187 var fn = this.getValue();
1188 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1189 this.get('/LeftProjectTree.model').loadProject(pm.getByFn(fn))
1194 xtype: Gtk.CellRendererText,
1195 pack : "pack_start,true",
1199 xtype: Gtk.ListStore,
1202 XObject.prototype.init.call(this);
1203 this.el.set_column_types ( 2, [
1204 GObject.TYPE_STRING, // real key
1205 GObject.TYPE_STRING // real type
1209 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
1211 pm.on('changed', function() {
1212 print("caught changed hook on project manager - reloading data");
1213 _this.loadData(pm.projects);
1217 loadData : function(data) {
1218 var ov = this.get('/LeftProjectTree.combo').getValue();
1220 var iter = new Gtk.TreeIter();
1222 data.forEach(function(p) {
1227 el.set_value(iter, 0, p.fn);
1228 el.set_value(iter, 1, p.name);
1232 this.get('/LeftProjectTree.combo').setValue(ov);
1241 xtype: Gtk.ScrolledWindow,
1243 shadow_type : Gtk.ShadowType.IN,
1245 XObject.prototype.init.call(this);
1246 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC );
1250 xtype: Gtk.TreeView,
1251 headers_visible : false,
1252 enable_tree_lines : true,
1255 XObject.prototype.init.call(this);
1256 var description = new Pango.FontDescription.c_new();
1257 description.set_size(8000);
1258 this.el.modify_font(description);
1260 this.selection = this.el.get_selection();
1261 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1265 "cursor_changed":function (self) {
1266 var iter = new Gtk.TreeIter();
1268 if (this.selection.count_selected_rows() < 1) {
1269 //XN.get('Builder.LeftTree.model').
1270 this.get('/LeftTree.model').load( false);
1274 var model = this.get('/LeftProjectTree.model');
1275 //console.log('changed');
1276 var s = this.selection;
1277 s.get_selected(model, iter);
1278 value = new GObject.Value('');
1279 model.el.get_value(iter, 2, value);
1281 console.log(value.value);// id..
1283 var file = this.get('/LeftProjectTree').project.getById(value.value);
1290 var nb = this.get('/LeftTopPanel.expander');
1291 nb.el.expanded = false;
1292 nb.listeners.activate.call(nb);
1293 //_expander.el.set_expanded(false);
1295 var ltm = this.get('/LeftTree.model');
1303 xtype: Gtk.TreeStore,
1307 XObject.prototype.init.call(this);
1308 this.el.set_column_types ( 3, [
1309 GObject.TYPE_STRING, // title
1310 GObject.TYPE_STRING, // tip
1311 GObject.TYPE_STRING // id..
1315 loadProject : function(pr) {
1320 this.get('/LeftProjectTree').project = pr;
1321 this.load(pr.toTree());
1322 this.get('/LeftProjectTree.view').el.expand_all();
1324 load : function(tr,iter) {
1326 console.log('Project tree load: ' + tr.length);
1327 var citer = new Gtk.TreeIter();
1328 //this.insert(citer,iter,0);
1331 tr.forEach(function (r) {
1333 _this.el.append(citer);
1335 _this.el.insert(citer,iter,-1);
1337 _this.el.set_value(citer, 0, '' + r.getTitle() ); // title
1338 _this.el.set_value(citer, 1, '' + r.getTitleTip()); // tip
1339 _this.el.set_value(citer, 2, '' + r.id ); //id
1340 if (r.cn && r.cn.length) {
1341 _this.load(r.cn, citer);
1346 getValue : function(iter, col) {
1347 var gval = new GObject.Value('');
1348 this.el.get_value(iter, col ,gval);
1349 return '' + gval.value;
1353 xtype: Gtk.TreeViewColumn,
1354 pack : "append_column",
1356 XObject.prototype.init.call(this);
1357 this.el.add_attribute(this.items[0].el , 'markup', 0 );
1361 xtype: Gtk.CellRendererText,
1384 pack : "pack_start,false,true,0",
1391 "button_press_event":function (self, event) {
1392 this.get('/MidPropTree.model').showData('props');
1404 stock : Gtk.STOCK_ADD,
1405 icon_size : Gtk.IconSize.MENU
1420 "button_press_event":function (self, event) {
1421 this.get('/MidPropTree.model').showData('events');
1433 stock : Gtk.STOCK_ADD,
1434 icon_size : Gtk.IconSize.MENU
1449 "button_press_event":function (self, ev) {
1450 var p = this.get('/AddPropertyPopup');
1454 p.el.set_screen(Gdk.Screen.get_default());
1456 p.el.popup(null, null, null, null, 3, ev.button.time);
1468 stock : Gtk.STOCK_ADD,
1469 icon_size : Gtk.IconSize.MENU
1481 id : "AddPropertyPopup",
1484 xtype: Gtk.MenuItem,
1486 tooltip_markup : "Using this.get('*someid') will find any id in an application.",
1489 "activate":function (self) {
1491 this.get('/LeftPanel.model').add( {
1502 xtype: Gtk.MenuItem,
1504 tooltip_markup : "Add what type of packing is to be used",
1507 "activate":function (self) {
1509 this.get('/LeftPanel.model').add( {
1519 xtype: Gtk.MenuItem,
1521 tooltip_markup : "Override the init method",
1524 "activate":function (self) {
1526 this.get('/LeftPanel.model').add( {
1529 val : "function() {\n XObject.prototype.init.call(this);\n}\n",
1536 xtype: Gtk.SeparatorMenuItem,
1540 xtype: Gtk.MenuItem,
1542 tooltip_markup : "Add a user defined string property",
1545 "activate":function (self) {
1547 this.get('/LeftPanel.model').add( {
1557 xtype: Gtk.MenuItem,
1559 tooltip_markup : "Add a user defined number property",
1562 "activate":function (self) {
1564 this.get('/LeftPanel.model').add( {
1574 xtype: Gtk.MenuItem,
1576 tooltip_markup : "Add a user defined boolean property",
1579 "activate":function (self) {
1581 this.get('/LeftPanel.model').add( {
1591 xtype: Gtk.SeparatorMenuItem,
1595 xtype: Gtk.MenuItem,
1597 tooltip_markup : "Add a user function boolean property",
1600 "activate":function (self) {
1602 this.get('/LeftPanel.model').add( {
1605 val : "function() {\n \n}\n",
1618 xtype: Gtk.ScrolledWindow,
1621 shadow_type : Gtk.ShadowType.IN,
1624 XObject.prototype.init.call(this);
1625 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
1629 xtype: Gtk.TreeView,
1632 headers_visible : false,
1633 enable_tree_lines : true,
1635 XObject.prototype.init.call(this);
1637 this.selection = this.el.get_selection();
1638 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
1641 var description = new Pango.FontDescription.c_new();
1642 description.set_size(8000);
1643 this.el.modify_font(description);
1646 "button_press_event":function (self, ev) {
1650 if (!this.el.get_path_at_pos(ev.button.x,ev.button.y, res)) {
1651 return false; //not on a element.
1655 if (ev.type != Gdk.EventType.BUTTON_PRESS || ev.button.button != 3) {
1657 if (res.column.title != 'value') {
1658 return false; // ignore..
1660 if ( this.get('/LeftPanel').editing) {
1663 var renderer = this.get('/LeftPanel').editableColumn.items[0].el; // set has_entry..
1664 this.get('/LeftPanel').editableColumn.items[0].el.stop_editing();
1665 var type = this.get('/LeftPanel.model').getType(res.path.to_string());
1669 var provider = this.get('/LeftTree').getPaleteProvider();
1671 var opts = provider.findOptions(type);
1673 if (opts === false) {
1674 this.get('/LeftPanel').editableColumn.setOptions([]);
1675 renderer.has_entry = true;
1677 LeftPanel.editableColumn.setOptions(opts);
1678 renderer.has_entry = false;
1682 //Seed.print("click" + ev.type);
1683 //console.dump(res);
1689 if (res.column.title == 'value') {
1692 //if (! this.get('/LeftPanelPopup')LeftPanelPopup.el) LeftPanelPopup.init();
1693 var p = this.get('/LeftPanelPopup');
1698 p.el.set_screen(Gdk.Screen.get_default());
1700 p.el.popup(null, null, null, null, 3, ev.button.time);
1701 //Seed.print("click:" + res.column.title);
1709 xtype: Gtk.TreeStore,
1713 XObject.prototype.init.call(this);
1714 this.el.set_column_types ( 5, [
1715 GObject.TYPE_STRING, // 0 real key
1716 GObject.TYPE_STRING, // 1 real value
1717 GObject.TYPE_STRING, // 2 visable key
1718 GObject.TYPE_STRING, // 3 visable value
1719 GObject.TYPE_STRING, // 4 need to store type of!!!
1723 toShort : function(str) {
1724 var a = typeof(str) == 'string' ? str.split("\n") : [];
1725 return a.length > 1 ? a[0] + '....' : '' + str;
1727 load : function(ar) {
1730 this.get('/RightEditor').el.hide();
1737 var provider = this.get('/LeftTree').getPaleteProvider();
1740 var iter = new Gtk.TreeIter();
1742 if (typeof(ar[i]) == 'object') {
1746 var type = provider.findType(ar, i, ar[i]);
1748 this.el.append(iter);
1749 var p = this.el.get_path(iter).to_string();
1751 this.el.set_value(iter, 0, i);
1752 this.el.set_value(iter, 1, '' + ar[i]);
1753 this.el.set_value(iter, 2, i);
1754 this.el.set_value(iter, 3, this.toShort(ar[i]));
1755 this.el.set_value(iter, 4, type);
1757 ar.listeners = ar.listeners || {};
1758 for (var i in ar.listeners ) {
1759 this.el.append(iter);
1760 var p = this.el.get_path(iter).to_string();
1763 this.el.set_value(iter, 0, '!'+ i );
1764 this.el.set_value(iter, 1, '' + ar.listeners[i]);
1765 this.el.set_value(iter, 2, '<b>'+ i + '</b>');
1767 this.el.set_value(iter, 3, '' + this.toShort(ar.listeners[i]));
1768 this.el.set_value(iter, 4, 'function');
1772 add : function(info) {
1773 // info includes key, val, skel, etype..
1775 type = info.type.toLowerCase();
1776 var data = this.toJS();
1778 if (info.etype == 'events') {
1779 data.listeners = data.listeners || { };
1780 if (typeof(data.listeners[info.key]) != 'undefined') {
1781 return; //already set!
1784 if (typeof(data[info.key]) != 'undefined') {
1789 if (typeof(info.val) == 'undefined') {
1792 if (info.type == 'boolean') {
1795 if (type == 'number') {
1803 if (info.etype == 'events') {
1805 data.listeners[info.key] = info.val;
1808 data[info.key] = info.val;
1812 var map = this.load(data);
1814 // flag it as changed to the interface..
1816 this.get('/LeftTree.model').changed(data, true);
1819 this.startEditing(map[k]);
1822 LeftPanel.get('view').el.row_activated(
1823 new Gtk.TreePath.from_string(map[k]),
1824 LeftPanel.editableColumn.el
1828 startEditing : function(path,col) {
1830 * start editing path (or selected if not set..)
1831 * @param {String|false} path (optional) treepath to edit - selected tree gets
1832 * edited by default.
1833 * @param {Number} 0 or 1 (optional)- column to edit.
1836 if (typeof(path) == 'string') {
1837 tp = new Gtk.TreePath.from_string(path);
1839 var iter = new Gtk.TreeIter();
1840 var s = this.get('/LeftPanel.view').selection;
1841 s.get_selected(this.el, iter);
1842 tp = this.el.get_path(iter);
1843 path = tp.to_string();
1847 // which colum is to be edited..
1849 if (typeof(col) == 'undefined') {
1850 var k = this.getValue(path, 0);
1851 colObj = (!k.length || k == '|') ?
1852 this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
1854 colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
1857 // make sure the pulldown is set correctly..
1858 // not really needed for second col...
1860 var provider = this.get('/LeftTree').getPaleteProvider();
1862 var type = this.get('/LeftPanel.model').getType(path);
1863 var opts = provider.findOptions(type);
1864 var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
1866 if (opts === false) {
1867 this.get('/LeftPanel').editableColumn.setOptions([]);
1868 renderer.has_entry = true; /// probably does not have any effect.
1870 this.get('/LeftPanel').editableColumn.setOptions(opts);
1871 renderer.has_entry = false;
1875 // iter now has row...
1876 GLib.timeout_add(0, 100, function() {
1878 colObj.items[0].el.editable = true; // esp. need for col 0..
1879 _this.get('/LeftPanel.view').el.set_cursor_on_cell(
1888 deleteSelected : function() {
1889 var data = this.toJS();
1890 var iter = new Gtk.TreeIter();
1891 var s = this.get('/LeftPanel.view').selection;
1892 s.get_selected(this.el, iter);
1895 var gval = new GObject.Value('');
1896 this.get('/LeftPanel.model').el.get_value(iter, 0 ,gval);
1898 var val = gval.value;
1899 if (val[0] == '!') {
1901 if (!data.listeners || typeof(data.listeners[ val.substring(1)]) == 'undefined') {
1904 delete data.listeners[ val.substring(1)];
1905 if (!XObject.keys(data.listeners).length) {
1906 delete data.listeners;
1910 if (typeof(data[val]) == 'undefined') {
1918 this.get('/LeftTree.model').changed(data, true);
1922 changed : function(str, doRefresh) {
1923 if (!this.activePath) {
1926 var iter = new Gtk.TreeIter();
1927 this.el.get_iter(iter, new Gtk.TreePath.from_string(this.activePath));
1929 this.el.set_value(iter, 1, '' +str);
1930 this.el.set_value(iter, 3, '' + this.toShort(str));
1931 // update the tree...
1933 this.get('/LeftTree.model').changed(this.toJS(), doRefresh);
1936 var iter = new Gtk.TreeIter();
1937 this.get('/LeftPanel.model').el.get_iter_first(iter);
1942 var k = this.getValue(this.el.get_path(iter).to_string(), 0);
1945 ar.listeners = ar.listeners || {};
1946 ar.listeners[ k.substring(1)] = this.getValue(this.el.get_path(iter).to_string(), 1);
1949 ar[ k ] = this.getValue(this.el.get_path(iter).to_string(), 1);
1952 if (! this.get('/LeftPanel.model').el.iter_next(iter)) {
1958 //print(JSON.stringify(ar));
1962 getType : function(treepath) {
1963 return this.getValue(treepath, 4);
1965 getValue : function(treepath_str, col) {
1966 var iter = new Gtk.TreeIter();
1967 this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath_str));
1969 var gval = new GObject.Value('');
1970 this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
1971 var val = '' + gval.value;
1975 var type = this.getType(this.el.get_path(iter).to_string());
1976 //print("TYPE: " +type + " - val:" + val);
1977 switch(type.toLowerCase()) {
1981 return parseFloat(val); // Nan ?? invalid!!?
1983 return val == 'true' ? true : false;
1989 editSelected : function(e) {
1990 print("EDIT SELECTED?");
1991 var iter = new Gtk.TreeIter();
1992 var s = this.get('/LeftPanel.view').selection;
1993 s.get_selected(this.get('/LeftPanel.model').el, iter);
1994 var m = this.get('/LeftPanel.model')
1996 var gval = new GObject.Value('');
1997 this.el.get_value(iter, 0 ,gval);
1998 var val = '' + gval.value;
2000 gval = new GObject.Value('');
2001 this.el.get_value(iter, 1 ,gval);
2002 var rval = gval.value;
2003 var activePath = this.el.get_path(iter).to_string();
2004 this.activePath = activePath ;
2005 // was activeIter...
2008 var showEditor = false;
2010 if (val[0] == '!') {
2013 if (val[0] == '|') {
2014 if (rval.match(/function/g) || rval.match(/\n/g)) {
2021 this.activePath = false;
2022 GLib.timeout_add(0, 1, function() {
2023 // Gdk.threads_enter();
2024 _this.get('/BottomPane').el.show();
2025 _this.get('/RightEditor').el.show();
2026 _this.get('/RightEditor.view').load( rval );
2030 _this.activePath = activePath ;
2032 // Gdk.threads_leave();
2037 this.get('/BottomPane').el.hide();
2038 this.get('/RightEditor').el.hide();
2040 //var type = this.getValue(this.el.get_path(iter).to_string(),4);
2046 xtype: Gtk.TreeViewColumn,
2047 pack : "append_column",
2049 XObject.prototype.init.call(this);
2051 this.el.add_attribute(this.items[0].el , 'markup', 2 );
2052 this.get('/LeftPanel').propertyColumn = this;
2057 xtype: Gtk.CellRendererText,
2058 pack : "pack_start",
2060 "editing_started":function (self, editable, path) {
2062 this.get('/LeftPanel.model').activePath = path;
2065 "edited":function (self, object, p0) {
2066 var model = this.get('/LeftPanel.model');
2067 var path = model.activePath;
2068 var iter = new Gtk.TreeIter();
2069 model.el.get_iter(iter, new Gtk.TreePath.from_string(path));
2070 model.el.set_value(iter, 0, p0);
2071 model.el.set_value(iter, 2, p0);
2073 model.activePath = false;
2075 this.get('/LeftTree.model').changed(model.toJS(), true);
2076 this.el.editable = false;
2083 xtype: Gtk.TreeViewColumn,
2084 pack : "append_column",
2086 XObject.prototype.init.call(this);
2087 this.el.add_attribute(this.items[0].el , 'text', 3 );
2088 this.el.add_attribute(this.items[0].el , 'sensitive', 3 );
2089 this.el.add_attribute(this.items[0].el , 'editable', 3 );
2090 // this.el.set_cell_data_func(cell, age_cell_data_func, NULL, NULL);
2092 this.get('/LeftPanel').editableColumn= this;
2094 setOptions : function(ar) {
2095 var m = this.items[0].el.model;
2097 var iter = new Gtk.TreeIter();
2098 ar.forEach(function(i) {
2101 m.set_value(iter, 0, i);
2107 xtype: Gtk.CellRendererCombo,
2108 pack : "pack_start",
2113 XObject.prototype.init.call(this);
2114 this.el.model = new Gtk.ListStore();
2115 this.el.model.set_column_types ( 1, [
2116 GObject.TYPE_STRING // 0 real key
2120 "edited":function (self, object, p0) {
2121 this.get('/LeftPanel').editing = false;
2122 print("EDITED? p:" + p0 + " t:" + p0);
2123 this.get('/LeftPanel.model').changed(p0, true);
2124 this.get('/LeftPanel.model').activePath = false;
2126 "editing_started":function (self, editable, path) {
2127 this.get('/LeftPanel').editing = true;
2128 // console.log('editing started');
2129 // r.has_entry = false;
2130 this.get('/LeftPanel.model').editSelected(editable);
2141 id : "LeftPanelPopup",
2144 xtype: Gtk.MenuItem,
2148 "activate":function (self) {
2149 this.get('/LeftPanel.model').deleteSelected();
2154 xtype: Gtk.MenuItem,
2158 "activate":function (self) {
2159 this.get('/LeftPanel.model').startEditing(false, 0);
2172 xtype: Gtk.ScrolledWindow,
2173 pack : "pack_end,false,true,0",
2175 shadow_type : Gtk.ShadowType.IN,
2177 XObject.prototype.init.call(this);
2178 XObject.prototype.init.call(this);
2179 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
2180 this.el.set_size_request ( 150, -1 );
2183 activeElement : false,
2184 hideWin : function() {
2191 if (this.get('/Window.left').el.position < 160) {
2194 this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
2201 xtype: Gtk.TreeView,
2202 enable_tree_lines : true,
2203 headers_visible : false,
2206 XObject.prototype.init.call(this);
2208 var description = new Pango.FontDescription.c_new();
2209 description.set_size(8000);
2210 this.el.modify_font(description);
2212 //this.selection = this.el.get_selection();
2213 // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
2222 "cursor_changed":function (self) {
2223 var iter = new Gtk.TreeIter();
2225 //console.log('changed');
2226 var m = this.get('model');
2227 if (!this.selection){
2228 this.selection = this.el.get_selection();
2231 var s = this.selection;
2232 if (!s.get_selected(m.el, iter)) {
2235 var tp = m.el.get_path(iter).to_string();
2240 var key = m.getValue(tp, 0);
2242 var type = m.getValue(tp, 1);
2243 var skel = m.getValue(tp, 3);
2244 var etype = m.getValue(tp, 5);
2247 this.get('/MidPropTree').hideWin();
2249 if (type == 'function') {
2251 if (etype != 'events') {
2255 this.get('/LeftPanel.model').add({
2264 if (type.indexOf('.') > -1 ||
2265 type == 'boolean') {
2269 this.get('/LeftPanel.model').add( {
2279 xtype: Gtk.ListStore,
2282 XObject.prototype.init.call(this);
2283 this.el.set_column_types ( 6, [
2284 GObject.TYPE_STRING, // real key
2285 GObject.TYPE_STRING, // real type
2286 GObject.TYPE_STRING, // docs ?
2287 GObject.TYPE_STRING, // visable desc
2288 GObject.TYPE_STRING, // function desc
2289 GObject.TYPE_STRING // element type (event|prop)
2293 getValue : function(treepath, col)
2295 var tp = new Gtk.TreePath.from_string (treepath);
2296 var iter = new Gtk.TreeIter();
2297 this.el.get_iter (iter, tp);
2298 var value = new GObject.Value('');
2299 this.el.get_value(iter, col, value);
2303 showData : function(type) {
2305 if (!this.get('/MidPropTree').activeElement || !type) {
2306 return; // no active element
2309 var fullpath = this.get('/LeftTree.model').file.guessName(this.get('/MidPropTree').activeElement);
2310 var palete = this.get('/LeftTree').getPaleteProvider();
2314 Seed.print('Showing right?');
2315 if (!this.get('/MidPropTree').shown) {
2317 this.get('/Window.left').el.position = this.get('/Window.left').el.position + 150;
2318 this.get('/MidPropTree').el.show();
2319 this.get('/MidPropTree').shown = true;
2322 var elementList = palete.getPropertiesFor(fullpath, type);
2323 print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
2324 // console.dump(elementList);
2327 var iter = new Gtk.TreeIter();
2328 for(var i =0 ; i < elementList.length; i++) {
2329 var p=elementList[i];
2330 this.el.append(iter);
2331 // console.log( '<b>' + p.name +'</b> ['+p.type+']');
2332 //GObject.TYPE_STRING, // real key
2333 // GObject.TYPE_STRING, // real type
2334 // GObject.TYPE_STRING, // docs ?
2335 // GObject.TYPE_STRING // func def?
2338 this.el.set_value(iter, 0, p.name);
2339 this.el.set_value(iter, 1, p.type);
2340 this.el.set_value(iter, 2, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>' + "\n" + p.desc);
2341 this.el.set_value(iter, 3, p.sig ? p.sig : '');
2342 this.el.set_value(iter, 4, '<span size="small"><b>' + p.name +'</b> ['+p.type+']</span>');
2343 this.el.set_value(iter, 5, type);
2351 xtype: Gtk.TreeViewColumn,
2353 this.el = new Gtk.TreeViewColumn();
2354 this.parent.el.append_column(this.el);
2356 XObject.prototype.init.call(this);
2357 this.el.add_attribute(this.items[0].el , 'markup', 4 );
2362 xtype: Gtk.CellRendererText,
2363 pack : "pack_start,true"
2387 xtype: Gtk.Notebook,
2388 pack : "pack_start,true,true",
2389 id : "view-help-nb",
2391 XObject.prototype.init.call(this);
2392 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Preview" }));
2393 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Help" }));
2397 xtype: Gtk.Notebook,
2399 id : "view-notebook",
2402 XObject.prototype.init.call(this);
2403 this.el.set_current_page(0);
2405 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
2406 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
2413 id : "RightBrowser",
2417 pack : "pack_start,false,true,0",
2421 pack : "pack_start,false,false,0",
2422 label : "Dump HTML to console",
2424 "activate":function (self) {
2425 this.get('/RightBrowser.view').el.execute_script(
2426 "console.log(document.body.innerHTML);");
2427 this.get('/RightBrowser.view').el.execute_script(
2428 "console.log(Builder.dump(Builder));");
2435 xtype: Gtk.ScrolledWindow,
2437 shadow_type : Gtk.ShadowType.IN,
2439 XObject.prototype.init.call(this);
2440 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2444 xtype: WebKit.WebView,
2448 XObject.prototype.init.call(this);
2449 // this may not work!?
2450 this.el.open('file:///' + __script_path__ + '/../builder.html');
2454 this.el, /* widget that will accept a drop */
2455 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2456 null, /* lists of target to support */
2457 0, /* size of list */
2458 Gdk.DragAction.COPY /* what to do with data after dropped */
2461 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2462 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2464 renderJS : function(data) {
2465 this.renderedData = data;
2466 var str = JSON.stringify(data) ;
2469 console.log('not loaded yet');
2471 Seed.print("RENDER:" + str);
2472 imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
2473 this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
2476 "load_finished":function (self, object) {
2477 if (this.ready) { // dont do it twice!
2482 this.renderJS(this.get('/LeftTree.model').toJS()[0]);
2484 "script_alert":function (self, object, p0) {
2487 return true; // do not display anything...
2489 "console_message":function (self, object, p0, p1) {
2490 console.log(object);
2491 if (!object.match(/^\{/)) {
2492 return false; // do not handle!!! -> later maybe in console..
2494 console.log(object);
2495 var val = JSON.parse(object);
2497 if (typeof(val['hover-node']) != 'undefined') {
2498 this.activeNode = val['hover-node'];
2499 console.log('active node: ' + this.activeNode);
2504 if (typeof(val['id']) != 'undefined') {
2505 // this.activeNode = val['id'];
2506 var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
2510 this.get('/LeftTree.view').selectNode(tg[0]);
2514 if (ret && typeof(val['set']) != 'undefined') {
2515 this.get('/LeftPanel.model').add({
2519 //console.log('active node: ' + this.activeNode);
2522 //Seed.print('a:'+a);
2523 //Seed.print('b:'+b);
2524 //Seed.print('c:'+c);
2527 "drag_motion":function (w, ctx, x, y, time, ud) {
2528 // console.log('DRAG MOTION');
2530 // if lastCurrentNode == this.currentNode.. -- don't change anything..
2531 this.targetData = [];
2532 this.el.execute_script("Builder.overPos(" + x +','+ y + ");");
2534 // A) find out from drag all the places that node could be dropped.
2535 var src = Gtk.drag_get_source_widget(ctx);
2536 if (!src.dropList) {
2537 Gdk.drag_status(ctx, 0, time);
2540 // b) get what we are over.. (from activeNode)
2541 // tree is empty.. - list should be correct..
2542 if (!this.get('/LeftTree.model').currentTree) {
2543 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2547 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2549 var tg = this.get('/LeftTree.model').findDropNode(this.activeNode, src.dropList);
2552 Gdk.drag_status(ctx, 0,time);
2553 this.get('/LeftTree.view').highlight(false);
2557 // if we have a target..
2558 // -> highlight it! (in browser)
2559 // -> highlight it! (in tree)
2561 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2562 this.get('/LeftTree.view').highlight(tg);
2563 this.targetData = tg;
2564 // for tree we should handle this...
2567 "drag_drop":function (w, ctx, x, y,time, ud) {
2568 print("TARGET: drag-drop");
2569 var is_valid_drop_site = true;
2574 w, /* will receive 'drag-data-received' signal */
2575 ctx, /* represents the current state of the DnD */
2576 this.get('/Window').atoms["STRING"], /* the target type we want */
2577 time /* time stamp */
2581 /* No target offered by source => error */
2584 return is_valid_drop_site;
2586 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
2588 print("Browser: drag-data-received");
2589 var delete_selection_data = false;
2590 vardnd_success = false;
2591 /* Deal with what we are given from source */
2592 if( sel_data && sel_data.length ) {
2594 if (ctx.action == Gdk.DragAction.ASK) {
2595 /* Ask the user to move or copy, then set the ctx action. */
2598 if (ctx.action == Gdk.DragAction.MOVE) {
2599 delete_selection_data = true;
2601 var source = Gtk.drag_get_source_widget(ctx);
2603 print("Browser: source.DRAGDATA? " + source.dragData);
2604 if (this.targetData) {
2605 print(this.targetData);
2606 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
2615 if (dnd_success == false)
2617 Seed.print ("DnD data transfer failed!\n");
2620 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
2632 id : "RightGtkView",
2633 renderJS : function(data, withDebug)
2638 this.withDebug = false;
2640 if (this.renderedEl) {
2641 this.get('view').el.remove(this.renderedEl);
2642 this.renderedEl.destroy();
2643 this.renderedEl = false;
2646 var tree = this.get('/LeftTree.model').toJS(false,true)[0];
2647 // in theory tree is actually window..
2649 this.renderedEl = this.viewAdd(tree.items[0], this.get('view').el);
2654 this.get('view').el.set_size_request(
2655 tree.default_width * 1 || 400, tree.default_height * 1 || 400
2658 this.renderedEl.set_size_request(
2659 tree.default_width || 600,
2660 tree.default_height || 400
2662 this.get('view').el.show_all();
2667 showInWindow : function() {
2668 print("GET PROEJCT");
2669 var pr = this.get('/LeftProjectTree').getActiveProject();
2671 console.log(pr.paths);
2674 var src= this.buildJS(
2675 this.get('/LeftTree.model').toJS()[0],
2680 //var x = new imports.sandbox.Context();
2684 Seed.check_syntax('var e = ' + src);
2687 this.get('/Terminal').feed(e.message || e.toString() + "\n");
2688 this.get('/Terminal').feed(console._dump(e)+"\n");
2690 var lines = src.split("\n");
2691 var start = Math.max(0, e.line - 10);
2692 var end = Math.min(lines.length, e.line + 10);
2693 for (var i =start ; i < end; i++) {
2695 this.get('/Terminal').feed(">>>>>" + lines[i] + "\n");
2698 this.get('/Terminal').feed(lines[i] + "\n");
2705 this.get('/BottomPane').el.set_current_page(1);
2706 this.get('/Terminal').el.fork_command( null , [], [], "/tmp", false,false,false);
2707 var cmd = "/usr/bin/seed /tmp/BuilderGtkView.js\n";
2708 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2710 var _top = x.get_global_object()._top;
2712 _top.el.set_screen(Gdk.Screen.get_default()); // just in case..
2714 if (_top.el.popup) {
2715 _top.el.popup(null, null, null, null, 3, null);
2719 viewAdd : function(item, par)
2721 // does something similar to xobject..
2722 item.pack = (typeof(item.pack) == 'undefined') ? 'add' : item.pack;
2724 if (item.pack===false || item.pack === 'false') { // no ;
2727 print("CREATE: " + item['|xns'] + '.' + item['xtype']);
2728 var ns = imports.gi[item['|xns']];
2729 var ctr = ns[item['xtype']];
2731 for(var k in item) {
2733 if (typeof(kv) == 'object' || typeof(kv) == 'function') {
2748 if (k[0] == '|' && typeof(kv) == 'string') {
2750 if (kv.match(new RegExp('function'))) {
2753 print("WASL " + k + '=' + kv);
2755 eval( 'kv = ' + kv);
2756 } catch(e) { continue; }
2759 print(k + '=' + kv);
2761 if (k[0] == '|') { // should be boolean or number..
2763 print(k + '=' + kv);
2766 if (k == 'show_tabs') { // force tab showing for notebooks.
2774 var el = new ctr(ctr_args);
2777 //console.dump(item.pack);
2784 if (typeof(item.pack) == 'string') {
2786 item.pack.split(',').forEach(function(e, i) {
2788 if (e == 'false') { args.push( false); return; }
2789 if (e == 'true') { args.push( true); return; }
2790 if (!isNaN(parseInt(e))) { args.push( parseInt(e)); return; }
2793 //print(args.join(","));
2795 pack_m = args.shift();
2797 pack_m = item.pack.shift();
2802 if (pack_m && typeof(par[pack_m]) == 'undefined') {
2804 name: "ArgumentError",
2805 message : 'pack method not available : ' + par.id + " : " + par + '.' + pack_m +
2806 "ADDING : " + item.id + " " + el
2815 //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
2816 //Seed.print('args: ' + args.length);
2818 par[pack_m].apply(par, args);
2822 item.items = item.items || [];
2823 item.items.forEach(function(ch) {
2824 _this.viewAdd(ch, el);
2829 // add the signal handlers.
2830 // is it a widget!?!!?
2836 el.signal.expose_event.connect(XObject.createDelegate(this.widgetExposeEvent, this, [ item ], true));
2837 el.signal.drag_motion.connect(XObject.createDelegate(this.widgetDragMotionEvent, this,[ item ], true));
2838 el.signal.drag_drop.connect(XObject.createDelegate(this.widgetDragDropEvent, this, [ item ], true));
2839 el.signal.button_press_event.connect(XObject.createDelegate(this.widgetPressEvent, this, [ item ], true ));
2840 el.signal.button_release_event.connect(XObject.createDelegate(this.widgetReleaseEvent, this, [ item ], true ));
2850 widgetExposeEvent : function() {
2851 /// print("WIDGET EXPOSE"); // draw highlight??
2854 widgetDragMotionEvent : function() {
2855 print("WIDGET DRAGMOTION");
2858 widgetDragDropEvent : function() {
2859 print("WIDGET DRAGDROP");
2862 widgetPressEvent : function(w,e,u,d) {
2863 if (this.get('view').pressed) {
2866 this.get('view').pressed = true;
2867 print("WIDGET PRESS " + d.xtreepath );
2868 this.get('/LeftTree.view').selectNode( d.xtreepath );
2871 widgetReleaseEvent : function() {
2872 this.get('view').pressed = false;
2878 pack : "pack_start,false,true,0",
2882 pack : "pack_start,false,false,0",
2883 label : "Run The Application",
2885 "button_press_event":function (self, event) {
2886 // call render on left tree - with special option!?!
2890 print("GET PROEJCT");
2891 var pr = this.get('/LeftProjectTree').getActiveProject();
2894 for (var i in pr.paths) {
2898 var runner = GLib.path_get_dirname (__script_path__) + '/gtkrun.js';
2899 print ("RUN DIR:" + dir);
2900 this.get('/BottomPane').el.show();
2901 this.get('/BottomPane').el.set_current_page(1);
2902 this.get('/Terminal').el.fork_command( null , [], [], GLib.path_get_dirname (__script_path__)
2903 , false,false,false);
2904 var cmd = "/usr/bin/seed " + runner + " " + dir + "\n";
2905 this.get('/Terminal').el.feed_child(cmd, cmd.length);
2915 xtype: Gtk.ScrolledWindow,
2918 shadow_type : Gtk.ShadowType.IN,
2920 XObject.prototype.init.call(this);
2921 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
2925 xtype: Gtk.EventBox,
2926 pack : "add_with_viewport",
2928 XObject.prototype.init.call(this);
2929 this.el.modify_bg(Gtk.StateType.NORMAL, new Gdk.Color({
2930 red: 0x9F00, green: 0xB800 , blue : 0xA800
2938 XObject.prototype.init.call(this);
2939 //this.el.set_hadjustment(this.parent.el.get_hadjustment());
2940 //this.el.set_vadjustment(this.parent.el.get_vadjustment());
2945 xtype: Gtk.EventBox,
2948 //this.el = new Gtk.Image.from_stock (Gtk.STOCK_HOME, Gtk.IconSize.MENU);
2949 XObject.prototype.init.call(this);
2953 this.el, /* widget that will accept a drop */
2954 Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
2955 null, /* lists of target to support */
2956 0, /* size of list */
2957 Gdk.DragAction.COPY /* what to do with data after dropped */
2960 // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
2961 Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
2964 getActiveNode : function(x,y)
2966 // workout what node is here..
2967 return '0'; // top..
2971 "drag_motion":function (self, ctx, x, y, time) {
2973 // A) find out from drag all the places that node could be dropped.
2974 var src = Gtk.drag_get_source_widget(ctx);
2975 if (!src.dropList) {
2976 Gdk.drag_status(ctx, 0, time);
2979 // b) get what we are over.. (from activeNode)
2980 // tree is empty.. - list should be correct..
2981 if (!this.get('/LeftTree.model').currentTree) {
2982 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
2986 // c) ask tree where it should be dropped... - eg. parent.. (after node ontop)
2987 var activeNode = this.getActiveNode(x, y);
2990 var tg = this.get('/LeftTree.model').findDropNode(activeNode, src.dropList);
2993 Gdk.drag_status(ctx, 0,time);
2994 this.get('/LeftTree.view').highlight(false);
2998 // if we have a target..
2999 // -> highlight it! (in browser)
3000 // -> highlight it! (in tree)
3002 Gdk.drag_status(ctx, Gdk.DragAction.COPY,time);
3003 this.get('/LeftTree.view').highlight(tg);
3004 this.targetData = tg;
3005 // for tree we should handle this...
3008 "drag_drop":function (self,ctx, x, y, time) {
3009 Seed.print("TARGET: drag-drop");
3010 var is_valid_drop_site = true;
3015 self, /* will receive 'drag-data-received' signal */
3016 ctx, /* represents the current state of the this.gDnD */
3017 this.get('/Window').atoms["STRING"], /* the target type we want */
3018 time /* time stamp */
3022 /* No target offered by source => error */
3025 return is_valid_drop_site;
3028 "drag_data_received":function (w, ctx, x, y, sel_data, target_type, time, ud)
3030 Seed.print("GtkView: drag-data-received");
3031 var delete_selection_data = false;
3032 var dnd_success = false;
3033 /* Deal with what we are given from source */
3034 if( sel_data && sel_data.length ) {
3036 if (ctx.action == Gdk.DragAction.ASK) {
3037 /* Ask the user to move or copy, then set the ctx action. */
3040 if (ctx.action == Gdk.DragAction.MOVE) {
3041 delete_selection_data = true;
3043 var source = Gtk.drag_get_source_widget(ctx);
3045 Seed.print("Browser: source.DRAGDATA? " + source.dragData);
3046 if (this.targetData) {
3047 Seed.print(this.targetData);
3048 this.get('/LeftTree.model').dropNode(this.targetData, source.dragData);
3057 if (dnd_success == false)
3059 Seed.print ("DnD data transfer failed!\n");
3062 Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
3065 "button_press_event":function (self, event) {
3066 this.pressed = false;
3082 xtype: Gtk.ScrolledWindow,
3087 xtype: WebKit.WebView,
3091 XObject.prototype.init.call(this);
3092 this.get('/Window.help-view').el.open(
3093 "http://devel.akbkhome.com/seed/");
3104 xtype: Gtk.Notebook,
3107 XObject.prototype.init.call(this);
3108 this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
3109 this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
3114 xtype: Gtk.ScrolledWindow,
3119 xtype: GtkSource.View,
3123 XObject.prototype.init.call(this);
3124 var description = Pango.Font.description_from_string("monospace")
3125 description.set_size(8000);
3126 this.el.modify_font(description);
3129 load : function(str) {
3131 // show the help page for the active node..
3132 this.get('/Window.view-help-nb').el.set_current_page(1);
3134 // get the active element being edited.
3135 var xtype = this.get('/LeftTree.model').file.guessName(
3136 this.get('/MidPropTree').activeElement);
3137 // now load the help info in the page..
3138 this.get('/Window.help-view').el.open(
3139 "http://devel.akbkhome.com/seed/" + xtype + ".html");
3142 this.get('/BottomPane').el.set_current_page(0);
3143 this.el.get_buffer().set_text(str, str.length);
3144 var lm = GtkSource.LanguageManager.get_default();
3146 this.el.get_buffer().set_language(lm.get_language('js'));
3147 var buf = this.el.get_buffer();
3148 var cursor = buf.get_mark("insert");
3149 var iter= new Gtk.TextIter;
3150 buf.get_iter_at_mark(iter, cursor);
3152 iter.set_line_offset(4);
3153 buf.move_mark(cursor, iter);
3156 cursor = buf.get_mark("selection_bound");
3157 iter= new Gtk.TextIter;
3158 buf.get_iter_at_mark(iter, cursor);
3160 iter.set_line_offset(4);
3161 buf.move_mark(cursor, iter);
3163 this.el.grab_focus();
3165 insert_spaces_instead_of_tabs : true,
3168 show_line_numbers : true,
3171 xtype: GtkSource.Buffer,
3172 pack : "set_buffer",
3174 "changed":function (self) {
3175 var s = new Gtk.TextIter();
3176 var e = new Gtk.TextIter();
3177 this.el.get_start_iter(s);
3178 this.el.get_end_iter(e);
3179 var str = this.el.get_text(s,e,true);
3181 Seed.check_syntax('var e = ' + str);
3183 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3184 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
3186 print("SYNTAX ERROR IN EDITOR");
3191 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
3192 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
3195 this.get('/LeftPanel.model').changed( str , false);
3204 xtype: Gtk.ScrolledWindow,
3208 xtype: Vte.Terminal,
3211 feed : function(str) {
3212 this.el.feed(str,str.length);
3223 pack : "pack_start,false,false",
3227 this.get('buttonbar').el.show();
3228 this.get('viewbox').el.hide();
3229 print("TRIED TO HIDE");
3232 this.get('buttonbar').el.hide();
3233 this.get('viewbox').el.show();
3234 // this.get('model').expanded();
3246 pack : "pack_start,false,true",
3248 "clicked":function (self) {
3249 this.get('/RightPalete').show();
3256 stock : Gtk.STOCK_GOTO_FIRST,
3257 icon_size : Gtk.IconSize.MENU
3267 XObject.prototype.init.call(this);
3268 this.el.add_events ( Gdk.EventMask.BUTTON_MOTION_MASK );
3271 "enter_notify_event":function (self, event) {
3272 this.get('/RightPalete').show();
3286 pack : "pack_start,false,true",
3295 pack : "pack_start,false,true",
3297 "clicked":function (self) {
3298 this.get('/RightPalete').hide();
3305 stock : Gtk.STOCK_GOTO_LAST,
3306 icon_size : Gtk.IconSize.MENU
3313 xtype: Gtk.ScrolledWindow,
3316 XObject.prototype.init.call(this);
3317 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
3318 this.el.set_size_request(-1,200);
3320 shadow_type : Gtk.ShadowType.IN,
3323 xtype: Gtk.TreeView,
3326 XObject.prototype.init.call(this);
3327 this.el.set_size_request(150,-1);
3328 // set_reorderable: [1]
3330 var description = new Pango.FontDescription.c_new();
3331 description.set_size(8000);
3332 this.el.modify_font(description);
3334 this.selection = this.el.get_selection();
3335 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
3336 // this.selection.signal['changed'].connect(function() {
3337 // _view.listeners['cursor-changed'].apply(_view, [ _view, '']);
3339 // see: http://live.gnome.org/GnomeLove/DragNDropTutorial
3341 Gtk.drag_source_set (
3342 this.el, /* widget will be drag-able */
3343 Gdk.ModifierType.BUTTON1_MASK, /* modifier that will start a drag */
3344 null, /* lists of target to support */
3345 0, /* size of list */
3346 Gdk.DragAction.COPY /* what to do with data after dropped */
3348 //Gtk.drag_source_set_target_list(this.el, LeftTree.targetList);
3350 Gtk.drag_source_set_target_list(this.el, this.get('/Window').targetList);
3351 Gtk.drag_source_add_text_targets(this.el);
3353 print("RP: TARGET:" + LeftTree.atoms["STRING"]);
3354 targets = new Gtk.TargetList();
3355 targets.add( LeftTree.atoms["STRING"], 0, 0);
3356 targets.add_text_targets( 1 );
3357 Gtk.drag_dest_set_target_list(this.el, LeftTree.targetList);
3359 //if you want to allow text to be output elsewhere..
3360 //Gtk.drag_source_add_text_targets(this.el);
3364 headers_visible : false,
3365 enable_tree_lines : true,
3367 "drag_begin":function (self, ctx) {
3368 // we could fill this in now...
3369 Seed.print('SOURCE: drag-begin');
3373 var iter = new Gtk.TreeIter();
3374 var s = this.selection;
3375 s.get_selected(this.get('/RightPalete.model').el, iter);
3376 var path = this.get('/RightPalete.model').el.get_path(iter);
3378 var pix = this.el.create_row_drag_icon ( path);
3381 Gtk.drag_set_icon_pixmap (ctx,
3388 var value = new GObject.Value('');
3389 this.get('/RightPalete.model').el.get_value(iter, 0, value);
3390 if (!this.get('/RightPalete').provider) {
3393 this.el.dropList = this.get('/RightPalete').provider.getDropList(value.value);
3394 this.el.dragData = value.value;
3401 "drag_data_get":function (self, drag_context, selection_data, info, time) {
3402 //Seed.print('Palete: drag-data-get: ' + target_type);
3403 if (this.el.dragData && this.el.dragData.length ) {
3404 selection_data.set_text(this.el.dragData ,this.el.dragData.length);
3408 //this.el.dragData = "TEST from source widget";
3412 "drag_end":function (self, drag_context) {
3413 Seed.print('SOURCE: drag-end');
3414 this.el.dragData = false;
3415 this.el.dropList = false;
3416 this.get('/LeftTree.view').highlight(false);
3422 xtype: Gtk.ListStore,
3425 XObject.prototype.init.call(this);
3426 this.el.set_column_types ( 2, [
3427 GObject.TYPE_STRING, // title
3428 GObject.TYPE_STRING // tip
3433 load : function(tr,iter)
3438 //console.log('Project tree load: ' + tr.length);
3439 var citer = new Gtk.TreeIter();
3440 //this.insert(citer,iter,0);
3441 for(var i =0 ; i < tr.length; i++) {
3444 this.el.append(citer);
3446 this.el.insert(citer,iter,-1);
3451 this.el.set_value(citer, 0, '' + r ); // title
3453 //this.el.set_value(citer, 1, new GObject.Value( r)); //id
3454 //if (r.cn && r.cn.length) {
3455 // this.load(r.cn, citer);
3461 getValue : function (iter, col) {
3462 var gval = new GObject.Value('');
3463 this.el.get_value(iter, col ,gval);
3470 xtype: Gtk.TreeViewColumn,
3471 pack : "append_column",
3473 XObject.prototype.init.call(this);
3474 this.el.add_attribute(this.items[0].el , 'markup', 0 );
3478 xtype: Gtk.CellRendererText,
3500 XObject.cache['/Window'] = Window;